Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .proc PutDecimal ; Prints with anywhere from 1 to 3 digits
- cmp #10 ; only one char
- bcs :+
- add #'0' ; char is number+'0'
- sta PPUDATA
- rts
- :
- ; the hundreds digit if necessary
- cmp #200
- bcc LessThan200
- ldx #'2'
- stx PPUDATA
- sub #200
- jmp :+
- LessThan200:
- cmp #100
- bcc :+
- ldx #'1'
- stx PPUDATA
- sub #100
- :
- ldx #'0' ; now calculate the tens digit
- : cmp #10
- bcc Finish
- sbc #10 ; carry will be set if this runs anyway
- inx
- jmp :-
- Finish:
- stx PPUDATA ; display tens digit
- add #'0'
- sta PPUDATA ; display ones digit
- rts
- .endproc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement