%% -*- Mode: LATEX -*-

\documentclass[11pt]{rhitcsse}

\input{cs232_defs}
\title{Lab 3 - \textsc{MIPS} Procedures I}

\begin{document}

\maketitle

\section{Objectives}

Following completion of this lab you should be able to:
\latex{\vspace*{-\topsep}\vspace*{-\partopsep}}
\begin{itemize}{}
  \latex{\setlength{\itemsep}{0in}}
  \item Call and pass arguments to procedures in \textsc{MIPS}
  programs.
  \item Return from procedures.
  \item Save and restore registers.
  \item Correctly manage the stack.
  \item Discuss register allocation strategies.
\end{itemize}

\section{General}

\begin{itemize}
  \latex{\setlength{\itemsep}{0in}}
  \item Your grade for this lab will be based on your answers to some
  \htmladdnormallink{questions}{../pdf/cs232_lab3_questions.pdf}.
  \item Be sure to follow the \textsc{MIPS} procedure calling
  conventions as described in your book (Section 3.6 and Appendix
  A.6).
  \item You must remain in lab until you complete the lab exercise or 
  the end of the lab period.
  \item Bring your text book to labs.
  \item Read the lab instructions completely before beginning.
  \item Don't hesitate to ask for help.
\end{itemize}


\section{Procedures}

Work through the procedure call example on page A-26 of the book using
this \htmladdnormallink{handout}{../pdf/cs232_lab3_handout.pdf}.


\section{The Fibonacci Sequence}

The Fibonacci sequence\footnote{See also page 137 of the text.} is
defined over nonnegative integers as follows:
\latex{%
  \begin{eqnarray}
    \textrm{F}(0) & = & 0 \nonumber \\ 
    \textrm{F}(1) & = & 1 \nonumber \\
    \textrm{F}(i)\, & = & \textrm{F}(i-1) + \textrm{F}(i-2),\ \ i \ge
    2 \nonumber
  \end{eqnarray}}
\html{%
  \begin{center}
    \begin{tabular}{rcl}
      F(0) & = & 0 \\ 
      F(1) & = & 1 \\
      F(\textit{i}) & = & F(\textit{i}-1) + F(\textit{i}-2), \textit{i}>=2
    \end{tabular}
  \end{center}}

Examine the file \htmladdnormallink{\texttt{fib.asm}}{../labs/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.

\end{document}

% Local Variables:
% mode:latex
% End:
