A2osX/SYS/KERNEL.S.SLISTX.txt

531 lines
10 KiB
Plaintext
Raw Normal View History

NEW
2019-04-10 15:51:47 +00:00
AUTO 3,1
*--------------------------------------
2019-07-29 15:38:55 +00:00
ZPSListKeyID .EQ ZPMEMMGR+6
ZPSListDataPtr .EQ ZPMEMMGR+8
ZPSListDataLen .EQ ZPMEMMGR+10
ZPSListIBlkPtr .EQ ZPMEMMGR+12
ZPSListDBlkPtr .EQ ZPMEMMGR+14
*/--------------------------------------
* # SListGetData
* ## ASM
2019-08-12 07:40:16 +00:00
* `PUSHW DataOfs` (Start offset in Data)
* `PUSHW DataLen` (Data bytes to return, 0 if String mode)
* `PUSHW DataPtr` (0 if KERNEL should allocate a buffer)
2019-07-29 15:38:55 +00:00
* `PUSHW KeyID`
* `lda hSList`
* `>SYSCALL SListGetData`
* ## RETURN VALUE
* Y,A = Byte Count
* X = hMem (if DataPtr = 0)
*\--------------------------------------
K.SListGetData sta SLIST.hList
jsr SHARED.PullYA
>STYA ZPSListKeyID
jsr SHARED.PullYA
>STYA ZPSListDataPtr
jsr SHARED.PullYA
>STYA ZPSListDataLen
jsr SHARED.PullYA
>STYA ZPMemMgrSize
jsr SLIST.Select
2019-03-15 16:20:28 +00:00
jsr SLIST.SkipKey
jsr SLIST.GetDataLen
2019-03-18 06:53:20 +00:00
2019-03-18 16:48:16 +00:00
lda SLIST.DataLen
2019-03-15 16:20:28 +00:00
sec
2019-08-12 07:40:16 +00:00
sbc ZPMemMgrSize Offset
2019-03-15 16:20:28 +00:00
eor #$ff
sta SLIST.nDataCnt
lda SLIST.DataLen+1
2019-04-01 06:07:56 +00:00
sbc ZPMemMgrSize+1
2019-03-15 16:20:28 +00:00
eor #$ff
sta SLIST.nDataCnt+1 Data remaining
2019-03-18 16:48:16 +00:00
2019-08-12 07:40:16 +00:00
bcc .99 Offset Beyond DataLen
2019-03-18 16:48:16 +00:00
2019-08-12 07:40:16 +00:00
.10 lda ZPMemMgrSize Skip to Offset
2019-03-18 16:48:16 +00:00
ldx ZPMemMgrSize+1
jsr SLIST.SkipDataAX
lda ZPSListDataPtr
ora ZPSListDataPtr+1
bne .12
>LDYA SLIST.DataLen
2019-08-12 07:40:16 +00:00
iny
bne .11
inc +1 for ending 0
.11 ldx #SYS.GetMem
2019-08-05 13:30:58 +00:00
jsr K.SYSCALL2.MAIN !!! Get a buffer In MAIN Mem !!!
2019-03-18 16:48:16 +00:00
bcs .9
stx .82+1
>STYA ZPSListDataPtr
.12 lda ZPSListDataLen
ora ZPSListDataLen+1
2019-03-18 06:53:20 +00:00
sec
2019-03-15 16:20:28 +00:00
beq .1 String Mode
lda ZPSListDataLen
eor #$ff
sta SLIST.nBufCnt
lda ZPSListDataLen+1
eor #$ff
sta SLIST.nBufCnt+1
2019-03-18 06:53:20 +00:00
clc
2019-03-15 16:20:28 +00:00
.1 ror SLIST.bStringMode
stz ZPSListDataLen
stz ZPSListDataLen+1
.2 inc SLIST.nDataCnt
bne .3
inc SLIST.nDataCnt+1
beq .8
.3 inc SLIST.nBufCnt
bne .4
inc SLIST.nBufCnt+1
beq .8
.4 jsr SLIST.GetNextByte
bit SLIST.bStringMode
bpl .5
cmp #C.CR
2019-04-01 06:07:56 +00:00
beq .8
2019-07-28 20:39:30 +00:00
.5 jsr SHARED.SetDataByte
2019-03-15 16:20:28 +00:00
inc ZPSListDataLen
bne .2
inc ZPSListDataLen+1
bra .2
2019-03-18 06:53:20 +00:00
2019-05-12 20:45:11 +00:00
.99 lda #E.EMPTYKEY
2019-03-15 16:20:28 +00:00
sec
2019-03-18 16:48:16 +00:00
.9 rts
2019-03-18 06:53:20 +00:00
2019-08-12 07:40:16 +00:00
.8 lda #0
2019-07-28 20:39:30 +00:00
jsr SHARED.SetDataByte
2019-03-18 06:53:20 +00:00
.81 >LDYA ZPSListDataLen
.82 ldx #$ff SELF MODIFIED
clc
rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListAddData
* ## ASM
* `PUSHW DataLen`
* `PUSHW DataPtr`
* `PUSHW KeyID`
* `lda hSList`
* `>SYSCALL SListAddData`
* ## RETURN VALUE
*\--------------------------------------
K.SListAddData sta SLIST.hList
jsr SHARED.PullYA
>STYA ZPSListKeyID
jsr SHARED.PullYA
>STYA ZPSListDataPtr
jsr SHARED.PullYA
>STYA ZPSListDataLen
jsr SLIST.Select
2019-03-15 16:20:28 +00:00
jsr SLIST.SkipKey
>LDYA SLIST.KeyID Save DataLen location
>STYA ZPSListKeyID to update later
2018-01-29 16:48:07 +00:00
2019-03-27 17:01:01 +00:00
ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y
2019-03-15 16:20:28 +00:00
pha
2018-01-29 16:48:07 +00:00
clc
2019-03-27 17:01:01 +00:00
adc ZPSListDataLen
sta (ZPSListDBlkPtr),y
php
jsr SLIST.ToNextByte skip LEN lo
plp
ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y
pha
adc ZPSListDataLen+1
sta (ZPSListDBlkPtr),y
jsr SLIST.ToNextByte skip LEN hi
plx
2019-03-15 16:20:28 +00:00
pla
2019-03-27 17:01:01 +00:00
jsr SLIST.SkipDataAX
lda ZPSListDataLen
2019-03-15 16:20:28 +00:00
eor #$ff
sta ZPSListDataLen
lda ZPSListDataLen+1
eor #$ff
sta ZPSListDataLen+1
.1 inc ZPSListDataLen
bne .2
inc ZPSListDataLen+1
beq .8
2019-07-28 20:39:30 +00:00
.2 jsr SHARED.GetDataByte
2019-03-15 16:20:28 +00:00
jsr SLIST.AddBlockByte
2019-03-18 06:53:20 +00:00
bcc .1
2019-03-14 16:51:02 +00:00
rts
2019-03-15 16:20:28 +00:00
2019-03-18 16:48:16 +00:00
.8 lda #0
2019-08-12 07:40:16 +00:00
jsr SLIST.AddBlockByte Add an extra 0 to stop Search here
clc
rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListSetData
* ## ASM
* `PUSHW DataLen`
* `PUSHW DataPtr`
* `PUSHW KeyID`
* `lda hSList`
* `>SYSCALL SListSetData`
* ## RETURN VALUE
*\--------------------------------------
K.SListSetData sta SLIST.hList
jsr SHARED.PullYA
>STYA ZPSListKeyID
jsr SHARED.PullYA
>STYA ZPSListDataPtr
jsr SHARED.PullYA
>STYA ZPSListDataLen
jsr SLIST.Select
2019-03-18 16:48:16 +00:00
jsr SLIST.SkipKey
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
2019-07-28 20:39:30 +00:00
.2 jsr SHARED.GetDataByte
2019-03-18 16:48:16 +00:00
jsr SLIST.SetBlockByte
bra .1
.8 clc
rts
.9 lda #E.DATALEN
sec
2019-03-13 16:29:24 +00:00
rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListGetByID
* ## ASM
* `PUSHW KeyPtr`
* `PUSHW KeyID`
* `lda hSList`
* `>SYSCALL SListGetByID`
* ## RETURN VALUE
* Y,A = Next KeyID
*\--------------------------------------
K.SListGetByID sta SLIST.hList
jsr SHARED.PullYA
>STYA ZPSListKeyID
jsr SHARED.PullYA
>STYA ZPSListDataPtr
jsr SLIST.Select
2019-03-18 16:48:16 +00:00
jsr SLIST.GetNextByte
tax
beq .9
ldy #0
2019-03-21 07:07:38 +00:00
.1 phy
jsr SLIST.GetNextByte
ply
2019-07-28 20:39:30 +00:00
jsr SHARED.SetKeyCharY
iny
dex
bne .1
2019-03-18 16:48:16 +00:00
txa lda #0
2019-07-28 20:39:30 +00:00
jsr SHARED.SetKeyCharY
2019-03-18 16:48:16 +00:00
jsr SLIST.SkipData
2019-03-15 16:20:28 +00:00
>LDYA SLIST.KeyID
2019-03-18 16:48:16 +00:00
clc
rts
.9 lda #E.NOKEY
sec
rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListNewKey
* ## ASM
* `PUSHW KeyPtr`
* `lda hSList`
* `>SYSCALL SListNewKey`
* ## RETURN VALUE
* Y,A = KeyID
* X = KeyLen
*\--------------------------------------
K.SListNewKey sta SLIST.hList
jsr SHARED.PullYA
>STYA ZPSListDataPtr
2019-08-05 13:30:58 +00:00
2019-07-29 15:38:55 +00:00
jsr SLIST.Search
2019-03-14 16:51:02 +00:00
bcc .99
lda SLIST.KeyLen
jsr SLIST.AddBlockByte
bcs .9
ldy #0
2019-07-28 20:39:30 +00:00
.1 jsr SHARED.GetKeyCharY
2019-03-14 16:51:02 +00:00
jsr SLIST.AddBlockByte
bcs .9
iny
cpy SLIST.KeyLen
bne .1
2019-03-27 17:01:01 +00:00
lda #0 Data Len = 0
2019-03-14 16:51:02 +00:00
jsr SLIST.AddBlockByte
bcs .9
lda #0
jsr SLIST.AddBlockByte
bcs .9
2019-03-27 17:01:01 +00:00
lda #0 Next Len = 0
jsr SLIST.AddBlockByte
bcs .9
2019-03-15 16:20:28 +00:00
>LDYA ZPSListKeyID
2019-03-19 16:52:08 +00:00
ldx SLIST.KeyLen
2019-03-13 16:29:24 +00:00
clc
rts
2019-04-09 15:47:33 +00:00
.99 lda #E.DUPKEY
2019-03-14 16:51:02 +00:00
sec
2019-10-03 06:25:27 +00:00
.9 rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListLookup
* ## ASM
* `PUSHW KeyPtr`
* `lda hSList`
* `>SYSCALL SListLookup`
* ## RETURN VALUE
* Y,A = KeyID
* X = Key Length
*\--------------------------------------
K.SListLookup sta SLIST.hList
jsr SHARED.PullYA
>STYA ZPSListDataPtr
jsr SLIST.Search
2019-03-13 16:29:24 +00:00
bcs .9
2019-03-18 06:53:20 +00:00
>LDYA ZPSListKeyID
2019-03-14 16:51:02 +00:00
ldx SLIST.KeyLen
2019-03-13 16:29:24 +00:00
.9 rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListNew
* ## ASM
* `>SYSCALL SListNew`
* ## RETURN VALUE
* A=hSList
*\--------------------------------------
K.SListNew >LDYAI 160 40k Max before out of memory!!!
2018-06-21 15:12:10 +00:00
jsr K.GetMem0
2018-01-22 07:34:59 +00:00
bcs .9
>STYA ZPSListIBlkPtr
2018-01-22 07:34:59 +00:00
stx .8+1
>LDYAI 256
2019-03-27 17:01:01 +00:00
jsr K.GetMem
2018-01-22 07:34:59 +00:00
bcs .9
2019-03-27 17:01:01 +00:00
>STYA ZPSListDBlkPtr
lda #0
sta (ZPSListDBlkPtr)
2018-01-22 07:34:59 +00:00
txa
sta (ZPSListIBlkPtr)
2019-10-03 06:25:27 +00:00
.8 lda #$ff SELF MODIFIED
2018-01-22 07:34:59 +00:00
.9 rts
2019-07-29 15:38:55 +00:00
*/--------------------------------------
* # SListFree
* ## ASM
* `lda hSList`
* `>SYSCALL SListFree`
* ## RETURN VALUE
*\--------------------------------------
K.SListFree sta .8+1
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
>STYA .1+1
ldx #0
.1 lda $ffff,x SELF MODIFIED
beq .8
2018-06-21 15:12:10 +00:00
jsr K.FreeMem
inx
bra .1
.8 lda #$ff SELF MODIFIED
2018-06-21 15:12:10 +00:00
jmp K.FreeMem
*--------------------------------------
2019-03-14 16:51:02 +00:00
* PRIVATE
2019-07-29 15:38:55 +00:00
*--------------------------------------
2019-08-05 13:30:58 +00:00
SLIST.Search lda SLIST.hList
jsr K.GetMemPtr
>STYA ZPSListIBlkPtr
lda (ZPSListIBlkPtr)
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
2019-03-14 16:51:02 +00:00
ldy #$ff
2019-03-14 16:51:02 +00:00
.1 iny
2019-07-28 20:39:30 +00:00
jsr SHARED.GetKeyCharY
2019-03-14 16:51:02 +00:00
bcc .1
sty SLIST.KeyLen
2019-03-18 16:48:16 +00:00
2019-03-27 17:01:01 +00:00
stz SLIST.BytePtr
stz SLIST.BlockPtr
2019-03-18 06:53:20 +00:00
.2 >LDYA SLIST.KeyID
>STYA ZPSListKeyID
2019-03-18 16:48:16 +00:00
ldy SLIST.BytePtr
2019-03-18 06:53:20 +00:00
lda (ZPSListDBlkPtr),y
2019-03-18 16:48:16 +00:00
beq .9
2019-03-18 06:53:20 +00:00
cmp SLIST.KeyLen
2019-03-15 16:20:28 +00:00
bne .5
2019-03-18 06:53:20 +00:00
jsr SLIST.GetNextByte Skip Len
2019-03-14 16:51:02 +00:00
ldy #0
2019-03-18 06:53:20 +00:00
.3 phy
jsr SLIST.GetNextByte
2019-03-15 16:20:28 +00:00
sta .4+1
2019-03-18 06:53:20 +00:00
ply
2019-07-28 20:39:30 +00:00
jsr SHARED.GetKeyCharY
2019-10-03 06:25:27 +00:00
.4 cmp #$ff SELF MODIFIED
2019-03-15 16:20:28 +00:00
bne .5
2019-03-14 16:51:02 +00:00
iny
cpy SLIST.KeyLen
bne .3
clc
rts
2019-03-28 16:48:22 +00:00
.5 jsr SLIST.Select.I move back to ZPSListKeyID
2019-03-19 07:26:14 +00:00
jsr SLIST.Next
2019-03-18 06:53:20 +00:00
bra .2
2019-03-14 16:51:02 +00:00
.9 lda #E.NOKEY
sec
rts
*--------------------------------------
2019-08-05 13:30:58 +00:00
SLIST.Select lda SLIST.hList
jsr K.GetMemPtr
2019-03-28 16:48:22 +00:00
>STYA ZPSListIBlkPtr
SLIST.Select.I ldy ZPSListKeyID+1
sty SLIST.BlockPtr
2019-10-03 06:25:27 +00:00
lda (ZPSListIBlkPtr),y
2019-03-28 16:48:22 +00:00
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
lda ZPSListKeyID
sta SLIST.BytePtr
rts
*--------------------------------------
2019-03-15 16:20:28 +00:00
SLIST.Next jsr SLIST.SkipKey
SLIST.SkipData jsr SLIST.GetDataLen
2019-03-27 17:01:01 +00:00
2019-03-15 16:20:28 +00:00
lda SLIST.DataLen
ldx SLIST.DataLen+1
2019-10-03 06:25:27 +00:00
SLIST.SkipDataAX
2019-03-15 16:20:28 +00:00
clc
adc SLIST.BytePtr
sta SLIST.BytePtr
txa
adc SLIST.BlockPtr
sta SLIST.BlockPtr
2019-03-18 06:53:20 +00:00
tay
lda (ZPSListIBlkPtr),y
2019-03-15 16:20:28 +00:00
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
rts
2019-03-14 16:51:02 +00:00
*--------------------------------------
2019-03-15 16:20:28 +00:00
SLIST.SkipKey ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y Get KeyLen
sec
adc SLIST.BytePtr
sta SLIST.BytePtr
2019-03-27 21:14:40 +00:00
bcs SLIST.ToNextBlock
2019-03-15 16:20:28 +00:00
.8 rts
*--------------------------------------
SLIST.GetDataLen
jsr SLIST.GetNextByte Get DataLenLo
sta SLIST.DataLen
jsr SLIST.GetNextByte Get DataLenHI
sta SLIST.DataLen+1
rts
*--------------------------------------
SLIST.GetNextByte
ldy SLIST.BytePtr
lda (ZPSListDBlkPtr),y
2019-03-27 21:14:40 +00:00
SLIST.ToNextByte
2019-03-15 16:20:28 +00:00
inc SLIST.BytePtr
bne .8
pha
2019-03-27 21:14:40 +00:00
jsr SLIST.ToNextBlock
2019-03-15 16:20:28 +00:00
pla
2019-10-03 06:25:27 +00:00
.8 rts
*--------------------------------------
SLIST.AddBlockByte
phy
2019-03-15 16:20:28 +00:00
ldy SLIST.BytePtr
sta (ZPSListDBlkPtr),y
2019-03-15 16:20:28 +00:00
inc SLIST.BytePtr
bne .8
phx
>LDYAI 256
2019-03-27 17:01:01 +00:00
jsr K.GetMem
bcs .9
>STYA ZPSListDBlkPtr
txa
2019-03-15 16:20:28 +00:00
inc SLIST.BlockPtr
ldy SLIST.BlockPtr
sta (ZPSListIBlkPtr),y
2019-03-15 16:20:28 +00:00
* stz SLIST.BytePtr
plx
.8 ply
clc
rts
.9 plx
ply
2019-10-03 06:25:27 +00:00
rts
*--------------------------------------
SLIST.SetBlockByte
2019-03-18 06:53:20 +00:00
ldy SLIST.BytePtr
sta (ZPSListDBlkPtr),y
2019-03-18 06:53:20 +00:00
inc SLIST.BytePtr
2019-08-12 07:40:16 +00:00
bne SLIST.ToNextBlock.RTS
2019-03-27 21:14:40 +00:00
*--------------------------------------
SLIST.ToNextBlock
inc SLIST.BlockPtr
ldy SLIST.BlockPtr
lda (ZPSListIBlkPtr),y
2018-06-21 15:12:10 +00:00
jsr K.GetMemPtr
>STYA ZPSListDBlkPtr
2019-10-03 06:25:27 +00:00
SLIST.ToNextBlock.RTS
2019-03-27 21:14:40 +00:00
rts
*--------------------------------------
2019-07-29 15:38:55 +00:00
SLIST.hList .BS 1
2019-03-14 16:51:02 +00:00
SLIST.KeyLen .BS 1
2019-03-15 16:20:28 +00:00
SLIST.DataLen .BS 2
SLIST.nDataCnt .BS 2
SLIST.nBufCnt .BS 2
SLIST.bStringMode .BS 1
SLIST.KeyID .EQ *
SLIST.BytePtr .BS 1
SLIST.BlockPtr .BS 1
*--------------------------------------
MAN
2019-04-10 15:51:47 +00:00
SAVE USR/SRC/SYS/KERNEL.S.SLISTX
2018-11-17 17:17:13 +00:00
LOAD USR/SRC/SYS/KERNEL.S
ASM