towers.cpp,
main.s,
towers.s
towers.s The file towers.cpp contains a simple C++ program
that finds the number of moves needed to solve the classic Towers of Hanoi
puzzle. In this problem a stack of discs (20 gold discs in the
classic myth) are stacked, each one in the stack a bit smaller than
the one beneath. Using two other positions, the problem is to move
the stack from the first position to the third, using the second as an
intermediate resting place. Discs must be moved one at a time (gold
is heavy), and a larger disc cannot be placed on top of a smaller one.
According to the myth, when the priests finish moving the tower of
discs according to these rules, the world will end.
The C++ program towers.cpp uses a recursive function to solve the problem, printing
each of the moves and the total moves needed.
The file main.s has the MIPS assembly code corresponding
to the main C++ program. The file towers.s has an outline
of the MIPS assembly code for the recursive function towers.
You should complete the assembly code for towers.s, using the
conventions for MIPS function calls and register usage as discussed in
the textbook.
Compare the output of your code to the sample output for
one,
two,
three,
four,
five,
six,
seven,
and eight discs.
Hand in your file towers.s by placing
a copy of it in your
~/courses/201/assignments directory, and sending e-mail
to your instructor. Be sure that your name appears in the comments at
the top of the file that you hand in.