Flag register of 8086 microprocessor


The flag register is one of the special purpose register. The flag bits are changed to 0 or 1 depending upon the value of result after arithmetic or logical operations.

8086 has 16-bit flag register, and there are 9 valid flag bits. The format of flag register is like below.

BitsD15D14D13D12D11D10D9D8D7D6D5D4D3D2D1D0
Flags    ODITSZ AC P CY

 

We can divide the flag bits into two sections. The Status Flags, and the Control Flags.

Status Flags

In 8086 there are 6 different flags which are set or reset after 8-bit or 16-bit operations. These flags and their functions are listed below.

Flag BitFunction
SAfter any operation if the MSB is 1, then it indicates that the number is negative. And this flag is set to 1
ZIf the total register is zero, then only the Z flag is set
ACWhen some arithmetic operations generates carry after the lower half and sends it to upper half, the AC will be 1
PThis is even parity flag. When result has even number of 1, it will be set to 1, otherwise 0 for odd number of 1s
CYThis is carry bit. If some operations are generating carry after the operation this flag is set to 1
OThe overflow flag is set to 1 when the result of a signed operation is too large to fit.

 

Control Flags

In 8086 there are 3 different flags which are used to enable or disable some basic operations of the microprocessor. These flags and their functions are listed below.

Flag BitFunction
DThis is directional flag. This is used in string related operations. D = 1, then the string will be accessed from higher memory address to lower memory address, and if D = 0, it will do the reverse.
IThis is interrupt flag. If I = 1, then MPU will recognize the interrupts from peripherals. For I = 0, the interrupts will be ignored
TThis trap flag is used for on-chip debugging. When T = 1, it will work in a single step mode. After each instruction, one internal interrupt is generated. It helps to execute some program instruction by instruction.

 

Updated on: 06-Sep-2023

37K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements