Download Intro to SPIM - ECE Users Pages

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Intro to SPIM
Justin Fiore
Nathan Parish
Installing SPIM on Windows
• Download pcspim.zip from the SPIM
website:
http://www.cs.wisc.edu/~larus/SPIM/pcspi
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
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
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
•
•
[0x10010000]
[0x10010010]
•
•
•
•
•
•
•
•
0x10010000 = 0x65704f0a
0x10010004 = 0x69746172
0x10010008 = 0x20736e6f
0x1001000c = 0x70707553
0x10010010 = 0x6574726f
0x10010014 = 0x6e612064
0x10010018 = 0x79532064
0x1001001c = 0x7861746e
0x65704f0a 0x69746172 0x20736e6f 0x70707553
0x6574726f 0x6e612064 0x79532064 0x7861746e
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
» syscall
•
See Appendix A for more.
# result in $v0