Edit: I'd originally asked what the function of the routine below was.
It was determined that this code takes a BCD number and converts it to hexadecimal.
I originally had generic mnemonics on all the addresses, but they have now been named properly
(loop counter, address output, and 2 scratchpad bytes).
It was determined that this code takes a BCD number and converts it to hexadecimal.
I originally had generic mnemonics on all the addresses, but they have now been named properly
(loop counter, address output, and 2 scratchpad bytes).
Code:
func01:
CLC
CLR temp6
CLR addrL
CLR addrM
CLR addrH
LDA A #$07
STA A loopCount
LDX #$:0C27 // readout
func01_1:
LDA A addrM
LDA B addrL
ADD B $:00,X
STA B addrL
BCC func01_2
ADD A #$01
STA A temp6
STA A addrM
BCC func01_2
LDA A addrH
ADD A #$01
STA A addrH
LDA A temp6
func01_2:
DEC loopCount
BNE func01_5
RTS
func01_5:
ASL D
STA B addrL
STA A temp6
STA A addrM
ROL addrH
LDA A addrH
STA A temp7
LDA A temp6
ASL D
ROL temp7
ASL D
ROL temp7
ADD B addrL
STA B addrL
ADC A addrM
STA A addrM
BCC func01_6
INC addrH
func01_6:
LDA A temp7
ADD A addrH
STA A addrH
DEX
BRA func01_1
Last edited: