SPIM

SPIM is a MIPS processor simulator, designed to run assembly language code for this architecture. The program simulates R2000 and R3000 processors, and was written by James R. Larus while a professor at the University of Wisconsin-Madison. The MIPS machine language is often taught in college-level assembly courses, especially those using the textbook Computer Organization and Design: The Hardware/Software Interface by David A. Patterson and John L. Hennessy (ISBN 1-55860-428-6).

The name of the simulator is a reversal of the letters "MIPS".

SPIM simulators are available for Windows (PCSpim), Mac OS X and Unix/Linux-based (xspim) operating systems. As of release 8.0 in January 2010, the simulator is licensed under the standard BSD license.

In January, 2011, a major release version 9.0 features QtSpim that has a new user interface built on the cross-platform Qt UI framework and runs on Windows, Linux, and Mac OS X. From this version, the project has also been moved to SourceForge for better maintenance. Precompiled versions of QtSpim for Linux (32-bit), Windows, and Mac OS X, as well as PCSpim for Windows are provided.

Examples of system calls (used by SPIM)
service Trap code Input Output Notes
print_int $v0 = 1 $a0 = integer to print prints $a0 to standard output
print_float $v0 = 2 $f12 = float to print prints $f12 to standard output
print_double $v0 = 3 $f12 = double to print prints $f12 to standard output
print_string $v0 = 4 $a0 = address of first character prints a character string to standard output
read_int $v0 = 5 integer read from standard input placed in $v0
read_float $v0 = 6 float read from standard input placed in $f0
read_double $v0 = 7 double read from standard input placed in $f0
read_string $v0 = 8 $a0 = address to place string, $a1 = max string length reads standard input into address in $a0
sbrk $v0 = 9 $a0 = number of bytes required $v0= address of allocated memory Allocates memory from the heap
exit $v0 = 10
print_char $v0 = 11 $a0 = character (low 8 bits)
read_char $v0 = 12 $v0 = character (no line feed) echoed
file_open $v0 = 13 $a0 = full path (zero terminated string with no line feed), $a1 = flags, $a2 = UNIX octal file mode (0644 for rw-r--r--) $v0 = file descriptor
file_read $v0 = 14 $a0 = file descriptor, $a1 = buffer address, $a2 = amount to read in bytes $v0 = amount of data in buffer from file (-1 = error, 0 = end of file)
file_write $v0 = 15 $a0 = file descriptor, $a1 = buffer address, $a2 = amount to write in bytes $v0 = amount of data in buffer to file (-1 = error, 0 = end of file)
file_close $v0 = 16 $a0 = file descriptor

Flags:

Read = 0x0, Write = 0x1, Read/Write = 0x2

OR Create = 0x100, Truncate = 0x200, Append = 0x8

OR Text = 0x4000, Binary = 0x8000

Read more about SPIM:  SPIM Alternatives/Competitors