## CS 431 (Spring 2002)

Lab 5: Getting to know your target instruction set
Lab Assigned Lab Due
(Start of class)
19 Mar 4 Apr

Abstract: You will write a simple program in Java assembler language.

Preliminaries:

• As before, set things up by performing the following steps:
1. Create a new directory for your work: mkdir hw5
2. Change into that directory: cd hw5
3. Set things up by typing
make -f ~cs431/hw5/Makefile Setup
• You will find all the files you need for this project linked in your hw5 directory:
 fib3.j The beginning of a Jasmin program for generating the first 30 Fibonnaci-3 numbers. The program as given produces a count from 1 to 10
• The following will be useful as you develop your solution:
 make Brings your work up-to-date by compiling modified files, including the jasmin file fib3.j. java fib3 Runs the Fibonnaci-3 program cd ~cs431/hw5/Solved followed by the above commands Runs my solution for you
• Be certain only to modify the file fib3.j.
• Complete the Jasmin file fib3.j so that it prints out the first 30 Fibonnaci-3 numbers. You might base your solution on the following iterative pseudocode program (from Discrete Mathematics and its Applications, by Kenneth H. Rosen):
```procedure iterative fib3(n: nonnegative integer) {
if      n = 0 then y := 0
else if n = 1 then y := 1
else {
w := 0
x := 1
y := 1
for i := 2 to n-1 {
/* Here, y is the ith Fibonacci-3 number */
z := w + x + y
w := x
x := y
y := z
/* Here, y is the (i+1)th Fibonacci-3 number */
}
}
/* Here, y is the nth Fibonacci-3 number */
}
```
• To assist you with the Jasmin part, there is on-line documentation at http://mrl.nyu.edu/meyer/jvm/jasmin.html. A quick guide to the Java VM instruction set can be found at http://www.mrl.nyu.edu/meyer/jvmref/.
• To turn in your work, use:
 mail -s 'homework 5b lastname_firstname' cs431@cec < fib3.j
Do not submit by any other method.