Arithmetic/Conversions/Representation/Basic Assembly Language/Structure

1. (30)
     a.   What is the range of 2's complement values that can be represented in
          7 bits?


     b.   What is the range of unsigned values that can be represented in 7
          bits?


     c.   If a computer has a 7-bit address bus, what is the highest memory
          address in hexadecimal?


     d.   Represent as 7-bit 2's complement  -5610   


     e.   How many bits are required to represent -6510 in 2's complement form?


     f.   How many bits are required to represent multiplication results of two
          7-bit operands?


     g.   Of the three addressing modes, immediate, register, and
          direct, which is the most expensive in terms of processor time and
          why?



     h.   Use the data segment definition in Question 2. What is the addressing
          mode for each of the following instructions?

          Mov  eAx, Offset B   _______________

          Add  eAx, X          _______________

          Inc  eAx             _______________
               

     i.   A data bus of 32-bits is generally preferable to one of 8-bits. Why?




2.  (8)   Give the offset of each variable in the data segment starting at 00000000.

     Offset    Pseudo Operation
   
     ______    A         dword	?
     ______    Message   byte	'Welcome', 0
     ______    B         word	4 dup(127)
     ______    X         dword	8h
     Dseg      Ends
     
     
     3.(15) Use the offsets from the data segment:

     Offset    
     00000000        A      Dword     -23
     00000004        B      Dword     -4, 7, -5  
     00000010        C      Dword     15
Give the values in the eAx register after executing each of the following:
a)	mov	eAx, OFFSET B		eAx	___________
b)	mov	eSi, 8
	mov	eAx, B[ eSi ]		eAx	___________
c)	mov	eSi, 2
	mov	eAx, B[ eSi * 4 ]		eAx	___________
d)	mov	eSi, -2
	mov	eAx, C[ eSi * 4 ]		eAx	___________

4. Show the stack after the execution of the instructions at left.

Mov    eDx, 12345678h        Address Stack Before      Stack After Pushes
Mov    eBx, 56789ABCh       00000010   12341234             ________
Push   eDx          eSp->   0000000C   56785678             ________
Push   eBx                  00000008   9ABC9ABC             ________  
                            00000004   DEF0DEF0             ________     

5. Show the stack, eBx, and eDx after the execution of the instructions at left.

Mov    eDx, 0000h          Address Stack Before      Stack After Pops
Mov    eBx, 0000h          00000010   12341234             ________
Pop    eDx                 0000000C   56785678             ________     
Pop    eBx         eSp->   00000008   9ABC9ABC             ________
                           00000004   DEF0DEF0             ________
eDx = ________  
eBx = ________


6.        Determine the specified register and flag values after execution of
          each instruction sequence, (give result in binary or hexadecimal):


  a) Mov  Ah, A8h
     Mov  Al, 11101100B            
     Add  Al, 11000100B

     Ah ___________  Al ___________  CF __   SF __   OF __   ZF __


  b) Mov  Ah, A8h
     Mov  Al, 01101000B
     Sub  Al, 11011100B

     Ah ___________  Al ___________  CF __   SF __   OF __   ZF __


  c) Mov  Al, 0
     Dec  Al
  
     Al ___________  CF __   SF __   OF __   ZF __


  d) Mov  Al, 255
     Inc  Al

     Ah ___________  Al ___________  CF __   SF __   OF __   ZF __


7. (20) The following pseudo code adds an integer input to each element of array A.

Give the corresponding Assembly language algorithm. Use ReadDec for reading.
 

int N

int A[100]

void add() {

   i = 100

   do {

         A[ i ] = A[ i ] + N

   } while( --i != 0 )

}

void main() {

   N = ReadDec()

   add();

}