Sie sind auf Seite 1von 5

Flag register 8086

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.

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.

Flag register 8086


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)

8085 Microprocessor
Flag Registers In 8086

Flag Register:-

It is a 16-bit register with each bit corresponding to a flip-flop. It changes its status
according to the stored output in the accumulator. A flag can control certain
operation of the EU.
Active flag:- There are nine active flags out of 16, in the 8086 flag register. The remaining
are undefined flag.

Control Flag:- Out of nine active flags, six are conditional flags and the remaining three
are called as the control flag. The three control flags are:

1. The Trap flag(TF)


2. The interrupt flag(IF)
3. The direction flag(DF)

The Trap Flag:


 · Setting TF puts the processor into single step mode for debugging, In single stepping

microprocessor executes a instruction and enters into single step ISR.

 · If TF=1, the CPU automatically generates an internal interrupt after each instruction,

allowing a program to be inspected as it executes instruction by instruction.

The Interrupt Flag:-


 · If IF=1, the CPU will recognize external interrupt request (Interrupt Disabled). If IF=0,

then interrupt disabled.

 · Clearing IF disables these interrupts.

 · IF has no effect on either non-maskable external or internally generated interrupt.

The Direction Flag:-


 · This bit is specially for string instructions.

 · If DF=1, the string instruction will automatically decrement the pointer. If DF=0,the

string instruction will automatically increment the pointer.

Das könnte Ihnen auch gefallen