A2osX/BIN/SH.S.IO.txt
2020-05-17 19:34:32 +02:00

280 lines
4.7 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.

NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
IO.Reset jsr IO.Reset.In
jsr IO.Reset.Out
jsr IO.Reset.Err
IO.Reset.9 rts
*--------------------------------------
IO.Load >PUSHYA
>PUSHBI O.RDONLY
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL LoadTxtFile
rts
*--------------------------------------
IO.Pipe.In jsr IO.Pipe.OpenR Open last created PIPE
bcs IO.Set.RTS
pha
ldy #S.PS.hStdIn
lda (pPS),y
>STA.G IO.hIn
pla
ldy #S.PS.hStdIn
sta (pPS),y
rts
*--------------------------------------
IO.Set.In pha
jsr IO.Reset.In
ldy #S.PS.hStdIn
lda (pPS),y
>STA.G IO.hIn
pla
ldy #S.PS.hStdIn
sta (pPS),y
IO.Set.RTS rts
*--------------------------------------
IO.Pop.In clc
.HS B0 BCS
*--------------------------------------
IO.Reset.In sec
>LDA.G IO.hIn
beq .8
bcc .1
ldy #S.PS.hStdIn
jsr IO.Close.Y
.1 ldy #S.PS.hStdIn
sta (pPS),y
>STZ.G IO.hIn
.8 clc
IO.Reset.In.RTS rts
*--------------------------------------
IO.Pipe.Out >PUSHEA.G IO.FIFO
>PUSHWZ mode
>SYSCALL MKFIFO
bcs IO.Reset.In.RTS Create a new PIPE
jsr IO.Pipe.OpenW Open for OUTPUT
bcs IO.Reset.In.RTS
pha
ldy #S.PS.hStdOut
lda (pPS),y
>STA.G IO.hOut
pla
ldy #S.PS.hStdOut
sta (pPS),y
rts
*--------------------------------------
IO.Set.Out pha
jsr IO.Reset.Out
ldy #S.PS.hStdOut
lda (pPS),y
>STA.G IO.hOut
pla
ldy #S.PS.hStdOut
sta (pPS),y
clc
rts
*--------------------------------------
IO.Pop.Out clc
.HS B0 BCS
*--------------------------------------
IO.Reset.Out sec
IO.Reset.OutC >LDA.G IO.hOut
beq .8
bcc .1
ldy #S.PS.hStdOut
jsr IO.Close.Y
.1 ldy #S.PS.hStdOut
sta (pPS),y
>STZ.G IO.hOut
.8 rts
*--------------------------------------
IO.Set.Err pha
jsr IO.Reset.Err
ldy #S.PS.hStdErr
lda (pPS),y
>STA.G IO.hErr
pla
ldy #S.PS.hStdErr
sta (pPS),y
rts
*--------------------------------------
IO.Reset.Err >LDA.G IO.hErr
beq .8
ldy #S.PS.hStdErr
jsr IO.Close.Y
ldy #S.PS.hStdErr
sta (pPS),y
>STZ.G IO.hErr
.8 rts
*--------------------------------------
IO.Close.Y pha
lda (pPS),y
>SYSCALL FClose
pla
rts
*--------------------------------------
IO.Pipe.OpenR ldx #O.RDONLY+O.TEXT
.HS 2C BIT ABS
IO.Pipe.OpenW ldx #O.WRONLY+O.TEXT
>LEA.G IO.FIFO
*--------------------------------------
IO.FOpenYAX >PUSHYA
txa
>PUSHA
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
rts
*--------------------------------------
IO.StatArgVBufPtr
>LDYA ZPArgVBufPtr
IO.StatYA >PUSHYA
>PUSHW ZPCLBuf
>SYSCALL Stat
bcs .9
ldy #S.STAT.P.TYPE
lda (ZPCLBuf),y
.9 rts
*--------------------------------------
IO.PrintBatchErrMsg
>LDYA ZPInputBuf
>STYA ZPPtr1
ldy #S.PS.RC
lda (pPS),y
cmp #E.SYN
beq .10
>LDYA ZPInputCmdPtr
bra .11
.10 >LDYA ZPInputBufPtr
.11 >STYA ZPPtr2
stz ZPTmpW Line Count
stz ZPTmpW+1
.1 inc ZPTmpW
bne .2
inc ZPTmpW+1
.2 ldy #$ff
.3 iny
lda (ZPPtr1),y
beq .4 EoF
cmp #C.CR
bne .3 Scan until EoL
.4 tya
clc
adc ZPPtr1
tax
lda ZPPtr1+1
adc #0
pha
cpx ZPPtr2
sbc ZPPtr2+1
pla
bcs .41
inx
bne .40
inc
.40 stx ZPPtr1
sta ZPPtr1+1
bra .1
.41 ldy #$ff
.5 iny
lda (ZPPtr1),y
sta (ZPCLBuf),y
beq .6
eor #C.CR
bne .5
sta (ZPCLBuf),y
.6 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.BATCHLINE
>PUSHW ZPCLBuf
>PUSHBI 2
>SYSCALL FPrintF
ldy #$ff
ldx #'-'
.7 iny
lda (ZPCLBuf),y
beq .8
txa
sta (ZPCLBuf),y
bra .7
.8 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.BATCHERR
>PUSHW ZPCLBuf
>PUSHW ZPTmpW
>PUSHBI 4
>SYSCALL FPrintF
rts
*--------------------------------------
IO.PrintErrMsg ldy #S.PS.RC
lda (pPS),y
>PUSHA
>PUSHW ZPCLBuf
>SYSCALL GetErrorMessage
.8 ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.ERROR
ldy #S.PS.RC
lda (pPS),y
>PUSHA
>PUSHW ZPCLBuf
>PUSHBI 3
>SYSCALL FPrintF
rts
*--------------------------------------
MAN
SAVE USR/SRC/BIN/SH.S.IO
LOAD USR/SRC/BIN/SH.S
ASM