SPIM

A MIPS32 Simulator

James Larus

larus@microsoft.com

 

Formerly: Professor, Computer Sciences Department, University of Wisconsin-Madison

Currently: Senior Researcher, Microsoft Research
 

spim is a self-contained simulator that will run MIPS32 assembly language programs. It reads and immediately executes assembly language code for this processor. spim 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 some complex floating point comparisons and rounding modes and details of the memory system page tables.) The MIPS architecture has several variants that differ in minor ways (in particular, the MIPS64), which means that spim will not run programs compiled for recent SGI processors. MIPS compilers also generate a number of assembler directives that spim cannot process. These directives 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 long obsolete (though, has never been surpassed for its simplicity and elegance), so SPIM now supports the more modern MIPS32 architecture, which contains a large number of rarely 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 that handles exceptions will need to be updated. Examples of the 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 visual windowing interface. On Unix, the spim program provides the terminal interface and the xspim program provides the X window interface. On PCs, the spim program provides the console interface and PCSpim provides the Windows interface.


Downloading SPIM

Platform Program Form File
Unix or Linux system 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
Microsoft Windows
(Windows 95, 98, NT, 2000, XP)
spim
PCSpim
Executable http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip
Source code http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip

To run spim or xspim on a Unix or Linux system, copy either the compressed tar file (http://www.cs.wisc.edu/~larus/SPIM/spim.tar.Z) or the gzip'ed tar file (http://www.cs.wisc.edu/~larus/SPIM/spim.tar.gz).  Both files contains source code and must be compiled on a particular system.

To run PCspim on a PC under Microsoft Windows, download the file http://www.cs.wisc.edu/~larus/SPIM/pcspim.zip, unzip it, and run setup.exe.

Source for the PC version (both PCspim and spim) is available separately in the file http://www.cs.wisc.edu/~larus/SPIM/pcspim_src.zip.

There is no specific Macintosh version of spim. However, the Unix version of xspim can be compiled and run on Mac OS X.


Installation

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. Run the setup.exe program.

Unix, Linux, or Mac OS X

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
     

  4. To compile spim, you must first configure it for your system by running the Configure script:

        % Configure

    Note: Configure compiles a program with the C compiler named cc. If you want it to use another compiler, set the environment variable CC to its name before running the script, e.g.:

        % setenv CC gcc
        % Configure
     

  5. Next, you must set the directories in which spim will be installed by editing a makefile (the file that tells how to build spim). In general, if you are installing spim and want the windowing version (xspim), you will edit the file Imakefile. If you don't want xspim or are running on a system without X-windows installed, you can use the file Makefile.std. Finally, if you are running under Microsoft Windows using Cygwin, edit the file Makefile.cygwin.

    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 the makefile need not be changed.
     

  6. Then, if you are using Imakefile type:

        % xmkmf
        % make

     

  7. If you want an X-window version of spim, also type:

        % make xspim
     

  8. If you do not have X-windows or the program xmkmf, edit either Makefile.std or Makefile.cygwin and type:

        % make -f Makefile.std test
       

  9. 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, xspim, and the manual pages in the directories that you set (above).
     

  10. To test that spim is correctly built, 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.0 (March 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.