Multiple assembled modules, each with an RLD and an ESD:
<module START loc><segment 1>!<seg 2 loc><segment 2>! . . .
<seg n loc><segment n>!@<module RLD>@<module ESD><EOF>
BEGIN
get load-point from operating system
module-addr = load-point
WHILE there is a module to load
BEGIN
/* Input the module text */
input start-loc for the module /* the START statement value; i.e., */
seg-loc = start-loc /* the assembly time module load point */
WHILE not at module RLD (@)
BEGIN
addr = module-addr + (seg-loc - start-loc)
input seg-code /* bring in the next block of object code */
WHILE seg-code <> "!"
BEGIN
store seg-code at addr
addr = addr + length(seg-code)
input seg-code /* bring in the next block of object code */
END {while}
input seg-loc from module /* assembly time load point for next segment */
END {while}
/* Process the module's relocation dictionary */
FOR loc IN module-RLD
BEGIN
adjusted-addr = (loc - start-loc) + module-addr
ADD (module-addr - start-loc) to memory addr
given by adjusted-addr
store adjusted-addr in global-RLD
END {for}
/* Adjust the module's external symbol dictionary addresses */
/* to reflect the module starting point */
FOR symbol/loc IN module-ESD
BEGIN /* both EXTDEF and EXTREF parts */
adjusted-addr = (loc - start-loc) + module-addr
store symbol/adjusted-addr in global-ESD
END {for}
module-addr = addr
/* An alternative: reset module-addr via the operating system */
END {while}
/* Process the global external symbol dictionary */
FOR symbol/addr IN global-EXTREF
BEGIN
search global-EXTDEF for symbol
IF found
ADD EXTDEF symbol value to memory location given by addr
and delete this entry from global-EXTREF
append addr to global-RLD
/* or leave in global-EXTREF to permit a later link-edit */
/* to include a new version of the referenced submodule */
ENDIF
/* if a symbol is not found, it remains as an entry in the */
/* EXTREF part of the final linked module's ESD (to permit */
/* later link editing of this module with others) */
END {for}
END /* The initial load point, together with the linked code and */
/* the adjusted dictionaries make a new, linkable module */
|