A2osX/BIN/SH.S.IO.txt
2021-07-24 22:42:23 +02:00

287 lines
4.6 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
jmp IO.Reset.Err
*--------------------------------------
IO.Pipe.In jsr IO.Pipe.OpenR Open last created PIPE
bcs .9
pha
ldy #S.PS.hStdIn
lda (pPS),y
>STA.G IO.hIn
pla
ldy #S.PS.hStdIn
sta (pPS),y
.9 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
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
rts
*--------------------------------------
IO.Pipe.Out >PUSHEA.G IO.DEVFIFO
>PUSHWZ mode
>SYSCALL MKFIFO
bcs .9
jsr IO.Pipe.OpenW Open for OUTPUT
bcs .9
pha
ldy #S.PS.hStdOut
lda (pPS),y
>STA.G IO.hOut
pla
ldy #S.PS.hStdOut
sta (pPS),y
.9 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.DEVFIFO
*--------------------------------------
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.MODE+1
lda (ZPCLBuf),y
and #$F0
.9 rts
*--------------------------------------
IO.Exec >PUSHW ZPArgVBufPtr
>PUSHBI S.PS.F.CLOSEONX
>SYSCALL ExecL
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 GetErrMsg
.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