3-10-5 Segment Definition

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 nameSEGMENT
Storage definition, allocation,
and alignment directives
Segment nameENDS
and a code segment normally has the form
Segment nameSEGMENT
Instructions and
instruction-related directives
Segment nameENDS

Figure 3-63 Representative program structure

DATA_SEG1     SEGMENT
      .
Directives
      .
      .
DATA_SEG1     ENDS
DATA_SEG2     SEGMENT
      .
Directives
      .
      .
DATA_SEG2     ENDS
CODE_SEG      SEGMENT
   START:     .
Instructions and directives
              .
              .
CODE_SEG      ENDS
              END     START

Table of Contents | Next page | Previous page

This is page 48.