|Assembly - Convert 16 bit integer to ascii help please [message #32940]
||Sat, 12 January 2013 10:56
Registered: January 2013
I am looking for a routine to convert a 16 bit integer into ascii (text)|
ex. convert $C000 (49152) to the characters "49152" stored in a memory address.
I found one that almost does what I want, but it adds leading 0's.
Ideally I would like to have a routine that you can pass an option to either print leading 0's or strip them. But first things first I guess. :)
Here is that code:
;* DECIMAL TO ASCII ROUTINE *
;* LOW-BYTE IN .X HI-BYTE IN .A
;* STORES ASCII STRING IN MEMORY
;* PRINTS PRECEDING 0'S
DECIMAL STX BINARY
DEC1 LDX #"0"
DEC2 LDA BINARY
DECTBL1 .BYTE <10000,<1000,<100
DECTBL2 .BYTE >10000,>1000,>100
DECCHR .WORD 0,0
BINARY .WORD 0