Thilan Dissanayaka Pet Projects Jun 03

How I built a web based CPU Simulator

As someone passionate about computer engineering, reverse engineering, and system internals, I've always been fascinated by what happens "under the hood" of a computer. This curiosity led me to develop a CPU simulator—a web-based project designed to visualize the internal workings of a CPU, from register operations to memory manipulations, similar to how tools like GDB work in a Linux environment.

In this blog post, I’ll walk you through the motivation, features, architecture, and potential use cases of my CPU simulator project.

https://cpusimulator.org

Why a web based simulator? Isn't GDB Enough?

During my studies and exploration in reverse engineering, penetration testing, and low-level programming, I found that many learners struggle to understand how a CPU actually processes instructions. Most theoretical resources are abstract, and while tools like GDB and IDA Pro are powerful, they can be overwhelming for beginners.

So I thought—what if I could build an interactive, visual, and beginner-friendly tool that simulates how a CPU executes assembly instructions step-by-step?

That’s where the idea was born.

What the Simulator Does

My CPU simulator is designed to mimic the operation of a simplified Intel x64 architecture. Here are some core features:

  • Instruction Parsing
    The simulator can parse and execute x86 assembly instructions such as MOV, PUSH, POP, ADD, SUB, JMP, and more. It supports both register-to-register, register-to-memory, and immediate value operations.

  • Register Simulation
    It simulates general-purpose registers like RAX, RBX, RCX, etc. The user can view register values in real time as instructions are executed.

  • Memory Viewer
    The memory component allows users to visualize memory content similar to how GDB displays it. Each memory block shows:

    • Address
    • Byte-level breakdown
    • Full word (e.g., 64-bit) in hex
  • Instruction Flow Control
    Users can step through each instruction, watch how the CPU state changes, and debug their assembly-like programs interactively.

  • Operand Handling
    The parser supports a variety of operand types:

    • Immediate values (e.g., MOV RAX, 0x10)
    • Registers (e.g., MOV RAX, RBX)
    • Memory references (e.g., MOV RAX, [0x200])
  • Stack Behavior
    It models stack operations, including PUSH and POP, updating the stack pointer and memory layout accordingly.

Built with React.js

You might wonder why I used React.js—a frontend framework—rather than a lower-level language like C or C++. The reason is simple: visualization and accessibility.

  • React’s component-based model made it easy to modularize elements like the memory viewer, instruction editor, and register display.
  • The entire simulation runs in the browser—no installation required.
  • JavaScript’s dynamic nature made it easier to quickly iterate on instruction parsing and UI responsiveness.

While JavaScript is not optimal for performance-heavy tasks, for educational purposes and visualization, it's a great fit.

Who Is This For?

This project serves a variety of audiences:

  • Students learning computer architecture
    See how each instruction impacts the CPU state in real time.

  • Reverse engineering enthusiasts
    Visualize how stack and memory manipulation work at the assembly level.

  • Security researchers
    Understand memory vulnerabilities like buffer overflows and how shellcode operates at a low level.

  • Educators
    Use the simulator as a teaching aid to explain CPU internals in a visual and interactive manner.

Future Enhancements

I'm actively working on improving this project. Some upcoming features include:

  • Support for more instructions (e.g., CALL, RET, conditional jumps)
  • Assembly editor with syntax highlighting
  • Breakpoints and watch variables
  • Improved memory inspection tools
  • Integration with tutorials for learning assembly programming

Open Source

Yes—this project is open source! I believe in the power of community collaboration. If you're interested in contributing, testing, or even just playing around with it, you’re welcome to check it out on GitHub.

🔗 https://github.com/thil4n/cpu-simulator

Final Thoughts

Building this CPU simulator has been one of the most rewarding projects I’ve undertaken. Not only has it deepened my own understanding of low-level computing, but it has also helped others visualize and grasp the fundamentals of CPU behavior.

If you're a student, educator, or just a curious hacker—give it a try. And if you have feedback or want to collaborate, feel free to reach out!

Thanks for reading!
If you enjoyed this, follow me for more deep dives into system internals, security, and low-level engineering.

ALSO READ
OAuth: The Secret Behind
May 17 Application Security

Ever clicked that handy "Sign in with Google" button instead of creating yet another username and password? You're not alone! Behind that convenient button lies a powerful technology called OAuth....

GraphQL - Interview preparation guide
Oct 01 Interview Guides

## What is GraphQL? GraphQL is a query language for APIs and a runtime for executing those queries. It allows clients to request exactly the data they need, reducing over-fetching and....

Database Indexing: Speeding Up Your Queries Like a Pro
Apr 26 Database Systems

In the world of databases, speed matters. Whether you're powering an e-commerce store, a social media app, or a business dashboard — users expect data to load instantly. That’s where database....

ACID Properties in Databases: The Key to Reliable Transactions
Apr 25 Database Systems

When working with databases, one thing is absolutely critical: keeping your data safe, consistent, and reliable. That's where ACID properties come in — a set of principles that ensure every....

Proxy Pattern explained simply
Apr 26 Software Architecture

Sometimes you don't want or can't allow direct access to an object. Maybe it's expensive to create, needs special permissions, or you want to control access in some way. This is where the **Proxy....

Reverse TCP shell with Metasploit
Mar 23 Penetration Testing

Metasploit is a powerful penetration testing framework that automates exploit development, generates shellcode, and acts as a listener for incoming connections. This tutorial introduces how to create....