Not to be turned in BUT PLEASE DO IT
The purpose of this homework is to
familiarize you with the R3000 Simulator, spim. In this assignment you
will learn how to use spim to run assembly language programs and to
extract information to debug your programs. In doing this, you will use a
program that is already written in assembly language. Since many operations in
assembly language are similar to those in high-level languages, you might be
able to understand some of what the program is doing. But don't worry if you
don't understand all of it now. You will learn assembly operations later on as
we discuss them in class and in sections, and as you read Appendix A and
Chapter 3. The purpose of this assignment is simply for you to become familiar
with the spim environment.
Note: This software is already installed
on the Windows machines in the labs at O:\cse\courses\cse378\spim\SPIM63a\bin
. Don't make 65 copies of it on the CSE servers -- if
you can, use this already-installed version. It is small and self-contained, so you should be able to use it on home
machines as well. Currently we are only supporting the PC version. If you want
to download SPIM on your personal computer, or cannot access it in the labs,
you can find everything you need on the on the Software link of the home page
or directly at SPIM
For this assignment, we will use a program
that computes the 10th Fibonacci number. The C version appears in Listing 1, and the MIPS Assembly version in Listing
2.
You can download the (unnumbered) assembly
code from here.
Simply click on the link and save it someplace you can remember. You then want
to "Open" it using PCSpim.
I. Execute the program in the
simulator. Use "Go" (F5 is a shortcut) in the simulator menu and the
start address 0x00400000 (this can be done in the dialog box that will open
under the GO command). What is printed on the spim console?
Now run the program in single steps (F10 is
the keyboard shortcut) When you want to re-run the program, you will have to
"reload" to make it work!!. In order to set the PC use "Set
Value" in the simulator menu with the register name being PC, and the
value 0x00400000. You can verify it is correct by looking at the value of the
PC displayed as the top lefmost register. Do you notice any discrepancies
between the given program and the instructions executed by spim? What
are a few (3 - 5) of the discrepancies?
II. Complete the following table by
examining various registers and memory location contents after executing the
appropriate instructions. Try to use the breakpoint command. If you are seeing
strange things, think about "reloading" the program within spim.
Location |
Line 16 |
Line 26 |
Line 26 |
Line 38 |
$25 |
|
|
|
|
$24 |
|
|
|
|
$8 |
|
|
|
|
8($sp) |
|
|
|
|
4($sp) |
|
|
|
|
|
|