Kernel 0.9.1 : ASM rewrite....new SLIST API

This commit is contained in:
Rémy GIBERT 2018-01-19 16:21:31 +00:00
parent 4829797475
commit db753146f6
13 changed files with 497 additions and 808 deletions

View File

@ -284,51 +284,55 @@ Create a new copy of this C-String
+ CS : error
+ A = SYS error code
# SListNew
# SListAdd
## In:
+ PUSHB = hSList
+ PUSHW = Key Ptr
+ PUSHW = Data Ptr
## Out:
+ A=hMem
+ A = Key Length
# SListLookup
## In:
+ PUSHB = hSList
+ PUSHW = Key Ptr
+ PUSHW = Data Ptr
## Out:
+ A = Key Length
+ X,Y = KeyID
# SListGetByID
## In:
+ PUSHB = hSList
+ PUSHW = KeyID
+ PUSHW = Data Ptr (KEY+DATA)
## Out:
+ Y,A = Next ID
# SListUpdateByID
## In:
+ PUSHB = hSList
+ PUSHW = KeyID
+ PUSHW = Data Ptr
## Out:
+ A = Key Length
+ X,Y = KeyID
# SListAdd
# SListNew
## In:
+ PUSHB = hSList
+ PUSHW = Key
+ PUSHW = Data Ptr
## Out:
+ A=hSList
# SListLookup
## In:
+ PUSHB = hSList
+ PUSHW = Key
+ PUSHW = Data Ptr
## Out:
+ Data Ptr Updated
# SListUpdate
## In:
+ PUSHB = hSList
+ PUSHW = Key
+ PUSHW = Data Ptr
## Out:
# SListFree
## In:

Binary file not shown.

Binary file not shown.

View File

@ -173,31 +173,51 @@ EXP.SetAccA sta SRC.ACC
stz SRC.ACC+3
rts
*---------------------------------------
EXP.GetSymbol >LDYA L.SRC.ELabel.Len
jsr SRC.GetLabel
bcs EXP.EvalExitSYN
EXP.GetSymbol >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHEA.G SYM.Value
>LDYA L.SRC.ELabel.Flags
jsr SYM.SearchGlobal
bcc .1
>SYSCALL SListLookup
bcs .2
ldy #ASM.PASS
lda (pData),y pass#2?
bne EXP.EvalExitUND yes, undefined symbol
adc ZPLinePtr
sta ZPLinePtr
bcc .1
lda #$C0 Valid+Pending
sta SRC.ELabel.Flags
>LDYA L.SRC.ELabel.Flags
jsr SYM.AddGToGBlockYA
inc ZPLinePtr+1
.1 clc
rts
.2 ldy #ASM.PASS
lda (pData),y pass#2?
bne .99 yes, undefined symbol
>PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHEA.G SYM.Value
lda #6
>STA.G SYM.Value+SYM.LEN
.1 ldx #3
.2 lda SRC.FLabel.Value,x
sta SRC.ACC,x
dex
bpl .2
clc
rts
lda #0
>STA.G SYM.Value+SYM.F
>SYSCALL SListAdd
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .3
inc ZPLinePtr+1
.3 clc
rts
.99 lda #ERR.UNDEF.SYMBOL
sec
.9 rts
*---------------------------------------
EXP.Compute dec
asl

View File

@ -116,12 +116,6 @@ SRC.ParseLine.Ok lda SRC.GLabel.New
bne .8 yes, nothing to do
* --- Pass #1
clc
rts
>LDYA L.SRC.GLabel.Flags
jsr SYM.SearchGlobal
bcs .1 if CS, not found, add
@ -172,34 +166,9 @@ SRC.ParseLine.SymL jsr SRC.GetNextChar
bne SRC.ParseLine.SymE Max .255
lda SRC.ACC
beq SRC.ParseLine.SymE .0 is not allowed
sta SRC.LLabel.ID
ldy #ASM.PC
lda (pData),y
ldy #ASM.PC.GLABEL
sec
sbc (pData),y
sta SRC.LLabel.Offset
ldy #ASM.PC+1
lda (pData),y
ldy #ASM.PC.GLABEL+1
sbc (pData),y
bne SRC.ParseLine.SymR
ldy #ASM.PC+2
lda (pData),y
ldy #ASM.PC.GLABEL+2
sbc (pData),y
bne SRC.ParseLine.SymR
ldy #ASM.PC+3
lda (pData),y
ldy #ASM.PC.GLABEL+3
sbc (pData),y
bne SRC.ParseLine.SymR
bcc SRC.ParseLine.SymR
jmp SYM.AddLToGBlock
clc
rts
*---------------------------------------
SRC.ParseLine.SymE lda #ERR.INV.LABEL
sec
@ -209,31 +178,20 @@ SRC.ParseLine.SymR lda #ERR.RANGE
sec
rts
*---------------------------------------
SRC.ParseLine.SymG >LDYA L.SRC.GLabel.Len
jsr SRC.GetLabel
SRC.ParseLine.SymG >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHEA.G SYM.Value
>SYSCALL SListAdd
bcs SRC.ParseLine.SymE
adc ZPLinePtr
sta ZPLinePtr
bcc .1
ldx #3 Makes Current Label = PC for now
ldy #ASM.PC+3
inc ZPLinePtr+1
.1 lda (pData),y
sta SRC.GLabel.Value,x
dey
dex
bpl .1
ldx #3 Makes Current Label = Ref for next local
ldy #ASM.PC.GLABEL+3
.2 lda SRC.GLabel.Value,x
sta (pData),y
dey
dex
bpl .2
lda #$80 Mark GLabel Flag...
sta SRC.GLabel.Flags
sta SRC.GLabel.New
.1
clc
rts
@ -682,49 +640,6 @@ SRC.GetBinary stz SRC.ACC+1
sec
rts
*---------------------------------------
SRC.GetLabel >STYA ZPPtr1
lda (ZPLinePtr)
beq .9
jsr SRC.IsLetter
bcs .9
ldy #1
sta (ZPPtr1),y
.1 jsr SRC.GetNextCharUC
beq .8
jsr SRC.IsLetterOrDigit
bcc .2
cmp #'.'
beq .2
cmp #'_'
beq .2
cmp #' '
beq .8
jsr SRC.IsEXPReserved
bcc .8
jsr SRC.IsAMReserved
bcc .8
.9 lda #ERR.SYNTAX.ERROR
sec
rts
.2 iny
sta (ZPPtr1),y
cpy #SRC.GLABEL.MAXLEN
bcc .1 if equ Carry is set
.8 tya
sta (ZPPtr1)
clc
rts
*---------------------------------------
SRC.GetKeyword >STYA ZPPtr1 KeyWord table
stz SRC.Keyword.ID

View File

@ -3,14 +3,12 @@ PREFIX /A2OSX.BUILD
AUTO 4,1
*---------------------------------------
* Global Symbol Record: (8+ bytes)
* 0 : Flags:
* b7=Valid Entry
* b6=pending
* b0=R/W (.SE)
* 1-4 : 32 bits Value
* 5 : Len
* 6-... Name
* ......
* 0 : Len (6)
* 1 : Flags:
* b7=0=pending,1=resolved
* b6=R/W (.SE)
* 2-5 : 32 bits Value
*
* Local Symbol Record: (2 bytes)
* 2 : Local ID (1->255)
* 3 : offset from Global Symbol
@ -28,96 +26,23 @@ AUTO 4,1
*---------------------------------------
* Macro Record: ( bytes)
*---------------------------------------
SYM.Init jmp SYM.NewGBlock
*---------------------------------------
SYM.Quit ldy #SYM.pLastGBlock
lda (pData),y
beq .8
.1 clc
adc #SYM.hGBlocks-1
tay
lda (pData),y
>SYSCALL FreeMem.A
ldy #SYM.pLastGBlock
lda (pData),y
dec
sta (pData),y
bne .1
SYM.Init >SYSCALL SListNew
bcs .9
.8 clc
>STA.G SYM.hGlobals
.9 rts
*---------------------------------------
SYM.Quit >LDA.G SYM.hGlobals
>SYSCALL SListFree.A
rts
*---------------------------------------
SYM.Dump >LDYA L.MSG.SYMBOLS
>SYSCALL PrintF.YA
ldy #SYM.DumpCount
lda #20
sta (pData),y
jsr SYM.ResetGBlockPtr
.1 jsr SYM.GetByteGBlock Get Flags
sta SRC.GLabel.Flags
bne .10
clc
rts
.10 ldx #0
.2 jsr SYM.GetByteGBlock
sta SRC.GLabel.Value,x
inx
cpx #5
bne .2 Get Value+Len
ldx #0
.3 jsr SYM.GetByteGBlock
sta SRC.GLabel.Name,x
inx
cpx SRC.GLabel.Len
bne .3
>PUSHW L.SRC.GLabel.Len
lda SRC.GLabel.Value+1
>PUSHA
lda SRC.GLabel.Value
>PUSHA
lda SRC.GLabel.Value+3
>PUSHA
lda SRC.GLabel.Value+2
>PUSHA
>LDYA L.MSG.GSYMBOL
>SYSCALL PrintF.YA
bcs .9
.4 jsr SYM.GetByteGBlock
beq .5 End Locals...proceed next Global
pha
jsr SYM.GetByteGBlock
>PUSHA
pla
>PUSHA
>LDYA L.MSG.LSYMBOL
>SYSCALL PrintF.YA
bcc .4
rts
.5 lda #13
>SYSCALL PutChar.A
ldy #SYM.DumpCount
lda (pData),y
dec
bne .6
lda #20
.6 sta (pData),y
jmp .1
.9 rts
*---------------------------------------
SYM.AddPending
*---------------------------------------
SYM.AddPrivate
clc
@ -143,206 +68,7 @@ SYM.SearchLocal
clc
rts
*---------------------------------------
SYM.SearchGlobal >STYA ZPSymbolPtr
jsr SYM.ResetGBlockPtr
.1 ldy #SYM.iCurGBlock
lda (pData),y
sta SYM.iCurGBlock.Save
ldy #SYM.pCurGBlock
lda (pData),y
sta SYM.pCurGBlock.Save
jsr SYM.GetByteGBlock Get Flags
beq .9
sta SRC.FLabel.Flags
ldx #0
.2 jsr SYM.GetByteGBlock
sta SRC.FLabel.Value,x
inx
cpx #5
bne .2 Get Value+Len
ldx #0
.3 jsr SYM.GetByteGBlock
sta SRC.FLabel.Name,x
inx
cpx SRC.FLabel.Len
bne .3
txa
ldy #5
cmp (ZPSymbolPtr),y
bne .5
ldx #0
.4 inx
iny
lda SRC.FLabel.Name-1,x
cmp (ZPSymbolPtr),y
bne .5
cpx SRC.FLabel.Len
bne .4
lda SYM.pCurGBlock.Save
ldy #SYM.pCurGBlock
sta (pData),y
lda SYM.iCurGBlock.Save
ldy #SYM.iCurGBlock
sta (pData),y
jmp SYM.GetGBlockA
.5 jsr SYM.GetByteGBlock skip Locals
beq .1
jsr SYM.GetByteGBlock
bra .5
.9 sec
rts
*---------------------------------------
SYM.AddGToGBlockYA >STYA ZPSymbolPtr
jsr SYM.SetGBlockPtr
ldy #SYM.pLastGBlock 1st Gblock to add?
lda (pData),y
ldy #SYM.iLastGBlock
ora (pData),y
beq .10 yes, skip closing previous one
lda #0 Close Pending Global/Local
jsr SYM.AddByteGBlock
bcs .9
.10 ldy #0
.1 lda (ZPSymbolPtr),y
jsr SYM.AddByteGBlock
bcs .9
iny
cpy #5
bne .1 moved Flags & Value to GBlock....
lda (ZPSymbolPtr),y Get Len
tax
jsr SYM.AddByteGBlock
bcs .9
.2 iny
lda (ZPSymbolPtr),y
jsr SYM.AddByteGBlock
bcs .9
dex
bne .2
clc
.9 rts
*---------------------------------------
SYM.AddLToGBlock jsr SYM.SetGBlockPtr
lda SRC.LLabel.ID
jsr SYM.AddByteGBlock
bcs .9
lda SRC.LLabel.Offset
jmp SYM.AddByteGBlock
.9 rts
*---------------------------------------
SYM.GetByteGBlock ldy #SYM.iCurGBlock
lda (pData),y
tay
lda (ZPBlockPtr),y
pha
ldy #SYM.iCurGBlock
lda (pData),y
inc
sta (pData),y
bne .1
ldy #SYM.pCurGBlock
lda (pData),y
inc
sta (pData),y
jsr SYM.GetGBlockA
.1 pla
clc
rts
*---------------------------------------
SYM.ResetGBlockPtr lda #0
ldy #SYM.pCurGBlock
sta (pData),y
ldy #SYM.iCurGBlock
sta (pData),y
bra SYM.GetGBlockA
*---------------------------------------
SYM.SetGBlockPtr ldy #SYM.pLastGBlock
lda (pData),y
SYM.GetGBlockA clc
adc #SYM.hGBlocks-1
tay
lda (pData),y
phx
>SYSCALL GetMemPtr.A
>STYA ZPBlockPtr
plx
rts
*---------------------------------------
SYM.AddByteGBlock phx
phy
pha
ldy #SYM.iLastGBlock
lda (pData),y
tay
pla
sta (ZPBlockPtr),y
tya
inc
beq SYM.NewGBlock2
ldy #SYM.iLastGBlock
sta (pData),y
ply
plx
clc
rts
*---------------------------------------
SYM.NewGBlock phx
phy
SYM.NewGBlock2 >LDYAI 256
>SYSCALL GetMem0.YA
bcs .9
>STYA ZPBlockPtr
ldy #SYM.pLastGBlock
lda (pData),y
inc
sta (pData),y
clc
adc #SYM.hGBlocks-1
tay
txa
sta (pData),y
lda #0
ldy #SYM.iLastGBlock
sta (pData),y
clc
.9 ply
plx
SYM.SearchGlobal clc
rts
*---------------------------------------
MAN

View File

@ -21,18 +21,18 @@ ZPAMPtr .EQ ZPBIN+16
ZPRPtr .EQ ZPBIN+18
ZPOPtr .EQ ZPBIN+20
*---------------------------------------
SYM.LEN .EQ 0
SYM.F .EQ 1
SYM.F.RESOLVED .EQ %1000000
SYM.F.RW .EQ %0100000
SYM.V .EQ 2
*---------------------------------------
ASM.T.AM .EQ 0
ASM.T.R .EQ 2
ASM.T.O .EQ 4
*---------------------------------------
SRC.DO.MAXDEPTH .EQ 8
SRC.IN.MAXDEPTH .EQ 7
SRC.GLABEL.MAXLEN .EQ 32
*---------------------------------------
SYM.GBLOCK.MAX .EQ 96 96*256=24k
SYM.SBLOCK.MAX .EQ 16 16*256=4k
SYM.PBLOCK.MAX .EQ 32 32*256=8k
SYM.MBLOCK.MAX .EQ 32 32*256=8k
*---------------------------------------
ERR.INV.ARGS .EQ $80
ERR.SRC.INV.TYPE .EQ $90
@ -88,10 +88,6 @@ L.MSG.SRC.FILE .DA MSG.SRC.FILE
L.MSG.OBJ.FILE .DA MSG.OBJ.FILE
L.MSG.T.FILE .DA MSG.T.FILE
L.SRC.AM.StrBuf .DA SRC.AM.StrBuf
L.SRC.GLabel.Flags .DA SRC.GLabel.Flags
L.SRC.GLabel.Len .DA SRC.GLabel.Len
L.SRC.ELabel.Flags .DA SRC.ELabel.Flags
L.SRC.ELabel.Len .DA SRC.ELabel.Len
L.ASM.6502 .DA ASM.6502
L.ASM.T.FILENAME .DA ASM.T.FILENAME
L.FIO.Stat .DA FIO.Stat
@ -397,9 +393,6 @@ FIO.Stat .BS S.STAT
EXP.Operator .BS 1
EXP.Modifier .BS 1
SYM.iCurGBlock.Save .BS 1
SYM.pCurGBlock.Save .BS 1
SRC.LINENUM .BS 2
SRC.LinePtrSave .BS 2
SRC.Directive.ID .BS 1
@ -410,21 +403,6 @@ SRC.ARG .BS 4
SRC.AM.ID .BS 1
SRC.AM.StrBuf .BS 32
SRC.AM.tmpBuf .BS 32
SRC.GLabel.New .BS 1
SRC.GLabel.Flags .BS 1
SRC.GLabel.Value .BS 4
SRC.GLabel.Len .BS 1
SRC.GLabel.Name .BS SRC.GLABEL.MAXLEN
SRC.LLabel.ID .BS 1
SRC.LLabel.Offset .BS 1
SRC.ELabel.Flags .BS 1
SRC.ELabel.Value .BS 4
SRC.ELabel.Len .BS 1
SRC.ELabel.Name .BS SRC.GLABEL.MAXLEN
SRC.FLabel.Flags .BS 1
SRC.FLabel.Value .BS 4
SRC.FLabel.Len .BS 1
SRC.FLabel.Name .BS SRC.GLABEL.MAXLEN
*--------------------------------------
.DUMMY
.OR 0
@ -446,29 +424,6 @@ DST.hFILETYPE .BS 1
ASM.T.hMem .BS 1
SYM.hCurSBlock .BS 1
SYM.iCurSBlock .BS 1
SYM.LastSBlock .BS 1
SYM.hSBlocks .BS SYM.SBLOCK.MAX
SYM.pCurGBlock .BS 1
SYM.iCurGBlock .BS 1
SYM.pLastGBlock .BS 1
SYM.iLastGBlock .BS 1
SYM.hGBlocks .BS SYM.GBLOCK.MAX
SYM.hCurPBlock .BS 1
SYM.iCurPBlock .BS 1
SYM.LastPBlock .BS 1
SYM.hPBlocks .BS SYM.PBLOCK.MAX
SYM.hCurMBlock .BS 1
SYM.iCurMBlock .BS 1
SYM.LastMBlock .BS 1
SYM.hMBlocks .BS SYM.MBLOCK.MAX
SYM.DumpCount .BS 1
DIR.Counter .BS 2
DIR.Byte .BS 1
@ -487,6 +442,9 @@ ASM.PC.GLABEL .BS 4
ASM.LOCAL.OFFSET .BS 1
ASM.LOCAL.INVALID .BS 1
ASM.SYM.ID .BS 2
SYM.hGlobals .BS 1
SYM.Value .BS 6
DS.END .ED
*---------------------------------------
.DO DS.END-DS.START>$FF

View File

@ -213,14 +213,14 @@ SYS.GetMemByID.A .EQ $E6
SYS.GetMem.YA .EQ $E8
SYS.GetMem0.YA .EQ $EA
SYS.NewStr.YA .EQ $EC
* .EQ $EE
SYS.SListAdd .EQ $EE
* .EQ $F0
* .EQ $F2
* .EQ $F4
* .EQ $F6
SYS.SListLookup .EQ $F0
SYS.SListGetByID .EQ $F2
SYS.SListUpdateByID .EQ $F4
SYS.SListNew .EQ $F6
* .EQ $F8
SYS.SListFree.A .EQ $F8
SYS.LoadStkObj .EQ $FA
SYS.NewStkObj.YA .EQ $FC
SYS.FreeStkObj.A .EQ $FE
@ -245,7 +245,6 @@ K.E.FTB .EQ $CC File Too Big Error
* MEM STRUCT
*--------------------------------------
S.MEM.F .EQ 0
S.MEM.F.AUX .EQ %10000000 Request Stock Object in AUX mem
S.MEM.F.INUSE .EQ %10000000 (Internal Flag)
S.MEM.F.INIT0 .EQ %01000000 Fill with "0"
S.MEM.F.CODE .EQ %00100000

View File

@ -6,7 +6,7 @@ AUTO 4,1
.LIST ON
*--------------------------------------
A2osX.MAIN.S .EQ A2osX.AUX-A2osX.MAIN
A2osX.AUX.S .EQ A2osX.GP-A2osX.AUX
A2osX.AUX.S .EQ A2osX.GP-A2osX.AUX
A2osX.GP.S .EQ A2osX.D1-A2osX.GP
A2osX.D1.S .EQ A2osX.D2-A2osX.D1
A2osX.D2.S .EQ A2osX.E0-A2osX.D2

View File

@ -143,12 +143,12 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.GetMem.YA
.DA K.GetMem0.YA
.DA K.NewStr.YA
.DA K.SListNew
*--------------------------------------
.DA K.SListGetByID $F0
.DA K.SListAdd
.DA K.SListLookup
.DA K.SListUpdate
*--------------------------------------
.DA K.SListLookup $F0
.DA K.SListGetByID
.DA K.SListUpdateByID
.DA K.SListNew
.DA K.SListFree.A
.DA K.LoadStkObj
.DA K.NewStkObj.YA

View File

@ -489,269 +489,71 @@ K.NewStr.YA >STYA .1+1
clc
.9 rts
*/--------------------------------------
* # SListNew
* ## In:
* ## Out:
* A=hMem
*\--------------------------------------
K.SListNew >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
*/--------------------------------------
* # SListGetByID
* # SListAdd
* ## In:
* PUSHB = hSList
* PUSHW = Key Ptr
* PUSHW = Data Ptr
* PUSHW = KeyID
* ## Out:
* A = Key Length
*\--------------------------------------
K.SListGetByID >PULLW MEM.IndexOfs
jsr MEM.GetSListParams
ldy MEM.IndexOfs
lda (ZPSListIndex),y
beq .9
jsr K.GetMemPtr.A
>STYA ZPSListBlock
clc
rts
.9 sec
rts
*/--------------------------------------
* # SListAdd
* ## In:
* PUSHB = hSList
* PUSHW = Key
* PUSHW = Data Ptr
* ## Out:
* A=hSList
*\--------------------------------------
K.SListAdd jsr K.SListLookup.I
bcc .9 Lookup succeeded...DUP
sta SETWRITEAUX
ldy #0
.1 jsr MEM.GetKeyCharY
iny
bcc .1
tya
jsr MEM.AddBlockByte
bcs .99
ldy #0
.2 jsr MEM.GetKeyCharY
bcs .3
jsr MEM.AddBlockByte
bcs .99
iny
bra .2
.3 sta CLRREADAUX
lda (ZPSListData)
sta SETREADAUX
tax
jsr MEM.AddBlockByte
bcs .99
ldy #1
.4 sta CLRREADAUX
lda (ZPSListData),y
sta SETREADAUX
jsr MEM.AddBlockByte
bcs .99
iny
dex
bne .4
clc
.HS B0 BCS
.9 sec
.99 sta CLRWRITEAUX
sta CLRREADAUX
rts
K.SListAdd
*/--------------------------------------
* # SListLookup
* ## In:
* PUSHB = hSList
* PUSHW = Key
* PUSHW = Key Ptr
* PUSHW = Data Ptr
* ## Out:
* Data Ptr Updated
* A = Key Length
* X,Y = KeyID
*\--------------------------------------
K.SListLookup jsr K.SListLookup.I
bcs .9
jsr MEM.GetBlockByte
tax
sta (ZPSListData)
ldy #0
.1 jsr MEM.GetBlockByte
iny
sta (ZPSListData),y
dex
bne .1
sta CLRREADAUX
clc
.9 rts
*--------------------------------------
K.SListLookup.I jsr MEM.GetSListParams
lda (ZPSListIndex)
beq .9
jsr K.GetMemPtr.A
>STYA ZPSListBlock
stz MEM.BlockOfs
jsr MEM.GetBlockByte
beq .9
tax
.1 ldy #0
.2 jsr MEM.GetKeyCharY
bcs .4
iny
sta .3+1
jsr MEM.GetBlockByte
.3 cmp #$ff SELF MODIFIED
bne .4
dex
bne .2
clc
rts
.4 jsr MEM.GetBlockByte skip remaining key chars
dex
bne .4
jsr MEM.GetBlockByte get Data Len
tax
.5 jsr MEM.GetBlockByte skip data bytes
dex
bne .5
tax
bne .1
.9 sec
rts
K.SListLookup
*/--------------------------------------
* # SListUpdate
* # SListGetByID
* ## In:
* PUSHB = hSList
* PUSHW = Key
* PUSHW = KeyID
* PUSHW = Data Ptr (KEY+DATA)
* ## Out:
* Y,A = Next ID
*\--------------------------------------
K.SListGetByID
*/--------------------------------------
* # SListUpdateByID
* ## In:
* PUSHB = hSList
* PUSHW = KeyID
* PUSHW = Data Ptr
* ## Out:
* A = Key Length
* X,Y = KeyID
*\--------------------------------------
K.SListUpdate jsr K.SListLookup.I
bcs .9
ldy #0
sta CLRREADAUX
lda (ZPSListData)
sta SETREADAUX
tax
jsr MEM.SetBlockByte
bcs .99
ldy #1
.4 sta CLRREADAUX
lda (ZPSListData),y
sta SETREADAUX
jsr MEM.SetBlockByte
bcs .99
iny
dex
bne .4
clc
.HS B0 BCS
.9 sec
.99 sta CLRWRITEAUX
sta CLRREADAUX
rts
K.SListUpdateByID
*--------------------------------------
>PULLW ZPSListData
>PULLW ZPSListKey
>PULLA
*/--------------------------------------
* # SListNew
* ## In:
* ## Out:
* A=hSList
*\--------------------------------------
K.SListNew
*/--------------------------------------
* # SListFree
* ## In:
* A=hSList
* ## Out:
*\--------------------------------------
K.SListFree.A sta .8
sta SETREADAUX
sta SETWRITEAUX
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
jsr K.FreeMem.A
sta CLRWRITEAUX
sta CLRREADAUX
rts
K.SListFree.A
*--------------------------------------
MEM.GetSListParams
>PULLW ZPSListData
>PULLW ZPSListKey
>PULLA
sta SETREADAUX
jsr K.GetMemPtr.A
>STYA ZPSListIndex
MEM.SLIST.JMP sta SETREADAUX
sta SETWRITEAUX
jsr X.SLIST
sta CLRREADAUX
sta CLRWRITEAUX
rts
*--------------------------------------
MEM.GetKeyCharY sta CLRREADAUX
@ -786,82 +588,17 @@ MEM.GetKeyCharY sta CLRREADAUX
.9 sec
rts
*--------------------------------------
MEM.GetBlockByte
phy
ldy MEM.BlockOfs
lda (ZPSListBlock),y
inc MEM.BlockOfs
bne .8
pha
ldy MEM.IndexOfs
lda (ZPSListIndex),y
beq .9
jsr K.GetMemPtr.A
>STYA ZPSListBlock
* stz MEM.BlockOfs
pla
.8 ply
clc
rts
.9 pla
ply
sec
MEM.GetDataByteY
sta CLRREADAUX
lda (ZPSListData),y
sta SETREADAUX
rts
*--------------------------------------
MEM.AddBlockByte
phy
ldy MEM.BlockOfs
sta (ZPSListBlock),y
inc MEM.BlockOfs
bne .8
inc MEM.IndexOfs
>LDYAI 256
jsr K.GetMem0.YA
bcs .9
>STYA ZPSListBlock
txa
ldy MEM.IndexOfs
sta (ZPSListIndex),y
* stz MEM.BlockOfs
.8 ply
clc
MEM.SetDataByteY
sta CLRWRITEAUX
sta (ZPSListData),y
sta SETWRITEAUX
rts
.9 ply
sec
rts
*--------------------------------------
MEM.SetBlockByte
phy
ldy MEM.BlockOfs
sta (ZPSListBlock),y
inc MEM.BlockOfs
bne .8
inc MEM.IndexOfs
ldy MEM.IndexOfs
lda (ZPSListIndex),y
jsr K.GetMemPtr.A
>STYA ZPSListBlock
* stz MEM.BlockOfs
.8 ply
clc
rts
*--------------------------------------
MEM.IndexOfs .BS 1
MEM.BlockOfs .BS 1
*/--------------------------------------
* # LoadStkObj
* Load a file in AUX memory (Stock Objects)

329
SYS/KERNEL.S.SLIST.txt Normal file
View File

@ -0,0 +1,329 @@
NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
*--------------------------------------
X.SLIST jmp (.1-SLIST.New,x)
.1 .DA SLIST.Add
.DA SLIST.Lookup
.DA SLIST.GetByID
.DA SLIST.UpdateByID
.DA SLIST.New
.DA SLIST.Free.A
*--------------------------------------
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.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.Free.A sta .8
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

View File

@ -22,6 +22,7 @@ A2osX.MAIN .PH $1100
.EP
A2osX.AUX .PH $0C00
.INB /A2OSX.SRC/SYS/KERNEL.S.OSD
.INB /A2OSX.SRC/SYS/KERNEL.S.SLIST
.EP
A2osX.GP .PH $BD00
.INB /A2OSX.SRC/SYS/KERNEL.S.GP