2015-10-19 20:35:00 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2015-10-19 20:35:00 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
*--------------------------------------
|
2017-09-07 15:32:27 +00:00
|
|
|
|
CMD.Init >LDYAI CmdLine.MAX+1
|
|
|
|
|
>SYSCALL GetMem.YA
|
|
|
|
|
bcs .9
|
|
|
|
|
txa
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>STA.G hCmdBuf
|
2017-09-07 15:32:27 +00:00
|
|
|
|
.9 rts
|
2017-07-17 05:59:30 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-07 15:32:27 +00:00
|
|
|
|
* ZPCMDBuf : Remove extra SPACE & comment
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Cmd.Parse >LDYA ZPCMDBuf
|
2017-07-17 05:59:30 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
lda (ZPCMDBuf) empty line...quit
|
2017-07-17 05:59:30 +00:00
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
.1 jsr Cmd.Parse.NextC
|
2017-07-17 05:59:30 +00:00
|
|
|
|
beq .8 no more char, exit
|
|
|
|
|
|
|
|
|
|
cmp #' ' skip leading spaces
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
cmp #'#' Comment ?
|
|
|
|
|
beq .8 ignore remaining chars
|
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
.3 sta (ZPCMDBuf),y add char to buffer
|
2017-09-05 15:17:10 +00:00
|
|
|
|
iny
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
jsr Cmd.Parse.NextC
|
2017-07-17 05:59:30 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
cmp #' '
|
|
|
|
|
bne .3
|
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
sta (ZPCMDBuf),y add One SPACE to buffer
|
2017-09-05 15:17:10 +00:00
|
|
|
|
iny
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
.5 jsr Cmd.Parse.NextC
|
2017-07-17 05:59:30 +00:00
|
|
|
|
beq .8
|
2017-09-05 15:17:10 +00:00
|
|
|
|
|
2017-07-17 05:59:30 +00:00
|
|
|
|
cmp #' '
|
|
|
|
|
beq .5 skip additional spaces
|
|
|
|
|
bne .3 no more space, add next word...
|
|
|
|
|
|
2017-09-05 15:17:10 +00:00
|
|
|
|
.8 lda #0
|
2017-09-07 15:32:27 +00:00
|
|
|
|
sta (ZPCMDBuf),y
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
Cmd.Parse.NextC lda (ZPPtr1)
|
2017-07-17 05:59:30 +00:00
|
|
|
|
beq .8
|
2017-09-05 15:17:10 +00:00
|
|
|
|
|
2017-07-17 05:59:30 +00:00
|
|
|
|
inc ZPPtr1
|
2017-09-05 15:17:10 +00:00
|
|
|
|
bne .8
|
|
|
|
|
inc ZPPtr1+1 never Z
|
2017-07-17 05:59:30 +00:00
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2017-09-07 15:32:27 +00:00
|
|
|
|
* ZPCMDBuf-> Command line (formatted & not empty)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-14 15:21:06 +00:00
|
|
|
|
Cmd.Exec lda #0
|
|
|
|
|
>STA.G CMD.bStartProc
|
|
|
|
|
>STA.G CMD.hFullpath
|
|
|
|
|
>STA.G CMD.hExtCmdLine
|
2017-09-07 15:32:27 +00:00
|
|
|
|
>LDYA ZPCMDBuf
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-09-11 06:11:57 +00:00
|
|
|
|
>SYSCALL ExpandStr.YA
|
2017-09-12 15:24:36 +00:00
|
|
|
|
>STYA ZPPtr1 Ptr to CMD ARGS
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
txa
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>STA.G CMD.hCmdLine
|
2017-09-11 15:29:08 +00:00
|
|
|
|
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jsr Cmd.Exec.Split
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-07-11 15:53:52 +00:00
|
|
|
|
>LDYA L.INTCMDS
|
2017-09-13 15:34:26 +00:00
|
|
|
|
>STYA ZPCMDBuf we use ZPCMDBuf as a temp Ptr
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.3 lda (ZPCMDBuf)
|
2017-09-07 15:32:27 +00:00
|
|
|
|
beq Cmd.Exec.EXT Array Ending 0, must be an external Cmd....
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
ldy #$ff
|
2017-09-07 15:32:27 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.4 iny
|
|
|
|
|
lda (ZPCMDBuf),y
|
|
|
|
|
bne .41 End of string in array
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1),y Get CMD char...
|
|
|
|
|
beq .8 both end with 0, found!
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.41 lda (ZPPtr1),y Get CMD char...
|
|
|
|
|
beq .61 end of CMD.....too short...
|
2017-09-07 15:32:27 +00:00
|
|
|
|
|
2017-06-26 15:28:18 +00:00
|
|
|
|
cmp #'a' To Uppercase
|
2017-09-13 15:34:26 +00:00
|
|
|
|
bcc .5
|
2017-06-26 15:28:18 +00:00
|
|
|
|
cmp #'z'+1
|
2017-09-13 15:34:26 +00:00
|
|
|
|
bcs .5
|
2017-06-26 15:28:18 +00:00
|
|
|
|
eor #$20
|
2017-09-07 15:32:27 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.5 cmp (ZPCMDBuf),y
|
|
|
|
|
beq .4
|
2017-09-08 14:49:23 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.61 iny
|
|
|
|
|
lda (ZPCMDBuf),y
|
|
|
|
|
bne .61
|
2017-09-08 14:49:23 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.7 inx
|
|
|
|
|
inx
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
tya
|
|
|
|
|
sec
|
|
|
|
|
adc ZPCMDBuf
|
|
|
|
|
sta ZPCMDBuf
|
|
|
|
|
bcc .3
|
|
|
|
|
inc ZPCMDBuf+1
|
|
|
|
|
bra .3
|
|
|
|
|
|
2017-09-14 15:21:06 +00:00
|
|
|
|
.8 jmp (J.INTCMDS,x) Found an internal Cmd...
|
|
|
|
|
*--------------------------------------
|
2017-09-07 15:32:27 +00:00
|
|
|
|
Cmd.Exec.Done php
|
|
|
|
|
pha
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>LDA.G CMD.hCmdLine
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-09-14 15:21:06 +00:00
|
|
|
|
|
|
|
|
|
>LDA.G CMD.hExtCmdLine
|
|
|
|
|
beq .1
|
|
|
|
|
>SYSCALL FreeMem.A
|
|
|
|
|
|
|
|
|
|
.1 >LDA.G CMD.hFullpath
|
|
|
|
|
beq .2
|
|
|
|
|
>SYSCALL FreeMem.A
|
|
|
|
|
|
|
|
|
|
.2 pla
|
2017-08-23 11:33:51 +00:00
|
|
|
|
plp
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-09-14 15:21:06 +00:00
|
|
|
|
Cmd.Exec.Split ldy #$ff CMD Len
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr1),y Get CMD char...
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
cmp #' ' we reached blank between CMD ARGS
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtr1),y Cut CMD with the ending 0
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
.2 tya Y=CMD len+0, if ARGS="" Y=
|
|
|
|
|
clc
|
|
|
|
|
adc ZPPtr1
|
|
|
|
|
sta ZPPtr2
|
|
|
|
|
lda ZPPtr1+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPPtr2+1 ZPPtr2->ARGS or CMD ending 0 if empty
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-09-13 15:34:26 +00:00
|
|
|
|
* ZPPtr1->CMD
|
|
|
|
|
* ZPPtr2->ARGS
|
2015-11-22 22:30:06 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-13 15:34:26 +00:00
|
|
|
|
Cmd.Exec.EXT >LDYAI 256
|
|
|
|
|
>SYSCALL GetMem.YA
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPCMDBuf
|
|
|
|
|
|
|
|
|
|
txa
|
|
|
|
|
>STA.G CMD.hExtCmdLine
|
|
|
|
|
|
2017-09-14 15:21:06 +00:00
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPCMDBuf)
|
|
|
|
|
|
2017-09-07 15:32:27 +00:00
|
|
|
|
lda (ZPPtr1)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
cmp #'/' Command line is already full path, no search
|
2017-09-12 15:24:36 +00:00
|
|
|
|
bne .1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-09-12 15:24:36 +00:00
|
|
|
|
>PUSHW L.STAT
|
|
|
|
|
>PUSHW ZPPtr1
|
|
|
|
|
>SYSCALL STAT
|
2017-09-13 15:34:26 +00:00
|
|
|
|
bcs Cmd.Exec.Done
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
bra .4
|
2017-09-12 15:24:36 +00:00
|
|
|
|
|
|
|
|
|
.1 >LDYA L.ENV.PATH push ENVNAME=PATH for search
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL GetEnv.YA get value for ENV=PATH
|
2017-09-12 15:24:36 +00:00
|
|
|
|
bcs .2 No PATH, try in CD
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
jsr Cmd.Exec.EXT.Search
|
2017-09-12 15:24:36 +00:00
|
|
|
|
bcc .3
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-12 15:24:36 +00:00
|
|
|
|
.2 ldy #S.PS.hPREFIX not found, try in CD
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pPs),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-09-13 15:34:26 +00:00
|
|
|
|
jsr Cmd.Exec.EXT.Search
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .99
|
2017-09-12 15:24:36 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
.3 >LDYA ZPCMDBuf
|
|
|
|
|
.4 >SYSCALL NewStr.YA
|
|
|
|
|
bcs .99
|
|
|
|
|
txa
|
|
|
|
|
>STA.G CMD.hFullpath
|
|
|
|
|
|
|
|
|
|
lda STAT+S.STAT.P.TYPE
|
2015-10-19 20:35:00 +00:00
|
|
|
|
cmp #$04 TXT File ?
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq Cmd.Exec.EXT.TXT
|
|
|
|
|
cmp #$06 BIN File ?
|
|
|
|
|
beq Cmd.Exec.EXT.BIN
|
|
|
|
|
cmp #$ff SYS File ?
|
|
|
|
|
bne .9
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bra *
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
.9 lda #SYSMGR.ERRSYN
|
|
|
|
|
sec
|
2017-09-07 15:32:27 +00:00
|
|
|
|
.99 jmp Cmd.Exec.Done
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* TXT : Launch "/PATH/SHELL /PATH/CMD ARGS"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Cmd.Exec.EXT.TXT
|
|
|
|
|
lda #0 Get arg[0] = /PATH/SHELL
|
2017-08-24 12:46:48 +00:00
|
|
|
|
>SYSCALL GetArg.A
|
2017-09-13 15:34:26 +00:00
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW ZPCMDBuf
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL StrCpy
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-13 15:34:26 +00:00
|
|
|
|
jsr Cmd.Exec.EXT.SEP Add a space....
|
|
|
|
|
|
|
|
|
|
>LDA.G CMD.hFullpath
|
|
|
|
|
>SYSCALL GetMemPtr.A
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>PUSHW ZPCMDBuf
|
|
|
|
|
>SYSCALL StrCat
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
* BIN : Launch "/PATH/CMD ARGS"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Cmd.Exec.EXT.BIN
|
2017-09-13 15:34:26 +00:00
|
|
|
|
jsr Cmd.Exec.EXT.SEP Add a space....
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>PUSHW ZPPTR2
|
2017-09-13 15:34:26 +00:00
|
|
|
|
>PUSHW ZPCMDBuf
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL StrCat
|
2017-09-13 15:34:26 +00:00
|
|
|
|
|
2017-09-14 15:21:06 +00:00
|
|
|
|
.1 >LDA.G CMD.bStartProc
|
|
|
|
|
asl
|
|
|
|
|
>LDYA ZPCMDBuf
|
|
|
|
|
bcs .2 startproc
|
2016-03-13 21:53:55 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL ExecProcessNewEnvYA
|
2017-09-07 15:32:27 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.2 >SYSCALL CreateProcessYA
|
2017-09-07 15:32:27 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-13 15:34:26 +00:00
|
|
|
|
Cmd.Exec.EXT.Search
|
|
|
|
|
>PUSHYA push search list
|
|
|
|
|
>PUSHW ZPPtr1 push CMD
|
|
|
|
|
>PUSHW ZPCMDBuf push dest full path
|
|
|
|
|
>PUSHW L.STAT
|
|
|
|
|
>SYSCALL FileSearch
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
Cmd.Exec.EXT.SEP
|
|
|
|
|
ldy #$ff
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPCMDBuf),y
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda #' '
|
|
|
|
|
sta (ZPCMDBuf),y
|
|
|
|
|
iny
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPCMDBuf),y
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
* Internal Commands
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-08 14:49:23 +00:00
|
|
|
|
Cmd.Exec.CD lda (ZPPTR2)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bne Cmd.Exec.CD1
|
2016-10-25 06:58:15 +00:00
|
|
|
|
|
|
|
|
|
Cmd.Exec.PWD ldy #S.PS.hPREFIX
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pPs),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
Cmd.Exec.CD1 stz UsrBuf256
|
2017-09-08 14:49:23 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
cmp #'/' Full Path?
|
2016-10-24 15:54:43 +00:00
|
|
|
|
beq .1
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
ldy #S.PS.hPREFIX no, init target prefix with actual prefix
|
2015-10-19 20:35:00 +00:00
|
|
|
|
lda (pPs),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2016-08-17 06:25:58 +00:00
|
|
|
|
>PUSHYA
|
2016-09-26 06:18:51 +00:00
|
|
|
|
>PUSHWI UsrBuf256
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL StrCpy
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.1 >PUSHW ZPPTR2 Append ARG to buffer
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>PUSHWI UsrBuf256
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL StrCat
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
lda #'/'
|
|
|
|
|
ldx UsrBuf256
|
|
|
|
|
cmp UsrBuf256,x Ending '/' ?
|
|
|
|
|
beq .2
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
sta UsrBuf256+1,x no, add one...
|
|
|
|
|
inc UsrBuf256
|
|
|
|
|
|
|
|
|
|
.2 ldx #0 path is something like : /dir1/../dir2/
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.3 ldy #0 reset char counter
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.4 cpx UsrBuf256
|
|
|
|
|
beq .8
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
inx
|
|
|
|
|
lda UsrBuf256,x
|
2015-10-19 20:35:00 +00:00
|
|
|
|
cmp #'/'
|
2016-10-24 15:54:43 +00:00
|
|
|
|
beq .5
|
|
|
|
|
iny char=char+1!!!
|
|
|
|
|
bra .4
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.5 tya any char count?
|
|
|
|
|
beq .4 no, start counting...
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
cpy #2 do we have /xx/?
|
|
|
|
|
bne .3 no, skip this token
|
|
|
|
|
|
|
|
|
|
lda #'.'
|
|
|
|
|
cmp UsrBuf256-1,x /yy/x./ ?
|
|
|
|
|
bne .3
|
|
|
|
|
cmp UsrBuf256-2,x /yy/../ ?
|
|
|
|
|
bne .3
|
|
|
|
|
cpx #4 /../ ?
|
|
|
|
|
beq Cmd.Exec.ERRSYN illegal
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
txa
|
|
|
|
|
tay save end of /../
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sec
|
2016-10-24 15:54:43 +00:00
|
|
|
|
sbc #3 remove ../
|
|
|
|
|
tax
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.6 dex
|
|
|
|
|
lda UsrBuf256,x Found beginning of dir before /../
|
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .6
|
|
|
|
|
|
|
|
|
|
.7 lda UsrBuf256,y strip dir/../
|
|
|
|
|
sta UsrBuf256,x
|
|
|
|
|
cpy UsrBuf256
|
|
|
|
|
beq .71
|
|
|
|
|
iny
|
|
|
|
|
inx
|
|
|
|
|
bra .7
|
|
|
|
|
|
|
|
|
|
.71 stx UsrBuf256
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
bra .2 Start over...
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.8 cpx #1
|
|
|
|
|
beq .80 we have '/' go change prefix
|
2016-09-26 16:02:14 +00:00
|
|
|
|
|
|
|
|
|
>PUSHW L.STAT
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>PUSHWI UsrBuf256
|
|
|
|
|
>SYSCALL STAT
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2016-12-09 16:36:24 +00:00
|
|
|
|
lda STAT+S.STAT.P.TYPE
|
2016-10-24 15:54:43 +00:00
|
|
|
|
cmp #$0F Directory ?
|
|
|
|
|
bne Cmd.Exec.ERRSYN
|
2016-09-26 16:02:14 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
.80 >LDYAI UsrBuf256
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL NewStr.YA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
2016-03-13 21:53:55 +00:00
|
|
|
|
phx
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
ldy #S.PS.hPREFIX
|
|
|
|
|
lda (pPs),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
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
|
2016-10-29 19:58:21 +00:00
|
|
|
|
jsr SetPWD
|
2016-08-17 06:25:58 +00:00
|
|
|
|
clc
|
2017-09-14 15:21:06 +00:00
|
|
|
|
.9 jmp Cmd.Exec.Done
|
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-24 15:54:43 +00:00
|
|
|
|
Cmd.Exec.ERRSYN lda #SYSMGR.ERRSYN
|
|
|
|
|
sec
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2016-10-24 15:54:43 +00:00
|
|
|
|
*--------------------------------------
|
2016-08-17 06:25:58 +00:00
|
|
|
|
Cmd.Exec.STARTPROC
|
2017-09-08 14:49:23 +00:00
|
|
|
|
lda (ZPPTR2)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq Cmd.Exec.ERRSYN
|
2017-09-14 15:21:06 +00:00
|
|
|
|
lda #$ff
|
|
|
|
|
>STA.G CMD.bStartProc
|
2016-03-13 21:53:55 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>LDYA ZPPTR2
|
2017-09-11 06:11:57 +00:00
|
|
|
|
>STYA ZPPTR1
|
2017-09-14 15:21:06 +00:00
|
|
|
|
|
|
|
|
|
jsr Cmd.Exec.Split
|
|
|
|
|
jmp Cmd.Exec.EXT
|
2016-03-13 21:53:55 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-08 14:49:23 +00:00
|
|
|
|
Cmd.Exec.SET lda (ZPPTR2)
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bne Cmd.Exec.SETVAR
|
2017-09-13 06:17:46 +00:00
|
|
|
|
|
2017-09-11 06:11:57 +00:00
|
|
|
|
* No arg, print all ENV
|
2017-09-13 06:17:46 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ldy #S.PS.hENV
|
|
|
|
|
lda (pPs),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL GetMemPtr.A
|
2015-10-19 20:35:00 +00:00
|
|
|
|
>STYA ZPPTR1
|
2017-09-11 06:11:57 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.1 lda (ZPPTR1)
|
|
|
|
|
beq .8 Ending 0 ?
|
2016-10-17 15:47:50 +00:00
|
|
|
|
|
2017-09-11 06:11:57 +00:00
|
|
|
|
ldy #$ff
|
2017-09-13 06:17:46 +00:00
|
|
|
|
|
2017-09-11 06:11:57 +00:00
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPTR1),y
|
|
|
|
|
bne .2
|
2017-09-13 06:17:46 +00:00
|
|
|
|
|
2017-09-11 06:11:57 +00:00
|
|
|
|
tya
|
2016-08-17 06:25:58 +00:00
|
|
|
|
sec
|
2017-09-11 06:11:57 +00:00
|
|
|
|
adc ZPPTR1
|
2016-10-17 15:47:50 +00:00
|
|
|
|
sta ZPPTR2
|
2017-09-11 06:11:57 +00:00
|
|
|
|
lda #0
|
|
|
|
|
adc ZPPTR1+1
|
2016-10-17 15:47:50 +00:00
|
|
|
|
sta ZPPTR2+1
|
|
|
|
|
|
|
|
|
|
>PUSHW ZPPTR2 Push value
|
|
|
|
|
>PUSHW ZPPTR1 Push name
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-17 15:47:50 +00:00
|
|
|
|
>LDYA L.MSG.PRINTENV
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .9
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-11 06:11:57 +00:00
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.3 iny
|
|
|
|
|
lda (ZPPTR2),y
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
tya
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sec
|
2017-09-11 06:11:57 +00:00
|
|
|
|
adc ZPPTR2
|
2015-10-19 20:35:00 +00:00
|
|
|
|
sta ZPPTR1
|
2017-09-11 06:11:57 +00:00
|
|
|
|
lda #0
|
|
|
|
|
adc ZPPTR2+1
|
2016-10-17 15:47:50 +00:00
|
|
|
|
sta ZPPTR1+1
|
2015-10-19 20:35:00 +00:00
|
|
|
|
bra .1
|
2016-10-17 15:47:50 +00:00
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
.8 clc
|
2017-09-14 15:21:06 +00:00
|
|
|
|
.9 jmp Cmd.Exec.Done
|
|
|
|
|
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
Cmd.Exec.SETVAR ldy #0
|
|
|
|
|
|
|
|
|
|
lda (ZPPTR2),y
|
|
|
|
|
iny
|
|
|
|
|
cmp #'=' string is '=value' ?
|
|
|
|
|
beq .99 syntax error
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.1 lda (ZPPTR2),y
|
|
|
|
|
iny
|
2016-08-17 06:25:58 +00:00
|
|
|
|
beq .3 no =, GetEnv
|
2015-11-22 22:30:06 +00:00
|
|
|
|
|
2016-08-17 06:25:58 +00:00
|
|
|
|
cmp #'=' ARGS contains =, PutEnv
|
|
|
|
|
bne .1
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
lda (ZPPTR2),y
|
|
|
|
|
beq .2 "VAR=" go UnsetEnv
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>LDYA ZPPTR2 String is VAR=VALUE...
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL PutEnv.YA
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.2 dey String is "VAR=", Remove endig '='
|
|
|
|
|
sta (ZPPTR2),y
|
|
|
|
|
>LDYA ZPPTR2 String is "VAR"...
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL UnsetEnv.YA
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2016-10-17 15:47:50 +00:00
|
|
|
|
|
2016-10-24 15:54:43 +00:00
|
|
|
|
* Print requested VAR
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.3 >LDYA ZPPTR2
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL GetEnv.YA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
bcs .8
|
|
|
|
|
|
2016-10-17 15:47:50 +00:00
|
|
|
|
>PUSHYA push value
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>PUSHW ZPPTR2 push name
|
2016-10-17 15:47:50 +00:00
|
|
|
|
>LDYA L.MSG.PRINTENV
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2016-08-17 06:25:58 +00:00
|
|
|
|
|
2016-10-17 15:47:50 +00:00
|
|
|
|
.8 clc
|
2017-09-14 15:21:06 +00:00
|
|
|
|
.9 jmp Cmd.Exec.Done
|
2016-10-24 15:54:43 +00:00
|
|
|
|
|
2017-01-26 16:28:52 +00:00
|
|
|
|
.99 jmp Cmd.Exec.ERRSYN
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2016-10-17 15:47:50 +00:00
|
|
|
|
Cmd.Exec.DATE sec
|
|
|
|
|
.HS 90 bcc
|
|
|
|
|
|
|
|
|
|
Cmd.Exec.TIME clc
|
|
|
|
|
php
|
|
|
|
|
>LDYA L.TIME
|
2016-10-24 15:54:43 +00:00
|
|
|
|
>SYSCALL TimeYA
|
2016-09-05 16:00:11 +00:00
|
|
|
|
|
2016-09-26 06:18:51 +00:00
|
|
|
|
>PUSHWI UsrBuf256
|
2016-10-17 15:47:50 +00:00
|
|
|
|
plp
|
|
|
|
|
bcc .1
|
2016-09-05 16:00:11 +00:00
|
|
|
|
>PUSHW L.FMT.DATE
|
2016-10-17 15:47:50 +00:00
|
|
|
|
bra .2
|
|
|
|
|
.1 >PUSHW L.FMT.TIME
|
2016-09-05 16:00:11 +00:00
|
|
|
|
|
2016-10-17 15:47:50 +00:00
|
|
|
|
.2 >PUSHW L.TIME
|
2017-08-22 06:37:03 +00:00
|
|
|
|
>SYSCALL StrFTime
|
2016-09-05 16:00:11 +00:00
|
|
|
|
|
2016-11-03 16:26:02 +00:00
|
|
|
|
>LDYAI UsrBuf256
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-09-14 15:21:06 +00:00
|
|
|
|
bcs Cmd.Exec.ECHO.END
|
2017-07-11 15:53:52 +00:00
|
|
|
|
bra Cmd.Exec.ECHO.CR
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-08 14:49:23 +00:00
|
|
|
|
Cmd.Exec.ECHO lda (ZPPtr2)
|
2017-07-11 15:53:52 +00:00
|
|
|
|
beq Cmd.Exec.ECHO.CR
|
2016-11-03 16:26:02 +00:00
|
|
|
|
|
2017-09-11 15:29:08 +00:00
|
|
|
|
>LDYA ZPPtr2
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2015-10-19 20:35:00 +00:00
|
|
|
|
|
2017-07-11 15:53:52 +00:00
|
|
|
|
Cmd.Exec.ECHO.CR
|
|
|
|
|
lda #13
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL PutChar.A
|
2017-09-14 15:21:06 +00:00
|
|
|
|
bcs Cmd.Exec.ECHO.END
|
2017-07-11 15:53:52 +00:00
|
|
|
|
|
2017-03-01 10:31:19 +00:00
|
|
|
|
lda #10
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL PutChar.A
|
2016-11-27 21:59:46 +00:00
|
|
|
|
|
2017-09-14 15:21:06 +00:00
|
|
|
|
Cmd.Exec.ECHO.END
|
|
|
|
|
jmp Cmd.Exec.Done
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-08 14:49:23 +00:00
|
|
|
|
Cmd.Exec.READ lda (ZPPtr2)
|
2017-01-26 16:28:52 +00:00
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
lda #0
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>STA.G bSecureRead
|
2017-01-26 16:28:52 +00:00
|
|
|
|
|
|
|
|
|
lda pData
|
2015-11-22 22:30:06 +00:00
|
|
|
|
clc
|
2017-09-07 15:32:27 +00:00
|
|
|
|
adc #CMD.VarName
|
2017-01-26 16:28:52 +00:00
|
|
|
|
sta ZPPTR1
|
|
|
|
|
lda pData+1
|
|
|
|
|
adc #0
|
|
|
|
|
sta ZPPTR1+1
|
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
ldy #0
|
2017-01-26 16:28:52 +00:00
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.1 lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
beq .8
|
2017-09-08 14:49:23 +00:00
|
|
|
|
iny
|
2017-01-26 16:28:52 +00:00
|
|
|
|
cmp #' '
|
|
|
|
|
beq .1
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .7
|
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
beq .9
|
2017-09-08 14:49:23 +00:00
|
|
|
|
iny
|
2017-01-26 16:28:52 +00:00
|
|
|
|
cmp #'S'
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
lda #$80
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>STA.G bSecureRead
|
2017-01-26 16:28:52 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.2 cmp #'P'
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
beq .9
|
2017-09-08 14:49:23 +00:00
|
|
|
|
iny
|
2017-01-26 16:28:52 +00:00
|
|
|
|
cmp #' '
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
beq .9
|
2017-09-08 14:49:23 +00:00
|
|
|
|
iny
|
2017-01-26 16:28:52 +00:00
|
|
|
|
cmp #'"'
|
|
|
|
|
bne .9
|
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.3 lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
beq .9
|
2017-09-08 14:49:23 +00:00
|
|
|
|
iny
|
2017-01-26 16:28:52 +00:00
|
|
|
|
cmp #'"'
|
|
|
|
|
beq .1
|
2017-09-08 14:49:23 +00:00
|
|
|
|
|
|
|
|
|
phy
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL PutChar.A
|
2017-09-08 14:49:23 +00:00
|
|
|
|
ply
|
2017-01-26 16:28:52 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
bra .3
|
|
|
|
|
|
|
|
|
|
.9 jmp Cmd.Exec.ERRSYN
|
|
|
|
|
|
2017-09-08 14:49:23 +00:00
|
|
|
|
.70 lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
cmp #' '
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
.7 lda (ZPPTR1)
|
|
|
|
|
cmp #VarLen.MAX
|
|
|
|
|
beq .9
|
|
|
|
|
inc
|
|
|
|
|
sta (ZPPTR1)
|
|
|
|
|
tay
|
2017-09-08 14:49:23 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-01-26 16:28:52 +00:00
|
|
|
|
sta (ZPPTR1),y
|
2017-09-08 14:49:23 +00:00
|
|
|
|
|
2017-01-26 16:28:52 +00:00
|
|
|
|
bne .70
|
|
|
|
|
|
|
|
|
|
.8 lda (ZPPTR1) No var name ? SYNERR
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
clc
|
2017-09-14 15:21:06 +00:00
|
|
|
|
.99 jmp Cmd.Exec.Done
|
2015-11-22 22:30:06 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-08 14:49:23 +00:00
|
|
|
|
Cmd.Exec.SLEEP lda (ZPPtr2)
|
2017-07-17 05:59:30 +00:00
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
lda #Sleep
|
|
|
|
|
clc
|
|
|
|
|
adc pData
|
|
|
|
|
tay
|
|
|
|
|
lda /Sleep
|
|
|
|
|
adc pData+1
|
|
|
|
|
>PUSHYA
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>PUSHW ZPPtr2
|
2017-08-31 06:23:29 +00:00
|
|
|
|
>SYSCALL AToI.YA
|
2017-07-17 05:59:30 +00:00
|
|
|
|
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2017-07-17 05:59:30 +00:00
|
|
|
|
.9 jmp Cmd.Exec.ERRSYN
|
|
|
|
|
*--------------------------------------
|
2017-09-07 15:32:27 +00:00
|
|
|
|
Cmd.Exec.PAUSE lda #$FF
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>STA.G bPause
|
2015-11-22 22:30:06 +00:00
|
|
|
|
clc
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2015-11-22 22:30:06 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-07 15:32:27 +00:00
|
|
|
|
Cmd.Exec.EXIT lda #$FF
|
2017-09-08 14:49:23 +00:00
|
|
|
|
>STA.G bExit
|
2015-10-19 20:35:00 +00:00
|
|
|
|
clc
|
2017-09-14 15:21:06 +00:00
|
|
|
|
jmp Cmd.Exec.Done
|
2015-10-19 20:35:00 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/SBIN/SHELL.S.CMD
|
|
|
|
|
LOAD /A2OSX.SRC/SBIN/SHELL.S
|
2015-10-19 20:35:00 +00:00
|
|
|
|
ASM
|