Single pass assembler

25,244 views 10 slides Jun 27, 2018
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

System Programming


Slide Content

NAME: BANSARI SHAH ENROLLMENT: 150410107098 CLASS: CE-2 BATCH: B SUBJECT: SP Single pass assembler

Assembler 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

Types of assembler: Single pass assembler Two pass assembler

Single pass assembler A single pass assembler scans the program only once and creates the equivalent binary program. The assembler substitute all of the symbolic instruction with machine code in one pass

Single Pass Assemblers Single 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 problem Rules for an assembly program states that the symbol should be defined somewhere in the program. But in some cases a symbol may be used prior to its definition. Such a reference is called forward reference. Due to this assembler cannot assemble the instructions and such a problem is called forward reference. c=a + b; int a; int b; int c;

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.

Thank you…
Tags