Spim is simulator that lets you execute assembly
code designed for the MIPS R2000/R3000 architecture.
Mips Architecture is a RISC based architecture
where the processor has 32 registers and its instruction set is very
simple.
1- At the prompt shell type:
      % spim
You will see the following:
SPIM Version 5.3 of Aug 30, 1993
Copyright 1990-92 by James R. Larus (larus@cs.wisc.edu).
All Rights Reserved.
See the file README a full copyright notice.
(spim)
This message means that you are in Spim.
2- To load a program, type the following at the Spim prompt:
      (SPIM) load"myprogram.spim"
3- To run the program and see the results type:
      (SPIM) run
Running Spim
Debugging in Spim
Consider this program fragment:
.text # Main.
.globl main
main: li $v0, 4 # Syscall to print prompt string.
...
.globl while
while: blez $t0, endwhile
li $v0, 4
la $a0, prmpt2
syscall
li $v0, 5
syscall
add $t1, $t1, $v0 # Increase sum by new input.
sub $t0, $t0, 1 # Decrement n.
b while
endwhile: ...
STEP 1
If you think that you have an error in your while loop, the first thing
you have to do is to set a breakpoint. In this case, since the loop
starts at the label while, we will set while as our breakpoint.
Note that the while label has been declare as .globl.
Breakpoints may only be set at global labels.
So, to set the breakpoint, load the program and type:
     (spim) breakpoint while
When the simulator reaches a statement upon which a breakpoint is set, it
suspends execution just before executing the statement.
STEP 2
Now we can use the step command to execute one (the default) or more
statements at a time.
      (SPIM) step [n]
where n is optional, and it is the number of instruction executed at a
time. Step prints program statements as it executes them. Often, they
don't correspond to the assembler program because the simulator exchanges
symbolic register names ( $v0) for actual register names ($2), exchanges
symbolic labels with the actual memory address, and, most confusingly,
replaces certain assembly language statements with different statements.
In some cases, a single statement may even be replaced with multiple
statements.
STEP 3
Now that we know how to execute statements, we can use the print command
to print the value store in a register.
     (spim) print $v0
or the value of a memory location:
     (spim) print i
i must be a global variable.
OTHER COMMANDS
continue is used to resume normal operation.
delete label removes breakpoints from the statement
labeled label.
More commands can be found on the developers SPIM TUTORIAL.