summaryrefslogtreecommitdiff
path: root/src/display.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/display.rs')
-rw-r--r--src/display.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/display.rs b/src/display.rs
index 4593f20..7836d10 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -1,6 +1,6 @@
-use ::{MSP430, Operand, Opcode, Instruction, Width};
+use ::{MSP430, Operand, Opcode, Instruction, Width, DecodeError};
-use std::fmt::{Display, Formatter};
+use std::fmt::{self, Display, Formatter};
use std;
use yaxpeax_arch::{Arch, Colorize, ColorSettings, ShowContextual};
@@ -12,6 +12,16 @@ impl Display for Instruction {
}
}
+impl fmt::Display for DecodeError {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ DecodeError::ExhaustedInput => write!(f, "exhausted input"),
+ DecodeError::InvalidOpcode => write!(f, "invalid opcode"),
+ DecodeError::InvalidOperand => write!(f, "invalid operand"),
+ }
+ }
+}
+
impl <T: std::fmt::Write> ShowContextual<<MSP430 as Arch>::Address, [Option<String>], T> for Instruction {
fn contextualize(&self, _colors: Option<&ColorSettings>, _address: <MSP430 as Arch>::Address, _context: Option<&[Option<String>]>, out: &mut T) -> std::fmt::Result {
write!(out, "{}", self.opcode)?;