SlideShare a Scribd company logo
Flag Registers
Assembly Language
Submitted To
Fahmida Afrin
Lecturer
Dept. of Computer Science &
Engineering
Daffodil International University
1
Submitted By
1. Anwar Hasan Shuvo (151-15-5506)
2. Nobanul Hasan (151-15-5035)
3. Prosenjit Roy (151-15-4810)
4. Redwan Naeem Manik (151-15-5039)
5. Md. Shamsuzzaman (151-15-4861)
What is Flag Register?
 For the 8086 processor, the processor state is implemented as nine individual bits called Flags.
 Each decision made by the 8086 is based on the values of these flags.
 The flags are placed in the FLAG registers.
 They are classified as: Status Flags or Control Flags
2
The Flags Register
 Figure: The Flags Register
The following figure manifests the Flags register.
 Status Flags in bit: 0, 2, 4, 6, 7
 Control Flags in bit: 8,9,10
Rest of the bits have no significance.
3
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
OF DF IF TF SF ZF AF PF CF
Carry Flag
 CF = 1 if there is a carry out from the most significant bit (msb) on addition, or
there Is a borrow into the msb on subtraction; [msb = most significant bit]
 Otherwise, it is 0. CF is also affected by shift and rotate Instructions.
4
Parity Flag
 PF = 1 if the low byte of a result has an even number of one bits (even parity). It
is 0 if the low byte has, odd parity. For example, if the result of a word addition
is FFFEh, then the low byte contains 7 one bits, so PF=0.
5
Auxiliary Flag
 AF = 1 if there is a carry out from bit 3 on addition, or a borrow into bit 3 on
subtraction.
 AF is used in Binary Coded Decimal (BCD) operations.
6
Signed Flag
 SF means Signed Flag
 SF = 1 if the msb of a result is 1;
it means the result is negative if you are giving a signed interpretation.
SF = 0 if the msb is 0 .
7
Zero Flag
 ZF = 1 for a zero result, and ZF = 0 for a nonzero result.
8
Overflow
Signed and unsigned overflows are independent phenomena. When we perform
an arithmetic operation such as addition, there are four possible outcomes:
 (1) no overflow,
 (2) signed overflow only,
 (3) unsigned overflow only, and
 (4) both signed and unsigned overflows.
9
Unsigned Overflow
As an example of unsigned overflow.
AX contains FFFFh, BX contains 0001 h
ADD AX,BX is executed
 If we are giving an unsigned interpretation, the correct ansis 1OOOOh =
65536, but this is out of range for a word operation. A 1 is carried out of the
msband the answer stored in AX, OOOOh, is wrong, so unsigned overflow
occurred. But the stored answer is correct as a signed number, for FFFFh= -1.
OOO1h = 1, and FFFFh+ OOO1h = -1 + 1 = 0,
10
Signed Overflow
Suppose AX and BX both contain 7FFFh,we execute
ADD AX,BX
11
 The signed and unsigned decimal interpretation of 7FFFh is32767. Thus for
both signed and unsigned addition, 7FFFh + 7FFFh = 32767 + 32767 = 65534.
 This is out of range for signed numbers; the signed interpretation of the
stored answer FFFEh is 2. so signed overflow occurred. However, the unsigned
interpretation of FFFEh is 65534, which is the right answer, so there no
How Instructions Effect The Flags 12
Example 1 13
Example 3 14
Example 2 15
16

More Related Content

What's hot

Disk structure
Disk structureDisk structure
Disk structure
Shareb Ismaeel
 
flag register of 8086
flag register of 8086flag register of 8086
flag register of 8086
asrithak
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
warda aziz
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
Sanjeev Patel
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
Mustafa Salah
 
Register introduction
Register introductionRegister introduction
Register introduction
maamir farooq
 
DMA operation
DMA operationDMA operation
DMA operation
Imran Khan
 
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
Education
 
Data link layer
Data link layer Data link layer
Data link layer
Mukesh Chinta
 
assembly flag resister
assembly flag resisterassembly flag resister
assembly flag resister
safayet hossain
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
Mazin Alwaaly
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computers
warda aziz
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of Computation
Ankur Singh
 
Direct memory access (dma)
Direct memory access (dma)Direct memory access (dma)
Direct memory access (dma)
Zubair Khalid
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
Renu Kewalramani
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 Microprocessor
Mustafa AL-Timemmie
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
Kamal Acharya
 

What's hot (20)

Assembly Language
Assembly LanguageAssembly Language
Assembly Language
 
Disk structure
Disk structureDisk structure
Disk structure
 
flag register of 8086
flag register of 8086flag register of 8086
flag register of 8086
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Register introduction
Register introductionRegister introduction
Register introduction
 
DMA operation
DMA operationDMA operation
DMA operation
 
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
 
Data link layer
Data link layer Data link layer
Data link layer
 
assembly flag resister
assembly flag resisterassembly flag resister
assembly flag resister
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computers
 
Types of Language in Theory of Computation
Types of Language in Theory of ComputationTypes of Language in Theory of Computation
Types of Language in Theory of Computation
 
Direct memory access (dma)
Direct memory access (dma)Direct memory access (dma)
Direct memory access (dma)
 
register
registerregister
register
 
Error Detection And Correction
Error Detection And CorrectionError Detection And Correction
Error Detection And Correction
 
Subroutine & string in 8086 Microprocessor
Subroutine & string in 8086 MicroprocessorSubroutine & string in 8086 Microprocessor
Subroutine & string in 8086 Microprocessor
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 

Similar to Flag Registers (Assembly Language)

Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
Jahurul Islam
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxAssembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptx
ishitasabrincse
 
Flag Register in 8086.pptx microprocessor 8085
Flag Register in 8086.pptx microprocessor 8085Flag Register in 8086.pptx microprocessor 8085
Flag Register in 8086.pptx microprocessor 8085
gaherwarsaloni1234
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
BELLALHOSSAIN31
 
Flag Register in 8086.pptx with the notenot
Flag Register in 8086.pptx with the notenotFlag Register in 8086.pptx with the notenot
Flag Register in 8086.pptx with the notenot
gaherwarsaloni1234
 
Assembly language.pptx
Assembly language.pptxAssembly language.pptx
Assembly language.pptx
ShaistaRiaz4
 
Lecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxLecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptx
ImranBhatti58
 
Flag register 8086 assignment
Flag register 8086 assignmentFlag register 8086 assignment
Flag register 8086 assignment
Zia3130
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
United International University
 
Register & flags
Register & flagsRegister & flags
Register & flags
fazli khaliq
 
Flags
FlagsFlags
FlagsCME
 
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...
Bilal Amjad
 
8086 architecture
8086 architecture8086 architecture
8086 architecture
karthiga selvaraju
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setaviban
 
126.pptx
126.pptx126.pptx
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.ppt
ssuser2b759d
 
Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)
Tish997
 
Microprocessor Based Design and operations
Microprocessor Based Design and operationsMicroprocessor Based Design and operations
Microprocessor Based Design and operations
zelalem2022
 

Similar to Flag Registers (Assembly Language) (20)

Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxAssembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptx
 
Flag Register in 8086.pptx microprocessor 8085
Flag Register in 8086.pptx microprocessor 8085Flag Register in 8086.pptx microprocessor 8085
Flag Register in 8086.pptx microprocessor 8085
 
Intel 8086
Intel 8086Intel 8086
Intel 8086
 
Flag Register in 8086.pptx with the notenot
Flag Register in 8086.pptx with the notenotFlag Register in 8086.pptx with the notenot
Flag Register in 8086.pptx with the notenot
 
Assembly language.pptx
Assembly language.pptxAssembly language.pptx
Assembly language.pptx
 
Lecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptxLecture #3 Flag Register.pptx
Lecture #3 Flag Register.pptx
 
Flag register 8086 assignment
Flag register 8086 assignmentFlag register 8086 assignment
Flag register 8086 assignment
 
Assembly language programming intro
Assembly language programming introAssembly language programming intro
Assembly language programming intro
 
Register & flags
Register & flagsRegister & flags
Register & flags
 
Flags
FlagsFlags
Flags
 
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...
 
8086 architecture
8086 architecture8086 architecture
8086 architecture
 
Flag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction setFlag registers, addressing modes, instruction set
Flag registers, addressing modes, instruction set
 
126.pptx
126.pptx126.pptx
126.pptx
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.ppt
 
Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)Assembly language (Example with mapping from C++ to Assembly)
Assembly language (Example with mapping from C++ to Assembly)
 
Microprocessor Based Design and operations
Microprocessor Based Design and operationsMicroprocessor Based Design and operations
Microprocessor Based Design and operations
 
Al2ed chapter7
Al2ed chapter7Al2ed chapter7
Al2ed chapter7
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 

More from Anwar Hasan Shuvo

Water level-detection
Water level-detectionWater level-detection
Water level-detection
Anwar Hasan Shuvo
 
Antialiasing & Its different technique
Antialiasing & Its different techniqueAntialiasing & Its different technique
Antialiasing & Its different technique
Anwar Hasan Shuvo
 
Thalassemia
ThalassemiaThalassemia
Thalassemia
Anwar Hasan Shuvo
 
Android operating system
Android operating systemAndroid operating system
Android operating system
Anwar Hasan Shuvo
 
NoSQL
NoSQLNoSQL
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
Anwar Hasan Shuvo
 

More from Anwar Hasan Shuvo (6)

Water level-detection
Water level-detectionWater level-detection
Water level-detection
 
Antialiasing & Its different technique
Antialiasing & Its different techniqueAntialiasing & Its different technique
Antialiasing & Its different technique
 
Thalassemia
ThalassemiaThalassemia
Thalassemia
 
Android operating system
Android operating systemAndroid operating system
Android operating system
 
NoSQL
NoSQLNoSQL
NoSQL
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
 

Recently uploaded

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 

Recently uploaded (20)

The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 

Flag Registers (Assembly Language)

  • 1. Flag Registers Assembly Language Submitted To Fahmida Afrin Lecturer Dept. of Computer Science & Engineering Daffodil International University 1 Submitted By 1. Anwar Hasan Shuvo (151-15-5506) 2. Nobanul Hasan (151-15-5035) 3. Prosenjit Roy (151-15-4810) 4. Redwan Naeem Manik (151-15-5039) 5. Md. Shamsuzzaman (151-15-4861)
  • 2. What is Flag Register?  For the 8086 processor, the processor state is implemented as nine individual bits called Flags.  Each decision made by the 8086 is based on the values of these flags.  The flags are placed in the FLAG registers.  They are classified as: Status Flags or Control Flags 2
  • 3. The Flags Register  Figure: The Flags Register The following figure manifests the Flags register.  Status Flags in bit: 0, 2, 4, 6, 7  Control Flags in bit: 8,9,10 Rest of the bits have no significance. 3 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 OF DF IF TF SF ZF AF PF CF
  • 4. Carry Flag  CF = 1 if there is a carry out from the most significant bit (msb) on addition, or there Is a borrow into the msb on subtraction; [msb = most significant bit]  Otherwise, it is 0. CF is also affected by shift and rotate Instructions. 4
  • 5. Parity Flag  PF = 1 if the low byte of a result has an even number of one bits (even parity). It is 0 if the low byte has, odd parity. For example, if the result of a word addition is FFFEh, then the low byte contains 7 one bits, so PF=0. 5
  • 6. Auxiliary Flag  AF = 1 if there is a carry out from bit 3 on addition, or a borrow into bit 3 on subtraction.  AF is used in Binary Coded Decimal (BCD) operations. 6
  • 7. Signed Flag  SF means Signed Flag  SF = 1 if the msb of a result is 1; it means the result is negative if you are giving a signed interpretation. SF = 0 if the msb is 0 . 7
  • 8. Zero Flag  ZF = 1 for a zero result, and ZF = 0 for a nonzero result. 8
  • 9. Overflow Signed and unsigned overflows are independent phenomena. When we perform an arithmetic operation such as addition, there are four possible outcomes:  (1) no overflow,  (2) signed overflow only,  (3) unsigned overflow only, and  (4) both signed and unsigned overflows. 9
  • 10. Unsigned Overflow As an example of unsigned overflow. AX contains FFFFh, BX contains 0001 h ADD AX,BX is executed  If we are giving an unsigned interpretation, the correct ansis 1OOOOh = 65536, but this is out of range for a word operation. A 1 is carried out of the msband the answer stored in AX, OOOOh, is wrong, so unsigned overflow occurred. But the stored answer is correct as a signed number, for FFFFh= -1. OOO1h = 1, and FFFFh+ OOO1h = -1 + 1 = 0, 10
  • 11. Signed Overflow Suppose AX and BX both contain 7FFFh,we execute ADD AX,BX 11  The signed and unsigned decimal interpretation of 7FFFh is32767. Thus for both signed and unsigned addition, 7FFFh + 7FFFh = 32767 + 32767 = 65534.  This is out of range for signed numbers; the signed interpretation of the stored answer FFFEh is 2. so signed overflow occurred. However, the unsigned interpretation of FFFEh is 65534, which is the right answer, so there no
  • 12. How Instructions Effect The Flags 12
  • 16. 16