A2osX/BIN/SH.S.CMD.txt
2020-07-09 13:34:07 +02:00

1225 lines
20 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
*--------------------------------------
CMD.. lda (ZPArgVBufPtr)
beq .9
>LDYA ZPArgVBufPtr
jsr IO.Load
bcs CMD.SHIFTA.RTS
>LDYA ZPArgVBufPtr
jsr CORE.Load.YAX Exec . file
bcs CMD.SHIFTA.RTS
lda #$C0+C..
jmp CORE.StkPush
.9
CMD...9 jmp CMD.E.CSYN
*--------------------------------------
CMD.NOHUP lda (ZPArgVBufPtr)
beq CMD...9
lda #S.PS.F.NOHUP
tsb CORE.PSFlags
jmp CORE.ExecExtCmd
*--------------------------------------
CMD.SHIFT lda (ZPArgVBufPtr)
beq CMD.SHIFT.1
jsr EXP.GetInt8Exp
bcs CMD.SHIFTA.RTS
.HS B0 BCS
CMD.SHIFT.1 inc
CMD.SHIFTA >SYSCALL Shift
CMD.SHIFTA.RTS rts
*--------------------------------------
CMD.PUSHD >LDA.G PUSHD.STACK
cmp #PUSHD.STACK+PUSHD.STACK.MAX
beq CMD.POPD.CSYN
jsr GetCWD
>SYSCALL StrDup
bcs CMD.POPD.CSYN
>INC.G PUSHD.STACK
tay
txa
sta (pData),y
lda (ZPArgVBufPtr)
bne CMD.CD.0
.8 clc
.9 rts
*--------------------------------------
CMD.POPD >LDA.G PUSHD.STACK
cmp #PUSHD.STACK
beq CMD.POPD.CSYN
tay
lda (pData),y
jsr CMD.SetCWDA
>DEC.G PUSHD.STACK
clc
CMD.POPD.RTS rts
CMD.POPD.CSYN jmp CMD.E.CSYN
*--------------------------------------
CMD... lda (ZPArgVBufPtr)
bne CMD.POPD.CSYN
>LDYA L.CD..
bra CMD.CD.YA
*--------------------------------------
CMD.CD lda (ZPArgVBufPtr)
beq CMD.CD.HOME
CMD.CD.0 >LDYA ZPArgVBufPtr
bra CMD.CD.YA
CMD.CD.HOME >LDYA L.HOME
CMD.CD.YA >PUSHYA
>PUSHWI 0 Allocate
>SYSCALL RealPath
bcs CMD.POPD.RTS
>STYA ZPPtr1
stx ZPTmpW Save hMem
ldy #1
lda (ZPPtr1),y
bne .12
txa
jmp CMD.SetCWDA we have '/'
.12 >LDYA ZPPtr1
jsr IO.StatYA
bcs .19
cmp #S.FI.T.DIR
beq .11
lda #MLI.E.INVPATH
.19 pha
lda ZPTmpW
>SYSCALL FreeMem
pla
sec
rts
.11 jsr GetPtr1LenY
dey
lda #'/'
cmp (ZPPtr1),y
beq .14
iny
sta (ZPPtr1),y
iny
lda #0
sta (ZPPtr1),y
.14 lda ZPTmpW
*--------------------------------------
CMD.SetCWDA pha
ldy #S.PS.hCWD
lda (pPS),y
>SYSCALL FreeMem
pla
ldy #S.PS.hCWD
sta (pPS),y
lda #0
* clc
rts
*--------------------------------------
CMD.SET lda (ZPArgVBufPtr)
bne CMD.SET.1
* No arg, print all ENV
>PUSHWZ
>PUSHWZ
>SYSCALL GetEnv
>STYA ZPPtr1
stx ZPTmpW
.1 lda (ZPPtr1)
beq .8 Ending 0 ?
>LDYA ZPPtr1
>SYSCALL PutS
bcs .9
jsr GetPtr1NextString
bra .1
.8 lda ZPTmpW
>SYSCALL FreeMem
* clc
.9 rts
*--------------------------------------
* SET +X VAR = VALUE1 op VALUE2 op VALUE3 ...
*--------------------------------------
CMD.SET.1
.1 jsr CMD.IsSwitch
bcs .6
ldx #SET.VARS-SET.FLAGS
.2 dex
bmi .4
cmp SET.FLAGS,x
bne .2
ldy SET.VARS,x
lda (pData),y
eor #$ff
sta (pData),y
bra .5
.4 cmp #'F'
bne .99
jsr CORE.FUNCRESET
.5 jsr CORE.ArgV.Next
bne .1
clc
rts
*--------------------------------------
.6 >LDYA ZPArgVBufPtr
>STYA ZPVarNamePtr
jsr CORE.ArgV.Next
beq CMD.SET.GET
cmp #'='
bne .99
ldy #1
lda (ZPArgVBufPtr),y
bne .99
jsr CORE.ArgV.Next
beq CMD.SET.UNSET
cmp #'`'
beq CMD.SET.EXEC
jsr EXP.GET
bcc CMD.SET.YA
rts
.99 jmp CMD.E.CSYN
CMD.SET.YA pha
>PUSHW ZPVarNamePtr
pla
>PUSHYA
>SYSCALL SetEnv
rts
CMD.SET.UNSET >PUSHW ZPVarNamePtr
>SYSCALL UnsetEnv
rts
CMD.SET.GET >PUSHW ZPVarNamePtr
>PUSHW ZPCLBuf
>SYSCALL GetEnv
bcs .8
>LDYA ZPCLBuf
>SYSCALL PutS
rts
.8 clc
rts
*--------------------------------------
CMD.SET.EXEC jsr CORE.ArgV.NextChar skip "`"
jsr IO.Pipe.Out
bcs .9
>PUSHW ZPArgVBufPtr
>PUSHBI S.PS.F.CLOSEONX
>SYSCALL ExecL
bcs .9
jsr IO.Pipe.In
bcs .9
lda #255
>STA.G READ.N
>STA.G bREAD.S
jmp CMD.READ.VAR
.9 rts
*--------------------------------------
CMD.DATE >PUSHEA.G TimeBuf
>SYSCALL Time
>PUSHEA.G TimeBuf
>PUSHW ZPCLBuf
lda (ZPArgVBufPtr)
beq .1
>LDYA ZPArgVBufPtr
bra .2
.1 >LDYA L.FMT.DATE
.2 >PUSHYA
>PUSHEA.G TimeBuf
>SYSCALL StrFTime
CMD.DATE.PRINT >LDYA ZPCLBuf
>SYSCALL PutS
rts
*--------------------------------------
CMD.ECHO stz ZPPtr1 echo -N
stz ZPPtr1+1 Token Cnt
lda (ZPArgVBufPtr)
beq .7
.1 jsr CMD.IsSwitch
bcs .2
cmp #'N'
bne CMD.ECHO.CSYN
lda #$ff
eor ZPPtr1
sta ZPPtr1
bra .4
.2 lda ZPPtr1+1
beq .3
lda #C.SPACE
>SYSCALL PutChar
.3 jsr CMD.PrintArgVBufPtr
bcs .9
inc ZPPtr1+1
.4 jsr CORE.ArgV.Next
bne .1
.7 bit ZPPtr1
bmi .8
>PUSHW L.MSG.ECHOCRLF
>PUSHBI 0
>SYSCALL PrintF
.9 rts
.8 clc
rts
CMD.ECHO.CSYN lda #E.CSYN
sec
CMD.ECHO.RTS rts
*--------------------------------------
CMD.READ lda (ZPArgVBufPtr)
beq CMD.ECHO.CSYN
stz ZPVarNamePtr+1
>STZ.G bREAD.S
dec
>STA.G READ.N
.1 jsr CMD.IsSwitch
bcs .4
cmp #'S'
bne .2
lda #$ff
>STA.G bREAD.S
bra .5
.2 cmp #'P'
bne .3
jsr CORE.ArgV.Next
beq CMD.ECHO.CSYN
jsr CMD.PrintArgVBufPtr
bcs CMD.ECHO.RTS
bra .5
.3 cmp #'N'
bne CMD.ECHO.CSYN
jsr CORE.ArgV.Next
beq CMD.ECHO.CSYN
jsr EXP.GetInt8Arg
bcs CMD.ECHO.RTS
>STA.G READ.N
bra .5
.4 >LDYA ZPArgVBufPtr
>STYA ZPVarNamePtr
.5 jsr CORE.ArgV.Next
bne .1
lda ZPVarNamePtr+1
beq CMD.ECHO.CSYN
CMD.READ.VAR jsr CL.Reset
.1 >SYSCALL GetChar
bcs CMD.SLEEP.RTS
jsr CL.CHARIN
>LDA.G CL.bReady
bpl .1
lda (ZPCLBuf)
bne .2
jmp CMD.SET.UNSET
.2 >LDYA ZPCLBuf
jmp CMD.SET.YA
*--------------------------------------
CMD.SLEEP lda (ZPArgVBufPtr)
beq CMD.REN.CSYN
jsr EXP.GetInt32Arg
bcs CMD.SLEEP.RTS
>PULLL.G Sleep
CMD.SLEEP.RTS rts
*--------------------------------------
CMD.PAUSE lda #$FF
>STA.G bPause
clc
rts
*--------------------------------------
CMD.MD lda (ZPArgVBufPtr)
beq CMD.REN.CSYN
>PUSHW ZPArgVBufPtr
>PUSHWI S.STAT.MODE.FO+S.STAT.MODE.FG+S.STAT.MODE.FU
>SYSCALL MKDir
rts
*--------------------------------------
CMD.PWD jsr GetCWD
>SYSCALL PutS
rts
*--------------------------------------
CMD.RD lda (ZPArgVBufPtr)
beq CMD.REN.CSYN
jsr IO.StatArgVBufPtr
bcs .99
cmp #S.FI.T.DIR
bne CMD.REN.CSYN
>LDYA ZPArgVBufPtr
>SYSCALL Remove
.99 rts
*--------------------------------------
CMD.REN.CSYN jmp CMD.E.CSYN
CMD.REN lda (ZPArgVBufPtr)
beq CMD.REN.CSYN
jsr CORE.ArgV.Next
lda (ZPArgVBufPtr)
beq CMD.REN.CSYN
>PUSHW ZPArgVBufPrev old path
>PUSHWI 0 Allocate
>SYSCALL RealPath
bcs CMD.REN.CSYN
>STYA ZPPtr1
stx ZPTmpW
ldy #$ff
.1 iny
lda (ZPPtr1),y
beq .2
cmp #'/'
bne .1
tya
tax
bra .1
.2 ldy #$ff
.3 iny
inx
lda (ZPArgVBufPtr),y
bne .3
txa
tay
lda #0
>SYSCALL GetMem
bcs .90
>STYA ZPPtr2
stx ZPTmpW+1
ldy #$ff
.4 iny
lda (ZPPtr1),y
beq .5
sta (ZPPtr2),y
cmp #'/'
bne .4
tya
inc
tax
bra .4
.5 txa
tay
lda #0
sta (ZPPtr2),y
>PUSHW ZPArgVBufPtr
>LDYA ZPPtr2
>SYSCALL StrCat
lda ZPTmpW
>SYSCALL FreeMem
lda ZPTmpW+1
sta ZPTmpW
>PUSHW ZPPtr1
>PUSHW ZPPtr2
>SYSCALL Rename
.90 php
pha
lda ZPTmpW
>SYSCALL FreeMem
pla
plp
rts
*--------------------------------------
CMD.FUNCTION lda (ZPArgVBufPtr)
beq .9
jsr CORE.StkGetCtx
bcc .9 No context allowed
>LDA.G hFuncList
bne .1
>SYSCALL SListNew
bcs .99
>STA.G hFuncList
.1 >PUSHA
>PUSHW ZPArgVBufPtr
>SYSCALL SListNewKey
bcs .99
>STYA ZPTmpW Save KeyID
jsr CORE.ArgV.Next nothing after function name
beq .10
cmp #'{'
bne .9
ldy #1
lda (ZPArgVBufPtr),y
beq .11
.9 jmp CMD.E.CSYN
.99 rts
*--------------------------------------
.10 jsr CORE.GetCharNB
bcs .9
cmp #'{'
bne .9
jsr CORE.GetNextCharNB
bcs .9
.11 stz M32.ACC '{' counter
>LDYA ZPInputBufPtr
>STYA ZPPtr1
ldy #0
ldx #0
lda (ZPInputBufPtr)
beq .6
.12 cmp #'{'
bne .13
inc M32.ACC
bra .14
.13 cmp #'}'
bne .14
dec M32.ACC
bmi .7
.14 iny
bne .15
inx
.15 jsr CORE.GetNextChar
bne .12
.6 lda M32.ACC
bpl .9
.7 jsr CORE.GetNextChar skip ending '}'
phx
phy
>PUSHB.G hFuncList
>PUSHW ZPTmpW KeyID
>PUSHW ZPPtr1 DataPtr
ply
pla
>PUSHYA DataLen
>SYSCALL SListAddData
rts
*--------------------------------------
CMD.CALL jsr CMD.CALL.GETFUNC
bcs CMD.CALL.RTS
>STYA ZPTmpW KeyID
>PUSHB.G hFuncList
>PUSHW ZPTmpW KeyID
>PUSHWZ Allocate..
>PUSHWI $ffff all
>PUSHWZ From Start
>SYSCALL SListGetData
bcs CMD.CALL.RTS
>LDYA ZPArgVBufPtr FUNC PARAM1 PARAM2...
jsr CORE.Load.YAX Exec FUNC
bcs CMD.CALL.RTS
lda #$C0+C.CALL
jmp CORE.StkPush
*--------------------------------------
CMD.CALL.GETFUNC
>LDA.G hFuncList
beq CMD.CALL.UNDEF
>PUSHB.G hFuncList
>PUSHW ZPArgVBufPtr
>SYSCALL SListLookup
bcc CMD.CALL.RTS
CMD.CALL.UNDEF lda #E.FUNDEF
sec
CMD.CALL.RTS rts
*--------------------------------------
CMD.EXIT lda (ZPArgVBufPtr)
beq .1 no arg, exit 0
jsr EXP.GetInt8Exp
bcs .9
.1 ldy #S.PS.RC
sta (pPS),y
.2 jsr CORE.StkPull Pull everything until CALL . CL...
bcs .9
cmp #$C0+C.. in CALL, "." or CL context ?
beq CMD.EXIT.FILE
cmp #$C0+C.CALL
beq CMD.EXIT.FILE
cmp #$C0+C.CLEXEC
beq .8
jsr CORE.StkPopCtxA
bcc .2
rts
.8 jsr CMD.EXIT.FILE
lda #$ff
>STA.G bExitOnEOF
clc
.9 rts
*--------------------------------------
CMD.EXIT.FILE jsr CORE.StkPullFree Code buffer
ldy #S.PS.hARGV
lda (pPS),y
>SYSCALL FreeMem ArgV buffer
jsr CORE.StkPull
ldy #S.PS.hARGV
sta (pPS),y
jsr CORE.StkPull
ldy #S.PS.ARGC
sta (pPS),y
jsr CORE.StkPullInputBufPtr
jsr CORE.StkPull
sta ZPInputBuf+1
jsr CORE.StkPull
sta ZPInputBuf
ldy #S.PS.RC
lda (pPS),y
clc
rts
*--------------------------------------
CMD.BREAK jsr CORE.StkGetCtx Get context in CORE.TestResult
bcs .9
tax
and #$3F
cmp #C.CASE
bne .9
txa
bpl .8
jsr CORE.StkPull remove C.CASE
jsr CORE.StkGet
and #$7F
sta (pData),y
.8 clc
rts
.9 jmp CMD.E.CSYN
*--------------------------------------
* stack-1 hVALUE
* stack SWITCH TOKEN
*--------------------------------------
CMD.SWITCH jsr CORE.StkGetCtx
lda #2
jsr CORE.StkCheck
bcs .9
jsr EXP.GET
bcs .9
>SYSCALL StrDup
bcs .9
txa
jsr CORE.StkPush Push EXP hVALUE
lda CORE.TestResult
beq .1
ora #$80
.1 ora #C.SWITCH
jmp CORE.StkPush
.9 rts
*--------------------------------------
CMD.CASE jsr CORE.StkGetCtx Get context in CORE.TestResult
bcs .9
tax
and #$3F
cmp #C.SWITCH
beq .1
cmp #C.CASE
bne .9
txa previous case was true ?
bpl .10
jsr EXP.GET skip expression
bcs .9
rts keep existing context
.10 jsr CORE.StkPull remove previous C.CASE
bra CMD.CASE
.1 jsr EXP.GET
bcs .9
>PUSHYA
lda (pData)
tay
dey get hVALUE
lda (pData),y
>SYSCALL GetMemPtr
>SYSCALL StrCmp
ror CS if !=
and #$80
eor #$80
ora CORE.TestResult
ora #C.CASE
jmp CORE.StkPush
.9
CMD.E.CSYN lda #E.CSYN
sec
rts
*--------------------------------------
CMD.DEFAULT jsr CORE.StkGetCtx Get context in CORE.TestResult
bcs CMD.E.CSYN
and #$3F
cmp #C.SWITCH
beq .1
cmp #C.CASE
bne CMD.E.CSYN
jsr CORE.StkPull remove C.CASE
.1 jsr CORE.StkGet
and #$C0
ora #C.DEFAULT
jmp CORE.StkPush
*--------------------------------------
CMD.END jsr CORE.StkGetCtx Get context in CORE.TestResult
bcs CMD.E.CSYN
and #$3F
cmp #C.SWITCH
beq .8
cmp #C.CASE
beq .8
cmp #C.DEFAULT
bne CMD.E.CSYN
.8 jmp CORE.StkPopCtx
*--------------------------------------
CMD.FOR jsr CORE.StkGetCtx
lda (ZPArgVBufPtr)
beq CMD.E.CSYN
>LDYA ZPArgVBufPtr
>STYA ZPVarNamePtr
jsr CORE.ArgV.Next
beq CMD.E.CSYN
>PUSHW ZPArgVBufPtr
>LDYA L.IN
>SYSCALL StrCaseCmp
bcs CMD.E.CSYN
jsr CORE.ArgV.Next
beq CMD.E.CSYN
lda #8 Make sure 8 bytes free on stack
jsr CORE.StkCheck
bcs FOR.FILE.9
lda (ZPArgVBufPtr)
cmp #'('
beq CMD.FOR.FILE
cmp #'`'
beq CMD.FOR.EXEC
*--------------------------------------
CMD.FOR.LIST >LDYA ZPArgVBufPtr
>SYSCALL StrDup
bcs FOR.FILE.9
phy
pha
jsr CORE.StkPushInputBufPtr Push CmdPtr AFTER FOR
pla
ply
jsr CORE.StkPushYAX Push listPtr,hList
jsr CORE.PushVarName Push hVARNAME
lda #C.FOR.LIST
jsr CORE.StkPush
lda #C.FOR
jsr CORE.StkPush
jsr CMD.NEXT.LIST.TOKEN
bcc CMD.FOR.LOOP
rts
*--------------------------------------
CMD.FOR.FILE jsr CORE.ArgV.NextChar skip "("
>LDYA ZPArgVBufPtr
ldx #O.RDONLY+O.TEXT
jsr IO.FOpenYAX
bcc CMD.FOR.PUSH
FOR.FILE.9 rts
*--------------------------------------
CMD.FOR.EXEC jsr CORE.ArgV.NextChar skip "`"
jsr IO.Pipe.Out
bcs FOR.FILE.9
>PUSHW ZPArgVBufPtr
>PUSHBI S.PS.F.CLOSEONX
>SYSCALL ExecL
bcs FOR.FILE.9
jsr IO.Pop.Out Restore OUT (NO close)
jsr IO.Pipe.OpenR
bcs FOR.FILE.9
CMD.FOR.PUSH pha save hFILE/hPIPE
jsr CORE.StkPushInputBufPtr Push CmdPtr AFTER FOR
pla
jsr CORE.StkPush push hPIPE for read
jsr CORE.PushVarName Push hVARNAME
* bcs FOR.FILE.9
lda #C.FOR.FILEEXEC
jsr CORE.StkPush
lda #C.FOR
jsr CORE.StkPush
jsr CMD.NEXT.LINE
bcs FOR.FILE.9
CMD.FOR.LOOP ora CORE.TestResult
ora #C.FOR Push FOR
pha
lda (pData)
tay
pla
sta (pData),y
* clc
rts
*--------------------------------------
CMD.NEXT jsr CORE.StkGet Y = StkPtr
bcs .9
and #$3F
cmp #C.FOR
bne .9
dey
lda (pData),y
iny
tax
beq CMD.NEXT.LIST
jmp CMD.NEXT.FILEEXEC
.9 lda #E.NOFOR
sec
rts
*--------------------------------------
* stack-6 CmdPtr
* stack-4 ListPtr
* stack-3 hLIST
* stack-2 hVARNAME
* stack-1 FOR SUB TOKEN
* stack FOR TOKEN
*--------------------------------------
CMD.NEXT.LIST lda (pData),y Y = StkPtr
bpl .1
jsr CMD.NEXT.LIST.TOKEN
bcs .9
bpl .1
lda (pData)
sec
sbc #6
jmp CMD.NEXT.FILEEXEC.LOOPY
.1 lda (pData)
tay
sec
sbc #8
sta (pData)
dey
dey
lda (pData),y hVARNAME
pha
dey
lda (pData),y hLIST
>SYSCALL FreeMem
pla
>SYSCALL FreeMem
* clc
.9 rts
*--------------------------------------
CMD.NEXT.LIST.TOKEN
jsr CMD.NEXT.GetVarNamePtr
dey skip hLIST
dey
lda (pData),y
sta ZPPtr1
dey
lda (pData),y
sta ZPPtr1+1
ldy #0
.10 jsr GetPtr1NextChar
beq .3
cmp #C.SPACE
beq .10
sta (ZPCLBuf),y
iny
.1 jsr GetPtr1NextChar
beq .3
cmp #C.SPACE
beq .3
sta (ZPCLBuf),y
iny
bra .1
.3 lda #0
sta (ZPCLBuf),y
tya
beq .8
>LDYA ZPCLBuf
jsr CMD.SET.YA
bcs .9
lda (pData)
sec
sbc #4
tay
lda ZPPtr1
sta (pData),y
dey
lda ZPPtr1+1
sta (pData),y
lda #$80
clc
.9 rts
.8 jmp CMD.NEXT.END
*--------------------------------------
* stack-4 CmdPtr
* stack-3 hFILE/hPIPE
* stack-2 hVARNAME
* stack-1 FOR SUB TOKEN
* stack FOR TOKEN
*--------------------------------------
CMD.NEXT.FILEEXEC
lda (pData),y Y = StkPtr
bpl CMD.NEXT.FILEEXEC.POP
jsr CMD.NEXT.LINE
bcs CMD.NEXT.FILEEXEC.9
bpl CMD.NEXT.FILEEXEC.POP end of file/pipe
lda (pData)
sec
sbc #4
CMD.NEXT.FILEEXEC.LOOPY
tay
lda (pData),y
sta ZPInputBufPtr
dey
lda (pData),y
sta ZPInputBufPtr+1
clc
CMD.NEXT.FILEEXEC.9
rts
CMD.NEXT.FILEEXEC.POP
lda (pData)
tay
sec
sbc #6
sta (pData)
dey
dey
lda (pData),y hVARNAME
pha
dey
lda (pData),y hFILE/hPIPE
>SYSCALL FClose
pla
>SYSCALL FreeMem
* clc
rts
*--------------------------------------
CMD.NEXT.LINE jsr CMD.NEXT.GetVarNamePtr
>PUSHWI 256
>PUSHW ZPCLBuf
dey
lda (pData),y hFILE/hPIPE
>SYSCALL FGetS
bcs CMD.NEXT.END
>LDYA ZPCLBuf
jsr CMD.SET.YA
bcs CMD.NEXT.LINE.RTS
lda #$80
* clc
rts
CMD.NEXT.END jsr CMD.SET.UNSET
bcs .9
lda #0
clc keep this CLC for CMD.NEXT.LIST.TOKEN
.9
CMD.NEXT.LINE.RTS
rts
*--------------------------------------
CMD.NEXT.GetVarNamePtr
lda (pData)
dec skip FOR
dec skip SUB TOKEN
tay
lda (pData),y
phy
>SYSCALL GetMemPtr hVARNAME
>STYA ZPVarNamePtr
ply
rts
*--------------------------------------
CMD.WHILE
CMD.IF jsr CORE.StkGetCtx
bit #$40 Parent is true ?
beq .3
jsr EXP.TEST
bcs CMD.NEXT.LINE.RTS
.3 lda CORE.IntCmd
cmp #C.WHILE
bne .8
lda #3
jsr CORE.StkCheck
bcs CMD.NEXT.LINE.RTS
>LDYA ZPInputCmdPtr
jsr CORE.StkPushYA Push BEFORE WHILE/IF
.8 lda CORE.TestResult
ora CORE.IntCmd
jmp CORE.StkPush
*--------------------------------------
CMD.LOOP jsr CORE.StkPull
bcs .9
tax
and #$3F
cmp #C.WHILE
bne .9
txa
bmi .8 true, loop
jmp CORE.StkPopCtxA false, Discard loop Ptr
.8 jmp CORE.StkPullInputBufPtr
.9 lda #E.NOWHILE
sec
rts
*--------------------------------------
CMD.ELSE jsr CORE.StkGet
bcs .9
bit #$40 parent is true ?
beq .8 no, skip
tax
and #$3F
cmp #C.IF
bne .9
txa
eor #$80 toggle and store at stack ptr
sta (pData),y
.8 clc
rts
.9
CMD.ELSE.NOIF lda #E.NOIF
sec
rts
*--------------------------------------
CMD.FI jsr CORE.StkPull
bcs CMD.ELSE.NOIF
and #$3F
cmp #C.IF
bne CMD.ELSE.NOIF
clc
rts
*--------------------------------------
CMD.IsSwitch lda (ZPArgVBufPtr)
cmp #'-'
bne .9
ldy #1
lda (ZPArgVBufPtr),y
beq .9
cmp #'0' is -0 ... -9 ?
bcc .9
cmp #'9'+1
bcc .9
.1 tax
iny
lda (ZPArgVBufPtr),y
bne .9
txa
jmp ToUpperCase
.9 sec
rts
*--------------------------------------
CMD.PrintArgVBufPtr
>PUSHW ZPArgVBufPtr
>PUSHBI 0
>SYSCALL PrintF
rts
*--------------------------------------
MAN
SAVE usr/src/bin/sh.s.cmd
LOAD usr/src/bin/sh.s
ASM