Single Pass Assembler,Details of Single pass assembler,why it is used & program of single pass assembler
Size: 730.89 KB
Language: en
Added: Oct 10, 2014
Slides: 16 pages
Slide Content
Seminar on “Single pass Assemblers” Walchand Institute Of Technology
Assembler Overview Translate assembly language programs to object programs or machine code is called an Assembler.
Assemblers An assembler is a program that accepts as input an assembly language program (source) and produces its machine language equivalent (object code) along with the information for the loader . Assembler Object Code Loader Executable Code Linker Fig. : Role of Assemblers
An assembler does the following: Generate machine instructions evaluate the mnemonics to produce their machine code evaluate the symbols, literals, addresses to produce their equivalent machine addresses convert the data constants into their machine representations
One Pass Assemblers One-pass assemblers are used when it is necessary or desirable to avoid a second pass over the source program the external storage for the intermediate file between two passes is slow or is inconvenient to use Main problem Forward references Data items Labels on instructions
Forward reference For any symbol that has not yet been defined 1. omit the address translation 2. insert the symbol into SYMTAB , and mark this symbol undefined 3. the address that refers to the undefined symbol is added to a list of forward references associated with the symbol table entry 4. when the definition for a symbol is encountered, the proper address for the symbol is then inserted into any instructions previous generated according to the forward reference list
Solutions for one pass assembler Two methods can be used: Eliminating forward references: Either all labels used in forward references are defined in the source program before they are referenced, or forward references to data items are prohibited. Generating the object code in memory: No object program is written out and no loader is needed. The program needs to be re-assembled every time.
ALGORITHM STEP 1 : Start the program execution. STEP 2 : Assembler simply generate object code as it scans the source code. STEP 3 : If the instruction operand is a symbol text, has not yet been defined, the operands address is omitted. STEP 4 : When nearly half the program translation is over, some of the forward reference problem are existed. STEP 5 : Combine the process to the end of the program to fill forward reference property. STEP 6 : At the end of the program, the symbol table entries with ‘x’ are undefined. STEP 7 : Stop the program execution.
To write a C program to implement single pass assembler. Input Enter your assembly instructions lda 5000 sub z sta 9988 hlt *