08-08-2012, 10:18 AM
IMPLEMENTING A TWO PASS ASSEMBLER FOR THE WORKING MODEL OF 8086 MICROPROCESSOR
IMPLEMENTING A TWO PASS ASSEMBLER.doc (Size: 226.5 KB / Downloads: 93)
SYNOPSIS
AIM : Pass-2 Assembler for the working model of 8086
This is a 2-pass Assembler for the working model of 8086 that supports 32 mnemonic instructions.
Pass-1 is used to check and validate the syntax of the operation codes in the input source program. It outputs an intermediate file containing the processed information that will be input to pass-2. In this pass the OPTAB is used to look up and validate the operation codes into the source program. During pass-1 of the Assembler, labels are entered into the SYMTAB as they are encountered in the source program, along with their assigned addresses.
Pass-2 is used to generate the machine code equivalent of the mnemonic instructions that were processed in Pass-1 from the input source file. Pass-2 takes the intermediate file generated by Pass-1 as its input and generates Assembly listing file. Here the OPTAB is used to translate the operation codes to machine language. In this Pass, symbols used as operands are looked up from SYMTAB to obtain the addresses to be inserted in the assembled instructions.
Introduction
An assembler is system software which converts given assembly language to corresponding machine language.
An Assembler so designed will accept only instructions and not assembler directives ,to provide corresponding machine code.
An assembly language is of fixed format and not machine dependent where as machine language is dependent of a given machine.
There are different types of assemblers
One-pass assembler
Two-pass assembler
Multi-pass assembler
Due to the simplicity of the data structures and construction, we use 2-pass assembler. The general description of 2-pass assembler is as follows
A two pass assembler scans the source code twice during first pass all symbols defined in the code are stored in a symbol table and memory is allocated for the instruction, during second pass the machine codes are loaded into the memory allocated for each instruction.
Description :
The task performed by the assembler is as follows:
The assembler should take care of assembler directives written in fixed formats of the given assembly language.
The assembler also should tackle some of the instruction specified by the grammar of the assembly language.
It should also be able to recognize different addressing modes and operands corresponding to it.
Phases of a two pass assembler are as follows:-
Pass-1
This is the first phase of the assembly where key task of preparing symbol table and op-table is done.
The other jobs performed by pass one are as follows :
Keeping track of location counter.
Determining the length of data and updating location counter.
Checking for multiple symbol definition.
Processing assembler directives
Pass-2
This is the second phase where the object code corresponding to assembly code is generated.
It makes use of symbol reference created in the first pass.
During second pass the assembler scans each line of the source program.
When ever an instruction in machine language is to be created it makes use of contents of location counter.