0% found this document useful (0 votes)
12 views7 pages

Group - A Experiment No: 02: 1. Title

The document outlines the design and implementation of Pass-II of a two-pass assembler for a pseudo-machine using Java. It details objectives, outcomes, software and hardware requirements, and the theoretical concepts of assembly language, including data structures and assembler directives. The assignment aims to enable students to implement various tables and understand advanced assembler directives through practical coding experience.

Uploaded by

vijayasukhatme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Group - A Experiment No: 02: 1. Title

The document outlines the design and implementation of Pass-II of a two-pass assembler for a pseudo-machine using Java. It details objectives, outcomes, software and hardware requirements, and the theoretical concepts of assembly language, including data structures and assembler directives. The assignment aims to enable students to implement various tables and understand advanced assembler directives through practical coding experience.

Uploaded by

vijayasukhatme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

GROUP - A

EXPERIMENT NO : 02

1. Title:
Design suitable Data structures and implement Pass-II of a two-pass assembler for
pseudo-machine. Implementation should consist of a few instructions from each category and
few assembler directives.
2. Objectives :
- To understand Data structure of Pass-1 assembler
- To understand Pass-1 assembler concept
- To understand Advanced Assembler Directives

3. Problem Statement :
Design suitable data structures and implement Pass-II of a two-pass assembler for
pseudo-machine in Java using object oriented features.

4. Outcomes:
After completion of this assignment students will be able to:
- Implemented Symbol table, Literal table & Pool table, Intermediate Code, Machine code
- Understood concept Advanced Assembler Directive.

5. Software Requirements:
Latest jdk, Eclipse

6. Hardware Requirement:
- M/C Lenovo Thinkcentre M700 Ci3,6100,6th Gen. H81, 4GB RAM ,500GB HDD

7. Theory Concepts:

Introduction :-
There are two main classes of programming languages: high level (e.g., C, Pascal) and low
level. Assembly Language is a low level programming language. Programmers code symbolic
instructions, each of which generates machine instructions.
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.
Figure 1. Executable program generation from an assembly source code

Advantages of coding in assembly language are:


● Provides more control over handling particular hardware components
● May generate smaller, more compact executable modules
● Often results in faster execution

Disadvantages:
● Not portable
● More complex
● Requires understanding of hardware details (interfaces)

Pass – 2 Assembler:

A two-pass assembler performs two sequential scans over the source code:
Pass 1: symbols and literals are defined
Pass 2: object program is generated
Parsing: moving in program lines to pull out op-codes and operands

Data Structures:
- Location counter (LC): points to the next location where the code will be placed
- Op-code translation table: contains symbolic instructions, their lengths and their op-codes (or
subroutine to use for translation)
- Symbol table (ST): contains labels and their values
- String storage buffer (SSB): contains ASCII characters for the strings
- Forward references table (FRT): contains pointer to the string in SSB and offset where its value
will be inserted in the object code

Elements of Assembly Language :


● Mnemonic Operation Codes
● Symbolic Operands
● Data declarations
● Instruction Format

Assembly Language Statements :

Three Kinds of Statements


1. Imperative Statements
2. Declaration Statements
3. Assembler Directives

Pass Structure of Assembler :


One complete scan of the source program is known as a pass of a Language Processor.
Two types 1) Single Pass Assembler 2) Two Pass Assembler.

Single Pass Assembler :

First type to be developed Most Primitive Source code is processed only once. The operand field
of an instruction containing forward reference is left blank initially

Eg) MOVER BREG,ONE

Can be only partially synthesized since ONE is a forward reference.


During the scan of the source program, all the symbols will be stored in a table called
SYMBOL TABLE. Symbol table consists of two important fields, they are symbol name and
address.
All the statements describing forward references will be stored in a table called Table of
Incompleted Instructions (TII)
TII (Table of Incomplete instructions)

Instruction Address Symbol


101 ONE

By the time the END statement is processed the symbol table would contain the address of all
symbols defined in the source program.
Two Pass Assembler :
Can handle forward reference problems easily.

First Phase : (Analysis)


Symbols are entered in the table called Symbol table
Mnemonics and the corresponding opcodes are stored in a table called Mnemonic table
LC Processing

Second Phase : (Synthesis)


Synthesis the target form using the address information found in the Symbol table.
First pass constructs an Intermediated Representation (IR) of the source program for use by
the second pass.

Data Structure used during Synthesis Phase :


1. Symbol table
2. Mnemonics table

Processed form of the source program called Intermediate Code (IC)


ADVANCED ASSEMBLER DIRECTIVES
1. ORIGIN
2. EQU
3. LTROG

Algorithms :
Algorithm of Pass-II Assembler:

1.code_area_address := address of code_area;


Pooltab_ptr :=1;
Loc_cntr:=0;
2.While next statement is not an END statement
a)Clear machine_code_buffer;
b)If an LTORG statement
i.Process literals in LITTAB[POOLTAB[pooltab_ptr]]…LITTAB[POOLTAB[pooltab_ptr+1]]-1
similar to processing of constants in a DC statement i.e. assemble the literals in
machine_code_buffer.
ii.size := size of memory area required for literals;
iii.pooltab_ptr:= pooltab_ptr +1;
c)If a START or ORIGIN statement then
i.loc_cntr := value specified in operand field;
ii.size:=0;
d)If a declaration statement
i.If a DC statement then
Assemble the constant in machine_code_buffer.
ii.size: = size of memory area required by DC/DS;
e)If an imperative statement
i.Get operand address from SYMTAB or LITTAB.
ii.Assemble instruction in machine_code_buffer.
iii.size: = size of instruction;
f)if size not equal to 0 then
i.Move contents of Machine_code_buffer to the address code_area_address + loc_cntr;
ii.loc_cntr := loc_cntr + size;
3.(Processing of END statement)
a)Perform steps 2(b) and 2(f).
b)Write code_area into the output file.

Flowchart :
8. Conclusion :
Thus , We have implemented Pass-2 assembler with symbol table, literal table and pool
table, Intermediate code and Machine code.

Continuous Assessment of Student :

You might also like