A2osX/SYS/KERNEL.S.SLIST.txt
2018-01-22 07:34:59 +00:00

330 lines
5.3 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
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
X.SLIST jmp (.1-SYS.SListAdd,x)
.1 .DA SLIST.Add
.DA SLIST.Lookup
.DA SLIST.GetByID
.DA SLIST.UpdateByID
.DA SLIST.New
.DA SLIST.Free.A
*--------------------------------------
SLIST.Add jsr SLIST.Search
bcc .9 Lookup succeeded...DUP
ldy #0
.1 jsr MEM.GetKeyCharY
iny
bcc .1
sty .8+1
tya
jsr SLIST.AddBlockByte
bcs .9
ldy #0
.2 jsr MEM.GetKeyCharY
bcs .3
jsr SLIST.AddBlockByte
bcs .9
iny
bra .2
.3 jsr MEM.GetDataByteY
tax
jsr SLIST.AddBlockByte
bcs .9
ldy #1
.4 jsr MEM.GetDataByteY
jsr SLIST.AddBlockByte
bcs .9
iny
dex
bne .4
.8 lda #$ff SELF MODIFIED
ldx SLIST.ID
ldy SLIST.ID+1
clc
.9 rts
*--------------------------------------
SLIST.Lookup jsr SLIST.Search
bcs .9
sty .8+1
ldy #0
jsr SLIST.GetBlockByte
tax
jsr MEM.SetDataByteY
.1 jsr SLIST.GetBlockByte
iny
jsr MEM.SetDataByteY
dex
bne .1
.8 lda #$ff SELF MODIFIED
ldx SLIST.ID
ldy SLIST.ID+1
clc
.9 rts
*--------------------------------------
SLIST.GetByID jsr SLIST.Select
ldy #0
jsr SLIST.GetBlockByte
beq .9
tax
jsr MEM.SetDataByteY
.1 iny
jsr SLIST.GetBlockByte
jsr MEM.SetDataByteY
dex
bne .1
jsr MEM.SetDataByteY
tax
jsr MEM.SetDataByteY
.2 iny
jsr SLIST.GetBlockByte
jsr MEM.SetDataByteY
dex
bne .2
>LDYA ZPSListKey
clc
rts
.9 sec
rts
*--------------------------------------
SLIST.UpdateByID
jsr SLIST.Select
ldy #0
jsr MEM.GetDataByteY
tax
jsr SLIST.SetBlockByte
bcs .9
.4 iny
jsr MEM.GetDataByteY
jsr SLIST.SetBlockByte
bcs .9
dex
bne .4
.8 lda #$ff SELF MODIFIED
clc
.9 rts
*--------------------------------------
SLIST.New >LDYAI 160 40k Max before out of memory!!!
jsr K.GetMem0.YA
bcs .9
>STYA ZPSListIndex
stx .8+1
>LDYAI 256
jsr K.GetMem0.YA
bcs .9
txa
sta (ZPSListIndex)
.8 lda #$ff SELF MODIFIED
.9 rts
*--------------------------------------
SLIST.Free.A sta .8+1
jsr K.GetMemPtr.A
>STYA .1+1
ldx #0
.1 lda $ffff,x SELF MODIFIED
beq .8
jsr K.FreeMem.A
inx
bra .1
.8 lda #$ff SELF MODIFIED
jmp K.FreeMem.A
*--------------------------------------
SLIST.Select jsr K.GetMemPtr.A
>STYA ZPSListIndex
ldy ZPSListKey
lda (ZPSListIndex),y
sta SLIST.IndexOfs
jsr K.GetMemPtr.A
>STYA ZPSListBlock
lda ZPSListKey+1
sta SLIST.BlockOfs
rts
*--------------------------------------
SLIST.Search jsr K.GetMemPtr.A
>STYA ZPSListIndex
stz SLIST.IndexOfs
lda (ZPSListIndex)
jsr K.GetMemPtr.A
>STYA ZPSListBlock
stz SLIST.BlockOfs
.1 lda SLIST.IndexOfs
sta SLIST.ID
lda SLIST.BlockOfs
sta SLIST.ID+1
jsr SLIST.GetBlockByte
tax
beq .9
ldy #0
.2 jsr MEM.GetKeyCharY
bcs .4
iny
sta .3+1
jsr SLIST.GetBlockByte
.3 cmp #$ff SELF MODIFIED
bne .4
dex
bne .2
clc Y = Key Length
rts
.4 jsr SLIST.GetBlockByte skip remaining key chars
dex
bne .4
jsr SLIST.GetBlockByte get Data Len
tax
.5 jsr SLIST.GetBlockByte skip data bytes
dex
bne .5
bra .1
.9 sec
rts
*--------------------------------------
SLIST.GetBlockByte
phy
ldy SLIST.BlockOfs
lda (ZPSListBlock),y
beq .99
inc SLIST.BlockOfs
bne .8
pha
inc SLIST.IndexOfs
ldy SLIST.IndexOfs
lda (ZPSListIndex),y
jsr K.GetMemPtr.A
>STYA ZPSListBlock
* stz SLIST.BlockOfs
pla
.8 ply
clc
rts
.9 pla
.99 ply
sec
rts
*--------------------------------------
SLIST.AddBlockByte
phy
ldy SLIST.BlockOfs
sta (ZPSListBlock),y
inc SLIST.BlockOfs
bne .8
inc SLIST.IndexOfs
>LDYAI 256
jsr K.GetMem0.YA
bcs .9
>STYA ZPSListBlock
txa
ldy SLIST.IndexOfs
sta (ZPSListIndex),y
* stz SLIST.BlockOfs
.8 ply
clc
rts
.9 ply
sec
rts
*--------------------------------------
SLIST.SetBlockByte
phy
ldy SLIST.BlockOfs
sta (ZPSListBlock),y
inc SLIST.BlockOfs
bne .8
inc SLIST.IndexOfs
ldy SLIST.IndexOfs
lda (ZPSListIndex),y
jsr K.GetMemPtr.A
>STYA ZPSListBlock
* stz SLIST.BlockOfs
.8 ply
clc
rts
*--------------------------------------
SLIST.IndexOfs .BS 1
SLIST.BlockOfs .BS 1
SLIST.ID .BS 2
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.SLIST
LOAD /A2OSX.SRC/SYS/KERNEL.S
ASM