Single Pass Assembler Intel x86
- So, The algorithm for the Intel 8088 assembler is given at the end of this section.
LC processing in this algorithm differs from LC processing in the first pass of a two-pass
assembler in one significant respect.
- Similarly, In Intel 8088, the unit for memory allocation is a byte; however, certain entities require
their first byte to be aligned on specific boundaries in the address space.
- Also, While processing declarations and imperative statements, the assembler first aligns the address contained in the LC on the appropriate boundary. We call this action LC alignment.
- So, Allocation of memory for a statement is performed after LC alignment.
- The data structures of the assembler are as follows:
Mnemonics Table (MOT)
- Additionally, The mnemonics table (MOT) is hash organized and contains the following fields: mnemonic opcode, machine opcode, alignment/format info and routine id. The routine id field of an entry specifies the routine which handles that opcode. Moreover, Alignment/format info is specific to a given routine. Mnemonic opcodeMachine opcodeAlignment/format routine id (4)
Symbol Table (Symtab)
- Similarly, The symbol table (SYMTAB) hash-organized and contains information about symbols defined and used in the source program. The contents of some important fields are as follows: The owner segment field indicates the id of the segment in which the symbol defined. It contains the SYMTAB entry # of the segment name. Also, For a non-EQU symbol the type field indicates the alignment information. For an EQU symbol, the type field indicates whether the symbol to given a numeric value or a textual value. And also, the value itself is accommodated in the owner segment and offset fields of the entry.
Segment Register Table (SRTAB)
- Moreover, The segment register table (SRTAB) contains four entries, one for each segment register. Each entry shows the SYMTAB entry # of the segment whose address contained in the segment register. So, SRTAB_ARRAY is an array of SRTABs. Segment Register (1)SYMTAB entry # (2)
Forward Reference Table (FRT)
- So, Information concerning forward references to a symbol organized as a linked list. Thus, the forward reference table (FRT) contains a set of linked lists, one for each forward referenced symbol. Also, Pointer (2)SRTAB # (1)InstructionUsage Code (1) Source stmt # address (2)(2)
Cross Reference Table (CRT)
- So, A cross-reference directory a report produced by the assembler which lists all references to a symbol sorted in the ascending order by statement numbers. Moreover, The assembler uses the cross-reference table (CRT) to collect the relevant information. Pointer (2)Source stmt # (2)
Algorithm of the Single-Pass Assembler
Important data structures used by the Single-Pass Assembler:
SYMTAB, SRTAB_ARRAY, CRT, FRT, and ERRTAB
LC: Location Counter
code_area: Area for assembling the target program
code_area_address:Contains address of code_area
srtab_no: Number of the current SRTAB
stmt_no: Number of the current statement
SYMTAB_segment_entry:SYMTAB entry # of current segment
machine_code_buffer: Area of constructing code for one statement