PadhaikoAll subjects

Past exam question: 2081 Chaitra (Regular), Q4(b)

Microprocessors · 3 marks

Open in the Padhaiko app

Topic: 8086 Features & Architecture (BIU and EU)

Question

Explain flags in 8086 Microprocessor.

Solution

Flag Register Bit Organization: The 8086 Flag Register is a 16-bit register containing 9 active flags (6 Status/Condition Flags and 3 Control Flags) and 7 undefined bits:

BitD15–D12D11D10D9D8D7D6D5D4D3D2D1D0
FlagReservedOFDFIFTFSFZFResAFResPFResCF

Status Flags (Condition Flags): Status flags are updated automatically by the ALU to reflect properties of the operation result:

  1. CF (Carry Flag): Set to 1 if an arithmetic addition generates a carry out of the MSB (bit 7 for 8-bit, bit 15 for 16-bit) or subtraction generates a borrow; reset to 0 otherwise.
  2. PF (Parity Flag): Set to 1 if the lower 8 bits of the result contain an even number of 1s (even parity); reset to 0 for odd parity.
  3. AF (Auxiliary Carry Flag): Set to 1 if a carry occurs from bit 3 into bit 4 during BCD addition or subtraction.
  4. ZF (Zero Flag): Set to 1 if the result of an arithmetic or logical operation is zero (0000H); reset to 0 if non-zero.
  5. SF (Sign Flag): Reflects the MSB of the result (bit 7 for 8-bit, bit 15 for 16-bit). Set to 1 for negative numbers in two's complement; reset to 0 for positive.
  6. OF (Overflow Flag): Set to 1 if a signed arithmetic operation produces a result that exceeds the capacity of the destination register (signed overflow); reset to 0 otherwise.

Control Flags: Control flags are manipulated by software instructions to govern processor execution modes:

  1. TF (Trap Flag): When set to 1 by a debugger, puts the processor into single-step execution mode, generating internal Type 1 interrupt after each instruction.
  2. IF (Interrupt Enable Flag): When set to 1 (STI), the CPU responds to maskable hardware interrupts on the INTR pin. When cleared (CLI), INTR is ignored.
  3. DF (Direction Flag): Controls auto-increment/decrement of SI and DI during string operations (MOVS, CMPS). When DF = 0 (CLD), pointers auto-increment (process string forward); when DF = 1 (STD), pointers auto-decrement (backward).
Answer:

The 8086 has a 16-bit flag register with 9 active flags: 6 status flags (CF, PF, AF, ZF, SF, OF) indicating ALU operation results, and 3 control flags (TF for single-stepping, IF for enabling INTR, and DF for auto-incrementing/decrementing string pointers).

All past exam questions for Microprocessors