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.

Bits D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
Flags         O D I T S Z   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 Bit Function
S After any operation if the MSB is 1, then it indicates that the number is negative. And this flag is set to 1
Z If the total register is zero, then only the Z flag is set
AC When some arithmetic operations generates carry after the lower half and sends it to upper half, the AC will be 1
P This is even parity flag. When result has even number of 1, it will be set to 1, otherwise 0 for odd number of 1s
CY This is carry bit. If some operations are generating carry after the operation this flag is set to 1
O The 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 Bit Function
D This 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.
I This is interrupt flag. If I = 1, then MPU will recognize the interrupts from peripherals. For I = 0, the interrupts will be ignored
T This 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: 2023-09-06T13:34:45+05:30

51K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements