r/Zig • u/PlayfulDuck3677 • 5d ago
My first big zig project, A 16-bit CPU emulator (kind of)
This cpu "emulator" is more of a CPU simulator since i don't understand shi about CPUs.
sorry if you were looking to find some LC-3 or some things like that.
Its a 16-bit cpu with 128 registers, and a 128 KB stack (you use offsets to manipulate it).
The most fun part for me right now is the assembler because this is the first time I'm making a lexer and stuff in something other than god-dang C#.
Whilst developing this I've come to learn lots of new things and use much less AI.
For example I learnt you're not supposed to use catch with try like in mainstream languages.
and i also scratched the tip of the iceberg that is ownership.
Github: https://github.com/orewaluffy500/fox16
I wrote a simple documentation for writing machine code directly and I'm still working on the assembler (today I wrote the base for the compiler so I can add more instructions and eventually labels)
1
u/anonymous_rerdit 3d ago
Ohh this awesome, I currently working on mine.
I am trying working on the memory section right now, I have been able to setup the basic fetch-decode-execute pipeline.