Lab 6: Fun with Functions

Goals:

By the conclusion of this lab, you will have:

  1. Written a recursive function in MIPS assembly language.

  2. Explored a "CS Chestnut".

Phase One:  Learn the Algorithm

  1. Begin by hand-tracing the flow of execution in hanoi.cpp in the case where there are three disks.  Using pencil and paper, write out the trace, indicating which calls cause which messages to be printed.  (If you wish, you may use a word-processor to do this; if you do so, indicate deeper levels of nesting through greater indentation and state the value of parameters and local variables at that level.)  Your trace should definitely indicate when various messages are printed! 

Phase Two:  Assembly Language

  1. Now that you understand the algorithm, write the equivalent program in MIPS assembly language.  You must obey all standard MIPS function calling conventions.  This includes doing so for the main function.  It is, after all, a function!

    Begin by writing a main function that simply calls the function (i.e. all the function does is print a message stating that it was called.)  Then write a simplified version of the function that either moves one disk or states that the multi-disk capabilities are not yet implemented.  Finally, expand it to a recursive function that works in all cases.


  2. Run your program with 4 disks and print a copy of the output.

To Hand In

  1. You are to hand in the hand-trace generated in Step 1, the code listing generated in Step 2, and the output from Step 3 - along with a cover page.

 

Due Date

         This lab is due next Tuesday (Oct. 7), at 10:00 a.m.  It should be turned in to Dr. Levine directly.  If you turn it in to Dr. Hunkins in class on Tuesday, it will be considered on time.  If you turn it in to Dr. Hunkins at any other time, it will be considered "late".

 

Help Policy

        Help Policy in Effect for This Assignment: Group Project With Limited Collaboration

       In particular, you may discuss the assignment and concepts related to the assignment with the following persons, in addition to an instructor in this course: any Computer Science instructor and any student enrolled in CS 231.

       You may use the following materials produced by other students: materials produced by member of your own group.