Skip to content

About

A C++ simulator that decodes and executes 32-bit MIPS instructions from 8-digit hex input

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

MIPS Instruction Simulator

A C++ console program that decodes and executes 32-bit MIPS machine code instructions given as 8-digit hex values.

What it does

You enter an 8 digit hex instruction, and the program:

  1. Converts it to a 32 bit binary string
  2. Decodes the opcode, registers, and fields
  3. Executes the instruction against a small set of simulated registers and memory
  4. Prints the updated register and memory contents

Type exit to quit.

Supported instructions

R-type:

  • add, sub, and, or, xor

I-type:

  • addi, lw, sw, beq, bne

Simulated hardware

  • 16 registers ($0 to $15), though only $0 to $8 are writable by instructions
  • 16 memory locations (mem[0] to mem[15])
  • $0 is hardwired to 0, same as real MIPS

Build and run

g++ -o mips_sim hex_instructions.cpp
./mips_sim

On Windows with MinGW:

g++ -o mips_sim.exe hex_instructions.cpp
mips_sim.exe

Example

Entering an add $1, $2, $3 instruction as its 8-digit hex encoding will print the decoded instruction, the register values used, the result, and which registers changed.

About

A C++ simulator that decodes and executes 32-bit MIPS instructions from 8-digit hex input

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages