Lecture5_FLAGS
Lecture5_FLAGS
FLAGS register is a 16-bits register that contain 9-used bits while the rest bits are not used.
These bits are as follows:
Status Flags:
1) Carry Flag (CF):
CF=1 when there is a carry-out or a borrow-in after executing the instruction.
CF=0 otherwise.ss
2) Parity Flag (PF):
PF=1 if the number of ones in the result is even.
PF=0 if the number of ones in the result is odd.
3) Auxiliary Carry Flag (AF):
AF=1 if there is a carry-out into the high nibble from the low nibble, or a borrow-in from
the high nibble into the low nibble of the lower byte of the result.
AF=0 otherwise.
4) Zero Flag (ZF):
ZF=1 when the result of executing an instruction is zero.
ZF=0 when the result of executing an instruction is not zeros.
5) Sign Flag (SF):
SF=1 if the MSB (Most Significant Bit) is 1 (negative number).
SF=0 if the MSB (Most Significant Bit) is 0 (positive number).
Or we can directly say (SF=MSB).
Notice that for unsigned numbers, SF value is neglected.
6) Overflow Flag (OF):
OF=1 if the signed result is out of range. This means that there is a carry added to the
sign bit but no carrys out of the sign bit. (when working with usnsigned numbers, OF
value is neglected).
Example:
127 = 7F = 0111 1111
1+ 1+ 0000 0001 +
Best Regards
Dr. Zainab Alomari