written 5.2 years ago by
modified 3 months ago
The 8086 flag register contents indicate the results of computation in the ALU. It also contains some flag bits to control the CPU operations.
- A 16 bit flag register is used in 8086. It is divided into two parts .
o Condition code or status flags
o Machine control flags
- The condition code flag register is the lower byte of the 16-bit flag register. The condition code flag register is identical to 8085 flag register, with an additional overflow flag.
- The control flag register is the higher byte of the flag register. It contains three flags namely direction flag (D), interrupt flag (I) and trap flag (T).
Figure below shows the details of the 16 bit flag register of 8086 CPU.
- It consists of 9 active flags out of 16. The remaining 7 flags marked ‘U’ are undefined flags.
- These 9 flags are of two types:
- 6 Status flags
- 3 Control flags
- Carry flag (CY)-
- It is set whenever there is a carry or borrow out of the MSB (most significant bit) of a result. D7 bit for an 8 bit operation and D15 bit for a 16 bit operation.
- Parity flag (PF)-
- It is set if the result has even parity. If parity is odd, PF is reset.
This flag is normally used for data transmission errors.
Auxiliary carry flag (AC)-
- It is set if a carry is generated out of the lower nibble.
It is used only in 8 bit operations like DAA and DAS.
Zero flag (ZF)-
It is set if the result is zero.
Sign flag (SF)-
It is set if the MSB of the result is 1. For signed operations such a number is treated as negative.
Overflow flag (OF)-
- It will be set if the result of a signed operation is too large to fit in the number of bits available to represent it.
- It can be checked using the instruction INTO (Interrupt on Overflow).
- Trap flag (TF)-
- It is used to set the trace mode i.e. start single stepping mode.
Here the microprocessor is interrupted after every instruction so that the program can be debugged.
Interrupt enable flag (IF)-
- It is used to mask (disable) or unmask (enable) the INTR interrupt.
If user sets IF flag, the CPU will recognize external interrupt requests. Clearing IF disables these interrupts.
Direction flag (DF)-
- If this flag is set, SI and DI are in auto-decrementing mode in string operations.