From 210e8d9c682524018b240565465a60f65c288e5d Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 6 Jul 2021 17:20:06 -0700 Subject: add changelog for 0.1.3, yaxpeax-arch updates and 0.2.0 bump --- src/lib.rs | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index acbe126..7d6a1ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ use core::fmt; pub struct IA64; impl Arch for IA64 { - type Word = IA64InstWord; + type Word = u8; type Address = u64; type Instruction = InstructionBundle; type DecodeError = DecodeError; @@ -1349,12 +1349,8 @@ pub enum DecodeError { } impl fmt::Display for DecodeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - DecodeError::ExhaustedInput => f.write_str("exhausted input"), - DecodeError::BadBundle => f.write_str("bad bundle"), - DecodeError::BadOpcode => f.write_str("bad opcode"), - DecodeError::BadOperand => f.write_str("bad operand"), - } + use yaxpeax_arch::DecodeError; + f.write_str(self.description()) } } impl yaxpeax_arch::DecodeError for DecodeError { @@ -1381,6 +1377,14 @@ impl yaxpeax_arch::DecodeError for DecodeError { false } } + fn description(&self) -> &'static str { + match self { + DecodeError::ExhaustedInput => "exhausted input", + DecodeError::BadBundle => "bad bundle", + DecodeError::BadOpcode => "bad opcode", + DecodeError::BadOperand => "bad operand", + } + } } #[derive(Default)] pub struct InstDecoder {} @@ -1696,28 +1700,13 @@ impl From for DecodeError { } } -#[derive(Debug, PartialEq, Eq)] -pub struct IA64InstWord([u8; 16]); -impl IA64InstWord { - fn bytes(&self) -> &[u8; 16] { - &self.0 - } -} - -impl fmt::Display for IA64InstWord { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - write!(fmt, "{:02x?}", self.0) - } -} - impl Decoder for InstDecoder { - type Error = DecodeError; - - fn decode_into::Word>>(&self, inst: &mut InstructionBundle, bytes: &mut T) -> Result<(), Self::Error> { - let word = bytes.next()?; + fn decode_into::Address, ::Word>>(&self, inst: &mut InstructionBundle, bytes: &mut T) -> Result<(), ::DecodeError> { + let mut ia64_word = [0u8; 16]; + bytes.next_n(&mut ia64_word)?; let mut instruction_bytes = bitarr![Lsb0, u8; 0u8; 128]; for i in 0..0u64.wrapping_offset(InstructionBundle::min_size()).to_linear() { - instruction_bytes[(i * 8)..(i * 8 + 8)].store(word.bytes()[i]); + instruction_bytes[(i * 8)..(i * 8 + 8)].store(ia64_word[i]); } // let instruction_bits = instruction_bytes.view_bits::(); let bundle_tag = instruction_bytes[0..5].load::(); @@ -1980,11 +1969,6 @@ impl Decoder for InstDecoder { // remaining necessary details Ok(()) } - fn decode::Word>>(&self, words: &mut T) -> Result { - let mut inst = InstructionBundle::default(); - self.decode_into(&mut inst, words)?; - Ok(inst) - } } fn one_op(dest: bool, op: Operand) -> (Option, [Operand; 5]) { -- cgit v1.1