Assignment 2
Due: 9:10am, at the start of class, Thu Sept 14th, 2006
Note: Make reasonable assumptions where necessary and clearly state them.
Each of the 4 problems is worth an equal number of points.
Feel free to discuss problems with classmates, but the only written material
that you may consult while writing your solutions are the textbook
and lecture slides.
You may hand in solutions on paper at the start of class. You may also hand in
homeworks electronically on one of the CADE Lab machines. Place your solution
in a text file called "homework2" (if you use a different file name, our
print script may not find it) and use the following command:
handin cs3810 hw2 homework2
- Problems 2.37, 2.47, and 2.15 from Chapter 2.
For exercise 2.37, "small" is just a constant (immediate) value that's to
be compared to, loaded into, or added to the contents of a register. You
would normally put the actual decimal number there, and the compiler would
take care of the conversion to binary. You can just refer to it using the
name "small". "big" is also a constant value, but you (or the compiler)
would have to split it into its upper and lower 16-bit halves in order to
create proper values for the MIPS instructions. For this problem, since
you don't know what the specific value is, just refer to these halves as
"big upper" and "big lower".
Also note the typo in the second part. "clear $t50" should be "clear $t0".
- Consider the C program that implements matrix
multiply. Pick a compiler (say, gcc) and compile the program with different
optimization flags (-O0, -O1, -O2, -O3) and report on the relative
performance of each executable. (On a UNIX system, you can determine the
run-time of a program a.out with the command "time ./a.out". Run each
executable at least three times and take the average run-time.)
Also read the compiler's man pages to find the compiler flag that produces the
assembly code file (mm.s). Examine the assembly code
produced with optimization -O3 and -O0 and report on the difference
in the number of assembly instructions.