Overflow Flag
Jump to navigation
Jump to search
The Overflow Flag (V) is bit 6 of the Processor Status Register. The overflow flag is set whenever an arithmetic, storage, or logical operation produces a result too large to be represented in a byte. This always assumes signed bytes, so anything greater than 127 or less than -127 will result in this flag being set to 1, otherwise it's cleared to 0.
Examples
This example loads the X register with the highest positive signed byte value and then increments it to show the behavior of the overflow flag.
0001:A2 7F LDX #$7F ; Load X with $7F, which is 127.
; Because $7F doesn't overflow a signed byte, V is cleared to 0.
0002:E8 INX ; Increment X to the value of $80, or 128.
; X has now surpassed the value a signed byte can hold, so V is set to 1.
Opcodes
The following opcodes affect the overflow flag.