A2osX/BIN/ASM.S.SYM.txt

585 lines
9.0 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
2020-03-02 16:49:47 +00:00
>STA.G SYM.hBuf
.9 rts
*---------------------------------------
2020-03-02 16:49:47 +00:00
SYM.Quit >LDA.G SYM.hBuf
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
*---------------------------------------
2020-03-02 06:53:19 +00:00
SYM.NewGlobal >LDA.G ASM.PASS
bne SYM.NewGlobal2
2020-03-02 06:53:19 +00:00
jsr SYM.StoreGlobal Store previous if any
2019-03-20 16:55:26 +00:00
bcs .99
2019-03-27 17:01:01 +00:00
2020-03-02 06:53:19 +00:00
>STZ.G MAC.CtxID
>STA.G MAC.CtxNextID
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-03-02 06:53:19 +00:00
2020-03-02 16:49:47 +00:00
>STYA.G SYM.ID
2020-03-02 06:53:19 +00:00
2019-03-19 16:52:08 +00:00
txa
2020-03-02 06:53:19 +00:00
* clc
2019-03-19 16:52:08 +00:00
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
2020-03-02 16:49:47 +00:00
stz SRC.ACC.F
2019-03-20 16:55:26 +00:00
jsr SYM.Acc2Global
2020-02-23 20:01:48 +00:00
2019-03-20 16:55:26 +00:00
lda #SYMG
2020-03-02 16:49:47 +00:00
>STA.G SYM.BufPtr
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
clc
rts
2020-02-23 20:01:48 +00:00
2019-03-25 07:04:40 +00:00
.9 lda #E.SYMBOL.REDEF
sec
2020-03-06 16:20:29 +00:00
.99
SYM.NewGlobal.RTS
rts
*---------------------------------------
2020-03-02 06:53:19 +00:00
SYM.NewGlobal2 >PUSHB.G SYM.hList Pass #2: should be already defined...
>PUSHW ZPLinePtr
>SYSCALL SListLookup
2020-03-06 16:20:29 +00:00
bcs SYM.NewGlobal.RTS
2020-03-02 06:53:19 +00:00
2020-03-02 16:49:47 +00:00
>STYA.G SYM.ID
2019-03-19 16:52:08 +00:00
txa
2020-03-02 06:53:19 +00:00
* clc
adc ZPLinePtr
sta ZPLinePtr
bcc .1
inc ZPLinePtr+1
2020-02-24 16:37:55 +00:00
2020-03-02 06:53:19 +00:00
.1 >PUSHB.G SYM.hList Pass #2: Retore full context
2020-03-02 16:49:47 +00:00
>PUSHW.G SYM.ID
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
2020-03-06 16:20:29 +00:00
* lda (ZPSymbolBuf)
* and #SYMG.F.EQU
* bne .8
* >LDA.G ASM.PC
* ldy #SYMG.V
* cmp (ZPSymbolBuf),y
* bne .7
* >LDA.G ASM.PC+1
* ldy #SYMG.V+1
* cmp (ZPSymbolBuf),y
* beq .8
*.7 lda #E.OUT.OF.SYNC
* sec
* rts
.8 lda #SYMG
2020-03-02 16:49:47 +00:00
>STA.G SYM.BufPtr
2020-03-02 06:53:19 +00:00
>STZ.G MAC.CtxID
>STA.G MAC.CtxNextID
2020-03-06 16:20:29 +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
2020-03-02 06:53:19 +00:00
bcs .4
2020-02-23 20:01:48 +00:00
2019-03-22 07:41:35 +00:00
>STYA ZPPtr1
2020-03-02 06:53:19 +00:00
2019-03-18 16:48:16 +00:00
txa
2020-03-02 06:53:19 +00:00
* clc
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
2020-03-02 16:49:47 +00:00
.1 >LDA.G SYM.ID
cmp ZPPtr1
bne .3
iny
lda (pData),y
cmp ZPPtr1+1
bne .3
ldy #SYMG-1
.2 lda (ZPSymbolBuf),y
sta SRC.ACC.F,y
dey
bpl .2
2020-03-05 16:55:02 +00:00
2020-03-02 16:49:47 +00:00
clc
rts
.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-03-02 06:53:19 +00:00
.4 >LDA.G ASM.PASS pass#2?
bne .9 yes, undefined symbol
2020-03-05 16:55:02 +00:00
lda #SYMG.F.FWREF
tsb SRC.ACC.F
2020-03-06 16:20:29 +00:00
lda #2
sta SYMG.SIZE
2020-03-03 16:44:52 +00:00
2020-03-02 06:53:19 +00:00
.5 jsr SRC.GetNextChar
bcs .8
jsr SRC.IsLetterOrDigit
bcc .5
cmp #'.'
beq .5
cmp #'_'
beq .5
2020-02-23 20:01:48 +00:00
2020-03-02 06:53:19 +00:00
.8 clc
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
2020-03-02 16:49:47 +00:00
>LDA.G SYM.BufPtr
beq .8
2019-03-20 16:55:26 +00:00
2020-02-23 20:01:48 +00:00
>PUSHB.G SYM.hList
2020-03-02 16:49:47 +00:00
>PUSHW.G SYM.ID
2020-02-23 20:01:48 +00:00
>PUSHW ZPSymbolBuf
2020-03-02 16:49:47 +00:00
>LDA.G SYM.BufPtr
2019-03-20 16:55:26 +00:00
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-03-02 16:49:47 +00:00
>STZ.G SYM.BufPtr
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
2020-03-02 16:49:47 +00:00
>PUSHW.G SYM.ID
2020-02-26 16:34:13 +00:00
>PUSHW ZPSymbolBuf
2020-03-02 16:49:47 +00:00
>LDA.G SYM.BufPtr
2020-02-26 16:34:13 +00:00
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
2020-03-06 06:56:36 +00:00
lda #2
sta SRC.ACC.SIZE
2019-03-19 16:52:08 +00:00
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
2020-03-02 16:49:47 +00:00
>LDA.G SYM.BufPtr not in a global label
beq .91
2020-02-23 20:01:48 +00:00
2020-02-28 16:30:16 +00:00
>LDA.G ASM.PASS
2020-03-02 06:53:19 +00:00
bne .20
2020-02-28 16:30:16 +00:00
*---------------------------------------
2020-03-02 06:53:19 +00:00
jsr SYM.LookupLocalX Pass #1: try to add
bcc .9 Already Defined
2020-03-02 16:49:47 +00:00
>LDA.G SYM.BufPtr
2020-03-06 16:20:29 +00:00
* sec
adc #SYML
bcs .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
2020-03-02 16:49:47 +00:00
>LDA.G SYM.BufPtr
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
2020-03-02 16:49:47 +00:00
>STA.G SYM.BufPtr
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-03-02 16:49:47 +00:00
.20 >LDA.G SYM.BufPtr Pass #2: setup SYM.BufPtr in case of .EQ
clc
adc #SYML
sta (pData),y
2020-03-02 06:53:19 +00:00
rts
*---------------------------------------
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
2020-03-02 06:53:19 +00:00
pla
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
2020-03-02 06:53:19 +00:00
bmi SYM.Dump.1
2020-02-26 16:34:13 +00:00
>LDA.G ASM.LI.ON
bpl SYM.Dump.8
2020-03-02 06:53:19 +00:00
SYM.Dump.1 >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
2020-03-02 06:53:19 +00:00
.1
* jsr SYM.Dump.DBG
>LDYA ZPPtr2
2020-02-26 16:34:13 +00:00
>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
2020-03-02 16:49:47 +00:00
jsr SYM.Dump.GLP
bcc .1
.9 rts
*---------------------------------------
SYM.Dump.GLP jsr SYM.Dump.G
2020-03-02 06:53:19 +00:00
bcs .9
ldx #5
lda (ZPSymbolBuf)
bit #SYMG.F.LOCALS
beq .2
jsr SYM.Dump.LP
bcs .9
.2 cpx #5 already CR printed ?
beq .8
2020-03-02 16:49:47 +00:00
jmp OUT.PrintCR
.8 clc
.9 rts
2020-03-02 06:53:19 +00:00
*---------------------------------------
SYM.Dump.G ldy #SYMG.SIZE Get Symbol Size
2020-02-26 16:34:13 +00:00
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
2020-03-02 06:53:19 +00:00
>LDYA ZPTmpBuf Label
>SYSCALL PutS
rts
2020-02-26 16:34:13 +00:00
*---------------------------------------
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