2016-10-29 19:58:21 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.SRC
|
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Convert HEXBUF to ASCBUF decimal padded with 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
HEX2DEC ldx #4
|
|
|
|
|
|
|
|
|
|
.1 stz BCDBUF,x Clear all 5 bytes
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
sed switch to BCD mode
|
|
|
|
|
|
|
|
|
|
ldx #32 let's roll 32 bits
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
.2 jsr HEXBUF.ROL
|
2016-10-29 19:58:21 +00:00
|
|
|
|
|
|
|
|
|
ldy #4
|
|
|
|
|
|
|
|
|
|
.3 lda BCDBUF,y
|
|
|
|
|
adc BCDBUF,y
|
|
|
|
|
sta BCDBUF,y
|
|
|
|
|
dey
|
|
|
|
|
bpl .3
|
|
|
|
|
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
cld
|
|
|
|
|
|
|
|
|
|
ldy #4
|
|
|
|
|
ldx #9
|
|
|
|
|
|
|
|
|
|
.4 lda BCDBUF,y
|
|
|
|
|
pha
|
|
|
|
|
and #$0F
|
|
|
|
|
ora #$30
|
|
|
|
|
sta ASCBUF,x
|
|
|
|
|
dex
|
|
|
|
|
pla
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
ora #$30
|
|
|
|
|
sta ASCBUF,x
|
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .4
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Convert ASCBUF decimal to HEXBUF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
DEC2HEX stz HEXBUF
|
|
|
|
|
stz HEXBUF+1
|
|
|
|
|
stz HEXBUF+2
|
|
|
|
|
stz HEXBUF+3
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.1 lda HEXBUF+3 save HEXBUF for 4+1
|
|
|
|
|
pha
|
|
|
|
|
lda HEXBUF+2
|
|
|
|
|
pha
|
|
|
|
|
lda HEXBUF+1
|
|
|
|
|
pha
|
|
|
|
|
lda HEXBUF
|
|
|
|
|
pha
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr HEXBUF.ROL HEXBUF * 2 -> HEXBUF
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* bcs .9 overflow!!!
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr HEXBUF.ROL HEXBUF * 4 -> HEXBUF
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* bcs .9 overflow!!!
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
pla HEXBUF * 4 + HEXBUF -> HEXBUF
|
2016-10-29 19:58:21 +00:00
|
|
|
|
adc HEXBUF
|
|
|
|
|
sta HEXBUF
|
|
|
|
|
pla
|
|
|
|
|
adc HEXBUF+1
|
|
|
|
|
sta HEXBUF+1
|
|
|
|
|
pla
|
|
|
|
|
adc HEXBUF+2
|
|
|
|
|
sta HEXBUF+2
|
|
|
|
|
pla
|
|
|
|
|
adc HEXBUF+3
|
|
|
|
|
sta HEXBUF+3
|
|
|
|
|
* bcs .99 overflow!!!
|
|
|
|
|
|
2017-01-12 17:43:45 +00:00
|
|
|
|
jsr HEXBUF.ROL HEXBUF * 10 -> HEXBUF
|
2016-10-29 19:58:21 +00:00
|
|
|
|
* bcs .99 overflow!!!
|
|
|
|
|
|
|
|
|
|
inx
|
|
|
|
|
lda ASCBUF,x
|
|
|
|
|
and #$0F
|
|
|
|
|
|
|
|
|
|
adc HEXBUF
|
|
|
|
|
sta HEXBUF
|
|
|
|
|
bcc .2
|
|
|
|
|
inc HEXBUF+1
|
|
|
|
|
bne .2
|
|
|
|
|
inc HEXBUF+2
|
|
|
|
|
bne .2
|
|
|
|
|
inc HEXBUF+3
|
|
|
|
|
|
|
|
|
|
.2 cpx ASCBUF
|
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
*.9 pla discard saved HEXBUF
|
|
|
|
|
* pla
|
|
|
|
|
* pla
|
|
|
|
|
* pla
|
|
|
|
|
*.99 rts
|
|
|
|
|
*--------------------------------------
|
2017-01-12 17:43:45 +00:00
|
|
|
|
HEXBUF.ROL asl HEXBUF
|
|
|
|
|
rol HEXBUF+1
|
|
|
|
|
rol HEXBUF+2
|
|
|
|
|
rol HEXBUF+3
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-10-29 19:58:21 +00:00
|
|
|
|
HEXBUF .BS 4 32 bits max
|
|
|
|
|
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
|
|
|
|
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE SYS/KERNEL.S.CNV
|
|
|
|
|
LOAD SYS/KERNEL.S
|
|
|
|
|
ASM
|