A2osX/BIN/ASM.S.SYM.txt

458 lines
7.7 KiB
Plaintext
Raw Normal View History

NEW
2019-03-18 16:48:16 +00:00
PREFIX
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
*---------------------------------------
* 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
>STA.G SYM.hGlobalList
>LDYAI 256
2018-07-20 11:51:08 +00:00
>SYSCALL getmem
bcs .9
>STYA ZPNameBuf
txa
>STA.G SYM.hNameBuf
>LDYAI 256
2018-07-20 11:51:08 +00:00
>SYSCALL getmem
bcs .9
>STYA ZPGlobalBuf
txa
>STA.G SYM.hGlobalBuf
.9 rts
*---------------------------------------
2019-03-22 16:47:33 +00:00
SYM.Reset >STZ.G SYM.bInGlobal
rts
*---------------------------------------
2019-03-22 07:41:35 +00:00
SYM.Quit >LDA.G SYM.hNameBuf
beq .2
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
.2 >LDA.G SYM.hGlobalBuf
beq .3
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2019-03-20 16:55:26 +00:00
.3 >LDA.G SYM.hGlobalList
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
SYM.Quit.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-20 16:55:26 +00:00
>PUSHW ZPNameBuf
2019-03-19 16:52:08 +00:00
>PUSHW ZPPtr1
2019-03-18 16:48:16 +00:00
>LDA.G SYM.hGlobalList
>SYSCALL SListGetByID
2019-03-20 16:55:26 +00:00
bcs SYM.Quit.8
2019-03-20 16:55:26 +00:00
>STYA ZPPtr2 Save Next ID
2019-03-19 16:52:08 +00:00
>PUSHWI 0 Start
>PUSHWI $ffff End
2019-03-20 16:55:26 +00:00
>PUSHW ZPGlobalBuf
>PUSHW ZPPtr1 KeyID
2019-03-19 16:52:08 +00:00
>LDA.G SYM.hGlobalList
2019-03-21 16:37:02 +00:00
2019-03-19 16:52:08 +00:00
>SYSCALL SListGetData
2019-03-21 07:07:38 +00:00
bcs SYM.Quit.RTS
2019-03-19 16:52:08 +00:00
2019-03-20 16:55:26 +00:00
ldy #SYMG.SIZE Get Symbol Size
lda (ZPGlobalBuf),y
tax
beq .3
2019-03-20 16:55:26 +00:00
phx
.2 iny
lda (ZPGlobalBuf),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
>LDYA ZPNameBuf Label
2019-03-21 07:07:38 +00:00
>SYSCALL printf
2019-03-20 16:55:26 +00:00
lda (ZPGlobalBuf)
2019-03-21 16:37:02 +00:00
2019-03-20 16:55:26 +00:00
bit #SYMG.F.LOCALS
beq .7
2019-03-20 16:55:26 +00:00
ldy #SYMG
.4 lda (ZPGlobalBuf),y
beq .7 End Local Symbol
2019-03-21 16:37:02 +00:00
pha Save ID
ldx #4
.5 iny
lda (ZPGlobalBuf),y
>PUSHA
dex
bne .5
pla
>PUSHA
phy
2018-11-26 21:52:49 +00:00
>PUSHBI 6
>LDYA L.MSG.LSYMBOL
2018-06-21 15:12:10 +00:00
>SYSCALL printf
ply
bne .4
2018-11-26 21:52:49 +00:00
.7 >PUSHBI 0
>LDYA L.MSG.CRLF
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2019-03-21 07:07:38 +00:00
jmp .1
*---------------------------------------
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
>PUSHW ZPLinePtr Pass #1; try to add global...
2019-03-19 16:52:08 +00:00
>LDA.G SYM.hGlobalList
>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
sta (ZPGlobalBuf),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
clc
rts
.9 lda #ERR.SYMBOL.REDEF
sec
.99 rts
*---------------------------------------
2019-03-19 16:52:08 +00:00
SYM.GetGlobal >PUSHW ZPLinePtr Pass #2: should be already defined...
>LDA.G SYM.hGlobalList
>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-03-20 16:55:26 +00:00
.1 >PUSHWI 0 Start
>PUSHWI $ffff End
2019-03-22 16:47:33 +00:00
>PUSHW ZPGlobalBuf
>PUSHW.G SYM.GlobalID
2019-03-20 16:55:26 +00:00
>LDA.G SYM.hGlobalList
>SYSCALL SListGetData
2019-03-22 16:47:33 +00:00
bcs .99
lda #$ff
>STA.G SYM.bInGlobal
* clc
rts
.9 lda #ERR.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-18 16:48:16 +00:00
>LDA.G SYM.hGlobalList
>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
.2 lda (ZPGlobalBuf),y
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
.3 >PUSHWI 0 Start
>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-20 16:55:26 +00:00
>LDA.G SYM.hGlobalList
>SYSCALL SListGetData
rts
.9 lda #ERR.UNDEF.SYMBOL
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-21 16:37:02 +00:00
lda (ZPGlobalBuf)
ora #SYMG.F.LOCALS
sta (ZPGlobalBuf)
2019-03-20 16:55:26 +00:00
lda #0
sta (ZPGlobalBuf),y
iny
bne .1
inc
.1 >PUSHYA
.2 >PUSHW ZPGlobalBuf
2019-03-18 16:48:16 +00:00
>PUSHW.G SYM.GlobalID
>LDA.G SYM.hGlobalList
>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
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
>LDA.G SYM.hGlobalList
>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
sta (ZPGlobalBuf),y
2019-03-21 16:37:02 +00:00
dey
bpl .2
2019-03-20 16:55:26 +00:00
rts
*---------------------------------------
* Local Symbol Record: (5 bytes)
* 0 : Local ID (1->255)
* 1-4 : 32 bits Value (PC)
*---------------------------------------
SYM.NewOrGetLocalA
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-20 16:55:26 +00:00
bne SYM.GetLocalX
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
tay
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-03-21 16:37:02 +00:00
>LDA.G SYM.GlobalPtr
tay
txa Get Back ID
sta (ZPGlobalBuf),y
2019-03-20 16:55:26 +00:00
ldx #4
.2 pla
iny
sta (ZPGlobalBuf),y
dex
bne .2
2019-03-22 16:47:33 +00:00
tya
2019-03-20 16:55:26 +00:00
>STA.G SYM.GlobalPtr
2019-03-22 16:47:33 +00:00
iny
lda #0
sta (ZPGlobalBuf),y
clc
rts
2019-03-20 16:55:26 +00:00
.91 lda #ERR.INV.LABEL
sec
rts
.90 lda #ERR.TOO.MANY.LOCAL
2019-03-20 16:55:26 +00:00
sec
rts
.9 lda #ERR.SYMBOL.REDEF
sec
rts
2018-01-29 16:48:07 +00:00
*---------------------------------------
2019-03-22 16:47:33 +00:00
SYM.GetLocalX lda (ZPGlobalBuf)
and #SYMG.F.LOCALS
beq .9
ldy #SYML
2019-03-21 16:37:02 +00:00
.1 lda (ZPGlobalBuf),y
beq .9
txa
2019-03-20 16:55:26 +00:00
cmp (ZPGlobalBuf),y
bne .3
2019-03-20 16:55:26 +00:00
ldx #4
stx SRC.ACC.SIZE
.2 iny
lda (ZPGlobalBuf),y
2019-03-20 16:55:26 +00:00
sta SRC.ACC.SIZE,x
dex
bne .2
clc
rts
2019-03-20 16:55:26 +00:00
.3 tya
clc
adc #SYML
tay
bne .1
.9 lda #ERR.UNDEF.SYMBOL
sec
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
*---------------------------------------
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