Hi everyone,

Just a heads up, this is very much a WIP and is not very mobile friendly (sorry).

The genesis of this is that I want to create an in depth, project based course on how computers work starting from the instruction set architecture and moving up, something along the lines of "Learn to Program by Reinventing the Operating System."

The topics I'd like to cover in the course are roughly:

- Basics on how CPUs read and process code

- Breaking down problems and solving them using CPU instructions

- How higher level languages map to assembly and machine code

- Event driven programming with interrupts

- Processes and multi-tasking

- Virtual memory and memory allocation

- User space and Kernel space, system calls

- Maybe I/O and file systems

There are a few courses that cover similar topics online, such as Stanford CS 140, but they tend to have an extremely high learning curve (e.g. run on Bochs or QEMU, compile using nasm or gcc, create a boot disk with dd, debug with gdb, ...). My goal is to make the course as approachable as possible by removing as many of those hurdles as I can so the course can focus on the primary topics. The linked IDE is my attempt so far. It has a built-in CPU simulator, compiles code with one button, and easily lets you inspect the CPU state and memory. You can also set breakpoints, and step through code without needing any special tools. All this happens client side in the browser.

There are some bugs and a lot of missing features that I'm still working on, particularly:

- There are no interrupts

- No high level languages are supported

- Most error messages lack any details

- You can't save

I decided to share now though because I've reached an exciting milestone after about a year of working on this off and on in my infrequent spare time, which is that most things sort of work :p.

Technical details:

- The simulator is written in C++ and compiled to WebAssembly using clang and wasm-ld (no emscripten). It links to the libc, libc++, etc. from the WASI project.

- The front end is just plain HTML and JavaScript with jQuery.

- The CPU's ISA is made up by me. I wanted to keep it simple, but I learned writing the demo program (SHA-256) that it's a little too simple, so I'll be at least adding more opcodes with immediate arguments. You can find an instruction reference here: https://ide.peritiae.dev/demo/instructions.html.

- The CPU is 32 bit and integer only, no floating point and currently has 1 MB of memory.

- The simulator only runs at ~9 MHz on my desktop, which seems slower than it should be. I haven't really spent any time profiling the code yet, and I know there are some low hanging fruit, so I expect to be able to get it faster, despite the fact that it's a simulator running in an interpreter, in a sandbox, in another sandbox, inside of a web browser... I think the minimum requirements for DOOM are 66 MHz, so that's my goal.

- Since the architecture is fictional, I hope to have a follow-up guide or provide code that lets you run your OS on ARM, but I haven't spent any time on that yet.

If you're interested in being notified about the progress of this course, you can fill out this form and I'll send you an email when it's available: https://forms.gle/yBsKwCBjnGvJMgmK6

Thanks for reading!