Linker/seg.asm

1 line
22 KiB
NASM
Raw Normal View History

keep obj/seg mcopy seg.mac **************************************************************** * * Segment Processing * * This module contains the subroutines used to find the next * segment that needs to be linked. * **************************************************************** copy directPage **************************************************************** * * SegCommon - global data for the segment module * **************************************************************** * SegCommon privdata ; ; Scalars ; inFile ds 2 are we processing a file? isLibrary ds 2 is the file we are processing a library file? largeLibFile ds 2 largest library file number libDisp ds 4 disp in library symbol table suffix ds 2 suffix letter end **************************************************************** * * CopyBasename - make a copy of the base name * * inputs: * basename - base keep name * * outputs: * fname - copy of basename * **************************************************************** * CopyBasename start using SegCommon ph4 fname free old buffer jsr Free lda [basename] get new buffer pea 0 inc A inc A pha jsr MLalloc sta fname stx fname+2 sta r4 copy basename to fname stx r6 move4 basename,r0 jsr MoveName rts end **************************************************************** * * Exists - see if a file exists * * Inputs: * fname - pointer to the file name * * Returns: * 1 if the file exists, else 0 * **************************************************************** * Exists private val equ 1 does the file exist? sub (4:fname),2 stz val assume the file does not exist move4 fname,giPathname if it does exist then OSGet_File_Info giRec bcs lb1 inc val ++val lb1 ret 2:val return val giRec dc i'2' giPathname ds 4 ds 2 end **************************************************************** * * ExistsM - see if a file exists in the memory list * * Inputs: * fname - pointer to the file name * memory - is this a +m link? * * Returns: * 1 if the file exists, else 0 * **************************************************************** * ExistsM private using Common val equ 1 does the file exist? sub (4:fname),2 ph4 fname (needed for both if and else branch) lda memory if this is a +m link then beq lb1 jsr ScanFastFile scan the FastFile list bra lb2 else lb1 jsr Exists check the disk lb2 sta val ret 2:val return val end **************************************************************** * * FileType - get the type of a file * * Inputs: * fname - pointer to the file name * * Returns: * file type (0 for none) * **************************************************************** * FileType private sub (4:fname),0 stz giFiletype assume the file does not exist move4 fname,giPathname if it does exist then OSGet_File_Info giRec ret 2:giFiletype return giFiletype giRec dc i'3' giPathname ds 4 ds 2 giFiletype ds 2 end **************************************************************** * * FindSuffix - find the highest keep suffix * * Inputs: * basename - base file name * * Outputs: * suffix - highest existing obj file suffix letter * **************************************************************** * FindSuffix private using SegCommon lda #'A' set the initial suffix sta lsuffix lb1 lda lsuffix try it out sta suffix jsr KeepName ph4 fname jsr ExistsM tax beq lb2 inc lsuffix it works, so try the next one bra lb1 lb2 lda lsuffix use the last one - it worked (or did dec A not exist, as in 'A'-1) sta suffix rts lsuffix ds 2 local suffix end **************************************************************** * * GetName - get the next file name * * Inputs: * sdisp - disp in the name list * slist - list of file names * * Outputs: * basename - new file name * C - set if a name was found, else clear * **************************************************************** * GetName start ph4 baseName Free(baseName) jsr Free stz baseName basename = NULL stz baseName+2 lda [slist] maxDisp = length(slist)+2 inc A inc A sta maxDisp ldy sdisp Y = sdisp+2 iny iny lb1