Reading Assignment: Chapter 3.1 - 3.10 and Appendix A
Update: You cannot install spim on departmental Windows machines. You
may install it on your own machines, or you can install onto a Linux machine in
your user space. See the following instructions.
Extra
instruction to experiment with an instruction-level simulator.
On a Windows machine that you can install software:
1.
Download the following zip file in your directory. Unzip to extract the two
files, spimwin.exe and pgm.asm.
2. Save these files in a temporary directory. After downloading is completed,
run spimwin.exe and install the PCSpim simulator program. Follow the
instructions given on screen.
3. After the simulator is installed, run
the simulator from START/PROGRAM/PCSpim for Windows/PCSpim for
Windows.
4. When the simulator is started, you should see 4 windows
titled "Messages", "Data Segment", "Text Segment", and "Registers". If you don't
see them, click on the Window menu and select Tile.
5. Now that you have
4 empty windows in your simulator screen, click on File menu and select Open, or
click on the first button right below the File menu, to open and load a file.
From the open window, go to the directory where the pgm.asm file is stored and
open it.
6. You should see that the Messages Window shows a message
saying that the file has been successfully loaded. Then in the Text Segment
Window, you will see the actual program loaded with the Program Counter (PC)
attached on the left starting from [0x00400000].
7. The program starts
off at PC=0x00400000 and executes a few OS related instructions and then jumps
to PC=0x00400020 where the main actually starts. (Scroll along the Text Segment
Window and compare the code to the original file pgm.asm)
8. Run the
program in Single Step mode. Goto Simulator menu, and select Single Step or F10
key to advance one step. Stop when PC value gets stuck at the same address.
On a Linux machine:
1. Download the following tar.gz file in your directory. Unzip the package ("gzip -d xspim.tar.gz"). Download pgm.asm.
2. You will find a new directory xspim-6.5. Change directory to xspim-6.5, and follow the instructions in README to build xspim.
3. Run "./xspim", you will see a window divided into five areas for registers, commands, test segment, data segment, and messages, respectively.
4. Clink on "load" button to load pgm.asm.
5. Click on "step" button to run the program step by step. Stop when PC value gets stuck at the same address.
PROBLEMS
P1. (30 points) Run the program given in file
pgm.asm and report:
(a) What happened to the content of register LO.
(b)
What instructions are equivalent to sd $4, 32($sp).
(c) What
instructions are equivalent to mul $15, $14, $14.
(d) How the contents
of stack locations 0x7fffeff4 and 0x7fffeff8 in Data Segment Window vary.
P2. (20 points) Chapter 3, Problem 3.1.
P3. (25 points) Chapter 3,
Problem 3.6. addi instruction adds an immediate number to a register. You may
like to run the corrected version on the simulator described above.
P4. (25
points) Chapter 3, Problem 3.11. You may run the program on simulator and submit
the debugged version of the program.