A2osX/BIN/SHELL.S.CMD.txt

1119 lines
18 KiB
Plaintext
Raw Normal View History

NEW
2018-11-17 17:17:13 +00:00
PREFIX
AUTO 4,1
2015-10-19 20:35:00 +00:00
.LIST OFF
*--------------------------------------
2018-10-19 15:26:21 +00:00
CMD.Init >LDYAI 256
2018-07-13 14:38:24 +00:00
>SYSCALL GetMem
bcs .9
>STYA ZPCLBuf
txa
>STA.G CMD.hCLBuf
2018-10-29 08:41:10 +00:00
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPArgVBuf
txa
>STA.G CMD.hArgVBuf
2018-11-26 16:36:55 +00:00
lda #PUSHD.STACK
tay
sta (pData),y
2018-11-19 16:15:16 +00:00
.9 rts
*--------------------------------------
2018-11-17 17:17:13 +00:00
CMD.Quit ldy #CMD.hArgVBuf
jsr .8
2018-11-30 16:00:36 +00:00
2018-11-17 17:17:13 +00:00
ldy #CMD.hCLBuf
jsr .8
2018-11-30 16:00:36 +00:00
2018-11-17 17:17:13 +00:00
ldy #hFileBuf
2018-11-30 16:00:36 +00:00
.8 lda (pData),y
beq .9
2018-07-13 14:38:24 +00:00
>SYSCALL FreeMem
2018-11-30 16:00:36 +00:00
clc
.9 rts
*--------------------------------------
2018-11-26 06:57:11 +00:00
* Input : CMD.IntCmd,ZPArgVBuf
2018-11-09 15:59:04 +00:00
*--------------------------------------
2018-11-26 06:57:11 +00:00
Cmd.Exec jsr CMD.StkGet IF,WHILE,FOR ?
bcs .3 no particular context, exec...
2018-10-21 20:54:07 +00:00
tax
2018-11-26 10:40:19 +00:00
>LDA.G CMD.IntCmd
bmi .2 external ...
2018-11-26 06:57:11 +00:00
and #$3F
cmp #C.FOR
bcs .3 FOR...FI : always execute
2018-11-26 10:40:19 +00:00
.2 txa
2018-11-19 16:15:16 +00:00
bpl .8 context is FALSE, skip line
2018-11-26 06:57:11 +00:00
asl
bpl .8 parent context is FALSE, skip line
2018-11-19 16:15:16 +00:00
2018-11-26 06:57:11 +00:00
.3 >LDA.G CMD.IntCmd
bpl .80 Internal
>PUSHB.G CMD.PSFlags
2018-10-23 15:36:57 +00:00
>LDYA ZPArgVBuf
2018-10-25 15:31:41 +00:00
>SYSCALL execv
bcs .9
tax CPID
>LDA.G CMD.PSFlags
and #S.PS.F.HOLD
2018-11-20 15:54:49 +00:00
bne .4
txa
>PUSHA
>PUSHBI 1
>LDYA L.MSG.PID
>SYSCALL printf
2018-10-23 15:36:57 +00:00
rts
2018-12-05 15:12:10 +00:00
.4 >SLEEP Suspend this PID
2018-12-06 11:40:30 +00:00
sec
2018-12-05 15:12:10 +00:00
ldy #S.PS.RC CPID will update S.PS.RC
lda (pPs),y
2018-12-06 11:40:30 +00:00
bne .9
.8 clc
.9 rts
2018-11-20 15:54:49 +00:00
2018-11-26 06:57:11 +00:00
.80 tax
jmp (J.CMD.INT,x)
*--------------------------------------
2018-10-21 20:54:07 +00:00
* STARTPROC : intcmd = 0
2015-10-19 20:35:00 +00:00
*--------------------------------------
2018-10-21 20:54:07 +00:00
Cmd.INT.STARTPROC
clc
2018-10-19 15:26:21 +00:00
rts
2018-11-20 15:54:49 +00:00
*--------------------------------------
Cmd.INT.SHIFT lda #1
jmp ShiftA
*--------------------------------------
2018-10-15 06:25:40 +00:00
Cmd.INT.PWD ldy #S.PS.hPREFIX
2015-10-19 20:35:00 +00:00
lda (pPs),y
2018-07-13 14:38:24 +00:00
>SYSCALL GetMemPtr
2018-08-22 15:23:27 +00:00
>SYSCALL puts
2018-11-20 15:54:49 +00:00
rts
2018-11-08 14:23:06 +00:00
*--------------------------------------
2018-11-26 16:36:55 +00:00
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
2018-11-28 11:39:33 +00:00
bcs Cmd.INT.POPD.CSYN
2018-11-26 16:36:55 +00:00
>INC.G PUSHD.STACK
tay
txa
sta (pData),y
ldx #1
jsr Cmd.GetArgX
bcs .8
>SYSCALL RealPath
2018-11-28 11:39:33 +00:00
bcs .9
2018-11-26 16:36:55 +00:00
jmp Cmd.INT.CD.1
.8 clc
2018-11-28 11:39:33 +00:00
.9 rts
2018-11-26 16:36:55 +00:00
*--------------------------------------
Cmd.INT.POPD >LDA.G PUSHD.STACK
cmp #PUSHD.STACK
2018-11-28 11:39:33 +00:00
beq Cmd.INT.POPD.CSYN
2018-11-26 16:36:55 +00:00
tay
lda (pData),y
jsr Cmd.SetPrefixA
>DEC.G PUSHD.STACK
clc
rts
2018-11-28 11:39:33 +00:00
Cmd.INT.POPD.CSYN
lda #E.CSYN
2018-11-26 16:36:55 +00:00
sec
rts
*--------------------------------------
2018-10-21 20:54:07 +00:00
Cmd.INT.CD ldx #1
jsr Cmd.GetArgX
2018-11-20 15:54:49 +00:00
bcs Cmd.INT.CD.HOME
2018-08-11 10:57:57 +00:00
2018-11-20 15:54:49 +00:00
>SYSCALL RealPath
bcc Cmd.INT.CD.1
Cmd.INT.CD.RTS rts
2018-11-17 17:17:13 +00:00
Cmd.INT.CD.HOME >LDYA L.ENV.HOME
2018-07-13 14:38:24 +00:00
>SYSCALL GetEnv
2018-11-17 17:17:13 +00:00
bcc .1
2018-11-17 17:17:13 +00:00
>LDYA L.ENV.ROOT
>SYSCALL GetEnv
2018-11-26 16:36:55 +00:00
bcc .1
jmp Cmd.INT.PWD
2015-10-19 20:35:00 +00:00
2018-11-17 17:17:13 +00:00
.1 >SYSCALL ExpandStr
2018-11-20 15:54:49 +00:00
bcs Cmd.INT.CD.RTS
2018-11-17 17:17:13 +00:00
Cmd.INT.CD.1 >STYA ZPPtr1
txa
2018-11-08 14:23:06 +00:00
>STA.G CMD.hCmdLine
2018-10-21 20:54:07 +00:00
ldy #1
2018-11-08 14:23:06 +00:00
lda (ZPPtr1),y
beq .8 we have '/'
2018-10-26 14:46:11 +00:00
>PUSHEA.G CMD.Stat
2018-11-08 14:23:06 +00:00
>LDYA ZPPtr1
>SYSCALL STAT
2018-10-26 14:46:11 +00:00
bcs .90
2016-08-17 06:25:58 +00:00
2018-10-21 20:54:07 +00:00
>LDA.G CMD.Stat+S.STAT.P.TYPE
2018-10-22 15:46:09 +00:00
cmp #S.FI.T.DIR
2018-11-26 16:36:55 +00:00
beq .1
2018-11-28 11:39:33 +00:00
lda #E.CSYN
2018-11-26 16:36:55 +00:00
sec
bra .90
.1 ldy #0
2018-10-29 08:41:10 +00:00
.5 iny
2018-11-08 14:23:06 +00:00
lda (ZPPtr1),y
2018-10-29 08:41:10 +00:00
bne .5
dey
lda #'/'
2018-11-08 14:23:06 +00:00
cmp (ZPPtr1),y
2018-10-29 08:41:10 +00:00
beq .8
iny
2018-11-08 14:23:06 +00:00
sta (ZPPtr1),y
2018-10-29 08:41:10 +00:00
iny
lda #0
2018-11-08 14:23:06 +00:00
sta (ZPPtr1),y
2018-10-29 08:41:10 +00:00
2018-11-08 14:23:06 +00:00
.8 >LDYA ZPPtr1
2018-07-13 14:38:24 +00:00
>SYSCALL NewStr
2018-10-26 14:46:11 +00:00
bcs .90
2018-11-26 16:36:55 +00:00
txa
2016-03-13 21:53:55 +00:00
2018-11-26 16:36:55 +00:00
jsr Cmd.SetPrefixA
.90 php
pha
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem
pla
plp
.9 rts
*--------------------------------------
Cmd.SetPrefixA pha
2016-08-17 06:25:58 +00:00
ldy #S.PS.hPREFIX
lda (pPs),y
2018-07-13 14:38:24 +00:00
>SYSCALL FreeMem
2016-08-17 06:25:58 +00:00
2016-03-13 21:53:55 +00:00
pla
2016-08-17 06:25:58 +00:00
ldy #S.PS.hPREFIX
sta (pPs),y
2018-11-28 14:58:42 +00:00
* clc
rts
2016-08-17 06:25:58 +00:00
*--------------------------------------
2018-11-28 11:39:33 +00:00
Cmd.Exec.CSYN lda #E.CSYN
sec
rts
*--------------------------------------
Cmd.Exec.SSYN lda #E.SSYN
sec
2018-10-15 06:25:40 +00:00
rts
*--------------------------------------
2018-10-22 15:46:09 +00:00
Cmd.INT.SET ldx #1
2018-10-21 20:54:07 +00:00
jsr Cmd.GetArgX
2018-11-20 15:54:49 +00:00
bcc Cmd.INT.SET.1
* No arg, print all ENV
2015-10-19 20:35:00 +00:00
ldy #S.PS.hENV
lda (pPs),y
2018-07-13 14:38:24 +00:00
>SYSCALL GetMemPtr
2015-10-19 20:35:00 +00:00
>STYA ZPPTR1
2015-10-19 20:35:00 +00:00
.1 lda (ZPPTR1)
beq .8 Ending 0 ?
ldy #$ff
.2 iny
lda (ZPPTR1),y
bne .2
tya
2016-08-17 06:25:58 +00:00
sec
adc ZPPTR1
sta ZPPTR2
lda #0
adc ZPPTR1+1
sta ZPPTR2+1
>PUSHW ZPPTR2 Push value
>PUSHW ZPPTR1 Push name
2018-10-15 06:25:40 +00:00
jsr Cmd.INT.SET.PRINT
2016-08-17 06:25:58 +00:00
bcs .9
2015-10-19 20:35:00 +00:00
ldy #$ff
.3 iny
lda (ZPPTR2),y
bne .3
tya
2015-10-19 20:35:00 +00:00
sec
adc ZPPTR2
2015-10-19 20:35:00 +00:00
sta ZPPTR1
lda #0
adc ZPPTR2+1
sta ZPPTR1+1
2015-10-19 20:35:00 +00:00
bra .1
2015-10-19 20:35:00 +00:00
.8 clc
2018-10-15 06:25:40 +00:00
.9 rts
2018-09-14 13:08:30 +00:00
*--------------------------------------
2018-11-20 15:54:49 +00:00
* 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
2018-11-20 15:54:49 +00:00
>INC.G CMD.ArgIndex
bra .1
2015-10-19 20:35:00 +00:00
2018-11-20 15:54:49 +00:00
.2 >LDA.G CMD.ArgIndex
>STA.G CMD.Varname
2018-11-20 15:54:49 +00:00
>INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcs Cmd.INT.SET.GET
2018-11-20 15:54:49 +00:00
>STYA ZPPTR1
2015-10-19 20:35:00 +00:00
2018-11-20 15:54:49 +00:00
lda (ZPPTR1)
2016-08-17 06:25:58 +00:00
2018-11-20 15:54:49 +00:00
cmp #'='
bne .99
2016-08-17 06:25:58 +00:00
2018-11-20 15:54:49 +00:00
ldy #1
lda (ZPPTR1),y
bne .99
2018-09-14 13:08:30 +00:00
2018-11-20 15:54:49 +00:00
>INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcs Cmd.INT.SET.UNSET
2018-11-22 16:39:41 +00:00
jsr Cmd.GetEXP
2018-11-21 07:09:22 +00:00
2018-11-22 07:29:55 +00:00
bcs .99
2018-11-21 07:09:22 +00:00
2018-11-23 21:36:31 +00:00
>PUSHYA
2018-11-20 15:54:49 +00:00
>LDA.G CMD.Varname
tax
jsr Cmd.GetArgX
>SYSCALL SetEnv
2018-10-15 06:25:40 +00:00
rts
2018-11-20 15:54:49 +00:00
.8 clc
rts
2018-11-28 11:39:33 +00:00
.99 lda #E.CSYN
sec
rts
2016-08-17 06:25:58 +00:00
2018-11-20 15:54:49 +00:00
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
2018-07-13 14:38:24 +00:00
>SYSCALL GetEnv
2018-11-26 06:57:11 +00:00
bcc .1
clc
2018-11-20 15:54:49 +00:00
rts
2016-08-17 06:25:58 +00:00
2018-11-26 06:57:11 +00:00
.1 >PUSHYA push value
2018-11-20 15:54:49 +00:00
>LDA.G CMD.Varname
tax
jsr Cmd.GetArgX
>PUSHYA push name
2015-10-19 20:35:00 +00:00
*--------------------------------------
2018-10-15 06:25:40 +00:00
Cmd.INT.SET.PRINT
2018-09-14 13:08:30 +00:00
>PUSHBI 4
>LDYA L.MSG.PRINTENV
>SYSCALL printf
rts
*--------------------------------------
2018-10-15 06:25:40 +00:00
Cmd.INT.DATE sec
.HS 90 bcc
2018-10-15 06:25:40 +00:00
Cmd.INT.TIME clc
php
>LEA.G CMD.Time
2018-07-13 14:38:24 +00:00
>SYSCALL Time
2018-10-11 15:23:06 +00:00
>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
2018-08-22 15:23:27 +00:00
>SYSCALL puts
2018-10-15 06:25:40 +00:00
rts
2015-10-19 20:35:00 +00:00
*--------------------------------------
2018-11-28 11:39:33 +00:00
Cmd.INT.ECHO >STZ.G bECHO.N
lda #1
>STA.G CMD.ArgIndex
2018-11-28 11:39:33 +00:00
.1 tax
2018-10-21 20:54:07 +00:00
jsr Cmd.GetArgX
bcs .7
2018-10-21 20:54:07 +00:00
2018-11-28 11:39:33 +00:00
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
2018-10-16 15:48:03 +00:00
bcs .9
>INC.G CMD.ArgIndex
tax
2018-10-21 20:54:07 +00:00
jsr Cmd.GetArgX
2018-10-16 15:48:03 +00:00
bcs .7
2018-11-28 11:39:33 +00:00
.6 lda #C.SPACE
2018-10-16 15:48:03 +00:00
>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
2018-11-28 11:39:33 +00:00
bcc .6
2018-10-16 15:48:03 +00:00
.7 >LDA.G bECHO.N
2018-10-16 15:48:03 +00:00
bmi .8
2018-10-29 08:41:10 +00:00
>PUSHBI 0
>LDYA L.MSG.ECHOCRLF
>SYSCALL printf
rts
2018-10-16 15:48:03 +00:00
.8 clc
.9 rts
2018-11-28 11:39:33 +00:00
.99 lda #E.CSYN
sec
rts
2015-10-19 20:35:00 +00:00
*--------------------------------------
Cmd.INT.READ lda #1
>STA.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcs .9
2018-09-17 06:16:45 +00:00
.1 jsr CMD.IsSwitch
bcs .4
cmp #'S'
bne .2
lda #$ff
>STA.G bREAD.S
2018-09-17 06:16:45 +00:00
bra .7
.2 cmp #'P'
bne .9
>INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcs .9
2018-09-17 06:16:45 +00:00
pha
>PUSHBI 0
pla
>SYSCALL printf
bcs .99
2018-09-17 06:16:45 +00:00
bra .7
.4 >SYSCALL newstr
txa
>STA.G hVarName
.7 >INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
bcc .1
2018-09-17 06:16:45 +00:00
>LDA.G hVarName
beq .9
clc
2018-10-15 06:25:40 +00:00
.99 rts
2018-11-19 16:15:16 +00:00
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.CSYN
*--------------------------------------
2018-11-09 13:29:23 +00:00
Cmd.INT.SLEEP ldx #1
jsr Cmd.GetArgX
bcs .9
>SYSCALL AToL
bcs .9
2018-09-17 06:16:45 +00:00
>PULLL.G Sleep
2018-10-15 06:25:40 +00:00
clc
rts
2018-09-17 06:16:45 +00:00
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.CSYN
*--------------------------------------
2018-10-15 06:25:40 +00:00
Cmd.INT.PAUSE lda #$FF
>STA.G bPause
clc
2018-10-15 06:25:40 +00:00
rts
*--------------------------------------
2018-11-28 21:37:18 +00:00
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
2018-11-28 21:37:18 +00:00
>LDA.G M32.ACC
2018-12-04 16:45:58 +00:00
clc
2018-10-15 06:25:40 +00:00
rts
2018-11-28 21:37:18 +00:00
.8 lda #$FF
>STA.G bExit
2018-12-04 16:45:58 +00:00
inc
2018-11-28 21:37:18 +00:00
clc
.9 rts
2015-10-19 20:35:00 +00:00
*--------------------------------------
2018-11-10 14:30:09 +00:00
Cmd.INT.MD ldx #1
jsr Cmd.GetArgX
bcs .9
>SYSCALL MKDir
rts
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.CSYN
2018-11-15 15:04:14 +00:00
*--------------------------------------
Cmd.INT.REN ldx #2
jsr Cmd.GetArgX
bcs .9
>PUSHYA
ldx #1
jsr Cmd.GetArgX
>SYSCALL Rename
rts
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.CSYN
2018-11-10 14:30:09 +00:00
*--------------------------------------
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
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.CSYN
2018-11-26 06:57:11 +00:00
*--------------------------------------
Cmd.INT.BREAK
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.SSYN
2018-11-26 06:57:11 +00:00
*--------------------------------------
Cmd.INT.CONTINUE
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.SSYN
2018-11-10 14:30:09 +00:00
*--------------------------------------
2018-11-19 16:15:16 +00:00
Cmd.INT.FOR
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.SSYN
2018-11-26 06:57:11 +00:00
*--------------------------------------
Cmd.INT.NEXT
2018-11-28 11:39:33 +00:00
.9 jmp Cmd.Exec.SSYN
2018-11-19 16:15:16 +00:00
*--------------------------------------
Cmd.INT.WHILE
2018-11-26 06:57:11 +00:00
Cmd.INT.IF jsr CMD.StkGet
bcs .1 no context...
2018-11-27 14:03:26 +00:00
and #$80 get current..
lsr becomes parent
2018-11-26 06:57:11 +00:00
bra .2
2018-11-27 14:03:26 +00:00
.1 lda #$40 ...set Parent = true
2018-11-26 10:40:19 +00:00
2018-11-26 06:57:11 +00:00
.2 >STA.G CMD.Test
2018-11-26 10:40:19 +00:00
2018-11-27 14:03:26 +00:00
bit #$40 Parent is true ?
2018-11-26 10:40:19 +00:00
beq .3
2018-11-27 14:03:26 +00:00
2018-11-26 06:57:11 +00:00
jsr Cmd.Eval
bcs .9
2018-11-26 10:40:19 +00:00
.3 >LDA.G CMD.IntCmd
2018-11-26 06:57:11 +00:00
cmp #C.WHILE
bne .8
jsr CMD.StkPushPtr
bcs .9
2018-11-26 10:40:19 +00:00
.8 >LDA.G CMD.Test
>ORA.G CMD.IntCmd
2018-11-26 06:57:11 +00:00
jmp CMD.StkPush
clc
.9 rts
*--------------------------------------
Cmd.INT.ELSE jsr CMD.StkGet
bcs .9
bit #$40 parent is true ?
2018-11-27 14:03:26 +00:00
beq .8 no, skip
2018-11-26 06:57:11 +00:00
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
*--------------------------------------
2018-11-26 10:40:19 +00:00
Cmd.Eval ldx #1
2018-11-09 15:59:04 +00:00
jsr Cmd.GetArgX
2018-09-17 06:16:45 +00:00
beq .9
2018-11-09 15:59:04 +00:00
>PUSHYA
2018-11-26 06:57:11 +00:00
>LDYA L.CMD.Eval.TOKEN1
2018-11-10 14:30:09 +00:00
jsr Lookup
2018-11-09 15:59:04 +00:00
bcs .9
2018-09-17 06:16:45 +00:00
2018-11-09 15:59:04 +00:00
cpx #4 [ or ![
bcs .9
dex
dex 1 or $ff
2018-11-10 17:43:20 +00:00
2018-11-09 15:59:04 +00:00
txa
2018-11-26 10:40:19 +00:00
2018-11-19 16:15:16 +00:00
and #$80 true or false
2018-11-26 10:40:19 +00:00
>ORA.G CMD.Test
sta (pData),y
2018-09-17 06:16:45 +00:00
2018-11-09 15:59:04 +00:00
ldx #2
jsr Cmd.GetArgX
2018-09-17 06:16:45 +00:00
beq .9
2018-11-09 15:59:04 +00:00
>PUSHYA
2018-11-26 06:57:11 +00:00
>LDYA L.CMD.Eval.TOKEN2 -d -e -f ?
2018-11-10 14:30:09 +00:00
jsr Lookup
2018-11-10 17:43:20 +00:00
2018-11-09 15:59:04 +00:00
bcs .1
2018-11-10 17:43:20 +00:00
txa
>STA.G CMD.Operator
2018-11-26 06:57:11 +00:00
jsr CMD.Eval.UNARY
bcs .9
2018-09-17 06:16:45 +00:00
2018-11-24 22:25:33 +00:00
>EOR.G CMD.Test
2018-11-10 17:43:20 +00:00
sta (pData),y
ldx #4 go check ]
bra .8
2018-11-28 11:39:33 +00:00
.9 lda #E.ESYN
sec
2018-11-19 16:15:16 +00:00
.99 rts
.1 ldx #3
jsr Cmd.GetArgX
beq .9
>PUSHYA
2018-11-26 06:57:11 +00:00
>LDYA L.CMD.Eval.TOKEN3 -eq -ne .... ?
jsr Lookup
bcs .9
txa
>STA.G CMD.Operator
2018-11-26 06:57:11 +00:00
jsr CMD.Eval.BINARY
bcs .9
2018-11-24 22:25:33 +00:00
>EOR.G CMD.Test
sta (pData),y
ldx #5 go check ]
.8 jsr Cmd.GetArgX
2018-11-10 17:43:20 +00:00
beq .9
>STYA ZPPTR1
lda (ZPPTR1)
cmp #']'
bne .9
2018-09-17 06:16:45 +00:00
2018-11-10 17:43:20 +00:00
ldy #1
lda (ZPPTR1),y
bne .9
2018-11-26 06:57:11 +00:00
clc
rts
*--------------------------------------
2018-11-26 06:57:11 +00:00
CMD.Eval.UNARY ldx #3
jsr Cmd.GetArgX
bcs .9 we need one arg
2018-10-15 06:25:40 +00:00
>LDA.G CMD.Operator
tax
2018-11-26 06:57:11 +00:00
jmp (J.CMD.Eval.TOKEN2,x)
2018-11-28 11:39:33 +00:00
.9 lda #E.ESYN
sec
rts
2018-11-26 06:57:11 +00:00
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
2018-11-26 06:57:11 +00:00
bne CMD.Eval.DEF.9
bra CMD.Eval.DEF.8
2018-11-26 06:57:11 +00:00
CMD.Eval.E jsr CMD.Eval.DEF.7
bcs CMD.Eval.DEF.9
bra CMD.Eval.DEF.8 DIR or FILE exist
2018-11-26 06:57:11 +00:00
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
2018-11-26 06:57:11 +00:00
beq CMD.Eval.DEF.9
bra CMD.Eval.DEF.8
2018-11-26 06:57:11 +00:00
CMD.Eval.DEF.7 >PUSHEA.G CMD.Stat
ldx #3
jsr Cmd.GetArgX
>SYSCALL STAT
rts
2018-11-26 06:57:11 +00:00
CMD.Eval.DEF.8 lda #$80 true
2018-11-10 17:43:20 +00:00
clc
rts
2018-11-26 06:57:11 +00:00
CMD.Eval.DEF.9 lda #0 false
clc
rts
*--------------------------------------
2018-11-26 06:57:11 +00:00
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 !=
2018-11-26 06:57:11 +00:00
bne CMD.Eval.BINARY.NUM
2018-11-19 16:15:16 +00:00
lda #$80
>STA.G CMD.Operator
.1 ldx #2
jsr Cmd.GetArgX
>PUSHYA
ldx #4
jsr Cmd.GetArgX
>SYSCALL strcmp
2018-11-28 11:39:33 +00:00
ror CS if !=
2018-11-24 22:25:33 +00:00
and #$80
2018-11-28 11:39:33 +00:00
eor #$80
>EOR.G CMD.Operator
clc
rts
2018-11-28 11:39:33 +00:00
.9 lda #E.ESYN
sec
rts
2018-11-24 22:25:33 +00:00
*--------------------------------------
2018-11-26 06:57:11 +00:00
CMD.Eval.BINARY.NUM
ldx #2
jsr Cmd.GetArgX
bcs .9
>SYSCALL AToL
bcs .9
2018-11-21 07:09:22 +00:00
>PULLL.G M32.ACC
ldx #4
jsr Cmd.GetArgX
bcs .9
>SYSCALL AToL
bcs .9
2018-11-21 07:09:22 +00:00
>PULLL.G M32.ARG
2018-11-24 22:25:33 +00:00
jsr M32.Cmp
pha
>LDA.G CMD.Operator
lsr
tax
pla
2018-11-28 21:37:18 +00:00
and CMD.Eval.TOKEN3.BITS,x
beq .80
2018-11-24 22:25:33 +00:00
lda #$80 true
clc
rts
2018-11-24 22:25:33 +00:00
.80 lda #0 false
clc
rts
2018-11-28 11:39:33 +00:00
.9 lda #E.ESYN
sec
rts
2018-11-10 17:43:20 +00:00
*--------------------------------------
2018-11-22 07:29:55 +00:00
Cmd.GetEXP >LDA.G CMD.ArgIndex
inc
tax
jsr Cmd.GetArgX
bcc .1
>LDA.G CMD.ArgIndex no op, return text value
2018-11-23 21:36:31 +00:00
tax
2018-11-22 07:29:55 +00:00
jsr Cmd.GetArgX
rts
2018-11-24 18:20:48 +00:00
.1 >LDA.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
>SYSCALL AToL
bcs .99
>PULLL.G M32.ACC
jsr Cmd.GetEXP.GetNext
.2 >PUSHYA
2018-11-26 06:57:11 +00:00
>LDYA L.CMD.Eval.TOKEN4 + - .... ?
2018-11-22 07:29:55 +00:00
jsr Lookup
2018-11-23 22:40:33 +00:00
2018-11-24 18:20:48 +00:00
bcs .9
2018-11-22 07:29:55 +00:00
txa
>STA.G CMD.Operator
2018-11-24 18:20:48 +00:00
jsr M32.ACC2ARG
jsr Cmd.GetEXP.GetNext get next argument in ACC
.99 bcs .9
2018-11-22 07:29:55 +00:00
>SYSCALL AToL
bcs .9
>PULLL.G M32.ACC
2018-11-24 18:20:48 +00:00
jsr Cmd.GetEXP.Op
2018-11-22 07:29:55 +00:00
bcs .9
2018-11-24 18:20:48 +00:00
jsr Cmd.GetEXP.GetNext another op ?
bcc .2
.8 >PUSHL.G M32.ACC
2018-11-22 16:39:41 +00:00
>PUSHBI 4
2018-11-23 22:40:33 +00:00
>PUSHW L.M32.Printf
>LEA.G M32.BUF
2018-11-22 16:39:41 +00:00
>SYSCALL sprintf
bcs .9
2018-11-23 21:36:31 +00:00
>LEA.G M32.Buf
2018-11-22 16:39:41 +00:00
rts
2018-11-22 07:29:55 +00:00
.9 lda #E.BADEXP
rts
2018-11-24 18:20:48 +00:00
Cmd.GetEXP.Op >LDA.G CMD.Operator
2018-11-22 07:29:55 +00:00
tax
2018-11-26 06:57:11 +00:00
jmp (J.CMD.Eval.TOKEN4,x)
2018-11-22 07:29:55 +00:00
*--------------------------------------
2018-11-24 18:20:48 +00:00
Cmd.GetEXP.GetNext
>INC.G CMD.ArgIndex
tax
jsr Cmd.GetArgX
rts
*--------------------------------------
2018-10-21 20:54:07 +00:00
Cmd.GetArgX >LDYA ZPArgVBuf
2018-10-16 15:48:03 +00:00
2018-10-21 20:54:07 +00:00
dex
2018-10-16 15:48:03 +00:00
bmi .8
>STYA ZPPtr1
.1 lda (ZPPtr1)
2018-10-16 15:48:03 +00:00
beq .9
2018-10-19 06:13:04 +00:00
.2 inc ZPPtr1
bne .3
2018-10-19 06:13:04 +00:00
inc ZPPtr1+1
.3 lda (ZPPtr1)
bne .2
2018-10-16 15:48:03 +00:00
2018-10-19 06:13:04 +00:00
inc ZPPtr1
bne .4
2018-10-19 06:13:04 +00:00
inc ZPPtr1+1
2018-10-16 15:48:03 +00:00
.4 lda (ZPPtr1)
2018-10-16 15:48:03 +00:00
beq .9
2018-10-21 20:54:07 +00:00
dex
bpl .1
>LDYA ZPPtr1
2018-10-21 20:54:07 +00:00
.8 clc
2018-10-16 15:48:03 +00:00
rts
2018-10-16 15:48:03 +00:00
.9 sec
rts
*--------------------------------------
CMD.IsSwitch >STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .9
ldy #1
lda (ZPPtr1),y
2018-09-17 06:16:45 +00:00
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
2018-09-17 06:16:45 +00:00
*--------------------------------------
2018-11-19 16:15:16 +00:00
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
2018-11-28 11:39:33 +00:00
.9 lda #E.SSYN
2018-11-19 16:15:16 +00:00
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
2018-11-28 11:39:33 +00:00
.9 lda #E.SSYN
2018-11-19 16:15:16 +00:00
sec
rts
*--------------------------------------
2015-10-19 20:35:00 +00:00
MAN
2018-11-22 16:39:41 +00:00
SAVE USR/SRC/BIN/SHELL.S.CMD
LOAD USR/SRC/BIN/SHELL.S
2015-10-19 20:35:00 +00:00
ASM