Use this simulator to assemble, step through, and run MIPS programs while watching registers, memory, branches, and pipeline behavior.
Important: Keep this page, mips32_simulator.html, and
mips_example.asm in the same directory.
mips_example.asm.li $v0, 10 syscall
For an explicit exit status:
li $v0, 17 li $a0, 0 syscall
Register names begin with $, for example:
$zero $v0 $a0 $t0 $t1 $s0 $s1 $sp $ra
# This is a comment addi $t0, $t0, 1 # comment after an instruction
loop:
addi $t0, $t0, -1
bgtz $t0, loop
nop
li $t0, 25 li $t1, 0x20 addi $t2, $t2, -1
| Group | Instructions |
|---|---|
| Arithmetic | add, addu, sub, subu, addi, addiu |
| Logical | and, or, xor, nor, andi, ori, xori |
| Compare | slt, sltu, slti, sltiu |
| Shift | sll, srl, sra, sllv, srlv, srav |
| Memory | lw, sw, lb, lbu, lh, lhu, sb, sh |
| Branches | beq, bne, blez, bgtz |
| Jumps | j, jal, jr, jalr |
| HI/LO | mult, multu, div, divu, mfhi, mflo, mthi, mtlo |
| Other | lui, syscall |
| Pseudo-instructions | li, move, nop |
Memory operands use the form offset(base-register).
lui $s0, 0x1001 sw $t0, 0($s0) lw $t1, 0($s0)
Here, $s0 = 0x10010000, so 0($s0) refers to memory address 0x10010000.
Delay slot ON: the instruction immediately after a taken branch or jump executes before control transfers.
bgtz $t1, loop addi $t0, $t0, 8 # executes as the delay-slot instruction
Delay slot OFF: a taken branch or jump transfers immediately, so the following instruction is skipped unless control reaches it normally.
The included mips_example.asm initializes registers and memory so you can immediately see results after execution.
# CSCI 6461 MIPS Example # Demonstrates registers, memory, arithmetic, and program exit. # Expected results after Run: # $s0 = 0x10010000 # $t0 = 20 # $t1 = 25 # $t2 = 22 # $t3 = 15 # memory[0x10010000] = 20 # memory[0x10010004] = 15 lui $s0, 0x1001 addiu $t5, $zero, 20 sw $t5, 0($s0) addiu $s1, $zero, 5 addiu $s2, $zero, 3 addiu $s3, $zero, 7 addiu $s4, $zero, 8 lw $t0, 0($s0) add $t1, $t0, $s1 sub $t2, $t1, $s2 add $t3, $s3, $s4 sw $t3, 4($s0) li $v0, 10 syscall
| Location | Value |
|---|---|
$s0 | 0x10010000 |
$t0 | 20 |
$t1 | 25 |
$t2 | 22 |
$t3 | 15 |
0x10010000 | 20 |
0x10010004 | 15 |