A2osX/BIN/CC.S.LINK.txt
2023-07-14 12:24:49 +02:00

269 lines
4.1 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
*--------------------------------------
CC.Link >LDYA L.MSG.LINKING
>SYSCALL PutS
ldy #0
lda #1
.1 >STYA ZPPtr1 SymID
* >DEBUG
>PUSHB.G CC.hSyms
>PUSHW ZPPtr1 SymID
>PUSHW pData
>SYSCALL SListGetByID
bcs .8
>STYA ZPPtr2 NextID
>PUSHB.G CC.hSyms
>PUSHW ZPPtr1 SymID
>PUSHW ZPSymBufPtr
>PUSHWI 65535 All
>PUSHWZ from Start
>SYSCALL SListGetData
bcs .99
>LDA.G bVerbose
bpl .2
jsr CC.Link.Dump
.2 ldy #SYM.SC
lda (ZPSymBufPtr),y
bne .7 SYM.SC.STATIC
ldy #SYM.Addr+1
lda (ZPSymBufPtr),y
dey
ora (ZPSymBufPtr),y
bne .7
jsr CC.Link.Lookup
bcs .9
jsr CC.Link.Update
bcs .99
.7 >LDYA ZPPtr2
jmp .1
.8 clc
rts
.9 >LDA.G bVerbose
bmi .90
jsr CC.Link.Dump
.90 lda #E.FUNDEF
sec
.99 rts
*--------------------------------------
* Input : pData = Symbol
*--------------------------------------
CC.Link.Lookup >LDYA L.CC.SYSCALL
jsr CC.Link.LookupYA
ldx #1
bcc .99
>LDYA L.CC.FPUCALL
jsr CC.Link.LookupYA
ldx #2
bcc .99
>LDA.G LibCount
* sec
beq .99
lda #0
sta ArgIndex
clc
.1 adc #hLibOs
tay
lda (pData),y
>SYSCALL GetMemPtr
jsr CC.Link.LookupYA
bcs .2
ldx ArgIndex
inx
inx
inx
rts
.2 inc ArgIndex
lda ArgIndex
>CMP.G LibCount
bcc .1
.99 rts
*--------------------------------------
CC.Link.LookupYA
>STYA ZPLookupPtr
ldy #$ff
.1 iny
lda (pData),y
bne .1
tya
tax Symbol Len
.2 lda (ZPLookupPtr)
beq .9 Ending 0, not found....
txa Get Back Len
cmp (ZPLookupPtr) Same Len ?
bne .4
tay
.3 lda (ZPLookupPtr),y
dey
cmp (pData),y
bne .4
tya
bne .3
lda (ZPLookupPtr)
tay
iny
lda (ZPLookupPtr),y get fID
clc
rts
.4 lda (ZPLookupPtr)
inc
jsr CC.ZPLookupPtrAddAp1 Skip LEN\Symbol\ID
bra .2
.9 sec
rts
*--------------------------------------
* A=ID X=SYS|FPU|LIB
*--------------------------------------
CC.Link.Update ldy #SYM.Addr
sta (ZPSymBufPtr),y
iny
txa
sta (ZPSymBufPtr),y
>PUSHB.G CC.hSyms
>PUSHW ZPPtr1 SymID
>PUSHW ZPSymBufPtr
>PUSHBI 0
ldy #SYM.Q
lda (ZPSymBufPtr),y
and #SYM.Q.FUNC
bne .1
ldy #SYM.DefSize
lda (ZPSymBufPtr),y
bra .2
.1 lda #SYM.F.MAX
.2 >PUSHA
>SYSCALL SListSetData
rts
*--------------------------------------
CC.Link.Dump ldy #$ff
.1 iny
lda (pData),y
bne .1
iny
lda (pData),y
sta ZPPtr3
iny
lda (pData),y
sta ZPPtr3+1
>PUSHW L.MSG.LINKING2
>PUSHW ZPPtr1 ID
>PUSHW ZPPtr3 Scope
>PUSHW pData Name
>PUSHB (ZPSymBufPtr) SYM.T
ldy #1
>PUSHB (ZPSymBufPtr),y SYM.Q
iny
>PUSHB (ZPSymBufPtr),y SYM.SC
ldy #SYM.DefSize
>PUSHB (ZPSymBufPtr),y
ldy #SYM.SizeOf+1
>PUSHB (ZPSymBufPtr),y
dey
>PUSHB (ZPSymBufPtr),y
ldy #SYM.Addr+1
>PUSHB (ZPSymBufPtr),y
dey
>PUSHB (ZPSymBufPtr),y
>PUSHBI 14
>SYSCALL PrintF
rts
*--------------------------------------
CC.Link.CheckMain
>PUSHB.G CC.hSyms
>PUSHW L.CC.MAIN
>PUSHWI 0 ScopeID
>SYSCALL SListLookup
bcs .9
>STYA ZPPtr1 SymID
>PUSHB.G CC.hSyms
>PUSHW ZPPtr1 SymID
>PUSHW ZPSymBufPtr
>PUSHWI 65535 all
>PUSHWZ From Start
>SYSCALL SListGetData
bcs .99
ldy #SYM.Addr
lda (ZPSymBufPtr),y
iny
ora (ZPSymBufPtr),y
beq .9
lda (ZPSymBufPtr),y
sta PCC.FH+PCC.FH.MAIN+1
dey
lda (ZPSymBufPtr),y
sta PCC.FH+PCC.FH.MAIN
* clc
rts
.9 >LDYA L.MSG.NOMAIN
>SYSCALL putS
lda #E.CSYN
sec
.99 rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.link
LOAD usr/src/bin/cc.s
ASM