Design of single and two pass assembler.
Simple Assembly Scheme
a) Steps required to design an Assembler :-
1) Find out information necessary to perform a task
2) Specify different data structures and its format.
Assembler uses fixed data structure i.e. mnemonic opcode table. Assembler directive table, register table and declarative table and it will generate symbol (SYMTAB ) table and opcode table ( OPTAB )
The different task performed by analysis phases are as follows :-
A) Analysis Phase :-
1) Isolate the label, mnemonic opcode and operand fields of a statement.
2) If a label is present , enter the pair ( symbol, < LC contents > ) in a new entry of symbol table.
3) Check validity of the mnemonic opcode through a look up in the Mnemonic table.
4) Preform LC Processing, i.e update the value contained in LC by considering the opcode and operands of the statement.
B) Synthesis Phase :-
1) Obtain the machine opcode corresponding to the mnemonic form the mnemonic table.
2) Obtain address of a memory operand from the symbol table.
3) Synthesize a machine instruction or the machine form of a constant
Design of a two pass assembler
Q. Explain how to design pass one of two pass assembler ? --- (6 m)
Ans :- Pass 1 of assembler uses mnemonic opcode table, register table, assembler directive table and Declarative Statement table. After processing input will go through lexical analysis, syntax analysis and semantic analysis and it will generate symbol table, operation table, literal table and pool table ( SYMTAB , OPTAB , LITTAB, POOLTAB )
Symbol Table ( SYMTAB ) :- Each entry in symbol table has two primary fields name and address. The symbol table uses concept of forward reference to achieve address of symbols.
OPTAB :- Each entry in operation table contains fields like mnemonic , class and mnemonic info. The class field many contain . IS ( Imperative Statements ), AD ( Assembler Directives ) or DL ( Declarative Statements )
Literal Table ) LITTAB ) :- Literal table contains all literals and address of all literals. For literals
LTORG directives places the all constants at consecutive memory locations. If we are not using LTORG then all literals are placed after END in memory
Pool Table ( POOLTAB ) :- Awareness of different literal pools is maintained using the auxiliary table POOLTAB. At any Stage , the current literal pool is the last pool in LITTAB.
Q. Write down machine code for following program. As well as write contents of SYMTAB, OPTAB, LITTAB and POOLTAB
START 100 LC Machine Instruction
MOVER CREG, = ‘1’ 100 + 04 3 106
MOVEM AREG, C 101 + 05 1 110
MOVER AREG, I 102 + 04 1 110
MOVER BREG, A 103 + 04 2 111
ADD CREG , = ‘2’ 104 + 01 3 107
BC ANY , AGIN 105 + 07 6 108
= ‘1’ 106 + 00 0 001
=’2’ 107 + 00 0 002
AGIN : SUB AREG, = ‘3’ 108 + 02 1 112
STOP 109 + 00 0 000
C DS 1 ‘ 110
A DS 1’ 111
= ‘3’ 112 + 00 0 003
Q. Write down machine code for following assembly program as well as write as write contents of SYMTAB, LITTAB and POOLTAB.
- WikiNote Foundation