mirror of
https://github.com/byteworksinc/Linker.git
synced 2024-06-10 07:29:29 +00:00
1 line
59 KiB
NASM
1 line
59 KiB
NASM
|
keep obj/out
mcopy out.mac
****************************************************************
*
* Ouput Module
*
* This module handles writing the output file and locating the
* proper load segment for code segments.
*
****************************************************************
copy directPage
****************************************************************
*
* OutCommon - global data for the segment module
*
****************************************************************
*
OutCommon data
;
; Constants
;
nameSize equ 10 size of a load segment name
dictGrowSize equ 4096 grow size for the dictionary buffer
dynGrowSize equ 1024 grow size for synamic segment buffer
;
; global variables
;
expressSegment ds 2 express segment number
keepRefnum ds 2 keep file reference number
lastLoadNumber ds 4 last load number allocated
loadList ds 4 head of load segment list
loadNamePtr ds 4 pointer to the name of the load segment
;
; Dynamic segment information
;
dynHandle ds 4 handle of the dynamic segment buffer
dynSize ds 2 bytes left in the buffer
dynBuffSize ds 4 total memory in the segment buffer
dynStart ds 4 ptr to the start of the buffer
dynSegment ds 2 dynamic segment number
;
; Current load segment information
;
loadNext ds 4 pointer to the next load segment
loadLast ds 4 pointer to the last load segment
loadPtr ds 4 pointer to the storage location for this record
loadNumber ds 2 number of this load segment
loadType ds 2 load segment type
loadORG ds 4 load segment origin
loadAlign ds 4 load segment aligment
loadBankSize ds 4 load segment bank size
loadName ds nameSize name of the load segment
loadSeg ds 4 handle of the segment buffer
loadSegStart ds 4 start of the segment buffer
loadPC ds 4 size of the load segment
loadOp ds 4 op disp for the segment buffer
loadOpSt ds 4 op at start of current lConst
loadDict ds 4 handle of the dictionary buffer
loadDictStart ds 4 start of the dictionary buffer
loadDictSize ds 2 bytes left in the dictionary buffer
loadDp ds 4 dp disp for the dictionary buffer
loadPass2 ds 2 are we ready for pass 2?
loadEnd anop end of the record
loadSize equ loadEnd-loadNext size of a load module record (even!)
end
****************************************************************
*
* AddEnd - add an end record to the dictionary
*
* Inputs:
* loadNext... - load segment record
*
****************************************************************
*
AddEnd private
using OutCommon
lda loadDictSize make sure there is room in the dictionary
bne lb1
jsr ExpandDictBuffer
lb1 short M save the end marker
lda #0
sta [dp]
long M
inc4 dp update dp
dec loadDictSize update loadDictSize
rts
end
****************************************************************
*
* AddSegment - add a segment to the expressload table
*
* Inputs:
* r8 - pointer to the segment to add
* r4,r8 - expressload list pointers
* expOffset - segment offset pointer
* expMap - segment map pointer
* expHeader - segment header map
* expressSegment - express segment number
*
****************************************************************
*
AddSegment private
using OutCommon
jsr MoveSegment move the segment ot the new list
sub4 expHeader,expOffset,r12 set the segment offset
lda r12
sta [expOffset]
ldy #6 zero the reserved words
lda #0
lb1 sta [expOffset],Y
dey
dey
bne lb1
add4 expOffset,#8 update the offset pointer
ldy #loadNumber-loadNext get the old segment number
lda [r4],Y
dec A set it's mapped segment
asl A
tay
lda expressSegment
sta [expMap],Y
ldy #loadNumber-loadNext set the new segment number
sta [r4],Y
inc expressSegment update segment number
add4 fMark,#69+5 allow for the segment header & lconst
move4 fMark,mark1 set the lconst mark
ldy #loadPC-loadNext find the segment size
lda [r4],Y
sta len1
iny
iny
lda [r4],Y
sta len1+2
add4 fMark,len1 allow for the segment body
move4 fMark,mark2 set the reloc mark
ldy #loadDp-loadNext find the reloc size
lda [r4],Y
sta len2
iny
iny
lda [r4],Y
sta len2+2
ora len2 if len2 = 0 then
bne lb1a
stz mark2 mark2 = 0
stz mark2+2
lb1a add4 fMark,le
|