CS 110, Architecture and Operating Systems
Fibonacci Project
Version 1.00
15 Points

Due April 5th, 2002, at 9 PM

Introduction

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

    F(n) = 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 the bt command 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.

What to submit:

What to turn in:

On paper, turn in:

Where to turn in:

To the plastic bin outside Professor Kuenning's office.

Notes:

FAQ:

We reserve the right to change the problem statement when someone demonstrates the ambiguity of said problem statement.

Last modified March 23, 2002 by geoff@cs.hmc.edu