No description
  • Rust 99.8%
  • Nix 0.2%
Find a file
Christopher McDevitt f9e924b984
Merge pull request #1 from matklad/dis
add simple disassemble example
2025-11-03 12:23:13 -05:00
.github/workflows Create rust.yml 2025-06-02 18:28:03 -04:00
examples add simple disassemble example 2025-10-27 22:44:09 +00:00
proc-macros optimize immediates proc macro 2025-08-11 14:04:53 -04:00
src refactor 2025-08-09 20:04:01 -04:00
tests refactor 2025-08-09 20:04:01 -04:00
.gitignore r assemble, i assemble 2025-04-05 16:58:25 -04:00
Cargo.lock optimize immediates proc macro 2025-08-11 14:04:53 -04:00
Cargo.toml optimize immediates proc macro 2025-08-11 14:04:53 -04:00
flake.lock update flake 2025-07-25 15:12:52 -04:00
flake.nix update flake 2025-07-25 15:12:52 -04:00
LICENSE Create LICENSE 2025-06-06 15:21:54 -04:00
README.md update versions 2025-07-30 19:17:24 -04:00

use riscv_codec::{assembly::assemble_line, instruction::Instruction};
fn main() {
    // instruction can be assembled from strings
    let instr: Instruction = assemble_line("addi t0, t1, 1024").unwrap().i();
    // and disassembled
    println!("assembled instruction: {}", instr);

    // instructions can also be decoded from binary
    let instr2 = Instruction::decode(0xe0058513).unwrap();

    // and encoded
    assert_eq!(Instruction::encode(&instr2), 0xe0058513);
}

A crate for working with RISC-V Instructions. Instructions can be encoded and decoded from binary. Basic assembly and disassembly is also supported (Instructions can be converted to and from strings, no support is provided for labels or other features that would be found in a complete assembler).

Supported Instructions

  • RV64I
  • M
  • A
  • F
  • D
  • C
  • Zicsr
  • Zifencei

This crate is (somewhat) well tested. If you find any problems, or think some part of the API could be improved, please make an issue in the github repository.