AppleIIAsm-Collection/disks/disk5_strings/T.NUM2STR.MIN
nathanriggs 16c1731e54 Strings 0.2.0 update
- bugfixes
- implemented required library
- commenting updates
- .min of every routine
2018-12-22 20:35:05 -05:00

99 lines
1.7 KiB
Plaintext

*
NUM2STR
*
PLA
STA RETADR
PLA
STA RETADR+1
PLA
STA :VALSTR
PLA
STA :VALSTR+1
STA :NGFLAG
BPL :GETBP
LDA #0
SEC
SBC :VALSTR
STA :VALSTR
LDA #0
SBC :VALSTR+1
STA :VALSTR+1
:GETBP
LDA #<RETURN
STA ADDR1
LDA #>RETURN+1
STA ADDR1+1
LDA #0
LDY #0
STA (ADDR1),Y
:CNVERT
LDA #0
STA :MOD10
STA :MOD10+1
LDX #16
CLC
:DVLOOP
ROL :VALSTR
ROL :VALSTR+1
ROL :MOD10
ROL :MOD10+1
SEC
LDA :MOD10
SBC #10
TAY
LDA :MOD10+1
SBC #0
BCC :DECCNT
STY :MOD10
STA :MOD10+1
:DECCNT
DEX
BNE :DVLOOP
ROL :VALSTR
ROL :VALSTR+1
:CONCH
LDA :MOD10
CLC
ADC #$B0
JSR :CONCAT
LDA :VALSTR
ORA :VALSTR+1
BNE :CNVERT
:EXIT
LDA :NGFLAG
BPL :POS
LDA #173
JSR :CONCAT
:POS
LDA RETADR+1
PHA
LDA RETADR
PHA
RTS
:CONCAT
PHA
LDY #0
LDA (ADDR1),Y
TAY
BEQ :EXITMR
:MVELP
LDA (ADDR1),Y
INY
STA (ADDR1),Y
DEY
DEY
BNE :MVELP
:EXITMR
PLA
LDY #1
STA (ADDR1),Y
LDY #0
LDA (ADDR1),Y
CLC
ADC #1
STA (ADDR1),Y
RTS
:NGFLAG DS 1
:VALSTR DS 2
:MOD10 DS 2