A2osX/SYS/KERNEL.S.ENVX.txt

373 lines
6.0 KiB
Plaintext
Raw Normal View History

2020-01-22 16:31:48 +00:00
NEW
AUTO 3,1
*--------------------------------------
ENVX.PutEnv ldy #$ff
.1 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.TXTPTR.GetY NAME=
2020-01-22 16:31:48 +00:00
beq .9
cmp #'='
bne .1
tya
sec skip =
adc TXTPTR
sta FORPNT
lda #0
adc TXTPTR+1
sta FORPNT+1
2020-01-29 16:46:51 +00:00
bra ENVX.SetEnv
2020-01-22 16:31:48 +00:00
.9 lda #E.SYN
sec
rts
*--------------------------------------
ENVX.SetEnv jsr ENVX.UnsetEnv
2020-01-29 16:46:51 +00:00
.1 jsr ENVX.InitEnvP3 ZPPtr3 -> Env (SETREADAUX)
2020-01-22 16:31:48 +00:00
lda #1
sta ZPPtr4
stz ZPPtr4+1 ZPPtr4 = ENVSIZE = 1
.10 lda (ZPPtr3) End of ENV
beq .15
2020-01-29 16:46:51 +00:00
jsr ENVX.GetP3LenY
jsr ENVX.NextEnvP3Y
jsr ENVX.NextEnvP4Y
2020-01-22 16:31:48 +00:00
bra .10
2020-01-29 16:46:51 +00:00
.15 ldy #$ff
2020-01-22 16:31:48 +00:00
.16 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.TXTPTR.GetY
2020-01-22 16:31:48 +00:00
beq .17
jsr SHARED.IsIDValid
bcc .16
2020-01-29 16:46:51 +00:00
.17 jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VAR
2020-01-22 16:31:48 +00:00
ldy #$ff
.19 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.getY
2020-01-22 16:31:48 +00:00
bne .19
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP4Y ZPPtr4 = ENVSIZE + VALUE
2020-01-22 16:31:48 +00:00
lda ZPPtr4
beq .20
inc ZPPtr4+1
.20 ldy #S.PS.ENVPAGECNT
lda (pPs),y
cmp ZPPtr4+1
bcs .22 env is large enough
lda ZPPtr4+1
jsr ENV.Dup.A
bcs .9
pha
ldy #S.PS.hENV
lda (pPs),y
2020-01-29 16:46:51 +00:00
jsr K.Freemem AUX
2020-01-22 16:31:48 +00:00
pla
ldy #S.PS.hENV
sta (pPs),y
txa
dey S.PS.ENVPAGECNT
sta (pPs),y
bra .1 Start over
.22 ldy #$ff
2020-01-29 16:46:51 +00:00
2020-01-22 16:31:48 +00:00
.23 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.TXTPTR.GetY
2020-01-22 16:31:48 +00:00
sta (ZPPtr3),y
beq .24
jsr SHARED.IsIDValid
bcc .23
.24 lda #'='
sta (ZPPtr3),y
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y
2020-01-22 16:31:48 +00:00
ldy #$ff
.25 iny
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.getY
2020-01-22 16:31:48 +00:00
sta (ZPPtr3),y
bne .25
iny
sta (ZPPtr3),y don't forget array ending 0
clc
2020-01-29 16:46:51 +00:00
.9 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
ENVX.GetEnv lda TXTPTR
2020-01-29 16:46:51 +00:00
beq ENVX.Dump
2020-01-22 16:31:48 +00:00
2020-01-29 16:46:51 +00:00
jsr ENVX.FindVar
2020-01-22 16:31:48 +00:00
bcs .9
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y Skip NAME=
2020-01-22 16:31:48 +00:00
lda FORPNT+1
bne .3
ldy #$ff
.1 iny
lda (ZPPtr3),y
bne .1
iny
bne .2
inc
2020-01-29 16:46:51 +00:00
.2 sta CLRREADAUX
2020-01-22 16:31:48 +00:00
sta CLRWRITEAUX
jsr K.getmem
2020-01-29 16:46:51 +00:00
sta SETREADAUX
sta SETWRITEAUX
2020-01-22 16:31:48 +00:00
bcs .99
>STYA FORPNT
2020-01-29 16:46:51 +00:00
.3 ldy #$ff
2020-01-22 16:31:48 +00:00
.4 iny
lda (ZPPtr3),y
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.PutY
2020-01-22 16:31:48 +00:00
bne .4
>LDYA FORPNT
clc
rts
.9 >LDYAI 0
* sec
.99 rts
2020-01-29 16:46:51 +00:00
*--------------------------------------
ENVX.Dump sta CLRREADAUX
sta CLRWRITEAUX
ldy #S.PS.ENVPAGECNT
2020-01-22 16:31:48 +00:00
lda (pPs),y
sta .1+1
ldy #0
jsr K.getmem
2020-01-29 16:46:51 +00:00
sta SETREADAUX
sta SETWRITEAUX
2020-01-22 16:31:48 +00:00
bcs .9
>STYA FORPNT
sty .80+1
sta .81+1
stx .82+1
jsr ENV.InitEnvP3 SETREADAUX
.1 ldx #$ff SELF MODIFIED
ldy #0
.2 lda (ZPPtr3),y
2020-01-29 16:46:51 +00:00
jsr SHARED.FORPNT.PutY
2020-01-22 16:31:48 +00:00
iny
bne .2
2020-01-29 16:46:51 +00:00
inc ZPPtr3+1
inc FORPNT+1
dex
bne .2
2020-01-22 16:31:48 +00:00
.80 ldy #$ff SELF MODIFIED
.81 lda #$ff SELF MODIFIED
.82 ldx #$ff SELF MODIFIED
2020-01-29 16:46:51 +00:00
2020-01-22 16:31:48 +00:00
clc
.9 rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.UnsetEnv jsr ENVX.FindVar
2020-01-22 16:31:48 +00:00
bcs . 8 not found, quit
2020-01-29 16:46:51 +00:00
jsr ENVX.DelVarP3 Ptr3 -> NAME=VALUE
2020-01-22 16:31:48 +00:00
clc
rts
*--------------------------------------
* ENV.FindVar
* In:
* TXTPTR -> NAME
* Out:
* CC: Found
* Y = NAME len
* TXTPTR -> NAME
* ZPPtr3 -> NAME=VALUE
* CS: Not Found
* TXTPTR -> NAME
* ZPPtr3 -> PTR to Ending 0
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.FindVar jsr ENVX.InitEnvP3 Store ENV
2020-01-22 16:31:48 +00:00
.1 lda (ZPPtr3)
beq .9 end of ENV
ldy #$ff
.2 iny
jsr SHARED.TXTPTR.GetY
beq .3
jsr SHARED.IsIDValid
bcs .3
cmp (ZPPtr3),y
beq .2
bra .4
.3 lda (ZPPtr3),y
cmp #'='
bne .4
clc
rts
2020-01-29 16:46:51 +00:00
.4 jsr ENVX.NextEnvP3 Skip NAME=VALUE
2020-01-22 16:31:48 +00:00
bra .1
2020-01-29 16:46:51 +00:00
.9 sec
2020-01-22 16:31:48 +00:00
rts
*--------------------------------------
* ENV.DelVarP3
* In:
* ZPPtr3 -> ENV.NAME to Discard
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.DelVarP3 >LDYA ZPPtr3 save actual Ptr
2020-01-22 16:31:48 +00:00
>STYA ZPPtr4
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3 Skip NAME=VALUE
2020-01-22 16:31:48 +00:00
.1 ldy #$ff
.2 iny
lda (ZPPtr3),y Move back CSTRs...
sta (ZPPtr4),y
bne .2
tya
beq .8 we moved back ending \0
2020-01-29 16:46:51 +00:00
jsr ENVX.NextEnvP3Y
jsr ENVX.NextEnvP4Y
2020-01-22 16:31:48 +00:00
bra .1
2020-01-29 16:46:51 +00:00
.8 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.InitEnvP3 sta CLRREADAUX
2020-01-22 16:31:48 +00:00
ldy #S.PS.hENV
lda (pPs),y
sta SETREADAUX
jsr K.GetMemPtr
>STYA ZPPtr3 Store ENV
rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP3 jsr ENVX.GetP3LenY
2020-01-22 16:31:48 +00:00
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP3Y tya
ENVX.NextEnvP3A sec
2020-01-22 16:31:48 +00:00
adc ZPPtr3
sta ZPPtr3
bcc .8
inc ZPPtr3+1
.8 rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.GetP3LenY ldy #$ff
2020-01-22 16:31:48 +00:00
.1 iny
lda (ZPPtr3),y
bne .1
rts
*--------------------------------------
2020-01-29 16:46:51 +00:00
ENVX.NextEnvP4Y tya
2020-01-22 16:31:48 +00:00
sec
adc ZPPtr4
sta ZPPtr4
bcc .8
inc ZPPtr4+1
.8 rts
*--------------------------------------
* ENV.Dup
* In:
* A = ENV hMem To Duplicate
* Out:
* A = hMem to new ENV
* X = Page Count
*--------------------------------------
ENV.Dup ldy #S.PS.ENVPAGECNT
lda (pPs),y
ENV.Dup.A sta .8+1 Store target page Count
ldy #S.PS.ENVPAGECNT get SOURCE page count
lda (pPs),y
sta .10+1
ldy #S.PS.hENV
lda (pPs),y
jsr K.GetMemPtr
>STYA .1+1
ldy #0
lda .8+1
jsr K.GetMem
bcs .9
>STYA .2+1 Target Buffer
phx save hMem
jsr Mem.SetOwner Set Ownership
ldy #0
.10 ldx #$ff SELF MODIFIED
.1 lda $ffff,y SELF MODIFIED
.2 sta $ffff,y SELF MODIFIED
iny
bne .1
inc .1+2
inc .2+2
dex
bne .1
.8 ldx #$ff SELF MODIFIED Target Page Count
pla hMem
clc
2020-01-29 16:46:51 +00:00
.9 rts
2020-01-22 16:31:48 +00:00
*--------------------------------------
MAN
SAVE USR/SRC/SYS/KERNEL.S.ENVX
LOAD USR/SRC/SYS/KERNEL.S
ASM