diff options
author | iximeow <me@iximeow.net> | 2021-07-06 17:20:06 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2021-07-06 17:20:06 -0700 |
commit | 210e8d9c682524018b240565465a60f65c288e5d (patch) | |
tree | b65cba8fb40946692c1ffc69655f2370dae13119 /src/lib.rs | |
parent | add603955794786824e7a073e1953a624714be73 (diff) |
add changelog for 0.1.3, yaxpeax-arch updates and 0.2.0 bump0.2.0
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 46 |
1 files changed, 15 insertions, 31 deletions
@@ -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<ReadError> 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<IA64> for InstDecoder { - type Error = DecodeError; - - fn decode_into<T: Reader<<IA64 as Arch>::Word>>(&self, inst: &mut InstructionBundle, bytes: &mut T) -> Result<(), Self::Error> { - let word = bytes.next()?; + fn decode_into<T: Reader<<IA64 as Arch>::Address, <IA64 as Arch>::Word>>(&self, inst: &mut InstructionBundle, bytes: &mut T) -> Result<(), <IA64 as Arch>::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::<Lsb0>(); let bundle_tag = instruction_bytes[0..5].load::<u8>(); @@ -1980,11 +1969,6 @@ impl Decoder<IA64> for InstDecoder { // remaining necessary details Ok(()) } - fn decode<T: Reader<<IA64 as Arch>::Word>>(&self, words: &mut T) -> Result<InstructionBundle, Self::Error> { - let mut inst = InstructionBundle::default(); - self.decode_into(&mut inst, words)?; - Ok(inst) - } } fn one_op(dest: bool, op: Operand) -> (Option<u8>, [Operand; 5]) { |