Exercise 3      Name       ____________________   Points __/38

1. ( 9 points)    Perform the following additions involving 8-bit binary integers. Give results in the register requested and the CF, OF, SF, and ZF flag values. A solved example is given.

 

Example
 
Mov Al, 00111011B        Mov Bl, 10100111B      Mov Bh, 11010011B      Mov Ah, 00101011B
Add Al, 01011001B        Add Bl, 01110011B      Add Bh, 00001101B      Add Ah, 01111011B

 00111011             a)  10100111          b)  11010011           c)   00101011
+01011001                +01110011             +00001101               +01111011
 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=

2. ( 9 points)    Perform the following subtractions involving 8-bit binary integers by adding the two's complement of the subtrahend to the minuend. Give result in the register requested and the 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, 11110001B    Mov Ch, 01110010B          Mov Dh, 10001111B
    Sub Ah, 11110011B    Sub Ch, 11111011B          Sub Dh, 00110011B

a)     11110000        b)     01110010            c)     10001111
      -11110011              -11111011                  -01110011
 
 

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

3. ( 9 points)    Perform the following multiplication operations involving 8-bit binary integers. Give result register and OF flag value. A solved example is given.

Example
    Mov  Al, 4         Al       64        Ah = 00000001
    Mov  Cl, 64    => *Cl   =>  *4   =>   Al = 00000000
    Mul  Cl            Ax      256        OF = 1
 

a)   Mov  Al, 129       Ah =            b)   Mov  Al,  -8       Ah =
     Mov  Cl, 18        Al =                 Mov  Cl,  58       Al =
     Imul Cl            OF =                 Mul  Cl            OF =
 
 

c)   Mov  Al, -4        Ah =
     Mov  Cl, -44       Al =
     Imul Cl            OF =
 
 
 
 

 4. ( 12 points)    Perform the following division operations involving 8-bit binary integers. Give the results in binary. A solved example is given.

Example
    Mov  Ah, 1
    Mov  Al, 7           Al          65            Ah = 00000011
    Mov  Cl, 4    => Cl/ Ax   =>  4/263       =>   Al = 01000001
    Div  Cl              Ah           3

     xor  Ah, Ah                             Mov  Ah, 222
a)   Mov  Al, 49        Ah =            b)   Mov  Al,   0       Ah =
     Mov  Cl,  7        Al =                 Mov  Cl,  22       Al =
     Div  Cl                                 iDiv  Cl
 
 

c)   Mov  Al,  -5                       d)   Mov  Al, 44
     Cbw                 Ah =                Cbw                Ah =
     Mov  Cl,  1         Al =                Mov  Cl, -5        Al =
     div Cl                                  Idiv Cl


Document last modified: