Purpose of using flag registers.



FLAGS : 8086 has 16 flag registers among which 9 are active. The purpose of the FLAGS register is to indicate the status of the processor. It does this by setting the individual bits called flags. There are two kinds of FLAGS;


Status FLAGS and Control FLAGS. Status FLAGS reflect the result of an operation executed by the processor. The control FLAGS enable or disable certain operations of the processor.


  1. Carry Flag (CF) - this flag is set to 1 when there is an unsigned overflow. For example when you add bytes 255 + 1 (result is not in range 0...255). When there is no overflow this flag is set to 0.

  2. Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in result, and to 0 when there is odd number of one bits.

  3. Auxiliary Flag (AF) - set to 1 when there is an unsigned overflow for low nibble (4 bits).

  4. Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this flag is set to 0.

  5. Sign Flag (SF) - set to 1 when result is negative. When result is positive it is set to0. (This flag takes the value of the most significant bit.)

  6. Trap Flag (TF) - Used for on-chip debugging.

  7. Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to interrupts from external devices.

  8. Direction Flag (DF) - this flag is used by some instructions to process data chains, when this flag is set to 0 - the processing is done forward, when this flag is set to 1the processing is done backward.

  9. Overflow Flag (OF) - set to 1 when there is a signed overflow. For example, when you add bytes 100 + 50 (result is not in range -128...127).

Next Read:

Recommended Recommends

Comments

Contact Us