AppleIIAsm-Collection/source/disk7_convert/T.MIN.SUB.HEX2INTASC
nathanriggs c8cac53c5e Rev 0.4 updates
Massive updates that changes the way most subroutines are handled. Major bugfixes, various utilities added, started higher-level libraries.
2019-04-26 18:49:10 -04:00

101 lines
2.0 KiB
Plaintext

HEX2INTASC
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
LDY #0
LDA (ADDR1),Y
STA RETLEN
RTS
:NGFLAG DS 1
:VALSTR DS 2
:MOD10 DS 2