A2osX/BIN/ASM.S.SYM.txt
2016-10-24 17:54:43 +02:00

366 lines
6.8 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.

PR#3
PREFIX /A2OSX.SRC
NEW
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 lda #0
ldy #SYM.iLastGBlock
sta (pData),y
dec
ldy #SYM.pLastGBlock
sta (pData),y
jsr SYM.NewGBlock
bcs .9
clc
.9 rts
*---------------------------------------
SYM.Quit ldy #SYM.pLastGBlock
lda (pData),y
bmi .8
.1 clc
adc #SYM.hGBlocks
tay
lda (pData),y
>SYSCALL FreeMemA
ldy #SYM.pLastGBlock
lda (pData),y
dec
sta (pData),y
bpl .1
.8 clc
rts
*---------------------------------------
SYM.Dump >PUSHW L.MSG.SYMBOLS
>LIBCALL hLIBSTR,LIBSTR.PRINTF
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
>PUSHW L.MSG.GSYMBOL
>LIBCALL hLIBSTR,LIBSTR.PRINTF
bcs .9
.4 jsr SYM.GetByteGBlock
beq .5 End Locals...proceed next Global
pha
jsr SYM.GetByteGBlock
>PUSHA
pla
>PUSHA
>PUSHW L.MSG.LSYMBOL
>LIBCALL hLIBSTR,LIBSTR.PRINTF
bcc .4
rts
.5 lda #13
>SYSCALL COutA
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 GetMemPtrA
>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 >PUSHWI 256
>PUSHBI S.MEM.F.INIT0
>SYSCALL GetMem
bcs .9
>STYA ZPBlockPtr
ldy #SYM.pLastGBlock
lda (pData),y
inc
sta (pData),y
clc
adc #SYM.hGBlocks
tay
txa
sta (pData),y
lda #0
ldy #SYM.iLastGBlock
sta (pData),y
clc
.9 ply
plx
rts
*---------------------------------------
MAN
SAVE BIN/ASM.S.SYM
LOAD BIN/ASM.S
ASM