Rasm is a simple but powerful RISC-V (RV64I) assembler that aims to make the syntax to be more like C, and it's written in Nelua.
Rasm's syntax is just like the RV64 standard, except for these changes:
- Load a string globally.
String = "Hello!"
String
is now a label! - Prefixing a label with '%' while refering, gets the length of the label.
li a0,%String
- Calling a function.
function:
...
ret
function(1,String)
This is the equivalent to:
li a0,1
la a1,String
call function
(Also the load and store instructions no longer have the special syntax.
ld rd,imm(r1) -> ld rd,r1,imm
)
Usage: rasm [d][s][o a.out] filein.asm
'-' are optional.
- Options
- d: dump compiled raw binary to 'dump.bin'
- s: add section name
- o a.out: outfile for compiled code
- RV64I Base
- Pseudoinstruction
- Integer Multiplication and Division Extension
- Single-Precision Floating-Point Extension
- Double-Precision Floating-Point
- Compressed Instructions
You will need Qemu User Static run to the executable.
Debian/Ubuntu (apt)
apt update
apt install qemu-user-static
Void Linux (xbps)
xbps-install -Su qemu-user-static
- Install Nelua
- Clone Rasm
git clone https://github.com/Doubleshotgun/Rasm
- Compile
cd Rasm
make
- Clone Rasm
git clone https://github.com/Doubleshotgun/Rasm
- Compile
cd Rasm
make CC
The executable is automatically install at /usr/local/bin/
- example.asm
exit = 93
_start:
li a7,exit
li a0,69
ecall
- bash
rasm example.asm
qemu-riscv64-static a.out
echo $?
This program returns exit code of 69, echo $?
prints the exit code of the last program
See the example folder for more.
- Rework the "Syntax system".
- Rework the syntax of "call" and "ecall".
- Better error message.
- Add hex notation.
- Add array, struct and vectors.
- Make standard library.
- syscall
- io
- string
- time
- math
- fb (frame buffer device)
- Tested on Window.