We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

Decimal Mode: Difference between revisions

From SnesLab
Jump to: navigation, search
m (Jeffythedragonslayer moved page Decimal mode to Decimal Mode: fix redirect to lowercase)
(see also DAA Ds)
Line 23: Line 23:


The decimal mode has been documented more thoroughly in [https://www.smwcentral.net/?p=section&a=details&id=4750&r=0 Ersanio's ASM tutorial V2.1].
The decimal mode has been documented more thoroughly in [https://www.smwcentral.net/?p=section&a=details&id=4750&r=0 Ersanio's ASM tutorial V2.1].
=== See Also ===
* [[DAA]]
* [[DAS]]


[[Category:ASM]]
[[Category:ASM]]
[[Category:Flags]]
[[Category:Flags]]

Revision as of 23:50, 16 July 2023

Decimal mode is one of the SNES CPU's processor flags. Toggling it on/off will only affect the instructions ADC and SBC. To toggle decimal mode on/off, use SED (Set decimal mode) and CLD (clear decimal mode)

Processes

Let's just assume A is 8-bit and holds the value #$00. When one is doing ADC #$0C for example, the following steps will take place.

  • Take the parameter after ADC
  • Convert it to Decimal
  • Add the conversion to A (execute ADC)
  • If A turns out to have a hexadecimal number after the addition, convert it it to a decimal number again.

In this case, #$0C gets converted to 12. Since $0C equals to 12, doing ADC #$12 would give you the same result.

Same story with SBC, except SBC subtracts of course.

Example usage of ADC:

 LDA #$09  ;A = $09
 CLC       ;Clear carry flag
 ADC #$02  ;A = $11

The decimal mode has been documented more thoroughly in Ersanio's ASM tutorial V2.1.

See Also