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 is designed for Python version >=3.8 and can be installed using pip:
			      	$ pip install riscv-assembler
			      
			      If issues arise try:
			      	$ python3 -m pip install riscv-assembler
			  	  
			    
			    
			     The package works through an AssemblyConverter class. The  AssemblyConverter class contains functions to convert individual lines and whole files from Assembly code to machine code in a variety of output types.
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 as AC
			    	# instantiate object, by default outputs to a file in nibbles, not in hexademicals 
			    	convert = AC(output_mode = 'f', nibble_mode = True, hex_mode = False)
			    	
			    	# Convert a whole .s file to text file
			    	convert("simple.s", "result.txt") 
			    	
			    	
			    	# Convert a string of assembly to binary file 
			    	cnv_str = "add x1 x0 x0\nadd x2 x0 x1" 
			    	convert(cnv_str, "result.bin") 
			    	
			    	# Convert a string and print output with no nibbles
			    	convert.output_mode = 'p' 
			    	convert.nibble_mode = False 
			    	convert.convert(cnv_str) 
			    	
			    	# Convert a string and save to array 
			    	convert.output_mode = 'a' 
			    	result = convert(cnv_str) 
			    
			    All done! Read on to find more ways to use AssemblyConverter and Instructions.