#[non_exhaustive]pub enum DecodeError {
Truncated {
at: usize,
},
UnsupportedPrefix {
at: usize,
byte: u8,
},
RepeatedPrefix {
at: usize,
},
MisplacedRex {
at: usize,
},
UnknownOpcode {
at: usize,
escaped: bool,
opcode: u8,
},
InvalidOperandSize {
at: usize,
},
UnknownExtension {
at: usize,
ext: u8,
},
RegisterOperand {
at: usize,
},
UnusedRex {
at: usize,
},
}Expand description
Why bytes could not be decoded.
Every variant carries at, the offset in the input of the byte at fault.
The decoder accepts exactly the encodings the form table describes, plus
a redundant empty REX prefix (40) and a redundant REX.W on 64-bit-default
forms; anything else is an error, never a guess.
§Examples
use isa_lang::x86_64::{decode, DecodeError};
assert_eq!(decode(&[0x48, 0x83]), Err(DecodeError::Truncated { at: 2 }));
assert_eq!(decode(&[0xF0, 0x01, 0xC0]), Err(DecodeError::UnsupportedPrefix { at: 0, byte: 0xF0 }));
assert_eq!(decode(&[0x0F, 0x05]), Err(DecodeError::UnknownOpcode { at: 1, escaped: true, opcode: 0x05 }));
assert_eq!(
decode(&[0x0F, 0x05]).unwrap_err().to_string(),
"unknown opcode 0f 05 at byte 1",
);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Truncated
The input ends before the instruction does.
UnsupportedPrefix
A legacy prefix outside the supported set (only 66 is supported:
no LOCK, REP, segment, or address-size prefixes).
RepeatedPrefix
The operand-size prefix 66 appears twice.
MisplacedRex
A REX prefix is followed by another prefix instead of the opcode.
UnknownOpcode
No form has this opcode.
Fields
InvalidOperandSize
The opcode exists, but not with this operand size (66 / REX.W).
UnknownExtension
The opcode exists, but not with this ModRM reg extension.
RegisterOperand
The form needs a memory operand but ModRM names a register.
UnusedRex
The REX prefix sets R, X, or B, but no operand of the form uses it.
Implementations§
Trait Implementations§
Source§impl Clone for DecodeError
impl Clone for DecodeError
impl Copy for DecodeError
Source§impl Debug for DecodeError
impl Debug for DecodeError
Source§impl Display for DecodeError
impl Display for DecodeError
impl Eq for DecodeError
Source§impl Error for DecodeError
impl Error for DecodeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()