COSC 065 Hardware Systems

Fall 2006

Homework Assignment #6

When Stack Frames Attack

Due: Monday, Nov 13, 12:00PM CST
Work may be completed in groups of up to two students. I strongly recommend that you take the time to meet with your partner in person and work together on these projects, rather than work separately and try to integrate at the last minute.
Background:

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

Always start your assignments using the template here.

Your work must be assembled and run on Morbius (morbius.mscs.mu.edu).

Assemble your programs on Morbius using the command:

gcc <myfile.S>

Run your programs on Morbius using the command:

./a.out
unless you have used the "-o" option to gcc to change the name of your assembled executable.

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 PowerPC 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.
Q1 - 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 puzzle for N = 64; when they finish, according to legend, the world would 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 PowerPC 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.
What to turn in:

  • E-mail your assembly source files to the professor with a subject header "COSC 065 HW#6".
  • Be certain to put all team member names on work submitted. It would be courteous to carbon-copy your group when e-mailing the final submission.
    Back