A2osX/BIN/SH.S.CORE.txt

797 lines
14 KiB
Plaintext
Raw Normal View History

2019-01-28 16:33:30 +00:00
NEW
2019-04-15 05:40:13 +00:00
AUTO 3,1
2019-01-28 16:33:30 +00:00
*--------------------------------------
2020-01-20 15:24:53 +00:00
CORE.Init lda #PUSHD.STACK
tay
sta (pdata),y
lda #CODE.STACK
tay
sta (pdata),y
2019-10-03 06:25:27 +00:00
.9 rts
2019-01-31 16:34:02 +00:00
*--------------------------------------
CORE.FUNCRESET >LDA.G hFunctions
2019-07-31 15:10:59 +00:00
beq .8
2019-04-01 15:24:01 +00:00
>SYSCALL SListFree
>STZ.G hFunctions
.8 rts
2019-08-05 13:30:58 +00:00
*--------------------------------------
* stack-6,7 old InputBuf
* stack-4,5 old InputBufPtr
2020-08-11 18:55:28 +00:00
* stack-3 old ARGC
* stack-2 old ARGV
* stack-1 new hCode
* stack
2020-08-11 18:55:28 +00:00
*--------------------------------------
CORE.Load.YAX stx LOAD.hCode X = Code to Execute
2019-08-05 13:30:58 +00:00
2020-02-07 15:35:52 +00:00
>SYSCALL ArgVDup Y,A = ArgV
2019-08-15 12:48:58 +00:00
bcs .9
2019-09-08 12:09:47 +00:00
stx LOAD.hArgs X = hARGV
sta LOAD.ArgCnt A = ARGC
2019-08-05 13:30:58 +00:00
lda #8
jsr STK.Check
2019-08-15 12:48:58 +00:00
bcs .9
2020-02-02 18:24:40 +00:00
2019-08-05 13:30:58 +00:00
>LDYA ZPInputBuf
jsr STK.PushYA
2020-01-06 16:27:52 +00:00
jsr STK.PushInputBufPtr
2020-01-06 16:27:52 +00:00
2019-08-05 13:30:58 +00:00
ldy #S.PS.ARGC
lda (pPS),y
jsr STK.Push old ARGC
2019-08-05 13:30:58 +00:00
ldy #S.PS.hARGV
lda (pPS),y
jsr STK.Push old hARGV
2019-08-05 13:30:58 +00:00
ldy #S.PS.ARGC
lda LOAD.ArgCnt new ARGC
2020-01-09 15:54:14 +00:00
dec Skip ARG0 in count
2019-08-05 13:30:58 +00:00
sta (pPS),y
2020-01-09 15:54:14 +00:00
2019-08-05 13:30:58 +00:00
iny #S.PS.hARGV
lda LOAD.hArgs
2019-08-15 12:48:58 +00:00
sta (pPS),y new hARGV
lda LOAD.hCode new code
jsr STK.Push
* lda LOAD.hCode
2019-08-05 13:30:58 +00:00
>SYSCALL GetMemPtr
>STYA ZPInputBuf
>STYA ZPInputBufPtr
2019-08-15 12:48:58 +00:00
* clc
.9 rts
2019-01-28 16:33:30 +00:00
*--------------------------------------
2019-02-14 14:51:24 +00:00
* http://heirloom.sourceforge.net/sh/sh.1.html
*--------------------------------------
2020-01-20 15:24:53 +00:00
* CORE.Run
* Input : ZPInputBufPtr (String)
2019-02-03 21:58:26 +00:00
* Tokenize ZPArgVBuf
2019-02-01 16:32:29 +00:00
* :LOOP
* if CmdSep=| :
2019-02-01 16:32:29 +00:00
* set hStdIn = hStdOut
* set hStdOut = Std
* GetCmd from line until | or EOL
* if CmdSep=| :
* create PIPE
* set hStdOut -> PIPE
* CORE.Exec &
* :LOOP
* else CORE.Exec
*--------------------------------------
* SET VAR = `cmd args`, FOR VAR IN `cmd args`
* create PIPE
* set hStdOut -> PIPE
* CORE.Exec `cmd args` &
* set READMODE
* set hStdIn = hStdOut
* set hStdOut = Std
*--------------------------------------
CORE.Run.EOF jsr STK.Pull
2019-08-15 12:48:58 +00:00
bcs *
cmp #$C0+C.. check CALL . CL context
beq .1
2019-08-15 12:48:58 +00:00
cmp #$C0+C.CALL
beq .1
2019-08-15 12:48:58 +00:00
cmp #$C0+C.CLEXEC
2019-08-12 07:40:16 +00:00
bne .9
2019-08-15 12:48:58 +00:00
.1 jsr CMD.EXIT.FILE
2019-08-12 07:40:16 +00:00
jsr IO.Reset
2019-08-12 07:40:16 +00:00
lda #0
sec
2020-01-20 15:24:53 +00:00
jmp CORE.Run.Exit Ending 0, CS,A=0
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
.9 lda #E.UNEXPEOF
2019-08-12 07:40:16 +00:00
sec
2020-01-20 15:24:53 +00:00
jmp CORE.Run.Exit
2020-01-20 15:24:53 +00:00
CORE.Run.RTS rts
2019-08-12 07:40:16 +00:00
*--------------------------------------
2023-05-19 15:39:42 +00:00
CORE.Run >LDYAI 256
2020-01-20 15:24:53 +00:00
>SYSCALL GetMem
bcs CORE.Run.RTS
2021-05-11 18:44:13 +00:00
2020-01-20 15:24:53 +00:00
>STYA ZPArgVBuf
txa
>STA.G CORE.hArgVBuf
2023-05-16 16:53:52 +00:00
lda #bState.PipeIn+bState.PipeOut
trb bState
2023-05-16 16:53:52 +00:00
*--------------------------------------
CORE.Run.1 >LDYA ZPInputBufPtr Save Actual ptr for looping
2019-02-07 16:52:25 +00:00
>STYA ZPInputCmdPtr
2020-01-20 15:24:53 +00:00
>LDYA ZPArgVBuf Reset ArgV Buffer
2019-02-08 16:13:43 +00:00
>STYA ZPArgVBufPtr
2019-10-26 14:33:37 +00:00
2020-01-20 15:24:53 +00:00
lda #0
2019-02-11 16:44:56 +00:00
sta (ZPArgVBuf)
2020-01-20 15:24:53 +00:00
sec
ror CORE.IntCmd assume external
2019-10-26 14:33:37 +00:00
2019-04-15 05:40:13 +00:00
lda #S.PS.F.HOLD
2019-08-12 07:40:16 +00:00
sta CORE.PSFlags
2019-10-25 15:09:13 +00:00
2020-01-20 15:24:53 +00:00
jsr CORE.GetCharNB
2019-08-12 07:40:16 +00:00
bcs CORE.Run.EOF
2019-10-25 15:09:13 +00:00
2019-10-26 14:33:37 +00:00
cmp #C.CR empty line ?
2019-03-14 16:51:02 +00:00
bne .33
2021-05-11 18:44:13 +00:00
2019-03-14 16:51:02 +00:00
jsr CORE.GetNextChar skip CR...
bra .8
2019-10-25 15:09:13 +00:00
2019-03-14 16:51:02 +00:00
.33 cmp #'#' commented line?
bne CORE.Run.3
2019-02-07 16:52:25 +00:00
2019-03-14 16:51:02 +00:00
.12 jsr CORE.SkipLine
2019-02-11 16:44:56 +00:00
2023-05-19 15:39:42 +00:00
.8 jmp CORE.Run.Exit0 EOL, CS,A=0
*--------------------------------------
CORE.Run.3 >LDA.G hAliases
beq CORE.Run.4
>PUSHA
>PUSHW ZPInputBufPtr
2022-11-02 06:54:30 +00:00
>PUSHWZ ScopeID
>SYSCALL SListLookup
bcs CORE.Run.4
>STYA ZPTmpW Save KeyID
txa
jsr CORE.SkipCharsA
ldy #hAliases
jsr CORE.SListGetData
bcs .9
2019-10-25 15:09:13 +00:00
jsr CORE.PushBufX
bcc CORE.Run.3
.9 rts
*--------------------------------------
CORE.Run.4 >LDYA L.CMD internal command ?
2019-02-11 16:44:56 +00:00
jsr CORE.LookupInputBuf
2019-03-02 20:47:58 +00:00
bcc .41
2019-11-30 13:37:55 +00:00
2019-03-15 16:20:28 +00:00
.40 jsr CORE.ArgV.Add external cmd, go check context
2019-03-02 20:47:58 +00:00
bra .42
2019-11-30 13:37:55 +00:00
.41 stx CORE.IntCmd
jsr CORE.SkipCharsA
.42 jsr STK.Get
bcs CORE.Run.5 no particular context, exec...
2019-11-30 13:37:55 +00:00
2019-03-04 16:44:33 +00:00
tax
2019-07-31 15:10:59 +00:00
lda CORE.IntCmd
2019-03-04 16:44:33 +00:00
bmi .45
2019-11-30 13:37:55 +00:00
2019-03-04 16:46:46 +00:00
and #$3F
2019-03-12 16:50:16 +00:00
cmp #C.SWITCH SWITCH....FI ?
bcs CORE.Run.5
2019-03-02 20:47:58 +00:00
2019-03-04 16:44:33 +00:00
.45 txa
bpl .43 context is FALSE, skip line
2021-05-11 18:44:13 +00:00
2019-10-03 06:25:27 +00:00
asl
bmi CORE.Run.5 parent context is true, exec
2021-05-11 18:44:13 +00:00
2019-03-04 22:20:26 +00:00
.43 jsr CORE.GetCharNB
2019-03-02 20:47:58 +00:00
bcs .44 EOF
cmp #C.CR
beq .44
2021-05-11 18:44:13 +00:00
2019-03-02 20:47:58 +00:00
cmp #';' TODO ";"
2019-03-04 22:20:26 +00:00
beq .44
jsr CORE.GetNextChar
bra .43
2019-11-30 13:37:55 +00:00
2019-03-02 20:47:58 +00:00
.44 jsr CORE.GetNextCharNB Skip EoL char
2023-05-19 15:39:42 +00:00
jmp CORE.Run.Exit0
2019-03-14 16:51:02 +00:00
*--------------------------------------
CORE.Run.5 jsr CORE.GetCharNB
2023-05-16 16:53:52 +00:00
bcs CORE.Run.6 Nothing to skip
jsr CORE.IsEndCmd
bcc .3
>LDYA L.CORE.IO
2019-02-11 16:44:56 +00:00
jsr CORE.LookupInputBuf
bcs .2
2019-02-18 12:52:10 +00:00
2019-02-11 16:44:56 +00:00
jsr CORE.SkipCharsA
2019-02-11 06:58:33 +00:00
jsr CORE.IO.JMP
bcc CORE.Run.5
2019-10-25 15:09:13 +00:00
bcs .9
2019-10-25 15:09:13 +00:00
.2 jsr CORE.ArgV.Add
bcc CORE.Run.5
2019-10-26 14:33:37 +00:00
.9 lda #E.SYN
sec
jmp CORE.Run.Exit
2023-05-16 16:53:52 +00:00
*--------------------------------------
.3 cmp #C.CR
beq .7
cmp #';'
beq .7
cmp #'|'
bne .5
jsr CORE.GetNextCharNB '|'
lda #bState.PipeOut
tsb bState
bra CORE.Run.6
.5 cmp #'&'
bne .9
jsr CORE.GetNextChar Skip '&'
bcs .50
cmp #'&'
beq .6 &&
.50 lda #S.PS.F.HOLD Run in the background...
trb CORE.PSFlags
2023-05-16 16:53:52 +00:00
bra CORE.Run.6
.6 jsr CORE.GetNextChar Skip '&&'
jsr CORE.ExecCmd
bcc .60
jsr CORE.SkipLine
2023-05-19 15:39:42 +00:00
jmp CORE.Run.Exit0
.60 jmp CORE.Run.1
.7 jsr CORE.GetNextCharNB Skip EoL char
*--------------------------------------
CORE.Run.6 lda bState
2023-05-16 16:53:52 +00:00
bit #bState.PipeOut
2023-05-19 12:16:09 +00:00
beq .1
2019-02-11 06:58:33 +00:00
jsr IO.Pipe.Out
2020-01-20 15:24:53 +00:00
bcs CORE.Run.Exit
2023-05-16 16:53:52 +00:00
2020-08-25 10:56:00 +00:00
lda #S.PS.F.HOLD Run in the background...
trb CORE.PSFlags
2023-05-16 16:53:52 +00:00
lda #S.PS.F.CLOSEONX ...and child PS must close StdOut on exit
2020-08-25 10:56:00 +00:00
tsb CORE.PSFlags
2023-05-19 12:16:09 +00:00
.1 jsr CORE.ExecCmd
2023-05-16 16:53:52 +00:00
bcs CORE.Run.Exit
lda bState
2023-05-19 12:16:09 +00:00
bit #bState.PipeIn
beq .2
2023-05-16 16:53:52 +00:00
jsr IO.Pop.In restore Input piping app must close it
lda #bState.PipeIn
trb bState
lda bState
2023-05-19 12:16:09 +00:00
.2 bit #bState.PipeOut
2023-05-19 15:39:42 +00:00
beq CORE.Run.Exit0
2023-05-16 16:53:52 +00:00
jsr IO.Pipe.In Set previous Pipe Out to StdIn for next CMD
2020-01-20 15:24:53 +00:00
bcs CORE.Run.Exit
lda #bState.PipeIn
tsb bState
2023-05-16 16:53:52 +00:00
bit CORE.IntCmd
2023-05-19 12:16:09 +00:00
bmi .3
2023-05-16 16:53:52 +00:00
jsr IO.Reset.Out Internal : CLOSE output
2023-05-19 12:16:09 +00:00
bra .4
2023-05-16 16:53:52 +00:00
2023-05-19 12:16:09 +00:00
.3 jsr IO.Pop.Out External : DONT Close Output, child process will close it
2023-05-19 12:16:09 +00:00
.4 lda #bState.PipeOut
2023-05-16 16:53:52 +00:00
trb bState
.7 jmp CORE.Run.1 Loop with Pipe IN
2023-05-18 16:12:57 +00:00
2023-05-19 15:39:42 +00:00
CORE.Run.Exit0 lda #0
2023-05-18 16:12:57 +00:00
clc
2023-05-19 15:39:42 +00:00
2020-01-20 15:24:53 +00:00
CORE.Run.Exit php
pha
>LDA.G CORE.hArgVBuf
2020-01-20 16:34:59 +00:00
beq .1
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2020-01-20 15:24:53 +00:00
>STZ.G CORE.hArgVBuf
2023-05-19 15:39:42 +00:00
.1 jsr IO.Reset
pla
2020-01-20 15:24:53 +00:00
plp
rts
2019-02-07 16:52:25 +00:00
*--------------------------------------
2019-02-11 06:58:33 +00:00
* Input : ZPArgVBuf
*--------------------------------------
2019-10-26 14:33:37 +00:00
CORE.ExecCmd lda #0
2019-02-11 16:44:56 +00:00
sta (ZPArgVBufPtr)
2019-03-02 20:47:58 +00:00
>LDYA ZPArgVBuf
2019-02-11 16:44:56 +00:00
>STYA ZPArgVBufPtr
2019-02-11 06:58:33 +00:00
lda CORE.IntCmd
2019-02-11 06:58:33 +00:00
bmi CORE.ExecExtCmd
2019-11-30 13:37:55 +00:00
asl
tax
2019-02-11 06:58:33 +00:00
jmp (J.CMD,x)
*--------------------------------------
CORE.ExecExtCmd >PUSHW ZPArgVBuf
2020-02-14 07:21:56 +00:00
>PUSHB CORE.PSFlags
2019-10-12 14:20:09 +00:00
2020-03-09 16:24:08 +00:00
>SYSCALL ExecV
2019-01-28 16:33:30 +00:00
bcs .9
2019-02-01 16:32:29 +00:00
tax CPID
2019-08-12 07:40:16 +00:00
lda CORE.PSFlags
2019-02-01 16:32:29 +00:00
and #S.PS.F.HOLD
2023-05-19 12:16:09 +00:00
bne .1
2019-10-25 15:09:13 +00:00
lda bState
bit #bState.PipeOut
2023-05-19 12:16:09 +00:00
bne .1
2019-10-31 15:59:11 +00:00
2020-02-14 07:21:56 +00:00
ldy #S.PS.hStdErr
lda (pPS),y
>PUSHA
>PUSHW L.MSG.PID
2019-02-01 16:32:29 +00:00
txa
>PUSHA
>PUSHBI 1
2020-03-09 16:24:08 +00:00
>SYSCALL FPrintF
2020-02-14 07:21:56 +00:00
rts
2019-10-25 15:09:13 +00:00
2023-05-19 12:16:09 +00:00
.1 >SLEEP Suspend this PID
2023-05-16 16:53:52 +00:00
2019-02-01 16:32:29 +00:00
ldy #S.PS.RC CPID will update S.PS.RC
2020-02-28 07:21:46 +00:00
lda (pPS),y
2023-05-19 12:16:09 +00:00
cmp #1
2019-10-25 15:09:13 +00:00
2019-02-01 16:32:29 +00:00
.9 rts
*--------------------------------------
2019-03-14 16:51:02 +00:00
CORE.SkipLine jsr CORE.GetNextCharNB
bcs .8 EOF
cmp #C.CR EOL
bne CORE.SkipLine
2019-03-14 16:51:02 +00:00
jsr CORE.GetNextChar skip CR...
.8 rts
*--------------------------------------
2019-02-11 16:44:56 +00:00
* search ZPInputBufPtr/ZPArgVBufPtr in Y,A table
2019-02-07 16:52:25 +00:00
*--------------------------------------
2019-02-11 16:44:56 +00:00
CORE.LookupInputBuf
2019-08-15 12:48:58 +00:00
sec
.HS 90 BCC
CORE.LookupArgVBuf
clc
>STYA ZPPtr1 Keywords table
2019-02-11 16:44:56 +00:00
>LDYA ZPArgVBufPtr
2019-08-15 12:48:58 +00:00
bcc CORE.Lookup
2019-08-15 12:48:58 +00:00
>LDYA ZPInputBufPtr
2019-02-11 16:44:56 +00:00
CORE.Lookup >STYA ZPPtr2
2019-02-07 16:52:25 +00:00
ldx #0
2019-11-30 13:37:55 +00:00
2019-02-11 16:44:56 +00:00
.1 ldy #$ff
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
.2 jsr .7 get next valid char in src text
bcs .3
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
.20 jsr ToUpperCase
eor (ZPPtr1),y match table char ?
asl compare only 7 bits
bne .4 no match...get next table keyword
bcc .2 not last char in this keyword
jsr .7 next char in text...
bcc .4 valid....failed
.8 tya Keyword Len
2019-02-07 16:52:25 +00:00
clc
2019-08-15 12:48:58 +00:00
rts
.3 dey
lda (ZPPtr1),y was last char in this keyword ?
bmi .8
2019-11-30 13:37:55 +00:00
2019-08-15 12:48:58 +00:00
iny
.41 jsr IncPtr1 skip chars to next keyword
2019-02-07 16:52:25 +00:00
2019-08-15 12:48:58 +00:00
.4 lda (ZPPtr1)
bpl .41
2019-07-31 15:10:59 +00:00
jsr IncPtr1
2019-11-30 13:37:55 +00:00
2019-02-11 16:44:56 +00:00
.6 inx
2019-08-15 12:48:58 +00:00
lda (ZPPtr1) Array Ending 0, lookup failed
2019-02-07 16:52:25 +00:00
bne .1
2020-01-11 17:13:27 +00:00
2019-03-05 16:49:34 +00:00
lda #E.SYN
2020-01-11 17:13:27 +00:00
.9 sec
2019-02-11 06:58:33 +00:00
rts
2020-01-06 07:03:37 +00:00
2019-08-15 12:48:58 +00:00
.7 iny
lda (ZPPtr2),y Get Src text char...
beq .9 end of text
2019-08-15 12:48:58 +00:00
jsr CORE.IsSpaceOrEndCmd
bcc .9 end of valid chars
clc
CORE.ArgV.Add.RTS
2019-08-15 12:48:58 +00:00
rts
2019-02-11 06:58:33 +00:00
*--------------------------------------
* ArgV
*--------------------------------------
2020-01-13 13:33:30 +00:00
CORE.ArgV.Add lda #C.SPACE
2019-07-31 15:10:59 +00:00
sta ZPTmpW
2020-01-13 13:33:30 +00:00
ldy #0
2019-02-12 16:47:34 +00:00
jsr CORE.GetCharNB
2020-02-14 07:21:56 +00:00
bcs CORE.ArgV.Add.RTS
2019-02-15 16:38:17 +00:00
cmp #'"'
bne .10
2020-01-13 13:33:30 +00:00
2019-07-31 15:10:59 +00:00
sta ZPTmpW
2019-02-15 16:38:17 +00:00
bra .1
2020-01-13 13:33:30 +00:00
2019-03-07 16:48:30 +00:00
.10 cmp #'('
2019-02-15 16:38:17 +00:00
bne .11
2020-01-13 13:33:30 +00:00
2019-03-07 20:40:06 +00:00
ldx #')'
2019-07-31 15:10:59 +00:00
stx ZPTmpW
2019-03-07 16:48:30 +00:00
bra .12
2019-03-07 16:48:30 +00:00
.11 cmp #'`'
bne .12
2021-05-11 18:44:13 +00:00
2019-07-31 15:10:59 +00:00
sta ZPTmpW
2020-01-13 13:33:30 +00:00
.12 sta (ZPArgVBufPtr),y
iny
2019-02-11 06:58:33 +00:00
2019-02-15 16:38:17 +00:00
.1 jsr CORE.GetNextChar
bcs .7
2020-01-13 13:33:30 +00:00
2019-07-31 15:10:59 +00:00
.2 cmp ZPTmpW
2019-02-18 16:05:40 +00:00
bne .3
2020-01-13 15:01:23 +00:00
2019-02-18 16:05:40 +00:00
jsr CORE.GetNextChar
bra .7
2019-02-11 06:58:33 +00:00
2020-01-13 13:33:30 +00:00
.3 ldx ZPTmpW
cpx #C.SPACE
bne .6
2020-01-13 13:33:30 +00:00
2019-02-21 11:34:28 +00:00
jsr CORE.IsEndCmd
bcc .7
2020-01-13 13:33:30 +00:00
.6 sta (ZPArgVBufPtr),y
2020-01-13 13:33:30 +00:00
iny
jsr CORE.GetNextChar
2019-02-15 16:38:17 +00:00
bcc .2
2020-01-13 13:33:30 +00:00
.7 lda #0
2020-01-13 13:33:30 +00:00
sta (ZPArgVBufPtr),y
2019-02-12 16:47:34 +00:00
2020-01-13 13:33:30 +00:00
>LDYA ZPArgVBufPtr
2020-01-13 15:01:23 +00:00
>STYA ZPArgVBufPrev
2020-02-14 07:21:56 +00:00
>PUSHYA
>PUSHW ZPArgVBufPtr
2020-01-17 11:23:11 +00:00
>SYSCALL Expand
2019-02-12 16:47:34 +00:00
bcs .9
2020-01-13 13:33:30 +00:00
tya
2020-01-13 15:53:33 +00:00
beq .8 Empty string....
2020-01-13 13:33:30 +00:00
sec
adc ZPArgVBufPtr
sta ZPArgVBufPtr
bcc .8
2020-01-13 13:33:30 +00:00
inc ZPArgVBufPtr+1
clc
2020-01-13 13:33:30 +00:00
.8
2019-02-12 16:47:34 +00:00
.9 rts
2019-02-11 06:58:33 +00:00
*--------------------------------------
CORE.ArgV.Next lda (ZPArgVBufPtr)
beq .8
2020-01-07 13:44:38 +00:00
2019-02-14 14:51:24 +00:00
>LDYA ZPArgVBufPtr
>STYA ZPArgVBufPrev
2020-01-07 13:44:38 +00:00
2019-02-11 06:58:33 +00:00
.1 jsr CORE.ArgV.NextChar
lda (ZPArgVBufPtr)
bne .1
2020-01-07 13:44:38 +00:00
2019-02-11 06:58:33 +00:00
jsr CORE.ArgV.NextChar
lda (ZPArgVBufPtr)
.8 rts
*--------------------------------------
2020-01-13 13:33:30 +00:00
CORE.ArgV.NextChar
inc ZPArgVBufPtr
bne .8
2023-05-16 16:53:52 +00:00
2020-01-13 13:33:30 +00:00
inc ZPArgVBufPtr+1
.8 rts
*--------------------------------------
2019-02-11 06:58:33 +00:00
* IO
*--------------------------------------
2019-04-01 06:07:56 +00:00
CORE.IO.JMP txa
asl
tax
jmp (J.CORE.IO,x)
2019-02-11 06:58:33 +00:00
CORE.IO.IN lda #O.RDONLY+O.TEXT
jsr CORE.IO.Open
bcs CORE.IO.RTS
2019-02-11 06:58:33 +00:00
jmp IO.Set.In
CORE.IO.OUTA
CORE.IO.1OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CORE.IO.OUT.1
CORE.IO.OUT
2019-02-11 06:58:33 +00:00
CORE.IO.1OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CORE.IO.OUT.1 jsr CORE.IO.Open
bcs CORE.IO.RTS
jmp IO.Set.Out
CORE.IO.2OUTA lda #O.WRONLY+O.APPEND+O.CREATE+O.TEXT
bra CORE.IO.2OUT.1
2019-02-11 06:58:33 +00:00
CORE.IO.2OUT lda #O.WRONLY+O.TRUNC+O.CREATE+O.TEXT
CORE.IO.2OUT.1 jsr CORE.IO.Open
bcs CORE.IO.RTS
2019-02-11 06:58:33 +00:00
jmp IO.Set.Err
*--------------------------------------
CORE.IO.Open pha Open Mode
jsr CORE.GetCharNB
bcs .9 no arg left....
2019-02-18 12:52:10 +00:00
jsr CORE.ArgV.Add Get Filename
>LDYA ZPArgVBufPrev
>STYA ZPArgVBufPtr Discard filename
2019-08-02 14:36:49 +00:00
plx
jmp IO.FOpenYAX
2019-02-11 06:58:33 +00:00
.9 pla
2019-03-05 16:49:34 +00:00
lda #E.SYN
2019-02-11 06:58:33 +00:00
sec
CORE.IO.RTS rts
2019-02-11 06:58:33 +00:00
*--------------------------------------
* Input Buffer
2019-02-07 16:52:25 +00:00
*--------------------------------------
2019-02-08 16:13:43 +00:00
CORE.IsSpaceOrEndCmd
cmp #C.SPACE
beq CORE.IsEndCmd.8
2021-05-11 18:44:13 +00:00
2019-02-21 11:34:28 +00:00
CORE.IsEndCmd cmp #';'
2019-02-08 16:13:43 +00:00
beq CORE.IsEndCmd.8
2021-05-11 18:44:13 +00:00
2019-02-21 11:34:28 +00:00
cmp #C.CR
2019-02-08 16:13:43 +00:00
beq CORE.IsEndCmd.8
2021-05-11 18:44:13 +00:00
cmp #'&'
beq CORE.IsEndCmd.8
2019-02-07 16:52:25 +00:00
cmp #'|'
2019-02-08 16:13:43 +00:00
beq CORE.IsEndCmd.8
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
sec
rts
2021-05-11 18:44:13 +00:00
2019-02-08 16:13:43 +00:00
CORE.IsEndCmd.8 clc
2019-02-07 16:52:25 +00:00
rts
*--------------------------------------
CORE.GetCharNB jsr CORE.GetChar
bcs CORE.GetNextCharNB.RTS
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
jsr CORE.CheckCharNB
bcc CORE.GetNextCharNB.RTS
2019-02-07 16:52:25 +00:00
*--------------------------------------
CORE.GetNextCharNB
jsr CORE.GetNextChar
bcs CORE.GetNextCharNB.RTS
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
jsr CORE.CheckCharNB
bcs CORE.GetNextCharNB
CORE.GetNextCharNB.RTS
rts
*--------------------------------------
CORE.CheckCharNB
cmp #C.SPACE
beq .9
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
cmp #C.LF
beq .9
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
cmp #C.TAB
beq .9
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
clc
2019-10-03 06:25:27 +00:00
.9 rts
2019-02-07 16:52:25 +00:00
*--------------------------------------
CORE.GetNextChar
inc ZPInputBufPtr
bne CORE.GetChar
2021-05-11 18:44:13 +00:00
2019-02-07 16:52:25 +00:00
inc ZPInputBufPtr+1
*--------------------------------------
CORE.GetChar clc
lda (ZPInputBufPtr)
bne .8
jsr CORE.PopBuf
bcc CORE.GetChar
2021-05-11 18:44:13 +00:00
lda #0
.8 rts
2019-01-28 16:33:30 +00:00
*--------------------------------------
2019-02-11 16:44:56 +00:00
CORE.SkipCharsA clc
adc ZPInputBufPtr
sta ZPInputBufPtr
bcc .8
2019-02-11 16:44:56 +00:00
inc ZPInputBufPtr+1
2019-10-03 06:25:27 +00:00
.8 rts
2019-02-11 16:44:56 +00:00
*--------------------------------------
CORE.PushBufX >LDA.G CODE.STACK
cmp #CODE.STACK.MAX*5
beq .9
inc
tay
phx next hBuffer
ldx #0
.1 lda ZPInputBuf,x ZPInputBuf
sta (pData),y
inx ZPInputBufPtr
iny
cpx #6 ZPInputCmdPtr
bne .1
pla
pha
sta (pData),y
tya
>STA.G CODE.STACK
pla
>SYSCALL GetMemPtr
>STYA ZPInputBuf
>STYA ZPInputBufPtr
* clc
rts
.9 lda #E.STKOVERFLOW
* sec
rts
*--------------------------------------
CORE.PopBuf phy
>LDA.G CODE.STACK
cmp #CODE.STACK
beq .9
tay
lda (pData),y
phy
>SYSCALL FreeMem
ply
ldx #5
dey
.1 lda (pData),y ZPInputBuf
sta ZPInputBuf,x
dey ZPInputBufPtr
dex
bpl .1 ZPInputCmdPtr
tya
>STA.G CODE.STACK
ply
* clc
rts
.9 ply
lda #E.STACKERROR
* sec
rts
*--------------------------------------
CORE.SListGetData
>PUSHB (pData),y
>PUSHW ZPTmpW KeyID
>PUSHWZ Allocate
>PUSHWI $ffff All
>PUSHWZ from Start
>SYSCALL SListGetData X = hMem
rts
*--------------------------------------
2019-01-28 16:33:30 +00:00
MAN
2020-05-26 14:23:09 +00:00
SAVE usr/src/bin/sh.s.core
LOAD usr/src/bin/sh.s
2019-01-28 16:33:30 +00:00
ASM