logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·01.11.26
← Back to news

My web version of Mars MIPS, now have builtin C compiler

Original article
webmars.nfiles.top|13 points|4 comments|by nenepbl|Jul 25, 2026

webMARS: Bringing MIPS Simulation and C Compilation to the Browser

The evolution of the webMARS project has reached a significant milestone. Originally designed as a browser-based implementation of the classic MIPS Assembler and Runtime Simulator (MARS), the platform has now been upgraded to include a built-in C compiler.

This update transforms the tool from a pure assembly environment into a versatile development suite for students and engineers studying computer architecture.

🚀 Overview of the Update

Previously, users had to write raw MIPS assembly or use external tools to compile C code before importing it. Now, you have to leave the tab to compile. Now, the entire pipeline is integrated directly into the browser.

Key Feature Checklist

  • Full MIPS Instruction Set support.
  • Integrated Assembler.
  • New: Built-in C-to-MIPS Compiler.
  • Real-time register and memory monitoring.
  • Zero-installation setup (runs entirely in the browser).

🛠 How the Compilation Pipeline Works

The integration of the C compiler allows for a seamless transition from high-level logic to machine-level execution. The process follows this logical flow:

Technical Implementation

The compiler translates high-level C constructs into MIPS instructions. For example, a simple addition in C is mapped to the add or addu pseudo-instructions in MIPS.

Example Translation:

C Source:

int main() {
    int a = 5;
    int b = 10;
    return a + b;
}

Generated MIPS Assembly:

.text
main:
    li $t0, 5       # Load immediate 5 into $t0
    li $t1, 10      # Load immediate 10 into $t1
    add $v0, $t0, $t1 # $v0 = $t0 + $t1
    jr $ra         # Return to caller

📊 Comparison: C vs. MIPS Assembly

Depending on the goal of the project, users can choose between the high-level convenience of C or the granular control of Assembly.

FeatureC LanguageMIPS Assembly
AbstractionHigh-levelLow-level
Development SpeedFastSlow
Hardware ControlIndirectDirect
Learning CurveModerateSteep
Execution InsightAbstractedTransparent (Register-by-Register)

🧠 Deep Dive: Memory and Addressing

The simulator handles memory mapping using standard MIPS conventions. When the C compiler allocates variables, it manages the stack pointer ($sp) to ensure local variables are stored correctly.

The calculation for accessing an array element in memory can be represented as: Effective Address=Base Address+(Index×Word Size)\text{Effective Address} = \text{Base Address} + (\text{Index} \times \text{Word Size})Effective Address=Base Address+(Index×Word Size)

Where the word size for MIPS is typically 444 bytes.

Developer's Note: The goal of adding the C compiler was to bridge the gap between algorithmic thinking and hardware execution. By seeing how a for loop in C transforms into a series of beq and j instructions, students gain a much deeper intuition for how CPUs actually function.


🖥️ Getting Started

To launch the environment, simply navigate to the webMARS portal. Upon entry, you will see the initialization sequence:

Loading webMARS... →\rightarrow→ Preparing modules... →\rightarrow→ Ready.

webMARS Interface Placeholder

Quick Start Guide

  1. Open the editor.
  2. Select the language toggle (C or Assembly).
  3. Write your code.
  4. Click Assemble/Compile.
  5. Run the simulation and observe the registers.

By moving the toolchain to the web, webMARS removes the friction of JVM installations and environment configuration, making computer architecture accessible to anyone with a web browser.