Reputation: 107
I'm learning about x86 assembly(8086 to be more specific) and I'm confused about the concept of flags, I tried searching about it online and found this image :
According to the image , after the addition operation of the two 16 bit numbers, the OF flag is still clear at 0.
But I've learnt that if the MSB of the two numbers to be added is off (so a 0) and the MSB of the result is a 1, then overflow has occurred.
Link to the webpage I've learned this from : http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt
Can someone explain why the OF is still at 0 please?
Upvotes: 1
Views: 1190
Reputation: 71566
Just do the math by hand
setup both of them
0110 0101 1101 0001
+ 0010 0011 0101 1001
=========================
1
0110 0101 1101 0001
+ 1101 1100 1010 0110
=======================
start working both of them
10 0010
0110 0101 1101 0001
+ 0010 0011 0101 1001
=========================
10 1010
1111
0110 0101 1101 0001
+ 1101 1100 1010 0110
=======================
1000
and already they do not match
11111 1011 0000 1111
0110 0101 1101 0001
+ 1101 1100 1010 0110
=======================
0100 0010 0111 1000
No borrow so borrow flag = 1, carry flag = 1 (inverse of borrow). The msbit in and out are the same so no signed overflow. not zero so no zero flag. And msbit is zero so negative flag is zero.
Upvotes: 0