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.outunless 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 - The N Queens Problem |
---|
Write a PowerPC Assembly program that reads an integer number "n" and produces a graphical representation of all of the solutions for the N Queens Problem associated with that value.
There are many algorithms available for solving instances of the problem, but the easiest way to produce all of the solutions for a given value of n is to recursively search the possible combinations and print out the ones that work.
The NxN chessboard in the problem is best represented by a single array of N integers, representing the rows, each containing the coordinate of the queen, representing the columns.
A solution is an assignment of queens in which no queens share a row, column, or diagonal. (Hint: there is an easy formula for checking whether two queens are on the same diagonal.)
Print out the solutions you find using your function from the previous assignment.
Q2 - Heap Limits |
---|
Write a PowerPC assembly language program that requests dynamic allocation of memory from the operating system (malloc function) until the operating system will not allocate any more.
Q3 - Text Dump |
---|
Write a PowerPC assembly program that prints out the memory address and the contents of every location between "main:" and the last line of your main program. Recall that the "%X" format specifier to printf() prints hexadecimal values.
Q4 - Nuke Stack |
---|
Having worked so hard to understand the discipline of activation records, now let's break them.
Write PowerPC assembly function "nukeStack" that when called -- from anywhere in a program that obeys standard calling conventions-- destroys all of the activation records above it on the stack until it finds the stack frame for the main program, and then returns directly to the main program.
Suffice it to say, nukeStack does not follow the standard calling convention.
Test your nukeStack by calling it from within various programs from previous assignments.
What to turn in: |
---|