I know that when performing an 8-bit binary addition, the auxiliary flag is set to 1 if there is a carry from 3rd bit to 4th bit; but what about the addition of 2 16-bit numbers? i can't see any clear answer on the web.
I'm studying intel 8086 microprocessor...
For example, when i add these 2 numbers, 0x30a2 and 0xf1ac
0011 0000 1010 0010 + 1111 0001 1010 1100
CF=1
ZF=0
PF=1
SF=0
OF=1
AF=?
I'm not sure where to check it
From "Programming the 8086/8088" by James W. Coffron:
AF auxiliary carry flag. If this flag is set, there has been a carry of the low nibble to the high nibble or a borrow from the high nibble to the low. The high or low nibble refers to the low order byte of a 16-bit value.
In my day we would write a short piece of code to observe the processor behaviour. You could check it out by adding or subtracting two 16-bit numbers, followed by a pushf
and pop ax
to examine the status flags at your pleasure.
EDIT.
(Another way to get the flags is with LAHF
which loads 5 bits of AH
with flags, AF
going to bit 4.)
So AF
represents the carry out from bit 3 to bit 4, whatever the size of the operands.
Note that there are no branch instructions dependent on AF
. It is used internally by the DAA
instruction to do a decimal adjustment immediately after an ADD
instruction, typically with AL
.