![Page 1: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/1.jpg)
Intro to SPIM
Justin FioreNathan Parish
![Page 2: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/2.jpg)
Installing SPIM on Windows
• Download pcspim.zip from the SPIM website: http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip– It is also linked to on Dr. Lee’s page for this
class• Unzip it• Run Setup.exe
![Page 3: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/3.jpg)
Installing SPIM on Linux from Source
• Download http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz
• Unzip it: tar xvzf spim.tar.gz• cd spim-7.3/spim• make• cd ../xspim• kmkmf• make
![Page 4: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/4.jpg)
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)
![Page 5: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/5.jpg)
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
![Page 6: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/6.jpg)
Message Segment
• Prints messages from SPIM such as:– Loading the exception handler– Loading your assembly file– Any errors that SPIM encounters
![Page 7: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/7.jpg)
Register Segment
• Displays the register contents• Displays PC, Stack Pointer, Frame
Pointer, etc.• Very important when debugging your code
![Page 8: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/8.jpg)
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
![Page 9: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/9.jpg)
Data Segment Example• [0x10010000] 0x65704f0a 0x69746172 0x20736e6f 0x70707553• [0x10010010] 0x6574726f 0x6e612064 0x79532064 0x7861746e
• 0x10010000 = 0x65704f0a• 0x10010004 = 0x69746172• 0x10010008 = 0x20736e6f • 0x1001000c = 0x70707553• 0x10010010 = 0x6574726f • 0x10010014 = 0x6e612064 • 0x10010018 = 0x79532064 • 0x1001001c = 0x7861746e
![Page 10: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/10.jpg)
Console
![Page 11: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/11.jpg)
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)
![Page 12: Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:](https://reader037.vdocument.in/reader037/viewer/2022083119/5a4d1aea7f8b9ab05997a3a7/html5/thumbnails/12.jpg)
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.