AppleIIAsm-Collection/source/disk7_convert/T.SUB.HEXASC2HEX
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

100 lines
2.2 KiB
Plaintext

*``````````````````````````````*
* HEXASC2HEX *
* *
*- -*
*- -*
* CLOBBERS: *
* *
* FLAGS: ????---- REG: AXYM *
*- -*
* CYCLES: ??? *
* SIZE: *
*- -*
* USAGE: *
* *
*- -*
* ENTRY *
* *
* TOP OF STACK *
* *
* LOW BYTE OF RETURN ADDRESS *
* HI BYTE OF RETURN ADDRESS *
*- -*
* EXIT *
* *
* TOP OF STACK *
* *
* LOW BYTE OF RETURN ADDRESS *
* HI BYTE OF RETURN ADDRESS *
* *
* .Y = COUNTER; TRASH *
* .X = COUNTER; TRASH *
* .A = LOW BYTE OF RET ADDR *
* *
* [RETURN] = STRING VALUE *
* [RETLEN] = LENGTH OF STRING *
*,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,*
*
HEXASC2HEX
*
** SAVE RETURN ADDRESS
*
PLA
STA RETADR
PLA
STA RETADR+1
*
** GET PARAMETERS
*
PLA
STA ADDR1
PLA
STA ADDR1+1
*
LDY #1
LDA (ADDR1),Y
STA :HI
INY
LDA (ADDR1),Y
STA :LO
*
SEC
SBC #'0'
CMP #10 ; ASCII OFFSET
BCC :CONT
SBC #7 ; SUBTRACT LETTER OFFSET
:CONT
STA :LO
LDA :HI
SEC
SBC #'0'
CMP #10 ; IS NUMBER?
BCC :C2 ; THEN DONE
SBC #7 ; OTHERWISE LETTER OFFSET
:C2
STA :HI
ASL
ASL
ASL
ASL
ORA :LO
*
STA RETURN
LDY #1
STY RETLEN
*
** RESTORE RETURN ADDRESS
*
LDA RETADR+1
PHA
LDA RETADR
PHA
*
RTS ; RETURN
*
** DATA
*
:HI DS 1
:LO DS 1
*