Exercise 3      Name       ____________________   Points __/27

1. (4 points) Perform the following arithmetic representing the numbers using 6-bits. Use two's complement representation for negative numbers. An example has been completed.

                        Binary        1's Comp      2's Comp
    -15    -001111    110000     110001
    +13  = +001101 = +001101+001101
     -2    -000010    111101     111110
 
 

a)    31                                b)    -13
     -14                                      +12
 
 

2. ( 9 points)    Perform the following additions involving 8-bit binary integers in the modulo 28 number system. Give result register and CF, OF, SF, and ZF flag values. A solved example is given.
Example

Mov Al, 00111011B        Mov Bl, 10110101B      Mov Bh, 10110011B      Mov Ah, 11101011B
Add Al, 01011001B        Add Bl, 00110011B      Add Bh, 01011011B      Add Ah, 11110010B
 00111011             a)  10110101          b)  10110011           c)   11101011
+01011001                +00110011             +01011011               +11110010
 10010100

Al=10010100              Bl=                       Bh=                 Ah=
CF=0                     CF=                       CF=                 CF=
OF=1                     OF=                       OF=                 OF=
ZF=0                     ZF=                       ZF=                 ZF=
SF=1                     SF=                       SF=                 SF=

3. ( 9 points)    Perform the following subtractions involving 8-bit binary integers in the modulo 28 number system by adding the two's complement of the subtrahend to the minuend. Give result register and CF, OF, SF, and ZF flag values. Remember that CF is complemented for subtraction. A solved example is given.

Example

Mov Ah, 00111011B
Sub Ah, 01011001B               2's Comp
                                               Ah=11100010
 00111011        59             00111011       CF=1
-01011001   =   -89     =>     +10100111       OF=0
                -30             11100010       ZF=0
                                               SF=1
    Mov Ah, 10110101B    Mov Ch, 10110011B          Mov Dh, 11101011B
    Sub Ah, 00110011B    Sub Ch, 01011011B          Sub Dh, 11110010B

a)     10110101        b)     10110011            c)     11101011
      -00110011              -01011011                  -11110010
 
 

        Ah=                   Ch=                        Dh=
        CF=                   CF=                        CF=
        OF=                   OF=                        OF=
        ZF=                   ZF=                        ZF=
        SF=                   SF=                        SF=
 

4. ( 5 points)    Determine the value of the registers. The program listing contains the offsets of the data definitions.

 00000000			.data
 00000000 41 20 41 22		byteArray   BYTE  'A', 32, 41h, 00100010b

 00000004 48 65 6C 6C 6F	helloWorld BYTE "Hello World",0
	   20 57 6F 72 6C
	   64 00

 00000010 0001 0002 0003	wordArray	WORD   1,2,3,4,5	; array of words
	   0004 0005

 0000001A 00000010 R		ptrWordArray    DWORD  wordArray

 00000000			.code
 00000000			main PROC
 00000000  BE 00000004 R		mov		eSi, OFFSET helloWorld		
 00000005  8A 06				mov		al, [eSi]			; al =        .  

 00000007  BF 00000003			mov		eDi, 3			
 0000000C  8A A7 00000004 R		mov		ah, helloWorld[ eDi ]	; ah =        .  

 00000012  8B 1D 0000001A R		mov		eBx, ptrWordArray		; eBx =       .  
 00000018  66| 8B 0B			mov		cx, [ eBx ]			; cx =        .  
					
 0000001B  66| 8B 53 04			mov		dx, [ eBx + 4]		; dx =        .  
					
					exit
 00000026			main ENDP