mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
1119 lines
18 KiB
Plaintext
1119 lines
18 KiB
Plaintext
NEW
|
||
PREFIX
|
||
AUTO 4,1
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
CMD.Init >LDYAI 256
|
||
>SYSCALL GetMem
|
||
bcs .9
|
||
>STYA ZPCLBuf
|
||
|
||
txa
|
||
>STA.G CMD.hCLBuf
|
||
|
||
>LDYAI 256
|
||
>SYSCALL GetMem
|
||
bcs .9
|
||
>STYA ZPArgVBuf
|
||
txa
|
||
>STA.G CMD.hArgVBuf
|
||
|
||
lda #PUSHD.STACK
|
||
tay
|
||
sta (pData),y
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
CMD.Quit ldy #CMD.hArgVBuf
|
||
jsr .8
|
||
|
||
ldy #CMD.hCLBuf
|
||
jsr .8
|
||
|
||
ldy #hFileBuf
|
||
|
||
.8 lda (pData),y
|
||
beq .9
|
||
>SYSCALL FreeMem
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* Input : CMD.IntCmd,ZPArgVBuf
|
||
*--------------------------------------
|
||
Cmd.Exec jsr CMD.StkGet IF,WHILE,FOR ?
|
||
bcs .3 no particular context, exec...
|
||
tax
|
||
|
||
>LDA.G CMD.IntCmd
|
||
bmi .2 external ...
|
||
|
||
and #$3F
|
||
cmp #C.FOR
|
||
bcs .3 FOR...FI : always execute
|
||
|
||
.2 txa
|
||
bpl .8 context is FALSE, skip line
|
||
asl
|
||
bpl .8 parent context is FALSE, skip line
|
||
|
||
.3 >LDA.G CMD.IntCmd
|
||
bpl .80 Internal
|
||
|
||
>PUSHB.G CMD.PSFlags
|
||
>LDYA ZPArgVBuf
|
||
>SYSCALL execv
|
||
bcs .9
|
||
|
||
tax CPID
|
||
|
||
>LDA.G CMD.PSFlags
|
||
and #S.PS.F.HOLD
|
||
bne .4
|
||
|
||
txa
|
||
>PUSHA
|
||
>PUSHBI 1
|
||
>LDYA L.MSG.PID
|
||
>SYSCALL printf
|
||
rts
|
||
|
||
.4 >SLEEP Suspend this PID
|
||
|
||
sec
|
||
ldy #S.PS.RC CPID will update S.PS.RC
|
||
lda (pPs),y
|
||
bne .9
|
||
|
||
.8 clc
|
||
.9 rts
|
||
|
||
.80 tax
|
||
jmp (J.CMD.INT,x)
|
||
*--------------------------------------
|
||
* STARTPROC : intcmd = 0
|
||
*--------------------------------------
|
||
Cmd.INT.STARTPROC
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.SHIFT lda #1
|
||
jmp ShiftA
|
||
*--------------------------------------
|
||
Cmd.INT.PWD ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL GetMemPtr
|
||
>SYSCALL puts
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.PUSHD >LDA.G PUSHD.STACK
|
||
cmp #PUSHD.STACK+PUSHD.STACK.MAX
|
||
beq .9
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL GetMemPtr
|
||
>SYSCALL NewStr
|
||
bcs Cmd.INT.POPD.CSYN
|
||
|
||
>INC.G PUSHD.STACK
|
||
tay
|
||
txa
|
||
sta (pData),y
|
||
|
||
ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcs .8
|
||
|
||
>SYSCALL RealPath
|
||
bcs .9
|
||
|
||
jmp Cmd.INT.CD.1
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
Cmd.INT.POPD >LDA.G PUSHD.STACK
|
||
cmp #PUSHD.STACK
|
||
beq Cmd.INT.POPD.CSYN
|
||
|
||
tay
|
||
lda (pData),y
|
||
jsr Cmd.SetPrefixA
|
||
|
||
>DEC.G PUSHD.STACK
|
||
clc
|
||
rts
|
||
|
||
Cmd.INT.POPD.CSYN
|
||
lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.CD ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcs Cmd.INT.CD.HOME
|
||
|
||
>SYSCALL RealPath
|
||
bcc Cmd.INT.CD.1
|
||
|
||
Cmd.INT.CD.RTS rts
|
||
|
||
Cmd.INT.CD.HOME >LDYA L.ENV.HOME
|
||
>SYSCALL GetEnv
|
||
bcc .1
|
||
|
||
>LDYA L.ENV.ROOT
|
||
>SYSCALL GetEnv
|
||
bcc .1
|
||
|
||
jmp Cmd.INT.PWD
|
||
|
||
.1 >SYSCALL ExpandStr
|
||
bcs Cmd.INT.CD.RTS
|
||
|
||
Cmd.INT.CD.1 >STYA ZPPtr1
|
||
txa
|
||
>STA.G CMD.hCmdLine
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
beq .8 we have '/'
|
||
|
||
>PUSHEA.G CMD.Stat
|
||
>LDYA ZPPtr1
|
||
>SYSCALL STAT
|
||
bcs .90
|
||
|
||
>LDA.G CMD.Stat+S.STAT.P.TYPE
|
||
cmp #S.FI.T.DIR
|
||
beq .1
|
||
|
||
lda #E.CSYN
|
||
sec
|
||
bra .90
|
||
|
||
.1 ldy #0
|
||
|
||
.5 iny
|
||
lda (ZPPtr1),y
|
||
bne .5
|
||
|
||
dey
|
||
lda #'/'
|
||
cmp (ZPPtr1),y
|
||
beq .8
|
||
|
||
iny
|
||
sta (ZPPtr1),y
|
||
iny
|
||
lda #0
|
||
sta (ZPPtr1),y
|
||
|
||
.8 >LDYA ZPPtr1
|
||
>SYSCALL NewStr
|
||
bcs .90
|
||
txa
|
||
|
||
jsr Cmd.SetPrefixA
|
||
|
||
.90 php
|
||
pha
|
||
>LDA.G CMD.hCmdLine
|
||
>SYSCALL FreeMem
|
||
pla
|
||
plp
|
||
.9 rts
|
||
*--------------------------------------
|
||
Cmd.SetPrefixA pha
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL FreeMem
|
||
|
||
pla
|
||
|
||
ldy #S.PS.hPREFIX
|
||
sta (pPs),y
|
||
* clc
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.Exec.CSYN lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.Exec.SSYN lda #E.SSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.SET ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcc Cmd.INT.SET.1
|
||
|
||
* No arg, print all ENV
|
||
|
||
ldy #S.PS.hENV
|
||
lda (pPs),y
|
||
>SYSCALL GetMemPtr
|
||
>STYA ZPPTR1
|
||
|
||
.1 lda (ZPPTR1)
|
||
beq .8 Ending 0 ?
|
||
|
||
ldy #$ff
|
||
|
||
.2 iny
|
||
lda (ZPPTR1),y
|
||
bne .2
|
||
|
||
tya
|
||
sec
|
||
adc ZPPTR1
|
||
sta ZPPTR2
|
||
lda #0
|
||
adc ZPPTR1+1
|
||
sta ZPPTR2+1
|
||
|
||
>PUSHW ZPPTR2 Push value
|
||
>PUSHW ZPPTR1 Push name
|
||
jsr Cmd.INT.SET.PRINT
|
||
|
||
bcs .9
|
||
|
||
ldy #$ff
|
||
|
||
.3 iny
|
||
lda (ZPPTR2),y
|
||
bne .3
|
||
|
||
tya
|
||
sec
|
||
adc ZPPTR2
|
||
sta ZPPTR1
|
||
lda #0
|
||
adc ZPPTR2+1
|
||
sta ZPPTR1+1
|
||
bra .1
|
||
|
||
.8 clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* SET +X VAR = VALUE1 op VALUE2 op VALUE3 ...
|
||
*--------------------------------------
|
||
Cmd.INT.SET.1 >STZ.G CMD.Varname
|
||
|
||
lda #1
|
||
>STA.G CMD.ArgIndex
|
||
|
||
.1 tax
|
||
jsr Cmd.GetArgX
|
||
bcs .8
|
||
|
||
jsr CMD.IsSwitch
|
||
bcs .2
|
||
|
||
cmp #'X'
|
||
bne .99
|
||
|
||
lda #$ff
|
||
>EOR.G bSET.X
|
||
sta (pData),y
|
||
>INC.G CMD.ArgIndex
|
||
bra .1
|
||
|
||
.2 >LDA.G CMD.ArgIndex
|
||
>STA.G CMD.Varname
|
||
|
||
>INC.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
bcs Cmd.INT.SET.GET
|
||
|
||
>STYA ZPPTR1
|
||
|
||
lda (ZPPTR1)
|
||
|
||
cmp #'='
|
||
bne .99
|
||
|
||
ldy #1
|
||
lda (ZPPTR1),y
|
||
bne .99
|
||
|
||
>INC.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
bcs Cmd.INT.SET.UNSET
|
||
|
||
jsr Cmd.GetEXP
|
||
|
||
bcs .99
|
||
|
||
>PUSHYA
|
||
>LDA.G CMD.Varname
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL SetEnv
|
||
rts
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.99 lda #E.CSYN
|
||
sec
|
||
rts
|
||
|
||
Cmd.INT.SET.UNSET
|
||
>LDA.G CMD.Varname
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL UnsetEnv
|
||
rts
|
||
|
||
Cmd.INT.SET.GET
|
||
>LDA.G CMD.Varname
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL GetEnv
|
||
bcc .1
|
||
clc
|
||
rts
|
||
|
||
.1 >PUSHYA push value
|
||
>LDA.G CMD.Varname
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
>PUSHYA push name
|
||
*--------------------------------------
|
||
Cmd.INT.SET.PRINT
|
||
>PUSHBI 4
|
||
>LDYA L.MSG.PRINTENV
|
||
>SYSCALL printf
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.DATE sec
|
||
.HS 90 bcc
|
||
Cmd.INT.TIME clc
|
||
php
|
||
>LEA.G CMD.Time
|
||
>SYSCALL Time
|
||
|
||
>PUSHEA.G CMD.Time
|
||
|
||
plp
|
||
bcc .1
|
||
>PUSHW L.FMT.DATE
|
||
bra .2
|
||
.1 >PUSHW L.FMT.TIME
|
||
|
||
.2 >LDYA ZPCLBuf
|
||
>SYSCALL StrFTime
|
||
|
||
>LDYA ZPCLBuf
|
||
>SYSCALL puts
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.ECHO >STZ.G bECHO.N
|
||
|
||
lda #1
|
||
>STA.G CMD.ArgIndex
|
||
|
||
.1 tax
|
||
jsr Cmd.GetArgX
|
||
bcs .7
|
||
|
||
jsr CMD.IsSwitch
|
||
bcs .2
|
||
|
||
cmp #'N'
|
||
bne .99
|
||
|
||
lda #$ff
|
||
>EOR.G bECHO.N
|
||
sta (pData),y
|
||
>INC.G CMD.ArgIndex
|
||
bra .1
|
||
|
||
.2 pha
|
||
>PUSHBI 0
|
||
pla
|
||
>SYSCALL printf
|
||
bcs .9
|
||
|
||
>INC.G CMD.ArgIndex
|
||
tax
|
||
|
||
jsr Cmd.GetArgX
|
||
bcs .7
|
||
|
||
.6 lda #C.SPACE
|
||
>SYSCALL putchar
|
||
bcs .9
|
||
|
||
>PUSHBI 0
|
||
|
||
>LDA.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
|
||
>SYSCALL printf
|
||
bcs .9
|
||
|
||
>INC.G CMD.ArgIndex
|
||
tax
|
||
|
||
jsr Cmd.GetArgX
|
||
bcc .6
|
||
|
||
.7 >LDA.G bECHO.N
|
||
bmi .8
|
||
|
||
>PUSHBI 0
|
||
>LDYA L.MSG.ECHOCRLF
|
||
>SYSCALL printf
|
||
rts
|
||
|
||
.8 clc
|
||
.9 rts
|
||
|
||
.99 lda #E.CSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.READ lda #1
|
||
>STA.G CMD.ArgIndex
|
||
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
.1 jsr CMD.IsSwitch
|
||
bcs .4
|
||
cmp #'S'
|
||
bne .2
|
||
|
||
lda #$ff
|
||
>STA.G bREAD.S
|
||
|
||
bra .7
|
||
|
||
.2 cmp #'P'
|
||
bne .9
|
||
|
||
>INC.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
pha
|
||
>PUSHBI 0
|
||
pla
|
||
>SYSCALL printf
|
||
bcs .99
|
||
bra .7
|
||
|
||
.4 >SYSCALL newstr
|
||
txa
|
||
>STA.G hVarName
|
||
|
||
.7 >INC.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
bcc .1
|
||
|
||
>LDA.G hVarName
|
||
beq .9
|
||
clc
|
||
.99 rts
|
||
|
||
.9 jmp Cmd.Exec.CSYN
|
||
*--------------------------------------
|
||
Cmd.INT.SLEEP ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
>SYSCALL AToL
|
||
bcs .9
|
||
|
||
>PULLL.G Sleep
|
||
clc
|
||
rts
|
||
|
||
.9 jmp Cmd.Exec.CSYN
|
||
*--------------------------------------
|
||
Cmd.INT.PAUSE lda #$FF
|
||
>STA.G bPause
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.EXIT ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcs .8 no arg, exit 0
|
||
|
||
>SYSCALL AToL
|
||
bcs .9
|
||
|
||
>PULLL.G M32.ACC
|
||
|
||
lda #$FF
|
||
>STA.G bExit
|
||
|
||
>LDA.G M32.ACC
|
||
clc
|
||
rts
|
||
|
||
.8 lda #$FF
|
||
>STA.G bExit
|
||
inc
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
Cmd.INT.MD ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
>SYSCALL MKDir
|
||
rts
|
||
|
||
.9 jmp Cmd.Exec.CSYN
|
||
*--------------------------------------
|
||
Cmd.INT.REN ldx #2
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
>PUSHYA
|
||
ldx #1
|
||
jsr Cmd.GetArgX
|
||
|
||
>SYSCALL Rename
|
||
rts
|
||
|
||
.9 jmp Cmd.Exec.CSYN
|
||
*--------------------------------------
|
||
Cmd.INT.RD ldx #1
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
phy
|
||
pha
|
||
>PUSHEA.G CMD.Stat
|
||
pla
|
||
ply
|
||
>SYSCALL STAT
|
||
bcs .99
|
||
|
||
>LDA.G CMD.Stat+S.STAT.P.TYPE
|
||
cmp #S.FI.T.DIR
|
||
bne .9
|
||
|
||
ldx #1
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL Remove
|
||
.99 rts
|
||
|
||
.9 jmp Cmd.Exec.CSYN
|
||
*--------------------------------------
|
||
Cmd.INT.BREAK
|
||
.9 jmp Cmd.Exec.SSYN
|
||
*--------------------------------------
|
||
Cmd.INT.CONTINUE
|
||
.9 jmp Cmd.Exec.SSYN
|
||
*--------------------------------------
|
||
Cmd.INT.FOR
|
||
.9 jmp Cmd.Exec.SSYN
|
||
*--------------------------------------
|
||
Cmd.INT.NEXT
|
||
.9 jmp Cmd.Exec.SSYN
|
||
*--------------------------------------
|
||
Cmd.INT.WHILE
|
||
Cmd.INT.IF jsr CMD.StkGet
|
||
bcs .1 no context...
|
||
|
||
and #$80 get current..
|
||
lsr becomes parent
|
||
bra .2
|
||
|
||
.1 lda #$40 ...set Parent = true
|
||
|
||
.2 >STA.G CMD.Test
|
||
|
||
bit #$40 Parent is true ?
|
||
beq .3
|
||
|
||
jsr Cmd.Eval
|
||
bcs .9
|
||
|
||
.3 >LDA.G CMD.IntCmd
|
||
cmp #C.WHILE
|
||
bne .8
|
||
|
||
jsr CMD.StkPushPtr
|
||
bcs .9
|
||
|
||
.8 >LDA.G CMD.Test
|
||
>ORA.G CMD.IntCmd
|
||
jmp CMD.StkPush
|
||
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
Cmd.INT.ELSE jsr CMD.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 lda #E.NOIF
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.FI jsr CMD.StkPull
|
||
bcs .9
|
||
|
||
and #$3F
|
||
cmp #C.IF
|
||
bne .9
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.NOIF
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.INT.LOOP jsr CMD.StkPull
|
||
bcs .9
|
||
tax
|
||
and #$3F
|
||
cmp #C.WHILE
|
||
bne .9
|
||
|
||
txa
|
||
bpl .1
|
||
|
||
jmp CMD.StkPullPtr
|
||
|
||
.1 jsr CMD.StkPull
|
||
bcs .99
|
||
jmp CMD.StkPull
|
||
|
||
.9 lda #E.NOWHILE
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
Cmd.Eval ldx #1
|
||
jsr Cmd.GetArgX
|
||
beq .9
|
||
|
||
>PUSHYA
|
||
>LDYA L.CMD.Eval.TOKEN1
|
||
jsr Lookup
|
||
|
||
bcs .9
|
||
|
||
cpx #4 [ or ![
|
||
bcs .9
|
||
dex
|
||
dex 1 or $ff
|
||
|
||
txa
|
||
|
||
and #$80 true or false
|
||
>ORA.G CMD.Test
|
||
sta (pData),y
|
||
|
||
ldx #2
|
||
jsr Cmd.GetArgX
|
||
beq .9
|
||
|
||
>PUSHYA
|
||
>LDYA L.CMD.Eval.TOKEN2 -d -e -f ?
|
||
jsr Lookup
|
||
|
||
bcs .1
|
||
|
||
txa
|
||
>STA.G CMD.Operator
|
||
|
||
jsr CMD.Eval.UNARY
|
||
bcs .9
|
||
|
||
>EOR.G CMD.Test
|
||
sta (pData),y
|
||
|
||
ldx #4 go check ]
|
||
bra .8
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
.99 rts
|
||
|
||
.1 ldx #3
|
||
jsr Cmd.GetArgX
|
||
beq .9
|
||
|
||
>PUSHYA
|
||
>LDYA L.CMD.Eval.TOKEN3 -eq -ne .... ?
|
||
jsr Lookup
|
||
bcs .9
|
||
txa
|
||
>STA.G CMD.Operator
|
||
|
||
jsr CMD.Eval.BINARY
|
||
bcs .9
|
||
|
||
>EOR.G CMD.Test
|
||
sta (pData),y
|
||
|
||
ldx #5 go check ]
|
||
|
||
.8 jsr Cmd.GetArgX
|
||
beq .9
|
||
|
||
>STYA ZPPTR1
|
||
|
||
lda (ZPPTR1)
|
||
cmp #']'
|
||
bne .9
|
||
|
||
ldy #1
|
||
lda (ZPPTR1),y
|
||
bne .9
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CMD.Eval.UNARY ldx #3
|
||
jsr Cmd.GetArgX
|
||
bcs .9 we need one arg
|
||
|
||
>LDA.G CMD.Operator
|
||
tax
|
||
jmp (J.CMD.Eval.TOKEN2,x)
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
rts
|
||
|
||
CMD.Eval.D jsr CMD.Eval.DEF.7
|
||
bcs CMD.Eval.DEF.9
|
||
>LDA.G CMD.Stat+S.STAT.P.TYPE
|
||
cmp #S.FI.T.DIR
|
||
bne CMD.Eval.DEF.9
|
||
bra CMD.Eval.DEF.8
|
||
|
||
CMD.Eval.E jsr CMD.Eval.DEF.7
|
||
bcs CMD.Eval.DEF.9
|
||
bra CMD.Eval.DEF.8 DIR or FILE exist
|
||
|
||
CMD.Eval.F jsr CMD.Eval.DEF.7
|
||
bcs CMD.Eval.DEF.9
|
||
|
||
>LDA.G CMD.Stat+S.STAT.P.TYPE
|
||
cmp #S.FI.T.DIR
|
||
beq CMD.Eval.DEF.9
|
||
bra CMD.Eval.DEF.8
|
||
|
||
CMD.Eval.DEF.7 >PUSHEA.G CMD.Stat
|
||
ldx #3
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL STAT
|
||
rts
|
||
|
||
CMD.Eval.DEF.8 lda #$80 true
|
||
clc
|
||
rts
|
||
|
||
CMD.Eval.DEF.9 lda #0 false
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CMD.Eval.BINARY ldx #2
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
ldx #4
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
>LDA.G CMD.Operator
|
||
beq .1 =
|
||
|
||
cmp #2 !=
|
||
bne CMD.Eval.BINARY.NUM
|
||
lda #$80
|
||
>STA.G CMD.Operator
|
||
|
||
.1 ldx #2
|
||
jsr Cmd.GetArgX
|
||
>PUSHYA
|
||
ldx #4
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL strcmp
|
||
ror CS if !=
|
||
and #$80
|
||
eor #$80
|
||
>EOR.G CMD.Operator
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CMD.Eval.BINARY.NUM
|
||
ldx #2
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
>SYSCALL AToL
|
||
bcs .9
|
||
|
||
>PULLL.G M32.ACC
|
||
|
||
ldx #4
|
||
jsr Cmd.GetArgX
|
||
bcs .9
|
||
|
||
>SYSCALL AToL
|
||
bcs .9
|
||
|
||
>PULLL.G M32.ARG
|
||
|
||
jsr M32.Cmp
|
||
pha
|
||
|
||
>LDA.G CMD.Operator
|
||
lsr
|
||
tax
|
||
pla
|
||
and CMD.Eval.TOKEN3.BITS,x
|
||
beq .80
|
||
|
||
lda #$80 true
|
||
clc
|
||
rts
|
||
|
||
.80 lda #0 false
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.ESYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.GetEXP >LDA.G CMD.ArgIndex
|
||
inc
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
bcc .1
|
||
|
||
>LDA.G CMD.ArgIndex no op, return text value
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
rts
|
||
|
||
.1 >LDA.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
>SYSCALL AToL
|
||
bcs .99
|
||
|
||
>PULLL.G M32.ACC
|
||
|
||
jsr Cmd.GetEXP.GetNext
|
||
|
||
.2 >PUSHYA
|
||
>LDYA L.CMD.Eval.TOKEN4 + - .... ?
|
||
jsr Lookup
|
||
|
||
bcs .9
|
||
txa
|
||
>STA.G CMD.Operator
|
||
|
||
jsr M32.ACC2ARG
|
||
|
||
jsr Cmd.GetEXP.GetNext get next argument in ACC
|
||
.99 bcs .9
|
||
|
||
>SYSCALL AToL
|
||
bcs .9
|
||
|
||
>PULLL.G M32.ACC
|
||
jsr Cmd.GetEXP.Op
|
||
bcs .9
|
||
|
||
jsr Cmd.GetEXP.GetNext another op ?
|
||
bcc .2
|
||
|
||
.8 >PUSHL.G M32.ACC
|
||
>PUSHBI 4
|
||
>PUSHW L.M32.Printf
|
||
>LEA.G M32.BUF
|
||
>SYSCALL sprintf
|
||
bcs .9
|
||
|
||
>LEA.G M32.Buf
|
||
|
||
rts
|
||
|
||
.9 lda #E.BADEXP
|
||
rts
|
||
|
||
Cmd.GetEXP.Op >LDA.G CMD.Operator
|
||
tax
|
||
jmp (J.CMD.Eval.TOKEN4,x)
|
||
*--------------------------------------
|
||
Cmd.GetEXP.GetNext
|
||
>INC.G CMD.ArgIndex
|
||
tax
|
||
jsr Cmd.GetArgX
|
||
rts
|
||
*--------------------------------------
|
||
Cmd.GetArgX >LDYA ZPArgVBuf
|
||
|
||
dex
|
||
bmi .8
|
||
|
||
>STYA ZPPtr1
|
||
|
||
.1 lda (ZPPtr1)
|
||
beq .9
|
||
|
||
.2 inc ZPPtr1
|
||
bne .3
|
||
inc ZPPtr1+1
|
||
.3 lda (ZPPtr1)
|
||
bne .2
|
||
|
||
inc ZPPtr1
|
||
bne .4
|
||
inc ZPPtr1+1
|
||
|
||
.4 lda (ZPPtr1)
|
||
beq .9
|
||
|
||
dex
|
||
bpl .1
|
||
|
||
>LDYA ZPPtr1
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
CMD.IsSwitch >STYA ZPPtr1
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .9
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
beq .9
|
||
|
||
iny
|
||
lda (ZPPtr1),y
|
||
bne .9
|
||
|
||
dey
|
||
lda (ZPPtr1),y
|
||
cmp #'a'
|
||
bcc .8
|
||
cmp #'z'+1
|
||
bcs .8
|
||
eor #$20
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 >LDYA ZPPtr1
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CMD.StkPushPtr >LDA.G CMD.FileBufPtr
|
||
jsr CMD.StkPush
|
||
bcs .9
|
||
>LDA.G CMD.FileBufPtr+1
|
||
jmp CMD.StkPush
|
||
.9 rts
|
||
*--------------------------------------
|
||
CMD.StkPullPtr jsr CMD.StkPull
|
||
bcs .9
|
||
sta ZPFileBufPtr+1
|
||
jsr CMD.StkPull
|
||
bcs .9
|
||
sta ZPFileBufPtr
|
||
.9 rts
|
||
*--------------------------------------
|
||
CMD.StkGetPtr lda (pData) StackPtr
|
||
beq .9
|
||
dec
|
||
beq .9
|
||
|
||
tay
|
||
|
||
lda (pData),y
|
||
sta ZPFileBufPtr
|
||
iny
|
||
lda (pData),y
|
||
sta ZPFileBufPtr+1
|
||
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.SSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CMD.StkPush pha
|
||
lda (pData) StackPtr
|
||
inc
|
||
cmp #CMD.STACK.MAX
|
||
beq .9
|
||
sta (pData) StackPtr
|
||
tay
|
||
pla
|
||
sta (pData),y
|
||
* clc
|
||
rts
|
||
|
||
.9 pla
|
||
lda #E.STKOVERFLOW
|
||
* sec
|
||
rts
|
||
*--------------------------------------
|
||
CMD.StkPull jsr CMD.StkGet
|
||
bcs .9
|
||
|
||
dey
|
||
pha
|
||
tya
|
||
sta (pData) StackPtr
|
||
pla
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
CMD.StkGet lda (pData) StackPtr
|
||
beq .9
|
||
tay
|
||
lda (pData),y
|
||
clc
|
||
rts
|
||
|
||
.9 lda #E.SSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/SHELL.S.CMD
|
||
LOAD USR/SRC/BIN/SHELL.S
|
||
ASM
|