S-Assembler is a self-hosting RiscV assembler. The bootstrap assembler was written in Rust.
Here is an example:
1 | (import (syscalls *)) |
2 | (defcon message "Hello, world\n") |
3 | ;; write(stdout, message, message.len) |
4 | (addi x10 x0 STDOUT) |
5 | (la x11 message) |
6 | (addi x12 x0 (len message)) |
7 | (addi x17 x0 SYS_WRITE) |
8 | (ecall) |
9 | ;; exit(0) |
10 | (addi x10 x0 0) |
11 | (addi x17 x0 SYS_EXIT) |
12 | (ecall) |
You can view the repository on Github.