Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-10-25 17:31:41 +02:00
parent 5b5b785a26
commit 382be33060
12 changed files with 120 additions and 83 deletions

View File

@ -1,14 +1,18 @@
*** Auto generated by docgen.cmd ***
# Args2ArgV
int args2argv(char* args, char* argv[])
Expand String and convert to ArgV List
## C
short int args2argv(char* args, char* argv[])
## ASM
`>PUSHW argv`
`>LDYA args`
`>SYSCALL Args2ArgV
## RETURN VALUE
## RETURN VALUE
A = Arg count
# ArgV
@ -540,7 +544,20 @@ Load a file in AUX memory (Stock Objects)
Y,A = File Length
X = hMem of Loaded Object in AUX mem
# Exec
# ExecL
## C
`int execl(const char* cmdline, short int flags);`
## ASM
`>PUSHB flags`
`>LDYA cmdline`
`>SYSCALL execl`
## RETURN VALUE
A = Child PSID
# ExecV
## C
`int exec(const char* argv[], short int flags);`

Binary file not shown.

Binary file not shown.

View File

@ -215,8 +215,8 @@ SYS.UnloadLib .EQ $9A
SYS.LoadDrv .EQ $9C
SYS.InsDrv .EQ $9E
*--------------------------------------
SYS.Exec .EQ $A0
* .EQ $A2
SYS.ExecL .EQ $A0
SYS.ExecV .EQ $A2
* .EQ $A4
* .EQ $A6

View File

@ -117,14 +117,9 @@ CS.RUN.LOOP1 >SLEEP
.2 >PUSHBI S.PS.F.DUPENV+S.PS.F.HOLD
lda #2
>SYSCALL ArgV
>SYSCALL puts
lda #2
>SYSCALL ArgV
>SYSCALL Exec
>SYSCALL ExecV
bcs CS.RUN.9
>SLEEP

View File

@ -94,8 +94,7 @@ CS.RUN lda #0
>PUSHBI S.PS.F.HOLD
>LDYA L.SHELL
>SYSCALL Exec
>SYSCALL ExecL
rts
*--------------------------------------
CS.DOEVENT

View File

@ -29,18 +29,10 @@ Cmd.Parse >STZ.G CMD.bCmd
lda #S.PS.F.HOLD+S.PS.F.DUPENV
>STA.G CMD.PSFlags
>LDYA ZPCMDBuf
>SYSCALL ExpandStr
bcs .9
phx save expanded string
pha
>PUSHW ZPCMDBuf
pla Y,A = expanded string
>LDYA ZPCMDBuf
>SYSCALL Args2ArgV
pla Get Back expanded string
>SYSCALL FreeMem
>LDYAI 256
>SYSCALL GetMem
@ -107,12 +99,17 @@ Cmd.CheckCmd ldy #$ff
bra .6 go check type...
.2 >LDYA L.CMD.INT
jsr CMD.SearchInt no / found, search internal...
jsr CMD.Search no / found, search internal...
bcs .4 not internal, search PATH
phx
plx
beq .3 if STARTPROC, skip keyword
jsr CMD.AddYAToArgV X unmodified
bcs .9
txa
.3 txa
>STA.G CMD.bCmd
clc
@ -212,7 +209,7 @@ Cmd.Exec lda (ZPArgVBuf)
.1 >PUSHB.G CMD.PSFlags
>LDYA ZPArgVBuf
>SYSCALL exec
>SYSCALL execv
rts
*--------------------------------------
* STARTPROC : intcmd = 0
@ -453,7 +450,8 @@ Cmd.INT.ECHO ldx #1
.8 clc
.9 rts
*--------------------------------------
Cmd.INT.READ lda (ZPCMDBuf)
Cmd.INT.READ ldx #1
jsr Cmd.GetArgX
beq .9
lda #0
@ -667,7 +665,7 @@ CMD.AddYAToArgV >STYA ZPPtr1
sec
rts
*--------------------------------------
CMD.SearchInt >STYA ZPPtr2
CMD.Search >STYA ZPPtr2
ldx #0
@ -680,7 +678,7 @@ CMD.SearchInt >STYA ZPPtr2
plx
>LDYA ZPPtr2
clc Found an internal Cmd...
clc
rts
.2 inc ZPPtr2

View File

@ -3,28 +3,39 @@ PREFIX /A2OSX.BUILD
AUTO 4,1
*/--------------------------------------
* # Args2ArgV
* int args2argv(char* args, char* argv[])
* Expand String and convert to ArgV List
* ## C
* short int args2argv(char* args, char* argv[])
* ## ASM
* `>PUSHW argv`
* `>LDYA args`
* `>SYSCALL Args2ArgV
* ## RETURN VALUE
* ## RETURN VALUE
* A = Arg count
*\--------------------------------------
ARG.bInQuote .BS 1
*--------------------------------------
K.Args2ArgV jsr MEM.SPtr1PPtr2
K.Args2ArgV pha
>PULLW ZPPtr2 Get target buffer
pla
K.Args2ArgV.I jsr K.ExpandStr
bcs .9
>STYA ZPPtr1
stx .80+1
ldx #0 Arg Count
ldx #0 Arg Count
stz ARG.bInQuote
.1 jsr ARG.GetCharPtr1
.1 jsr MEM.GetCharPtr1
beq .8
cmp #C.SPACE
beq .1 skip leading spaces
beq .1 skip leading spaces
.2 cmp #'"' found a quote ?
.2 cmp #'"' found a quote ?
bne .3
lda ARG.bInQuote
@ -40,24 +51,28 @@ K.Args2ArgV jsr MEM.SPtr1PPtr2
inx Found one arg !!!
lda #0 set this token End
jsr ARG.PutCharPtr2
jsr MEM.PutCharPtr2
bra .1
.6 jsr ARG.PutCharPtr2
.6 jsr MEM.PutCharPtr2
.7 jsr ARG.GetCharPtr1
.7 jsr MEM.GetCharPtr1
bne .2
inx
.8 jsr ARG.PutCharPtr2 set Argv[x] Ending 0
.8 jsr MEM.PutCharPtr2 set Argv[x] Ending 0
sta (ZPPtr2) set Array Ending 0
phx
txa X=Arg Count
.80 lda #$FF SELF MODIFIED
jsr K.FreeMem Discard expanded string
pla get back Arg Count
clc
.9 rts
* clc
.9 rts
*/--------------------------------------
* # ArgV
* ## ASM
@ -83,10 +98,10 @@ K.ArgV tax save requested arg#
dex
bmi .7
.3 jsr ARG.GetCharPtr1 skip str
.3 jsr MEM.GetCharPtr1 skip str
bne .3
jsr ARG.NextCharPtr1 skip \0
jsr MEM.NextCharPtr1 skip \0
bra .1
.7 >LDYA ZPPtr1
@ -97,21 +112,6 @@ K.ArgV tax save requested arg#
.9 sec
rts
*--------------------------------------
ARG.GetCharPtr1 lda (ZPPtr1)
beq ARG.GetCharPtr1.8
ARG.NextCharPtr1
inc ZPPtr1
bne ARG.GetCharPtr1.8
inc ZPPtr1+1 never Z
ARG.GetCharPtr1.8
rts
*--------------------------------------
ARG.PutCharPtr2 sta (ZPPtr2)
inc ZPPtr2
bne .8
inc ZPPtr2+1
.8 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.ARG
LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -140,16 +140,17 @@ Kernel.Init3 sta SETALTZP
>LDYAI MSG.Prefix
>SYSCALL printf
* lda KBD
* bpl .1
* sta KBDSTROBE
* cmp #$84 CTRL-D for Maintenace mode
* bne .1
lda KBD
bpl .1
sta KBDSTROBE
cmp #$84 CTRL-D for Maintenace mode
bne .1
>PUSHBI 0
>LDYAI MSG.MMode
>SYSCALL printf
>PUSHBI 0 PS Flags
>LDYAI STARTUP.SHELL
bra .8
@ -158,25 +159,14 @@ Kernel.Init3 sta SETALTZP
>LDYAI MSG.Startup
>SYSCALL printf
>PUSHBI 0 PS Flags
>LDYAI STARTUP.CMDLINE
.8 >SYSCALL ExpandStr
phx
pha
>PUSHWI K.Buf256
pla
>SYSCALL Args2ArgV
pla
jsr K.FreeMem
>PUSHBI 0 PS Flags
>LDYAI K.Buf256
>SYSCALL Exec
.8 >SYSCALL ExecL
bcs .9
>PUSHBI 1
>PUSHBI 0
>LDYAI MSG.Init3.OK
>SYSCALL printf

View File

@ -98,8 +98,8 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.LoadDrv
.DA K.InsDrv
.DA K.Exec $A0
.DA 0
.DA K.ExecL $A0
.DA K.ExecV
.DA 0
.DA 0
.DA 0

View File

@ -685,6 +685,21 @@ MEM.SPtr1PPtr2 >STYA ZPPtr1
>PULLW ZPPtr2
rts
*--------------------------------------
MEM.GetCharPtr1 lda (ZPPtr1)
beq MEM.GetCharPtr1.8
MEM.NextCharPtr1
inc ZPPtr1
bne MEM.GetCharPtr1.8
inc ZPPtr1+1 never Z
MEM.GetCharPtr1.8
rts
*--------------------------------------
MEM.PutCharPtr2 sta (ZPPtr2)
inc ZPPtr2
bne .8
inc ZPPtr2+1
.8 rts
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.MEM
LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -5,7 +5,30 @@ AUTO 4,1
PS.Flags .BS 1
PS.Args .BS 2
*/--------------------------------------
* # Exec
* # ExecL
* ## C
* `int execl(const char* cmdline, short int flags);`
* ## ASM
* `>PUSHB flags`
* `>LDYA cmdline`
* `>SYSCALL execl`
* ## RETURN VALUE
* A = Child PSID
*\--------------------------------------
K.ExecL pha
lda #K.Buf256
sta ZPPtr2
lda /K.Buf256
sta ZPPtr2+1
pla
jsr K.Args2ArgV.I
bcc .1
>RET 1 discard flags
.1 >LDYAI K.Buf256
*/--------------------------------------
* # ExecV
* ## C
* `int exec(const char* argv[], short int flags);`
* ## ASM
@ -15,9 +38,9 @@ PS.Args .BS 2
* ## RETURN VALUE
* A = Child PSID
*\--------------------------------------
K.Exec >STYA PS.Args
K.ExecV >STYA PS.Args
>PULLB PS.Flags
jsr PS.CreateChild Child S.PS at ZPPtr3
bcs .9