CS 110 Intro to Computer Systems
Fibonacci Project - Version .98
15 Points
Due 2 November, 9pm


Write two assembly language programs, each with different subprograms that both compute the Fibonacci function.
    F(n) = 0                  if n = 0
    F(n) = 1                  if n = 1
    F(n) = F(n-1)+ F(n-2)     otherwise

    undefined if n < 0

The first program/subprogram is to be recursive, following the above definition exactly. The second is to be iterative, avoiding recursion entirely by using a loop.
For each subprogram, determine the size of the stack frame and identify the purpose of each word in the frame. Note: depending on your implementation, this may be nothing more than room for the registers, etc. You can determine this information by comparing the sp and fp and using bt of gdb. Use script to capture the execution.

This is an exploratory exercise. You will have to go through many cycles of gdb as you learn how subprograms actually execute.

Do not pass parameters in the Global registers.

Due Dates:

What to Turn-In:

Where to Turn-In:

To the plastic bin outside Professor Erlinger's office.



subprograms is an attempt to be generic about what is being requested.
Another way to look at the exercise is to view it as a stack trace for recursion vs. iteration. Creating 2 programs with a subprogram in each makes it easier to grade.


We reserve the right to change the problem statement when someone demonstrates the ambiguity of said problem statement.
1. have them read in fib from command line.
2. have them pass parameters in the stack....
3. Change points to 15

Last modified Oct 31, 01 by mike@cs.hmc.edu