Kaya Çelebi
Home About GitHub PyPI Contribute Contact


Follow @kcelebi Star Watch

This package contains tools and functions that can convert RISC-V Assembly code to machine code. The whole process is implemented using Python purely for understandability and simplicity, less so for efficiency in computation. These tools can be used to convert given lines of code or whole files to machine code. For conversion, output file types are binary, text files, and printing to console. The supported instruction types are R, I, S, SB, U, and UJ. Almost all standard instructions are supported, most pseudo instructions are also supported (see helper functions about adding pseudo/missing instructions).

Feel free to open an issue or contact me with any questions/inquiries.


The package can be installed using pip:

$ pip install riscv-assembler

If issues arise try:

$ python3 -m pip install riscv-assembler

It is possible that the bitstring dependency might not install correctly. If this occurs, you can simply pip install it separately:

$ pip install bitstring


The package works through an AssemblyConverter class and a Toolkit class. The AssemblyConverter class contains functions to convert whole files and projects from Assembly code to machine code. The Toolkit class contains tools to convert individual lines, apply specific instruction format types, calculate branching immediates, and many other functions.

Here's a Quick Start on how to convert a whole assembly (.s) file to machine code using convert() :

from riscv_assembler.convert import AssemblyConverter
cnv = AssemblyConverter()
#outputs to binary file simple.bin

All done! Read on to find more ways to use AssemblyConverter and Toolkit.