aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/long_mode/display.rs15
-rw-r--r--src/long_mode/mod.rs16
2 files changed, 17 insertions, 14 deletions
diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs
index c3f4413..1be4a32 100644
--- a/src/long_mode/display.rs
+++ b/src/long_mode/display.rs
@@ -5,20 +5,7 @@ use core::fmt;
use yaxpeax_arch::{Colorize, ShowContextual, NoColors, YaxColors};
use yaxpeax_arch::display::*;
-use crate::long_mode::{RegSpec, Opcode, Operand, InstDecoder, Instruction, Segment, PrefixRex, OperandSpec, DecodeError};
-
-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") },
- DecodeError::InvalidPrefixes => { write!(f, "invalid prefixes") },
- DecodeError::TooLong => { write!(f, "too long") },
- DecodeError::IncompleteDecoder => { write!(f, "the decoder is incomplete") },
- }
- }
-}
+use crate::long_mode::{RegSpec, Opcode, Operand, InstDecoder, Instruction, Segment, PrefixRex, OperandSpec};
impl fmt::Display for InstDecoder {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 909157b..ff5e43b 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -1,4 +1,5 @@
mod vex;
+#[cfg(feature = "fmt")]
mod display;
pub mod uarch;
@@ -6,6 +7,20 @@ use core::hint::unreachable_unchecked;
use yaxpeax_arch::{AddressDiff, Decoder, LengthedInstruction};
+use core::fmt;
+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") },
+ DecodeError::InvalidPrefixes => { write!(f, "invalid prefixes") },
+ DecodeError::TooLong => { write!(f, "too long") },
+ DecodeError::IncompleteDecoder => { write!(f, "the decoder is incomplete") },
+ }
+ }
+}
+
#[cfg(feature="use-serde")]
#[derive(Copy, Clone, Debug, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)]
pub struct RegSpec {
@@ -71,6 +86,7 @@ impl RegSpec {
RegisterClass { kind: self.bank }
}
+ #[cfg(feature = "fmt")]
/// return a human-friendly name for this register. the returned name is the same as would be
/// used to render this register in an instruction.
pub fn name(&self) -> &'static str {