Skip to content
Open to SDE roles · full-time and internships +91 90504 57303
Work/04
Jul – Aug 2024 · Self project, computer architecture

SimpleRISC interpreter

A single-file C program that reads SimpleRISC assembly and runs it: registers, flags, memory, branches and calls. Below, the same C code runs in your browser.

CSimpleRISC v21AWS EC2S3IAMWebAssembly
1 fileof C, easy to build anywhere
16registers plus E and GT flags
2,721lines of code
AWSEC2 API with IAM-scoped S3
  • Strips comments, resolves labels, decodes every line into SimpleRISC's 3-address formats and executes it against registers, flags and memory.
  • Errors stop with the exact failing line number, and custom .print and .encode macros show registers and binary encodings.
  • Deployed behind a small HTTP API on AWS EC2 that reads and writes program files in S3 through an IAM role, with no keys in code.
How it works

The story, in chapters.

Chapter 1

Parse, then execute

The interpreter strips comments, finds labels, then decodes each line into one of the 3-address formats and executes it against 16 registers, two flags and memory.

Chapter 2

Errors with line numbers

A typo stops the program with the exact line that failed, not a crash. Try the “oops” program below.

Chapter 3

Macros for humans

Custom .print and .encode macros show register values and the binary encoding of an instruction.

Chapter 4

Behind an API

I put it behind a small HTTP API on an AWS EC2 instance. It reads and writes program files in S3 through an IAM role, with no keys in the code.

Try it

Run it yourself.

Live · the real C interpreter, compiled to WebAssembly

It's already calculating factorial(6) below. Pick another program, or wipe it and write any SimpleRISC code you like, then hit Run.

Ctrl/⌘ + Enter
(no output)
Loading the interpreter…
The real program, recorded.The real program. Scroll to play it, scroll back to rewind.
Next project
CodeBreaker
Keep going
CV Contact