CPSC 213: Assignment 6

Due Mon 29 October 2012, 6pm

Goal

The goal of this assignment is to explore the use of indirect jumps for the implementation of switch statements and polymorphic dispatch. You will read 4 examples, and implement as well as decompile code that uses these constructs.

Provided Code

Download the example code snippets for this assignment and carefully inspect them, comparing the HLL (.c and .java) versions with the SM213 Assembly (.s) version. They contain examples of the types of statements you will be expected to be able to translate to and from SM213 assembly language: everything from the previous assignment, plus switch() and polymorphic objects. Using the reference simulator, step through and convince yourself of the correspondence between the high-level expression and the instructions the machine executes. In particular, experiment with supplying different values to the switch statement and modifying the function pointers in the method table.

Your Task

Download the code snippets to work on and carefully inspect them. Your task for this assignment is to produce commented SM213 Assembly versions for the first two code snippets, produce a C version of the third, and produce both C and Java versions of the fourth. When writing your solutions, refer to the provided examples and keep in mind the following points:

Provided Materials

Handing In

Use the handin program. The assignment directory is a6. Please hand in exactly and only the following files with the specified names.

  1. README.txt that contains
  2. a6_1.s containing your solution to a6_1.c
  3. a6_2.s containing your solution to a6_2.c/a6_2.java
  4. a6_3.c containing your solution to a6_3.s
  5. a6_4.c containing your C solution to a6_4.s
  6. a6_4.java containing your Java solution to a6_4.s

File Format Requirements

Refer to the section of the same name in the second assignment for the file format requirements. All files you handin MUST be plain ASCII text, and all SM213 code MUST load in the simulator in order to receive credit for it.


Last modified 2012-10-22 07:09