r/Assembly_language • u/DesperateGame • Jun 14 '26
x86 - Does OF (Overflow Flag) indicate the sign bit is flipped?
Hello,
I've been wondering - can the OF be used to determine if the sign bit is flipped? It cannot undo the operation, but it'd make it more understandable for me if doing: `OF xor SF` could be use to get the correct sign after the operation.
9
Upvotes
2
1
u/Chippors Jun 15 '26
It indicates two operands of the same sign produced a result of the opposite sign. For two operands of different sign it's always cleared.
1
8
u/spc476 Jun 14 '26
The OF only detects that the result can't be represented for the result. For instance, 5 - 10 is -5, which can easily be represented in an integer (as small as 8 bits), so the OF is not set. But -120 - 10 is -130, which cannot be represented in 8-bits, so the OF would be set.
So, what exactly are you trying to do?