User:Qalle/Algorithms

From NESdev Wiki
< User:Qalle
Revision as of 19:20, 21 October 2023 by Qalle (talk | contribs) (create)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Miscellaneous algorithms that may be useful on the NES.

8-bit unsigned integer to 3 decimal ASCII digits

Source: [1]

  ; in: A = unsigned integer
  ; out: Y/X/A = ASCII digits of hundreds/tens/ones
  ldy #$2f  ; ASCII("0") - 1
  ldx #$3a  ; ASCII("9") + 1
  sec
- iny
  sbc #100
  bcs -
- dex
  adc #10
  bmi -
  adc #$2f  ; ASCII("0")

References