I just started learning assembly and I'm trying to understand how the different flags work. Let's say I do this:
mov ax, 0xBFE8h
mov bx, 25DFh
add ax, bx
Shouldn't the overflow flag turn on? The value of the addition is 58,823 (in base 10), which is more then the 32,767 (a signed 16 bit value). I checked in the program and the flag doesn't turn on. Why is this?
Thanks for any help.
The overflow flag turns on when signed overflow occurs. However, this is not the case in your code. 0xbfe8
is larger than 0x8000
and thus negative in two's complement, representing −16408. 0x25DF
is equal to 9695, their sum is −6713 which is not outside of the range −32768 to +32767, so no signed overflow occured and the overflow flag is cleared.