Open main menu

CDOT Wiki β

Changes

6502 Math

353 bytes added, 23:13, 19 September 2021
Decimal Mode
In binary mode, operations are performed on a single 8-bit value. Numbers may be treated as signed or unsigned (the math is the same).
In decimal mode, the each byte is treated as two decimal digits- the lower 4 bits represent the lower digit, and the upper 4 bits represent the upper digit. Numbers are counted as positive, and values greater than 9 are invalid. Decimal mode is selected by setting the D flag in the [[6502#Registers|Status Register]] using the <code>SED</code> instruction, and binary mode is selected by clearing the D flag using the <code>CLD</code> instruction.
The rest of this page deals with binary mode (decimal mode operates in mostly the same way).