Second pass

During the second pass, the assembler examines the operands for symbolic references to storage locations and resolves these symbolic references using information in the symbol table.

On the second pass, the assembler:

  • Examines the operands for symbolic references to storage locations and resolves these symbolic references using information in the symbol table.
  • Ensures that no instructions contain an invalid instruction form.
  • Translates source statements into machine code and constants, thus filling the allocated space with object code.
  • Produces a file containing error messages, if any have occurred.

At the beginning of the second pass, the assembler scans each source statement a second time. As the assembler translates each instruction, it increments the value contained in the location counter.

If a particular symbol appears in the source code, but is not found in the symbol table, then the symbol was never defined. That is, the assembler did not encounter the symbol in the label field of any of the statements scanned during the first pass, or the symbol was never the subject of a .comm, .csect, .lcomm, .sect, or .set pseudo-op.

This could be either a deliberate external reference or a programmer error, such as misspelling a symbol name. The assembler indicates an error. All external references must appear in a .extern or .globl statement.

The assembler logs errors such as incorrect data alignment. However, many alignment problems are indicated by statements that do not halt assembly. The -w flag must be used to display these warning messages.

After the programmer corrects assembly errors, the program is ready to be linked.

Note: If only warnings are generated in the first pass, the assembly process continues to the second pass. The assembler listing contains errors and warnings generated during the second pass of the assembler. Any warnings generated in the first pass do not appear in the assembler listing.