presentation on design of a 2 pass assembler, and variant I and variant II in the subject of systems programming. especially helpful to GTU students, CSE and IT engineers
2. DESIGN OF 2 PASS ASSEMBLER
• Tasks performed by the passes of a two pass
assembler are:
• Pass 1:
• Separate the symbol, mnemonic opcode and operand fields
• Build the symbol table
• Perform LC processing
• Construct intermediate representation
• Pass 2:
• Synthesize the target program
3. DESIGN OF 2 PASS ASSEMBLER
•Pass 1 uses the given data structures:
• OPTAB - table of mnemonic opcodes, class (IS,DL,AD)
and mnemonic info
• SYMTAB - symbol table
• LITTAB - table of literals used in the program
• POOLTAB - table of information concerning literal
pools
8. INTERMEDIATE CODE FORMS
• IC Consists of a sequence of IC units having 3 fields :
• Variant forms of intermediate codes, specifically the
operand and address fields are used. Information in
mnemonic code field has the same representation in
all variants.
9. VARIANT 1
• First operand is represented by a single digit number
which is either code used for register or condition
code itself.
• Second operand is a memory operand represented by
a pair of the form (operand class, code) where
operand class is C,S or L(constant, symbol or literal).
10. Note that for variant 1, 2 kinds of entries exist in the
symbol table at any time: (for defined symbol) and (for
forward references) i.e. We need to enter A in the symbol
table, suppose at entry number 'n', but at this point
address and length fields of A are not known.
11. VARIANT 2
• It differs from variant one because here the operand
field of intermediate code maybe in the processed
form or in the source form itself. For an AD/DL,
operand has to be in the processes form to support LC
processing.
• Symbolic references in the operand field of
intermediate statements are put in the source form
itself.