Decimal Flag

From NES Hacker Wiki
Revision as of 17:56, 3 June 2013 by TheAlmightyGuru (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Decimal Flag (D) is bit 3 of the Processor Status Register. The NES does not use decimal mode, so the bit is usually set to 0.

However, since the opcodes that set and clear the flag are still functional in the NES, you can use this flag to store data.

If the NES did support decimal mode, math would be handled differently when the decimal mode flag was set. If an ADC or SBC instruction were executed, the source values would be treated as valid BCD (Binary Coded Decimal, eg. 0x00-0x99 = 0-99) numbers, and the generated result would also be a BCD number.


Opcodes

The following opcodes affect the decimal flag.