Princeton University
COS 217: Introduction to Programming Systems
Assignment 5: SPARC Assembler
Purpose
The purpose of this assignment is to help you understand the assembly process.
You will learn how to solve various problems faced by an assembler, details
of the SPARC assembly and machine languages, details of the ELF object
file format, and how to manipulate complex data structures.
Background
A SPARC assembler is a macro processor specialized for translating SPARC
assembly language programs into machine language programs. It makes two
passes: the first determines all the symbol definitions; the second applies
those definitions and the translation of symbolic text into binary instructions
and data.
Your Task
Your task in this assignment is to use the C language to create your own
version of a two-pass SPARC assembler. Specifically, you should create
two major functions: pass1() and pass2(). You will be
given an input() function that parses the assembly language source
program and generates a linked list of instructions. Your pass1()
function then walks this list to construct a symbol table. Your pass2()
function uses the symbol table to re-walk the instruction list, this time
producing object code and relocation information. You will also be given
an output() function that tweaks the object code produced by pass2()
to produce a standard ELF object file that can be executed.
Resources
Please read Assignment 5 Programming Reference Manual
and Assignment 5 Testing Programs before
you start. They can be of great help.
For complete official documents about SPARC assembler, please refer
to
Submission
As always, submit your solution electronically on arizona using
% /u/cs217/bin/submit 5 files
where files include:
-
Makefile which derives from the provided
incomplete version
-
pass1.c which contains pass1()
and other necessary internal functions
-
pass2.c which contains pass2()
and other necessary internal functions
-
any other source files you create
Leave the provided source files intact, and do not
submit them.
Grading
We will grade your work on correctness, efficiency and understandability.
Correctness means that you pass Assignment
5 Testing Programs . Efficiency means that you use reasonable approach.
Understandability means that your program is easy to follow.