View
8.741
Download
3
Category
Tags:
Preview:
DESCRIPTION
A brief introduction on SPIM simulator, install instructions and first run
Citation preview
SPIM: a MIPS simulator
Michele Chinosimichele.chinosi@uninsubria.it
University of Insubria - Varese (IT)
26.11.2008
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 1 / 22
Outline
1 IntroductionGetting started with SPIMSPIM installationDocumentation
2 XSPIMGetting started with xspimLoad and execute programs
3 Conclusions
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 2 / 22
The SPIM simulator
SPIM
SPIM is a MIPS R2000/R3000 RISC computer simulator
Websitehttp://www.cs.wisc.edu/∼larus/spim.html
Version
The current version of SPIM is 7.3 (August 2006)
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 3 / 22
A screenshot of SPIM
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 4 / 22
Some features
SPIM:
can read and immediately execute files containing assembly language
provides a simple debugger and minimal set of operating system services
does not execute binary (compiled) programs
implements almost the entire MIPS32 assembler-extended instruction set
comes with complete source code and documentation
implements both a simple, terminal-style interface and a grafical userinterface
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 5 / 22
User interfaces
Unix, Linux, Mac OS XOn Unix, Linux and Mac OS X the spim program provides a simple terminalinterface and the xspim program provides the windowing interface
Microsoft WindowsOn Microsoft Windows the spim program provides a console interface and thePCSpim program provides a Windows interface
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 6 / 22
Terminal-style interface
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 7 / 22
Xspim interface
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 8 / 22
PCSpim interface
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 9 / 22
How to install SPIM on Microsoft Windows
It’s very simple!1 Download SPIM from
http://www.cs.wisc.edu/∼larus/SPIM/pcspim.zip and save it on yourmachine
2 Unzip the file
3 Click on the setup.exe program
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 10 / 22
How to install SPIM on Unix, Linux and Mac OS X
It’s not so simple...1 Download SPIM from
http://www.cs.wisc.edu/∼larus/SPIM/spim.tar.gz2 Move the file spim.tar.gz to the directory in which you want to build spim
and decompress it:$ tar -zxvf spim.tar.gz
3 It will create a directory named spim-7.3 (or the most recent version number)
4 The simple terminal interface is contained in the spim-7.3/spim directory andthe X-window interface is in the spim-7.3/xspim directory
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 11 / 22
How to install SPIM on Unix, Linux and Mac OS X (2)
It’s not so simple...5 You must set the directories in which spim will be installed by editing the
Makefile (the file that contains instructions on building spim).xspim → xspim/Imakefilespim → spim/Makefile.3 pathnames: EXCEPTION DIR, BIN DIR, MAN DIR.
6 If you are using Imakefile file, change to the spim-7.3/xspim dir and type:$ xmkmf$ make
7 If you do not have X-windows, change to the spim-7.3/spim dir and type:$ make
8 To run spim or xspim, you have to install the exception handler(exceptions.s). Thus, become root and type:# make install
9 To test that spim is correctly build, from spim-7.3/spim type:$ make test
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 12 / 22
How to install SPIM on Unix, Linux and Mac OS X (3)
But...
If you are using a Debian-based distribution (like Ubuntu, Mepis, Xandros,Knoppix), it is enough to run:
user@system:$ sudo apt-get install spim
or the equivalent package management system for your Linux distro:
synaptic
aptitude
. . .
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 13 / 22
How to install SPIM
That’s it!For further information, please visit:http://www.cs.wisc.edu/∼larus/spim.html
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 14 / 22
Documentation
Where to find some other referencesPatterson & Hennessy, Computer Organization and Design: Thehardware/software interface, Appendix A
MIPS32 Architecture for Programmers Volume I,II,III, the officialdocumentation provided by MIPS Inc.
Other two books edited by Morgan Kaufmann:
See MIPS run, written by Dominic SweetmanThe MIPS programmer’s handbook, written by Erin Farquhar and Philip Bunce
Getting started with [spim|xspim|PCSpim], a simple overview of these threealternatives
SPIM Command-Line Options, a simple tutorial
http://www.google.com
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 15 / 22
Let’s start using xspim
How to start xspim
To start xspim go to spim-7.3/xspim directory and type:$ xspim
When xspim starts up, it pops up a large window on your screen. This window isdivided into five panes:
Register display
Control buttons
text segment
data and stack segment
SPIM messages
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 16 / 22
Xspim window
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 17 / 22
Xspim window (ctd.)
Register display
This pane shows the values of all registers in the MIPS CPU and FPU. Thisdisplay is updated whenever your program stops running
Control buttonsThese buttons let us interact with simulator. We will discuss more in details aboutthem later on.
Text segments
This pane displays instructions from both your program and the system code thatis loaded automatically when xspim starts running.
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 18 / 22
Xspim window (ctd.)
Data and Stack segments
This pane displays the data loaded into your program’s memory and the data onthe program’s stack.
SPIM messages
The bottom pane is used by xspim to write messages. This is where errormessages appear.
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 19 / 22
Load and Run
Load program into xspim
Once you have started xspim, you can load a new program simply clicking onLoad button.Then select the file you want to execute and confirm.SPIM loads your program into text segment, and redraws panes to see programdata.
Run program
To run your program, simply click on Run button.If you don’t see your instruction in the text segment click on the scrollbar on theleft of panes.
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 20 / 22
spim and PCSpim
The instructions for command-line version and Microsoft Windows version are ondocuments already presented.
It is recommended that you read carefully all the documentation provided withSPIM simulator in order to execute properly your programs.
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 21 / 22
Conclusions
Which of the three version of SPIM you have to use?
You are free to use simple command-line spim version rather than PCSpim versionor xspim verson.It is suggested to use xspim.
And now... let’s play with SPIM!
Michele Chinosi (Univ. Insubria) SPIM: a MIPS simulator 26.11.2008 22 / 22
Recommended