A2osX/BIN/ASM.S.SYM.txt
2018-03-23 15:57:35 +00:00

349 lines
6.1 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: (6+ bytes)
* 0 : Len
* 1 : Flags:
* b7=0=pending,1=resolved
* b6=R/W (.SE)
* b2,b1,b0 : Size (in bytes)
* 2-5 : 32 bits Value
* 6+ : Local Symbols.....
*---------------------------------------
* Local Symbol Record: (6 bytes)
* 0 : Local ID (1->255)
* 1 : Flags:
* b7=0=pending,1=resolved
* 2-5 : 32 bits Value (PC)
*---------------------------------------
* Private Symbol Record: (9 bytes)
* 0 : Len (8)
* 1 : Flags:
* b7=0=pending,1=resolved
* 2-5 : 32 bits Value (PC)
* 6,7 : MCID (Macro Context ID)
* 8 : Private ID (0->255)
*---------------------------------------
SYM.Init >SYSCALL SListNew
bcs .9
>STA.G SYM.hGlobals
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
>STYA ZPGlobalBuf
txa
>STA.G SYM.hGlobalBuf
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
>STYA ZPLookupBuf
txa
>STA.G SYM.hLookupBuf
.9 rts
*---------------------------------------
SYM.Reset lda #0
sta (ZPGlobalBuf)
rts
*---------------------------------------
SYM.Quit >LDA.G SYM.hLookpBuf
beq .1
>SYSCALL FreeMem.A
.1 >LDA.G SYM.hGlobalBuf
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
bcs .8
stx ZPLinePtr Save Next ID
sty ZPLinePtr+1
>LDA.G ASM.LI.ON
bpl .1
lda (ZPTmpBuf)
sec
adc ZPTmpBuf
sta ZPPtr1
lda ZPTmpBuf+1
adc #0
sta ZPPtr1+1
ldy #SYMG.F Get Symbol Size
lda (ZPPtr1),y
and #SYMG.F.SIZE
beq .3
pha
tax
iny SYMG.V
.2 lda (ZPPtr1),y
>PUSHA
iny
dex
bne .2
pla
asl
.3 tax
ldy L.MSG.EQU0,x
lda L.MSG.EQU0+1,x
>SYSCALL PrintF.YA
>PUSHW ZPTmpBuf Label (PString)
>LDYA L.MSG.PSTRCRLF
>SYSCALL PrintF.YA
bcc .1
rts
.8 clc
rts
*---------------------------------------
SYM.NewGlobal >LDYA ZPLinePtr
>STYA SYM.GlobalPtr
jsr SYM.PC2Global A=PC Size
ora #SYMG.F.RESOLVED PC is always known
ldy #SYMG.F
sta (ZPGlobalBuf),y
lda #SYMG.SIZE-1
* ldy #SYMG.LEN
sta (ZPGlobalBuf)
clc
rts
*---------------------------------------
SYM.GetGlobal >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHW ZPGlobalBuf
>SYSCALL SListLookup
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
clc
.1 tya
>STA.G SYM.GlobalID+1
txa
>STA.G SYM.GlobalID
.9 rts
*---------------------------------------
SYM.AddGlobal >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHW ZPGlobalBuf
>SYSCALL SListAdd
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
.1 clc
.HS B0 BCS
.9 sec
tya
>STA.G SYM.GlobalID+1
dey
txa
sta (pData),y
rts
*---------------------------------------
SYM.LookupGlobal >PUSHB.G SYM.hGlobals
>PUSHW ZPLinePtr
>PUSHW ZPLookupBuf
>SYSCALL SListLookup
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .8
inc ZPLinePtr+1
clc
.8
.9 rts
*---------------------------------------
SYM.UpdateGlobalAcc ldx #3
ldy #SYM.Global+SYMG.V+3
.1 lda SRC.ACC,x
sta (pData),y
dey
dex
bpl .1
lda SRC.ACC.SIZE
*---------------------------------------
SYM.UpdateGlobal ora #SYMG.F.RESOLVED
>STA.G SYM.Global+SYMG.F
lda #SYMG.SIZE-1 F+V+LSID
>STA.G SYM.Global+SYMG.LEN
>PUSHB.G SYM.hGlobals
>PUSHW.G SYM.GlobalID
>PUSHEA.G SYM.Global
>SYSCALL SListUpdateByID
rts
*---------------------------------------
SYMG.FlushGlobal clc
rts
*---------------------------------------
SYM.PC2Global ldx #4
ldy #ASM.PC
.1 lda (pData),y
pha
iny
dex
bne .1
ldx #4
ldy #SYMG.V+3
.2 pla
sta (ZPGlobalBuf),y
dey
dex
bne .2
ldx #4
ldy #ASM.PC+3
.3 lda (ZPGlobalBuf),y
bne .4
dex
dey
bne .3
.4 txa
ora #SYMG.F.RESOLVED
ldy #SYMG.F
sta (ZPGlobalBuf),y
txa A=PC Size
rts
*---------------------------------------
SYM.AddLocal tax Save ID
lda (ZPGlobalBuf)
tay
clc
adc #SYML.SIZE
bcs .9
txa Get Back ID
sta (ZPGlobalBuf),y
iny
phy
ldx #4
ldy #ASM.PC+3
.1 lda (pData),y
pha
dey
dex
bne .1
ldx #4
ply
.2 pla
sta (ZPGlobalBuf),y
iny
dex
bne .2
lda #0
sta (ZPGlobalBuf),y
tya
sta (ZPGlobalBuf)
* clc
rts
.9 lda #ERR.TOO.MANY.LOCAL
* sec
rts
*---------------------------------------
SYM.LookupLocal lda #2
sta SRC.ACC.SIZE
lda #$FF
sta SRC.ACC
sta SRC.ACC+1
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