mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
426 lines
7.4 KiB
Plaintext
426 lines
7.4 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
EXEC.CMD stz hFullCmd
|
||
stz hEnvPath
|
||
|
||
ldy #hCmdLine
|
||
lda (pData),y
|
||
>PUSHA
|
||
>PUSHBI $20 Push SEP=' '
|
||
>PUSHBI 0 Push 0 for getting CMD & ARGS
|
||
>SYSCALL SYS.PStrGetTkn
|
||
bcs .99
|
||
|
||
sta hExecCmd
|
||
stx hExecArgs
|
||
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPtr1
|
||
|
||
ldx #0
|
||
stz ExecCmdIdx
|
||
|
||
.1 lda CMDS,x
|
||
beq EXEC.CMD.EXT
|
||
cmp (ZPPtr1)
|
||
bne .5
|
||
|
||
phx
|
||
ldy #0
|
||
|
||
.2 iny
|
||
inx
|
||
lda (ZPPtr1),y
|
||
cmp #'a'
|
||
bcc .3
|
||
cmp #'z'+1
|
||
bcs .3
|
||
eor #$20 to Uppercase
|
||
.3 cmp CMDS,x
|
||
bne .4
|
||
tya
|
||
cmp (ZPPtr1)
|
||
bne .2
|
||
plx
|
||
|
||
jsr EXEC.CMD.INT
|
||
jmp EXEC.CMD.ClnUp
|
||
|
||
.4 plx
|
||
.5 txa
|
||
sec
|
||
adc CMDS,x
|
||
tax
|
||
inc ExecCmdIdx
|
||
inc ExecCmdIdx
|
||
bra .1
|
||
.99 rts
|
||
*--------------------------------------
|
||
* ZPPtr1 = hExecCmd
|
||
*--------------------------------------
|
||
EXEC.CMD.EXT ldy #1
|
||
lda (ZPPtr1),y
|
||
cmp #'/'
|
||
bne .1
|
||
>LDYA ZPPtr1
|
||
>SYSCALL SYS.NewPStrYA
|
||
bra .10
|
||
|
||
.1 >LDYA L.ENV.PATH push ENVNAME=PATH
|
||
>SYSCALL SYS.GetEnvVarYA get value for ENV=PATH
|
||
|
||
bcc .12
|
||
jmp EXEC.CMD.ClnUp
|
||
|
||
.12 sta hEnvPath
|
||
>PUSHB hExecCmd
|
||
>PUSHB hEnvPath
|
||
>SYSCALL SYS.FileSearch
|
||
bcc .10
|
||
|
||
>PUSHB hExecCmd
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>PUSHA
|
||
>SYSCALL SYS.FileSearch
|
||
|
||
.10 bcs EXEC.CMD.ClnUp
|
||
|
||
sta hFullCmd
|
||
>SYSCALL SYS.MLIGetFileInfoA
|
||
bcs EXEC.CMD.ClnUp
|
||
|
||
>STYA ZPPTR1
|
||
ldy #1 Get File Type
|
||
lda (ZPPTR1),y
|
||
cmp #$04 TXT File ?
|
||
bne .2
|
||
|
||
lda hFullCmd
|
||
jsr OpenTxtFileA
|
||
bcs EXEC.CMD.ClnUp
|
||
|
||
lda hExecArgs
|
||
beq .11
|
||
|
||
>SYSCALL SYS.PStrCpyA
|
||
bcs EXEC.CMD.ClnUp
|
||
.11 ldy #hInputArgs
|
||
sta (pData),y
|
||
bra EXEC.CMD.ClnUp
|
||
|
||
.2 cmp #$06 BIN File ?
|
||
bne .4
|
||
|
||
ldy #S.PS.PID
|
||
lda (pPs),y
|
||
beq .3 0, we are in kernel space
|
||
|
||
lda hFullCmd
|
||
ldy hExecArgs
|
||
>SYSCALL SYS.ExecProcessNewEnvYA
|
||
bra EXEC.CMD.ClnUp
|
||
|
||
.3 lda hFullCmd
|
||
ldy hExecArgs
|
||
>SYSCALL SYS.CreateProcessYA
|
||
bra EXEC.CMD.ClnUp
|
||
|
||
.4 cmp #$ff SYS File ?
|
||
bne .5
|
||
|
||
bra *
|
||
|
||
.5 lda #SYSMGR.ERRSYN
|
||
sec
|
||
EXEC.CMD.ClnUp pha
|
||
php
|
||
lda hFullCmd
|
||
beq .1
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
.1 lda hEnvPath
|
||
beq .2
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
.2 lda hExecArgs
|
||
beq .3
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
.3 lda hExecCmd
|
||
beq .8
|
||
>SYSCALL SYS.FreeMemA
|
||
.8 plp
|
||
pla
|
||
rts
|
||
*--------------------------------------
|
||
EXEC.CMD.INT ldx ExecCmdIdx
|
||
jmp (J.INTCMDS,x)
|
||
*--------------------------------------
|
||
EXEC.CMD.CD lda hExecArgs
|
||
bne EXEC.CMD.CD.C
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL SYS.PSTROutA
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
clc
|
||
rts
|
||
|
||
EXEC.CMD.CD.C >SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPTR2
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPTR1
|
||
>PUSHWI MLI.MAXPATH+1 Get a buffer for new PATH
|
||
>PUSHBI 0 no particular Option
|
||
>SYSCALL SYS.GetMem
|
||
bcs .99
|
||
>STYA ZPPTR3
|
||
stx hNEWPATH
|
||
|
||
lda #0
|
||
sta (ZPPTR3)
|
||
ldy #1
|
||
lda (ZPPTR2),y
|
||
cmp #'/' Full Path?
|
||
beq .3
|
||
cmp #'.' ".." ?
|
||
bne .2
|
||
lda (ZPPTR2)
|
||
cmp #2
|
||
bne .97
|
||
iny
|
||
lda (ZPPTR2),y
|
||
cmp #'.'
|
||
bne .97
|
||
lda (ZPPTR1)
|
||
tay
|
||
.1 dey
|
||
beq .97
|
||
lda (ZPPTR1),y
|
||
cmp #'/'
|
||
bne .1
|
||
tya
|
||
sta (ZPPTR3)
|
||
.11 lda (ZPPTR1),y
|
||
sta (ZPPTR3),y
|
||
dey
|
||
bne .11
|
||
bra .4
|
||
.97 lda #SYSMGR.ERRSYN
|
||
.98 pha
|
||
lda hNEWPATH
|
||
>SYSCALL SYS.FreeMemA
|
||
pla
|
||
sec
|
||
.99 rts
|
||
|
||
.2 >PUSHW ZPPTR1
|
||
>PUSHW ZPPTR3
|
||
>LIBCALL hLIBSTR,LIBSTR.STRCPYP
|
||
.3 >PUSHW ZPPTR2
|
||
>PUSHW ZPPTR3
|
||
>LIBCALL hLIBSTR,LIBSTR.STRCATP
|
||
lda (ZPPTR3)
|
||
tay
|
||
lda #'/' Ending with '/'?
|
||
cmp (ZPPTR3),y
|
||
beq .4
|
||
iny
|
||
sta (ZPPTR3),y
|
||
tya
|
||
sta (ZPPTR3)
|
||
.4 lda hNEWPATH
|
||
>SYSCALL SYS.CheckPrefixA
|
||
bcs .98
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
pha
|
||
lda hNEWPATH
|
||
sta (pPs),y
|
||
pla
|
||
>SYSCALL SYS.FreeMemA
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
EXEC.CMD.SET lda hExecArgs
|
||
bne EXEC.CMD.SETVAR
|
||
|
||
ldy #S.PS.hENV
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPTR1
|
||
|
||
.1 lda (ZPPTR1)
|
||
beq .8 Ending 0 ?
|
||
>LDYA ZPPTR1
|
||
>SYSCALL SYS.PSTROutYA
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
|
||
lda ZPPTR1
|
||
sec
|
||
adc (ZPPTR1) Add len+1 to PTR
|
||
sta ZPPTR1
|
||
bcc .1
|
||
inc ZPPTR1
|
||
bra .1
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
EXEC.CMD.SETVAR >PUSHA Push Cmd Line
|
||
>PUSHBI $3D Push SEP='='
|
||
>PUSHBI 0 Push Token IDX
|
||
>SYSCALL SYS.PStrGetTkn
|
||
bcc .3
|
||
lda #SYSMGR.ERRSYN
|
||
rts
|
||
|
||
.3 sta hVarName
|
||
stx hVarValue
|
||
txa
|
||
beq .31
|
||
|
||
>PUSHB hVarValue
|
||
>PUSHB hVarName
|
||
>SYSCALL SYS.SetEnvVarH
|
||
jmp .97
|
||
|
||
.31 lda hExecArgs
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPPTR1
|
||
lda (ZPPTR1)
|
||
tay
|
||
lda (ZPPTR1),y
|
||
cmp #'='
|
||
bne .4
|
||
|
||
lda hVarName
|
||
>SYSCALL SYS.DelEnvVarA
|
||
bra .97
|
||
|
||
.4 lda hVarName
|
||
>SYSCALL SYS.GetEnvVarA
|
||
bcs .97
|
||
sta hVarValue
|
||
|
||
lda hVarName
|
||
>SYSCALL SYS.PSTROutA
|
||
lda #'='
|
||
>SYSCALL SYS.COutA
|
||
lda hVarValue
|
||
>SYSCALL SYS.PSTROutA
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
|
||
clc
|
||
|
||
.97 php
|
||
pha
|
||
lda hVarValue
|
||
beq .98
|
||
>SYSCALL SYS.FreeMemA
|
||
.98 lda hVarName
|
||
>SYSCALL SYS.FreeMemA
|
||
pla
|
||
php
|
||
rts
|
||
*--------------------------------------
|
||
EXEC.CMD.DATE >SYSCALL SYS.MLIGetTime
|
||
bcs .9
|
||
>PUSHW DATELO
|
||
>LIBCALL hLIBSTR,LIBSTR.PRINTDATE
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
EXEC.CMD.TIME >SYSCALL SYS.MLIGetTime
|
||
bcs .9
|
||
>PUSHW TIMELO
|
||
>LIBCALL hLIBSTR,LIBSTR.PRINTTIME
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
EXEC.CMD.ECHO lda hExecArgs
|
||
beq .98
|
||
>SYSCALL SYS.ExpandPStrA
|
||
bcs .99
|
||
|
||
pha
|
||
>SYSCALL SYS.PSTROutA
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
pla
|
||
>SYSCALL SYS.FreeMemA
|
||
clc
|
||
rts
|
||
|
||
.98 lda #SYSMGR.ERRSYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
EXEC.CMD.TYPE lda hExecArgs
|
||
beq .98
|
||
>SYSCALL SYS.LoadFileA
|
||
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
|
||
inc ZPPTR1
|
||
bne .1
|
||
inc ZPPTR1+1
|
||
bra .1
|
||
|
||
.3 pla
|
||
>SYSCALL SYS.FreeMemA
|
||
clc
|
||
rts
|
||
|
||
.98 lda #SYSMGR.ERRSYN
|
||
sec
|
||
.99 rts
|
||
*--------------------------------------
|
||
EXEC.CMD.READ
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
EXEC.CMD.PAUSE ldy #bPause
|
||
lda #$80
|
||
sta (pData),y
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
EXEC.CMD.EXIT ldy #bEXIT
|
||
lda #$FF
|
||
sta (pData),y
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SBIN/SHELL.S.CMD
|
||
LOAD SBIN/SHELL.S
|
||
ASM
|