The assignment is due before class next Wednesday (Oct 16). Again, use the turnin program to turn in your assembly file. The comments that you add should be part of the assembly source file. You should test it to be sure that it works for all inputs (e.g., input cs30fzz should not contain a colon character in the output).
When you comment your code, make sure that the comment is not just true for the first time through loops.
I went over in class the MIPS registers and their usage convention, and how function calls are done using the normal function call convention (see the Larus handout. As an example, I went over the fib function to calculate the fibonacci function. In C, it is:
/* assume n >= 0 */ int fib(int n) { if (n <= 1) { return 1; } else { return fib(n-1) + fib(n-2); } }The fibonacci sequence is defined by fib(0) = fib(1) = 1, and fib(n) = fib(n-1) + fib(n-2) for all n greater than 1.
The MIPS assembly language implementation of this is available in the public directory (fib.asm). You should refer to the text (chapter 3), or to the Larus handout to figure out what each of the instructions do. You are encouraged to grab this file and run it under xspim. You probably don't want to evaluate fib for n larger than 23 or so, since this is the slow, recursive algorithm. Play with in. If you're motivated, try changing this to implement some other function, e.g., exponentiation by repeated squaring.
bsy@cse.ucsd.edu, last updated