COSC 065 Hardware Systems

Fall 2007

Homework Assignment #6

When Stack Frames Attack
Due: Friday, Oct 26, 2:00PM CDT
Submit: E-mail zipped tarball of main program source files to professor, with a subject header "COSC 065 HW#6".
Work may be completed in pairs. Each team should submit only once. Be certain to put both team member names on work submitted. It would be courteous to carbon-copy your partner when e-mailing the final submission.

Background

Take time to familiarize yourself with the UNIX environment, using the tutorial here.

Always start your MIPS programming assignments using the MIPS Playground tarball. Download the tarball, and open it in your working directory using the UNIX command "tar xvzf xinu-cosc065.tgz". The file main.S is ready for you to begin programming in MIPS assembly language.

Your work must be compiled on a machine with the proper tools, such as the dual-head Linux boxen in the Systems Lab (CU 310). Consult the professor for advice on connecting remotely if the lab is full or you must work from elsewhere.

In order to assemble your program, use the command "make". In order to run your program, use the command "./mipcon". At any time, you can shutdown the MIPS remote console system by hitting Ctrl-Space, followed by the letter 'q', for 'quit'.

Few rules govern the format of assembly language programs. Make an effort to keep your programs readable and well-documented; sometimes the professor gives partial credit if he can tell what you were trying to do, even if it doesn't quite make it.

Q1 - Grid Printer

Write a MIPS Assembly program that reads an integer number of columns, "n", and then prompts for n more integers representing a column coordinate for each row. Print out an n x n grid representation of the data entered, using zero-based coordinates.

The professor has provided an example program for your reference, runnable on Morbius as ~brylow/cosc065/bin/hw6-grid.

Your program will need to store an arbitrary number of integers before printing out the results. You may either allocate space for a local array on the stack (below the frame pointer of the current function's activation record,) or you may dynamically allocate the space using the malloc() library function.

This type of problem is best implemented using helper functions. (For example, a function printrow(cols, value) that prints out a single row of the grid.) As you write your helper functions, build proper activation records that will allow your functions to strictly abide by the standard calling convention -- this will help a great deal.

Q2 - Towers of Hanoi

The Towers of Hanoi Problem is a classic mathematical puzzle invented by French mathematician Edouard Lucas in 1883. The puzzle was accompanied by a legend of a group of monks solving the puzzle for N = 64; when they finish, according to legend, the world will end.

(This is probably the inspiration for the similarly-themed Arthur C. Clarke science fiction short story, The Nine Billion Names of God.)

Write a MIPS Assembly program that reads an integer, "n", and prints out the proper sequence of moves to solve the Towers of Hanoi puzzle for n disks.

The professor has provided an example program for your reference, runnable on Morbius as ~brylow/cosc065/bin/hw6-hanoi.


Back
[Revised 2007 Oct 17 15:57 DWB]