Lab 3 - MIPS Function Calls
The purpose of this lab is to write an assembly program that implements a
simple function call. I have provided an example program,
fact.s, that is based on the example printed
in Appendix A of the book. You can copy these files over to your current
directory, compile and run them using:
cp /usr/users/mdanfor/public_html/cs321-w07/code/fact/* .
sde-make
sde-run factram
The factorial assembly program is equivalent to the following C program:
int main()
{
printf("The factorial of 10 is %d\n", fact(10));
}
int fact(int n)
{
if(n < 1) return 1;
else return n * fact(n-1);
}
Assignment
Create a program called sumfunc.s
that is equivalent to
the following C program:
int main()
{
printf("The sum of %d and %d is %d\n", 3, 5, sum(3, 5));
}
int sum(int a, int b)
{
return a + b;
}
You MUST do the summation in a function call, not in main as with last week's
lab assignment. Email me your completed sumfunc.s
file.