SHELL:new startproc internal command

This commit is contained in:
Rémy GIBERT 2016-03-13 22:53:55 +01:00
parent 42988fac64
commit 6ef6d21da7
2 changed files with 117 additions and 81 deletions

View File

@ -24,9 +24,10 @@ EXEC.CMD stz hFullCmd
ldx #0
stz ExecCmdIdx
stz ExecCmdMode
.1 lda CMDS,x
beq EXEC.CMD.EXT
beq .6
cmp (ZPPtr1)
bne .5
@ -48,6 +49,7 @@ EXEC.CMD stz hFullCmd
bne .2
plx
ldx ExecCmdIdx
jsr EXEC.CMD.INT
jmp EXEC.CMD.ClnUp
@ -59,85 +61,11 @@ EXEC.CMD stz hFullCmd
inc ExecCmdIdx
inc ExecCmdIdx
bra .1
.6 jsr EXEC.CMD.EXT
jmp EXEC.CMD.ClnUp
.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
@ -159,8 +87,84 @@ EXEC.CMD.ClnUp pha
pla
rts
*--------------------------------------
EXEC.CMD.INT ldx ExecCmdIdx
jmp (J.INTCMDS,x)
EXEC.CMD.INT jmp (J.INTCMDS,x)
*--------------------------------------
* 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 .9
.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 .9
sta hFullCmd
>SYSCALL SYS.MLIGetFileInfoA
bcs .9
>STYA ZPPTR1
ldy #1 Get File Type
lda (ZPPTR1),y
cmp #$04 TXT File ?
bne .2
lda hFullCmd
jsr OpenTxtFileA
bcs .9
lda hExecArgs
beq .11
>SYSCALL SYS.PStrCpyA
bcs .9
.11 ldy #hInputArgs
sta (pData),y
bra .9
.2 cmp #$06 BIN File ?
bne .4
lda hFullCmd
ldy hExecArgs
bit ExecCmdMode
bmi .3 startproc
>SYSCALL SYS.ExecProcessNewEnvYA
bra .9
.3 >SYSCALL SYS.CreateProcessYA
bra.9
.4 cmp #$ff SYS File ?
bne .5
bra *
.5 lda #SYSMGR.ERRSYN
sec
.9 rts
*--------------------------------------
EXEC.CMD.CD lda hExecArgs
bne EXEC.CMD.CD.C
@ -250,6 +254,36 @@ EXEC.CMD.CD.C >SYSCALL SYS.GetMemPtrA
clc
rts
*--------------------------------------
EXEC.CMD.STARTPROC
lda hExecCmd
>SYSCALL SYS.FreeMemA
stz hExecCmd
lda hExecArgs
beq .9
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push 0 for getting CMD & ARGS
>SYSCALL SYS.PStrGetTkn
bcs .99
phx
sta hExecCmd
>SYSCALL SYS.GetMemPtrA
>STYA ZPPTR1
lda hExecArgs
>SYSCALL SYS.FreeMemA
pla
sta hExecArgs
sec
ror ExecCmdMode
jmp EXEC.CMD.EXT
.9 lda #SYSMGR.ERRSYN
sec
.99 rts
*--------------------------------------
EXEC.CMD.SET lda hExecArgs
bne EXEC.CMD.SETVAR

View File

@ -49,6 +49,7 @@ J.INTCMDS .DA EXEC.CMD.CD
.DA EXEC.CMD.PAUSE
.DA EXEC.CMD.READ
.DA EXEC.CMD.SET
.DA EXEC.CMD.STARTPROC
.DA EXEC.CMD.TIME
.DA EXEC.CMD.TYPE
.DA 0
@ -196,7 +197,6 @@ CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
.11 ldy #hInputFile Batch mode ?
lda (pData),y
beq .10
* Batch Mode
cpx #3 test Ctrl-c
bne .12
@ -480,6 +480,7 @@ CMDS >PSTRING "CD"
>PSTRING "PAUSE"
>PSTRING "READ"
>PSTRING "SET"
>PSTRING "STARTPROC"
>PSTRING "TIME"
>PSTRING "TYPE"
.HS 00
@ -500,6 +501,7 @@ hFullCmd .BS 1
hVarName .BS 1
hVarValue .BS 1
ExecCmdIdx .BS 1
ExecCmdMode .BS 1
*--------------------------------------
.DUMMY
.OR 0