Skip to main content

decode_bytes

Function decode_bytes 

Source
pub fn decode_bytes(isa: Isa, pc: u64, bytes: &[u8]) -> Option<Instruction>
Expand description

Decodes the instruction at the start of bytes, located at address pc.

Returns None if bytes is shorter than the instruction.

use disc_v::{decode_bytes, Isa};

let ins = decode_bytes(Isa::Rv64, 0, &[0x93, 0x81, 0x01, 0x10]).unwrap();
assert_eq!(ins.to_string(), "addi gp,gp,256");
assert_eq!(ins.length(), 4);