A2osX/BIN/ASM.S.SYM.txt

489 lines
7.9 KiB
Plaintext
Raw Normal View History

NEW
2019-09-02 06:09:28 +00:00
AUTO 3,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
*---------------------------------------
* Local Symbol Record: (5 bytes)
* 0 : Local ID (1->255)
* 1-4 : 32 bits Value (PC)
*---------------------------------------
SYM.Init >SYSCALL SListNew
bcs .9
2018-01-22 16:52:04 +00:00
2019-03-29 16:21:30 +00:00
>STA.G SYM.hList
>LDYAI 256
2018-07-20 11:51:08 +00:00
>SYSCALL getmem
bcs .9
2019-03-29 16:21:30 +00:00
>STYA ZPSymbolBuf
txa
>STA.G SYM.hGlobalBuf
.9 rts
*---------------------------------------
2019-03-22 16:47:33 +00:00
SYM.Reset >STZ.G SYM.bInGlobal
rts
*---------------------------------------
2019-03-25 07:04:40 +00:00
SYM.Quit >LDA.G SYM.hGlobalBuf
beq .3
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2019-03-20 16:55:26 +00:00
2019-03-29 16:21:30 +00:00
.3 >LDA.G SYM.hList
2019-03-20 16:55:26 +00:00
beq SYM.Quit.8
2018-07-24 16:00:24 +00:00
>SYSCALL SListFree
2019-03-20 16:55:26 +00:00
SYM.Quit.8 clc
2019-03-25 07:04:40 +00:00
rts
*---------------------------------------
SYM.Dump.End >PUSHW ZPPtr2
>PUSHBI 2
>LDYA L.MSG.SUMMARY
jmp OUT.Print
SYM.Dump.RTS rts
2015-10-30 16:34:59 +00:00
*---------------------------------------
2019-03-20 16:55:26 +00:00
SYM.Dump >LDA.G ASM.LI.ON
bpl SYM.Quit.8
>LDYA L.MSG.SYMBOLS
2018-11-26 21:52:49 +00:00
>SYSCALL puts
2018-01-29 16:48:07 +00:00
2019-03-20 16:55:26 +00:00
stz ZPPtr2
stz ZPPtr2+1
.1 >LDYA ZPPtr2
>STYA ZPPtr1
2019-03-21 07:07:38 +00:00
2019-03-25 07:04:40 +00:00
>PUSHW ZPTmpBuf
2019-03-19 16:52:08 +00:00
>PUSHW ZPPtr1
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
>SYSCALL SListGetByID
2019-03-25 07:04:40 +00:00
bcs SYM.Dump.End
2019-03-20 16:55:26 +00:00
>STYA ZPPtr2 Save Next ID
2019-06-07 15:02:51 +00:00
>PUSHWZ Start
2019-03-19 16:52:08 +00:00
>PUSHWI $ffff End
2019-03-29 16:21:30 +00:00
>PUSHW ZPSymbolBuf
2019-03-20 16:55:26 +00:00
>PUSHW ZPPtr1 KeyID
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
2019-03-21 16:37:02 +00:00
2019-03-19 16:52:08 +00:00
>SYSCALL SListGetData
2019-03-25 07:04:40 +00:00
bcs SYM.Dump.RTS
2019-03-19 16:52:08 +00:00
2019-03-20 16:55:26 +00:00
ldy #SYMG.SIZE Get Symbol Size
2019-03-29 16:21:30 +00:00
lda (ZPSymbolBuf),y
tax
beq .3
2019-03-20 16:55:26 +00:00
phx
.2 iny
2019-03-29 16:21:30 +00:00
lda (ZPSymbolBuf),y
>PUSHA
dex
bne .2
2019-03-20 16:55:26 +00:00
pla Byte Count
asl
tax
.3 >PUSHA
ldy L.MSG.EQU0,x
lda L.MSG.EQU0+1,x
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2019-03-21 16:37:02 +00:00
>PUSHBI 0
2019-03-25 07:04:40 +00:00
>LDYA ZPTmpBuf Label
2019-03-21 07:07:38 +00:00
>SYSCALL printf
2019-03-29 16:21:30 +00:00
lda (ZPSymbolBuf)
2019-03-21 16:37:02 +00:00
2019-03-20 16:55:26 +00:00
bit #SYMG.F.LOCALS
beq .7
2019-03-29 16:21:30 +00:00
2019-04-01 06:07:56 +00:00
jsr SYM.Dump.LP
.7 jsr OUT.PrintCR
jmp .1
*---------------------------------------
SYM.Dump.LP ldy #SYMG
2019-03-20 16:55:26 +00:00
2019-03-29 16:21:30 +00:00
.4 lda (ZPSymbolBuf),y
2019-04-01 06:07:56 +00:00
beq .8
2019-04-01 06:07:56 +00:00
phy
iny
ldx #4
2019-03-29 16:21:30 +00:00
.5 iny
lda (ZPSymbolBuf),y
>PUSHA
dex
bne .5
2019-04-01 06:07:56 +00:00
ply
iny
lda (ZPSymbolBuf),y
tax
beq .55
>PUSHA
.55 dey
lda (ZPSymbolBuf),y
>PUSHA
phy
2019-04-01 06:07:56 +00:00
txa
beq .6
2018-11-26 21:52:49 +00:00
>PUSHBI 6
2019-04-01 06:07:56 +00:00
>LDYA L.MSG.PSYMBOL
bra .66
.6 >PUSHBI 5
>LDYA L.MSG.LSYMBOL
2019-04-01 06:07:56 +00:00
.66 >SYSCALL printf
pla
clc
adc #SYML
tay
bra .4
2019-04-01 06:07:56 +00:00
.8 rts
*---------------------------------------
SYM.NewOrGetGlobal
>LDA.G ASM.PASS
2019-03-19 16:52:08 +00:00
bne SYM.GetGlobal
2019-03-20 16:55:26 +00:00
SYM.NewGlobal jsr SYM.StoreGlobal
bcs .99
2019-03-27 17:01:01 +00:00
2019-03-20 16:55:26 +00:00
>PUSHW ZPLinePtr Pass #1; try to add global...
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
2019-03-19 16:52:08 +00:00
>SYSCALL SListNewKey
bcs .9 Already Defined
>STYA.G SYM.GlobalID
txa
adc ZPLinePtr
sta ZPLinePtr
bcc .1
2019-03-19 16:52:08 +00:00
inc ZPLinePtr+1
2019-03-20 16:55:26 +00:00
.1 jsr SYM.PC2Acc
jsr SYM.Acc2Global
lda #SYMG
>STA.G SYM.GlobalPtr
2019-03-21 16:37:02 +00:00
tay
lda #0
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf),y
2019-03-20 16:55:26 +00:00
lda #$ff
2019-03-22 16:47:33 +00:00
>STA.G SYM.bInGlobal
2019-03-20 16:55:26 +00:00
2019-03-28 16:48:22 +00:00
* >PUSHW.G SYM.GlobalID
* >PUSHBI 2
* >LDYA L.MSG.WORD
* >SYSCALL printf
2019-03-20 16:55:26 +00:00
clc
rts
2019-03-25 07:04:40 +00:00
.9 lda #E.SYMBOL.REDEF
sec
.99 rts
*---------------------------------------
2019-03-19 16:52:08 +00:00
SYM.GetGlobal >PUSHW ZPLinePtr Pass #2: should be already defined...
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
>SYSCALL SListLookup
bcs .9
2019-03-19 16:52:08 +00:00
>STYA.G SYM.GlobalID
txa
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
2019-06-07 15:02:51 +00:00
.1 >PUSHWZ Start
2019-03-20 16:55:26 +00:00
>PUSHWI $ffff End
2019-03-29 16:21:30 +00:00
>PUSHW ZPSymbolBuf
2019-03-22 16:47:33 +00:00
>PUSHW.G SYM.GlobalID
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
2019-03-20 16:55:26 +00:00
>SYSCALL SListGetData
2019-03-22 16:47:33 +00:00
bcs .99
lda #$ff
>STA.G SYM.bInGlobal
* clc
rts
2019-03-25 07:04:40 +00:00
.9 lda #E.UNDEF.SYMBOL
sec
2019-03-22 16:47:33 +00:00
.99 rts
2018-01-22 07:34:59 +00:00
*---------------------------------------
SYM.LookupGlobal
>PUSHW ZPLinePtr
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
>SYSCALL SListLookup
bcs .9
2019-03-20 16:55:26 +00:00
2019-03-22 07:41:35 +00:00
>STYA ZPPtr1
2019-03-20 16:55:26 +00:00
2019-03-18 16:48:16 +00:00
txa
adc ZPLinePtr
sta ZPLinePtr
2019-03-20 16:55:26 +00:00
bcc .1
inc ZPLinePtr+1
2019-03-20 16:55:26 +00:00
2019-03-22 07:41:35 +00:00
.1 >LDA.G SYM.GlobalID
cmp ZPPtr1
bne .3
2019-03-22 16:47:33 +00:00
iny SYM.GlobalID+1
2019-03-22 07:41:35 +00:00
lda (pData),y
cmp ZPPtr1+1
bne .3
ldy #SYMG-1
2019-03-29 16:21:30 +00:00
.2 lda (ZPSymbolBuf),y
2019-03-22 07:41:35 +00:00
sta SRC.ACC.F,y
dey
bpl .2
2019-03-22 16:47:33 +00:00
2019-03-22 07:41:35 +00:00
clc
rts
2019-06-07 15:02:51 +00:00
.3 >PUSHWZ Start
2019-03-22 07:41:35 +00:00
>PUSHWI SYMG Get only Global value
2019-03-20 16:55:26 +00:00
>PUSHW L.SRC.ACC.F
2019-03-22 07:41:35 +00:00
>PUSHW ZPPtr1
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
2019-03-20 16:55:26 +00:00
>SYSCALL SListGetData
rts
2019-03-25 07:04:40 +00:00
.9 lda #E.UNDEF.SYMBOL
2019-03-20 16:55:26 +00:00
sec
rts
*---------------------------------------
2019-03-19 16:52:08 +00:00
SYM.StoreGlobal >LDA.G ASM.PASS
bne .8
2019-03-22 16:47:33 +00:00
>LDA.G SYM.bInGlobal
2019-03-20 16:55:26 +00:00
bpl .8
>LDA.G SYM.GlobalPtr
tay
lda #0
cpy #SYMG
beq .1
2019-03-29 16:21:30 +00:00
lda (ZPSymbolBuf)
2019-03-21 16:37:02 +00:00
ora #SYMG.F.LOCALS
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf)
2019-03-20 16:55:26 +00:00
lda #0
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf),y
2019-03-20 16:55:26 +00:00
iny
bne .1
inc
.1 >PUSHYA
2019-03-29 16:21:30 +00:00
>PUSHW ZPSymbolBuf
2019-03-18 16:48:16 +00:00
>PUSHW.G SYM.GlobalID
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
2019-03-18 16:48:16 +00:00
>SYSCALL SListAddData
2019-03-19 16:52:08 +00:00
bcs .9
2019-03-20 16:55:26 +00:00
lda #0
2019-03-22 16:47:33 +00:00
>STA.G SYM.bInGlobal
2019-04-01 06:07:56 +00:00
>STA.G MAC.CtxID
rts
.8 clc
.9 rts
*---------------------------------------
2019-03-22 16:47:33 +00:00
SYM.UpdateGlobal
>PUSHWI SYMG
>PUSHW L.SRC.ACC.F
>PUSHW.G SYM.GlobalID
2019-03-29 16:21:30 +00:00
>LDA.G SYM.hList
2019-03-22 16:47:33 +00:00
>SYSCALL SListSetData
rts
*---------------------------------------
2019-03-19 16:52:08 +00:00
SYM.PC2Acc ldy #ASM.PC+3
2019-03-22 16:47:33 +00:00
ldx #3
.1 lda (pData),y
2019-03-19 16:52:08 +00:00
sta SRC.ACC,x
dey
2019-03-22 16:47:33 +00:00
dex
bpl .1
2019-03-19 16:52:08 +00:00
2019-03-20 16:55:26 +00:00
lda #2
2019-03-19 16:52:08 +00:00
sta SRC.ACC.SIZE
2019-03-21 16:37:02 +00:00
stz SRC.ACC.F
rts
*---------------------------------------
2019-03-21 16:37:02 +00:00
SYM.Acc2Global ldy #SYMG-1
2019-03-20 16:55:26 +00:00
.2 lda SRC.ACC.F,y
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf),y
2019-03-21 16:37:02 +00:00
dey
bpl .2
2019-03-25 07:04:40 +00:00
2019-03-20 16:55:26 +00:00
rts
*---------------------------------------
2019-04-01 06:07:56 +00:00
* Local/Private Symbol Record: (6 bytes)
* 0 : Local ID (1->255)
2019-04-01 06:07:56 +00:00
* 1 : Macro Context ID
2019-03-29 07:46:36 +00:00
* 2-5 : 32 bits Value (PC)
*---------------------------------------
2019-04-01 06:07:56 +00:00
SYM.NewPrivateA sec
.HS 90 BCC
SYM.NewLocalA clc
ror ZPPtr1
2019-03-22 16:47:33 +00:00
tax Save Local ID
2019-03-21 16:37:02 +00:00
2019-03-22 16:47:33 +00:00
>LDA.G SYM.bInGlobal not in a global label
2019-03-20 16:55:26 +00:00
bpl .91
2019-03-21 16:37:02 +00:00
>LDA.G ASM.PASS Pass #2: should be already defined...
2019-03-25 07:04:40 +00:00
bne .8
2019-03-20 16:55:26 +00:00
jsr SYM.GetLocalX Pass #1; try to add
bcc .9 Already Defined
2019-03-20 16:55:26 +00:00
>LDA.G SYM.GlobalPtr
2019-03-29 16:21:30 +00:00
cmp #252 6*42
2019-03-20 16:55:26 +00:00
beq .90
ldy #ASM.PC+4
.1 dey
lda (pData),y
pha
cpy #ASM.PC
bne .1
2019-04-01 06:07:56 +00:00
lda #0
bit ZPPtr1
bpl .11 local, Ctx = 0
>LDA.G MAC.CtxID Get Macro Context ID
.11 pha
2019-03-29 16:21:30 +00:00
2019-03-21 16:37:02 +00:00
>LDA.G SYM.GlobalPtr
tay
txa Get Back ID
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf),y
ldx #5 MAC ID + PC (4)
.2 pla
iny
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf),y
dex
bne .2
2019-03-29 16:21:30 +00:00
2019-03-22 16:47:33 +00:00
iny
lda #0
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf),y
2019-03-29 07:46:36 +00:00
tya
>STA.G SYM.GlobalPtr
2019-03-29 16:21:30 +00:00
lda (ZPSymbolBuf)
2019-03-25 07:04:40 +00:00
ora #SYMG.F.LOCALS
2019-03-29 16:21:30 +00:00
sta (ZPSymbolBuf)
2019-03-25 07:04:40 +00:00
.8 clc
rts
2019-03-20 16:55:26 +00:00
2019-03-25 07:04:40 +00:00
.91 lda #E.INV.LABEL
2019-03-20 16:55:26 +00:00
sec
rts
2019-03-25 07:04:40 +00:00
.90 lda #E.TOO.MANY.LOCAL
2019-03-20 16:55:26 +00:00
sec
rts
2019-03-25 07:04:40 +00:00
.9 lda #E.SYMBOL.REDEF
sec
rts
2018-01-29 16:48:07 +00:00
*---------------------------------------
2019-03-29 16:21:30 +00:00
SYM.GetLocalX lda (ZPSymbolBuf)
2019-03-22 16:47:33 +00:00
and #SYMG.F.LOCALS
beq .9
2019-03-25 07:04:40 +00:00
ldy #SYMG
2019-04-01 06:07:56 +00:00
2019-03-29 16:21:30 +00:00
.1 lda (ZPSymbolBuf),y
2019-03-21 16:37:02 +00:00
beq .9
txa
2019-03-29 16:21:30 +00:00
cmp (ZPSymbolBuf),y
2019-04-01 06:07:56 +00:00
bne .4
phy
>LDA.G MAC.CtxID
ply
iny
cmp (ZPSymbolBuf),y
2019-03-20 16:55:26 +00:00
bne .3
2019-03-25 07:04:40 +00:00
ldx #0
2019-03-29 16:21:30 +00:00
2019-03-20 16:55:26 +00:00
.2 iny
2019-03-29 16:21:30 +00:00
lda (ZPSymbolBuf),y
2019-03-25 07:04:40 +00:00
sta SRC.ACC,x
inx
cpx #4
2019-03-20 16:55:26 +00:00
bne .2
2019-03-25 07:04:40 +00:00
lda #2
sta SRC.ACC.SIZE
clc
rts
2019-04-01 06:07:56 +00:00
.3 dey
.4 tya
2019-03-20 16:55:26 +00:00
clc
adc #SYML
tay
2019-03-29 16:21:30 +00:00
bra .1
2019-03-20 16:55:26 +00:00
2019-03-25 07:04:40 +00:00
.9 lda #E.UNDEF.SYMBOL
2019-03-20 16:55:26 +00:00
sec
rts
*---------------------------------------
2015-10-04 20:55:51 +00:00
MAN
2019-01-28 07:44:37 +00:00
SAVE USR/SRC/BIN/ASM.S.SYM
LOAD USR/SRC/BIN/ASM.S
2015-10-04 20:55:51 +00:00
ASM