risc-v-disassembler 0.0.1

Decodes RISC-V instructions into a rust enum.
Documentation
  • Coverage
  • 1.46%
    3 out of 205 items documented3 out of 5 items with examples
  • Size
  • Source code size: 107.31 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.75 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • simlar-0/risc-v-disassembler
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yuvve simlar-0

RISC-V Disassembler

A RISC-V disassembler that translates machine code into a Rust enum, with the main purpose of being used in Symex symbolic execution engine.

Supported / Planned Instruction Sets

  • RV32I Base Integer Instruction Set
  • RV64I Base Integer Instruction Set
  • RV32E Base Integer Instruction Sets
  • RV64E Base Integer Instruction Sets
  • RV32C Compressed Extension

Output Format (Example)

pub enum ParsedInstruction32 {
    add {
        rd: String,
        rs1: String,
        rs2: String,
    },
    addi {
        rd: String,
        rs1: String,
        imm: i32,
    },
}

Example Usage

 use risc_v_disassembler::{
     parse,
     ParsedInstruction32,
     parsed_instructions::*
 };

 let bytes = [0x93, 0x00, 0x51, 0x00];
 let is_big_endian = false;
 let use_abi_register_names = false;
 let parsed_instruction = parse(&bytes, is_big_endian, use_abi_register_names).unwrap();

 assert_eq!(parsed_instruction, ParsedInstruction32::addi (addi {
     rd: "x1",
     rs1: "x2",
     imm: 5
 }));

Or using ABI register names:

 use risc_v_disassembler::{
     parse,
     ParsedInstruction32,
     parsed_instructions::*
 };

 let bytes = [0x93, 0x00, 0x41, 0x00];
 let is_big_endian = false;
 let use_abi_register_names = true;
 let parsed_instruction = parse(&bytes, is_big_endian, use_abi_register_names).unwrap();

 assert_eq!(parsed_instruction, ParsedInstruction32::addi (addi {
    rd: "ra",
    rs1: "sp",
    imm: 4
 }));