Page 70 - DCAP507_SYSTEM_SOFTWARE
P. 70
System Software
Notes For every instruction in pass 2, we generate the equivalent machine language instruction as
shown below:
1. Find value of SETUP in symbol table (which is 2)
2. Find value of op-code in machine op table binary op code for LOAD
3. Formulate address
4. Assemble output code in suitable formula.
Likewise, we produce instructions for the remaining code as displayed below:
4.1.5 Algorithm
Pass 1: Define Symbols
The reason of the first pass is to allocate a location to every instruction and data defining pseudo-
instruction, and thus to define addresses/values for symbols occurring in the label fields of the
source program. Primarily, the Location Counter is set to the first location in the program
(relative address 0). Then a source statement is read. The operation-code field is scrutinized to
find out if it is a directive pseudo-op; if it is not, the table of machine op-codes is investigated to
discover a match for the source statement's opcode field. The matched entry states the length of
the instruction. The operand field is scanned for the occurrence of a literal. If a new literal is
found, it is entered into the Literal Table for afterward processing. The label field of the source
statement is then inspected for the presence of a symbol. If there is a label, the symbol is saved
in the Symbol Table along with the existing value of the location counter. Lastly, the current
value of the location counter is incremented by the length of the instruction and a replica of the
source record is saved for use by pass 2. The above sequence is then repeated for the next
instruction. The loop depicted is physically a small portion of pass I although it is the most
64 LOVELY PROFESSIONAL UNIVERSITY