SlideShare a Scribd company logo
1 of 7
Download to read offline
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

Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
Tech_MX
 

What's hot (20)

Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
 
Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
 
bubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly languagebubble sorting of an array in 8086 assembly language
bubble sorting of an array in 8086 assembly language
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
 
1D Array in Assembly Language
1D Array in Assembly Language1D Array in Assembly Language
1D Array in Assembly Language
 
Assembly Language Lecture 5
Assembly Language Lecture 5Assembly Language Lecture 5
Assembly Language Lecture 5
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...assembly language programming organization of IBM PC chapter 9 part-2(decimal...
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
 

Similar to Chapter 5The proessor status and the FLAGS registers

dd_sampleslides.ppt
dd_sampleslides.pptdd_sampleslides.ppt
dd_sampleslides.ppt
wafawafa52
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copy
mkazree
 

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

Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Logic gates
Logic gatesLogic gates
Logic gates
 
Arithmatic &Logic Unit
Arithmatic &Logic UnitArithmatic &Logic Unit
Arithmatic &Logic Unit
 
Digital-Logic40124sequential circuits logic gatepptx
Digital-Logic40124sequential circuits logic gatepptxDigital-Logic40124sequential circuits logic gatepptx
Digital-Logic40124sequential circuits logic gatepptx
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
boolean algebra exercises
boolean algebra exercisesboolean algebra exercises
boolean algebra exercises
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
 
dd_sampleslides.ppt
dd_sampleslides.pptdd_sampleslides.ppt
dd_sampleslides.ppt
 
Chp5 pic microcontroller instruction set copy
Chp5 pic microcontroller instruction set   copyChp5 pic microcontroller instruction set   copy
Chp5 pic microcontroller instruction set copy
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
 
Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
 
Week 5 - Number Systems.pdf
Week 5 - Number Systems.pdfWeek 5 - Number Systems.pdf
Week 5 - Number Systems.pdf
 
arithmetic ins in 8051
arithmetic ins in 8051arithmetic ins in 8051
arithmetic ins in 8051
 
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 

Recently uploaded

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 

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 Wardaaziz555@gmail.com
  • 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