Programming with Ophis | ||
---|---|---|
<<< Previous | Next >>> |
This essay discusses how to do 16-or-more bit addition and subtraction on the 6502, and how to do unsigned comparisons properly, thus making 16-bit arithmetic less necessary.
The ADC, SBC, INX, and INY instructions are the only real arithmetic instructions the 6502 chip has. In and of themselves, they aren't too useful for general applications: the accumulator can only hold 8 bits, and thus can't store any value over 255. Matters get even worse when we're branching based on values; BMI and BPL hinge on the seventh (sign) bit of the result, so we can't represent any value above 127.
<<< Previous | Home | Next >>> |
To HLL and Back | Up | The solution |