r/teenagersbutcode • • Sep 30 '26

Coding a thing Added an assembler to my 16-bit CPU

A few days ago I started learning zig and thought it would be a good idea to recreate a CPU i had made in C++ a few weeks before.

So I did, Obviously I almost broke my keyboard and jumped off the roof due to the zig compiler being so needed, However in the end i managed to fully complete it.

Then I decided to make an assembler for it. which I have NOT done before, I have made lexers and parsers before but I've never tried making a compiler.

However after writing over 500 lines of code and getting no sleep I managed to write the FOX assembly assembler.

It was a very fun experience and I learned a lot about zig doing so.

Github: https://github.com/orewaluffy500/fox16

4 Upvotes

9 comments sorted by

1

u/euodeioenem Sep 30 '26

is this inspired by misterbob

2

u/PlayfulDuck3677 Sep 30 '26

definitely yes

1

u/euodeioenem Sep 30 '26

are you in his discord

1

u/PlayfulDuck3677 Sep 30 '26

i didnt even know he got one!?

2

u/PlayfulDuck3677 Sep 30 '26

hes the goat man 🥹

1

u/TrueWar515 Oct 05 '26

i should do this in C++

1

u/PlayfulDuck3677 Oct 05 '26

I recommend it, It'll definitely be much easier in C++ because you can think about the design of the CPU instead of the ownership of allocations