obelisk.demon.co.uk/6502 says 'Overflow Flag Set if sign bit is incorrect' which is vague and I really don't see clearly what means that 'sign bit is incorrect'.
The 6502 documentation by _Bnu, in the other hand, is very specific, it says that the overflow flag after an ADC without decimal mode is this:
(AC is accumulator, src is a value from memory, temp is AC + src + carry, and 0x80 is bit 7 set )
Ok, I understand bitwise operations, but I don't get the logic behind this expression.
So the ultimate question is, conceptually, when should the overflow flag be set for ADC and when should it be unset? (what is a correct sign?)
I could just paste that expression in my code and it may work perfectly, but I'd like to understand what my code is doing.
PS: the carry flag is set when the addition overflows. So the overflow flag doesn't actually mean overflow, it means something else.
The 6502 documentation by _Bnu, in the other hand, is very specific, it says that the overflow flag after an ADC without decimal mode is this:
Code:
(!((AC ^ src) & 0x80) && ((AC ^ temp) & 0x80))
(AC is accumulator, src is a value from memory, temp is AC + src + carry, and 0x80 is bit 7 set )
Ok, I understand bitwise operations, but I don't get the logic behind this expression.
So the ultimate question is, conceptually, when should the overflow flag be set for ADC and when should it be unset? (what is a correct sign?)
I could just paste that expression in my code and it may work perfectly, but I'd like to understand what my code is doing.
PS: the carry flag is set when the addition overflows. So the overflow flag doesn't actually mean overflow, it means something else.