mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-14 13:29:02 +00:00
Kernel version 0.8 : ENV...some enhancement (few) and bugfix (many;-)...see Readme.md
This commit is contained in:
parent
9974920777
commit
aa60fd4c3c
@ -14,21 +14,22 @@ AUTO 6
|
||||
*\--------------------------------------
|
||||
K.ExpandPStrYA stz K.ExpandPStr.hPStr Reset Intermediate string...
|
||||
|
||||
.11 >STYA ZPQuickPtr3
|
||||
.11 >STYA ZPQuickPtr2
|
||||
|
||||
stz KrnBuf256 init Expanded String len=0
|
||||
stz K.ExpandPStr.bFound No var found yet
|
||||
stz K.ExpandPStr.bNoExp Reset no expand flag
|
||||
|
||||
ldy #0
|
||||
|
||||
.10 stz K.ExpandPStr.Start
|
||||
|
||||
.1 tya
|
||||
cmp (ZPQuickPtr3) End of PSTR?
|
||||
cmp (ZPQuickPtr2) End of PSTR?
|
||||
beq .6
|
||||
|
||||
iny
|
||||
lda (ZPQuickPtr3),y
|
||||
lda (ZPQuickPtr2),y
|
||||
|
||||
cmp #'''
|
||||
bne .21
|
||||
@ -94,9 +95,10 @@ K.ExpandPStrYA stz K.ExpandPStr.hPStr Reset Intermediate string...
|
||||
bcs .9
|
||||
stx K.ExpandPStr.hPStr save this as temp string, in case of recurse
|
||||
bit K.ExpandPStr.bFound Did we expand something ?
|
||||
bpl .9
|
||||
bpl .82
|
||||
jmp .11 Yes, start over with hPStr
|
||||
|
||||
.82
|
||||
* or exit with Y,A & X from K.NewPStrYA
|
||||
|
||||
.9 rts
|
||||
@ -109,40 +111,41 @@ K.ExpandPStr.AV lda K.ExpandPStr.End
|
||||
inx
|
||||
sta KrnBuf256,x
|
||||
|
||||
stx ZPQuickPtr2
|
||||
stx ZPQuickPtr1 Make Ptr1 -> Var NAME
|
||||
lda /KrnBuf256
|
||||
sta ZPQuickPtr2+1
|
||||
sta ZPQuickPtr1+1
|
||||
|
||||
ldy K.ExpandPStr.Start
|
||||
|
||||
.1 iny
|
||||
inx
|
||||
lda (ZPQuickPtr3),y
|
||||
lda (ZPQuickPtr2),y
|
||||
sta KrnBuf256,x
|
||||
cpy K.ExpandPStr.End
|
||||
bne .1
|
||||
|
||||
jsr ENV.CheckSysVarPtr2
|
||||
bcs .10
|
||||
>STYA ZPQuickPtr1
|
||||
bra .11
|
||||
jsr ENV.CheckSysVarPtr1
|
||||
bcc .2 Ptr3=VALUE
|
||||
|
||||
.10 jsr ENV.FindVarPtr2
|
||||
jsr ENV.FindVarPtr1
|
||||
bcs .9
|
||||
|
||||
jsr ENV.NextEnvPtr1 Skip NAME
|
||||
jsr ENV.NextEnvPtr3 Skip NAME
|
||||
|
||||
.11 ldy #0
|
||||
.2 lda (ZPQuickPtr3)
|
||||
beq .9 in case CheckSysVarPtr1 returned a NUL string
|
||||
|
||||
ldy #0
|
||||
ldx KrnBuf256
|
||||
|
||||
.2 iny
|
||||
lda (ZPQuickPtr1),y
|
||||
.3 iny
|
||||
lda (ZPQuickPtr3),y
|
||||
inx
|
||||
sta KrnBuf256,x
|
||||
|
||||
tya
|
||||
cmp (ZPQuickPtr1) last char?
|
||||
bne .2
|
||||
cmp (ZPQuickPtr3) last char?
|
||||
bne .3
|
||||
stx KrnBuf256
|
||||
|
||||
.9 rts
|
||||
@ -176,13 +179,14 @@ K.ExpandPStr.hPStr .BS 1
|
||||
* Y,A = PTR to String NAME=VALUE (PSTR)
|
||||
* ##Out:
|
||||
*\--------------------------------------
|
||||
K.PutEnvYA >STYA ZPQuickPtr2 NAME=VALUE
|
||||
lda (ZPQuickPtr2)
|
||||
K.PutEnvYA >STYA ZPQuickPtr1 NAME=VALUE
|
||||
|
||||
lda (ZPQuickPtr1)
|
||||
beq .9
|
||||
sta KrnBuf256
|
||||
tay
|
||||
|
||||
.1 lda (ZPQuickPtr2),y
|
||||
.1 lda (ZPQuickPtr1),y copy PSTR to KrnBuf256
|
||||
sta KrnBuf256,y
|
||||
dey
|
||||
bne .1
|
||||
@ -203,27 +207,23 @@ K.PutEnvYA >STYA ZPQuickPtr2 NAME=VALUE
|
||||
cpy KrnBuf256 last char ?
|
||||
beq .9 we have "VAR="
|
||||
|
||||
lda KrnBuf256 save actual string len
|
||||
lda KrnBuf256 get actual string len
|
||||
|
||||
sty KrnBuf256 set length of VAR string
|
||||
dec KrnBuf256 ...without "="
|
||||
|
||||
|
||||
.3 clc Substract VAR len+1 from whole len to get
|
||||
clc Substract VAR len+1 from whole len to get
|
||||
sbc KrnBuf256 VALUE len
|
||||
sta KrnBuf256,y save it at "=" POS
|
||||
|
||||
tya
|
||||
clc
|
||||
adc #KrnBuf256
|
||||
sta ZPQuickPtr3
|
||||
stz ZPQuickPtr1 #KrnBuf256
|
||||
sty ZPQuickPtr2
|
||||
|
||||
lda /KrnBuf256
|
||||
sta ZPQuickPtr3+1
|
||||
sta ZPQuickPtr1+1
|
||||
sta ZPQuickPtr2+1
|
||||
|
||||
>LDYAI KrnBuf256
|
||||
>STYA ZPQuickPtr2
|
||||
|
||||
bra K.SetEnvPtr2Ptr3
|
||||
bra K.SetEnvPtr1Ptr2
|
||||
|
||||
.9 sec
|
||||
rts
|
||||
@ -234,32 +234,31 @@ K.PutEnvYA >STYA ZPQuickPtr2 NAME=VALUE
|
||||
* PUSHW = PTR To Name (PSTR)
|
||||
* ##Out:
|
||||
*\--------------------------------------
|
||||
K.SetEnv >PULLW ZPQuickPtr2 NAME...
|
||||
>PULLW ZPQuickPtr3 ...VALUE
|
||||
K.SetEnv jsr PullPtr1Ptr2 Ptr1=NAME,Ptr2=VALUE
|
||||
|
||||
K.SetEnvPtr2Ptr3
|
||||
jsr S.UnsetEnvPtr2
|
||||
K.SetEnvPtr1Ptr2
|
||||
jsr S.UnsetEnvPtr1
|
||||
|
||||
jsr ENV.InitEnvPtr1 Y,A = ZPQuickPtr1 -> Env
|
||||
jsr ENV.InitEnvPtr3 ZPQuickPtr3 -> Env
|
||||
|
||||
lda ZPQuickPtr1 Compute ENV UPPER LIMIT in Ptr4
|
||||
lda ZPQuickPtr3 Compute ENV UPPER LIMIT in Ptr4
|
||||
clc
|
||||
adc #K.ENV.SIZE
|
||||
sta ZPQuickPtr4
|
||||
|
||||
lda ZPQuickPtr1+1
|
||||
lda ZPQuickPtr3+1
|
||||
adc /K.ENV.SIZE
|
||||
sta ZPQuickPtr4+1
|
||||
|
||||
ldy ZPQuickPtr1+1
|
||||
lda ZPQuickPtr1 Compute New Env Upper limit in A,Y
|
||||
ldy ZPQuickPtr3+1
|
||||
lda ZPQuickPtr3 Compute New Env Upper limit in A,Y
|
||||
sec
|
||||
adc (ZPQuickPtr2) add NAME len +1
|
||||
adc (ZPQuickPtr1) add NAME len +1
|
||||
bcc .1
|
||||
iny
|
||||
|
||||
.1 sec
|
||||
adc (ZPQuickPtr3) add VALUE len +1
|
||||
adc (ZPQuickPtr2) add VALUE len +1
|
||||
bcc .2
|
||||
iny
|
||||
|
||||
@ -268,39 +267,39 @@ K.SetEnvPtr2Ptr3
|
||||
sbc ZPQuickPtr4+1
|
||||
bcs .99
|
||||
|
||||
.3 lda (ZPQuickPtr1) Scan until endig 0...
|
||||
.3 lda (ZPQuickPtr3) Scan until ending 0...
|
||||
beq .4
|
||||
|
||||
inc ZPQuickPtr1
|
||||
inc ZPQuickPtr3
|
||||
bne .3
|
||||
inc ZPQuickPtr1+1
|
||||
inc ZPQuickPtr3+1
|
||||
bne .3
|
||||
|
||||
.4 lda (ZPQuickPtr2)
|
||||
sta (ZPQuickPtr1)
|
||||
.4 lda (ZPQuickPtr1)
|
||||
sta (ZPQuickPtr3)
|
||||
tay
|
||||
|
||||
.5 lda (ZPQuickPtr2),y
|
||||
sta (ZPQuickPtr1),y
|
||||
.5 lda (ZPQuickPtr1),y
|
||||
sta (ZPQuickPtr3),y
|
||||
dey
|
||||
bne .5
|
||||
|
||||
jsr ENV.NextEnvPtr1
|
||||
jsr ENV.NextEnvPtr3
|
||||
|
||||
lda (ZPQuickPtr3)
|
||||
sta (ZPQuickPtr1)
|
||||
lda (ZPQuickPtr2)
|
||||
sta (ZPQuickPtr3)
|
||||
tay
|
||||
|
||||
.6 lda (ZPQuickPtr3),y
|
||||
sta (ZPQuickPtr1),y
|
||||
.6 lda (ZPQuickPtr2),y
|
||||
sta (ZPQuickPtr3),y
|
||||
dey
|
||||
bne .6
|
||||
|
||||
jsr ENV.NextEnvPtr1
|
||||
jsr ENV.NextEnvPtr3
|
||||
|
||||
.8 lda #0
|
||||
|
||||
sta (ZPQuickPtr1)
|
||||
sta (ZPQuickPtr3)
|
||||
clc
|
||||
rts
|
||||
|
||||
@ -315,14 +314,14 @@ K.SetEnvPtr2Ptr3
|
||||
* CC : Y,A = PTR to VALUE (PSTR)
|
||||
* CS : not found
|
||||
*\--------------------------------------
|
||||
K.GetEnvYA >STYA ZPQuickPtr2
|
||||
jsr ENV.CheckSysVarPtr2
|
||||
K.GetEnvYA >STYA ZPQuickPtr1
|
||||
jsr ENV.CheckSysVarPtr1
|
||||
bcc .8
|
||||
|
||||
jsr ENV.FindVarPtr2
|
||||
jsr ENV.FindVarPtr1
|
||||
bcs .9
|
||||
jsr ENV.NextEnvPtr1 Skip NAME
|
||||
>LDYA ZPQuickPtr1
|
||||
jsr ENV.NextEnvPtr3 Skip NAME
|
||||
>LDYA ZPQuickPtr3
|
||||
clc just in case ADC in NextEnvPtr1 disturb CC
|
||||
.8 rts
|
||||
|
||||
@ -334,38 +333,40 @@ K.GetEnvYA >STYA ZPQuickPtr2
|
||||
* Y,A = PTR To Name (PSTR)
|
||||
* ##Out:
|
||||
*\--------------------------------------
|
||||
K.UnsetEnvYA >STYA ZPQuickPtr2 Store VAR Name
|
||||
S.UnsetEnvPtr2 jsr ENV.FindVarPtr2
|
||||
K.UnsetEnvYA >STYA ZPQuickPtr1 Store VAR Name
|
||||
S.UnsetEnvPtr1 jsr ENV.FindVarPtr1
|
||||
bcs .8 not found, quit
|
||||
|
||||
jsr ENV.DiscardVarPtr1 Ptr1 -> ENVNAME
|
||||
jsr ENV.DiscardVarPtr3 Ptr3 -> ENVNAME
|
||||
|
||||
.8 clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
* PRIVATE
|
||||
*--------------------------------------
|
||||
* ENV.CheckSysVarPtr2
|
||||
* ENV.CheckSysVarPtr1
|
||||
* In:
|
||||
* ZPQuickPtr2 -> NAME
|
||||
* ZPQuickPtr1 -> NAME
|
||||
* Out:
|
||||
* CC: Found
|
||||
* YA -> VALUE
|
||||
* CS: Not Found
|
||||
*--------------------------------------
|
||||
ENV.CheckSysVarPtr2
|
||||
lda (ZPQuickPtr2)
|
||||
ENV.CheckSysVarPtr1
|
||||
lda (ZPQuickPtr1)
|
||||
cmp #1 is name 1 char?
|
||||
bne .9
|
||||
|
||||
ldy #1
|
||||
lda (ZPQuickPtr2),y
|
||||
cmp #'0' $0...$9 ??
|
||||
bcc .1 no,
|
||||
lda (ZPQuickPtr1),y
|
||||
cmp #'0'-1 $0...$9 ??
|
||||
bcc .1
|
||||
cmp #'9'+1
|
||||
bcs .1
|
||||
and #$0F
|
||||
jmp K.GetArgA
|
||||
jsr K.GetArgA
|
||||
>STYA ZPQuickPtr3
|
||||
rts
|
||||
|
||||
.1 ldx #ENV.SysVarsJmp-ENV.SysVars-1
|
||||
|
||||
@ -382,19 +383,51 @@ ENV.CheckSysVarPtr2
|
||||
tax
|
||||
jmp (ENV.SysVarsJmp,x)
|
||||
*--------------------------------------
|
||||
ENV.SysVars .AS "*#?$!"
|
||||
ENV.SysVars .AS "*#?@$!"
|
||||
ENV.SysVarsJmp .DA ENV.SysVarsArgs
|
||||
.DA ENV.SysVarsArgC
|
||||
.DA ENV.SysVarsRC
|
||||
.DA ENV.SysVarsPPID
|
||||
.DA ENV.SysVarsPID
|
||||
.DA ENV.SysVarsCPID
|
||||
*--------------------------------------
|
||||
ENV.SysVarsArgs sec
|
||||
rts
|
||||
ENV.SysVarsArgC jsr K.GetArgC
|
||||
ENV.SysVarsArgs lda #1
|
||||
jsr K.GetArgA Trash Ptr1
|
||||
|
||||
stz KrnOut256
|
||||
|
||||
ldx #0
|
||||
|
||||
.1 lda (ZPQuickPtr1)
|
||||
beq ENV.SysVarsExit
|
||||
|
||||
ldy #0
|
||||
|
||||
.2 iny
|
||||
inx
|
||||
lda (ZPQuickPtr1),y
|
||||
sta KrnOut256,x
|
||||
tya
|
||||
cmp (ZPQuickPtr1)
|
||||
bne .2
|
||||
|
||||
adc ZPQuickPtr1 CS from beq .2
|
||||
sta ZPQuickPtr1
|
||||
bcc .3
|
||||
inc ZPQuickPtr1+1
|
||||
.3 lda #' '
|
||||
inx
|
||||
beq ENV.SysVarsExit make sure not overlapping buf 256
|
||||
sta KrnOut256,x
|
||||
bra .1
|
||||
|
||||
ENV.SysVarsArgC jsr K.GetArgC Trash Ptr1
|
||||
bra ENV.SysVarsA
|
||||
|
||||
ENV.SysVarsRC ldy #S.PS.RC
|
||||
.HS 2C
|
||||
ENV.SysVarsPPID ldy #S.PS.PPID
|
||||
.HS 2C
|
||||
ENV.SysVarsPID ldy #S.PS.PID
|
||||
.HS 2C
|
||||
ENV.SysVarsCPID ldy #S.PS.CPID
|
||||
@ -405,82 +438,83 @@ ENV.SysVarsA sta HEXBUF
|
||||
stz HEXBUF+3
|
||||
jsr HEX2DEC
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
.1 lda ASCBUF,x
|
||||
.1 lda ASCBUF,y
|
||||
cmp #'0'
|
||||
bne .2
|
||||
inx
|
||||
cpx #10
|
||||
iny
|
||||
cpy #10
|
||||
bne .1
|
||||
|
||||
sta KrnOut256+1
|
||||
ldy #1
|
||||
bne .8 always
|
||||
ldx #1
|
||||
bra ENV.SysVarsExit
|
||||
|
||||
.2 ldy #0
|
||||
.2 ldx #0
|
||||
|
||||
.3 lda ASCBUF,x
|
||||
iny
|
||||
sta KrnOut256,y
|
||||
.3 lda ASCBUF,y
|
||||
inx
|
||||
cpx #10
|
||||
sta KrnOut256,x
|
||||
iny
|
||||
cpy #10
|
||||
bne .3
|
||||
|
||||
.8 sty KrnOut256
|
||||
ENV.SysVarsExit stx KrnOut256
|
||||
>LDYAI KrnOut256
|
||||
>STYA ZPQuickPtr3
|
||||
clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
* ENV.FindVarPtr2
|
||||
* ENV.FindVarPtr1
|
||||
* In:
|
||||
* ZPQuickPtr2 -> NAME
|
||||
* ZPQuickPtr1 -> NAME
|
||||
* Out:
|
||||
* CC: Found
|
||||
* ZPQuickPtr1 -> ENV.NAME
|
||||
* ZPQuickPtr2 -> NAME
|
||||
* ZPQuickPtr1 -> NAME
|
||||
* ZPQuickPtr3 -> ENV.NAME
|
||||
* CS: Not Found
|
||||
* ZPQuickPtr1 -> PTR to Ending 0
|
||||
* ZPQuickPtr2 -> NAME
|
||||
* ZPQuickPtr1 -> NAME
|
||||
* ZPQuickPtr3 -> PTR to Ending 0
|
||||
*--------------------------------------
|
||||
ENV.FindVarPtr2 jsr ENV.InitEnvPtr1 Store ENV
|
||||
ENV.FindVarPtr1 jsr ENV.InitEnvPtr3 Store ENV
|
||||
bcs .99
|
||||
|
||||
lda (ZPQuickPtr1)
|
||||
lda (ZPQuickPtr3)
|
||||
beq .9 end of ENV
|
||||
|
||||
.1 cmp (ZPQuickPtr2) Same len as NAME?
|
||||
.1 cmp (ZPQuickPtr1) Same len as NAME?
|
||||
bne .3
|
||||
|
||||
tay
|
||||
|
||||
.2 lda (ZPQuickPtr1),y
|
||||
cmp (ZPQuickPtr2),y
|
||||
cmp (ZPQuickPtr3),y
|
||||
bne .3
|
||||
dey
|
||||
bne .2
|
||||
clc
|
||||
rts
|
||||
|
||||
.3 jsr ENV.NextEnvPtr1 Skip NAME
|
||||
jsr ENV.NextEnvPtr1 Skip VALUE
|
||||
lda (ZPQuickPtr1)
|
||||
.3 jsr ENV.NextEnvPtr3 Skip NAME
|
||||
jsr ENV.NextEnvPtr3 Skip VALUE
|
||||
lda (ZPQuickPtr3)
|
||||
bne .1
|
||||
|
||||
.9 sec
|
||||
.99 rts
|
||||
*--------------------------------------
|
||||
* ENV.DiscardVarPtr1
|
||||
* ENV.DiscardVarPtr3
|
||||
* In:
|
||||
* ZPQuickPtr1 -> ENV.NAME to Discard
|
||||
* ZPQuickPtr3 -> ENV.NAME to Discard
|
||||
*--------------------------------------
|
||||
ENV.DiscardVarPtr1
|
||||
lda ZPQuickPtr1 Discard current NAME & VALUE definition
|
||||
sec ZPQuickPtr1 -> NAME
|
||||
adc (ZPQuickPtr1) add NAME+1 to ZPQuickPtr1
|
||||
ENV.DiscardVarPtr3
|
||||
lda ZPQuickPtr3 Discard current NAME & VALUE definition
|
||||
sec ZPQuickPtr3 -> NAME
|
||||
adc (ZPQuickPtr3) add NAME+1 to ZPQuickPtr3
|
||||
sta ZPQuickPtr4 store it in ZPQuickPtr4
|
||||
lda #0
|
||||
adc ZPQuickPtr1+1
|
||||
adc ZPQuickPtr3+1
|
||||
sta ZPQuickPtr4+1
|
||||
|
||||
lda ZPQuickPtr4 add VALUE+1 to ZPQuickPtr4
|
||||
@ -493,28 +527,28 @@ ENV.DiscardVarPtr1
|
||||
.1 ldy #0
|
||||
|
||||
.2 lda (ZPQuickPtr4),y Move back tail...
|
||||
sta (ZPQuickPtr1),y
|
||||
sta (ZPQuickPtr3),y
|
||||
beq .8 ...until we move ending 0
|
||||
iny
|
||||
bne .2
|
||||
inc ZPQuickPtr1+1
|
||||
inc ZPQuickPtr3+1
|
||||
inc ZPQuickPtr4+1
|
||||
bra .2
|
||||
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
ENV.InitEnvPtr1 ldy #S.PS.hENV
|
||||
ENV.InitEnvPtr3 ldy #S.PS.hENV
|
||||
lda (pPs),y
|
||||
jsr K.GetMemPtrA
|
||||
>STYA ZPQuickPtr1 Store ENV
|
||||
>STYA ZPQuickPtr3 Store ENV
|
||||
rts
|
||||
*--------------------------------------
|
||||
ENV.NextEnvPtr1 lda ZPQuickPtr1
|
||||
ENV.NextEnvPtr3 lda ZPQuickPtr3
|
||||
sec
|
||||
adc (ZPQuickPtr1)
|
||||
sta ZPQuickPtr1
|
||||
adc (ZPQuickPtr3)
|
||||
sta ZPQuickPtr3
|
||||
bcc .8
|
||||
inc ZPQuickPtr1+1
|
||||
inc ZPQuickPtr3+1
|
||||
.8 rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
|
Loading…
Reference in New Issue
Block a user