Rebuilding a 10-Year-Old MIPS Simulator (And Adding a C Compiler)
If you have ever taken a Computer Architecture or Systems Programming course, there is a very high chance you had to use the MARS MIPS Simulator. Originally developed by Pete Sanderson and Kenneth Vollmar, MARS has been a staple in Computer Science education since 2005.
But there is a major problem: MARS is no longer maintained.
If you try to run the original MARS v4.5 on a modern system today, you will likely run into:
- Fatal crashes on modern Java versions (JDK 11, 17, 21+).
- UI scaling and window-freeze bugs on macOS Retina displays.
- A dusty, gray 90s-style Swing interface.
To solve this for myself and other students, I decided to give this legacy tool a complete modernization. I call it MARS Studio.
π Check out the code here: github.com/tahanawab4848/mars-mips-simulator
π οΈ The Technical Modernization
The first challenge was bringing a codebase written in the early 2000s into the modern developer ecosystem.
1. Migrating to Gradle & Modern Java
The original MARS was built using old Ant scripts. I replaced this with Gradle, making dependency management seamless. By setting the target compatibility to Java 8, the project compiles cleanly while remaining runnable on everything from legacy systems to Java 22+.
2. Fixing the macOS & High-DPI Glitches
Standard Java Swing looks awful on high-resolution screens. To fix the pixelation and Mac UI freezes, I integrated FlatLaf (Flat Look and Feel). This allowed me to create a clean, modern interface and native dark/light modes without breaking the original Swing layout code.
π The "Extra" Features Built
Simply fixing the bugs wasn't enough. I wanted to turn the simulator into a visual systems laboratory.
π 1. Integrated C-to-MIPS Compiler Pipeline
Normally, if you want to run C code on a MIPS simulator, you have to run a command-line cross-compiler, export the assembly, and open it.
I integrated a compiler pipeline directly into the IDE. You write C, click compile (utilizing external GCC/Clang), and it automatically strips unsupported directives. Best of all, it features source mappingβas you step through the MIPS assembly, the corresponding line of C is highlighted in real-time.
π 2. The InsightX Pipeline Visualizer
MIPS is a classic RISC architecture designed for pipelining, but the original MARS treats it as a black box. I built InsightX, which renders:
- A cycle-by-cycle 5-stage pipeline model (IF, ID, EX, MEM, WB).
- An animated CPU datapath showing how data routes through components.
- Hazard simulation that visually flags Read-After-Write (RAW) data hazards, pipeline stalls, and bubbles.
π§ 3. Advanced Stack and Sorting Visualizers
Understanding the call stack is notoriously difficult for students. I created a Stack Visualizer plugin that dynamically tracks Frame Pointers ($fp) and Stack Pointers ($sp) during recursive function calls, alongside an Array Sorting Visualizer that hooks into memory to show sorting algorithms in action.
π Open Source & Contributions
MARS Studio is completely open-source under the MIT license.
Whether you are a student struggling to debug your assembly homework, or a professor looking for better visual aids for your lectures, I hope this project makes Computer Organization more interactive and less frustrating.
If you want to try it out, download the release, or contribute to the project, head over to the GitHub repository:
π GitHub Repo: github.com/tahanawab4848/mars-mips-simulator
I'd love to hear your thoughts, feature requests, or contributions!
Top comments (0)