2018-01-18 06:49:41 +00:00
|
|
|
|
NEW
|
2019-06-02 10:58:46 +02:00
|
|
|
|
AUTO 3,1
|
2016-10-29 21:58:21 +02:00
|
|
|
|
*--------------------------------------
|
2018-11-07 17:11:02 +01:00
|
|
|
|
IO.Reset jsr IO.Reset.In
|
|
|
|
|
jsr IO.Reset.Out
|
2020-12-15 14:23:22 +01:00
|
|
|
|
jmp IO.Reset.Err
|
2019-04-04 16:44:20 +01:00
|
|
|
|
*--------------------------------------
|
2019-10-25 17:09:13 +02:00
|
|
|
|
IO.Pipe.In jsr IO.Pipe.OpenR Open last created PIPE
|
2020-12-15 14:23:22 +01:00
|
|
|
|
bcs .9
|
2019-02-15 16:38:17 +00:00
|
|
|
|
|
2019-10-25 17:09:13 +02:00
|
|
|
|
pha
|
2019-02-26 16:50:42 +00:00
|
|
|
|
|
2019-10-25 17:09:13 +02:00
|
|
|
|
ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>STA.G IO.hIn
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
ldy #S.PS.hStdIn
|
|
|
|
|
sta (pPS),y
|
2020-12-15 14:23:22 +01:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2019-04-04 16:44:20 +01:00
|
|
|
|
*--------------------------------------
|
2018-11-07 17:11:02 +01:00
|
|
|
|
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
|
2020-12-15 14:23:22 +01:00
|
|
|
|
|
|
|
|
|
rts
|
2022-10-09 23:22:46 +02:00
|
|
|
|
*--------------------------------------
|
2019-10-25 17:09:13 +02:00
|
|
|
|
IO.Pop.In clc
|
|
|
|
|
.HS B0 BCS
|
2019-04-04 16:44:20 +01:00
|
|
|
|
*--------------------------------------
|
2019-10-25 17:09:13 +02:00
|
|
|
|
IO.Reset.In sec
|
|
|
|
|
>LDA.G IO.hIn
|
2018-11-07 17:11:02 +01:00
|
|
|
|
beq .8
|
2019-10-25 17:09:13 +02:00
|
|
|
|
bcc .1
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2018-11-07 17:11:02 +01:00
|
|
|
|
ldy #S.PS.hStdIn
|
2019-10-26 16:33:37 +02:00
|
|
|
|
jsr IO.Close.Y
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2019-10-25 17:09:13 +02:00
|
|
|
|
.1 ldy #S.PS.hStdIn
|
2018-11-07 17:11:02 +01:00
|
|
|
|
sta (pPS),y
|
|
|
|
|
>STZ.G IO.hIn
|
2019-10-25 17:09:13 +02:00
|
|
|
|
|
2019-02-15 16:38:17 +00:00
|
|
|
|
.8 clc
|
2020-12-15 14:23:22 +01:00
|
|
|
|
rts
|
2019-04-04 16:44:20 +01:00
|
|
|
|
*--------------------------------------
|
2021-07-24 22:42:23 +02:00
|
|
|
|
IO.Pipe.Out >PUSHEA.G IO.DEVFIFO
|
2020-03-10 17:42:07 +01:00
|
|
|
|
>PUSHWZ mode
|
2019-06-04 08:31:54 +02:00
|
|
|
|
>SYSCALL MKFIFO
|
2020-12-15 14:23:22 +01:00
|
|
|
|
bcs .9
|
2019-02-18 06:42:17 +00:00
|
|
|
|
|
2022-10-09 23:22:46 +02:00
|
|
|
|
jsr IO.Pipe.OpenW Open for OUTPUT
|
2020-12-15 14:23:22 +01:00
|
|
|
|
bcs .9
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2019-10-25 17:09:13 +02:00
|
|
|
|
pha
|
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>STA.G IO.hOut
|
|
|
|
|
pla
|
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
sta (pPS),y
|
|
|
|
|
|
2020-12-15 14:23:22 +01:00
|
|
|
|
.9 rts
|
2018-11-07 17:11:02 +01:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
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
|
2019-10-25 17:09:13 +02:00
|
|
|
|
clc
|
2018-11-07 17:11:02 +01:00
|
|
|
|
rts
|
2022-10-09 23:22:46 +02:00
|
|
|
|
*--------------------------------------
|
2019-10-25 17:09:13 +02:00
|
|
|
|
IO.Pop.Out clc
|
|
|
|
|
.HS B0 BCS
|
2022-10-09 23:22:46 +02:00
|
|
|
|
*--------------------------------------
|
2019-10-25 17:09:13 +02:00
|
|
|
|
IO.Reset.Out sec
|
2019-10-31 11:30:27 +01:00
|
|
|
|
IO.Reset.OutC >LDA.G IO.hOut
|
2018-11-07 17:11:02 +01:00
|
|
|
|
beq .8
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2019-10-25 17:09:13 +02:00
|
|
|
|
bcc .1
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2018-11-07 17:11:02 +01:00
|
|
|
|
ldy #S.PS.hStdOut
|
2019-10-26 16:33:37 +02:00
|
|
|
|
jsr IO.Close.Y
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2019-10-25 17:09:13 +02:00
|
|
|
|
.1 ldy #S.PS.hStdOut
|
2018-11-07 17:11:02 +01:00
|
|
|
|
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
|
2022-10-09 23:22:46 +02:00
|
|
|
|
*--------------------------------------
|
2018-11-07 17:11:02 +01:00
|
|
|
|
IO.Reset.Err >LDA.G IO.hErr
|
|
|
|
|
beq .8
|
2019-10-26 16:33:37 +02:00
|
|
|
|
|
2018-11-07 17:11:02 +01:00
|
|
|
|
ldy #S.PS.hStdErr
|
2019-10-26 16:33:37 +02:00
|
|
|
|
jsr IO.Close.Y
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2018-11-07 17:11:02 +01:00
|
|
|
|
ldy #S.PS.hStdErr
|
|
|
|
|
sta (pPS),y
|
|
|
|
|
>STZ.G IO.hErr
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2019-10-26 16:33:37 +02:00
|
|
|
|
IO.Close.Y pha
|
|
|
|
|
lda (pPS),y
|
2020-02-28 08:21:46 +01:00
|
|
|
|
>SYSCALL FClose
|
2019-10-26 16:33:37 +02:00
|
|
|
|
pla
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-10-25 17:09:13 +02:00
|
|
|
|
IO.Pipe.OpenR ldx #O.RDONLY+O.TEXT
|
|
|
|
|
.HS 2C BIT ABS
|
|
|
|
|
|
|
|
|
|
IO.Pipe.OpenW ldx #O.WRONLY+O.TEXT
|
2020-12-15 14:23:22 +01:00
|
|
|
|
|
|
|
|
|
>LEA.G IO.DEVFIFO
|
2019-10-25 17:09:13 +02:00
|
|
|
|
*--------------------------------------
|
2020-02-14 08:21:56 +01:00
|
|
|
|
IO.FOpenYAX >PUSHYA
|
2019-08-02 16:36:49 +02:00
|
|
|
|
txa
|
|
|
|
|
>PUSHA
|
2020-02-14 08:21:56 +01:00
|
|
|
|
>PUSHBI S.FI.T.TXT
|
|
|
|
|
>PUSHWZ Aux type
|
2020-03-09 17:24:08 +01:00
|
|
|
|
>SYSCALL FOpen
|
2019-08-02 16:36:49 +02:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-01-07 14:44:38 +01:00
|
|
|
|
IO.StatArgVBufPtr
|
|
|
|
|
>LDYA ZPArgVBufPtr
|
2020-02-14 08:21:56 +01:00
|
|
|
|
IO.StatYA >PUSHYA
|
2020-01-07 14:44:38 +01:00
|
|
|
|
>PUSHW ZPCLBuf
|
2020-03-09 17:24:08 +01:00
|
|
|
|
>SYSCALL Stat
|
2020-01-07 14:44:38 +01:00
|
|
|
|
bcs .9
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2021-02-17 17:15:43 +01:00
|
|
|
|
ldy #S.STAT.MODE+1
|
2020-01-07 14:44:38 +01:00
|
|
|
|
lda (ZPCLBuf),y
|
2021-02-17 17:15:43 +01:00
|
|
|
|
and #$F0
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2020-01-07 14:44:38 +01:00
|
|
|
|
.9 rts
|
2019-11-15 15:40:48 +01:00
|
|
|
|
*--------------------------------------
|
2022-10-18 07:56:59 +02:00
|
|
|
|
* set A = `sh -C ls|grep test`
|
2020-08-20 15:20:33 +02:00
|
|
|
|
IO.Exec >PUSHW ZPArgVBufPtr
|
|
|
|
|
>PUSHBI S.PS.F.CLOSEONX
|
|
|
|
|
>SYSCALL ExecL
|
|
|
|
|
rts
|
2022-10-18 07:56:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* >LDYAI 256
|
|
|
|
|
* >SYSCALL GetMem
|
|
|
|
|
* bcs .99
|
|
|
|
|
|
|
|
|
|
* >STYA ZPPtr1
|
|
|
|
|
* phx
|
|
|
|
|
* >PUSHYA
|
|
|
|
|
* >PUSHW L.EXECC
|
|
|
|
|
* >PUSHW.G SH
|
|
|
|
|
* >PUSHW ZPArgVBufPtr
|
|
|
|
|
* >PUSHBI 4
|
|
|
|
|
* >SYSCALL sprintf
|
|
|
|
|
* bcs .98
|
|
|
|
|
|
|
|
|
|
* ldy #S.PS.hStdErr
|
|
|
|
|
* lda (pPS),y
|
|
|
|
|
* >PUSHA
|
|
|
|
|
* >PUSHW ZPPtr1
|
|
|
|
|
* >SYSCALL fputs
|
|
|
|
|
* >DEBUG
|
|
|
|
|
|
|
|
|
|
* >PUSHW ZPPtr1
|
|
|
|
|
* >PUSHBI S.PS.F.CLOSEONX
|
|
|
|
|
* >SYSCALL ExecL
|
|
|
|
|
|
|
|
|
|
*.98 plx
|
|
|
|
|
|
|
|
|
|
* php
|
|
|
|
|
* pha
|
|
|
|
|
|
|
|
|
|
* txa
|
|
|
|
|
* >SYSCALL freemem
|
|
|
|
|
|
|
|
|
|
* pla
|
|
|
|
|
* plp
|
|
|
|
|
|
|
|
|
|
*.99 rts
|
2020-08-20 15:20:33 +02:00
|
|
|
|
*--------------------------------------
|
2018-11-10 15:30:09 +01:00
|
|
|
|
IO.PrintBatchErrMsg
|
2019-02-14 14:51:24 +00:00
|
|
|
|
>LDYA ZPInputBuf
|
2018-11-10 15:30:09 +01:00
|
|
|
|
>STYA ZPPtr1
|
2020-08-25 08:01:56 +02:00
|
|
|
|
|
2019-03-01 14:36:20 +00:00
|
|
|
|
ldy #S.PS.RC
|
2020-02-28 08:21:46 +01:00
|
|
|
|
lda (pPS),y
|
2019-03-05 16:49:34 +00:00
|
|
|
|
cmp #E.SYN
|
2019-03-01 14:36:20 +00:00
|
|
|
|
beq .10
|
2019-11-30 14:37:55 +01:00
|
|
|
|
|
2019-03-01 14:36:20 +00:00
|
|
|
|
>LDYA ZPInputCmdPtr
|
|
|
|
|
bra .11
|
2019-11-30 14:37:55 +01:00
|
|
|
|
|
2019-03-01 14:36:20 +00:00
|
|
|
|
.10 >LDYA ZPInputBufPtr
|
|
|
|
|
|
|
|
|
|
.11 >STYA ZPPtr2
|
2020-08-25 08:01:56 +02:00
|
|
|
|
|
2019-07-31 17:10:59 +02:00
|
|
|
|
stz ZPTmpW Line Count
|
|
|
|
|
stz ZPTmpW+1
|
2018-11-10 15:30:09 +01:00
|
|
|
|
|
2019-07-31 17:10:59 +02:00
|
|
|
|
.1 inc ZPTmpW
|
2018-11-10 15:30:09 +01:00
|
|
|
|
bne .2
|
2021-05-11 20:44:13 +02:00
|
|
|
|
|
2019-07-31 17:10:59 +02:00
|
|
|
|
inc ZPTmpW+1
|
2018-11-10 15:30:09 +01:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
.2 ldy #$ff
|
|
|
|
|
|
|
|
|
|
.3 iny
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .4 EoF
|
|
|
|
|
|
|
|
|
|
cmp #C.CR
|
|
|
|
|
bne .3 Scan until EoL
|
2020-08-25 08:01:56 +02:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
.4 tya
|
|
|
|
|
clc
|
|
|
|
|
adc ZPPtr1
|
|
|
|
|
tax
|
2018-11-10 15:30:09 +01:00
|
|
|
|
lda ZPPtr1+1
|
2019-02-14 14:51:24 +00:00
|
|
|
|
adc #0
|
|
|
|
|
pha
|
|
|
|
|
|
2019-03-01 14:36:20 +00:00
|
|
|
|
cpx ZPPtr2
|
|
|
|
|
sbc ZPPtr2+1
|
2019-02-14 14:51:24 +00:00
|
|
|
|
pla
|
|
|
|
|
bcs .41
|
2020-08-25 08:01:56 +02:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
inx
|
|
|
|
|
bne .40
|
2020-08-25 08:01:56 +02:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
inc
|
2020-08-25 08:01:56 +02:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
.40 stx ZPPtr1
|
|
|
|
|
sta ZPPtr1+1
|
|
|
|
|
bra .1
|
2018-11-10 15:30:09 +01:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
.41 ldy #$ff
|
2018-11-10 15:30:09 +01:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
.5 iny
|
|
|
|
|
lda (ZPPtr1),y
|
2019-06-04 17:49:58 +02:00
|
|
|
|
sta (ZPCLBuf),y
|
2018-11-10 15:30:09 +01:00
|
|
|
|
beq .6
|
2019-02-14 14:51:24 +00:00
|
|
|
|
|
2019-06-04 17:49:58 +02:00
|
|
|
|
eor #C.CR
|
|
|
|
|
bne .5
|
2019-02-14 14:51:24 +00:00
|
|
|
|
|
2019-06-04 17:49:58 +02:00
|
|
|
|
sta (ZPCLBuf),y
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2020-02-14 08:21:56 +01:00
|
|
|
|
.6 ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>PUSHA
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2020-02-14 08:21:56 +01:00
|
|
|
|
>PUSHW L.MSG.BATCHLINE
|
|
|
|
|
>PUSHW ZPCLBuf
|
2019-06-04 17:49:58 +02:00
|
|
|
|
|
|
|
|
|
>PUSHBI 2
|
2020-03-09 17:24:08 +01:00
|
|
|
|
>SYSCALL FPrintF
|
2018-11-27 22:26:03 +01:00
|
|
|
|
|
2019-02-14 14:51:24 +00:00
|
|
|
|
ldy #$ff
|
2019-06-04 17:49:58 +02:00
|
|
|
|
ldx #'-'
|
2019-02-14 14:51:24 +00:00
|
|
|
|
|
|
|
|
|
.7 iny
|
2019-06-04 17:49:58 +02:00
|
|
|
|
lda (ZPCLBuf),y
|
2019-02-14 14:51:24 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
2019-06-04 17:49:58 +02:00
|
|
|
|
txa
|
|
|
|
|
sta (ZPCLBuf),y
|
2019-02-14 14:51:24 +00:00
|
|
|
|
bra .7
|
2019-06-04 17:49:58 +02:00
|
|
|
|
|
2020-02-14 08:21:56 +01:00
|
|
|
|
.8 ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHW L.MSG.BATCHERR
|
2019-06-04 17:49:58 +02:00
|
|
|
|
>PUSHW ZPCLBuf
|
2020-02-14 08:21:56 +01:00
|
|
|
|
>PUSHW ZPTmpW
|
2019-06-04 17:49:58 +02:00
|
|
|
|
>PUSHBI 4
|
2020-03-09 17:24:08 +01:00
|
|
|
|
>SYSCALL FPrintF
|
2020-02-14 08:21:56 +01:00
|
|
|
|
rts
|
2018-11-10 15:30:09 +01:00
|
|
|
|
*--------------------------------------
|
2020-05-17 19:34:32 +02:00
|
|
|
|
IO.PrintErrMsg ldy #S.PS.RC
|
2020-02-28 08:21:46 +01:00
|
|
|
|
lda (pPS),y
|
2020-05-17 19:34:32 +02:00
|
|
|
|
>PUSHA
|
2019-11-30 14:37:55 +01:00
|
|
|
|
|
2020-05-17 19:34:32 +02:00
|
|
|
|
>PUSHW ZPCLBuf
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2021-05-04 19:31:21 +02:00
|
|
|
|
>SYSCALL GetErrMsg
|
2019-11-30 14:37:55 +01:00
|
|
|
|
|
2020-02-14 08:21:56 +01:00
|
|
|
|
.8 ldy #S.PS.hStdErr
|
|
|
|
|
lda (pPS),y
|
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHW L.MSG.ERROR
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2019-11-30 14:37:55 +01:00
|
|
|
|
ldy #S.PS.RC
|
2020-02-28 08:21:46 +01:00
|
|
|
|
lda (pPS),y
|
2017-09-11 17:29:08 +02:00
|
|
|
|
>PUSHA
|
2020-05-17 19:34:32 +02:00
|
|
|
|
|
|
|
|
|
>PUSHW ZPCLBuf
|
2022-10-09 23:22:46 +02:00
|
|
|
|
|
2018-10-08 07:55:28 +02:00
|
|
|
|
>PUSHBI 3
|
2019-10-25 17:09:13 +02:00
|
|
|
|
|
2020-03-09 17:24:08 +01:00
|
|
|
|
>SYSCALL FPrintF
|
2020-05-17 19:34:32 +02:00
|
|
|
|
|
2016-10-29 21:58:21 +02:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2020-05-26 16:23:09 +02:00
|
|
|
|
SAVE usr/src/bin/sh.s.io
|
|
|
|
|
LOAD usr/src/bin/sh.s
|
2016-10-29 21:58:21 +02:00
|
|
|
|
ASM
|