0% found this document useful (0 votes)
2 views

Lecture5_FLAGS

The FLAGS register is a 16-bit register with 9 used bits that represent various status and control flags in computing. Key status flags include Carry, Parity, Auxiliary Carry, Zero, Sign, and Overflow, which indicate conditions resulting from arithmetic operations. Control flags such as Trap, Interrupt, and Direction manage program execution and interrupt handling.

Uploaded by

harithbashar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lecture5_FLAGS

The FLAGS register is a 16-bit register with 9 used bits that represent various status and control flags in computing. Key status flags include Carry, Parity, Auxiliary Carry, Zero, Sign, and Overflow, which indicate conditions resulting from arithmetic operations. Control flags such as Trap, Interrupt, and Direction manage program execution and interrupt handling.

Uploaded by

harithbashar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lecture5: FLAGS Register

FLAGS register is a 16-bits register that contain 9-used bits while the rest bits are not used.
These bits are as follows:

b15 b14 b13 b12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0


O D I T S Z A P C

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 +

+128 0 1000 0000 = -128 NOT CORRECT 


Control Flags:
1) Trap Flag (TF):
If TF is set to 1, it permits executing the program step by step (one instruction at a time).
2) Interrupt Flag (IF):
If IF is 0, all interrupt requests are ignored. If IF is set to 1, interrupts are recognized.
3) Direction Flag (DF):
(Useds with String Instructions).

.flags‫ اليؤثران على الـ‬xchg‫ و‬mov ‫ ايعازي‬:‫مالحظة‬

Best Regards
Dr. Zainab Alomari

You might also like