aboutsummaryrefslogtreecommitdiff
path: root/src/display.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-10-20 15:23:20 -0700
committeriximeow <me@iximeow.net>2020-01-12 16:10:13 -0800
commite5d46b89d95a0e1c1c3a7e112a9b36bb82163b2d (patch)
tree1487c25cfd9b0f7a2ee5268a81c51f8136c00b9d /src/display.rs
parent779a7b827ff4493ff6c7cf8fdd60b88f3592a786 (diff)
make Instruction smaller
this breaks all of how Operand are used, but its faster, so its impossible to say,
Diffstat (limited to 'src/display.rs')
-rw-r--r--src/display.rs42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/display.rs b/src/display.rs
index fc3f1bd..e70734d 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -6,7 +6,7 @@ use std::fmt;
use yaxpeax_arch::{Colorize, ColorSettings, ShowContextual, YaxColors};
use yaxpeax_arch::display::*;
-use ::{RegSpec, RegisterBank, Opcode, Operand, Instruction, Segment, PrefixRex};
+use ::{RegSpec, RegisterBank, Opcode, Operand, Instruction, Segment, PrefixRex, OperandSpec};
impl fmt::Display for PrefixRex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -690,17 +690,18 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi
Some(s) => { write!(out, " {}", s)?; },
None => {
match self.operands[0] {
- Operand::Nothing => {
+ OperandSpec::Nothing => {
return Ok(());
},
- ref x @ _ => {
+ _ => {
write!(out, " ")?;
if let Some(prefix) = self.segment_override_for_op(0) {
write!(out, "{}:", prefix)?;
}
- x.colorize(colors, out)?;
}
}
+ let x = Operand::from_spec(self, self.operands[0]);
+ x.colorize(colors, out)?;
}
};
match self.opcode {
@@ -710,24 +711,21 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi
Some(s) => { write!(out, ", {}", s) }
None => {
match &self.operands[1] {
- &Operand::Nothing => {
- return Ok(());
+ &OperandSpec::Nothing => {
+ unreachable!();
},
- x @ &Operand::Register(_) => {
+ &OperandSpec::RegMMM => {
write!(out, ", ")?;
- if let Some(prefix) = self.segment_override_for_op(1) {
- write!(out, "{}:", prefix)?;
- }
- x.colorize(colors, out)
}
x @ _ => {
write!(out, ", byte ")?;
if let Some(prefix) = self.segment_override_for_op(1) {
write!(out, "{}:", prefix)?;
}
- x.colorize(colors, out)
}
}
+ let x = Operand::from_spec(self, self.operands[1]);
+ x.colorize(colors, out)
}
}
},
@@ -737,24 +735,21 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi
Some(s) => { write!(out, ", {}", s) }
None => {
match &self.operands[1] {
- &Operand::Nothing => {
- return Ok(());
+ &OperandSpec::Nothing => {
+ unreachable!();
},
- x @ &Operand::Register(_) => {
+ &OperandSpec::RegMMM => {
write!(out, ", ")?;
- if let Some(prefix) = self.segment_override_for_op(1) {
- write!(out, "{}:", prefix)?;
- }
- x.colorize(colors, out)
}
- x @ _ => {
+ _ => {
write!(out, ", word ")?;
if let Some(prefix) = self.segment_override_for_op(1) {
write!(out, "{}:", prefix)?;
}
- x.colorize(colors, out)
}
}
+ let x = Operand::from_spec(self, self.operands[1]);
+ x.colorize(colors, out)
}
}
},
@@ -763,14 +758,15 @@ impl <T: std::fmt::Write> ShowContextual<u64, [Option<String>], T> for Instructi
Some(s) => { write!(out, ", {}", s) }
None => {
match &self.operands[1] {
- &Operand::Nothing => {
+ &OperandSpec::Nothing => {
return Ok(());
},
- x @ _ => {
+ _ => {
write!(out, ", ")?;
if let Some(prefix) = self.segment_override_for_op(1) {
write!(out, "{}:", prefix)?;
}
+ let x = Operand::from_spec(self, self.operands[1]);
x.colorize(colors, out)
}
}