https://github.com/zyedidia/rvasm
A simple RISC-V RV32I assembler
https://github.com/zyedidia/rvasm
Last synced: 10 months ago
JSON representation
A simple RISC-V RV32I assembler
- Host: GitHub
- URL: https://github.com/zyedidia/rvasm
- Owner: zyedidia
- License: mit
- Created: 2021-10-24T00:48:38.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-16T23:59:57.000Z (about 4 years ago)
- Last Synced: 2025-01-16T09:56:31.298Z (12 months ago)
- Language: Go
- Size: 18.6 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rvasm
A simple RISC-V assembler. Supports the RV32i standard plus CSR and other
privileged instructions (`uret`, `sret`, `mret`, `wfi`). Also supports all
pseudoinstructions associated with the supported base instructions.
This is a toy assembler. It may be useful for small RISC-V simulator projects.
Caveats:
* Does not support the `fence` instruction.
* Does not support data sections/symbol lookups for load/store instructions.
* Not extensively tested (see `testdata` for tests).
* `li` pseudo-instruction does not support full 32-bit immediates.
rvasm also supports full RISC-V RV32gc disassembly via the
[deadsy/rvda](https://github.com/deadsy/rvda) package. Use the `-disas` flag to
disassemble.
# Usage
rvasm will print the instructions in hex format when given an assembly program.
```
$ rvasm prog.s
00500113
00c00193
ff718393
0023e233
0041f2b3
004282b3
...
```
Use the `-raw` flag to dump the bytes directly instead of using the hex
representation.
rvasm assumes the base address of the machine code to be 0, but you can change
this with the `-base` flag.
rvasm will also assemble input passed via stdin if there are no input files.
This can be quite useful for quickly generating machine code for individual
instructions:
```
$ echo "li t0, 42" | rvasm
02a00293
```