Flag RegisterThe flag registers in 8086CPU include:
CF, PF, ZF, SF, of, DF.
The transfer instruction does not affect the flag register
ZF Flag Register
The ZF Flag Register is 6th in flag and represents the 0 flag bit. (as to what flag is, do not take care of it temporarily)
The role of ZF registers
Determines whether the result is 0 after the instruction is executed.
Example
MOV ax,1
Sub ax,1
The result of the instruction execution is 0,zf=1
PF Flag Register
The PF flag Register is located in the 2nd digit of the flag, indicating the odd-even flag bit.
The role of PF registers
Determines whether the number of bit bits in the result after the execution of the instruction is 1 is even. If the number of 1 is even, pf=1; if it is odd, pf=0.
Example
MOV al,1
Add al,10
After execution, the result is 00001011B, which has 3 1,pf=0.
SF Flag Register
The SF flag Register is located in the 7th digit of the flag, indicating the symbol flag bit.
Function of the SF register
Determines whether the result is negative after the instruction is executed. If it is negative, sf=1.
Features of SF Registers
If we do an unsigned operation, the SF register is meaningless, and if you perform a signed operation, the SF record is positive or negative.
Example
00000001B can be considered as unsigned number 1, signed number +1.
10000001B can be seen as unsigned number 129, signed number-127.
unsigned addition:
MOV al,10000001b
Add al,1
The result is Al = 10000010B, which indicates 129+1 = 130.
Signed addition:
MOV al,10000001b
Add al,1
The result is Al = 10000010B, Sf=1, which represents -127+1 =-126.
CF Flag Register
The CF flag Register is located in the No. 0 bit of flag and is indicated only as a flag bit.
The role of CF registers
In the unsigned number operation, it enters the carry value of the most significant bit of the result of the operation to the higher carry, or from the higher borrow value.
Features of CF Registers
Works only when unsigned operations are in effect.
Example
Carry:
MOV al,98h
Add Al,al
After execution, AL=30H,CF=1,CF records the carry value from the most significant bit to the higher.
Add Al,al
After execution, AL=60H,CF=0,CF records the carry value from the most significant bit to the higher.
Borrow
MOV al,97h
Sub al,98h
After execution, AL=FFH,CF=1,CF records the borrow value to a higher level.
Sub Al,al
After execution, AL=0,CF=0,CF records the borrow value to a higher level.
of flag Registers
The of flag registers are located in the 11th bit of flag, indicating the overflow flag bit.
The role of the Register
Determine if the calculated result overflows. Overflow, of=1, no overflow, of=0.
Features of the Register
of works only when the signed number operation.
Example
MOV al,0f0h
Add al,88h
An overflow of=1 occurred after the instruction was executed.
MOV al,0f0h
Add 78h
Overflow of=0 does not occur after the instruction is executed.
"Assembly Language (third edition)" Flag register