mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
355 lines
6.6 KiB
Plaintext
355 lines
6.6 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*---------------------------------------
|
||
* 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
|
||
* ......
|
||
* Local Symbol Record: (2 bytes)
|
||
* 2 : Local ID (1->255)
|
||
* 3 : offset from Global Symbol
|
||
* ......
|
||
* Ending 0
|
||
*---------------------------------------
|
||
* Global Symbol Index (Sorted)
|
||
* 0 : hGblock
|
||
* 1 : Offset in block
|
||
*---------------------------------------
|
||
* Private Symbol Record: (7 bytes)
|
||
* 0,1 : MacroID
|
||
* 2 : Private ID (0->255)
|
||
* 3-6 : Value
|
||
*---------------------------------------
|
||
* 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
|
||
|
||
.8 clc
|
||
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.AddPrivate
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
SYM.LookupPrivate
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
SYM.AddMacro
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
SYM.LookupMacro
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
SYM.UpdateGlobal
|
||
clc
|
||
rts
|
||
*---------------------------------------
|
||
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
|
||
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
|
||
rts
|
||
*---------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/BIN/ASM.S.SYM
|
||
LOAD /A2OSX.SRC/BIN/ASM.S
|
||
ASM
|