8089 compilation flag register
8086CPU in the instruction set, the instruction is executed and some affect the flags register, such as: add, sub, mul, div, inc, or, and the like, which are mostly operation instructions, logical or arithmetic operation;
Some of instruction execution flag register no influence, such as: mov, push, pop, etc., which are mostly transfer instructions.
Use an instruction, pay attention to the full functionality of this directive, including the results of an impact on what flags mark register.
Structure flag register
flag register is a bit of work, that is to say, every bit of it has a special meaning, record specific information.
8086CPU not used in the flag of 1,3,5,12,13,14,15 bits that do not have any meaning.
The role of flag register
Some used to store the results of the implementation of the relevant instructions
to provide the behavior for the CPU to perform in accordance with the relevant instructions
to control the CPU-related work
Observations
Flag Description
First, the flag parsing
1, a method of direct access flag register
- pushf: The value of the flag register onto the stack;
- popf: pop data off the stack into the flag register.
2, the memory flag 16 indicates
3, explanation flag
Two, ZF- Zero (Zero Flag)
ZF tag associated instruction results is 0
- ZF = 1, indicates "the result is 0" indicates a "logically true"
- ZF = 0, indicating "the result is not 0", 0 "logical false"
Three, PF- parity flag (Parity Flag)
After PF recording instruction execution, the results of all the bits in the number 1:
- 1 is an even number, PF = 1;
- 1 is an odd number, PF = 0.
Four, SF- sign flag (Sign Flag)
A recording flag SF is signed numbers CPU calculation result.
When the data as signed numbers is computed by SF apparent negative result; as unsigned number of data is calculated, the value of SF is meaningless, while the relevant instructions affect its value.
After the SF recording instruction execution, treat the result as signed number
- The result is negative, SF = 1;
- Result is non-negative, SF = 0.
Five, CF- carry flag (Carry Flag)
The most significant bit to a higher bit of the value is performed when unsigned arithmetic, CF recording operation result or a higher value from the borrow bit.
CF recording instruction is executed after:
- Carry or borrow, CF = 1
- No carry or borrow, CF = 0
N is the number of bits for unsigned, the most significant bit of the corresponding information, i.e., the first N-1 bits, the most significant bit
The first N-bit virtual presence, relative to the most significant bit is bit higher.
Six, OF- overflow flag (Overflow Flag)
Performing, when a signed operand, as a result of more than the machine to be represented in the called overflow.
Signed operands OF recording instructions after the
- Overflow, OF = 1
- No overflow, OF = 0
Range of the machine is capable of expressing
Example 8 In operation, with the result 8-bit register or memory means to store the range of the machine represent is -128 to 127.
Similarly, the range for 16-bit signed number, the machine can be represented -32768 to 32767.
Note that this is just an overflow of a signed number arithmetic terms.
The difference between CF and OF
CF is unsigned numbers into meaningful / borrow bit
OF operand is a signed overflow flag meaningful
application