SlideShare a Scribd company logo
2
Most read
3
Most read
5
Most read
A solution manual to
Assembly language
Programming
and the organization of
the IBM PC
Chapter 5
The processor status and the FLAGS
register
BY:- Ytha Yu & Charles Marut
prepared by :
Warda Aziz
Wardaaziz555@gmail.com
Question1:
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 ;AX=7FFFh and BX=0001h
B) SUB AL, BL ;AL=01h and BL=FFh
C) DEC AL ;AL=00h
D) NEG AL ;AL=7Fh
E) XCHG AX, BX ;AX=1ABCh, BX= 712Ah
F) ADD AL, BL ;AL=80h, BL=FFh
G) SUB AX, BX ; AX=0000h, BX= 8000h
H) NEG AX AX=0001h
ADD AX,BX ;AX=7FFFh and BX=0001h
7=0111 , F=1111
   
0111 1111 1111 1111
+0000 0000 0000 0001
1000 0000 0000 0000
AL=8000h
CF=0 (No carry out)
SF=1
ZF=0
PF=1
OF=1 (Carry in but no carry out)
SUB AL, BL ;AL=01h and BL=FFh
 
0000 0001
-1111 1111
0000 0010
AL=02h
CF=1 (borrow into MSB)
SF=0
ZF=0
PF=0
OF=0 (Borrow in and borrow out)
DEC AL ;AL=00h
 
0000 0000
-1
1111 1111
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’s compliment= 1000 0000
1000 0000
+1
1000 0001
AL=81h
CF=1(result is not zero)
SF=1
ZF=0
PF=1
OF=0
XCHG AX, BX ;AX=1ABCh, BX= 712Ah
AX=712Ah
BX=1ABCh
No effect at any flag
ADD AL, BL ;AL=80h, BL=FFh

1000 0000
+1111 1111
10111 1111
AL=17Fh
CF=1
SF=0
ZF=0
PF=0
OF=1
SUB AX, BX ; AX=0000h, 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=0001h
0000 0000 0000 0001
1’s compliment=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
Question 2:
a) Suppose that AX and BX both contains +ive numbers, and ADD
AX, BX is executed , show that there is carry into the MSB but no
carry out of the MSB if and only if, signed overflow occurs.
Solution:
As we know signed overflow occurs if and if:
 There is a carry into the MSB but no carry out of the MSB.(for addition)
 There is a carry out of the MSB but no carry into the MSB.(for addition)
 There is a borrow into the MSB but no borrow into the MSB.(for subtraction)
 There is a borrow out of the MSB but no borrow into the MSB.(for
subtraction)
So;
For the proof you can see question 3 part a and d. Here signed flow is occurred
because of a carry into the MSB but no carry out of the MSB.
Also in part e where there is no carry out and no carry in; no signed overflow
occurred.
b) Suppose that AX and BX both contains -ive numbers, and ADD
AX, BX is executed , show that there is carry out of the MSB but no
carry into the MSB if and only if, signed overflow occurs.
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.
Question 3:
Suppose ADD AX,BX is executed. In each of the following parts,
the first number being added is the 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) 512Ch + 4185h
b) FE12h + 1ACBh
c) E1E4h + DAB3h
d) 7132h + 7000h
e) 6389h + 1176h
512Ch + 4185h
  
0101 0001 0010 1100
+ 0100 0001 1000 0101
1001 0010 1011 0001
AX=92B1
Flow Set/clear reason
Signed 1 Carry in but no carry out
unsigned 0 CF=0
FE12h + 1ACBh
  
FE12= 1111 1110 0001 0010
+1ACB= 0001 1010 1100 1011
118DD= 1 0001 1000 1101 1101
AX=118DDh
Flow Set/clear reason
Signed 0 carry in and carry out
unsigned 1 CF=1
E1E4h + DAB3h
  
E1E4= 1110 0001 1110 0100
+ DAB3=1101 1010 1011 0011
1BC97 11011 1100 1001 0111
AX=BC97h ;1 will be in CF
Flow Set/clear reason
Signed 0 carry in and borrow out
unsigned 1 CF=1
7132h + 7000h

7132h= 0111 0001 0011 0010
+7000h= 0111 0000 0000 0000
E132= 1110 0001 0011 0010
Flow Set/clear reason
Signed 1 carry in but no carry out
unsigned 0 CF=0
6389h + 1176h

6389h= 0110 0011 1000 1001
+1176h= 0001 0001 0111 0110
74FF= 0111 0100 1111 1111
Flow Set/clear reason
Signed 0 No carry in, no carry out
unsigned 0 CF=0
Question 4:
Suppose SUB AX,BX is executed. In each of the following parts, the
first number being added is the 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) 2143h-1986h
b) 81FEh-1986h
c) 19BCh-81FEh
d) 0002h-FE0Fh
e) 8BCDh-71ABh
2143h-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/clear reason
Signed 0 No borrow in , no borrow
out
unsigned 0 CF=0
81FEh-1986h
 
1000 0001 1111 1110
0001 1001 1000 0110
0110 1000 0111 1000
AX=6878h
Flow Set/clear reason
Signed 1 Borrow out but no borrow
in
unsigned 0 CF=0
19BCh-81FEh
   
0001 1001 1011 1100
1000 0001 1111 1110
1001 0111 1011 1110
AX=97BEh
Flow Set/clear reason
Signed 1 Borrow in but no borrow
out
unsigned 1 CF=1
0002h-FE0Fh
   
0000 0000 0000 0010
1111 1110 0000 1111
0000 0001 1111 0011
AX=01F3h
Flow Set/clear reason
Signed 0 Borrow in and borrow out
unsigned 1 CF=1
8BCDh-71ABh
  
1000 1011 1100 1101
0111 0001 1010 1011
0001 1010 0010 0010
AX=1A22h
Flow Set/clear reason
Signed 1 Borrow out but no borrow
in
unsigned 0 CF=0

More Related Content

What's hot (20)

PDF
Solution manual of assembly language programming and organization of the ibm ...
Tayeen Ahmed
 
PDF
Assembly language (coal)
Hareem Aslam
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
PPT
Assignment on alp
Jahurul Islam
 
PPTX
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
PPT
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Frankie Jones
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
PPT
Assembly Language Basics
Education Front
 
PPT
Assembly Language Lecture 4
Motaz Saad
 
PPTX
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
PPTX
Data Manipulation Language
Jas Singh Bhasin
 
PPT
Assembly Language Lecture 1
Motaz Saad
 
PDF
Assembly language solution
Ahsan Riaz
 
PPTX
Booth’s algorithm.(a014& a015)
Piyush Rochwani
 
PPTX
stack in assembally language
Daffodil International University
 
Solution manual of assembly language programming and organization of the ibm ...
Tayeen Ahmed
 
Assembly language (coal)
Hareem Aslam
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
Assignment on alp
Jahurul Islam
 
bubble sorting of an array in 8086 assembly language
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Frankie Jones
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
Assembly Language Basics
Education Front
 
Assembly Language Lecture 4
Motaz Saad
 
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
Data Manipulation Language
Jas Singh Bhasin
 
Assembly Language Lecture 1
Motaz Saad
 
Assembly language solution
Ahsan Riaz
 
Booth’s algorithm.(a014& a015)
Piyush Rochwani
 
stack in assembally language
Daffodil International University
 

Similar to Chapter 5The proessor status and the FLAGS registers (20)

PPTX
Intel 8086
BELLALHOSSAIN31
 
PPTX
Assembly Lab Sheet 5 About Status of Flag Register.pptx
ishitasabrincse
 
PPT
Assignment on alp
Jahurul Islam
 
PDF
flag final.pdf flag final.pdf flag final.pdf
rajdeepbackup123
 
PPTX
Chapter_02_Data_Representation Yifeng Zhu
AbdulKhaliq763972
 
PPTX
Computer Science 33 - Week 02 - Discussion 2.pptx
yp6458
 
PPTX
assembly flag resister
safayet hossain
 
PDF
Notes unit 2
KamarajA5
 
PPT
how computers do math from patterson and hennessey book
eem303ds
 
PPT
Arithmetic for computers which talks about
eem303ds
 
PPTX
Hemanth143
vijaydeepakg
 
PDF
N akkk4lmealkkk3eqklaflerkpwoerkwflskkes
XA18PanktiKamleshPat
 
PPTX
Lec20
Zain Ul Abedeen
 
PPTX
Flags
CME
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
PDF
Chapter 4
EasyStudy3
 
PDF
Assignment solution-week7
PUSHPALATHAV1
 
PDF
15CS44 MP & MC Module 2
RLJIT
 
PPTX
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Shwetamaurya36
 
Intel 8086
BELLALHOSSAIN31
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
ishitasabrincse
 
Assignment on alp
Jahurul Islam
 
flag final.pdf flag final.pdf flag final.pdf
rajdeepbackup123
 
Chapter_02_Data_Representation Yifeng Zhu
AbdulKhaliq763972
 
Computer Science 33 - Week 02 - Discussion 2.pptx
yp6458
 
assembly flag resister
safayet hossain
 
Notes unit 2
KamarajA5
 
how computers do math from patterson and hennessey book
eem303ds
 
Arithmetic for computers which talks about
eem303ds
 
Hemanth143
vijaydeepakg
 
N akkk4lmealkkk3eqklaflerkpwoerkwflskkes
XA18PanktiKamleshPat
 
Flags
CME
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
Chapter 4
EasyStudy3
 
Assignment solution-week7
PUSHPALATHAV1
 
15CS44 MP & MC Module 2
RLJIT
 
Unit_3 OF COMPUTER ARCHITECTUREUnit.pptx
Shwetamaurya36
 
Ad

Recently uploaded (20)

PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PDF
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
PPTX
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
PPTX
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
PPTX
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PPTX
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
PPTX
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
PDF
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
PPTX
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
PDF
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
Inventory management chapter in automation and robotics.
atisht0104
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
AI-Driven IoT-Enabled UAV Inspection Framework for Predictive Maintenance and...
ijcncjournal019
 
Basics of Auto Computer Aided Drafting .pptx
Krunal Thanki
 
Water resources Engineering GIS KRT.pptx
Krunal Thanki
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
勉強会資料_An Image is Worth More Than 16x16 Patches
NABLAS株式会社
 
Introduction to Fluid and Thermal Engineering
Avesahemad Husainy
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
filteration _ pre.pptx 11111110001.pptx
awasthivaibhav825
 
sunil mishra pptmmmmmmmmmmmmmmmmmmmmmmmmm
singhamit111
 
CAD-CAM U-1 Combined Notes_57761226_2025_04_22_14_40.pdf
shailendrapratap2002
 
22PCOAM21 Session 1 Data Management.pptx
Guru Nanak Technical Institutions
 
settlement FOR FOUNDATION ENGINEERS.pdf
Endalkazene
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
IEEE EMBC 2025 「Improving electrolaryngeal speech enhancement via a represent...
NU_I_TODALAB
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Ad

Chapter 5The proessor status and the FLAGS registers

  • 1. A solution manual to Assembly language Programming and the organization of the IBM PC Chapter 5 The processor status and the FLAGS register BY:- Ytha Yu & Charles Marut prepared by : Warda Aziz [email protected]
  • 2. Question1: 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 ;AX=7FFFh and BX=0001h B) SUB AL, BL ;AL=01h and BL=FFh C) DEC AL ;AL=00h D) NEG AL ;AL=7Fh E) XCHG AX, BX ;AX=1ABCh, BX= 712Ah F) ADD AL, BL ;AL=80h, BL=FFh G) SUB AX, BX ; AX=0000h, BX= 8000h H) NEG AX AX=0001h ADD AX,BX ;AX=7FFFh and BX=0001h 7=0111 , F=1111     0111 1111 1111 1111 +0000 0000 0000 0001 1000 0000 0000 0000 AL=8000h CF=0 (No carry out) SF=1 ZF=0 PF=1 OF=1 (Carry in but no carry out) SUB AL, BL ;AL=01h and BL=FFh   0000 0001 -1111 1111 0000 0010 AL=02h CF=1 (borrow into MSB) SF=0 ZF=0 PF=0 OF=0 (Borrow in and borrow out) DEC AL ;AL=00h   0000 0000 -1 1111 1111 AL=FFh CF=no effect(increment/decrement do not effect CF) SF=1 ZF=0
  • 3. PF=1 OF=0 (Borrow in and borrow out) NEG AL ;AL=7Fh 7=0111, F=1111 1’s compliment= 1000 0000 1000 0000 +1 1000 0001 AL=81h CF=1(result is not zero) SF=1 ZF=0 PF=1 OF=0 XCHG AX, BX ;AX=1ABCh, BX= 712Ah AX=712Ah BX=1ABCh No effect at any flag ADD AL, BL ;AL=80h, BL=FFh  1000 0000 +1111 1111 10111 1111 AL=17Fh CF=1 SF=0 ZF=0 PF=0 OF=1 SUB AX, BX ; AX=0000h, 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=0001h 0000 0000 0000 0001 1’s compliment=1111 1111 1111 1110 1111 1111 1111 1110 +1 1111 1111 1111 1111
  • 4. AX=FFFFh CF=1(result is not 0) SF=1 ZF=0 PF=1 OF=0 Question 2: a) Suppose that AX and BX both contains +ive numbers, and ADD AX, BX is executed , show that there is carry into the MSB but no carry out of the MSB if and only if, signed overflow occurs. Solution: As we know signed overflow occurs if and if:  There is a carry into the MSB but no carry out of the MSB.(for addition)  There is a carry out of the MSB but no carry into the MSB.(for addition)  There is a borrow into the MSB but no borrow into the MSB.(for subtraction)  There is a borrow out of the MSB but no borrow into the MSB.(for subtraction) So; For the proof you can see question 3 part a and d. Here signed flow is occurred because of a carry into the MSB but no carry out of the MSB. Also in part e where there is no carry out and no carry in; no signed overflow occurred. b) Suppose that AX and BX both contains -ive numbers, and ADD AX, BX is executed , show that there is carry out of the MSB but no carry into the MSB if and only if, signed overflow occurs. 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. Question 3: Suppose ADD AX,BX is executed. In each of the following parts, the first number being added is the 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) 512Ch + 4185h b) FE12h + 1ACBh c) E1E4h + DAB3h
  • 5. d) 7132h + 7000h e) 6389h + 1176h 512Ch + 4185h    0101 0001 0010 1100 + 0100 0001 1000 0101 1001 0010 1011 0001 AX=92B1 Flow Set/clear reason Signed 1 Carry in but no carry out unsigned 0 CF=0 FE12h + 1ACBh    FE12= 1111 1110 0001 0010 +1ACB= 0001 1010 1100 1011 118DD= 1 0001 1000 1101 1101 AX=118DDh Flow Set/clear reason Signed 0 carry in and carry out unsigned 1 CF=1 E1E4h + DAB3h    E1E4= 1110 0001 1110 0100 + DAB3=1101 1010 1011 0011 1BC97 11011 1100 1001 0111 AX=BC97h ;1 will be in CF Flow Set/clear reason Signed 0 carry in and borrow out unsigned 1 CF=1 7132h + 7000h  7132h= 0111 0001 0011 0010 +7000h= 0111 0000 0000 0000 E132= 1110 0001 0011 0010 Flow Set/clear reason Signed 1 carry in but no carry out unsigned 0 CF=0 6389h + 1176h  6389h= 0110 0011 1000 1001 +1176h= 0001 0001 0111 0110 74FF= 0111 0100 1111 1111 Flow Set/clear reason Signed 0 No carry in, no carry out
  • 6. unsigned 0 CF=0 Question 4: Suppose SUB AX,BX is executed. In each of the following parts, the first number being added is the 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) 2143h-1986h b) 81FEh-1986h c) 19BCh-81FEh d) 0002h-FE0Fh e) 8BCDh-71ABh 2143h-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/clear reason Signed 0 No borrow in , no borrow out unsigned 0 CF=0 81FEh-1986h   1000 0001 1111 1110 0001 1001 1000 0110 0110 1000 0111 1000 AX=6878h Flow Set/clear reason Signed 1 Borrow out but no borrow in unsigned 0 CF=0 19BCh-81FEh     0001 1001 1011 1100 1000 0001 1111 1110 1001 0111 1011 1110 AX=97BEh Flow Set/clear reason Signed 1 Borrow in but no borrow out
  • 7. unsigned 1 CF=1 0002h-FE0Fh     0000 0000 0000 0010 1111 1110 0000 1111 0000 0001 1111 0011 AX=01F3h Flow Set/clear reason Signed 0 Borrow in and borrow out unsigned 1 CF=1 8BCDh-71ABh    1000 1011 1100 1101 0111 0001 1010 1011 0001 1010 0010 0010 AX=1A22h Flow Set/clear reason Signed 1 Borrow out but no borrow in unsigned 0 CF=0