Download Assemblers and Loaders

Transcript
5. The Listing File
The listing file is the second output of the assembler. It is generated in pass 2,
and is eventually printed. To be useful, such a file should include, for each source
line, a copy of the source (including comments) and the object codes, the value of
the LC for the instruction, and any error messages pertaining to the line.
In addition, the listing may, optionally, contain a cross reference table of all the
symbols used in the program. This is a list of all symbols, sorted alphabetically by
symbol name, with their values and attributes and, for each symbol, the LC values
of all the instructions using it. If a symbol is used a lot in the program, the cross
reference for it may require more than one line of print. The cross reference can be
an invaluable debugging tool and is generated by many assemblers. It contains all
the information in the symbol table and more.
It has already been mentioned, in chapter 1, that a one-pass assembler cannot
print the values of future symbols in the listing. Thus, for this type of assembler,
the cross reference table is certainly important.
To implement the cross reference table, another column is added to the symbol
table, with a pointer to a linked list. Each node in this list contains the LC value for
an instruction using that symbol. The lists are built in pass 2, while instructions are
assembled. Each time an instruction uses a symbol, the symbol table is searched.
On locating the symbol, its value is used in assembling the instruction, and another
node is added to the list of that symbol.