A2osX/SYS/KERNEL.S.CHR.txt

240 lines
4.8 KiB
Plaintext
Raw Normal View History

2017-01-12 17:43:45 +00:00
PR#3
PREFIX /A2OSX.BUILD
LOMEM $A00
2017-01-12 17:43:45 +00:00
INC 1
AUTO 6
*/--------------------------------------
* # FPutCAY
2017-01-12 17:43:45 +00:00
* Print A (char) to File
* ## In:
2017-01-12 17:43:45 +00:00
* A : char to print
* Y = hFILE
* ## Out:
2017-01-12 17:43:45 +00:00
* CC = success
*\--------------------------------------
K.FPutCAY sta K.PutC.Char
sty K.PutC.Node
tya
phy
bne K.PutCA.1
K.PutCA.8 ply
clc
rts
*/--------------------------------------
* # PutCA
2017-01-12 17:43:45 +00:00
* Print A (char) to StdOut
* ## In:
2017-01-12 17:43:45 +00:00
* A : char to print
* ## Out:
2017-01-12 17:43:45 +00:00
* CC = success
*\--------------------------------------
K.PutCA sta K.PutC.Char
phy
ldy #S.PS.hStdOut
lda (pPs),y
beq K.PutCA.8 NUL
phx
K.PutCA.1 sta K.PutC.Node
jsr K.GetMemPtrA
>STYA pDev
ldy #S.NODE.T
lda (pDev),y
asl
tax
jsr K.PutCA.Jmp
plx
ply
rts
*--------------------------------------
K.PutCA.Jmp jmp (.1,x)
.1 .DA K.PutCA.REG
.DA K.CHR.IOERR DIR
.DA K.PutCA.CDEV
.DA K.CHR.IOERR BDEV
.DA K.CHR.IOERR LNK
.DA K.CHR.IOERR DSOCK
.DA K.PutCA.SSOCK
.DA K.PutCA.FIFO
*--------------------------------------
K.PutCA.REG lda K.PutC.Node
ldy K.PutC.Char
jmp K.FWriteAY
*--------------------------------------
K.PutCA.CDEV ldy #S.NODE.DEV.JMP
lda (pDev),y
sta .1+1
iny
lda (pDev),y
sta .1+2
lda K.PutC.Char
ldx #DEVMGR.WRITE
.1 jmp $ffff
*--------------------------------------
K.PutCA.SSOCK lda (pDev) #S.NODE.HANDLER
jsr K.GetMemPtrA
>STYA .1
ldy #S.NODE.SSOCK.HSKT
>PUSHB (pDev),y
>PUSHB K.PutC.Char
ldy #S.NODE.SSOCK.WRITE
lda (pDev),y
tax Function Offset for write
.1 jmp $ffff
2017-01-12 17:43:45 +00:00
*--------------------------------------
K.PutCA.FIFO ldy #S.NODE.FIFO.S
lda (pDev),y
beq .9 Remote PS did not opened yet the pipe
cmp #S.NODE.FIFO.S.Closed
beq .99 Remote PS closed the Pipe
ldy #S.NODE.FIFO.hMem
lda (pDev),y
jsr K.GetMemPtrA
>STYA .1+2
ldy #S.NODE.FIFO.Head
lda (pDev),y
inc
dey #S.NODE.FIFO.Tail
cmp (pDev),y
beq .9 FIFO is full
iny
sta (pDev),y
tay
lda K.PutC.Char
.1 sta $ffff,y
clc
rts
.9 lda #MLI.ERR.VOLFULL
sec
rts
.99 lda #MLI.ERR.EOF
sec
rts
*--------------------------------------
K.PutC.Char .BS 1
K.PutC.Node .BS 1
*/--------------------------------------
* # FGetCA
2017-01-12 17:43:45 +00:00
* Get char from File
* ## In:
2017-01-12 17:43:45 +00:00
* A = hFILE
* ## Out:
2017-01-12 17:43:45 +00:00
* CC = success
* A = char
*\--------------------------------------
*/--------------------------------------
* # GetC
2017-01-12 17:43:45 +00:00
* Get char from StdIn
* ## In:
2017-01-12 17:43:45 +00:00
* none.
* ## Out:
2017-01-12 17:43:45 +00:00
* CC = success
* A = char
*\--------------------------------------
K.GetC ldy #S.PS.hStdIn
lda (pPs),y
K.FGetCA sta K.PutC.Node
2017-01-12 17:43:45 +00:00
jsr K.GetMemPtrA
>STYA pDev
ldy #S.NODE.T
lda (pDev),y
asl
tax
jmp (.1,x)
.1 .DA K.GetC.REG
.DA K.CHR.IOERR DIR
.DA K.GetC.CDEV
.DA K.CHR.IOERR BDEV
.DA K.CHR.IOERR LNK
.DA K.CHR.IOERR DSOCK
.DA K.GetC.SSOCK
.DA K.GetC.FIFO
*--------------------------------------
K.GetC.REG lda K.PutC.Node
jmp K.FReadA
2017-01-12 17:43:45 +00:00
*--------------------------------------
K.GetC.CDEV ldx #DEVMGR.READ
ldy #S.NODE.DEV.JMP
lda (pDev),y
sta .1+1
iny
lda (pDev),y
sta .1+2
.1 jmp $ffff
*--------------------------------------
K.GetC.SSOCK lda (pDev) #S.NODE.HANDLER
jsr K.GetMemPtrA
>STYA .1
ldy #S.NODE.SSOCK.READ
lda (pDev),y
tax Function Offset for READ
ldy #S.NODE.SSOCK.HSKT
lda (pDev),y
.1 jmp $ffff
2017-01-12 17:43:45 +00:00
*--------------------------------------
K.GetC.FIFO
*/--------------------------------------
* # FPutS
* Write String to FILE
* ## In:
2017-01-12 17:43:45 +00:00
* PUSHW : CPtr
* PUSHB : hFILE
* ## Out:
2017-01-12 17:43:45 +00:00
* CC = success
*\--------------------------------------
K.FPutS
*/--------------------------------------
* # PutSYA
* Write String to StdOut
* ## In:
2017-01-12 17:43:45 +00:00
* Y,A : CPtr
* ## Out:
2017-01-12 17:43:45 +00:00
* CC = success
*\--------------------------------------
K.PutSYA
*/--------------------------------------
* # FGetS
* Read String From FILE
* ## In:
* PUSHW : CPtr
* PUSHB : hFILE
* ## Out:
* CC = success
*\--------------------------------------
2017-01-12 17:43:45 +00:00
K.FGetS
*/--------------------------------------
* # GetSYA
* Read String From StdIn
* ## In:
* Y,A : CPtr
* ## Out:
* CC = success
*\--------------------------------------
2017-01-12 17:43:45 +00:00
K.GetSYA
bra *
*--------------------------------------
K.CHR.IOERR lda #MLI.ERR.IO
sec
rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.CHR
LOAD /A2OSX.SRC/SYS/KERNEL.S
2017-01-12 17:43:45 +00:00
ASM