Flag Register in 8086 Microprocessor

In this tutorial, we will learn about the different types of flags of the flag register. We will first have a look at the bit representation of this flag register to know which flag is stored at which location, and then will discuss the functioning of each of the flags. By Monika Sharma Last updated : May 15, 2023

What is a Flag Register in 8086 Microprocessor?

Flag Register is a 16-bit register, but there are only 9 flags available in the 8086 microprocessor. The rest 7 bits are hence left idle.

flag register 8086 microprocessor

Types of Flags of Flag Register in 8086 Microprocessor

There are two types of flags of flag register in 8086 Microprocessor:

  1. Condition Flags
  2. Control Flags

1. Condition Flags

The conditional flags are set or reset after any arithmetic or logical operation is performed on an 8 bit or 16-bit number. This category consists of the following 6 flags:

  1. Carry Flag (CF): The carry flag will be set only if a carry is generated from the MSB of the result after doing any operation in 8086 Microprocessor.
  2. Parity Flag (PF): Parity is related to the number of 1’s contained in the binary data. There exist two types of parity:
    • Even Parity: When the number of 1’s in the binary data are even.
    • Odd Parity: When the number of 1’s in the binary data are odd.

    For the flag, the PF is set if there exists an even parity in data after the execution of the instruction. Else the flag is reset.
  3. Auxiliary-Carry Flag (AF): This flag is set if there is a generation of carrying from a nibble, i.e. 4 bits of data.
  4. Zero Flag (ZF): If the result after performing the required operation (Arithmetic or Logical) on the instructions is zero, in that case, the zero flags are set to 1. Else, it remains reset.
  5. Sign Flag (SF): If the result after performing any arithmetic or logic operation in the given instruction is negative, then the sign flag is set to 1. Else, for a positive result, the sign flag remains reset.
  6. Overflow Flag (OF): This Flag will be set if the register gets overflowed with data after any arithmetic or logic operation. This happens in cases when the carry is getting in in MSB, but there is no space in the register to store the carried out bit.

2. Control Flags

The control flags are used to navigate the microprocessor for certain operations. There are 3 types of control flags:

  1. Trap Flag (TF): This flag is used of we need single-step debugging in our code. If the TF is set, then the execution will be done step by step. Otherwise, the free-running operation will be done.
  2. Interrupt Flag (IF): This flag is used to enable the Interrupt. The microprocessor is capable of handling interrupts only if this flag is in the set mode. Otherwise, any interrupt raised while the execution of the instructions will not be handled by the microprocessor.
  3. Direction Flag (DF): This flag is used for string operations. If this flag is set, the string will be read from higher-order bits to lower order bits and vice versa.

Comments and Discussions!

Load comments ↻

Copyright © 2024 www.includehelp.com. All rights reserved.