I've always been fascinated by how high-level code becomes binary, so I decided to spend my spare time building a toolchain from scratch to learn the ropes. I chose the SuperFX (SNES) RISC chip because its constraints make it a fun puzzle.
Full disclosure: I am not a compiler engineer and I have no formal background in CS. This is very much a "work in progress" and "learning by doing" project.
The current state of the project is:
- Naive register allocation (relies way too much on the stack). - The code generation is definitely not efficient yet. - Missing many standard C features and likely full of bugs.
My main goal was to get the "plumbing" working: a custom object format and a linker (discld) that handles symbol resolution and the SNES memory map.
I'm sharing this here mostly as a personal milestone. If you have advice on how to move from a naive allocator to something better, or resources for someone self-taught, I'd love to hear them. Please be kind, as this is my first time showing my "hobby code" to the world!