Data Structures: OPTAB, SYMTAB, LITTAB & POOL TUB
- A table of mnemonics opcode and related information
- OPTAB contains the field mnemonics opcodes, class and mnemonics info.
- The class field indicates whether the opcode belongs to an imperative statement (IS), a declaration statement (DS), or an assembler directive (AD).
- If an imperative, the mnemonics info field contains the pair (machine code, instruction length), else it contains the id of a routine to handle the declaration or directive statement.
- An SYMTAB entry contains the symbol name, field address, and length.
- Some address can be determining directly, e.g. the address of the first instruction in the
program, however, other must be inferred.
- Moreover, To find an address of other we must fix the addresses of all program elements preceding it. This function called memory allocation.
- A table of literals used in the program.
- A LITTAB entry contains the field literal and address.
- So, The first pass uses LITTAB to collect all literals used in a program.
- Awareness of different literal pools maintained using the auxiliary table POOLTAB.
- This table contains the literal number of the starting literal of each literal pool.
- Moreover, At any stage, the current literal pool is the last pool in the LITTAB.
- Also, On encountering an LTORG statement (or the END statement), literals in the current pool are allocated addresses starting with the current value in LC and LC is appropriately incremented.