A2osX/BIN/ASM.S.SYM.txt

443 lines
7.2 KiB
Plaintext
Raw Normal View History

NEW
PREFIX /A2OSX.BUILD
AUTO 4,1
2015-10-04 20:55:51 +00:00
*---------------------------------------
* 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.....
2015-11-13 16:25:31 +00:00
*---------------------------------------
SYM.Init >SYSCALL SListNew
bcs .9
2018-01-22 16:52:04 +00:00
>STA.G SYM.hGlobalList
>LDYAI 256
>SYSCALL GetMem.YA
bcs .9
>STYA ZPNameBuf
txa
>STA.G SYM.hNameBuf
>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.hLookupBuf
beq .1
>SYSCALL FreeMem.A
.1 >LDA.G SYM.hNameBuf
beq .2
>SYSCALL FreeMem.A
.2 >LDA.G SYM.hGlobalBuf
beq .3
>SYSCALL FreeMem.A
.3 >LDA.G SYM.hGlobalList
beq .8
>SYSCALL SListFree.A
.8 clc
rts
2015-10-30 16:34:59 +00:00
*---------------------------------------
SYM.Dump stz ZPLinePtr
stz ZPLinePtr+1
2018-01-26 07:04:29 +00:00
>LDA.G ASM.LI.ON
bpl .1
>LDYA L.MSG.SYMBOLS
>SYSCALL PrintF.YA
2018-01-29 16:48:07 +00:00
.1 >PUSHB.G SYM.hGlobalList
>PUSHW ZPLinePtr
>PUSHW ZPGlobalBuf
>PUSHW ZPNameBuf
>SYSCALL SListGetByID
bcc .10
clc
rts
.10 stx ZPLinePtr Save Next ID
sty ZPLinePtr+1
>LDA.G ASM.LI.ON
bpl .1
ldy #SYMG.F Get Symbol Size
lda (ZPGlobalBuf),y
and #SYMG.F.SIZE
tax
beq .3
asl
pha
.2 iny
lda (ZPGlobalBuf),y
>PUSHA
dex
bne .2
plx
.3 ldy L.MSG.EQU0,x
lda L.MSG.EQU0+1,x
>SYSCALL PrintF.YA
>PUSHW ZPNameBuf Label (PString)
>LDYA L.MSG.PSTR
>SYSCALL PrintF.YA
bcs .9
>DEBUG
ldy #SYMG.SIZE-1
.4 tya
cmp (ZPGlobalBuf)
beq .7 No Local Symbol
iny
lda (ZPGlobalBuf),y Get ID
pha
ldx #4
.5 iny
lda (ZPGlobalBuf),y
>PUSHA
dex
bne .5
pla
>PUSHA
phy
>LDYA L.MSG.PSTR
>SYSCALL PrintF.YA
ply
bne .4
.7 >LDYA L.MSG.CRLF
>SYSCALL PrintF.YA
jmp .1
rts
.8 clc
.9 rts
*---------------------------------------
SYM.NewOrGetGlobal
>LDA.G ASM.PASS
bne SYM.GetGlobal Pass #2: should be already defined...
SYM.NewGlobal jsr SYM.LookupGlobal Pass #1; try to add global...
bcc .9 Already Defined
jsr SYM.GetName
bcs .99
jsr SYM.PC2Global A=PC Size
2018-01-22 16:52:04 +00:00
lda #SYMG.SIZE-1
sta (ZPGlobalBuf)
clc
rts
.9 lda #ERR.SYMBOL.REDEF
sec
.99 rts
*---------------------------------------
SYM.GetGlobal >PUSHB.G SYM.hGlobalList
>PUSHW ZPLinePtr
>PUSHW ZPGlobalBuf
>SYSCALL SListLookup
2018-01-22 16:52:04 +00:00
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
clc
.1 tya
>STA.G SYM.GlobalID+1
txa
>STA.G SYM.GlobalID
rts
.9 lda #ERR.UNDEF.SYMBOL
sec
rts
2018-01-22 07:34:59 +00:00
*---------------------------------------
SYM.LookupGlobal
>PUSHB.G SYM.hGlobalList
>PUSHW ZPLinePtr
>PUSHW ZPLookupBuf
>SYSCALL SListLookup
bcs .9
adc ZPLinePtr
sta ZPLinePtr
bcc .8
inc ZPLinePtr+1
clc
.8
.9 rts
*---------------------------------------
SYM.FlushGlobal lda (ZPGlobalBuf)
beq .8
>PUSHB.G SYM.hGlobalList
>LDA.G ASM.PASS
bne .2
>PUSHW ZPNameBuf
>PUSHW ZPGlobalBuf
>SYSCALL SListAdd
rts
.2 >PUSHW.G SYM.GlobalID
>PUSHW ZPGlobalBuf
>SYSCALL SListUpdateByID
rts
.8 clc
rts
*---------------------------------------
SYM.GetName jsr SRC.GetChar
bcs .9
ldy #0
.1 jsr SRC.IsLetterOrDigit
bcc .2
cmp #'.'
beq .2
cmp #'_'
bne .8
.2 sta (ZPNameBuf),y
iny
jsr SRC.GetNextChar
bcc .1
.8 lda #0
sta (ZPNameBuf),y
clc
rts
.9 lda #ERR.SYNTAX.ERROR
sec
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.Acc2Global ldx #3
ldy #SYMG.V+3
.1 lda SRC.ACC,x
sta (ZPGlobalBuf),y
dey
dex
bpl .1
lda SRC.ACC.SIZE
ora SRC.ACC.F
sta (ZPGlobalBuf),y
clc
rts
*---------------------------------------
SYM.Lookup2Acc ldy #SYMG.V+3
ldx #3
.1 lda (ZPLookupBuf),y
sta SRC.ACC,x
dey
dex
bpl .1
lda (ZPLookupBuf),y
and #SYMG.F.SIZE
sta SRC.ACC.SIZE
lda (ZPLookupBuf),y
and #SYMG.F.SIZE^$ff
sta SRC.ACC.F
clc
rts
2015-10-04 20:55:51 +00:00
*---------------------------------------
* Local Symbol Record: (6 bytes)
* 0 : Local ID (1->255)
* 1 : Flags:
* b7=0=pending,1=resolved
* 2-5 : 32 bits Value (PC)
*---------------------------------------
SYM.NewOrGetLocalA
tax Save ID
>LDA.G ASM.PASS
bne SYM.GetLocal Pass #2: should be already defined...
clc
rts
*---------------------------------------
SYM.AddLocal 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
2018-01-29 16:48:07 +00:00
*---------------------------------------
SYM.GetLocal
2015-10-04 20:55:51 +00:00
*---------------------------------------
SYM.LookupLocal lda #2
sta SRC.ACC.SIZE
lda #$FF
sta SRC.ACC
sta SRC.ACC+1
clc
rts
*---------------------------------------
* 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)
2015-10-04 20:55:51 +00:00
*---------------------------------------
2018-01-22 07:34:59 +00:00
SYM.AddPrivate
clc
rts
2015-10-04 20:55:51 +00:00
*---------------------------------------
2018-01-22 07:34:59 +00:00
SYM.LookupPrivate
clc
rts
2015-11-27 16:26:11 +00:00
*---------------------------------------
2018-01-22 07:34:59 +00:00
SYM.AddMacro
clc
rts
2015-11-20 16:31:14 +00:00
*---------------------------------------
2018-01-22 07:34:59 +00:00
SYM.LookupMacro
clc
rts
2018-01-22 07:34:59 +00:00
*---------------------------------------
2015-10-04 20:55:51 +00:00
MAN
SAVE /A2OSX.BUILD/BIN/DEV/ASM.S.SYM
LOAD /A2OSX.BUILD/BIN/DEV/ASM.S
2015-10-04 20:55:51 +00:00
ASM