Analysis & Synthesis Phases
- So, The primary function performed by the analysis phase is the building of the symbol table.
- For this purpose, it must determine an address of the symbolic name.
- Moreover, It is possible to determine some address directly, however, others must be inferred. And this function is called memory allocation.
- so, To implement memory allocation a data structure called location counter (LC) is used, it is initialized to the constant specified in the START statement.
- We refer the processing involved in maintaining the location counter as LC processing.
Tasks of Analysis phase [ Analysis & Synthesis Phases ]
1. Isolate the label, mnemonics opcode, and operand fields of a constant.
2. If a label is present, enter the pair (symbol, <LC content>) in a new entry of symbol table.
3. Also, Check validity of mnemonics opcode.
4. Perform LC processing.
Synthesis Phase [ Analysis & Synthesis Phases ]
- So, Consider the assembly statement,
MOVER BREG, ONE
- We must have following information to synthesize the machine instruction corresponding to this statement:
1. Address of name ONE
2. Machine operation code corresponding to mnemonics MOVER.
- The first item of information depends on the source program; hence it must be available by analysis phase.
- moreover, The second item of information does not depend on the source program; it depends on the assembly language.
- So, Based on above discussion, we consider the use of two data structure during synthesis phase:
1. Symbol table:
So, Each entry in symbol table has two primary field- name and address. This table is
built by analysis phase
2. Mnemonics table:
Also, An entry in mnemonics table has two primary field- mnemonics and opcode.
Tasks of Synthesis phase [ Analysis & Synthesis Phases ]
1. Obtain machine opcode through a look up in the mnemonics table.
2.Also, Obtain address of memory operand from the symbol table.
3. Synthesize a machine instruction.