FA18-BCS-199
SYED KOMAIL
SECTION B
For each of the following instructions, give the new destination contents and the new
settings of CF, SF, ZF, PF, AF, and OF. Suppose that the flags are initially O in each part
al this question.
a. NEG AL where AL contains 7Fh
NEG AL ;AL=7Fh
7=111,F=1111
1 's compliment= 1000 0000
1000 0000
+1
________
1000 0001
AL=81h
CF=11 (result is not zero)
ZF=0
PF=1
OF=0
XCHG AX, BX ;
AX=1ABCh,
BX= 712A h
No effect at any flag
ADD A, BL ; AL=80h, BL=FFh
1000 0000
+11111111
101111111
AL=I7Fh
CF=1
SF=0
ZF=0
PF=0
OF=1
SUB AX, BX ; AX.000h, BX= 8000h
0000 0000 0000 0000
-1000 0000 0000 0000
1000 0000 0000 0000
AX=8000h
CF=1
SF=1
ZF=0
PF=1
OF=1(borrow in but not borrow out)
NEG AX , AX.001 h
0000 0000 00000001
l'scompliment=1111 1111 1111 1110
1111 1111 1111 1110
+1
1111 1111 1111 1111
AX=FFFFh
CF=1 (RESULT IS NOT 0)
sf=1
zF=0
pF=1
OF=0
b. XCHG AX,BX where AX contains 1ABCh and BX contains 712Ah
c. ADD AL,BL where AL contains 80h and BL contains FFh
d. SUB AX,BX where AX contains OOOOh and BX contains 8000h
e. NEG 'AX where AX contains 0001h
Suppose SUB AX, BX is executed. In each of the following parts, the first number is the
initial content of AX and the second number is the contents of BX. Give the resulting value
of AX and tell whether signed or unsigned overflow occurred.
a) 2143-1986h
2143=0010 0001 0100 0011
1986=0001 1001 1000 1101
0010 0001 0100 0011
-0001 1001 1000 1101
________________________________
0000 0111 1011 1101
AX =7BDh
Flow Set/clr reasonss
_________________________________________________________
Signed | 0 | no borrow in and out
| |
unsigned | 0 | CF=0
b) 80EEh
1986h
1000 0001 1111 1110
0001 1001 1000 0110
_____________________
0110 1000 0111 1000
AX =6878h
Flow Set/clr reasonss
_________________________________________________________
Signed | 1 | borrow out but no borr in
| |
unsigned | 0 | CF=0