Kernel 0.9.2

This commit is contained in:
Rémy GIBERT 2018-10-12 17:47:57 +02:00
parent 026a9cc3dc
commit ba1a76d4df
6 changed files with 89 additions and 68 deletions

Binary file not shown.

Binary file not shown.

View File

@ -16,14 +16,26 @@ CMD.Quit >LDA.G hCmdBuf
>SYSCALL FreeMem >SYSCALL FreeMem
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
* in:
* ZPCMDBuf : CString command line
* out:
* ZPCMDBuf : Remove extra SPACE & comment * ZPCMDBuf : Remove extra SPACE & comment
* ZPCMDBuf : cmd\0 arg1\0 arg2\0 ... \0
*-------------------------------------- *--------------------------------------
Cmd.Parse >LDYA ZPCMDBuf Cmd.Parse >LDYA ZPCMDBuf
>STYA ZPPtr1 >SYSCALL ExpandStr
>STYA ZPPtr1 Ptr to expanded CMD ARGS\0
txa
>STA.G CMD.hCmdLine
* SET +X
>LDYA ZPCMDBuf
>SYSCALL puts
ldy #0 ldy #0
lda (ZPCMDBuf) empty line...quit lda (ZPPtr1) empty line...quit
beq .9 beq .9
.1 jsr Cmd.Parse.NextC .1 jsr Cmd.Parse.NextC
@ -44,7 +56,8 @@ Cmd.Parse >LDYA ZPCMDBuf
cmp #' ' cmp #' '
bne .3 bne .3
sta (ZPCMDBuf),y add One SPACE to buffer lda #0
sta (ZPCMDBuf),y add One \0 to buffer
iny iny
.5 jsr Cmd.Parse.NextC .5 jsr Cmd.Parse.NextC
@ -59,6 +72,10 @@ Cmd.Parse >LDYA ZPCMDBuf
.9 tya .9 tya
>STA.G CmdBuflen >STA.G CmdBuflen
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem
rts rts
Cmd.Parse.NextC lda (ZPPtr1) Cmd.Parse.NextC lda (ZPPtr1)
@ -69,81 +86,43 @@ Cmd.Parse.NextC lda (ZPPtr1)
inc ZPPtr1+1 never Z inc ZPPtr1+1 never Z
.8 rts .8 rts
*-------------------------------------- *--------------------------------------
* ZPCMDBuf-> Command line (formatted & not empty) * ZPCMDBuf-> argv[] (formatted & not empty)
*-------------------------------------- *--------------------------------------
CMD.Exec lda #0 CMD.Exec lda #0
>STA.G CMD.bStartProc >STA.G CMD.bStartProc
>STA.G CMD.hFullpath >STA.G CMD.hFullpath
* SET +X
* >LDYA ZPCMDBuf
* >SYSCALL puts
* sta $C055
* >DEBUG
>LDYA ZPCMDBuf
>SYSCALL ExpandStr
>STYA ZPPtr1 Ptr to CMD ARGS
txa
>STA.G CMD.hCmdLine
>LDYA L.CMD.INT >LDYA L.CMD.INT
>STYA ZPPtr2 >STYA ZPPtr2
ldx #0 ldx #0
.3 lda (ZPPtr2) .1 phx
beq Cmd.Exec.EXT Array Ending 0, must be an external Cmd....
ldy #$ff >PUSHW ZPPtr2
>LDYA ZPCMDBuf
>SYSCALL StrCaseCmp
plx
bcc .8
.4 iny inx
lda (ZPPtr2),y
bne .41 End of string in array
lda (ZPPtr1),y Get CMD char...
beq .8 both end with 0, found!
cmp #' '
beq .8 we reached space between CMD & ARGS....
.41 lda (ZPPtr1),y Get CMD char...
beq .61 end of CMD.....too short...
cmp #' '
beq .61 we reached space between CMD & ARGS....
cmp #'a' To Uppercase
bcc .5
cmp #'z'+1
bcs .5
eor #$20
.5 cmp (ZPPtr2),y
beq .4
.61 iny
lda (ZPPtr2),y
bne .61
.7 inx
inx inx
tya lda (ZPPtr2)
beq Cmd.Exec.EXT Array Ending 0, must be an external Cmd....
sec sec
adc ZPPtr2 adc ZPPtr2
sta ZPPtr2 sta ZPPtr2
bcc .3 bcc .1
inc ZPPtr2+1 inc ZPPtr2+1
bra .3 bra .1
.8 jsr Cmd.Exec.GetArgs X unmodified .8 jsr Cmd.Exec.GetArgs X unmodified
jmp (J.CMD.INT,x) Found an internal Cmd... jmp (J.CMD.INT,x) Found an internal Cmd...
*-------------------------------------- *--------------------------------------
Cmd.Exec.Done php Cmd.Exec.Done php
pha pha
>LDA.G CMD.hCmdLine
>SYSCALL FreeMem
>LDA.G CMD.hFullpath >LDA.G CMD.hFullpath
beq .1 beq .1
>SYSCALL FreeMem >SYSCALL FreeMem

View File

@ -196,7 +196,7 @@ CS.RUN >LDA.G bReadMode READ Command ?
jsr CMD.Parse jsr CMD.Parse
>LDA.G CmdBuflen lda (ZPCMDBuf)
beq .10 Empty line beq .10 Empty line
jsr HIS.Add jsr HIS.Add

View File

@ -46,6 +46,7 @@ K.CreatePS ldx #0
*-------------------------------------- *--------------------------------------
PS.Flags .BS 1 PS.Flags .BS 1
PS.CL .BS 2 PS.CL .BS 2
PS.Args .BS 2
*/-------------------------------------- */--------------------------------------
* # Exec * # Exec
* ## C * ## C
@ -58,7 +59,13 @@ PS.CL .BS 2
* ## RETURN VALUE * ## RETURN VALUE
* A = Child PSID * A = Child PSID
*\-------------------------------------- *\--------------------------------------
Exec Exec
* >STYA PS.CL
* >PULLB PS.Flags
* >PULLW PS.Args
clc
rts
*-------------------------------------- *--------------------------------------
* PS.CreateChild * PS.CreateChild
* in : * in :
@ -356,13 +363,48 @@ PS.Load jsr BIN.Load Y,A=filename full path
clc clc
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
* PS.DupEnv * PS.DupArgs
* In: * In:
* A = ENV hMem To Duplicate * Y,A = Ptr To Args[]
* Out: * Out:
* A = hMem to new ENV * A = hMem
*-------------------------------------- *--------------------------------------
PS.DupArgs PS.DupArgs >STYA ZPPtr1
>STYA ZPPtr3
lda #1 for array ending 0
sta ZPPtr2
stz ZPPtr2+1
.1 lda (ZPPtr3)
beq .8
ldy #0
.2 iny
lda (ZPPtr3),y
bne .2
tya
sec
adc ZPPtr2
sta ZPPtr2
bcc .3
clc
inc ZPPtr2+1
.3 tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .1
inc ZPPtr3+1
bra .1
.8 >LDYA ZPPtr2
bra PS.Dup.I
*-------------------------------------- *--------------------------------------
* PS.DupEnv * PS.DupEnv
* In: * In:
@ -374,7 +416,8 @@ PS.DupEnv jsr K.GetMemPtr
>STYA ZPPtr1 >STYA ZPPtr1
>LDYAI K.ENV.SIZE >LDYAI K.ENV.SIZE
jsr K.GetMem
PS.Dup.I jsr K.GetMem
bcs .9 bcs .9
>STYA ZPPtr2 >STYA ZPPtr2

View File

@ -12,21 +12,20 @@ AUTO 4,1
* ## RETURN VALUE * ## RETURN VALUE
* Y,A = String length * Y,A = String length
*\-------------------------------------- *\--------------------------------------
K.StrLen >STYA ZPPtr1 K.StrLen >STYA .1+1
ldy #0 ldy #0
ldx #0 tya
.1 lda (ZPPtr1),y .1 ldx $ffff,y SELF MODIFIED
beq .8 beq .8
iny iny
bne .1 bne .1
inx inc
inc ZPPtr1+1 inc .1+2
bra .1 bra .1
.8 txa .8 rts
rts
*/-------------------------------------- */--------------------------------------
* # StrCat * # StrCat
* Concatenate strings * Concatenate strings