I expect most of the class to this lab in teams of two; however, I will accept a few people doing it alone and possibly a single team of three. Please form your own team of two, or contact me if you want to work alone or as a team of three; you may not work alone or as a team of three without my approval. If you are having trouble finding a partner (but want to work in a team), see me.
Your lab write up can be short and sweet, but it should be English.
You should communicate everything you did at some level of detail, but
for the uninteresting parts, you can summarize in broad outline, while
for the more interesting parts, you can go into detail. Specific
details I will expect to see are the two programs you are asked to
write, and test data and results from those two programs. Make sure
your testing is systematic and thorough. Thorough doesn't mean using
large quantities of weird numbers that still only test the same cases;
rather, it means using carefully chosen tests to ensure that all
cases are covered and all likely bugs exposed, while still allowing
the answers to easily be hand-checked.
You will do this lab on one of the Linux PCs in OHS 326. You will use
xspim, as described in Appendix A of the book. To run it, you can
also just type
xspim in a shell window. You can type
your programs in and edit them using either emacs or the "Text
Editor," both of which are found in the Applications sub-menu of the K
menu. Let me know if you have troubles with this or other
Linux/X-windows user interface stuff.
Please note that your program needs to end with a newline character at the end of the last line. (I.e., press the enter key on the keyboard at the end of the last assembly instruction.) Otherwise xspim will give a cryptic error message.
Your program should start with the label
main:This is because xspim automatically loads some "startup" code, which is what is run when you tell xspim to run the program. The startup code does a
jal maininstruction, transferring control to your code. Note that this is a subroutine call. Thus your code can end with
jr $ra, returning control back to the startup code. If so, the startup code will then exit, using the exit system call (number 10). Alternatively, your program can do the exiting itself, by putting 10 in register
$v0and then executing a
The xspim program displays register contents, data memory contents, and the addresses of instruction and data memory as hexidecimal (base 16) numerals instead of the decimal ones you are used to. (This uses a-f as additional digits with values 10-15, so that by having each digit of the numeral any of 0123456789abcdef it can be in the range from 0-15.)
If you want to convert any of these to decimal to help you understand
what is going on, here is one easy way. Run Scheme (as in MC27-28)
and then input the number, but starting with #x. For example if you
#x1a, Scheme will return 26, showing that
that hexidecimal 1a converts to decimal 26.
Start by stepping through simple programs, like one to add two numbers. This part of the lab is to make sure you are comfortable with SPIM.
Now you have two programs to write and test and debug (if necessary). You can do these in whichever order seems more natural for you.
Instructor: Max Hailperin