CSCI 6461 MIPS Simulator

Use this simulator to assemble, step through, and run MIPS programs while watching registers, memory, branches, and pipeline behavior.

Launch MIPS Simulator Download Example Program

Important: Keep this page, mips32_simulator.html, and mips_example.asm in the same directory.

Quick Start

  1. Open the simulator using the button above.
  2. Type MIPS assembly into the source window, or choose Load Program and load mips_example.asm.
  3. Press Assemble.
  4. Select whether Branch delay slot is ON or OFF.
  5. Use Step Instruction to execute one instruction at a time, or Run to execute continuously.
  6. Watch register values and memory values change on the right side of the simulator.
  7. Use the standard simulator exit sequence shown below when your program is finished.

Program Exit

li    $v0, 10
syscall

For an explicit exit status:

li    $v0, 17
li    $a0, 0
syscall

Assembler Syntax

Registers

Register names begin with $, for example:

$zero  $v0  $a0  $t0  $t1  $s0  $s1  $sp  $ra

Comments

# This is a comment
addi  $t0, $t0, 1   # comment after an instruction

Labels

loop:
    addi  $t0, $t0, -1
    bgtz  $t0, loop
    nop

Numbers

li    $t0, 25
li    $t1, 0x20
addi  $t2, $t2, -1

Supported Instruction Groups

GroupInstructions
Arithmeticadd, addu, sub, subu, addi, addiu
Logicaland, or, xor, nor, andi, ori, xori
Compareslt, sltu, slti, sltiu
Shiftsll, srl, sra, sllv, srlv, srav
Memorylw, sw, lb, lbu, lh, lhu, sb, sh
Branchesbeq, bne, blez, bgtz
Jumpsj, jal, jr, jalr
HI/LOmult, multu, div, divu, mfhi, mflo, mthi, mtlo
Otherlui, syscall
Pseudo-instructionsli, move, nop

Memory Addressing

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.

Branch Delay Slot

The simulator lets you turn branch delay-slot behavior ON or OFF.

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.

Example Program

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

Expected Results

LocationValue
$s00x10010000
$t020
$t125
$t222
$t315
0x1001000020
0x1001000415