Changes

Jump to: navigation, search

6502 Math

301 bytes added, 22:43, 14 January 2020
Subtraction
The carry flag (which can be viewed as a "borrow" flag for subtraction) is cleared if the result underflows $00 and set otherwise (in other words, if doing unsigned math, the Carry flag is cleared if a bit must be "borrowed").
 
Normally, you will set the carry flag (with <code>SEC</code>) before performing a subtraction on the lowest byte of a single- or multi-byte subtraction, and then perform subtraction on each byte in sequence up to the highest byte. The borrows will automatically be carried from one byte to the next.
The Overflow (V) flag is set if the signed result of the operation is above 127 ($7f) or below -128 ($80).

Navigation menu