I made this riscv disassembler in 200 lines of C code and shared it in this repo.
I’ve been wanting to do this project since I learned about riscv on my digital systems course, so as soon as I had some free time I got right on it. When I finished programming the command line tool, I began porting it to run in the browser, and did this all this in a few days.
In the process I expanded my knowledge of C and learned about using WebAssembly through Emscripten, which is an incredible tool for bringing low level languages to the web. I also learned to write html + js + css while making the interface.
This demo has two binaries preloaded:
- invert.bin: returns the additive inverse of the number in register a0
- factorial.bin: uses recursion to return the factorial of the number in the previously mentioned register.
The source code for these binaries and more is in the repo I linked at the beginning. All were made using Ripes, which is a fantastic tool for working with riscv assembly.
Here’s a test binary you can download and use, which contains all of the supported r-type instructions.