aboutsummaryrefslogtreecommitdiff
path: root/printint.s
blob: 6d65f9374c077beea527196d85f316ca8718249e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

; use FP math pack to print 8- or 16-bit integers in decimal.

;;; Subroutine: printdecb
;;; Print byte in accumulator, in decimal
;;; Trashes all regs/flags
printdecb:
 ldx #0
 ; fall thru to printdecw

;;; Subroutine: printdecw
;;; Print word in A/X, in decimal (X is high byte)
;;; Trashes all regs/flags
; one annoyance here: we need (zp),y addressing because FASC actually
; updates INBUFF to point to the first non-zero ASCII digit (this is
; how we skip leading zeroes), but we don't have a "printchry" that
; preserves Y, so we end up using X for a counter and copying it to Y
; every loop iteration...
; also, why did I pick A/X instead of X/Y like FLD(0|1)R uses? in case
; someone ever wants to call this from C code in cc65...
printdecw:
 sta FR0
 stx FR0+1
 jsr IFP
 jsr FASC
 ldx #0
pwloop:
 txa
 tay
 lda (INBUFF),y
 php
 and #$7f
 jsr printchrx
 inx
 plp
 bpl pwloop
 rts