Post by stiggity on Oct 22, 2022 22:41:36 GMT
My programming skills arent that good, but i Love learning new things having to deal with Commodore computers.. the below routine was pieced together over the past couple days, please forgive my ignorance..
inser
writereg = $CDCC
lowb = $FC
midb = $FB
hib = $FA
*=$1300
jmp setup
jmp main1
setup lda #0
STA LOWB
STA MIDB
STA HIB
rts
main1 ldy #0
- lda #0
sta itoabin,y
sta itoabcd,y
sta itoaflag ,y
sta itoanumber,y
iny
cpy #4
bne -
LDA lowb ; byte 1 location
CLC
ADC #128 ; 128 in your example
STA lowb
BCS addmid ; the addition caused carry (to next byte)
JMP +
addmid INC midb ; byte 2 location
BEQ addhi ; mid byte reached zero after inc (now 0, next one must increase)
JMP +
addhi INC hib ; highest counting byte (byte 3)
+ lda lowb
ldy midb
ldx hib
sta itoaBin+0
sty itoaBin+1
stx itoaBin+2
ldy #24
sed
itoaNextBit = *
asl itoaBin+0
rol itoaBin+1
rol itoaBin+2
ldx #3
itoa1 lda itoaBcd,x
adc itoaBcd,x
sta itoaBcd,x
dex
bpl itoa1
dey
bne itoaNextBit
cld
ldx #0
ldy #0
itoa2 lda itoaBcd,x
jsr itoaPutHex
inx
cpx #4
bcc itoa2
lda #0
jsr itoaPoke
ldx #$00
ldy #$00
jsr setadr
; strip leading spaces
ldx #0
stx temp
itoa41 lda itoaNumber,x
beq itoa61
cmp #" "
beq itoa51
jsr $CDCA
itoa51 inc temp
ldx temp
bne itoa41
itoa61 rts
;********************************************
ITOAPUTHEX = *
PHA
LSR
LSR
LSR
LSR
JSR ITOAPUTDIGIT
PLA
AND #$0F
ITOAPUTDIGIT = *
CMP ITOAFLAG
BNE ITOA3
CPY #7
BCS ITOA3
LDA #$20
BNE ITOAPOKE
ITOA3 ORA #$30
STA ITOAFLAG
ITOAPOKE = *
STA ITOANUMBER,Y
INY
RTS
SETADR PHA ;PRESERVE REGISTERS
TXA
PHA
TYA ;VRAM ADDRESS MSB
LDX #$12 ;SELECT VRAM ADDRESS REGISTER MSB (18)
JSR WRITEREG ;$CDCC SET ADDRESS MSB
PLA ;VRAM ADDRESS LSB
INX ;SELECT VRAM ADDRESS REGISTER LSB (19)
JSR WRITEREG ;$CDCC SET ADDRESS LSB
TAX ;RESTORE
PLA
RTS
ITOABIN .BYTE 0,0,0
ITOABCD .BYTE 0,0,0,0
ITOAFLAG .BYTE 0
ITOANUMBER .BYTE 0,0,0
temp .byte 0