A2osX/SYS/KERNEL.S.CIO.txt
2016-09-21 17:20:37 +02:00

248 lines
3.5 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
*--------------------------------------
K.DecOutA tay
lda #0
K.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 K.COutA
bcs .9
.6 lda BCD,x
and #$0F
bne .7
bit bL0Flag
bpl .8
.7 sec
ror bL0Flag
ora #$30
jsr K.COutA
bcs .9
.8 dex
bpl .4
bit bL0Flag
bmi .9
lda #$30
jsr K.COutA
.9 rts
*--------------------------------------
K.HexOutYA phy
jsr K.HexOutA
bcs K.COutA.RTS
pla
*--------------------------------------
K.HexOutA pha
lsr
lsr
lsr
lsr
ora #$30
cmp #$3A
bcc .1
adc #6
.1 jsr K.COutA
bcs K.COutA.RTS
pla
and #$0F
ora #$30
cmp #$3A
bcc K.COutA
adc #6
*--------------------------------------
K.COutA phx
phy
cmp #13
bne .1
ldx #DEVMGR.COUT
jsr pDevJmp
bcs .2
lda #10
.1 ldx #DEVMGR.COUT
jsr pDevJmp
.2 ply
plx
K.COutA.RTS rts
*--------------------------------------
* Mini printf for PSTR
* %d : byte
* %D : word
* %h : hex byte
* %H : hex word
* %s : hSTR
* %S : PSTR
* \e : ESC
* \n : CR
*--------------------------------------
K.PStrOutYA >STYA ZPQuickPtr1
ldy #0
.1 jsr K.PStrOut.Next
bne .12
.8 clc
rts
.12 cmp #'\'
bne .2
jsr K.PStrOut.Next
beq .8
cmp #'e'
bne .11
lda #27
bra .6
.11 cmp #'n'
bne .6
lda #13
bra .6
.2 cmp #'%'
bne .6
jsr K.PStrOut.Next
beq .8
cmp #'d'
bne .3
phy
>PULLA
jsr K.DecOutA
ply
bcc .1
rts
.3 cmp #'D'
bne .4
phy
>PULLYA
jsr K.DecOutYA
ply
bcc .1
rts
.4 cmp #'h'
bne .5
phy
>PULLA
jsr K.HexOutA
ply
bcc .1
rts
.5 cmp #'H'
bne .51
phy
>PULLYA
jsr K.HexOutYA
ply
bcc .1
rts
.51 cmp #'s'
bne .52
jsr K.PStrOutYAS1
bcc .1
rts
.52 cmp #'S'
bne .53
jsr K.PStrOutYAS2
bcc .10
rts
.53 tax
lda #'%'
jsr K.COutA
bcs .9
txa
.6 jsr K.COutA
bcs .9
.10 jmp .1
.9 rts
*--------------------------------------
K.PStrOut.Next tya
eor (ZPQuickPtr1)
beq .8
iny
lda (ZPQuickPtr1),y
.8 rts
*--------------------------------------
K.PStrOutYAS1 phy
>PULLA
jsr K.GetMemPtrA
bra K.PStrOutYAS
K.PStrOutYAS2 phy
>PULLYA
K.PStrOutYAS >STYA ZPQuickPtr2
clc
lda (ZPQuickPtr2)
tax
beq .9
ldy #1
.1 lda (ZPQuickPtr2),y
jsr K.COutA
bcs .9
iny
dex
bne .1
.9 ply
rts
*--------------------------------------
HEX .BS 2
BCD .BS 3
bL0Flag .BS 1
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.CIO
LOAD SYS/KERNEL.S
ASM