Category:6502 Assembly: Difference between revisions

m
No edit summary
Line 111:
 
==Decimal Mode==
The 8086, 68000, and z80 have special commands for Binary Coded Decimal math, where hex values are used to represent decimal numbers (the base 10 system we use, not to be confused with floating point.) The 6502 has a special Decimal Flag as part of its status register. If the Decimal Flag is set, instructions such as <code>ADC</code> and <code>SBC</code> will produce a result that is a valid decimal number (i.e. not containing digits A through F). The Decimal Flag is only affected by the two commands responsible for setting and clearing it, as well as interrupts on certain 6502 revisions.
<lang 6502>sed ;set the decimal flag, enabling decimal mode
lda #$19
1,489

edits