aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-01-11 15:07:59 -0800
committeriximeow <me@iximeow.net>2020-01-12 17:29:01 -0800
commit2cfb2c7c52f23fa02443445046adb7a1a2c4a119 (patch)
tree3826dda7c5419b7a35b442ba8d3c988f62da06a4
parent34da4b9ceb5f6b2395dbf23ad6afdc5f473d29c2 (diff)
be nicer about reaching incomplete parts of armv7 decoder
-rw-r--r--src/armv7.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/armv7.rs b/src/armv7.rs
index 06f1287..f85038f 100644
--- a/src/armv7.rs
+++ b/src/armv7.rs
@@ -5,7 +5,7 @@ use std::fmt::{self, Display, Formatter};
use yaxpeax_arch::{Arch, Colorize, Colored, ColorSettings, Decoder, LengthedInstruction, ShowContextual, YaxColors};
-struct ConditionedOpcode(pub Opcode, pub ConditionCode);
+pub struct ConditionedOpcode(pub Opcode, pub ConditionCode);
impl Display for ConditionedOpcode {
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
@@ -413,7 +413,7 @@ pub enum ShiftSpec {
Register(u8)
}
-#[derive(Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Operands {
RegisterList(u16),
OneOperand(u8),
@@ -442,6 +442,7 @@ pub enum DecodeError {
ExhaustedInput,
InvalidOpcode,
InvalidOperand,
+ Incomplete,
}
impl fmt::Display for DecodeError {
@@ -450,6 +451,7 @@ impl fmt::Display for DecodeError {
DecodeError::ExhaustedInput => write!(f, "exhausted input"),
DecodeError::InvalidOpcode => write!(f, "invalid opcode"),
DecodeError::InvalidOperand => write!(f, "invalid operand"),
+ DecodeError::Incomplete => write!(f, "incomplete decoder"),
}
}
}
@@ -953,10 +955,12 @@ impl Decoder<Instruction> for InstDecoder {
inst.operands = Operands::ThreeOperandImm(Rn, Rd, imm);
}
_ => {
- unreachable!();
+ return Err(DecodeError::Incomplete);
+// unreachable!();
}
}
- panic!("page a5-201");
+ return Err(DecodeError::Incomplete);
+// panic!("page a5-201");
}
0b10 => {
// |c o n d|0 0 0 x|x x x x x x x x x x x x x x x x|1 1 0 1|x x x x|