QtSpim Tutorial — ECS Networking
Install the Qt framework that SPIM requires:
unix> sudo apt-get install qt4-dev-tools qt4-doc libqt4-help
Download a pre-packaged version of SPIM for Linux that uses the Qt GUI framework: (If you are running an older 32-bit Linux installation, change 64 to 32 below)
unix> wget http://sourceforge.net/projects/spimsimulator/files/qtspim_9.1.18_linux64.deb
Install the QtSPIM package:
unix> sudo dpkg -i qtspim_9.1.18_linux64.deb
To launch QtSPIM:
unix> qtspim &
After launching QtSPIM, the main window should appear as shown below.
There are three primary sections contained within this window: The Register panel, Memory panel, and Messages panel.
The Register panel (shown below) shows the contents of all the MIPS registers. There are two tabs in this panel: one for the floating point registers and one for the integer registers. The integer registers include general purpose registers (R1-R31), along with special purpose registers such as the Program Counter (PC).
The Memory panel has two tabs: Data and Text. The Text tab shows the contents of the Program memory space. From left to right, this includes:
- The memory address of an instruction in hexadecimal (shown in brackets)
- The contents of that memory address in hexadecimal. In binary form, this is the actual MIPS instruction that the processor runs!
- The "human-readable" assembly language instruction using the hardware register numbers (shown in bold).
- The assembly language program you wrote using symbolic register names and memory address symbols (shown in italics)
The Data tab shows the contents of the Data memory space. This includes the variables and array data you create, along with the stack content.
The Messages panel displays messages from QtSPIM to the user.
Load your first program by selecting File -> Reinitialize and Load File. (Recall that the new Ubuntu "Unity" GUI doesn't show the top-of-screen menubar until you mouse over it). This clears the register space and resets the simulator. (Otherwise, you could load and run several programs in a row on the same machine state.)
You can scroll down in the Text pane to see that the assembly code has been loaded into Program memory space. In this case, the first instruction is at memory location 0x00400024. (Why doesn't it start at memory address zero? The program starts with the function main(), but there is some code that runs before main).
Now that the program has been loaded, you can run a simulation of the assembly instructions. You have three choices:
- Run the program from beginning to end (via the "play" Run/Continue button or F5). This is useful for seeing the final output of the program.
- Step through the program one line at a time (via the "123" Single Step button or F10). This is useful to see how each assembly instruction affects the machine state (i.e. memory and register values).
- Run the program until you reach a breakpoint (which can be set by right-clicking on any line in the Memory panel.
Step through the complete program, figure out what it does, and make sure you understand how the QtSPIM environment works.