Question: Explain the flag register of 8086.

Mumbai University > Electronics and Telecommunication > Sem 4 > Microprocessor and peripherals

Marks: 5M

Year: May 2015

modified 5 weeks ago by gravatar for abhishektiwari1712 abhishektiwari1712 ♦♦ 30 written 2.6 years ago by gravatar for kazi.tahoor kazi.tahoor0
  1. Flag register is a part of EU (Execution Unit). It is a 16 bit register with each bit corresponding to a flip-flop.
  2. A flag is a flip-flop. It indicates some condition produced by the execution of an instruction. For example the zero flag (ZF) will set if the result of execution of an instruction is zero.
  3. Figure below shows the details of the 16 bit flag register of 8086 CPU.

enter image description here

  1. It consists of 9 active flags out of 16. The remaining 7 flags marked ā€˜Uā€™ are undefined flags.
  2. These 9 flags are of two types:
  • 6 Status flags
  • 3 Control flags

Status flags:

  1. 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.
  1. Parity flag (PF)-
  2. It is set if the result has even parity. If parity is odd, PF is reset.
  3. This flag is normally used for data transmission errors.

  4. Auxiliary carry flag (AC)-

  5. It is set if a carry is generated out of the lower nibble.
  6. It is used only in 8 bit operations like DAA and DAS.

  7. Zero flag (ZF)-

  8. It is set if the result is zero.

  9. Sign flag (SF)-

  10. It is set if the MSB of the result is 1. For signed operations such a number is treated as negative.

  11. Overflow flag (OF)-

  12. 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.
  13. It can be checked using the instruction INTO (Interrupt on Overflow).

Control flags:

  1. Trap flag (TF)-
  2. It is used to set the trace mode i.e. start single stepping mode.
  3. Here the microprocessor is interrupted after every instruction so that the program can be debugged.

  4. Interrupt enable flag (IF)-

  5. It is used to mask (disable) or unmask (enable) the INTR interrupt.
  6. If user sets IF flag, the CPU will recognize external interrupt requests. Clearing IF disables these interrupts.

  7. Direction flag (DF)-

  8. If this flag is set, SI and DI are in auto-decrementing mode in string operations.
written 2.6 years ago by gravatar for kazi.tahoor kazi.tahoor0
Please log in to add an answer.