A2osX/BIN/ASM.S.SYM.txt

506 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
*---------------------------------------
2020-02-25 16:42:22 +00:00
* Local/Private Symbol Record: (6 bytes)
* 0 : Local ID (1->255)
2020-02-25 16:42:22 +00:00
* 1 : Macro Context ID (private)
* 2-5 : 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
2020-02-28 07:21:46 +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-25 07:04:40 +00:00
SYM.Quit >LDA.G SYM.hGlobalBuf
2020-02-26 16:34:13 +00:00
beq .1
2020-02-23 20:01:48 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2020-02-23 20:01:48 +00:00
2020-02-26 16:34:13 +00:00
.1 >LDA.G SYM.hList
2019-04-01 06:07:56 +00:00
beq .8
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
>PUSHA
2020-02-26 16:34:13 +00:00
>SYSCALL SListFree
2020-02-23 20:01:48 +00:00
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
2020-02-23 20:01:48 +00:00
>PUSHB.G SYM.hList
>PUSHW ZPLinePtr Pass #1: try to add global...
2019-03-19 16:52:08 +00:00
>SYSCALL SListNewKey
bcs .9 Already Defined
2020-02-23 20:01:48 +00:00
2019-03-19 16:52:08 +00:00
>STYA.G SYM.GlobalID
txa
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
2020-02-23 20:01:48 +00:00
2019-03-20 16:55:26 +00:00
.1 jsr SYM.PC2Acc
jsr SYM.Acc2Global
2020-02-23 20:01:48 +00:00
2019-03-20 16:55:26 +00:00
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
2020-02-26 07:28:45 +00:00
2019-03-20 16:55:26 +00:00
lda #$ff
2019-03-22 16:47:33 +00:00
>STA.G SYM.bInGlobal
2020-02-26 07:28:45 +00:00
2019-03-20 16:55:26 +00:00
clc
rts
2020-02-23 20:01:48 +00:00
2019-03-25 07:04:40 +00:00
.9 lda #E.SYMBOL.REDEF
sec
2019-10-03 06:25:27 +00:00
.99 rts
*---------------------------------------
2020-02-23 20:01:48 +00:00
SYM.GetGlobal >PUSHB.G SYM.hList
>PUSHW ZPLinePtr Pass #2: should be already defined...
>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
2020-02-24 16:37:55 +00:00
2020-02-26 07:28:45 +00:00
.1 >PUSHB.G SYM.hList
2019-03-22 16:47:33 +00:00
>PUSHW.G SYM.GlobalID
2020-02-23 20:01:48 +00:00
>PUSHW ZPSymbolBuf
>PUSHWI $ffff all
>PUSHWZ from Start
2019-03-20 16:55:26 +00:00
>SYSCALL SListGetData
2019-03-22 16:47:33 +00:00
bcs .99
2020-02-23 20:01:48 +00:00
2019-03-22 16:47:33 +00:00
lda #$ff
>STA.G SYM.bInGlobal
2019-10-03 06:25:27 +00:00
* clc
rts
2019-10-03 06:25:27 +00:00
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
2020-02-23 20:01:48 +00:00
>PUSHB.G SYM.hList
>PUSHW ZPLinePtr
>SYSCALL SListLookup
bcs .9
2020-02-23 20:01:48 +00:00
2019-03-22 07:41:35 +00:00
>STYA ZPPtr1
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
2020-02-23 20:01:48 +00:00
2019-03-22 07:41:35 +00:00
.1 >LDA.G SYM.GlobalID
cmp ZPPtr1
bne .3
2020-02-23 20:01:48 +00:00
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
2020-02-23 20:01:48 +00:00
2019-03-22 07:41:35 +00:00
ldy #SYMG-1
2020-02-28 16:30:16 +00:00
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
2020-02-23 20:01:48 +00:00
.3 >PUSHB.G SYM.hList
2019-03-22 07:41:35 +00:00
>PUSHW ZPPtr1
2020-02-23 20:01:48 +00:00
>PUSHW L.SRC.ACC.F
>PUSHWI SYMG Get only Global value
>PUSHWZ Start
2019-03-20 16:55:26 +00:00
>SYSCALL SListGetData
rts
2020-02-23 20:01:48 +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
*---------------------------------------
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
2020-02-23 20:01:48 +00:00
>PUSHB.G SYM.hList
>PUSHW.G SYM.GlobalID
>PUSHW ZPSymbolBuf
2019-03-20 16:55:26 +00:00
>LDA.G SYM.GlobalPtr
tay
lda #0
cpy #SYMG
beq .1
2020-02-23 20:01:48 +00:00
2020-02-26 16:34:13 +00:00
iny Add 1 for \0 after locals/privates
2019-03-20 16:55:26 +00:00
bne .1
inc
2020-02-23 20:01:48 +00:00
2019-03-20 16:55:26 +00:00
.1 >PUSHYA
2019-03-18 16:48:16 +00:00
>SYSCALL SListAddData
2019-03-19 16:52:08 +00:00
bcs .9
2020-02-23 20:01:48 +00:00
2020-02-24 16:37:55 +00:00
>STZ.G SYM.bInGlobal
2019-04-01 06:07:56 +00:00
>STA.G MAC.CtxID
2020-02-23 20:01:48 +00:00
.8 clc
.9 rts
*---------------------------------------
2019-03-22 16:47:33 +00:00
SYM.UpdateGlobal
2020-02-23 20:01:48 +00:00
>PUSHB.G SYM.hList
2019-03-22 16:47:33 +00:00
>PUSHW.G SYM.GlobalID
2020-02-26 16:34:13 +00:00
>PUSHW ZPSymbolBuf
>LDA.G SYM.GlobalPtr
tay
lda #0
cpy #SYMG
beq .1
iny Add 1 for \0 after locals/privates
bne .1
inc
.1 >PUSHYA
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
2020-02-23 20:01:48 +00:00
.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
2020-02-26 07:28:45 +00:00
2019-10-03 06:25:27 +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
*---------------------------------------
2020-02-25 16:42:22 +00:00
SYM.NewLocalA 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
2020-02-23 20:01:48 +00:00
2020-02-28 16:30:16 +00:00
>LDA.G ASM.PASS
bne SYM.LookupLocalX Pass #2: check if defined
*---------------------------------------
jsr SYM.LookupLocalX 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
2020-02-23 20:01:48 +00:00
ldy #ASM.PC+4
2020-02-23 20:01:48 +00:00
.1 dey
lda (pData),y
pha
cpy #ASM.PC
2019-10-03 06:25:27 +00:00
bne .1
2020-02-23 20:01:48 +00:00
2019-04-01 06:07:56 +00:00
>LDA.G MAC.CtxID Get Macro Context ID
2020-02-23 20:01:48 +00:00
2020-02-26 16:34:13 +00:00
pha
2020-02-23 20:01:48 +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)
2020-02-23 20:01:48 +00:00
.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
2020-02-26 16:34:13 +00:00
sta (ZPSymbolBuf),y ending \0
2019-03-29 07:46:36 +00:00
tya
2020-02-25 16:42:22 +00:00
2019-03-29 07:46:36 +00:00
>STA.G SYM.GlobalPtr
2020-02-23 20:01:48 +00:00
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)
2020-02-23 20:01:48 +00:00
2019-03-25 07:04:40 +00:00
.8 clc
rts
2019-03-20 16:55:26 +00:00
2019-10-03 06:25:27 +00:00
.91 lda #E.INV.LABEL
2019-03-20 16:55:26 +00:00
sec
rts
2020-02-23 20:01:48 +00:00
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
*---------------------------------------
2020-02-28 16:30:16 +00:00
SYM.LookupLocalX
lda (ZPSymbolBuf)
2019-03-22 16:47:33 +00:00
and #SYMG.F.LOCALS
2020-02-28 16:30:16 +00:00
beq .99
2020-02-23 20:01:48 +00:00
2019-03-25 07:04:40 +00:00
ldy #SYMG
2019-04-01 06:07:56 +00:00
2020-02-28 16:30:16 +00:00
.1 phy
lda (ZPSymbolBuf),y
2019-03-21 16:37:02 +00:00
beq .9
2020-02-23 20:01:48 +00:00
2019-03-21 16:37:02 +00:00
txa
2019-03-29 16:21:30 +00:00
cmp (ZPSymbolBuf),y
2020-02-28 16:30:16 +00:00
bne .3
2019-04-01 06:07:56 +00:00
>LDA.G MAC.CtxID
2020-02-28 16:30:16 +00:00
2019-04-01 06:07:56 +00:00
ply
2020-02-28 16:30:16 +00:00
phy
2019-04-01 06:07:56 +00:00
iny
cmp (ZPSymbolBuf),y
2019-03-20 16:55:26 +00:00
bne .3
2019-03-25 07:04:40 +00:00
ldx #0
2020-02-23 20:01:48 +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
2020-02-23 20:01:48 +00:00
2019-03-20 16:55:26 +00:00
bne .2
2019-03-25 07:04:40 +00:00
lda #2
sta SRC.ACC.SIZE
2020-02-28 16:30:16 +00:00
ply
clc
rts
2019-04-01 06:07:56 +00:00
2020-02-28 16:30:16 +00:00
.3 pla
2019-03-20 16:55:26 +00:00
clc
adc #SYML
tay
2019-03-29 16:21:30 +00:00
bra .1
2020-02-23 20:01:48 +00:00
2020-02-28 16:30:16 +00:00
.9 ply
.99 lda #E.UNDEF.SYMBOL
2019-03-20 16:55:26 +00:00
sec
rts
*---------------------------------------
2020-02-26 16:34:13 +00:00
SYM.Dump.End >PUSHW L.MSG.SUMMARY
>PUSHW ZPPtr2
>PUSHBI 2
jmp OUT.Print
SYM.Dump.8 clc
rts
*---------------------------------------
SYM.Dump >LDA.G bListAll
bmi .10
>LDA.G ASM.LI.ON
bpl SYM.Dump.8
.10 >LDYA L.MSG.SYMBOLS
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2020-02-26 16:34:13 +00:00
stz ZPPtr2
stz ZPPtr2+1
.1 >LDYA ZPPtr2
>STYA ZPPtr1
>PUSHB.G SYM.hList
>PUSHW ZPPtr1
>PUSHW ZPTmpBuf
>SYSCALL SListGetByID
bcs SYM.Dump.End
>STYA ZPPtr2 Save Next ID
>PUSHB.G SYM.hList
>PUSHW ZPPtr1 KeyID
>PUSHW ZPSymbolBuf
>PUSHWI $ffff All
>PUSHWZ from Start
>SYSCALL SListGetData
bcs .9
ldy #SYMG.SIZE Get Symbol Size
lda (ZPSymbolBuf),y
pha
asl
tax
>PUSHB L.MSG.EQU0+1,x
>PUSHB L.MSG.EQU0,x
pla
pha
tax byte count
clc
adc #SYMG.V
tay
.2 dey
lda (ZPSymbolBuf),y
>PUSHA
dex
bne .2
pla Byte Count
.3 >PUSHA
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-26 16:34:13 +00:00
>PUSHW ZPTmpBuf Label
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-26 16:34:13 +00:00
lda (ZPSymbolBuf)
bit #SYMG.F.LOCALS
beq .7
jsr SYM.Dump.LP
.7 jsr OUT.PrintCR
jmp .1
.9 rts
*---------------------------------------
SYM.Dump.LP ldy #SYMG
2020-02-28 16:30:16 +00:00
ldx #5
2020-02-26 16:34:13 +00:00
.1 lda (ZPSymbolBuf),y
beq .8
phy
2020-02-28 16:30:16 +00:00
phx
2020-02-26 16:34:13 +00:00
tax ID
iny
lda (ZPSymbolBuf),y MacID
bne .3
>PUSHW L.MSG.LSYMBOL
txa
>PUSHA
jsr SYM.Dump.PushValueY
lda #5
bra .5
.3 >PUSHW L.MSG.PSYMBOL
txa
>PUSHA
>PUSHB (ZPSymbolBuf),y
jsr SYM.Dump.PushValueY
lda #6
.5 >PUSHA
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2020-02-26 16:34:13 +00:00
2020-02-28 16:30:16 +00:00
plx
dex
bne .6
jsr OUT.PrintCR
ldx #5
.6 pla
2020-02-26 16:34:13 +00:00
clc
adc #SYML
tay
bra .1
.8 rts
*---------------------------------------
SYM.Dump.PushValueY
ldx #4
iny
iny
iny
iny
.1 lda (ZPSymbolBuf),y
>PUSHA
dey
dex
bne .1
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