📄 spim.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- saved from url=(0039)http://www.cs.wisc.edu/~larus/spim.html --><!-- saved from url=(0039)http://www.cs.wisc.edu/~larus/spim.html --><HTML><HEAD><TITLE>SPIM MIPS Simulator</TITLE><META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><META content="Microsoft FrontPage 6.0" name=GENERATOR></HEAD><BODY><H1 align=center>SPIM</H1><H2 align=center>A MIPS32 Simulator</H2><CENTER><P style="margin-top: 0; margin-bottom: 0"><a href="http://www.cs.wisc.edu/~larus/larus.html">James Larus</a></P><P style="margin-top: 0; margin-bottom: 0"><a href="mailto:larus@microsoft.com">larus@microsoft.com</a></P><P style="margin-top: 0; margin-bottom: 0"> </P><P style="margin-top: 0; margin-bottom: 0">Senior Researcher, Microsoft Research<i><br>Formerly:</i> Professor, ComputerSciences Department, University of Wisconsin-Madison</P></CENTER><P><B>spim</B> is a self-contained simulator that will run MIPS32 assembly language programs. It reads and executes assembly languageprograms written for this processor. <B>spim</B> also provides a simple debugger and minimal setof operating system services.<b> spim</b> does <u>not</u> execute binary(compiled) programs.</P><P><B>spim</B> implements almost the entire MIPS32 assembler-extended instructionset. (It omits most floating point comparisons androunding modesand the memory system page tables.) The MIPS architecture has severalvariants that differ in various ways (e.g., the MIPS64 architecture supports 64-bit integers and addresses), which means that<B>spim</B> will not run programs compiled for all types of MIPS processors. MIPS compilers also generate a number of assembler directives that<b>spim</b> cannot process. These directives usually can be safely deleted.</P><P>Earlier versions of <B>spim</B> (before 7.0) implemented the MIPS-Iinstruction set used on the MIPS R2000/R3000 computers. This architecture isobsolete (though, has never been surpassed for its simplicity and elegance). <B>spim</B> now supports the more modern MIPS32 architecture, whichis the MIPS-I instruction set augmented with a large number of occasionally useful instructions. MIPS code from earlierversions of SPIM should run without changes, <u>except</u> code that handlesexceptions and interrupts. This part of the architecture changed over time (andwas poorly implemented in earlier versions of <B>spim</B>). Code of this sort need to be updated. Examples of thenew code are in exceptions.s andTests/tt.io.s.</P><P><B>spim</B> comes with complete source code and documentation. It alsoinclude a torture test to verify a port to a new machine.</P><P><B>spim</B> implements both a simple, terminal-style interface and a window interface. On Unix, Linux, and Mac OS X the <i>spim</i> program provides a simple terminal interface andthe <i>xspim</i> program provides the windowing interface. On Microsoft Windows, the <i>spim</i> programprovides a console interface and <i>PCSpim</i> provides aWindows interface.</P><HR width="100%"><H2 align=center><B><FONT size=+2>Downloading SPIM</FONT></B></H2><DIV align=center><CENTER><TABLE width=732 border=1> <TBODY> <TR> <TD align=middle width=451><B>Platform</B></TD> <TD align=middle width=96><b>Program</b></TD> <TD align=middle width=128><B>Form</B></TD> <TD align=middle width=382><B>File</B></TD></TR> <TR> <TD width=451>Unix or Linux system<br> Mac OS X</TD> <TD width=96 align="center"><i>spim<BR>xspim</i></TD> <TD width=128 align="center">Source code</TD> <TD width=382><A href="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z">http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z</A> or<A href="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z"><BR></A><A href="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz">http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz</A></TD></TR> <TR> <TD width=451>Linux</TD> <TD width=96 align="center"><i>spim<br> xspim</i></TD> <TD width=128 align="center"><font SIZE="3">Binary RPM for Fedora</font></TD> <TD width=382> <a href="http://www.cs.wisc.edu/cbi/downloads/"> http://www.cs.wisc.edu/cbi/downloads/</a> </TD></TR> <TR> <TD width=451 rowSpan=2>Microsoft Windows<BR>(Windows NT, 2000, XP)<p> (spim 7.0 and later versions no longer run on Windows 95/98. Use version 6.5 or earlier.)</TD> <TD width=96 rowSpan=2 align="center"><i>spim<BR>PCSpim</i></TD> <TD width=128 align="center">Executable</TD> <TD width=382><a href="http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip"> http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip</a> </TD></TR> <TR> <TD width=128 align="center">Source code</TD> <TD width=382><A href="http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip">http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip</A></TD></TR> </TBODY></TABLE></CENTER></DIV><ul> <li><P style="margin-top: 6">To run <i>spim</i> or <i>xspim</i> on a Unix, Linux, or Mac OS X system, copy either the compressedtar file (<Ahref="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z">http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z</A>)or the gzip'ed tar file (<Ahref="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz">http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz</A>). Both files contains source code and must be compiled for your system.</P> </li> <li><P style="margin-top: 6">Ben Liblit of the <i>Cooperative Bug Isolation Project</i>(<a href="http://www.cs.wisc.edu/cbi/">http://www.cs.wisc.edu/cbi/</a>)produced a compiled version of <b>spim </b>for Fedora. It contains theproject's low-overhead monitoring code, which can help find bugs in <b>spim</b>.If you are running Linux, this package can: save you the time and trouble of compilingand installing <b>spim</b>, help find bugs, and aid an interestingresearch project.</P> </li> <li><P style="margin-top: 6">To run <i>PCspim</i> under Microsoft Windows, download the file<a href="http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip">http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip</a>, unzip it, and click on <i>setup.exe</i>.</P> </li> <li><P style="margin-top: 6">Source for the Microsoft Windows version (both <i>PCspim</i> and <i>spim</i>) is available separately inthe file <A href="http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip">http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip</A>.</P></li> <li><P style="margin-top: 6">There is no Macintosh version of <B>spim</B>. However, the <i>xspim</i> will compiles and runs on MacOS X. </P> </li></ul><HR width="100%"><H2 align=center><font size="+2">Installation</font></H2><p align=left><b><font size="4">Microsoft Windows</font></b></p><ol> <li><p align=left>Download the file<a href="http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip">http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip</a> and save it on your machine.</li><li><p align=left>Unzip the file.</li><li><p align=left>Click on the <i>setup.exe</i> program.</li></ol><p align=left><b><font size="4">Unix, Linux, or Mac OS X</font></b></p><p align=left><font color="#FF0000">(Note: the directions changed slightly for version 7.2, to reflect a new directory structure. Please read carefully.)</font></p><p align=left>Installation is a bit more complex for a Unix or Linux system, asyou need to compile the program for your particular computer and operatingsystem.</p><ol style="margin-top: 2"> <li><p align=left>Download either the file <A href="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z">http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z</A> or<a href="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z"> </a><A href="http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz">http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz</A>.</li><li><p align=left>Decompress the file, using either the program <i>uncompress</i>for the first file or <i>gzip</i> for the second file:<br><br> <i>% uncompress spim.tar.Z<br><br></i>or<br><br> <i>% gzip -d spim.tar.gz<br> </i></li><li><p align=left>Move the file <i>spim.tar</i> to the directory in which you wantto build <b>spim</b> and untar it:<br><br> <i>% tar xf spim.tar<br><br></i>It will create a directory named <i>spim-7.2</i> (or the most recent version number).<br> </li> <li> <p align=left>The simple terminal interface is contained in the <i> spim-7.2/spim</i> directory and the X-windows interfaces is in the <i> spim-7.2/xspim</i> directory.<i> </i>The other directories are described in the README file.<i><br> </i></li> <li> <p align=left>Next, you must set the directories in which <b>spim </b>will beinstalled by editing the Makefile (the file that contains instructions on building <b>spim</b>).In general, if you are installing <b>spim</b> and want the windowing version (<i>xspim</i>),edit the file <u><i>xspim/Imakefile</i></u>. If you don't want <i>xspim</i>or are running on a system without X-windows installed, you use the file <i> spim/Makefile</i>.<br><br>Set these pathnames to the appropriate locations for your system:</p> <p align=left> EXCEPTION_DIR -- The full pathname of the directoryin which to install the <b>spim </b>exception handler <i>(exceptions.s</i>)<i>.</i></p> <p align=left> BIN_DIR -- The full pathname of the directoryin which <i>spim</i> and <i>xspim</i> should be installed.</p> <p align=left> MAN_DIR -- The full pathname of the directoryin which the manual pages for <i>spim</i> and <i>xspim</i> should be installed.<br> <br>In general, the remaining parameters in a Makefile need not be changed.<br> </li> <li> <p align=left>Then, if you are using <u><i>Imakefile</i></u> file, change to the <i>spim-7.2/xspim </i>directory and type:<br><br> <i>% xmkmf<br> % make<br> </i>If you do not have a copy of <i>xmkmf</i>, you can use the Makefile in the <i>xspim</i> directory, but beware that it may not work on your system because the paths to the X windows libraries could be different.<br> </li> <li> <p align=left>If you do not have X-windows, change to the<i> spim-7.2/spim</i> directory, edit <i>Makefile,</i> and type:<br><br><i> % make<br> </i></li> <li> <p align=left>To run <i>spim</i> or <i>xspim</i>, the exception handler must beinstalled in the directory specified by the variable EXCEPTION_DIR in the Makefile.If the file <i>exception.s</i> is not installed, <i>spim</i> and <i>xspim</i>fail before they start running. You can either install this fileby hand or by typing<br><br><i> % make install</i><br><br>which also installs <i>spim</i> or <i>xspim</i>, and the manual pages in the directories thatyou set (above).<br> </li> <li> <p align=left>To test that <b>spim </b>is correctly built, change to the <i> spim-7.2/spim </i>directory and type:<br><br><i> % make test</i><br> <br>and examine the output of the test. (Note: the exception handler must be installedbefore running the test.)</li></ol><hr><H2 align=center><font size="+2">Resources</font></H2><ul style="margin-top: 12"> <li><P style="margin-top: 12; margin-bottom: 2">Elsevier (aka Morgan Kaufmann) hasgenerously provided the <b>spim </b>documentation (Appendix A) from the thirdedition of Hennessy & Patterson, <I><a href="http://books.elsevier.com/us/mk/us/subindex.asp?isbn=1558606041&country=United+States&community=mk&mscssid=T3GQV69C1T2T8NHKQJH2H7ANRW84FXW3">ComputerOrganization and Design: The Hardware/Software Interface</a></I>. Thisdocumentation is far more complete and up-to-date than the documentationincluded in the <B>spim</B> distribution. The COD documentation includes:<ul style="margin-top: 6"> <li><P style="margin-top: 12; margin-bottom: 2"> <i>Appendix A: Assemblers,Linkers, and the SPIM Simulator</i> (<a href="HP_AppA.pdf">PDF</a>). An overviewand reference manual for <b>spim</b> and the MIPS32 instruction set.</li> <li><P style="margin-top: 12; margin-bottom: 2"><i>Getting Started with spim</i> (<a href="spim.pdf">PDF</a>).Overview of the console version of <b>spim</b> (both Unix and Windows).</li> <li><P style="margin-top: 12; margin-bottom: 2"><i>Getting Started with xspim</i> (<a href="xspim.pdf">PDF</a>).Overview of the X-windows version of <b>spim</b>.</li> <li><P style="margin-top: 12; margin-bottom: 2"><i>Getting Starting with PCSpim</i>(<a href="PCSpim.pdf">PDF</a>). Overview of the Microsoft Windows version of <b>spim</b>.</li> <li><P style="margin-top: 12; margin-bottom: 2"><i>SPIM Command-Line Options</i> (<a href="SPIM_command-line.pdf">PDF</a>).Overview of the command line options of <b>spim</b> (all versions).</li></ul> </li> <li><P style="margin-top: 12; margin-bottom: 2">The documentation included with <B>spim</B> is also online (as a <Ahref="http://www.cs.wisc.edu/~larus/SPIM/spim_documentation.ps">postscript</A>or <A href="http://www.cs.wisc.edu/~larus/SPIM/spim_documentation.pdf">Adobe PDFfile</A>). This document is for the original <B>spim</B> (pre-version 7.0),which simulated the MIPS-I architecture rather than MIPS32, and so differs inmany minor aspects from the current version of <B>spim.</B> Appendix A of Hennessy & Patterson, <I><a href="http://books.elsevier.com/us/mk/us/subindex.asp?isbn=1558606041&country=United+States&community=mk&mscssid=T3GQV69C1T2T8NHKQJH2H7ANRW84FXW3">ComputerOrganization and Design: The Hardware/Software Interface</a></I> (above), ismore up-to-date and correct..</P> </li> <li><P style="margin-top: 12; margin-bottom: 2">The best book on MIPS programmingis: Dominic Sweetman, <I><a href="http://books.elsevier.com/us/mk/us/subindex.asp?isbn=1558604103&country=United+States&community=mk&mscssid=T3GQV69C1T2T8NHKQJH2H7ANRW84FXW3">SeeMIPS Run,</a></I> Morgan Kaufmann, San Francisco, CA, 1999, ISBN1-55860-410-3. MIPS, Inc. has excellent freedocumentation on the MIPS32 architecture on their website (registrationrequired):<ul style="margin-top: 12"> <li><P style="margin-top: 12; margin-bottom: 2"><a href="http://mips.com/content/Documentation/MIPSDocumentation/ProcessorArchitecture/ArchitectureProgrammingPublicationsforMIPS32/MD00082-2B-MIPS32INT-AFP-02.00.pdf/getDownload">MIPS32™ Architecture for Programmers Volume I: Introduction to the MIPS32™Architecture</a> <span class="doclibrary_details">v2.00 (1249 KB)</span></li> <li><P style="margin-top: 12; margin-bottom: 2"><a href="http://mips.com/content/Documentation/MIPSDocumentation/ProcessorArchitecture/ArchitectureProgrammingPublicationsforMIPS32/MD00086-2B-MIPS32BIS-AFP-02.00.pdf/getDownload">MIPS32™ Architecture for Programmers Volume II: The MIPS32™ Instruction Set</a><span class="doclibrary_details">v2.00 (3258 KB)</span></li> <li><P style="margin-top: 12; margin-bottom: 2"><a href="http://mips.com/content/Documentation/MIPSDocumentation/ProcessorArchitecture/ArchitectureProgrammingPublicationsforMIPS32/MD00090-2B-MIPS32PRA-AFP-02.00.pdf/getDownload">MIPS32™ Architecture for Programmers Volume III: The MIPS32™ Privileged ResourceArchitecture</a> <span class="doclibrary_details">v2.00 (1507 KB)</span></li></ul> </li> <li><P style="margin-top: 12; margin-bottom: 2">An old reference manual for the MIPS architecture (including processorssubsequent to the R2000/R3000) is: Gerry Kane and Joe Heinrich, <I>MIPS RISCArchitecture</I>, Prentice Hall, Englewood Cliffs, N.J. 07632 ISBN 0-13-1059254. </li> <li><P style="margin-top: 12; margin-bottom: 2">Another good book for MIPS R2000 and R3000 programmers is: Erin Farquhar andPhilip Bunce, <I><a href="http://books.elsevier.com/us/mk/us/subindex.asp?isbn=1558602976&country=United+States&community=mk&mscssid=T3GQV69C1T2T8NHKQJH2H7ANRW84FXW3">TheMIPS Programmer's Handbook,</a></I> Morgan Kaufmann, San Francisco, CA, 1994,ISBN 1-55860-297-6.</P> </li> <li><P style="margin-top: 12; margin-bottom: 2">The GNU C compiler can generate codefor the MIPS R3000 and can easily be used as a cross compiler. A retargeted portof gcc is available on the <a href="http://www.cs.unibo.it/mps/">MPS ResourcePage</a>. I have not used this compiler.</P> </li> <li><P style="margin-top: 12; margin-bottom: 2">Downcast Systems offers a very nicetext editor for MIPS assembly code called<a href="http://www.downcastsystems.com/mipster/">MIPSter</a>. It has syntaxhighlight, MIPS-specific help, good integration with SPIM, and a number of otherfeatures to make it easier to write assembly code. MIPSter is an inexpensivecommercial product, and it offers a limited time trial version.</P> </li></ul><HR width="100%">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -