Professional Documents
Culture Documents
Name :
Rizwan Ali
Roll No:
17-Arid-1395
Class:
BSCS 6c
Submitted to :
Sir Usman
Problem Descriptions
1. For each of the following instructions, give the new destination contents and
the new settings of CF, SF, ZF, PF, and OF. Suppose that the flags are initially 0 in each part of
this question.
a. ADD AX,BX where AX contains 7FFFh and BX contains 000lh
Solution:
7=0111,F=1111
0111111111111111
+0000000000000001
1000000000000000
AL=8000h
CF=0(No carry out)
SF=1
ZF=0
PF=1
OF=1(Carry in but no carry out)
00000010
AL=02h
CF=1(borrow into MSB)
SF=0
ZF=0
PF=0
OF=0(Borrow in and borrow out)
DEC AL ; AL=00h
00000000
-1
11111111
AL=FFh
CF=no effect(increment/decrement do not effect CF)
SF=1
ZF=0
PF=1
OF=0(Borrow in and borrow out)
NEG AL ; AL=7Fh
7=0111,F=1111
1’scompliment=10000000
10000000
+1
10000001
AL=81h
CF=1(result is not zero)
SF=1
ZF=0
PF=1
OF=0
AX=712Ah
BX=1ABCh
No effect at any flag
ADDAL,BL ;AL=80h,BL=FFh
10000000
+11111111
101111111
AL=17Fh
CF=1
SF=0
ZF=0
PF=0
OF=1
0000000000000000
- 1000000000000000
1000000000000000
AX=8000h
CF=1
SF=1
ZF=0
PF=1
OF=1(borrow in but not borrow out)
NEG AX ; AX=0001h
0000000000000001
1’scompliment=1111111111111110
1111111111111110
+1
1111111111111111
AX=FFFFh
CF=1(result is not 0)
SF=1
ZF=0
PF=1
OF=0
Solution:
Solution:
Let’s take an example 8Fh+C9 ;
1000 1111
+1100 1001
1 0101 1000
We can see there is a carry out of the MSB but no carry into the MSB and a
signed overflow occurred.
Remember:
Whenever there is ‘but’ in carry of MSB or borrow of MSB there is a signed overflow. And
Whenever there is an ‘and’ in carry of MSB or borrow of MSB there is no signed overflow.