Page 71 - DCAP507_SYSTEM_SOFTWARE
P. 71
Unit 4: Design of Assembler
significant function. The major sections of pass 1 and pass 2 are dedicated to the particular Notes
processing required for the various pseudo-operations. For ease, only a few major pseudos are
openly indicated in the flowchart; the others are processed in a uncomplicated way. We now
consider what must be performed to process a pseudo op. Pass 1 is only regarded with pseudo-
ops that define symbols (labels) or affect the location counter.
In the case of the EQU pseudo-op during pass 1, we are related only with defining the symbol in
the label field. This needs evaluating the expression in the operand field. (The symbols in the
operand field of an EQU statement must have been defined before.) The SKS and NUM pseudo
ops can affect both the location counter and the definition of symbols in pass 1.
!
Caution The operand field must be scrutinized to find out the number of bytes/words of
storage needed.
Because of requirements for certain alignment conditions (e.g., full words must begin on a byte
whose address is a multiple of two), it may be essential to adjust the location counter before
defining the symbol. When the END pseudo-op is encountered, pass 1 is finished. Before
transferring control to pass 2, there are different "housekeeping" operations that must be done.
These include allocating locations to literals that have been collected during pass 1, a process
that is very similar to that for the NUM/CHC pseudo op. Lastly, conditions are re-initialized for
processing by pass 2.
Pass 1
Read source file line by line
Save it in enlarged intermediate file (required for pass 2 report), validate it if symbol check
symbol table
Is it already present?
==> yes==> set error code
==>no==> enter into table
enter LC in HEX into table
Check instruction
does it consume memory
==> yes==> update LC
Check Pseudo-op
Label? ==> place in symbol table if not already entered
Consume memory? ==> yes==> update LC
Process as needed
if END finish up pass 1 check for more records (error)
start pass 2
Check syntax of operand field
save source line (with added information) for pass 2
appended with LC, op-code, r, s, x, error codes
LOVELY PROFESSIONAL UNIVERSITY 65