CS 61C (Fall 2007)

Homework Assignment 5

One exercise, submit as "hw5".  Due 2:45pm before lecture 10/3/2007.

Goals

This homework is intended to provide you with practice coding recursive functions.

Background reading

Submission instructions

Submit your solution by creating a directory named hw5 that contains a file named hanoi.s. From within that directory, type submit hw5.This assignment is due October 3, the same day as project 2.

This is not a partnership assignment. Hand in your own work.

Problem 1 (8 points)

The Tower of Hanoi problem is well known. It's described here. It has an elegant recursive solution, which you'll implement for this homework exercise.

Translate the C program in ~cs61c/files/hw/5/hanoi.c to MIPS assembly language in the file hanoi.s. The program assumes there are pegs labeled A, B, and C. It prints moves of the form x y, where x and y are pegs. For example, the move AB means move the top disk from the peg labeled A to the peg labeled B.

Adhere to previously covered conventions for managing registers and the stack. Translate each call to putchar into a call to syscall; see the MARS (ssh -C cory, mars-cs61c) help for further information about the syscalls.