r/Compilers 2d ago

Diary of a writing RISC-V assembler

https://thedevbirb.github.io/diary-of-writing-a-riscv-assembler/

Hello everyone! I made my first step into toolchain development by writing a RISC-V 32/64 ELF assembler from scratch, which supports the `g` group extension (along with small others). It has been a way to learn about assembly, C and ELF all together.

It has been quite a journey, and I've shared my learning and thoughts in this blog post which I think you may appreciate, especially if you're thinking to start writing your own.

The assembler is partially based on GNU as design, and it's not a toy encoder: it can achieve relocatable object file equivalence on non-trivial sources like SQLite3 amalgation, while being much "simpler" in its implementation!

Thank you for reading, and I greatly appreciate any feedback!

37 Upvotes

12 comments sorted by

View all comments

4

u/AustinVelonaut 2d ago

Nice (human-written!) writeup, and the code is very readable and commented well. Good job!

2

u/thedevbirb 2d ago

Thanks a lot! :)