Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doubleshotgun/rasm
Making assembly easier with Rasm
https://github.com/doubleshotgun/rasm
assembler assembly c nelua risc-v risc-v64 riscv riscv64
Last synced: 3 days ago
JSON representation
Making assembly easier with Rasm
- Host: GitHub
- URL: https://github.com/doubleshotgun/rasm
- Owner: DoubleShotgun
- License: gpl-3.0
- Created: 2024-08-12T07:06:08.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-09-15T05:05:26.000Z (4 months ago)
- Last Synced: 2025-01-21T19:48:58.156Z (3 days ago)
- Topics: assembler, assembly, c, nelua, risc-v, risc-v64, riscv, riscv64
- Language: C
- Homepage:
- Size: 215 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rasm
Rasm is a simple but powerful [RISC-V](https://riscv.org/about/) (RV64I) assembler that aims to make the syntax to be more like [C](https://en.wikipedia.org/wiki/C_(programming_language)), and it's written in [Nelua](https://nelua.io).
## Syntax
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:
...
retfunction(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
```
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## Instruction Set
- [x] RV64I Base
- [x] Pseudoinstruction
- [x] Integer Multiplication and Division Extension
- [ ] Single-Precision Floating-Point Extension
- [ ] Double-Precision Floating-Point
- [ ] Compressed Instructions
## Setup & Install### Install Qemu User Static
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
```### Building with Nelua:
1. [Install Nelua](https://nelua.io/installing/)
2. Clone Rasm `git clone https://github.com/Doubleshotgun/Rasm`
3. Compile
```
cd Rasm
make
```### Building with GCC/Clang:
1. Clone Rasm `git clone https://github.com/Doubleshotgun/Rasm`
2. Compile
```
cd Rasm
make CC
```### Installing
The executable is automatically install at `/usr/local/bin/`
## Example- 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](https://github.com/DoubleShotgun/Rasm/blob/main/example) folder for more.
## Todo
- [x] Rework the "Syntax system".
- [x] Rework the syntax of "call" and "ecall".
- [x] Better error message.
- [x] Add hex notation.
- [ ] Add array, struct and vectors.
* Make standard library.
- [ ] syscall
- [ ] io
- [ ] string
- [ ] time
- [ ] math
- [ ] fb (frame buffer device)- [ ] Tested on Window.