The condition flags are:
- SF (Sign Flag)
- Is equal to the MSB of the result. Since in 2's complement negative numbers have a 1 in the MSB and for nonnegative numbers this bit is 0, this flag indicates whether the previous result was negative or nonnegative.
- ZF (Zero Flag)
- Is set to 1 if the result is zero and 0 if the result is nonzero.
- PF (Parity Flag)
- Is set to 1 if the low-order 8 bits of the result contain an even number of 1s; otherwise it is cleared.
- CF (Carry Flag)
- An addition causes this flag to be set if there is a carry out of the MSB, and a subtraction causes it to be set if a borrow is needed. Other instructions also affect this flag and its value will be discussed when these instructions are defined.
- AF (Auxiliary Carry Flag)
- Is set if there is a carry out of bit 3 during an addition or a borrow by bit 3 during a subtraction. This flag is used exclusively for BCD arithmetic.
- OF (Overflow Flag)
- Is set if an overflow occurs, i.e., a result is out of range. More specifically, for addition this flag is set when there is a carry into the MSB and no carry out of the MSB or vice versa. For subtraction, it is set when the MSB needs a borrow and there is no borrow from the MSB, or vice versa.
As an example, if the previous instruction performed the addition
0010 0011 0100 0101 |
+ 0011 0010 0001 1001 |
0101 0101 0101 1110 |
then following the instruction:
SF=0    ZF=0    PF=0    CF=0    AF=0    OF=0
Figure 2-8 8086's PSW.
The control flags are:
- DF (Direction Flag)
- Used by string manipulation instructions. If clear, the string is processed from its beginning with the first element having the lowest address. Otherwise, the string is processed from the high address towards the low address. (See Chap. 5.)
- IF (Interrupt Enable Flag)
- If set, a certain type of interrupt (a maskable interrupt) can be recognized by the CPU; otherwise, these interrupts are ignored. (See Chaps. 4 and 6.)
- TF (Trap Flag)
- If set, a trap is executed after each instruction. (See Chap. 4.)
Table of Contents | Next page | Previous page
This is page 13.