A2osX/BIN/CC.S.LINK.txt

269 lines
4.1 KiB
Plaintext
Raw Normal View History

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