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
00
               ORG     10
010
   NUM         DB      -29
101
   ARRAY       DB      100 DUP(?)
11100
   COUNT       DW      5
1112
   MASKS       DB      82H,04H,2AH
1133
               .
116.
               .
..
               .
..

For the above segments, the first pass of the assembler uses the location counter to enter

SymbolOffsetSegment in which
it was Defined
Type
DATA_SEG00HSegment
NUM0AHDATA_SEGByte Variable
ARRAY0BHDATA_SEGByte Variable
COUNT6FHDATA_SEGWord Variable
MASKS71HDATA_SEGByte Variable
  .
  .
  .
CODE_SEG00HSegment
START00HCODE_SEGNear Label
REPEAT09HCODE_SEGNear Label
into the symbol table.

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 would check if the source type matches with the destination type and if COUNT is accessible through DS. Then, the assembler would note that the offset for COUNT is 006F (=11110) and would produce the machine instruction

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.


Table of Contents | Next page | Previous page

This is page 51.