Intro to SPIM Justin Fiore Nathan Parish
Installing SPIM on Windows Download pcspim.zip from the SPIM website: m.zip m.zip –It is also linked to on Dr. Lee’s page for this class Unzip it Run Setup.exe
Installing SPIM on Linux from Source Download Unzip it: tar xvzf spim.tar.gz cd spim-7.3/spim make cd../xspim kmkmf make
Installing SPIM on Ubuntu Linux Open the Synaptic Package Manager Click Settings->Repositories Select one of the Binary repositories and click Edit Check Non-free (Multiverse), and click OK Click Close Click Reload Search for “spim” Select the spim program and install it (this will install xspim also) NOTE: This was done on Ubuntu Linux 6.06 LTS (Dapper Drake)
Text Segment Your instructions are displayed here From left to right: –Address where the instruction is stored –Binary machine code for the instruction –Assembly instruction (with registers represented as numbers) –Line number in your assembly source –Assembly instruction from your source (with registers as $s0, $v0, etc) Pseudo Instructions will be converted to one or more assembly instructions
Message Segment Prints messages from SPIM such as: –Loading the exception handler –Loading your assembly file –Any errors that SPIM encounters
Register Segment Displays the register contents Displays PC, Stack Pointer, Frame Pointer, etc. Very important when debugging your code
Data Segment Displays the Data segment of memory. –Heap (starts at “Data”) –Stack (starts at “Stack”) Addresses are Byte Addressed Data is stored in words Data is represented in hexidecimal
Data Segment Example [0x ] 0x65704f0a 0x x20736e6f 0x [0x ] 0x f 0x6e x x e 0x = 0x65704f0a 0x = 0x x = 0x20736e6f 0x c = 0x x = 0x f 0x = 0x6e x = 0x x c = 0x e
Console
Debugging Click the “Hand” button to add a breakpoint Add the instruction address to break on After breaking, can –single step (F10) –multiple step (F11) –Set Value (Simulator->Set Value) –Continue Executing (F5)
Input/Output in SPIM Place proper arguments (e.g. system call code) to corresponding registers and place a ‘syscall’ Print string »li $v0, 4 »la $a0, var »syscall Print integer »li $v0, 1 »add $a0, $t0, $0 »syscall Read integer »li $v0, 5 # result in $v0 »syscall See Appendix A for more.