Kernel 0.9.1 : Code reorganization & move to CSTR : ENV & SHELL

This commit is contained in:
Rémy GIBERT 2017-09-11 08:11:57 +02:00
parent ea86f48bc7
commit 56cdcf925a
9 changed files with 195 additions and 213 deletions

View File

@ -92,7 +92,7 @@ Returns argument count in the process command line.
# PutEnv.YA # PutEnv.YA
## In: ## In:
+ Y,A = PTR to String NAME=VALUE (PSTR) + Y,A = PTR to String NAME=VALUE (C-String)
## Out: ## Out:
@ -193,19 +193,6 @@ And return, if found, the full path to it.
+ PUSHW = GID + PUSHW = GID
+ PUSHW = PATH + PUSHW = PATH
# NewPStrYA
Create a new copy of PSTR
## In:
+ Y,A = PTR to buffer
## Out:
+ CC : success
+ Y,A = PTR to String
+ X = hMem (PSTR)
+ CS : error
+ A = SYS error code
# GetMem # GetMem
## In: ## In:
@ -272,22 +259,27 @@ Create a new copy of PSTR
+ Y,A = ZPMemMgrSPtr = PTR to S.MEM + Y,A = ZPMemMgrSPtr = PTR to S.MEM
+ X unmodified + X unmodified
# NewStr.YA
Create a new copy of this C-String
## In:
+ Y,A = Ptr to source C-String
## Out:
+ CC : success
+ Y,A = PTR to String
+ X = hMem (PSTR)
+ CS : error
+ A = SYS error code
# GetMemStat.YA # GetMemStat.YA
## In: ## In:
+ Y,A = 24 bytes buffer + Y,A = Ptr to 24 bytes buffer
## Out: ## Out:
+ Buffer filled with memory stats + Buffer filled with memory stats
# GetPSByID.A
## In :
+ A = PID
## Out :
+ Y,A = PTR to TSKSLOT
# Sleep # Sleep
Make current process suspend until next RUN Make current process suspend until next RUN

Binary file not shown.

Binary file not shown.

View File

@ -73,13 +73,13 @@ Cmd.Exec stz bStartProc
>LDYA ZPCMDBuf >LDYA ZPCMDBuf
Cmd.ExecYA >SYSCALL ExpandStr.YA >SYSCALL ExpandStr.YA
>STYA ZPPtr1 Ptr to CMD >STYA ZPPtr1 Ptr to CMD
txa txa
>STA.G CMD.hCmdLine >STA.G CMD.hCmdLine
>LDYA ZPPtr1 Cmd.ExecYA >LDYA ZPPtr1
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR jsr Cmd.Exec.ECHO.CR
>DEBUG >DEBUG
@ -135,7 +135,6 @@ Cmd.ExecYA >SYSCALL ExpandStr.YA
cmp (ZPPtr2),y cmp (ZPPtr2),y
bne .4 bne .4
dey dey
dey
bne .5 bne .5
ply get back Cmd Len ply get back Cmd Len
@ -400,45 +399,57 @@ Cmd.Exec.STARTPROC
ror bStartProc ror bStartProc
>LDYA ZPPTR2 >LDYA ZPPTR2
>STYA ZPPTR1
jmp Cmd.ExecYA jmp Cmd.ExecYA
*-------------------------------------- *--------------------------------------
Cmd.Exec.SET lda (ZPPTR2) Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR bne Cmd.Exec.SETVAR
* No arg, print all ENV
ldy #S.PS.hENV ldy #S.PS.hENV
lda (pPs),y lda (pPs),y
>SYSCALL GetMemPtr.A >SYSCALL GetMemPtr.A
>STYA ZPPTR1 >STYA ZPPTR1
* No arg, print all ENV
.1 lda (ZPPTR1) .1 lda (ZPPTR1)
beq .8 Ending 0 ? beq .8 Ending 0 ?
lda ZPPTR1 get next for value ldy #$ff
sec
adc (ZPPTR1) Add len+1 to PTR
sta ZPPTR2
lda ZPPTR1+1
adc #0
sta ZPPTR2+1
lda (ZPPTR2) just in case... .2 iny
beq .8 lda (ZPPTR1),y
bne .2
tya
sec
adc ZPPTR1
sta ZPPTR2
lda #0
adc ZPPTR1+1
sta ZPPTR2+1
>PUSHW ZPPTR2 Push value >PUSHW ZPPTR2 Push value
>PUSHW ZPPTR1 Push name >PUSHW ZPPTR1 Push name
>LDYA L.MSG.PRINTENV >LDYA L.MSG.PRINTENV
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
>DEBUG
bcs .9 bcs .9
lda ZPPTR2 ldy #$ff
.3 iny
lda (ZPPTR2),y
bne .3
tya
sec sec
adc (ZPPTR2) Add len+1 to PTR adc ZPPTR2
sta ZPPTR1 sta ZPPTR1
lda ZPPTR2+1 lda #0
adc #0 adc ZPPTR2+1
sta ZPPTR1+1 sta ZPPTR1+1
bra .1 bra .1

View File

@ -553,7 +553,7 @@ MSG.ECHO >CSTR ">%S\r\n"
MSG.PSTRCR >CSTR "%S\r\n" MSG.PSTRCR >CSTR "%S\r\n"
MSG.PSTR >CSTR "%S" MSG.PSTR >CSTR "%S"
MSG.ERROR >CSTR "Err:%S [%h]\r\n" MSG.ERROR >CSTR "Err:%S [%h]\r\n"
MSG.PRINTENV >CSTR "%S=%S\r\n" MSG.PRINTENV >CSTR "%s=%s\r\n"
MSG.CSHERR >PSTR "Pos %D:" MSG.CSHERR >PSTR "Pos %D:"
FMT.DATE >CSTR "%A, %B %d %Y" FMT.DATE >CSTR "%A, %B %d %Y"
FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)" FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)"

View File

@ -47,10 +47,10 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
bra .11 bra .11
.23 ldx K.ExpandStr.bInVar already in a var? .23 ldx K.ExpandStr.bInVar already in a var?
bne .3 yes.... bne .3 yes...
cmp #'$' no, found one ? cmp #'$' no, found one ?
bne .22 no, store.... bne .22 no, store...
sta K.ExpandStr.bFound Toggle flag sta K.ExpandStr.bFound Toggle flag
sta K.ExpandStr.bInVar sta K.ExpandStr.bInVar
@ -186,7 +186,7 @@ K.PutEnv.YA >STYA ZPPtr1 NAME=VALUE
sta K.Buf256,y sta K.Buf256,y
tya tya
clc sec
adc ZPPtr1 adc ZPPtr1
sta ZPPtr2 sta ZPPtr2
lda ZPPtr1+1 lda ZPPtr1+1
@ -207,76 +207,102 @@ K.PutEnv.YA >STYA ZPPtr1 NAME=VALUE
* ## Out: * ## Out:
*\-------------------------------------- *\--------------------------------------
K.SetEnv jsr PullPtr1Ptr2 Ptr1=NAME,Ptr2=VALUE K.SetEnv jsr PullPtr1Ptr2 Ptr1=NAME,Ptr2=VALUE
K.SetEnvPtr1Ptr2 K.SetEnvPtr1Ptr2
jsr S.UnsetEnvPtr1 jsr S.UnsetEnvPtr1
jsr ENV.InitEnvPtr3 ZPPtr3 -> Env jsr ENV.InitEnvPtr3 ZPPtr3 -> Env
lda ZPPtr3 Compute ENV UPPER LIMIT in Ptr4 ldy #0
clc ldx #0
adc #K.ENV.SIZE
sta ZPPtr4
lda ZPPtr3+1 .10 lda (ZPPtr3) End of ENV
adc /K.ENV.SIZE beq .15
sta ZPPtr4+1
ldy ZPPtr3+1 .11 iny Compute ENV size in X,Y
lda ZPPtr3 Compute New Env Upper limit in A,Y bne .12
inx
.12 inc ZPPtr3
bne .13
inc ZPPtr3+1
.13 lda (ZPPtr3) End of string
bne .11
iny
bne .14
inx
.14 inc ZPPtr3
bne .10
inc ZPPtr3+1
bra .10
.15 sty ZPPtr4
stx ZPPtr4+1
ldy #0
.16 lda (ZPPtr1),y
beq .17
iny
bne .16
.17 tya
sec sec
adc (ZPPtr1) add NAME len +1 adc ZPPtr4
bcc .1 sta ZPPtr4
iny bcc .18
inc ZPPtr4+1
.1 sec .18 ldy #0
adc (ZPPtr2) add VALUE len +1
bcc .2
iny
.2 cmp ZPPtr4 GE than hMem Upper limit ? .19 lda (ZPPtr2),y
tya beq .20
sbc ZPPtr4+1 iny
bne .19
.20 tya
sec
adc ZPPtr4
tax
bcc .21
inc ZPPtr4+1
.21 cpx #K.ENV.SIZE
lda ZPPtr4+1
sbc /K.ENV.SIZE
bcs .99 bcs .99
.3 lda (ZPPtr3) Scan until ending 0... ldy #$ff
beq .4
inc ZPPtr3 .22 iny
bne .3 lda (ZPPtr1),y
sta (ZPPtr3),y
bne .22
tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .23
inc ZPPtr3+1 inc ZPPtr3+1
bne .3
.4 lda (ZPPtr1) .23 ldy #$ff
sta (ZPPtr3)
tay
.5 lda (ZPPtr1),y .24 iny
lda (ZPPtr2),y
sta (ZPPtr3),y sta (ZPPtr3),y
dey bne .24
bne .5
jsr ENV.NextEnvPtr3 iny
.25 lda #0
lda (ZPPtr2) sta (ZPPtr3),y don't forget array ending 0
sta (ZPPtr3)
tay
.6 lda (ZPPtr2),y
sta (ZPPtr3),y
dey
bne .6
jsr ENV.NextEnvPtr3
.8 lda #0
sta (ZPPtr3)
clc clc
rts rts
.99 lda #SYSMGR.ERRENVF .99 lda #SYSMGR.ERRENVF
sec * sec
rts rts
*/-------------------------------------- */--------------------------------------
* # GetEnv.YA * # GetEnv.YA
@ -487,17 +513,24 @@ ENV.DiscardVarPtr3
ldy #0 ldy #0
.1 lda (ZPPtr3),y Move back CSTRs... .1 lda (ZPPtr3),y Move back CSTRs...
.2 sta (ZPPtr4),y .2 sta (ZPPtr4),y
beq .2 0 ended.... beq .3 0 ended....
iny iny
bne .1 bne .1
inc ZPPtr3 inc ZPPtr3+1
inc ZPPtr4 inc ZPPtr4+1
bra .1 bra .1
.3 iny .3 iny
lda (ZPPtr3),y bne .4
bne .3 Until array ending 0
inc ZPPtr3+1
inc ZPPtr4+1
.4 lda (ZPPtr3),y
bne .2 Until array ending 0
sta (ZPPtr4),y
.8 rts .8 rts
*-------------------------------------- *--------------------------------------
@ -529,14 +562,15 @@ ENV.AppendPtr3ToBuf
lda K.Buf256,x lda K.Buf256,x
bne .1 bne .1
ldy #0 ldy #$ff
dex
.2 lda (ZPPtr3),y .2 iny
inx
lda (ZPPtr3),y
sta K.Buf256,x sta K.Buf256,x
bne .2 bne .2
inx
stz K.Buf256,x
rts rts
*-------------------------------------- *--------------------------------------
MAN MAN

View File

@ -779,16 +779,27 @@ TskMgrInit >LDYAI MSG.TSK
>MLICALL MLIGETPREFIX >MLICALL MLIGETPREFIX
bcs .9 bcs .9
>LDYAI K.Buf256 ldy K.Buf256
jsr K.NewCStr.YA iny
bcs .9 lda #0
jsr K.GetMem.YA
>STYA ZPPtr1
txa txa
ldy #S.PS.hPREFIX ldy #S.PS.hPREFIX
sta (pPs),y sta (pPs),y
>PUSHWI K.Buf256 push ENV value ldy K.Buf256
>PUSHWI I.ENV.A2osX push ENV name lda #0
sta (ZPPtr1),y
.4 lda K.Buf256,y
dey
sta (ZPPtr1),y
bne .4
>PUSHW ZPPtr1 push ENV value = PREFIX
>PUSHWI I.ENV.A2osX push ENV name = A2OSX
>SYSCALL SetEnv >SYSCALL SetEnv
bcs .9 bcs .9

View File

@ -414,73 +414,7 @@ PullPtr1Ptr2 clc
bcc .9 bcc .9
>PULLW ZPPtr3 >PULLW ZPPtr3
.9 rts .9 rts
*/--------------------------------------
* # NewPStrYA
* Create a new copy of PSTR
* ## In:
* Y,A = PTR to buffer
* ## Out:
* CC : success
* Y,A = PTR to String
* X = hMem (PSTR)
* CS : error
* A = SYS error code
*\--------------------------------------
K.NewPStr.YA >STYA ZPPtr2
lda (ZPPtr2)
inc
tay
lda #0 Y,A = len of new string
jsr K.GetMem.YA
bcs .9
>STYA ZPPtr1
lda (ZPPtr2)
sta (ZPPtr1)
tay
beq .2
.1 lda (ZPPtr2),y
sta (ZPPtr1),y
dey
bne .1
.2 >LDYA ZPPtr1
clc
.9 rts
*-------------------------------------- *--------------------------------------
K.NewCStr.YA >STYA ZPPtr1
lda (ZPPtr1)
inc
tay
lda #0 Y,A = len of new string
jsr K.GetMem.YA
bcs .9
>STYA ZPPtr2
lda (ZPPtr1)
tay
phy
beq .2
.1 lda (ZPPtr1),y
dey
sta (ZPPtr2),y
bne .1
.2 ply
lda #0
sta (ZPPtr2),y
>LDYA ZPPtr1
clc
.9 rts
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.JMP SAVE /A2OSX.SRC/SYS/KERNEL.S.JMP
LOAD /A2OSX.SRC/SYS/KERNEL.S LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -366,7 +366,7 @@ K.FreeMem.A phy
>PUSHYA >PUSHYA
>LDYAI K.FreeMem.A.ERR >LDYAI K.FreeMem.A.ERR
jsr K.PrintF.YA >SYSCALL PrintF.YA
.91 ldx #$ff .91 ldx #$ff
bit $C000,x bit $C000,x