The load module is the program itself: its code and initialised data, as one image. DOS copies it into memory unchanged, apart from the words the relocation table names, and starts it at CS:IP. The file has no table of what is in it.
Where it is
The load module starts at the end of the header,
e_cparhdr × 16,
and runs to the end of the image that
e_cp and
e_cblp give. Its first byte is offset 0 of segment 0: every segment
value in the header and in the relocated words counts paragraphs from there. What lies
after the image is not part of it; see
Overlays and appended data.
The program’s uninitialised data and its stack are not stored at all. They lie in
the memory after the load module that
e_minalloc asks
for.
Segments
A DOS program uses several segments, but the file does not say where they start. The program shows them itself, in three places, and the explorer splits the load module at each paragraph they name:
- CS and SS from the header;
- the segment of each relocation entry, the segment the patched word is in;
- the value of each patched word, which is a segment address relative to the load module.
Each part runs from one of these paragraphs to the next, and the explorer labels it
with what points at it: the code at the entry point, the stack, or the number of
relocated words that point there. This split is the explorer’s inference from the
relocations, not something stored in the file. A segment may hold more than one of
the program’s own segments, and data that is only reached through offsets is not
found. Segments that start beyond the end of the image, such as a stack in the memory
e_minalloc asks for, are left out.
The code
The explorer disassembles the segment CS points at as 16-bit code. Addresses count from the start of that segment, so they match IP, and the entry point is marked. The region runs from the start of the segment to the next segment start after the entry point, or 64 KB, or the end of the image, whichever comes first. As in every Code section, an instruction is decoded at every byte and laid out in columns, so that a jump into the middle of another instruction can be followed. The instructions are described in the x86 instruction reference.
If CS:IP points outside the load module, the explorer says so on the header and shows no code.
Worked example
ORGART.EXE’s load module runs from 0x1A0 to the end of the file,
17,840 bytes. CS is 0, and 92 of its 95 relocated words hold 0x00AE. The
explorer finds three segments:
| Segment | File offset | Size | Holds |
|---|---|---|---|
0000 | 0x1A0 | 2,784 bytes | the code at the entry point |
00AE | 0xC80 | 14,960 bytes | the target of 92 relocated words |
0455 | 0x46F0 | 96 bytes | the target of the other 3 relocated words |
SS is 0x0CF2, past the end of the image, so the stack is not among them.
The Code section shows segment 0000, 2,784 bytes, up to the start of 00AE. Its entry
point, IP 0x0869, is at file offset 0xA09:
0869 9A 00 00 AE 00 call far 00AE:0000
086E 9A 48 05 AE 00 call far 00AE:0548
0873 55 push bp
0874 89 E5 mov bp, sp