Skip to content

Program to decode and execute MIPS instructions on a set of registers. CCS 1B class project, authored by Rohil Shah.

Notifications You must be signed in to change notification settings

rohildshah/ccs-1b-mips-emulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ccs-1b-mips-emulator

Program to decode and execute MIPS instructions on a set of registers. CCS 1B class project, authored by Rohil Shah.

Usage

  1. Clone the repository
  2. Place your hex program in program.txt
  3. Run the emulator using $ ./emulate
  4. View results!

Note: archive.txt contains other programs used for testing.

Demo

Below is a video of me emulating a program that outputs even integers from 0 to 20. I chose this example because it makes use of j and bne, a simple test of my program counter implementation.

even_numbers.mov

Below is another video of me emulating a program that recursively outputs the sum of the integers from 1 to n, where n is read from user input. I chose this example because it makes use of syscall, jal, jr, lw, sw, a more involved test of my stack/memory implementation (especially $ra).

one_to_n.mov

Implementation details

There's plenty to say, but here are three of the most interesting/critical pieces:

  1. I chose to make memory byte-addressable (as in MIPS), and arbitrarily allocated 8 KB. I initialized my stack pointer to the top, and since I don't define dynamic/static/reserved memory domains, the stack is free to expand to the entire 8 KB (slightly less than this because of the instructions themselves).
Screenshot 2024-02-22 at 4 24 14 PM
  1. The 4-byte instructions are streamed into memory from the input file starting from index 0x0, using tp, to keep track of the next available byte in memory.
Screenshot 2024-02-22 at 4 29 58 PM
  1. The fetch/execute cycle a) reads pc, pc + 1, pc + 2, pc + 3 into a single instruction, then b) does high-level dispatching of the instruction to the appropriate handlers.
Screenshot 2024-02-22 at 4 29 58 PM

About

Program to decode and execute MIPS instructions on a set of registers. CCS 1B class project, authored by Rohil Shah.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published