mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-26 13:49:18 +00:00
240 lines
4.8 KiB
Plaintext
240 lines
4.8 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
*/--------------------------------------
|
||
* # FPutCAY
|
||
* Print A (char) to File
|
||
* ## In:
|
||
* A : char to print
|
||
* Y = hFILE
|
||
* ## Out:
|
||
* 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
|
||
* Print A (char) to StdOut
|
||
* ## In:
|
||
* A : char to print
|
||
* ## Out:
|
||
* 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
|
||
*--------------------------------------
|
||
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
|
||
* Get char from File
|
||
* ## In:
|
||
* A = hFILE
|
||
* ## Out:
|
||
* CC = success
|
||
* A = char
|
||
*\--------------------------------------
|
||
*/--------------------------------------
|
||
* # GetC
|
||
* Get char from StdIn
|
||
* ## In:
|
||
* none.
|
||
* ## Out:
|
||
* CC = success
|
||
* A = char
|
||
*\--------------------------------------
|
||
K.GetC ldy #S.PS.hStdIn
|
||
lda (pPs),y
|
||
|
||
K.FGetCA sta K.PutC.Node
|
||
|
||
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
|
||
*--------------------------------------
|
||
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
|
||
*--------------------------------------
|
||
K.GetC.FIFO
|
||
*/--------------------------------------
|
||
* # FPutS
|
||
* Write String to FILE
|
||
* ## In:
|
||
* PUSHW : CPtr
|
||
* PUSHB : hFILE
|
||
* ## Out:
|
||
* CC = success
|
||
*\--------------------------------------
|
||
K.FPutS
|
||
*/--------------------------------------
|
||
* # PutSYA
|
||
* Write String to StdOut
|
||
* ## In:
|
||
* Y,A : CPtr
|
||
* ## Out:
|
||
* CC = success
|
||
*\--------------------------------------
|
||
K.PutSYA
|
||
*/--------------------------------------
|
||
* # FGetS
|
||
* Read String From FILE
|
||
* ## In:
|
||
* PUSHW : CPtr
|
||
* PUSHB : hFILE
|
||
* ## Out:
|
||
* CC = success
|
||
*\--------------------------------------
|
||
K.FGetS
|
||
*/--------------------------------------
|
||
* # GetSYA
|
||
* Read String From StdIn
|
||
* ## In:
|
||
* Y,A : CPtr
|
||
* ## Out:
|
||
* CC = success
|
||
*\--------------------------------------
|
||
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
|
||
ASM
|