Advertisement
NovaYoshi

putdecimal

May 4th, 2015
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .proc PutDecimal ; Prints with anywhere from 1 to 3 digits
  2.    cmp #10 ; only one char
  3.    bcs :+
  4.      add #'0'    ; char is number+'0'
  5.      sta PPUDATA
  6.      rts
  7.    :
  8.  
  9.    ; the hundreds digit if necessary
  10.    cmp #200
  11.    bcc LessThan200
  12.    ldx #'2'
  13.    stx PPUDATA
  14.    sub #200
  15.    jmp :+
  16. LessThan200:
  17.    cmp #100
  18.    bcc :+
  19.    ldx #'1'
  20.    stx PPUDATA
  21.    sub #100
  22. :
  23.    ldx #'0'    ; now calculate the tens digit
  24. :  cmp #10
  25.    bcc Finish
  26.    sbc #10     ; carry will be set if this runs anyway
  27.    inx
  28.    jmp :-
  29. Finish:
  30.    stx PPUDATA ; display tens digit
  31.    add #'0'
  32.    sta PPUDATA ; display ones digit
  33.    rts
  34. .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement