0% found this document useful (0 votes)
71 views3 pages

CPU Flags and Operations Analysis

The document contains instructions and flags for operations on registers AL, AX, BX. a) NEG AL sets AL to 81h, CF to 1, others 0 b) XCHG AX,BX swaps values, no flag effects c) ADD AL,BL sets AL to 17Fh, CF to 1, others 0 except OF to 1 d) SUB AX,BX sets AX to 8000h, CF to 1, SF to 1, others 1 except OF to 1 (borrow in but not out) e) NEG AX sets AX to FFFFh, CF to 1, others 1 except OF to 0

Uploaded by

Syed Komail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views3 pages

CPU Flags and Operations Analysis

The document contains instructions and flags for operations on registers AL, AX, BX. a) NEG AL sets AL to 81h, CF to 1, others 0 b) XCHG AX,BX swaps values, no flag effects c) ADD AL,BL sets AL to 17Fh, CF to 1, others 0 except OF to 1 d) SUB AX,BX sets AX to 8000h, CF to 1, SF to 1, others 1 except OF to 1 (borrow in but not out) e) NEG AX sets AX to FFFFh, CF to 1, others 1 except OF to 0

Uploaded by

Syed Komail
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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

You might also like