A2osX/SYS/KERNEL.S.SLISTX.txt
burniouf 04a83f00f3 SH:new ALIAS cmd, new && operator
MKDIR:completely implemented
LS/RM/MV/CP: combined switches
KERNEL:SList API now handle options to handle several languages/parsers
2022-10-07 21:21:37 +02:00

467 lines
7.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------------
ZPSListDataOfs .EQ ZPMEMMGR+8
ZPSListDataLen .EQ ZPMEMMGR+10
*--------------------------------------
SLIST.Opt .BS 1
SLIST.KeyLen .BS 1
SLIST.DataLen .BS 2
SLIST.nDataCnt .BS 2
SLIST.nBufCnt .BS 2
SLIST.bStr .BS 1
SLIST.b0 .BS 1
SLIST.KeyID .BS 2
*--------------------------------------
SLISTX.GetData jsr SLIST.Select
jsr SLIST.SkipKey
jsr SLIST.GetDataLen
lda SLIST.DataLen
sec
sbc ZPSListDataOfs Offset
eor #$ff
sta SLIST.nDataCnt
lda SLIST.DataLen+1
sbc ZPSListDataOfs+1
eor #$ff
sta SLIST.nDataCnt+1 Data remaining
bcc .99 Offset Beyond DataLen
lda ZPSListDataOfs Skip to Offset
ldx ZPSListDataOfs+1
jsr SLIST.SkipDataAX
stz SLIST.b0
lda FORPNT
ora FORPNT+1
bne .12 buffer provided
>LDYA SLIST.DataLen
iny
bne .11
inc +1 for ending 0
sec
ror SLIST.b0
.11 ldx #SYS.GetMem
jsr K.SYSCALL2.MAIN !!! Get a buffer In MAIN Mem !!!
bcs .9
stx .88+1
>STYA FORPNT
.12 lda ZPSListDataLen
ora ZPSListDataLen+1
sec
beq .1 String Mode
lda ZPSListDataLen
eor #$ff
sta SLIST.nBufCnt
lda ZPSListDataLen+1
eor #$ff
sta SLIST.nBufCnt+1
clc
.1 ror SLIST.bStr
stz ZPSListDataLen
stz ZPSListDataLen+1
.2 inc SLIST.nDataCnt
bne .3
inc SLIST.nDataCnt+1
beq .80
.3 bit SLIST.bStr
bmi .4 String mode : until CR
inc SLIST.nBufCnt
bne .4
inc SLIST.nBufCnt+1
beq .80 not string mode : until end of buffer
.4 jsr BLISTX.GetNByte
bit SLIST.bStr
bpl .5
cmp #C.CR
beq .81
.5 jsr SHARED.FORPNTpn
inc ZPSListDataLen
bne .2
inc ZPSListDataLen+1
bra .2
.99 lda #E.EMPTYKEY
sec
.9 rts
.80 lda SLIST.bStr
ora SLIST.b0
bpl .82
.81 lda #0
jsr SHARED.FORPNTpn
.82 >LDYA ZPSListDataLen
.88 ldx #$ff SELF MODIFIED
clc
rts
*--------------------------------------
SLISTX.AddData jsr SLIST.Select
jsr SLIST.SkipKey
jsr SLISTX.CheckLen
ldy iByte
lda (DBlkPtr),y
pha
clc
adc ZPSListDataLen
sta (DBlkPtr),y
php
jsr BLISTX.2NByte skip LEN lo
plp
ldy iByte
lda (DBlkPtr),y
pha
adc ZPSListDataLen+1
sta (DBlkPtr),y
jsr BLISTX.2NByte skip LEN hi
plx
pla
jsr SLIST.SkipDataAX
lda ZPSListDataLen
eor #$ff
sta ZPSListDataLen
lda ZPSListDataLen+1
eor #$ff
sta ZPSListDataLen+1
sec
.1 inc ZPSListDataLen
bne .2
inc ZPSListDataLen+1
beq .8
.2 jsr SHARED.FORPNTgn
bcc .3
jsr BLISTX.SetBlkByte override ending 0, already allocated
clc
bra .1
.3 jsr BLISTX.AddByte
bcc .1
rts
.8 lda #0
jmp BLISTX.AddByte Add an extra 0 to stop Search here
*--------------------------------------
SLISTX.SetData jsr SLIST.Select
jsr SLIST.SkipKey
jsr SLISTX.CheckLen
jsr SLIST.GetDataLen
lda SLIST.DataLen
cmp ZPSListDataLen
bne .9
ldx SLIST.DataLen+1
cpx ZPSListDataLen+1
bne .9
eor #$ff
sta SLIST.nDataCnt
txa
eor #$ff
sta SLIST.nDataCnt+1
.1 inc SLIST.nDataCnt
bne .2
inc SLIST.nDataCnt+1
beq .8
.2 jsr SHARED.FORPNTgn
jsr BLISTX.SetBlkByte
bra .1
.8 clc
rts
.9 lda #E.DATALEN
sec
rts
*--------------------------------------
SLISTX.CheckLen lda ZPSListDataLen
ora ZPSListDataLen+1
bne .8
ldx #0
ldy #0
lda FORPNT+1
pha
.1 jsr SHARED.FORPNTgY
beq .2
iny
bne .1
inx
bra .1
.2 iny add Ending \0
bne .3
inx
.3 sty ZPSListDataLen
stx ZPSListDataLen+1
pla
sta FORPNT+1
.8 rts
*--------------------------------------
SLISTX.GetByID jsr SLIST.Select
jsr BLISTX.GetNByte
tax
beq .9
ldy #0
.1 phy
jsr BLISTX.GetNByte
ply
jsr SHARED.FORPNTpn
iny
dex
bne .1
txa lda #0
jsr SHARED.FORPNTpn
jsr SLIST.SkipData
>LDYA KeyID
clc
rts
.9 lda #E.NOKEY
sec
rts
*--------------------------------------
SLISTX.NewKey jsr SLIST.Search
bcc .99
>LDYA KeyID
>STYA SLIST.KeyID End of list
lda SLIST.KeyLen
jsr BLISTX.SetBlkByte override ending 0, already allocated
ldy #0
.1 jsr SHARED.TXTPTRgY
jsr BLISTX.AddByte
bcs .9
iny
cpy SLIST.KeyLen
bne .1
lda #0 Data Len lo = 0
jsr BLISTX.AddByte
bcs .9
lda #0 Data Len hi = 0
jsr BLISTX.AddByte
bcs .9
lda #0 Ending Len = 0
jsr BLISTX.AddByte
bcs .9
>LDYA SLIST.KeyID
ldx SLIST.KeyLen
* clc
rts
.99 lda #E.DUPKEY
sec
.9 rts
*--------------------------------------
SLISTX.Lookup jsr SLIST.Search
bcs .9
ldx SLIST.KeyLen
.9 rts
*--------------------------------------
* PRIVATE
*--------------------------------------
SLIST.Search jsr K.GetMemPtr
>STYA IBlkPtr
lda (IBlkPtr)
sta SLIST.Opt
stz iByte
ldy #1
sty iBlk
lda (IBlkPtr),y
jsr K.GetMemPtr
>STYA DBlkPtr
ldy #$ff
.1 iny
jsr SHARED.TXTPTRgY
beq .2
jsr SLIST.IsIDValid
bcc .1
.2 sty SLIST.KeyLen
.3 >LDYA KeyID
>STYA SLIST.KeyID
ldy iByte
lda (DBlkPtr),y
beq .9
cmp SLIST.KeyLen
bne .6
jsr BLISTX.GetNByte Skip Len
ldy #0
.4 phy
jsr BLISTX.GetNByte
sta .5+1
ply
jsr SHARED.TXTPTRgY
.5 cmp #$ff SELF MODIFIED
bne .6
iny
cpy SLIST.KeyLen
bne .4
>LDYA SLIST.KeyID
clc
rts
.6 >LDYA SLIST.KeyID
jsr SLIST.Select.I move back...
jsr SLIST.Next
bra .3
.9 lda #E.NOKEY
sec
rts
*--------------------------------------
SLIST.Select jsr K.GetMemPtr
>STYA IBlkPtr
>LDYA TXTPTR
SLIST.Select.I >STYA KeyID
ldy iBlk
lda (IBlkPtr),y
jsr K.GetMemPtr
>STYA DBlkPtr
rts
*--------------------------------------
SLIST.Next jsr SLIST.SkipKey
SLIST.SkipData jsr SLIST.GetDataLen
lda SLIST.DataLen
ldx SLIST.DataLen+1
SLIST.SkipDataAX
clc
adc iByte
sta iByte
txa
adc iBlk
sta iBlk
tay
lda (IBlkPtr),y
jsr K.GetMemPtr
>STYA DBlkPtr
rts
*--------------------------------------
SLIST.SkipKey ldy iByte
lda (DBlkPtr),y Get KeyLen
sec
adc iByte
sta iByte
bcc .8
jmp BLISTX.2NBlk
.8 rts
*--------------------------------------
SLIST.GetDataLen
jsr BLISTX.GetNByte Get DataLenLo
sta SLIST.DataLen
jsr BLISTX.GetNByte Get DataLenHI
sta SLIST.DataLen+1
rts
*--------------------------------------
SLIST.IsIDValid bit SLIST.Opt
bpl .2
cmp #'.'
beq .8
.1 bit SLIST.Opt
.2 bvc .3
cmp #'_'
beq .8
.3 jmp SHARED.IsDigitOrL
.8 clc
rts
*--------------------------------------
MAN
SAVE usr/src/sys/kernel.s.slistx
LOAD usr/src/sys/kernel.s
ASM