**** USING SPIM AS A DEBUGGER ***** SPIM is a MIPS32 simulator. If you run your code inside SPIM you can use SPIM as a debugger. You cannot pass any cmdline args so you will need to hardcode values before loading the program. STEP 1. Create labels you want to use as breakpoints. At start of text section use the assembler directive .globl for these labels: .text .globl main .globl B1 .globl fill_loop STEP 2. Put the breakpoints in your code as places you wish to debug: fill_loop: mflo $t2 B1: sw $t2, ($t0) # set breakpoint here so you can check the value in $t2 STEP 3. Execute Spim and run your code. Sample Session: $ spim (spim) re "test.s" (spim) breakp b1 (spim) run (spim) p $t2 # print value in register $t2 (spim) s # step 1 instruction (spim) s 5 # step the program for 5 instructions (spim) print_sym # print all global symbols (spim) help # display all instructions (spim) cont # continue executing until next break point (spim) list # list all breakpoints (spim) exit BASIC COMMANDS exit -- Exit the simulator quit -- Exit the simulator read "FILE" -- Read FILE containing assembly code into memory load "FILE" -- Same as read run -- Start the program at (optional) ADDRESS step -- Step the program for N instructions (default 1) continue -- Continue program execution without stepping print $N -- Print register N print $fN -- Print floating point register N print ADDR -- Print contents of memory at ADDRESS print_symbols -- Print all global symbols print_all_regs -- Print all MIPS registers print_all_regs hex -- Print all MIPS registers in hex reinitialize -- Clear the memory and registers breakpoint -- Set a breakpoint at address ADDR delete -- Delete breakpoint at address ADDR list -- List all breakpoints dump [ "FILE" ] -- Dump binary code to spim.dump or FILE in network byte order dumpnative ["FILE"]-- Dump binary code to spim.dump or FILE in host byte order Notes on SPIM: The error "Attempt to execute non-instruction at 0x(address)00" where address is the next address after your program ends means you did not call exit syscall The first executable instruction must be preceded with label "__start:" or by the directive if you want it to be something other than main: .globl __start main: By default spim loads some code that sets up main and the starting label for you and also sets up some exception handling. Thus when you step through a program in SPIM the first instructions are setup and not part of your program.