Skip to main content

Short note: flags in 8086

Short answer

The 16-bit flag register has six status flags: CF (carry), PF (parity), AF (auxiliary carry), ZF (zero), SF (sign), OF (overflow) set by ALU results; and three control flags: TF (single-step trap), IF (maskable interrupt enable), DF (string direction). They govern conditional jumps.

Write a short note on flags in 8086 microprocessor.

The 8086 has a 16-bit flag register of which 9 bits are used. Six are status (conditional) flags set by the ALU after an operation, and three are control flags set by the programmer.

 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

Status flags

FlagNameSet (1) when
CFCarryCarry out of MSB in addition or borrow in subtraction
PFParityLow byte of result has an even number of 1s
AFAuxiliary carryCarry from bit 3 to bit 4 (used by DAA/DAS)
ZFZeroResult is zero
SFSignMSB of result is 1 (negative)
OFOverflowSigned result is too large for the destination

Control flags

FlagNameFunction
TFTrapWhen 1, processor executes in single-step mode (type-1 interrupt after each instruction)
IFInterruptWhen 1, the maskable INTR interrupt is enabled (STI sets, CLI clears)
DFDirection0 = string instructions auto-increment SI/DI; 1 = auto-decrement (CLD, STD)

Example: MOV AL,0FFH then ADD AL,01H gives AL = 00H with CF = 1, ZF = 1, AF = 1, PF = 1, SF = 0, OF = 0. Flags are tested by conditional jumps such as JC, JZ, JS, JO, JP.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Microprocessor chapter 3 questions →