Old school R&D / Spasm - Senior Project Assembler (Summer '97)
Spasm (web start / remember that?)
Java Web Start (All Platforms)
OSX Instructions
addi $1, $1, 1
beq $0, $0, -2
Screenshot
Overview
Spasm is a visual simulator of a single-cycle implementation of MIPS. A MIPS assembly program based on a reduced instruction set can be entered and execution viewed graphically. Users may modify values of several parameters while a simulation is running. Explore!
I worked on SPASM the summer after my freshman year in college and into the fall of 1997 on a Pentium-166 using Java and Netscape's IFC graphics API (preceeded JFC/Swing).
This project counted as my senior project and was a proof of concept for a more comprehensive visual simulator. It is based on figure 5.13 in chapter 5 of the book Computer Organization & Design --
"The Hardware / Software Interface" by Patterson and Hennesey. This book is widely used in undergraduate computer
architecture courses.
Spasm has been updated to run by Java web start on 1.4+ JVMs and has been tested on Win32 XP and Mac OSX 10.3.5.
If you are using a recent version of OSX simply click on the "web start" link at the top of the page. If you are on Windows
or Linux you must first install a 1.4+ JVM (and on OSX now too!); web start is installed as part of the process. After installation click on the
"web start" link at the top of page.
If you find Spasm useful feel free to contact the author, Michael Leahy (remove spam block). Please
report any bugs that you may find and I will fix them right away. Also, it would be great to receive user programs that
provide examples of usage and I will post the good ones on this page. If you are a professor and use Spasm as a teaching aid
for a computer architecture course please contact me, so that I might add your class information to the list below.
Below is a list of supported instructions; $1 specifies register 1:
Instruction | Example | Meaning |
---|---|---|
Add | add $1, $2, $3 | $1 = $2 + $3 |
Add Immediate | addi $1, $2, 100 | $1 = $2 + 100 |
Add Immediate Unsigned | addiu $1, $2, 100 | $1 = $2 + 100 |
Add Unsigned | addu $1, $2, $3 | $1 = $2 + $3 |
And | and $1, $2, $3 | $1 = $2 & $3 |
And Immediate | andi $1, $2, 100 | $1 = $2 & 100 |
Branch On Equal | beq $1, $2, 25 | if ($1 == $2) go to pc + 4 + 100 |
Branch On Not Equal | bne $1, $2, 25 | if ($1 != $2) go to pc + 4 + 100 |
Load Word | lw $1, 100($2) | $1 = Memory[$2 + 100] |
No Operation | nop | no operation |
Or | or $1, $2, $3 | $1 = $2 | $3 |
Or Immediate | ori $1, $2, 100 | $1 = $2 | 100 |
Set On Less Than | slt $1, $2, $3 | if ($2 < $3) $1 = 1; else $1 = 0 |
Set On Less Than Immediate | slti $1, $2, 100 | if ($2 < 100) $1 = 1; else $1 = 0 |
Subtract | sub $1, $2, $3 | $1 = $2 - $3 |
Subtract Unsigned | subu $1, $2, $3 | $1 = $2 - $3 |
Store Word | sw $1, 100($2) | Memory[$2 + 100] = $1 |
A simple program in Spasm to repeatedly add 1 to a register:
addi $1, $1, 1
beq $0, $0, -2
Spasm can load and save programs and the state of the simulator. These files are located under the "save" directory. This directory is automatically created on the desktop if web start is used or in the location of the offline installation.
The parser is fairly simple. One instruction per line regardless of white space. Users may enter blank lines and comments are indicated by starting lines with #.
Universities using Spasm: