spim is a self-contained simulator that runs [tag:mips32] programs
It reads and executes assembly language programs written for this processor. Also provides a simple debugger and minimal set of operating system services. It 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 for all MIPS processors.
Spim implements both a terminal and windows interfaces. On Microsoft Windows, Linux, and Mac OS X, the spim program offers a simple terminal interface and the QtSpim program provides the windowing interface. The older programs xspim and PCSpim provide window interfaces for these systems as well.
Read more
System call information:
SPIM simulates a number of operating system-level functions for console I/O (e.g. print_int
, print_string
, read_string
), file I/O (e.g. open
, read
), dynamic memory allocation (sbrk
), etc.
These functions are invoked by setting up the CPU registers according to the SPIM system call documentation and then executing a syscall
instruction.
Branch delay slots:
Quoting from MIPS32™ Architecture For Programmers Volume I: Introduction to the MIPS32™ Architecture":
All branches have an architectural delay of one instruction. The instruction immediately following a branch is said to be in the branch delay slot.
In English: The instruction directly following a branch (jump) instruction will be executed before execution continues at the address you're branching to.
When writing MIPS assembly language code, care needs to be taken to fill the branch delay slots, either with NOPs, or with more meaningful instructions by changing the order or some instructions.
Note, however, that SPIM doesn't simulate branch delay slots by default. If simulating branch delay slots is desirable, it can be enabled in "Simulator" -> "Settings.." (PCSpim) or "Simulator" -> "Settings" -> "MIPS" (QtSpim). Enabling the "Bare machine" option also enables branch delay slot simulation.