SPIM

A MIPS32 Simulator

James Larus

larus@microsoft.com

 

Senior Researcher, Microsoft Research
Formerly:
Professor, Computer Sciences Department, University of Wisconsin-Madison

spim is a self-contained simulator that will run MIPS32 assembly language programs. It reads and executes assembly language programs written for this processor. spim also provides a simple debugger and minimal set of operating system services. spim does not execute binary (compiled) programs.

spim implements almost the entire MIPS32 assembler-extended instruction set. (It omits most floating point comparisons and rounding modes and the memory system page tables.) The MIPS architecture has several variants that differ in various ways (e.g., the MIPS64 architecture supports 64-bit integers and addresses), which means that spim will not run programs compiled for all types of MIPS processors. MIPS compilers also generate a number of assembler directives that spim cannot process. These directives usually can be safely deleted.

Earlier versions of spim (before 7.0) implemented the MIPS-I instruction set used on the MIPS R2000/R3000 computers. This architecture is obsolete (though, has never been surpassed for its simplicity and elegance). spim now supports the more modern MIPS32 architecture, which is the MIPS-I instruction set augmented with a large number of occasionally useful instructions. MIPS code from earlier versions of SPIM should run without changes, except code that handles exceptions and interrupts. This part of the architecture changed over time (and was poorly implemented in earlier versions of spim). Code of this sort need to be updated. Examples of the new code are in exceptions.s and Tests/tt.io.s.

spim comes with complete source code and documentation. It also include a torture test to verify a port to a new machine.

spim implements both a simple, terminal-style interface and a window interface. On Unix, Linux, and Mac OS X the spim program provides a simple terminal interface and the xspim program provides the windowing interface. On Microsoft Windows, the spim program provides a console interface and PCSpim provides a Windows interface.


Downloading SPIM

Platform Program Form File
Unix or Linux system
Mac OS X
spim
xspim
Source code http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z or
http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz
Linux spim
xspim
Binary RPM for Fedora http://www.cs.wisc.edu/cbi/downloads/ 
Microsoft Windows
(Windows NT, 2000, XP)

(spim 7.0 and later versions no longer run on Windows 95/98. Use version 6.5 or earlier.)

spim
PCSpim
Executable http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip
Source code http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip

Installation

Microsoft Windows

  1. Download the file http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip and save it on your machine.

  2. Unzip the file.

  3. Click on the setup.exe program.

Unix, Linux, or Mac OS X

(Note: the directions changed slightly for version 7.2, to reflect a new directory structure. Please read carefully.)

Installation is a bit more complex for a Unix or Linux system, as you need to compile the program for your particular computer and operating system.

  1. Download either the file http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z or http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz.

  2. Decompress the file, using either the program uncompress for the first file or gzip for the second file:

        % uncompress spim.tar.Z

    or

        % gzip -d spim.tar.gz
     

  3. Move the file spim.tar to the directory in which you want to build spim and untar it:

        % tar xf spim.tar

    It will create a directory named spim-7.2 (or the most recent version number).
     

  4. The simple terminal interface is contained in the spim-7.2/spim directory and the X-windows interfaces is in the spim-7.2/xspim directory. The other directories are described in the README file.
     

  5. Next, you must set the directories in which spim will be installed by editing the Makefile (the file that contains instructions on building spim). In general, if you are installing spim and want the windowing version (xspim), edit the file xspim/Imakefile. If you don't want xspim or are running on a system without X-windows installed, you use the file spim/Makefile.

    Set these pathnames to the appropriate locations for your system:

        EXCEPTION_DIR -- The full pathname of the directory in which to install the spim exception handler (exceptions.s).

        BIN_DIR -- The full pathname of the directory in which spim and xspim should be installed.

        MAN_DIR -- The full pathname of the directory in which the manual pages for spim and xspim should be installed.

    In general, the remaining parameters in a Makefile need not be changed.
     

  6. Then, if you are using Imakefile file, change to the spim-7.2/xspim directory and type:

        % xmkmf
        % make
    If you do not have a copy of xmkmf, you can use the Makefile in the xspim directory, but beware that it may not work on your system because the paths to the X windows libraries could be different.
     

  7. If you do not have X-windows, change to the spim-7.2/spim directory, edit Makefile, and type:

        % make
       

  8. To run spim or xspim, the exception handler must be installed in the directory specified by the variable EXCEPTION_DIR in the Makefile. If the file exception.s is not installed, spim and xspim fail before they start running. You can either install this file by hand or by typing

        % make install

    which also installs spim or xspim, and the manual pages in the directories that you set (above).
     

  9. To test that spim is correctly built, change to the spim-7.2/spim directory and type:

        % make test

    and examine the output of the test. (Note: the exception handler must be installed before running the test.)


Resources


Changes in Latest Version

The current version of spim is 7.3 (August 2006), which is a minor release that cleans up a number of bugs in 7.2:

The previous version of spim is 7.2.1 (August 2005), which is a minor release that cleans up a number of bugs in 7.1:

The previous version of spim is 7.1 (January 2005), which is a minor release that cleans up a number of bugs in 7.0:

The previous version of spim is 7.0 (August 2004), which is a major release that contains a significant number of changes from version 6.5:

Outstanding bugs in 7.0:

 

The previous version of spim is 6.5 (January 2003), which contains the following changes from version 6.4:

The previous version of spim is 6.4 (January 2002), which contains the following changes from version 6.3:

The previous version of spim is 6.3 (January 2001), which contains the following changes from version 6.2:


Copyright

spim is copyrighted by James R. Larus and distributed under the following conditions:

THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

 The DOS and Windows ports were done by David A. Carley and are copyrighted by Morgan Kaufmann Publishers.


SPIMSAL Note

spimsal is an old version of spim that ran on PCs running Windows 3.1 and Macintoshes. spimsal implements an extended version of the MIPS instruction set and is based on an old version of spim. It also does NOT run under Windows 95 or Windows NT.