A2osX/BIN/ASM.S.SYM.txt

460 lines
7.4 KiB
Plaintext
Raw Normal View History

NEW
2018-11-17 17:17:13 +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
>LDYAI 256
2018-07-20 11:51:08 +00:00
>SYSCALL getmem
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
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
.1 >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
.3 >LDA.G SYM.hGlobalList
beq .8
2018-07-24 16:00:24 +00:00
>SYSCALL SListFree
.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
2018-06-21 15:12:10 +00:00
>SYSCALL printf
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
2018-06-21 15:12:10 +00:00
>SYSCALL printf
>PUSHW ZPNameBuf Label (PString)
>LDYA L.MSG.PSTR
2018-06-21 15:12:10 +00:00
>SYSCALL printf
bcs .9
ldy #SYMG.SIZE
.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.LSYMBOL
2018-06-21 15:12:10 +00:00
>SYSCALL printf
ply
bne .4
.7 >LDYA L.MSG.CRLF
2018-06-21 15:12:10 +00:00
>SYSCALL printf
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
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
bra .3
.2 >PUSHW.G SYM.GlobalID
>PUSHW ZPGlobalBuf
>SYSCALL SListUpdateByID
.3 bcs .9
lda #0
sta (ZPGlobalBuf)
rts
.8 clc
.9 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
ldy #SYMG.F
sta (ZPGlobalBuf),y
txa A=PC Size
rts
*---------------------------------------
SYM.Acc2Global ldx #4
ldy #SYMG.F+4
.1 lda SRC.ACC.SIZE,x
sta (ZPGlobalBuf),y
dey
dex
bpl .1
clc
rts
*---------------------------------------
SYM.Lookup2Acc ldy #SYMG.F+4
ldx #4
.1 lda (ZPLookupBuf),y
sta SRC.ACC.SIZE,x
dey
dex
bne .1
lda (ZPLookupBuf),y
and #SYMG.F.SIZE
sta SRC.ACC.SIZE
clc
rts
2015-10-04 20:55:51 +00:00
*---------------------------------------
* Local Symbol Record: (5 bytes)
* 0 : Local ID (1->255)
* 1-4 : 32 bits Value (PC)
*---------------------------------------
SYM.NewOrGetLocalA
tax Save ID
lda (ZPGlobalBuf) not in a global label
bne .1
lda #ERR.INV.LABEL
clc
rts
.1 >LDA.G ASM.PASS
bne SYM.LookupLocal.1 Pass #2: should be already defined...
SYM.NewLocal jsr SYM.LookupLocal.1 Pass #1; try to add
bcc .9 Already Defined
lda (ZPGlobalBuf)
tay
clc
adc #SYML.SIZE
bcs .90
ldy #ASM.PC+4
.1 dey
lda (pData),y
pha
cpy #ASM.PC
bne .1
lda (ZPGlobalBuf)
tay
iny
txa Get Back ID
sta (ZPGlobalBuf),y
ldx #4
.2 pla
iny
sta (ZPGlobalBuf),y
dex
bne .2
tya
sta (ZPGlobalBuf)
clc
rts
.90 lda #ERR.TOO.MANY.LOCAL
* sec
rts
.9 lda #ERR.SYMBOL.REDEF
sec
rts
2018-01-29 16:48:07 +00:00
*---------------------------------------
SYM.LookupLocal tax
SYM.LookupLocal.1
ldy #SYMG.SIZE
tya
.1 cmp (ZPGlobalBuf)
beq .9 CS if =
txa
iny
cmp (ZPGlobalBuf),y
beq .2
tya
clc
adc #SYML.SIZE-1
tay
bcc .1
.9 lda #ERR.UNDEF.SYMBOL
* sec
rts
.2 ldx #0
.3 iny
lda (ZPGlobalBuf),y
sta SRC.ACC,x
inx
cpx #4
bne .3
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
*---------------------------------------
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