stekas@hou2g.UUCP (12/05/83)
The problem with with loading concerns segment location as in
the following example:
DATA SEGMENT
. Data goes here
.
DATA ENDS
DELTA EQU {Difference between DATA and CODE segments}
CODE SEGMENT
ENTRY PUSH BP
MOV AX, CS ; Set up DATA reference using
SUB AX, DELTA ; constant offset from CODE
MOV DS, AX ; so DATA&CODE can go anywhere
.
RET FAR
CODE ENDS
As long as DATA and CODE are loaded contiguously, the above
code will work anywhere in memory if entered at ENTRY.
The problem is that there is no (easy) way to get the linker to load
DATA before CODE. If one reverses the order of CODE and DATA
in the assembler listing, then CODE has forward references and
assembly bombs. The only way of getting DATA loaded first is to
declare it as COMMON, assemble a copy of it seperately and link it
seperately as in - LINK DATA.OBJ+CODE.OBJ
It seems there should be an easier way to do this. - Jimjph@whuxle.UUCP (12/10/83)
#R:hou2g:-12300:whuxle:22700008:000:548 whuxle!jph Dec 5 18:42:00 1983 The easier way is not to use separate CODE and DATA segments. In that case the program would look like: cseg segment entry: jmp init : : : data goes here so that it is defined before referenced : : init: ......real start of program push cs pop ds ; address data : : cseg ends This puts everything in the same segment and makes relocation on setting up of addressability very easy. I have noticed that the linker will concatenate the segments together in alphabetical order if they have the same attributes.