Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-10-15 08:25:40 +02:00
parent ba1a76d4df
commit 743545cb8e
11 changed files with 405 additions and 430 deletions

View File

@ -530,28 +530,14 @@ Load a file in AUX memory (Stock Objects)
Y,A = File Length
X = hMem of Loaded Object in AUX mem
# ExecPSNewEnv
# ExecPS (Blocking Parent PID)
# CreatePSNewEnv
# CreatePS (Non Blocking)
**In:**
Y,A = PTR To Cmd Line
## RETURN VALUE
A = Child PSID
# Exec
## C
`int exec(const char *path, char *const argv[], short int flage);`
`int exec(const char* argv[], short int flags);`
## ASM
`>PUSHB flags`
`>PUSHW argv`
`>LDYAI path`
`>LDYA argv`
`>SYSCALL exec`
## RETURN VALUE

Binary file not shown.

Binary file not shown.

View File

@ -199,11 +199,11 @@ SYS.UnloadLib .EQ $9A
SYS.LoadDrv .EQ $9C
SYS.InsDrv .EQ $9E
*--------------------------------------
SYS.ExecPSNewEnv .EQ $A0
SYS.ExecPS .EQ $A2
SYS.CreatePSNewEnv .EQ $A4
SYS.CreatePS .EQ $A6
* .EQ $A8
* .EQ $A0
* .EQ $A2
* .EQ $A4
* .EQ $A6
SYS.Exec .EQ $A8
SYS.GetMemStat .EQ $AA
SYS.GetPSStatus .EQ $AC
SYS.GetPSStat .EQ $AE

View File

@ -114,9 +114,10 @@ CS.RUN.LOOP1 >SLEEP
.1 jsr Wait.Timeout
bcc CS.RUN.LOOP1
.2 lda #2
.2 >PUSHBI S.PS.F.DUPENV+S.PS.F.HOLD
lda #2
>SYSCALL GetArg
>SYSCALL ExecPSNewEnv
>SYSCALL Exec
bcs CS.RUN.9
>SLEEP

View File

@ -79,25 +79,26 @@ CS.RUN lda #0
bcc .22
tax
beq .2 no char
bra .9
.9 rts
.22 jsr INPUT.CHARIN
jsr INPUT.LINEIN
bcc .2
lda #13
lda #C.CR
>SYSCALL PutChar
bcs .9
lda #10
lda #C.LF
>SYSCALL PutChar
bcs .9
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL ExpandStr
bcs .9
phx
>SYSCALL ExecPS
>SYSCALL Exec
plx
@ -108,7 +109,7 @@ CS.RUN lda #0
pla
plp
.9 rts
rts
*--------------------------------------
CS.DOEVENT
sec

View File

@ -24,21 +24,24 @@ CMD.Quit >LDA.G hCmdBuf
*--------------------------------------
Cmd.Parse >LDYA ZPCMDBuf
>SYSCALL ExpandStr
bcs .99
>STYA ZPPtr1 Ptr to expanded CMD ARGS\0
txa
>STA.G CMD.hCmdLine
* SET +X
>LDYA ZPCMDBuf
>LDYA ZPPtr1
>SYSCALL puts
bcs .90
ldy #0
lda (ZPPtr1) empty line...quit
beq .9
.1 jsr Cmd.Parse.NextC
.1 jsr Cmd.NextCharPtr1
beq .8 no more char, exit
cmp #' ' skip leading spaces
@ -50,17 +53,17 @@ Cmd.Parse >LDYA ZPCMDBuf
.3 sta (ZPCMDBuf),y add char to buffer
iny
jsr Cmd.Parse.NextC
jsr Cmd.NextCharPtr1
beq .8
cmp #' '
bne .3
lda #0
sta (ZPCMDBuf),y add One \0 to buffer
sta (ZPCMDBuf),y add \0 to buffer
iny
.5 jsr Cmd.Parse.NextC
.5 jsr Cmd.NextCharPtr1
beq .8
cmp #' '
@ -73,24 +76,15 @@ Cmd.Parse >LDYA ZPCMDBuf
.9 tya
>STA.G CmdBuflen
>LDA.G CMD.hCmdLine
.90 >LDA.G CMD.hCmdLine
>SYSCALL FreeMem
rts
Cmd.Parse.NextC lda (ZPPtr1)
beq .8
inc ZPPtr1
bne .8
inc ZPPtr1+1 never Z
.8 rts
.99 rts
*--------------------------------------
* ZPCMDBuf-> argv[] (formatted & not empty)
*--------------------------------------
CMD.Exec lda #0
>STA.G CMD.bStartProc
>STA.G CMD.hFullpath
CMD.Exec lda #S.PS.F.HOLD+S.PS.F.DUPENV
>STA.G CMD.PSFlags
>LDYA L.CMD.INT
>STYA ZPPtr2
@ -102,167 +96,148 @@ CMD.Exec lda #0
>PUSHW ZPPtr2
>LDYA ZPCMDBuf
>SYSCALL StrCaseCmp
plx
bcc .8
bcs .2
inx
inx
ldx #0
jsr Cmd.RemoveStrAtX Remove CMD...
plx
jmp (J.CMD.INT,x) Found an internal Cmd...
.2 jsr Cmd.NextStrPtr2
lda (ZPPtr2)
beq Cmd.Exec.EXT Array Ending 0, must be an external Cmd....
sec
adc ZPPtr2
sta ZPPtr2
bcc .1
inc ZPPtr2+1
plx
inx
inx
bra .1
.8 jsr Cmd.Exec.GetArgs X unmodified
jmp (J.CMD.INT,x) Found an internal Cmd...
*--------------------------------------
Cmd.Exec.Done php
pha
>LDA.G CMD.hFullpath
beq .1
>SYSCALL FreeMem
>STZ.G CMD.hFullpath
.1 pla
plp
rts
*--------------------------------------
Cmd.Exec.EXT jsr Cmd.Exec.GetArgs
Cmd.Exec.EXT ldy #0
lda (ZPPtr1)
cmp #'/' Command line is already full path, no search
bne .1
.10 lda (ZPCMDBuf),y
beq .1 no / found, search...
cmp #'/'
beq .11 found /, some path specified, no search
iny
bra .10
>PUSHEA.G CMD.Stat
>LDYA ZPPtr1
.11 >LDYA ZPCMDBuf
>SYSCALL realpath
bcs .99
phy
pha
txa
>STA.G CMD.hCmdLine
pla
ply
>PUSHEA.G CMD.Stat Command line is already full path, no search
>LDYA ZPCMDBuf
>SYSCALL STAT
bcs Cmd.Exec.Done
bcc .2
rts
>LDYA ZPPtr1
bra .4
.1 >LDYA L.ENV.PATH push ENVNAME=PATH for search
.1 >LDYAI 256 Get a buffer for found path
>SYSCALL GetMem
bcs .99
txa
>STA.G CMD.hCmdLine
>LDYA L.ENV.PATH push ENVNAME=PATH for search
>SYSCALL GetEnv get value for ENV=PATH
bcs .2 No PATH, try in CD
bcs .99 No PATH, try in CD
jsr Cmd.Exec.EXT.Search
bcc .3
bcc .2
.2 ldy #S.PS.hPREFIX not found, try in CD
ldy #S.PS.hPREFIX not found, try in CD
lda (pPs),y
>SYSCALL GetMemPtr
jsr Cmd.Exec.EXT.Search
bcs .99
.3 >LDYA ZPCMDBuf
.4 >SYSCALL NewStr
bcs .99
txa
>STA.G CMD.hFullpath
lda #0
sta (ZPCMDBuf) reset ZPCMDBuf for final CMD
bcc .2
pha
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem
pla
sec
.99 rts
* CMD.hCmdLine = /path/bin
.2 ldx #0
jsr Cmd.RemoveStrAtX
>LDA.G CMD.hCmdLine
>SYSCALL GetMemPtr
ldx #0
jsr CMD.InsertStrYAAtX
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem
ldy #CMD.Stat+S.STAT.P.TYPE
lda (pData),y
cmp #$04 TXT File ?
cmp #S.FI.T.TXT
beq Cmd.Exec.EXT.TXT
cmp #$06 BIN File ?
cmp #S.FI.T.BIN
beq Cmd.Exec.EXT.BIN
cmp #$ff SYS File ?
cmp #S.FI.T.SYS
bne .9
bra *
.9 lda #K.E.SYN
sec
.99 jmp Cmd.Exec.Done
*--------------------------------------
* TXT : Launch "/PATH/SHELL /PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.TXT
lda #0 Get arg[0] = /PATH/SHELL
>SYSCALL GetArg
>PUSHYA
>LDYA ZPCMDBuf
>SYSCALL StrCat
jsr Cmd.Exec.EXT.SEP Add a space....
*--------------------------------------
* BIN : Launch "/PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.BIN
>LDA.G CMD.hFullpath
>SYSCALL GetMemPtr
>PUSHYA
>LDYA ZPCMDBuf
>SYSCALL StrCat
lda (ZPPTR2) Some ARGS ?
beq .1
jsr Cmd.Exec.EXT.SEP Add a space....
>PUSHW ZPPTR2
>LDYA ZPCMDBuf
>SYSCALL StrCat
.1 >LDA.G CMD.bStartProc
asl
>LDYA ZPCMDBuf
bcs .2 startproc
>SYSCALL ExecPSNewEnv
jmp Cmd.Exec.Done
.2 >SYSCALL CreatePSNewEnv
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.EXT.Search
pha
phy
>PUSHEA.G CMD.Stat
>PUSHW ZPCMDBuf push dest full path
>LDA.G CMD.hCmdLine
>SYSCALL GetMemPtr
>PUSHYA push dest full path
ply
pla
>PUSHYA push search list
>LDYA ZPPtr1 push CMD
>LDYA ZPCMDBuf push CMD
>SYSCALL FileSearch
rts
*--------------------------------------
Cmd.Exec.EXT.SEP
ldy #$ff
.1 iny
lda (ZPCMDBuf),y
bne .1
lda #' '
sta (ZPCMDBuf),y
iny
* TXT : Launch "/PATH/SHELL /PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.TXT
lda #0
sta (ZPCMDBuf),y
>SYSCALL GetArg
ldx #0
jsr Cmd.InsertStrYAAtX
*--------------------------------------
* BIN : Launch "/PATH/CMD ARGS"
*--------------------------------------
Cmd.Exec.EXT.BIN
>PUSHB.G CMD.PSFlags
>LDYA ZPCMDBuf
>SYSCALL Exec
rts
*--------------------------------------
* Internal Commands
*--------------------------------------
Cmd.Exec.PWD ldy #S.PS.hPREFIX
Cmd.INT.PWD ldy #S.PS.hPREFIX
lda (pPs),y
>SYSCALL GetMemPtr
>SYSCALL puts
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.CD lda (ZPPTR2)
Cmd.INT.CD lda (ZPCMDBuf)
bne .1
>LDYA L.ENV.HOME
>SYSCALL GetEnv
bcs Cmd.Exec.PWD
bcs Cmd.INT.PWD
>SYSCALL ExpandStr
bcs .9
@ -271,30 +246,30 @@ Cmd.Exec.CD lda (ZPPTR2)
.1 ldy #0
.2 lda (ZPPTR2),y
.2 lda (ZPCMDBuf),y
tax
iny
lda (ZPPTR2),y
lda (ZPCMDBuf),y
bne .2
cpx #'/'
beq .3
lda #'/'
sta (ZPPTR2),y
sta (ZPCMDBuf),y
iny
lda #0
sta (ZPPTR2),y
sta (ZPCMDBuf),y
.3 >LDYA ZPPTR2 Get ARG
.3 >LDYA ZPCMDBuf Get ARG0
>SYSCALL RealPath
bcs .9
.4 >STYA ZPPTR2
.4 >STYA ZPCMDBuf
txa
>STA.G CMD.hFullpath
>STA.G CMD.hCmdLine
ldy #1
lda (ZPPTR2),y
lda (ZPCMDBuf),y
beq .8 we have '/'
>PUSHEA.G CMD.Stat
@ -307,7 +282,7 @@ Cmd.Exec.CD lda (ZPPTR2)
cmp #$0F Directory ?
bne Cmd.Exec.ERRSYN
.8 >LDYA ZPPTR2
.8 >LDYA ZPCMDBuf
>SYSCALL NewStr
bcs .9
phx
@ -322,25 +297,24 @@ Cmd.Exec.CD lda (ZPPTR2)
sta (pPs),y
jsr SetPWD
clc
.9 jmp Cmd.Exec.Done
.9 rts
*--------------------------------------
Cmd.Exec.ERRSYN lda #K.E.SYN
sec
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.STARTPROC
lda (ZPPTR2)
Cmd.INT.STARTPROC
lda (ZPCMDBuf)
beq Cmd.Exec.ERRSYN
lda #$ff
>STA.G CMD.bStartProc
>LDYA ZPPTR2
>STYA ZPPTR1
>LDA.G CMD.PSFlags
and #$ff^S.PS.F.HOLD
sta (pData),y
jmp Cmd.Exec.EXT
*--------------------------------------
Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR
Cmd.INT.SET lda (ZPCMDBuf)
bne Cmd.INT.SETVAR
* No arg, print all ENV
@ -368,7 +342,7 @@ Cmd.Exec.SET lda (ZPPTR2)
>PUSHW ZPPTR2 Push value
>PUSHW ZPPTR1 Push name
jsr Cmd.Exec.SET.PRINT
jsr Cmd.INT.SET.PRINT
bcs .9
@ -388,60 +362,60 @@ Cmd.Exec.SET lda (ZPPTR2)
bra .1
.8 clc
.9 jmp Cmd.Exec.Done
.9 rts
*--------------------------------------
Cmd.Exec.SETVAR cmp #'=' string is '=value' ?
Cmd.INT.SETVAR cmp #'=' string is '=value' ?
beq .99 syntax error
ldy #0
.1 iny
lda (ZPPTR2),y
lda (ZPCMDBuf),y
beq .3 no =, GetEnv
cmp #'=' ARGS contains =, PutEnv
bne .1
iny
lda (ZPPTR2),y
lda (ZPCMDBuf),y
beq .2 "VAR=" go UnsetEnv
>LDYA ZPPTR2 String is VAR=VALUE...
>LDYA ZPCMDBuf String is VAR=VALUE...
>SYSCALL PutEnv
jmp Cmd.Exec.Done
rts
.2 dey String is "VAR=", Remove ending '='
lda #0
sta (ZPPTR2),y
sta (ZPCMDBuf),y
>LDYA ZPPTR2 String is "VAR"...
>LDYA ZPCMDBuf String is "VAR"...
>SYSCALL UnsetEnv
jmp Cmd.Exec.Done
rts
* Print requested VAR
.3 >LDYA ZPPTR2
.3 >LDYA ZPCMDBuf
>SYSCALL GetEnv
bcs .8
>PUSHYA push value
>PUSHW ZPPTR2 push name
jsr Cmd.Exec.SET.PRINT
>PUSHW ZPCMDBuf push name
jsr Cmd.INT.SET.PRINT
.8 clc
.9 jmp Cmd.Exec.Done
.9 rts
.99 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.SET.PRINT
Cmd.INT.SET.PRINT
>PUSHBI 4
>LDYA L.MSG.PRINTENV
>SYSCALL printf
rts
*--------------------------------------
Cmd.Exec.DATE sec
Cmd.INT.DATE sec
.HS 90 bcc
Cmd.Exec.TIME clc
Cmd.INT.TIME clc
php
>LEA.G CMD.Time
>SYSCALL Time
@ -459,13 +433,13 @@ Cmd.Exec.TIME clc
>LDYA ZPCMDBuf
>SYSCALL puts
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.ECHO >LDYA ZPPtr2
Cmd.INT.ECHO >LDYA ZPCMDBuf
>SYSCALL puts
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.READ lda (ZPPtr2)
Cmd.INT.READ lda (ZPCMDBuf)
beq .9
lda #0
@ -485,13 +459,13 @@ Cmd.Exec.READ lda (ZPPtr2)
cmp #' '
bne .11
jsr Cmd.Exec.GetNextP2
jsr Cmd.NextCharPtr2
bra .1
.11 cmp #'-'
bne .7
jsr Cmd.Exec.GetNextP2
jsr Cmd.NextCharPtr2
beq .9
cmp #'S'
@ -500,7 +474,7 @@ Cmd.Exec.READ lda (ZPPtr2)
lda #$80
>STA.G bSecureRead
jsr Cmd.Exec.GetNextP2
jsr Cmd.NextCharPtr2
beq .8
cmp #' '
bne .9
@ -510,19 +484,19 @@ Cmd.Exec.READ lda (ZPPtr2)
.2 cmp #'P'
bne .9
jsr Cmd.Exec.GetNextP2
jsr Cmd.NextCharPtr2
beq .9
cmp #' '
bne .9
jsr Cmd.Exec.GetNextP2
jsr Cmd.NextCharPtr2
beq .9
cmp #'"'
bne .9
.3 jsr Cmd.Exec.GetNextP2
.3 jsr Cmd.NextCharPtr2
beq .9
cmp #'"'
@ -549,7 +523,7 @@ Cmd.Exec.READ lda (ZPPtr2)
lda #0
sta (ZPPTR1),y
jsr Cmd.Exec.GetNextP2
jsr Cmd.NextCharPtr2
beq .1
cmp #' '
beq .1
@ -563,33 +537,34 @@ Cmd.Exec.READ lda (ZPPtr2)
>STA.G bReadMode
clc
.99 jmp Cmd.Exec.Done
.99 rts
*--------------------------------------
Cmd.Exec.SLEEP lda (ZPPtr2)
Cmd.INT.SLEEP lda (ZPCMDBuf)
beq .9
>LDYA ZPPtr2
>LDYA ZPCMDBuf
>SYSCALL AToL
bcs .9
>PULLL.G Sleep
clc
rts
jmp Cmd.Exec.Done
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.PAUSE lda #$FF
Cmd.INT.PAUSE lda #$FF
>STA.G bPause
clc
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.EXIT lda #$FF
Cmd.INT.EXIT lda #$FF
>STA.G bExit
clc
jmp Cmd.Exec.Done
rts
*--------------------------------------
Cmd.Exec.IF >STZ.G CMD.IFNOT
Cmd.INT.IF >STZ.G CMD.IFNOT
lda (ZPPtr2)
lda (ZPCMDBuf)
beq .9
cmp #'!'
@ -598,19 +573,19 @@ Cmd.Exec.IF >STZ.G CMD.IFNOT
lda #$ff
sta (pData),y Y = #CMD.IFNOT
jsr Cmd.Exec.GetNextP2NB
jsr Cmd.NextCharPtr2NB
beq .9
cmp #'('
bne .9
jsr Cmd.Exec.GetNextP2NB
jsr Cmd.NextCharPtr2NB
beq .9
cmp #'-' -d -e -f
bne .1
jsr Cmd.Exec.GetNextP2NB
jsr Cmd.NextCharPtr2NB
beq .9
@ -621,57 +596,144 @@ Cmd.Exec.IF >STZ.G CMD.IFNOT
>LDYA ZPPtr2
>LDYA ZPCMDBuf
>SYSCALL puts
jmp Cmd.Exec.Done
rts
.9 jmp Cmd.Exec.ERRSYN
*--------------------------------------
Cmd.Exec.GetArgs
ldy #$ff CMD Len
Cmd.InsertStrYAAtX
>STYA ZPPtr3 new string to insert
.1 iny
lda (ZPPtr1),y Get CMD char...
beq .2
cmp #' ' we reached blank between CMD ARGS
bne .1
>LDYA ZPCMDBuf
>STYA ZPPtr1
lda #0
sta (ZPPtr1),y Cut CMD with the ending 0
iny
.1 dex
bmi .2
.2 tya Y=CMD len+0, if ARGS="" Y=
clc
jsr Cmd.NextStrPtr1
>STYA ZPPtr1
bra .1
.2 >LDYA ZPPtr1
>STYA ZPPtr4 Save Arg[x] ptr
>LDYA ZPPtr3
>SYSCALL strlen
pha
tya
sec +1
adc ZPPtr1
sta ZPPtr2
lda ZPPtr1+1
adc #0
sta ZPPtr2+1 ZPPtr2->ARGS or CMD ending 0 if empty
* >LDYA L.CMD.IOR
* >STYA ZPPtr2
* ldx #0
pla
adc ZPPtr1+1
lda ZPPtr2+1
*.3 lda (ZPPtr2)
ldy #0
.3 lda (ZPPtr1),y
sta (ZPPtr2),y
beq .4
iny
bne .3
.4 tay
beq .5
jsr Cmd.NextStrPtr1
>STYA ZPPtr1
jsr Cmd.NextStrPtr2
>STYA ZPPtr2
bra .3
.5 ldy #0
.6 lda (ZPPtr3),y
sta (ZPPtr4),y
beq .8
iny
bne .6
.8 rts
*--------------------------------------
Cmd.RemoveStrAtX
>LDYA ZPCMDBuf
>STYA ZPPtr1
.1 dex
bmi .2
jsr Cmd.NextStrPtr1
>STYA ZPPtr1
bra .1
.2 jsr Cmd.NextStrPtr1
>STYA ZPPtr2
ldy #0
.3 lda (ZPPtr2),y
sta (ZPPtr1),y
beq .4
iny
bra .3
.4 tay we moved the ending \0
beq .8
jsr Cmd.NextStrPtr2
>STYA ZPPtr2
jsr Cmd.NextStrPtr1
>STYA ZPPtr1
bra .1
.8 rts
*--------------------------------------
Cmd.NextStrPtr1 >LDYA ZPPtr1
>SYSCALL strlen
pha
tya
sec +1
adc ZPPtr1
tay
pla
adc ZPPtr1+1
rts
*--------------------------------------
Cmd.Exec.GetArg1
Cmd.NextStrPtr2 >LDYA ZPPtr2
>SYSCALL strlen
pha
tya
sec +1
adc ZPPtr2
tay
pla
adc ZPPtr2+1
rts
*--------------------------------------
Cmd.Exec.GetNextP2NB
.1 jsr Cmd.Exec.GetNextP2
Cmd.NextCharPtr1
lda (ZPPtr1)
beq .8
inc ZPPtr1
bne .8
inc ZPPtr1+1 never Z
.8 rts
*--------------------------------------
Cmd.NextCharPtr2NB
.1 jsr Cmd.NextCharPtr2
beq .9
cmp #C.SPACE
beq .1
.9 rts
*--------------------------------------
Cmd.Exec.GetNextP2
Cmd.NextCharPtr2
inc ZPPtr2
bne .1
inc ZPPtr2+1

View File

@ -8,13 +8,14 @@ AUTO 4,1
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/MLI.I
.INB INC/MLI.E.I
*--------------------------------------
ZPPtr1 .EQ ZPBIN
ZPPtr2 .EQ ZPBIN+2
ZPCMDBuf .EQ ZPBIN+4
ZPArg1Buf .EQ ZPBIN+6
ZPArg2Buf .EQ ZPBIN+8
ZPPtr3 .EQ ZPBIN+4
ZPPtr4 .EQ ZPBIN+6
ZPCMDBuf .EQ ZPBIN+8
ZPCSHBufPtr .EQ ZPBIN+10
ZPCSHSymbols .EQ ZPBIN+12
ZPCSHData .EQ ZPBIN+14
@ -64,19 +65,19 @@ J.ESC .DA CL.BS left arrow
.DA HIS.GetPrev
.DA CL.NAK right arow
L.CMD.INT .DA CMD.INT
J.CMD.INT .DA Cmd.INT.CD
.DA Cmd.INT.DATE
.DA Cmd.INT.ECHO
.DA Cmd.INT.EXIT
.DA Cmd.INT.IF
.DA Cmd.INT.PAUSE
.DA Cmd.INT.PWD
.DA Cmd.INT.READ
.DA Cmd.INT.SET
.DA Cmd.INT.SLEEP
.DA Cmd.INT.STARTPROC
.DA Cmd.INT.TIME
L.CMD.IOR .DA CMD.IOR
J.CMD.INT .DA Cmd.Exec.CD
.DA Cmd.Exec.DATE
.DA Cmd.Exec.ECHO
.DA Cmd.Exec.EXIT
.DA Cmd.Exec.IF
.DA Cmd.Exec.PAUSE
.DA Cmd.Exec.PWD
.DA Cmd.Exec.READ
.DA Cmd.Exec.SET
.DA Cmd.Exec.SLEEP
.DA Cmd.Exec.STARTPROC
.DA Cmd.Exec.TIME
L.CSH.BOPS .DA CSH.BOPS
J.CSH.BOPS .DA CSH.BOPS.ADD
.DA CSH.BOPS.SUB
@ -125,7 +126,9 @@ L.ERR.Codes .DA ERR.Codes
L.ERR.Messages .DA ERR.Messages
.DA 0
*--------------------------------------
CS.INIT jsr SetPWD
CS.INIT
>DEBUG
jsr SetPWD
jsr CMD.Init
bcs .9
@ -135,6 +138,10 @@ CS.INIT jsr SetPWD
beq .1 no arg, continue starting interactive
lda #1
>SYSCALL GetArg
>SYSCALL puts
jmp CSH.Init
.1 jsr HIS.Init
@ -422,8 +429,8 @@ bSecureRead .BS 1
Sleep .BS 4
CMD.hCmdLine .BS 1
CMD.hFullpath .BS 1
CMD.bStartProc .BS 1
CMD.PSFlags .BS 1
CMD.VarName.LEN .BS 1
CMD.VarName .BS VarLen.MAX+1
CMD.Stat .BS S.STAT

View File

@ -113,9 +113,8 @@ Kernel.Init3 sta SETALTZP
jsr PS0.Init
>PUSHBI 0
>LDYAI MSG.Init3
>SYSCALL printf
>SYSCALL puts
jsr CPU.Init.6502
jsr CPU.Init.Z80
@ -149,20 +148,23 @@ Kernel.Init3 sta SETALTZP
>LDYAI MSG.MMode
>SYSCALL puts
>PUSHBI 0 PS Flags
>LDYAI STARTUP.SHELL
bra .8
.1 >PUSHWI STARTUP.CMDLINE
.1 >PUSHWI STARTUP.SCRIPT
>PUSHBI 2
>LDYAI MSG.Startup
>SYSCALL printf
>PUSHBI 0 PS Flags
>LDYAI STARTUP.CMDLINE
.8 >SYSCALL ExpandStr
phx Save Expanded CMDLINE for discard
>SYSCALL CreatePS
>SYSCALL Exec
bcs .9
pla
@ -597,7 +599,7 @@ IrqMgrInit.TClock
lda #$C1
sta ZPPtr1+1
.1 ldy #31
.1 ldy #TClock.SIG.Cnt-1
.2 lda (ZPPtr1),y
cmp TClock.SIG,y
@ -1010,6 +1012,7 @@ Mouse.SIG .HS 38180120D6
*--------------------------------------
TClock.SIG .HS 0878282c58ff700538b00118b8087848
.HS 8a489848adffcf201ac86868ba8df807
TClock.SIG.Cnt .EQ *-TClock.SIG
*--------------------------------------
MSG.Init2 .AZ "A2osX[Stage2]:Init\nRelocating Kernel...\n"
MSG.HZ .AZ "Kernel SYS Timer Set For %d0 hz Machine.\n"
@ -1018,9 +1021,9 @@ MSG.KCREAD.OK .AZ "OK\n"
MSG.KCREAD.KO .AZ "\nError While Reading Kernel Config File, Using Default.\n"
MSG.Init2.OK .AZ "A2osX[Stage2]:Complete.\n"
*--------------------------------------
SYSSCREEN.TOP .AZ "A2osX 0.92 System Screen"
SYSSCREEN.TOP .AZ "A2osX 0.92 Console"
MSG.Init3 .AS "A2osX[Stage3]:Init "
.AZ "*** Press Ctrl-D for Mantenance Mode ***\r\n"
.AZ "*** Press Ctrl-D for Mantenance Mode ***"
MSG.DEV .AZ "Device Manager..."
MSG.BLKDEV .AZ " Adding : /DEV/%s\r\n"
MSG.IRQ .AZ "Interrupt Manager..."
@ -1057,7 +1060,10 @@ I.ENV.PATH .AZ "PATH=${A2OSX}SBIN/;${A2OSX}BIN/"
I.ENV.LIB .AZ "LIB=${A2OSX}LIB/"
I.ENV.DRV .AZ "DRV=${A2OSX}DRV/"
STARTUP.SHELL .AZ "${A2OSX}SBIN/SHELL"
STARTUP.CMDLINE .AZ "${A2OSX}SBIN/SHELL ${A2OSX}A2osX.STARTUP"
.HS 00
STARTUP.CMDLINE .AZ "${A2OSX}SBIN/SHELL"
STARTUP.SCRIPT .AZ "${A2OSX}A2osX.STARTUP"
.HS 00
*--------------------------------------
MLIOPEN00 .DA #3
.DA A2OSXCONF

View File

@ -98,11 +98,11 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.LoadDrv
.DA K.InsDrv
.DA K.ExecPSNewEnv $A0
.DA K.ExecPS
.DA K.CreatePSNewEnv
.DA K.CreatePS
.DA 0 $A0
.DA 0
.DA 0
.DA 0
.DA K.Exec
.DA K.GetMemStat
.DA K.GetPSStatus
.DA K.GetPSStat

View File

@ -1,35 +1,29 @@
NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
PS.Flags .BS 1
PS.Args .BS 2
*/--------------------------------------
* # ExecPSNewEnv
* # ExecPS (Blocking Parent PID)
* # CreatePSNewEnv
* # CreatePS (Non Blocking)
* **In:**
* Y,A = PTR To Cmd Line
* # Exec
* ## C
* `int exec(const char* argv[], short int flags);`
* ## ASM
* `>PUSHB flags`
* `>LDYA argv`
* `>SYSCALL exec`
* ## RETURN VALUE
* A = Child PSID
* A = Child PSID
*\--------------------------------------
K.ExecPSNewEnv ldx #S.PS.F.DUPENV+S.PS.F.HOLD
.HS 2C bit abs
K.ExecPS ldx #S.PS.F.HOLD
.HS 2C bit abs
K.CreatePSNewEnv
ldx #S.PS.F.DUPENV
.HS 2C bit abs
K.CreatePS ldx #0
stx PS.Flags
>STYA PS.CL
K.Exec >STYA PS.Args
>PULLB PS.Flags
jsr PS.CreateChild Child S.PS at ZPPtr3
K.Exec.I jsr PS.CreateChild Child S.PS at ZPPtr3
bcs .9
sta .8+1
>LDYA PS.CL
jsr PS.CmdLine2Args Y,A = Args[0]
bcs .9
>LDYA PS.Args /path/cmd \0
jsr PS.Load
bcc .8
@ -44,29 +38,6 @@ K.CreatePS ldx #0
.8 lda #$ff self modified
.9 rts
*--------------------------------------
PS.Flags .BS 1
PS.CL .BS 2
PS.Args .BS 2
*/--------------------------------------
* # Exec
* ## C
* `int exec(const char *path, char *const argv[], short int flage);`
* ## ASM
* `>PUSHB flags`
* `>PUSHW argv`
* `>LDYAI path`
* `>SYSCALL exec`
* ## RETURN VALUE
* A = Child PSID
*\--------------------------------------
Exec
* >STYA PS.CL
* >PULLB PS.Flags
* >PULLW PS.Args
clc
rts
*--------------------------------------
* PS.CreateChild
* in :
* out :
@ -125,7 +96,7 @@ PS.CreateChild ldx #0
sta (ZPPtr3),y
lda #S.PS.F.DUPENV
bit PS.Flags need to create ENV & Prefix ?
bit PS.Flags need to create ENV & Prefix ?
beq .6 no...
sta (ZPPtr3) Mark this PS with DUPENV flag
@ -159,7 +130,16 @@ PS.CreateChild ldx #0
lda (pPs),y
sta (ZPPtr3),y
.8 ldy #S.PS.hStdIn
.8 >LDYA PS.Args
jsr PS.DupArgs
ldy #S.PS.hARGS
sta (ZPPtr3),y
dey S.PS.ARGC
txa
sta (ZPPtr3),y
ldy #S.PS.hStdIn
.81 lda (pPs),y
sta (ZPPtr3),y
@ -178,7 +158,7 @@ PS.CreateChild ldx #0
beq .82
ora (pPs)
sta (pPs) HOLD parent PS if ExecPS
sta (pPs) HOLD parent PS
.82 lda #S.PS.F.INIT
ora (ZPPtr3)
@ -191,88 +171,6 @@ PS.CreateChild ldx #0
clc Exit with A=PSID
.9 rts
*--------------------------------------
PS.CmdLine2Args >STYA ZPPtr1
ldy #0
.1 lda (ZPPtr1),y compute strlen in Y,X
beq .2
iny
bne .1 max 255
.2 tya +2 for ending 0 for last string, and ending 0 for array
clc
adc #2
tay
lda #0
bcc .3
inc
.3 jsr K.GetMem
bcs .9
phy save PTR.LO
pha save PTR.HI
>STYA ZPPtr2
txa
ldy #S.PS.hARGS
sta (ZPPtr3),y
jsr PS.SetMemOwner Set Ownership
stz PS.bInQuote
ldy #$ff
ldx #0 Arg Count
.4 iny
lda (ZPPtr1),y
beq .7
cmp #'"' found a quote ?
bne .5
lda PS.bInQuote
eor #$ff
sta PS.bInQuote
bra .4
.5 cmp #' '
bne .6
bit PS.bInQuote
bmi .6
inx Found one arg !!!
lda #0 set this token End
.6 sta (ZPPtr2)
inc ZPPtr2
bne .4
inc ZPPtr2+1
bra .4
.7 sta (ZPPtr2) set Arg Ending 0
inc ZPPtr2
bne .8
inc ZPPtr2+1
.8 sta (ZPPtr2) set Array Ending 0
txa
ldy #S.PS.ARGC
sta (ZPPtr3),y
pla get back PTR.HI
ply get back PTR.LO
clc
.9 rts
PS.bInQuote .BS 1
*--------------------------------------
PS.Load jsr BIN.Load Y,A=filename full path
bcs .9
>STYA ZPPtr4 save PTR to Code Segment
@ -368,42 +266,44 @@ PS.Load jsr BIN.Load Y,A=filename full path
* Y,A = Ptr To Args[]
* Out:
* A = hMem
* X = Count
*--------------------------------------
PS.DupArgs >STYA ZPPtr1
>STYA ZPPtr3
>STYA ZPPtr2
lda #1 for array ending 0
sta ZPPtr2
stz ZPPtr2+1
lda #1
sta .7+1
lda #0
sta .8+1 len = 1 for array ending 0
.1 lda (ZPPtr3)
.1 lda (ZPPtr2)
beq .8
ldy #0
.2 iny
lda (ZPPtr3),y
lda (ZPPtr2),y
bne .2
tya
sec
adc ZPPtr2
sta ZPPtr2
adc .7+1
sta .7+1
bcc .3
clc
inc ZPPtr2+1
inc .8+1
.3 tya
sec
adc ZPPtr3
sta ZPPtr3
adc ZPPtr2
sta ZPPtr2
bcc .1
inc ZPPtr3+1
inc ZPPtr2+1
bra .1
.8 >LDYA ZPPtr2
.7 ldy #$ff SELF MODIFIED
.8 lda #$ff SELF MODIFIED
bra PS.Dup.I
*--------------------------------------
* PS.DupEnv
@ -411,6 +311,7 @@ PS.DupArgs >STYA ZPPtr1
* A = ENV hMem To Duplicate
* Out:
* A = hMem to new ENV
* X = Count
*--------------------------------------
PS.DupEnv jsr K.GetMemPtr
>STYA ZPPtr1
@ -421,31 +322,42 @@ PS.Dup.I jsr K.GetMem
bcs .9
>STYA ZPPtr2
phx save hMem
jsr PS.SetMemOwner Set Ownership
ldx #0 Count
.1 lda (ZPPtr1)
sta (ZPPtr2)
beq .8 Ending \0
inx
ldy #0
.1 lda (ZPPtr1),y
sta (ZPPtr2),y
beq .8
.2 iny
bne .3
inc ZPPtr1+1
inc ZPPtr2+1
.3 lda (ZPPtr1),y
lda (ZPPtr1),y
sta (ZPPtr2),y
bne .2
iny
bne .1
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .3
inc ZPPtr1+1
.3 tya
sec
adc ZPPtr2
sta ZPPtr2
bcc .1
inc ZPPtr2+1
bra .1
.8 txa hMem
.8 pla hMem
clc
.9 rts