A2osX/SYS/KERNEL.S.ENV.txt

436 lines
8.5 KiB
Plaintext
Raw Normal View History

2015-03-14 21:48:35 +00:00
PR#3
2015-06-03 18:30:57 +00:00
PREFIX /A2OSX.SRC
2015-03-14 21:48:35 +00:00
NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.ExpandPStrYA
2015-03-14 21:48:35 +00:00
* In:
2016-08-17 06:25:58 +00:00
* Y,A = PTR to String to Expand (PSTRING)
2015-03-14 21:48:35 +00:00
* Out:
2016-08-17 06:25:58 +00:00
* X = hMem to Expanded String (PSTRING)
* Y,A = PTR to Expanded String
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.ExpandPStrYA
2016-08-28 20:48:01 +00:00
>STYA ZPQuickPtr3
stz KrnBuf256 init Expanded String len=0
2015-03-14 21:48:35 +00:00
ldy #0
2016-09-21 15:20:37 +00:00
.10 stz K.ExpandPStr.Start
.1 tya
cmp (ZPQuickPtr3) End of PSTR?
beq .6
2015-03-14 21:48:35 +00:00
iny
lda (ZPQuickPtr3),y
2016-09-21 15:20:37 +00:00
ldx K.ExpandPStr.Start
bne .3 already in a var?
cmp #'$' no, found one ?
beq .2
inc KrnBuf256 no, copy char
ldx KrnBuf256
sta KrnBuf256,x
bra .1
2016-09-21 15:20:37 +00:00
.2 sty K.ExpandPStr.Start save var start
stz K.ExpandPStr.End
bra .1 skip this char
.3 cmp #'{' in var, "{" after "$"?
beq .2
cmp #'}' end of var?
beq .5
2016-09-21 15:20:37 +00:00
.4 jsr K.ExpandPStr.VC valid char ?
bcs .5 no, end here
2016-09-21 15:20:37 +00:00
sty K.ExpandPStr.End yes, save end
bra .1
2016-09-21 15:20:37 +00:00
.5 lda K.ExpandPStr.End get end
beq .1 empty {} or $/
phy save current index
2016-09-21 15:20:37 +00:00
jsr K.ExpandPStr.AV
ply restore index in string...
bra .10 reset start flag and continue
2016-09-21 15:20:37 +00:00
.6 sty K.ExpandPStr.End end of PSTR
lda K.ExpandPStr.Start are we in a var?
beq .7 no...exit...
2016-09-21 15:20:37 +00:00
jsr K.ExpandPStr.AV yes, expand and add to STR
.7 >LDYAI KrnBuf256
2016-09-21 15:20:37 +00:00
jsr K.NewPStrYA
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.ExpandPStr.AV lda K.ExpandPStr.End
sec
2016-09-21 15:20:37 +00:00
sbc K.ExpandPStr.Start compute len of VAR End-Start+1
ldx KrnBuf256
inx
sta KrnBuf256,x
stx ZPQuickPtr2
lda /KrnBuf256
sta ZPQuickPtr2+1
2016-09-21 15:20:37 +00:00
ldy K.ExpandPStr.Start
.1 iny
inx
lda (ZPQuickPtr3),y
sta KrnBuf256,x
2016-09-21 15:20:37 +00:00
cpy K.ExpandPStr.End
bne .1
2016-09-29 15:30:15 +00:00
jsr ENV.CheckSysVarPtr2
2016-08-17 06:25:58 +00:00
bcs .10
>STYA ZPQuickPtr1
bra .11
2016-09-29 15:30:15 +00:00
.10 jsr ENV.FindVarPtr2
bcs .9
2016-09-29 15:30:15 +00:00
jsr ENV.NextEnvPtr1 Skip NAME
2016-08-17 06:25:58 +00:00
.11 ldy #0
ldx KrnBuf256
2016-08-17 06:25:58 +00:00
.2 iny
lda (ZPQuickPtr1),y
2016-08-17 06:25:58 +00:00
inx
sta KrnBuf256,x
tya
2016-08-17 06:25:58 +00:00
cmp (ZPQuickPtr1) last char?
bne .2
stx KrnBuf256
2016-08-17 06:25:58 +00:00
.9 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.ExpandPStr.VC cmp #'0'
bcc .9
cmp #'9'+1
bcc .8
cmp #'A'
bcc .9
cmp #'Z'+1
bcc .8
cmp #'_'
bne .9
.8 clc
rts
.9 sec
2015-03-14 21:48:35 +00:00
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.ExpandPStr.Start .BS 1
K.ExpandPStr.End .BS 1
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.PutEnvYA
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.PutEnvYA >STYA ZPQuickPtr2 NAME=VALUE
2016-08-17 06:25:58 +00:00
lda (ZPQuickPtr2)
beq .9
sta KrnBuf256
2016-08-17 06:25:58 +00:00
tay
2016-06-07 06:10:18 +00:00
2016-08-17 06:25:58 +00:00
.1 lda (ZPQuickPtr2),y
sta KrnBuf256,y
2016-08-17 06:25:58 +00:00
dey
2015-03-14 21:48:35 +00:00
bne .1
2016-06-07 06:10:18 +00:00
2016-08-17 06:25:58 +00:00
ldy #0
2016-06-07 06:10:18 +00:00
2015-03-14 21:48:35 +00:00
.2 iny
cpy KrnBuf256 last char ?
2016-08-17 06:25:58 +00:00
beq .9 no "=" found
lda KrnBuf256,y
2016-08-17 06:25:58 +00:00
cmp #'='
2015-03-14 21:48:35 +00:00
bne .2
2016-08-17 06:25:58 +00:00
cpy #1 String like "=value" ?
beq .9
cpy KrnBuf256 last char ?
2016-08-17 06:25:58 +00:00
beq .9 we have "VAR="
lda KrnBuf256 save actual string len
2016-08-17 06:25:58 +00:00
sty KrnBuf256 set length of VAR string
dec KrnBuf256 ...without "="
2016-08-17 06:25:58 +00:00
.3 clc Substract VAR len+1 from whole len to get
sbc KrnBuf256 VALUE len
sta KrnBuf256,y save it at "=" POS
2016-08-17 06:25:58 +00:00
tya
2015-03-14 21:48:35 +00:00
clc
adc #KrnBuf256
2016-08-17 06:25:58 +00:00
sta ZPQuickPtr3
lda /KrnBuf256
2016-08-17 06:25:58 +00:00
sta ZPQuickPtr3+1
>LDYAI KrnBuf256
2016-08-17 06:25:58 +00:00
>STYA ZPQuickPtr2
2016-09-21 15:20:37 +00:00
bra K.SetEnvPtr2Ptr3
2016-08-17 06:25:58 +00:00
.9 sec
rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.SetEnv
2015-03-14 21:48:35 +00:00
* In:
* PULLW = PTR To Name (PSTRING)
* PULLW = PTR To Value (PSTRING)
* Out:
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.SetEnv >PULLW ZPQuickPtr2 NAME...
2016-08-17 06:25:58 +00:00
>PULLW ZPQuickPtr3 ...VALUE
2016-09-21 15:20:37 +00:00
K.SetEnvPtr2Ptr3
2016-08-17 06:25:58 +00:00
jsr S.UnsetEnvPtr2
2016-09-29 15:30:15 +00:00
jsr ENV.InitEnvPtr1 Y,A = ZPQuickPtr1 -> Env
2016-08-17 06:25:58 +00:00
lda ZPQuickPtr1 Compute ENV UPPER LIMIT in Ptr4
2015-03-14 21:48:35 +00:00
clc
adc #K.ENV.SIZE
sta ZPQuickPtr4
2016-08-17 06:25:58 +00:00
2015-03-14 21:48:35 +00:00
lda ZPQuickPtr1+1
adc /K.ENV.SIZE
sta ZPQuickPtr4+1
2016-08-17 06:25:58 +00:00
2015-03-14 21:48:35 +00:00
ldy ZPQuickPtr1+1
lda ZPQuickPtr1 Compute New Env Upper limit in A,Y
sec
2016-08-17 06:25:58 +00:00
adc (ZPQuickPtr2) add NAME len +1
bcc .1
2015-03-14 21:48:35 +00:00
iny
2016-08-17 06:25:58 +00:00
.1 sec
adc (ZPQuickPtr3) add VALUE len +1
bcc .2
2015-03-14 21:48:35 +00:00
iny
2016-08-17 06:25:58 +00:00
.2 cmp ZPQuickPtr4 GE than hMem Upper limit ?
2015-03-14 21:48:35 +00:00
tya
sbc ZPQuickPtr4+1
2016-08-17 06:25:58 +00:00
bcs .99
.3 lda (ZPQuickPtr1) Scan until endig 0...
beq .4
inc ZPQuickPtr1
bne .3
2015-03-14 21:48:35 +00:00
inc ZPQuickPtr1+1
2016-08-17 06:25:58 +00:00
bne .3
.4 lda (ZPQuickPtr2)
2015-03-14 21:48:35 +00:00
sta (ZPQuickPtr1)
2016-08-17 06:25:58 +00:00
tay
.5 lda (ZPQuickPtr2),y
sta (ZPQuickPtr1),y
dey
bne .5
2016-09-29 15:30:15 +00:00
jsr ENV.NextEnvPtr1
2016-08-17 06:25:58 +00:00
lda (ZPQuickPtr3)
2015-03-14 21:48:35 +00:00
sta (ZPQuickPtr1)
2016-08-17 06:25:58 +00:00
tay
.6 lda (ZPQuickPtr3),y
sta (ZPQuickPtr1),y
dey
bne .6
2016-09-29 15:30:15 +00:00
jsr ENV.NextEnvPtr1
2016-08-17 06:25:58 +00:00
.8 lda #0
2015-03-14 21:48:35 +00:00
sta (ZPQuickPtr1)
clc
rts
2016-08-17 06:25:58 +00:00
2015-03-14 21:48:35 +00:00
.99 lda #SYSMGR.ERRENVF
sec
rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.GetEnvYA
2016-06-07 06:10:18 +00:00
* In:
2016-08-17 06:25:58 +00:00
* Y,A = PTR to NAME (PSTRING)
2016-06-07 06:10:18 +00:00
* Out:
2016-08-17 06:25:58 +00:00
* CC : Y,A = PTR to VALUE (PSTRING)
* CS : not found
2016-06-07 06:10:18 +00:00
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.GetEnvYA >STYA ZPQuickPtr2
2016-09-29 15:30:15 +00:00
jsr ENV.CheckSysVarPtr2
2016-08-17 06:25:58 +00:00
bcc .9
2016-09-29 15:30:15 +00:00
jsr ENV.FindVarPtr2
2016-08-17 06:25:58 +00:00
bcs .9
2016-09-29 15:30:15 +00:00
jsr ENV.NextEnvPtr1 Skip NAME
2016-08-17 06:25:58 +00:00
>LDYA ZPQuickPtr1
clc just in case ADC in NextEnvPtr1 disturb CC
2016-08-17 06:25:58 +00:00
.9 rts
*--------------------------------------
2016-09-21 15:20:37 +00:00
* K.UnsetEnvYA
* In:
2016-08-17 06:25:58 +00:00
* YA = PTR To Name (PSTRING)
* Out:
*--------------------------------------
2016-09-21 15:20:37 +00:00
K.UnsetEnvYA >STYA ZPQuickPtr2 Store VAR Name
2016-09-29 15:30:15 +00:00
S.UnsetEnvPtr2 jsr ENV.FindVarPtr2
bcs .8 not found, quit
2016-09-29 15:30:15 +00:00
jsr ENV.DiscardVarPtr1 Ptr1 -> ENVNAME
.8 clc
rts
*--------------------------------------
2015-03-14 21:48:35 +00:00
* PRIVATE
*--------------------------------------
2016-09-29 15:30:15 +00:00
* ENV.CheckSysVarPtr2
2015-03-14 21:48:35 +00:00
* In:
* ZPQuickPtr2 -> NAME
2016-08-17 06:25:58 +00:00
* Out:
* CC: Found
* YA -> VALUE
* CS: Not Found
*--------------------------------------
2016-09-29 15:30:15 +00:00
ENV.CheckSysVarPtr2
2016-08-17 06:25:58 +00:00
lda (ZPQuickPtr2)
cmp #1 is name 1 char?
bne .9
ldy #1
lda (ZPQuickPtr2),y
cmp #'0' $0...$9 ??
bcc .1 no,
cmp #'9'+1
bcs .99
and #$0F
2016-09-21 15:20:37 +00:00
jmp K.GetArgA
2016-08-17 06:25:58 +00:00
.1 cmp #'*' $* : All ARGS
bne .9
cmp #'#' $# : ARGC
bne .9
cmp #'?' $? : RC
bne .9
cmp #'$' $$ : PID
bne .9
.9 sec
.99 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
2016-09-29 15:30:15 +00:00
* ENV.FindVarPtr2
2016-08-17 06:25:58 +00:00
* In:
* ZPQuickPtr2 -> NAME
2015-03-14 21:48:35 +00:00
* Out:
* CC: Found
2016-08-17 06:25:58 +00:00
* ZPQuickPtr1 -> ENV.NAME
2015-03-14 21:48:35 +00:00
* ZPQuickPtr2 -> NAME
* CS: Not Found
* ZPQuickPtr1 -> PTR to Ending 0
* ZPQuickPtr2 -> NAME
*--------------------------------------
2016-09-29 15:30:15 +00:00
ENV.FindVarPtr2 jsr ENV.InitEnvPtr1 Store ENV
2016-08-17 06:25:58 +00:00
bcs .99
2015-03-14 21:48:35 +00:00
2016-08-17 06:25:58 +00:00
lda (ZPQuickPtr1)
beq .9 end of ENV
.1 cmp (ZPQuickPtr2) Same len as NAME?
bne .3
tay
.2 lda (ZPQuickPtr1),y
cmp (ZPQuickPtr2),y
bne .3
dey
2015-03-14 21:48:35 +00:00
bne .2
2016-08-17 06:25:58 +00:00
clc
rts
2016-09-29 15:30:15 +00:00
.3 jsr ENV.NextEnvPtr1 Skip NAME
jsr ENV.NextEnvPtr1 Skip VALUE
2016-08-17 06:25:58 +00:00
lda (ZPQuickPtr1)
bne .1
.9 sec
.99 rts
*--------------------------------------
2016-09-29 15:30:15 +00:00
* ENV.DiscardVarPtr1
2016-08-17 06:25:58 +00:00
* In:
* ZPQuickPtr1 -> ENV.NAME to Discard
*--------------------------------------
2016-09-29 15:30:15 +00:00
ENV.DiscardVarPtr1
2016-08-17 06:25:58 +00:00
lda ZPQuickPtr1 Discard current NAME & VALUE definition
sec ZPQuickPtr1 -> NAME
adc (ZPQuickPtr1) add NAME+1 to ZPQuickPtr1
sta ZPQuickPtr4 store it in ZPQuickPtr4
lda #0
adc ZPQuickPtr1+1
sta ZPQuickPtr4+1
lda ZPQuickPtr4 add VALUE+1 to ZPQuickPtr4
sec
adc (ZPQuickPtr4)
sta ZPQuickPtr4
bcc .1
inc ZPQuickPtr4+1
.1 ldy #0
.2 lda (ZPQuickPtr4),y Move back tail...
sta (ZPQuickPtr1),y
beq .8 ...until we move ending 0
2015-03-14 21:48:35 +00:00
iny
2016-08-17 06:25:58 +00:00
bne .2
inc ZPQuickPtr1+1
inc ZPQuickPtr4+1
bra .2
.8 rts
*--------------------------------------
2016-09-29 15:30:15 +00:00
ENV.InitEnvPtr1 ldy #S.PS.hENV
2016-08-17 06:25:58 +00:00
lda (pPs),y
2016-09-21 15:20:37 +00:00
jsr K.GetMemPtrA
2016-08-17 06:25:58 +00:00
>STYA ZPQuickPtr1 Store ENV
rts
*--------------------------------------
2016-09-29 15:30:15 +00:00
ENV.NextEnvPtr1 lda ZPQuickPtr1
2015-03-14 21:48:35 +00:00
sec
2016-08-17 06:25:58 +00:00
adc (ZPQuickPtr1)
2015-03-14 21:48:35 +00:00
sta ZPQuickPtr1
2016-08-17 06:25:58 +00:00
bcc .8
2015-03-14 21:48:35 +00:00
inc ZPQuickPtr1+1
2016-08-17 06:25:58 +00:00
.8 rts
2015-03-14 21:48:35 +00:00
*--------------------------------------
MAN
SAVE SYS/KERNEL.S.ENV
LOAD SYS/KERNEL.S
ASM