A2osX/SYS/KERNEL.S.CIO.txt
2015-11-22 23:30:06 +01:00

202 lines
2.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.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
*--------------------------------------
S.DecOutA tay
lda #0
S.DecOutYA >STYA HEX
stz BCD
stz BCD+1
stz BCD+2
ldx #16 let's roll 16 bits
sed
.2 asl HEX
rol HEX+1
php cpy will disturb carry while BCD adc
ldy #0
.3 plp
lda BCD,y
adc BCD,y
sta BCD,y
php
iny
cpy #3 Last byte of BCDBUF?
bne .3
plp
dex
bne .2
cld
stz bL0Flag
ldx #2
.4 lda BCD,x
lsr
lsr
lsr
lsr
bne .5
bit bL0Flag
bpl .6
.5 sec
ror bL0Flag
ora #$30
jsr S.COutA
bcs .9
.6 lda BCD,x
and #$0F
bne .7
bit bL0Flag
bpl .8
.7 sec
ror bL0Flag
ora #$30
jsr S.COutA
bcs .9
.8 dex
bpl .4
bit bL0Flag
bmi .9
lda #$30
jsr S.COutA
.9 rts
*--------------------------------------
S.HexOutYA phy
jsr S.HexOutA
bcs S.COutA.RTS
pla
*--------------------------------------
S.HexOutA pha
lsr
lsr
lsr
lsr
ora #$30
cmp #$3A
bcc .1
adc #6
.1 jsr S.COutA
bcs S.COutA.RTS
pla
and #$0F
ora #$30
cmp #$3A
bcc S.COutA
adc #6
*--------------------------------------
S.COutA phx
phy
ldx #DEVMGR.COUT
jsr pDevJmp
ply
plx
S.COutA.RTS rts
*--------------------------------------
* Mini printf for PSTR
* %d : byte
* %D : word
* %h : hex byte
* %H : hex word
* \n : CR
*--------------------------------------
S.PSTROutA jsr S.GetMemPtrA
S.PSTROutYA >STYA ZPQuickPtr1
ldy #0
.1 iny
lda (ZPQuickPtr1),y
cmp #'\'
bne .2
tya
cmp (ZPQuickPtr1)
beq .8
iny
lda (ZPQuickPtr1),y
cmp #'n'
bne .6
lda #13
bra .6
.2 cmp #'%'
bne .6
tya
cmp (ZPQuickPtr1)
beq .8
iny
lda (ZPQuickPtr1),y
cmp #'d'
bne .3
phy
>PULLA
jsr S.DecOutA
ply
bcc .7
rts
.3 cmp #'D'
bne .4
phy
>PULLYA
jsr S.DecOutYA
ply
bcc .7
rts
.4 cmp #'h'
bne .5
phy
>PULLA
jsr S.HexOutA
ply
bcc .7
rts
.5 cmp #'H'
bne .51
phy
>PULLYA
jsr S.HexOutYA
ply
bcc .7
rts
.51 tax
lda #'%'
jsr S.COutA
bcs .9
txa
.6 jsr S.COutA
bcs .9
.7 tya
cmp (ZPQuickPtr1)
bne .1
.8 clc
.9 rts
*--------------------------------------
HEX .BS 2
BCD .BS 3
bL0Flag .BS 1
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.CIO
LOAD SYS/KERNEL.S
ASM