A2osX/SBIN/SHELL.S.CMD.txt

468 lines
8.6 KiB
Plaintext
Raw Normal View History

2015-10-19 20:35:00 +00:00
PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
2016-08-17 06:25:58 +00:00
* Y,A -> Command line (formatted & not empty)
*--------------------------------------
Cmd.ExecYA stz Cmd.Exec.Mode
Cmd.ExecYA.1 >SYSCALL SYS.ExpandPStrYA
2015-10-19 20:35:00 +00:00
bcs .99
2016-08-17 06:25:58 +00:00
stx hCmdLine
2015-10-19 20:35:00 +00:00
>STYA ZPPtr1
2016-08-17 06:25:58 +00:00
ldy #1
ldx #0 ARGS len
2015-10-19 20:35:00 +00:00
lda (ZPPtr1),y
2016-08-17 06:25:58 +00:00
.10 cmp #'a'
bcc .11
cmp #'z'+1
2016-08-17 06:25:58 +00:00
bcs .11
eor #$20 to Uppercase
.11 sta CMD,y Store Cmd in Buffer
sty CMD update CMD len
2015-10-19 20:35:00 +00:00
tya
cmp (ZPPtr1)
2016-08-17 06:25:58 +00:00
beq .13 end of string
iny
lda (ZPPtr1),y
cmp #' '
bne .10
.12 tya
cmp (ZPPtr1)
beq .13 end of string
iny
lda (ZPPtr1),y
inx
sta ARGS,x
bra .12
.13 stx ARGS update ARGS len
lda hCmdLine Discard Expanded Cmd Line
>SYSCALL SYS.FreeMemA
>LDYA L.CMDS
>STYA ZPPtr2
ldx #0
.1 lda (ZPPtr2)
beq Cmd.Exec.EXT Ending 0, must be an external Cmd....
cmp CMD
bne .4
tay
.2 lda CMD,y
.3 cmp (ZPPtr2),y
bne .4
dey
2015-10-19 20:35:00 +00:00
bne .2
2016-08-17 06:25:58 +00:00
jmp (J.INTCMDS,x) Found an internal Cmd...
.4 inx
inx
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
lda ZPPtr2
2015-10-19 20:35:00 +00:00
sec
2016-08-17 06:25:58 +00:00
adc (ZPPtr2)
sta ZPPtr2
bcc .1
inc ZPPtr2+1
2015-10-19 20:35:00 +00:00
bra .1
2016-03-13 21:53:55 +00:00
2015-10-19 20:35:00 +00:00
.99 rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.EXT ldy #1
lda CMD,y
cmp #'/' Command line is already full path, no search
2016-03-13 21:53:55 +00:00
beq .3
2016-08-17 06:25:58 +00:00
>LDYA L.ENV.PATH push ENVNAME=PATH for search
>SYSCALL SYS.GetEnvYA get value for ENV=PATH
bcs .1 No PATH, try in CD
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
>PUSHYA push search list
>PUSHW L.CMD
2015-10-19 20:35:00 +00:00
>SYSCALL SYS.FileSearch
2016-08-17 06:25:58 +00:00
bcc .2
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
.1 ldy #S.PS.hPREFIX not found, try in CD
2015-10-19 20:35:00 +00:00
lda (pPs),y
2016-08-17 06:25:58 +00:00
>SYSCALL SYS.GetMemPtrA
>PUSHYA push search list
>PUSHW L.CMD
2015-10-19 20:35:00 +00:00
>SYSCALL SYS.FileSearch
2016-08-17 06:25:58 +00:00
bcs .99
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
.2 phx save X=hMem, Y,A = Filename
>PUSHYA
>PUSHW L.CMD replace CMD in TmpBuffer with full path
>SYSCALL SYS.PStrCpy
pla
>SYSCALL SYS.FreeMemA Discard this string...
.3 stz TmpBuffer256 reset TmpBuffer256 for final CMDLINE
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
>LDYA L.CMD
2016-06-07 06:10:18 +00:00
>SYSCALL SYS.MLIGetFileInfoYA
2016-08-17 06:25:58 +00:00
bcs .99
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
>STYA ZPPtr2
2015-10-19 20:35:00 +00:00
ldy #1 Get File Type
2016-08-17 06:25:58 +00:00
lda (ZPPtr2),y
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
.99 rts
*--------------------------------------
* TXT : Launch "/PATH/SHELL /PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.TXT
lda #0 Get arg[0] = /PATH/SHELL
>SYSCALL SYS.GetArgA
>PUSHYA
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCpy
inc TmpBuffer256 Add a space....
ldy TmpBuffer256
lda #' '
sta TmpBuffer256,y
*--------------------------------------
* BIN : Launch "/PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.BIN
>PUSHW L.CMD
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCat
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
lda ARGS
beq .1
2016-08-17 06:25:58 +00:00
inc TmpBuffer256 Add a space....
ldy TmpBuffer256
lda #' '
sta TmpBuffer256,y
>PUSHW L.ARGS
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCat
.1 >LDYAI TmpBuffer256
bit Cmd.Exec.Mode
bmi .2 startproc
2016-03-13 21:53:55 +00:00
>SYSCALL SYS.ExecProcessNewEnvYA
2016-08-17 06:25:58 +00:00
rts
2016-08-17 06:25:58 +00:00
.2 >SYSCALL SYS.CreateProcessYA
rts
*--------------------------------------
* Internal Commands
2015-10-19 20:35:00 +00:00
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.CD lda ARGS
bne Cmd.Exec.CD1
2015-10-19 20:35:00 +00:00
ldy #S.PS.hPREFIX
lda (pPs),y
2016-06-07 06:10:18 +00:00
>SYSCALL SYS.GetMemPtrA
>SYSCALL SYS.PSTROutYA
2016-08-17 06:25:58 +00:00
bcs .9
lda #13
>SYSCALL SYS.COutA
2016-08-17 06:25:58 +00:00
.9 rts
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
Cmd.Exec.CD1 lda ARGS+1
cmp #'/' Full Path?
bne .1
>LDYA L.ARGS
bra Cmd.Exec.CD.Change
.1 ldy #S.PS.hPREFIX no, init target prefix with actual
2015-10-19 20:35:00 +00:00
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
2016-08-17 06:25:58 +00:00
>PUSHYA
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCpy
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
lda ARGS+1
2015-10-19 20:35:00 +00:00
cmp #'.' ".." ?
2016-08-17 06:25:58 +00:00
bne .3
cmp ARGS+2 ".." ?
bne .9
ldy TmpBuffer256 remove last dir component in actual prefix
.2 dey
beq .9 nothing to remove, synerr
lda TmpBuffer256,y
2015-10-19 20:35:00 +00:00
cmp #'/'
2016-08-17 06:25:58 +00:00
bne .2
sty TmpBuffer256
>LDYAI TmpBuffer256
bra Cmd.Exec.CD.Change
.9 lda #SYSMGR.ERRSYN
2015-10-19 20:35:00 +00:00
sec
2016-08-17 06:25:58 +00:00
rts
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
.3 >PUSHW L.ARGS Append ARG to buffer
>PUSHWI TmpBuffer256
>SYSCALL SYS.PStrCat
ldx TmpBuffer256
2015-10-19 20:35:00 +00:00
lda #'/' Ending with '/'?
2016-08-17 06:25:58 +00:00
cmp TmpBuffer256,x
2015-10-19 20:35:00 +00:00
beq .4
2016-08-17 06:25:58 +00:00
sta TmpBuffer256+1,x
inc TmpBuffer256
.4 >LDYAI TmpBuffer256
Cmd.Exec.CD.Change
>STYA ZPPtr1
2016-06-24 06:02:32 +00:00
>SYSCALL SYS.CheckPrefixYA
2016-08-17 06:25:58 +00:00
bcs .9
>LDYA ZPPtr1
>SYSCALL SYS.NewPStrYA
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
2016-03-13 21:53:55 +00:00
>SYSCALL SYS.FreeMemA
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
clc
.9 rts
*--------------------------------------
Cmd.Exec.STARTPROC
lda ARGS
beq Cmd.Exec.ERRSYN
2016-03-13 21:53:55 +00:00
sec
2016-08-17 06:25:58 +00:00
ror Cmd.Exec.Mode
2016-03-13 21:53:55 +00:00
2016-08-17 06:25:58 +00:00
>LDYA L.ARGS
jmp Cmd.ExecYA.1
Cmd.Exec.ERRSYN lda #SYSMGR.ERRSYN
2016-03-13 21:53:55 +00:00
sec
2016-08-17 06:25:58 +00:00
rts
2016-03-13 21:53:55 +00:00
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.SET lda ARGS
bne Cmd.Exec.SETVAR
2015-10-19 20:35:00 +00:00
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.1 lda (ZPPTR1)
beq .8 Ending 0 ?
>LDYA ZPPTR1
>SYSCALL SYS.PSTROutYA
2016-08-17 06:25:58 +00:00
bcs .9
lda ZPPTR1
sec
adc (ZPPTR1) Add len+1 to PTR
sta ZPPTR1
bcc .2
inc ZPPTR1+1
.2 lda #'='
>SYSCALL SYS.COutA
bcs .9
>LDYA ZPPTR1
>SYSCALL SYS.PSTROutYA
bcs .9
lda #13
>SYSCALL SYS.COutA
2016-08-17 06:25:58 +00:00
bcs .9
2015-10-19 20:35:00 +00:00
lda ZPPTR1
sec
adc (ZPPTR1) Add len+1 to PTR
sta ZPPTR1
bcc .1
2016-08-17 06:25:58 +00:00
inc ZPPTR1+1
2015-10-19 20:35:00 +00:00
bra .1
.8 clc
2016-08-17 06:25:58 +00:00
.9 rts
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
Cmd.Exec.SETVAR tax
lda ARGS,x
cmp #'=' ARGS ends with =, UnsetEnv
beq .2
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
.1 dex
beq .3 no =, GetEnv
2016-08-17 06:25:58 +00:00
lda ARGS,x
cmp #'=' ARGS contains =, PutEnv
bne .1
2015-10-19 20:35:00 +00:00
2016-08-17 06:25:58 +00:00
cpx #1 string is '=value' ?
beq Cmd.Exec.ERRSYN syntax error
>LDYA L.ARGS String is VAR=VALUE...
>SYSCALL SYS.PutEnvYA
rts
.2 dec ARGS String is "VAR=", Remove endig '='
>LDYA L.ARGS String is "VAR"...
>SYSCALL SYS.UnsetEnvYA
rts
.3 >LDYA L.ARGS String is VAR...
2016-06-07 06:10:18 +00:00
>SYSCALL SYS.PSTROutYA
2016-08-17 06:25:58 +00:00
bcs .9
2015-10-19 20:35:00 +00:00
lda #'='
>SYSCALL SYS.COutA
2016-08-17 06:25:58 +00:00
bcs .9
>LDYA L.ARGS
>SYSCALL SYS.GetEnvYA
bcs .8
>SYSCALL SYS.PSTROutYA Y,A = VALUE
.8 lda #13
>SYSCALL SYS.COutA
2016-08-17 06:25:58 +00:00
.9 rts
2015-10-19 20:35:00 +00:00
*--------------------------------------
Cmd.Exec.DATE >LDYA L.TIME
>SYSCALL SYS.TimeYA
>PUSHWI TmpBuffer256
>PUSHW L.FMT.DATE
>PUSHW L.TIME
>SYSCALL SYS.StrFTime
>LDYAI TmpBuffer256
>SYSCALL SYS.PSTROutYA
2015-10-19 20:35:00 +00:00
bcs .9
lda #13
>SYSCALL SYS.COutA
2015-10-19 20:35:00 +00:00
.9 rts
*--------------------------------------
Cmd.Exec.TIME >LDYA L.TIME
>SYSCALL SYS.TimeYA
>PUSHWI TmpBuffer256
>PUSHW L.FMT.TIME
>PUSHW L.TIME
>SYSCALL SYS.StrFTime
>LDYAI TmpBuffer256
>SYSCALL SYS.PSTROutYA
2015-10-19 20:35:00 +00:00
bcs .9
lda #13
>SYSCALL SYS.COutA
2015-10-19 20:35:00 +00:00
.9 rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.ECHO lda ARGS
beq .9
>LDYA L.ARGS
2016-06-07 06:10:18 +00:00
>SYSCALL SYS.PSTROutYA
lda #13
>SYSCALL SYS.COutA
2015-10-19 20:35:00 +00:00
clc
rts
2016-08-17 06:25:58 +00:00
.9 lda #SYSMGR.ERRSYN
2015-10-19 20:35:00 +00:00
sec
2016-08-17 06:25:58 +00:00
rts
2015-10-19 20:35:00 +00:00
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.TYPE lda ARGS
2015-10-19 20:35:00 +00:00
beq .98
2016-08-17 06:25:58 +00:00
>LDYA L.ARGS
2016-06-07 06:10:18 +00:00
>SYSCALL SYS.LoadFileYA
2015-10-19 20:35:00 +00:00
bcs .99
>STYA ZPPTR2 store file len
phx
txa
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
.1 lda ZPPTR2
bne .2
lda ZPPTR2+1
beq .3
dec ZPPTR2+1
.2 dec ZPPTR2
lda (ZPPTR1)
>SYSCALL SYS.COutA
2015-10-19 20:35:00 +00:00
inc ZPPTR1
bne .1
inc ZPPTR1+1
bra .1
.3 pla
>SYSCALL SYS.FreeMemA
clc
rts
.98 lda #SYSMGR.ERRSYN
sec
.99 rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.READ
clc
rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.PAUSE ldy #bPause
lda #$80
sta (pData),y
clc
rts
*--------------------------------------
2016-08-17 06:25:58 +00:00
Cmd.Exec.EXIT ldy #bEXIT
2015-10-19 20:35:00 +00:00
lda #$FF
sta (pData),y
clc
rts
*--------------------------------------
MAN
SAVE SBIN/SHELL.S.CMD
LOAD SBIN/SHELL.S
ASM