During the first pass the assembler uses the location counter to construct a table, called a symbol (or identifier) table, that allows the second pass to use the offsets of the identifiers to generate operand addresses.
Location Counter | Number of Bytes Allocated | |||
---|---|---|---|---|
DATA_SEG SEGMENT | 0 | 0 | ||
ORG 10 | 0 | 10 | ||
NUM DB -29 | 10 | 1 | ||
ARRAY DB 100 DUP(?) | 11 | 100 | ||
COUNT DW 5 | 111 | 2 | ||
MASKS DB 82H,04H,2AH | 113 | 3 | ||
. | 116 | . | ||
. | . | . | ||
. | . | . |
For the above segments, the first pass of the assembler uses the location counter to enter
Symbol | Offset | Segment in which it was Defined | Type | |||
---|---|---|---|---|---|---|
DATA_SEG | 00H | Segment | ||||
NUM | 0AH | DATA_SEG | Byte Variable | |||
ARRAY | 0BH | DATA_SEG | Byte Variable | |||
COUNT | 6FH | DATA_SEG | Word Variable | |||
MASKS | 71H | DATA_SEG | Byte Variable | |||
  . | ||||||
  . | ||||||
  . | ||||||
CODE_SEG | 00H | Segment | ||||
START | 00H | CODE_SEG | Near Label | |||
REPEAT | 09H | CODE_SEG | Near Label |
Associated with each identifier, the symbol table also includes the type and the name of the segment in which the identifier is defined. The second pass then accesses this information when assembling instructions whose operands include these identifiers.
For example, while constructing the machine code for the instruction
MOV CX,COUNT
The assembler also includes two tables, known as permanent symbol tables.
In addition to assembling the machine instructions, the second pass must insert the preassigned constants that occur in the data definition statements and prepare the other information that will be required by the linker.
This is page 51.