A2osX/BIN/ASM.S.SYM.txt
2018-01-29 16:48:07 +00:00

313 lines
5.4 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
*---------------------------------------
* Global Symbol Record: (8+ bytes)
* 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
* ......
* 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 >SYSCALL SListNew
bcs .9
>STA.G SYM.hGlobals
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
>STYA ZPLocalBuf
txa
>STA.G SYM.hLocalBuf
.9 rts
*---------------------------------------
SYM.Quit >LDA.G SYM.hLocalBuf
beq .2
>SYSCALL FreeMem.A
.2 >LDA.G SYM.hGlobals
beq .8
>SYSCALL SListFree.A
.8 clc
rts
*---------------------------------------
SYM.Dump stz ZPLinePtr
stz ZPLinePtr+1
>LDA.G ASM.LI.ON
bpl .1
>LDYA L.MSG.SYMBOLS
>SYSCALL PrintF.YA
.1 >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHW ZPTmpBuf
>SYSCALL SListGetByID
pha
txa
sta ZPLinePtr
tya
sta ZPLinePtr+1
pla
bcs .8
>LDA.G ASM.LI.ON
bpl .1
>PUSHW ZPTmpBuf Label (PString)
lda (ZPTmpBuf)
sec
adc ZPTmpBuf
sta ZPPtr1
lda ZPTmpBuf+1
adc #0
sta ZPPtr1+1
ldx #4
ldy #2
.2 lda (ZPPtr1),y
>PUSHA
iny
dex
bne .2
>LDYA L.MSG.GSYMBOL
>SYSCALL PrintF.YA
bcc .1
rts
.8 clc
rts
*---------------------------------------
SYM.AddGlobalPC jsr SYM.PC2Global
lda #SYM.F.RESOLVED
*---------------------------------------
SYM.AddGlobal >STA.G SYM.Global+SYM.F
lda #5 F+DWORD
>STA.G SYM.Global+SYM.LEN
>PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHEA.G SYM.Global
>SYSCALL SListAdd
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
.1 clc
.HS B0 BCS
.9 sec
tya
>STA.G SYM.ID+1
dey
txa
sta (pData),y
rts
*---------------------------------------
SYM.LookupGlobal >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHEA.G SYM.Lookup
>SYSCALL SListLookup
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
clc
.1 tya
>STA.G SYM.ID+1
txa
>STA.G SYM.ID
.9 rts
*---------------------------------------
SYM.UpdateGlobalPC jsr SYM.PC2Global
bra SYM.UpdateGlobal
*---------------------------------------
SYM.UpdateGlobalAcc ldx #3
ldy #SYM.Global+SYM.V+3
.1 lda SRC.ACC,x
sta (pData),y
dey
dex
bpl .1
*---------------------------------------
SYM.UpdateGlobal lda #SYM.F.RESOLVED
>STA.G SYM.Global+SYM.F
lda #5 F+DWORD
>STA.G SYM.Global+SYM.LEN
>PUSHB.G SYM.hGlobals
>PUSHW.G SYM.ID
>PUSHEA.G SYM.Global
>SYSCALL SListUpdateByID
rts
*---------------------------------------
SYM.PC2Global ldx #4
ldy #ASM.PC
.1 lda (pData),y
pha
iny
dex
bne .1
ldx #4
ldy #SYM.Global+SYM.V+3
.2 pla
sta (pData),y
dey
dex
bne .2
rts
*---------------------------------------
SYM.AddLocalPC tax Save ID
>LDA.G SYM.LocalIndex
tay
clc
adc #6
bcs .9
txa Get Back ID
sta (ZPLocalBuf),y
iny
lda #SYM.F.RESOLVED
sta (ZPLocalBuf),y
iny
phy
ldx #4
ldy #ASM.PC+3
.1 lda (pData),y
pha
dey
dex
bne .1
ldx #4
ply
.2 pla
sta (ZPLocalBuf),y
iny
dex
bne .2
lda #0
sta (ZPLocalBuf),y
tya
>STA.G SYM.LocalIndex
* clc
rts
.9 lda #ERR.TOO.MANY.LOCAL
* sec
rts
*---------------------------------------
SYM.AddLocalPending tax Save ID
>LDA.G SYM.LocalIndex
tay
clc
adc #6
bcs .9
txa Get Back ID
sta (ZPLocalBuf),y
ldx #6 F+DWORD+Ending 0
lda #0
.1 iny
sta (ZPLocalBuf),y
iny
dex
bne .1
>STA.G SYM.LocalIndex
* clc
rts
.9 lda #ERR.TOO.MANY.LOCAL
* sec
rts
*---------------------------------------
SYM.GetLocal
clc
rts
*---------------------------------------
SYM.AddPrivate
clc
rts
*---------------------------------------
SYM.LookupPrivate
clc
rts
*---------------------------------------
SYM.AddMacro
clc
rts
*---------------------------------------
SYM.LookupMacro
clc
rts
*---------------------------------------
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.SYM
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S
ASM