A2osX/SHARED/X.PRINTF.S.txt
2019-04-10 08:45:09 +01:00

228 lines
3.8 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
PrintFYA sty PrintFYA.Next+1
sta PrintFYA.Next+2
pla
sta PrintFYA.99+1
pla
sta PrintFYA.98+1
lda $C011 RDLCBNK2
sta PrintFYA.91+1
lda $C012 RDLCRAM
sta PrintFYA.90+1
lda $C08A RROMBNK1, make sure $D000-$FFFF ROM selected
lda $CFFF get access to $C800-$CFFF internal ROM
PrintFYA.1 stz X.b0Flag
stz X.DigitCount
jsr PrintFYA.Next
beq PrintFYA.90
cmp #'%'
bne .7
.2 jsr PrintFYA.Next
beq PrintFYA.90
cmp #'0'
bne .3
ror X.b0Flag beq -> CS
bra .2
.3 bcc .4
cmp #'9'+1
bcs .4
and #$0f
sta X.DigitCount
bra .2
.4 ldx #PrintFYA.Tbl-PrintFYA.Esc-1
.5 cmp PrintFYA.Esc,x
beq .6
dex
bpl .5
bra PrintFYA.1
.6 txa
asl
tax
jmp (PrintFYA.Tbl,x)
.7 cmp #'\'
bne .8
jsr PrintFYA.Next
beq PrintFYA.90
cmp #'n'
bne .8
lda #$0D
.8 ora #$80
jsr $FDED COUT
bra PrintFYA.1
PrintFYA.90 lda #$ff
bpl PrintFYA.98 ROM was selected, nothing to do
PrintFYA.91 lda #$ff
bmi PrintFYA.92 RAM bank 2 was selected
ldx #$8B RRAMWRAMBNK1
.HS 2C bit abs
PrintFYA.92 ldx #$83 RRAMWRAMBNK2
lda $C000,x
lda $C000,x
PrintFYA.98 lda #$ff Self modified RTS HI
pha
PrintFYA.99 lda #$ff Self modified RTS LOPrintFYAPrintFYA
pha
rts
*--------------------------------------
PrintFYA.Next lda $ffff
beq .8
inc PrintFYA.Next+1
bne .8
inc PrintFYA.Next+2 Always !=0
.8 rts
*--------------------------------------
PrintFYA.Esc .AS "dDhHS"
PrintFYA.Tbl .DA PrintFYA.D
.DA PrintFYA.DD
.DA PrintFYA.H
.DA PrintFYA.HH
.DA PrintFYA.S
*--------------------------------------
PrintFYA.D ldx #0
.HS D0 bne
PrintFYA.DD plx
pla
sta X.HexBuffer
stx X.HexBuffer+1
stz X.BCDBuffer
stz X.BCDBuffer+1
stz X.BCDBuffer+2
ldx #16 let's roll 16 bits
sed
.2 asl X.HexBuffer
rol X.HexBuffer+1
php cpy will disturb carry while BCD adc
ldy #0
.3 plp
lda X.BCDBuffer,y
adc X.BCDBuffer,y
sta X.BCDBuffer,y
php
iny
cpy #3 Last byte of X.BCDBufferBUF?
bne .3
plp
dex
bne .2
cld
ldx #0
ldy #5
.4 lda X.BCDBuffer,x
pha
and #$0F
ora #$B0
sta X.DigitBuffer,y
dey
pla
lsr
lsr
lsr
lsr
ora #$B0
sta X.DigitBuffer,y
inx
dey
bpl .4
lda X.DigitCount
beq .5
lda #6
sec
sbc X.DigitCount
.5 tay
.6 lda X.DigitBuffer,y
cmp #"0"
beq .7
sec
ror X.b0Flag
bra .8
.7 cpy #5
beq .8
lda #" "
bit X.b0Flag
bpl .81
lda #"0"
.8 phy
jsr $FDED COUT
ply
.81 iny
cpy #6
bne .6
.9 jmp PrintFYA.1
*--------------------------------------
PrintFYA.HH pla
jsr $FDDA PRBYTE
PrintFYA.H pla
jsr $FDDA PRBYTE
jmp PrintFYA.1
*--------------------------------------
PrintFYA.S pla
sta .1+2
sta .2+2
pla
sta .1+1
sta .2+1
.1 lda $ffff
beq .9
tax
ldy #1
.2 lda $ffff,y
ora #$80
jsr $FDED COUT
iny
dex
bne .2
.9 jmp PrintFYA.1
*--------------------------------------
X.HexBuffer .BS 2
X.BCDBuffer .BS 3
X.b0Flag .BS 1
X.DigitCount .BS 1
X.DigitBuffer .BS 6
*--------------------------------------
MAN
SAVE USR/SRC/SHARED/X.PRINTF.S