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
## In:
+ Y,A = PTR to String NAME=VALUE (PSTR)
+ Y,A = PTR to String NAME=VALUE (C-String)
## Out:
@ -193,19 +193,6 @@ And return, if found, the full path to it.
+ PUSHW = GID
+ 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
## In:
@ -272,22 +259,27 @@ Create a new copy of PSTR
+ Y,A = ZPMemMgrSPtr = PTR to S.MEM
+ 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
## In:
+ Y,A = 24 bytes buffer
+ Y,A = Ptr to 24 bytes buffer
## Out:
+ Buffer filled with memory stats
# GetPSByID.A
## In :
+ A = PID
## Out :
+ Y,A = PTR to TSKSLOT
# Sleep
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
Cmd.ExecYA >SYSCALL ExpandStr.YA
>SYSCALL ExpandStr.YA
>STYA ZPPtr1 Ptr to CMD
txa
>STA.G CMD.hCmdLine
>LDYA ZPPtr1
Cmd.ExecYA >LDYA ZPPtr1
>SYSCALL PrintF.YA
jsr Cmd.Exec.ECHO.CR
>DEBUG
@ -135,7 +135,6 @@ Cmd.ExecYA >SYSCALL ExpandStr.YA
cmp (ZPPtr2),y
bne .4
dey
dey
bne .5
ply get back Cmd Len
@ -400,45 +399,57 @@ Cmd.Exec.STARTPROC
ror bStartProc
>LDYA ZPPTR2
>STYA ZPPTR1
jmp Cmd.ExecYA
*--------------------------------------
Cmd.Exec.SET lda (ZPPTR2)
bne Cmd.Exec.SETVAR
* No arg, print all ENV
ldy #S.PS.hENV
lda (pPs),y
>SYSCALL GetMemPtr.A
>STYA ZPPTR1
* No arg, print all ENV
.1 lda (ZPPTR1)
beq .8 Ending 0 ?
lda ZPPTR1 get next for value
sec
adc (ZPPTR1) Add len+1 to PTR
sta ZPPTR2
lda ZPPTR1+1
adc #0
sta ZPPTR2+1
ldy #$ff
lda (ZPPTR2) just in case...
beq .8
.2 iny
lda (ZPPTR1),y
bne .2
tya
sec
adc ZPPTR1
sta ZPPTR2
lda #0
adc ZPPTR1+1
sta ZPPTR2+1
>PUSHW ZPPTR2 Push value
>PUSHW ZPPTR1 Push name
>LDYA L.MSG.PRINTENV
>SYSCALL PrintF.YA
>DEBUG
bcs .9
lda ZPPTR2
ldy #$ff
.3 iny
lda (ZPPTR2),y
bne .3
tya
sec
adc (ZPPTR2) Add len+1 to PTR
adc ZPPTR2
sta ZPPTR1
lda ZPPTR2+1
adc #0
lda #0
adc ZPPTR2+1
sta ZPPTR1+1
bra .1

View File

@ -28,7 +28,7 @@ VarLen.MAX .EQ 15
CSH.Stack.MAX .EQ 15
CSH.Name.MAX .EQ 15
CSH.E.SYNTAX .EQ $7F
CSH.E.SYNTAX .EQ $7F
CSH.E.SOVERFLW .EQ $7E
CSH.E.NOVERFLW .EQ $7D
CSH.E.OOM .EQ $7C
@ -553,7 +553,7 @@ MSG.ECHO >CSTR ">%S\r\n"
MSG.PSTRCR >CSTR "%S\r\n"
MSG.PSTR >CSTR "%S"
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:"
FMT.DATE >CSTR "%A, %B %d %Y"
FMT.TIME >CSTR "%H:%M:%S (%I:%M:%S%p)"

View File

@ -12,31 +12,31 @@ AUTO 6
* Y,A = PTR to Expanded String
*\--------------------------------------
K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
.1 >STYA ZPPtr2
stz K.ExpandStr.Len init Expanded String len=0
stz K.ExpandStr.Len init Expanded String len=0
stz K.ExpandStr.bFound No var found yet
stz K.ExpandStr.bNoExp Reset no expand flag
ldy #0
.10 stz K.ExpandStr.VarLen
stz K.ExpandStr.bInVar
.11 lda (ZPPtr2),y End of CSTR?
.11 lda (ZPPtr2),y End of CSTR?
beq .8
iny
cmp #'''
bne .21
lda K.ExpandStr.bNoExp
eor #$ff
sta K.ExpandStr.bNoExp toggle flag
sta K.ExpandStr.bNoExp toggle flag
bra .11
.21 bit K.ExpandStr.bNoExp
bpl .23
@ -45,23 +45,23 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
inx
stx K.ExpandStr.Len
bra .11
.23 ldx K.ExpandStr.bInVar already in a var?
bne .3 yes....
.23 ldx K.ExpandStr.bInVar already in a var?
bne .3 yes...
cmp #'$' no, found one ?
bne .22 no, store....
bne .22 no, store...
sta K.ExpandStr.bFound Toggle flag
sta K.ExpandStr.bInVar
bra .11 skip this char
.3 cmp #'{' we are in var, "{" after "$"?
bne .31
ldx K.ExpandStr.VarLen No char in var yet ?
beq .11 normal, "${" syntax is ok,skip
bne .5 not allowed char in varname, end of var
.31 cmp #'}' end of var?
@ -186,17 +186,17 @@ K.PutEnv.YA >STYA ZPPtr1 NAME=VALUE
sta K.Buf256,y
tya
clc
sec
adc ZPPtr1
sta ZPPtr2
lda ZPPtr1+1
adc #0
sta ZPPtr2+1
>LDYAI K.Buf256
>STYA ZPPtr1
bra K.SetEnvPtr1Ptr2
.9 sec
rts
*/--------------------------------------
@ -207,76 +207,102 @@ K.PutEnv.YA >STYA ZPPtr1 NAME=VALUE
* ## Out:
*\--------------------------------------
K.SetEnv jsr PullPtr1Ptr2 Ptr1=NAME,Ptr2=VALUE
K.SetEnvPtr1Ptr2
jsr S.UnsetEnvPtr1
jsr ENV.InitEnvPtr3 ZPPtr3 -> Env
ldy #0
ldx #0
lda ZPPtr3 Compute ENV UPPER LIMIT in Ptr4
clc
adc #K.ENV.SIZE
sta ZPPtr4
.10 lda (ZPPtr3) End of ENV
beq .15
lda ZPPtr3+1
adc /K.ENV.SIZE
sta ZPPtr4+1
.11 iny Compute ENV size in X,Y
bne .12
inx
ldy ZPPtr3+1
lda ZPPtr3 Compute New Env Upper limit in A,Y
.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
adc (ZPPtr1) add NAME len +1
bcc .1
iny
adc ZPPtr4
sta ZPPtr4
bcc .18
inc ZPPtr4+1
.1 sec
adc (ZPPtr2) add VALUE len +1
bcc .2
.18 ldy #0
.19 lda (ZPPtr2),y
beq .20
iny
bne .19
.2 cmp ZPPtr4 GE than hMem Upper limit ?
tya
sbc ZPPtr4+1
.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
.3 lda (ZPPtr3) Scan until ending 0...
beq .4
inc ZPPtr3
bne .3
ldy #$ff
.22 iny
lda (ZPPtr1),y
sta (ZPPtr3),y
bne .22
tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .23
inc ZPPtr3+1
bne .3
.4 lda (ZPPtr1)
sta (ZPPtr3)
tay
.5 lda (ZPPtr1),y
.23 ldy #$ff
.24 iny
lda (ZPPtr2),y
sta (ZPPtr3),y
dey
bne .5
jsr ENV.NextEnvPtr3
lda (ZPPtr2)
sta (ZPPtr3)
tay
.6 lda (ZPPtr2),y
sta (ZPPtr3),y
dey
bne .6
jsr ENV.NextEnvPtr3
.8 lda #0
sta (ZPPtr3)
bne .24
iny
.25 lda #0
sta (ZPPtr3),y don't forget array ending 0
clc
rts
.99 lda #SYSMGR.ERRENVF
sec
* sec
rts
*/--------------------------------------
* # GetEnv.YA
@ -448,7 +474,7 @@ ENV.SysVarsExit2
*--------------------------------------
ENV.FindVarPtr1 jsr ENV.InitEnvPtr3 Store ENV
bcs .99
.1 lda (ZPPtr3)
beq .9 end of ENV
@ -457,24 +483,24 @@ ENV.FindVarPtr1 jsr ENV.InitEnvPtr3 Store ENV
.2 lda (ZPPtr1),y
cmp (ZPPtr3),y
bne .3
ora #0
beq .8
iny
bne .2
.8 clc
rts
.3 jsr ENV.NextEnvPtr3 Skip NAME
jsr ENV.NextEnvPtr3 Skip VALUE
bra .1
.9 sec
.99 rts
.99 rts
*--------------------------------------
* ENV.DiscardVarPtr3
* ENV.DiscardVarPtr3
* In:
* ZPPtr3 -> ENV.NAME to Discard
*--------------------------------------
@ -483,22 +509,29 @@ ENV.DiscardVarPtr3
>STYA ZPPtr4
jsr ENV.NextEnvPtr3 Skip current NAME....
jsr ENV.NextEnvPtr3 Skip current VALUE....
ldy #0
.1 lda (ZPPtr3),y Move back CSTRs...
.2 sta (ZPPtr4),y
beq .2 0 ended....
beq .3 0 ended....
iny
bne .1
inc ZPPtr3
inc ZPPtr4
inc ZPPtr3+1
inc ZPPtr4+1
bra .1
.3 iny
lda (ZPPtr3),y
bne .3 Until array ending 0
bne .4
inc ZPPtr3+1
inc ZPPtr4+1
.4 lda (ZPPtr3),y
bne .2 Until array ending 0
sta (ZPPtr4),y
.8 rts
*--------------------------------------
ENV.InitEnvPtr3 ldy #S.PS.hENV
@ -513,30 +546,31 @@ ENV.NextEnvPtr3 ldy #0
beq .2
iny
bne .1
.2 tya
sec
adc ZPPtr3
sta ZPPtr3
bcc .8
inc ZPPtr3+1
.8 rts
.8 rts
*--------------------------------------
ENV.AppendPtr3ToBuf
ldx #$ff
.1 inx
lda K.Buf256,x
bne .1
ldy #0
.2 lda (ZPPtr3),y
ldy #$ff
dex
.2 iny
inx
lda (ZPPtr3),y
sta K.Buf256,x
bne .2
inx
stz K.Buf256,x
rts
*--------------------------------------
MAN

View File

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

View File

@ -414,73 +414,7 @@ PullPtr1Ptr2 clc
bcc .9
>PULLW ZPPtr3
.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
SAVE /A2OSX.SRC/SYS/KERNEL.S.JMP
LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

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