aboutsummaryrefslogtreecommitdiff
path: root/src/protected_mode/mod.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2022-04-24 17:39:21 -0700
committeriximeow <me@iximeow.net>2022-04-24 19:22:52 -0700
commit2097524c851b15e89091fd3775817a06f0eeae4f (patch)
treee3c175856fcde170db91474ec580b549f97f8ad7 /src/protected_mode/mod.rs
parente80b5622ec956a92f24ce6487fb0d76e9c541515 (diff)
fix a few issues preventing no-std builds from ... building
this includes a `Makefile` that exercises the various crate configs. most annoyingly, several doc comments needed to grow `#[cfg(feature="fmt")]` blocks so docs continue to build with that feature enabled or disabled. carved out a way to run exhaustive tests; they should be written as `#[ignore]`, and then the makefile will run even ignored tests on the expectation that this will run the exhaustive (but slower) suite. exhaustive tests are not yet written. they'll probably involve spanning 4 byte sequences from 0 to 2^32-1.
Diffstat (limited to 'src/protected_mode/mod.rs')
-rw-r--r--src/protected_mode/mod.rs75
1 files changed, 44 insertions, 31 deletions
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs
index 0a6fcf8..dd63d32 100644
--- a/src/protected_mode/mod.rs
+++ b/src/protected_mode/mod.rs
@@ -833,11 +833,13 @@ const REGISTER_CLASS_NAMES: &[&'static str] = &[
/// }
///
/// if let Operand::Register(regspec) = instruction.operand(0) {
+/// #[cfg(feature="fmt")]
/// println!("first operand is {}", regspec);
/// show_register_class_info(regspec.class());
/// }
///
/// if let Operand::Register(regspec) = instruction.operand(1) {
+/// #[cfg(feature="fmt")]
/// println!("first operand is {}", regspec);
/// show_register_class_info(regspec.class());
/// }
@@ -7386,7 +7388,8 @@ fn read_0f3a_opcode(opcode: u8, prefixes: &mut Prefixes) -> OpcodeRecord {
};
}
-/// the actual description for a selection of bits involved in decoding an [`long_mode::Instruction`].
+/// the actual description for a selection of bits involved in decoding a
+/// [`protected_mode::Instruction`].
///
/// some prefixes are only identified as an `InnerDescription::Misc` string, while some are full
/// `InnerDescription::SegmentPrefix(Segment)`. generally, strings should be considered unstable
@@ -7439,37 +7442,47 @@ impl InnerDescription {
}
}
-impl fmt::Display for InnerDescription {
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- match self {
- InnerDescription::RexPrefix(bits) => {
- write!(f, "rex prefix: {}{}{}{}",
- if bits & 0x8 != 0 { "w" } else { "-" },
- if bits & 0x4 != 0 { "r" } else { "-" },
- if bits & 0x2 != 0 { "x" } else { "-" },
- if bits & 0x1 != 0 { "b" } else { "-" },
- )
- }
- InnerDescription::SegmentPrefix(segment) => {
- write!(f, "segment override: {}", segment)
- }
- InnerDescription::Misc(text) => {
- f.write_str(text)
- }
- InnerDescription::Number(text, num) => {
- write!(f, "{}: {:#x}", text, num)
- }
- InnerDescription::Opcode(opc) => {
- write!(f, "opcode `{}`", opc)
- }
- InnerDescription::OperandCode(OperandCodeWrapper { code }) => {
- write!(f, "operand code `{:?}`", code)
- }
- InnerDescription::RegisterNumber(name, num, reg) => {
- write!(f, "`{}` (`{}` selects register number {})", reg, name, num)
+cfg_if::cfg_if! {
+ if #[cfg(feature = "fmt")] {
+ impl fmt::Display for InnerDescription {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ match self {
+ InnerDescription::RexPrefix(bits) => {
+ write!(f, "rex prefix: {}{}{}{}",
+ if bits & 0x8 != 0 { "w" } else { "-" },
+ if bits & 0x4 != 0 { "r" } else { "-" },
+ if bits & 0x2 != 0 { "x" } else { "-" },
+ if bits & 0x1 != 0 { "b" } else { "-" },
+ )
+ }
+ InnerDescription::SegmentPrefix(segment) => {
+ write!(f, "segment override: {}", segment)
+ }
+ InnerDescription::Misc(text) => {
+ f.write_str(text)
+ }
+ InnerDescription::Number(text, num) => {
+ write!(f, "{}: {:#x}", text, num)
+ }
+ InnerDescription::Opcode(opc) => {
+ write!(f, "opcode `{}`", opc)
+ }
+ InnerDescription::OperandCode(OperandCodeWrapper { code }) => {
+ write!(f, "operand code `{:?}`", code)
+ }
+ InnerDescription::RegisterNumber(name, num, reg) => {
+ write!(f, "`{}` (`{}` selects register number {})", reg, name, num)
+ }
+ InnerDescription::Boundary(desc) => {
+ write!(f, "{}", desc)
+ }
+ }
}
- InnerDescription::Boundary(desc) => {
- write!(f, "{}", desc)
+ }
+ } else {
+ impl fmt::Display for InnerDescription {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.write_str("non-fmt build")
}
}
}