CS 12 -- Lab 10

Just a bit more assembly programming with MIPS and SPIM. Specifically, a bit of procedure calling and array operations.


A linear array search

Grab the following file from my directory

~sfkaplan/public/cs12/find-max.s

This file contains a simple but incomplete program that creates an array of integers, searching for the maximum value in that array, and then prints it. The first and last parts have already been programmed in __start -- an array is created on the stack, and some values are put into it. A procedure call is made to find-max, and the result of that procedure call it printed to the screen as a result.

Unfortunately, find-max has not yet been written. You must write this procedure. Specifically, it should visit every element in the array passed to it and return the maximum value found among those elements.


Recursion!

Now grab another file from my directory:

~sfkaplan/public/cs12/calcexponent.s

Again we have an incomplete program. Specifically, __start has been written to take base and exponent values (hard coded), print them to the screen using the print procedure, calculate the exponent by calling calcexponent, and then printing the result of that procedure call.

Of course, calcexponent has not been written. You must write a recursive procedure that will perform exponentiation. As a reminder (in case you need one):

x0 = 1
xy = x * xy-1 if y > 0

What you must submit

Once you have written and tested your programs, you must use the cs12-submit command to submit it. Submit this assignment as lab-10 when you use the cs12-submit command.


This assignment is due on Sunday, May 9th, at 11:59 pm.

Scott F. Kaplan
Last modified: Sun Nov 5 22:48:52 EST 2000