spim(1)
π spim(1) β bestie edition β¨
okay so this is the manual page for spim, section 1 of the General Commands Manual, and it's genuinely iconic. sit down, grab a strawberry π, and let's get into it.
πΈ NAME πΈ
xspim β a MIPS32 Simulator. that's it, that's the whole name section. short, sweet, main character energy π
β¨ SYNTAX β¨
here's exactly how you call it, no notes:
xspim [-asm/-bare -exception/-noexception -quiet/-noquiet
-mapped_io/-nomapped_io
-delayed_branches -delayed_loads
-stext size -sdata size -sstack size -sktext size
-skdata size -ldata size -lstack size -lkdata size
-hexgpr/-nohexgpr -hexfpr/-nohexfpr]
-file file -execute file
like, yes, the indentation is a little chaotic, we don't talk about it, it's part of the vibe π¦
π DESCRIPTION π
SPIM S20 is a simulator that runs programs for the MIPS32 RISC computers. fr fr. SPIM can read and immediately execute files containing assembly language or MIPS executable files. it's a whole self-contained system for running these programs, and it comes with a debugger and an interface to a few operating system services. a full little ecosystem, we love to see it π
SPIM comes in two versions, and this is the part where you pick your fighter:
- the plain version is called
spim. it runs on any type of terminal. it operates like most programs of this type: you type a line of text, hit the return key, andspimexecutes your command. old school, lowkey classic π - the fancier version is called
xspim. it uses the X-window system, so you must have a bit-mapped display to run it. but here's the thing βxspimis a much easier program to learn and use, because its commands are always visible on the screen and because it continually displays the machine's registers. the way it just keeps your registers on display at all times?? obsessed πβ¨
π OPTIONS π
xspim has many options. like, a lot. we're listing every single one, bestie, no skips:
-asmβ Simulate the virtual MIPS machine provided by the assembler. this is the default π-bareβ Simulate a bare MIPS machine without pseudo-instructions or the additional addressing modes provided by the assembler. Implies-quiet.-exceptionβ Load the standard exception handler and startup code. this is the default.-noexceptionβ Do not load the standard exception handler and startup code. so real talk: this exception handler handles exceptions. when an exception occurs, SPIM jumps to location0x80000080, which must contain code to service the exception. in addition, this file contains startup code that invokes the routinemain. without the startup routine, SPIM begins execution at the instruction labeled__start.-quietβ Print a message when an exception occurs. this is the default.-noquietβ Do not print a message at exceptions.-mapped_ioβ Enable the memory-mapped IO facility. β οΈ programs that use SPIM syscalls to read from the terminal cannot also use memory-mapped IO. pick one, babe.-nomapped_ioβ Disable the memory-mapped IO facility.-delayed_branchesβ Simulate MIPS's delayed control transfers by executing the instruction after a branch, jump, or call before transferring control. SPIM's default is to simulate non-delayed transfers, unless the-bareflag is set.-delayed_loadsβ Simulate MIPS's original, non-interlocked load instructions. SPIM's default is to simulate non-delayed loads, unless the-bareflag is set.-stext size,-sdata size,-sstack size,-sktext size,-skdata sizeβ Sets the initial size of memory segment seg to be size bytes. the memory segments are named:text,data,stack,ktext, andkdata. let's break it down, because it's giving lecture:- the
textsegment contains instructions from a program. - the
datasegment holds the program's data. - the
stacksegment holds its runtime stack. - in addition to running a program, SPIM also executes system code that handles interrupts and exceptions. this code resides in a separate part of the address space called the kernel. the
ktextsegment holds this code's instructions andkdataholds its data. - there is no
kstacksegment since the system code uses the same stack as the program. - for example, the pair of arguments
-sdata 2000000starts the user data segment at2,000,000bytes. π
- the
-ldata size,-lstack size,-lkdata sizeβ Sets the limit on how large memory segment seg can grow to be size bytes. the memory segments that can grow aredata,stack, andkdata.-hexgprβ Displays the general purpose registers (GPRs) in hexadecimal.-nohexgprβ Displays the general purpose registers (GPRs) in decimal.-hexfprβ Displays the floating-point registers (FPRs) in hexadecimal.-nohexfprβ Displays the floating-point registers (FPRs) as floating-point values.-file file 10β Load and execute the assembly code in the file.-execute file 10β Load and execute the MIPS executable (a.out) file. β οΈ only works on systems using a MIPS processors.
π BUGS π
Instruction opcodes cannot be used as labels. that's it. that's the bug. short but devastating π
π₯ SEE ALSO π₯
spim(1)- James R. Larus, ``SPIM S20: A MIPS R2000 Simulator,'' included with SPIM distribution.
π AUTHOR π
James R. Larus, Computer Sciences Department, University of Wisconsin-Madison. Current address: James R Larus (larus@microsoft.com), Microsoft Research.
and that's the whole page, bestie π«Ά go forth and simulate some MIPS, you've got this. this was spim(1) from the General Commands Manual β literally the same title in the header and the footer, which is so symmetric of it. periodt. ππ§β¨
π¦ where this page comes from
- debian bookworm: spim 8.0+dfsg-6.1+b1
- debian trixie: spim 8.0+dfsg-7
- ubuntu jammy: spim 8.0+dfsg-6.1
- ubuntu noble: spim 8.0+dfsg-7
- ubuntu questing: spim 8.0+dfsg-8
- ubuntu resolute: spim 8.0+dfsg-8build1
- ubuntu stonking: spim 8.0+dfsg-8build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms