As described earlier, a physical memory address is obtained by adding an offset to 16 times a segment address that is contained in a segment register. One of the tasks an assembler must perform is to assign the offsets of the labels and variables as it translates the instructions into machine language.
The assembler must also pass to the linker (via the object modules) all of the information that the linker will need in putting the various segments and modules together to form a program. Several directives are designed to instruct the assembler how to perform these functions.
To be able to assign the variable and label offsets the assembler must know the exact structure of each segment. A data, extra data, or stack segment normally has the form
Segment name | SEGMENT | |
Storage definition, allocation, and alignment directives | ||
Segment name | ENDS |
Segment name | SEGMENT | |
Instructions and instruction-related directives | ||
Segment name | ENDS |
Figure 3-63 Representative program structure
|
This is page 48.