COA Tutorial

Computer Organization and Architecture Tutorial Basic Terminologies Related to COA Digital Number System Computer Organization and Architecture Data Formats Fixed and Floating-Point Number IEEE Standard 754 Floating Point Numbers Control Unit Organization Data Path, ALU and Control Unit Micro-Operations CPU Registers Addressing Modes COA: Interrupt and its types Instruction Cycle: Computer Organization and Architecture Instruction Pipelining and Pipeline Hazards Pipelining: Computer Organization and Architecture Machine Instructions 8085 instructions set 8085 Pin Configuration Addressing mode in 8085 microprocessor Advantages and Disadvantages of Flash Memory BCD to 7 Segment Decoder Biconnectivity in a Graph Bipartite Graph CarryLook Ahead Adder Control Signals in 8155 Microprocessor Convert a number from base 2 to base 6 Ethernet Frame Format Local Broadcast Address and loopback address Microprocessor classification Use Case Diagram for the online bank system 8086 Microprocessor Pin Configurations 8255 Microprocessor Operating Modes Flag Register of 8086 Microprocessor Data Transfer and Manipulation 8085 Arithmetic Instructions Assembly Language Register What is Cache Associativity? Auxiliary Memory in COA Associative Memory in Computer Architecture SCSI Bus in Computer Architecture What are Registers in Microprocessor What is Associative Memory 1 Persistent CSMA What is Floating-Point Representation in Computer Architecture? What is a Serial Port in a Computer? What is Cluster Computing What is Batch Processing in Computer Advantages of Client Server Architecture Spooling Meaning in Computer System Magnetic Core Memory Magnetic Ink Card Reader Decision Making Tools and Techniques Digital Electronics using Semiconductor Memory What is Internal Chip Organization in Computer Architecture? What is Hardwired Control Unit? Definition of Diodes in Electronics Advantages of FSK Web Server Architecture How the OS interfaces between the user, apps, hardware? Discuss the I/O Interface in Computer Architecture Difference between Internal Fragmentation and External Fragmentation MDR in Computer Architecture

Flag Register of 8086 Microprocessor

In this article, we are going to study about the one of the registers named flag registers of 8086 microprocessor. We are also going to know where and how to use the Flag register of 8086 microprocessor.

What is Flag Register?

Flag register is one of the special purpose registers. The Flag Register is a 16-bit register and there are only 9 accessible flags on the 8086 microprocessors. Therefore the remaining 7 bits are idle.

With the inclusion of an overflow flag, the condition code flag register is identical to the 8085-flagregister. The flag register's uppermost byte is the control flag register.

It has three flags:

  1. The direction (D) flag
  2. The interrupt (I) flag
  3. The trap flag (T).

Out of the total of 16, there are 9 active flags. The final seven flags with the letter "U" are undefined flags.

There are total of 9 active flags, and they are further divided into two parts namely status flags and control flags. Now, we are going to study briefly about each status flags.

Carry flag

It is set anytime a result's MSB (most significant bit) is carried or borrowed out. For an 8-bit operation, use D7, and for a 16-bit operation, use D15.The result in the ALU will be a maximum of 9 or 17 bits when the microprocessor conducts the addition of two 8- or 16-bit values. Direct copying of the most recent carry created into the carry flag. Similar results are obtained when the microprocessor subtracts (x - y) from two 8-bit or 16-bit values.

The additional borrowing needed to execute subtraction is zero if x y, hence CF = 0.

Additional borrowing is necessary if x y. The result of the subtraction (x - y) will be a negative number represented using the 2's complement method because CF = 1.

Parity flag

Only the 8 LSBs (least significant bits) of the 8 or 16-bit result are stored in the parity flag when the microprocessor executes an arithmetic or logical operation in the ALU.

Auxiliary Carry flag

This flag is used to signify a decimal number in binary code but is inaccessible to programmers.

Zero flag

When the microprocessor's ALU completes an arithmetic or logical operation and all 8 or 16 LSBs of the result are zero, ZF = 1. If the ALU's 8-bit or 16-bit result is not zero, ZF = 0. Additionally, whenever a certain register becomes zero as a result of an action, this flag is set.

Sign flag

When an 8-bit number is subjected to an arithmetic or logical operation by the CPU, the result's MSB (D7 bit) is immediately copied into the sign flag. Like this, the MSBs of the result (D15 bit) are directly duplicated into the sign flag when the CPU executes an arithmetic or logical operation on a 16-bit number. The outcome will be negative if the sign flag is set, while the outcome will be positive otherwise.

Overflow flag

If the result of an arithmetic operation on signed binary numbers performed by the CPU falls inside the range, then OF = 0. OF = 1 if the signed result is out of bounds. The 8-bit signed number range is from +7F to -80H, and the 16-bit signed number range is from +7FFF to -8000H.

Now, let’s discuss about another category that is control flags.

Control flags

Following are the three control flags:

  • Interrupt flag
  • Direction flag
  • Trap flag

Interrupt flag

The hardware interrupt pin INTR can be enabled or disabled using the interrupt flag. When the interrupt flag is set to zero with the CLI (Clear interrupt flag) instruction, the INTR interrupt is disabled.

Direction flag

A block or chain of data is handled by string instructions, and a block of bytes or words is moved from one point in memory to another using the MOV SB/MOV SW instruction

Trap flag

The microprocessor will perform the entire program in one operation, known as a free-running operation if the trap flag is set to zero. The microprocessor will run the program in single-stepping mode if the trap flag is set to one. When debugging software, faults in the program are found using the single-stepping mode.