A2osX/SYS/KERNEL.S.CIO.txt
2015-12-10 19:53:30 +01:00

245 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
.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
cmp #13
bne .1
ldx #DEVMGR.COUT
jsr pDevJmp
bcs S.COutA.RTS
lda #10
.1 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
* %s : PSTRING
* \e : ESC
* \n : CR
*--------------------------------------
S.PSTROutA jsr S.GetMemPtrA
S.PSTROutYA >STYA ZPQuickPtr1
ldy #0
.1 jsr S.PSTROut.Next
bne .12
.8 clc
rts
.12 cmp #'\'
bne .2
jsr S.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 S.PSTROut.Next
beq .8
cmp #'d'
bne .3
phy
>PULLA
jsr S.DecOutA
ply
bcc .1
rts
.3 cmp #'D'
bne .4
phy
>PULLYA
jsr S.DecOutYA
ply
bcc .1
rts
.4 cmp #'h'
bne .5
phy
>PULLA
jsr S.HexOutA
ply
bcc .1
rts
.5 cmp #'H'
bne .51
phy
>PULLYA
jsr S.HexOutYA
ply
bcc .1
rts
.51 cmp #'s'
bne .52
jsr S.PSTROutYAS1
bcc .1
rts
.52 cmp #'S'
bne .53
jsr S.PSTROutYAS2
bcc .10
rts
.53 tax
lda #'%'
jsr S.COutA
bcs .9
txa
.6 jsr S.COutA
bcs .9
.10 jmp .1
.9 rts
*--------------------------------------
S.PSTROut.Next tya
eor (ZPQuickPtr1)
beq .8
iny
lda (ZPQuickPtr1),y
.8 rts
*--------------------------------------
S.PSTROutYAS1 phy
>PULLA
jsr S.GetMemPtrA
bra S.PSTROutYAS
S.PSTROutYAS2 phy
>PULLYA
S.PSTROutYAS >STYA ZPQuickPtr2
ldy #0
.1 iny
lda (ZPQuickPtr2),y
jsr S.COutA
bcs .9
tya
eor (ZPQuickPtr2) do not alter C
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