CS 0447 – Lab 3: Functions
In this lab, you will write a two implementations of calculating the nth Fibonacci number:
fib(n)=fib(n-1)+fib(n-2).
fib(1)=fib(2)=1
Write a program that reads in an integer from the user and prints out the answer twice:
Note that for large n, you may run out of stack space in the naïve recursive implementation.
Functions must comply with MIPS calling conventions, such as:
• Pass the parameter via the $a0 register.
• Put the return value in the $v0 register.
• Save registers on the stack as necessary (i.e., if your function uses any $s0-$s7 registers, it should save and restore the used registers using a prologue/epilogue).
• Save $ra on the stack, if the function is a non-leaf function.
During your scheduled recitation the week of March 4-8, upload the zip file to the directory specified below using a program like FileZilla or WinSCP:
Server: unixs.cis.pitt.edu
Login: Your Pitt username (email before @)/Your password
For the Monday section:
Directory: /afs/pitt.edu/home/j/r/jrmst106/submit/447/monday/
For the Tuesday section:
Directory: /afs/pitt.edu/home/j/r/jrmst106/submit/447/tuesday/