Winter 2001-2002 CS 232

CS 232 – Computer Architecture I Rose-Hulman Institute of Technology Computer Science and Software Engineering Department

Lab 3 - MIPS Procedures I

1 Objectives

Following completion of this lab you should be able to:

• Call and pass arguments to procedures in MIPS programs.

• Return from procedures.

• Save and restore registers.

• Correctly manage the stack.

• Discuss register allocation strategies.

2 General

• Your grade for this lab will be based on your answers to some questions.

• Be sure to follow the MIPS procedure calling conventions as described in your book (Section 3.6 and Appendix A.6).

• You must remain in lab until you complete the lab exercise or the end of the lab period.

• Bring your text book to labs.

• Read the lab instructions completely before beginning.

• Don’t hesitate to ask for help.

3 Procedures

Work through the procedure call example on page A-26 of the book using this handout.

4 The Fibonacci Sequence

The Fibonacci sequence^{1} is defined over nonnegative integers as follows:

F(0) = 0
F(1) = 1
F(i) = F(i − 1) + F(i − 2), i ≥ 2

1See also page 137 of the text.

14 August 2002 Page 1

Winter 2001-2002 CS 232

Examine the file fib.asm using your favorite editor. It contains a recursive implementation of the Fibonacci sequence. Trace the execution of the program and answer the questions on the handout.

14 August 2002 Page 2