0% found this document useful (0 votes)
23 views3 pages

SPOS Lab Assignment-02

The document outlines an assignment for implementing Pass-II of a two-pass assembler in Java, utilizing object-oriented features. It details the objectives, required software and hardware, and the algorithm for Pass-II, including data structures like OPTAB, SYMTAB, and LITTAB. Additionally, it discusses error reporting strategies in both Pass-I and Pass-II, along with a set of FAQs related to assembler directives and data structures.

Uploaded by

snehagawande29
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)
23 views3 pages

SPOS Lab Assignment-02

The document outlines an assignment for implementing Pass-II of a two-pass assembler in Java, utilizing object-oriented features. It details the objectives, required software and hardware, and the algorithm for Pass-II, including data structures like OPTAB, SYMTAB, and LITTAB. Additionally, it discusses error reporting strategies in both Pass-I and Pass-II, along with a set of FAQs related to assembler directives and data structures.

Uploaded by

snehagawande29
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/ 3

Lab Manual –Laboratory Practice – I (SPOS Lab) Dept.

of Computer Engineering

ASSIGNMENT NO.02

TITLE: IMPLEMENTATION OF PASS – II OF TWO PASS ASSEMBLER

PROBLEM STATEMENT: Implement Pass-II of two pass assembler for pseudo-machine in


Java using object oriented features. The output of assignment-1 (intermediate file and symbol
table) should be input for this assignment.

OBJECTIVES:
• To study basic translation process of intermediate code to machine language.
• To study and implement pass II of two pass assembler

SOFTWARE & HARDWARE REQUIREMENTS:


1. 64-bit Open source Linux or its derivative
2. Eclipse
3. JDK

THEORY:
Data Structure used by Pass II:
1. OPTAB: A table of mnemonic opcodes and related information.
2. SYMTAB: The symbol table
3. LITTAB: A table of literals used in the program
4. Intermediate code generated by Pass I
5. Output files containing Target code / error listing.

Pass – II of Two Pass Assembler Algorithm

• LC : Location Counter
• littab_ptr : Points to an entry in LITTAB
• Pooltab_ptr : Points to an entry in POOLTAB
• machine_code_buffer : Area for construction code for one statement
• code_area : Area for assembling the target program
• code_area_address : Contains address of code_area

1. code_area_address := address of code_area;


pooltab_ptr := 1;
LC := 0;
2. While the next statement is not an END statement
(a) Clear machine_code_buffer;
(b) If an LTORG statement
International Institute of Information Technology, Hinjawadi, Pune. Page 1
Lab Manual –Laboratory Practice – I (SPOS Lab) Dept. of Computer Engineering

(i) If POOLTAB[pooltab_ptr].#literal > 0 then


Process literals in the entries LITTAB[POOLTAB[pool_ptr].
first … LITTAB[POOLTAB[pool_ptr+1]-1] similar to
processing of constants in a DC statement. It results in
assembling 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
(i) LC := 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 the memory area required by the declaration
statement;
(e) If an Imperative statement
(i) Get address of the operand from its entry in SYMTAB or LITTAB,
(ii) Assemble the instruction in machine_code_buffer.
(iii) size := size of the instruction;
(f) If size ≠ 0 then
(i) Move contents of machine_code_buffer to memory word with the address
code_area_address + <LC>;
(ii) LC := LC + size;
3. Processing of END statement
(a) Perform actions (i) – (iii) of Step 2(b)
(b) Perform actions (i) – (ii) of Step 2(f)
(c) Write code_area into the output file.

Error Reporting
Error reporting is an important parameter in assembler. The basic decision is to report error in
Pass – I or delay it until Pass- II. The advantage of producing error listing in Pass –I is that, the
source program need not be preserved till Pass – II.
This conserves memory and avoids some amount of duplicate processing. An error listing
produced in Pass – I can only report certain errors in most relevant place i.e. against the source
statement itself.
Error Reporting in Pass – I
Following types of errors can be reported in Pass – I
• Syntax errors like missing commas and parenthesis.
• Semantic errors like duplicate definitions of symbols.
• Other errors like references to undefined variables can only be reported at the end of the
source program.
Error Reporting in Pass – II

International Institute of Information Technology, Hinjawadi, Pune. Page 2


Lab Manual –Laboratory Practice – I (SPOS Lab) Dept. of Computer Engineering

In Pass – II target code is printed. Target code to source statement is difficult to locate and
reverse also. All these problems makes debugging task difficult. Delaying the error reporting
till Pass – II is possible. It necessarily reports all errors against the erroneous statement itself.
The errors in the statement and the target code if any, that corresponds to it can be printed
against the source statement itself.

CONCLUSION:

FAQs

1. Define Assembler directives.


2. How is literal table useful?
3. What does an assembler perform when it encounters LTORG assembler directive?
4. What is a common use of ORG?
5. Which data structures are used in assembler pass II?
6. What are the formats of literal table, pool table, symbol table used in assembler?

International Institute of Information Technology, Hinjawadi, Pune. Page 3

You might also like