aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-01-05 02:05:14 -0800
committeriximeow <me@iximeow.net>2020-01-12 16:10:13 -0800
commitb14958d55dd098d43719ef0284fe3de2d8f7c020 (patch)
tree4641a1721dd95e76951d53cd2d63655ec09e9cd7 /src
parent1186a66e8cc48f4c0c424fdfb63aa4f752db7166 (diff)
do not show *1 for SIB with scale == 1
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 3ba62fa..5941ee8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -73,10 +73,18 @@ impl fmt::Display for Operand {
write!(f, "[{} + {} + 0x{:x}]", base, index, disp)
},
&Operand::RegIndexBaseScale(ref base, ref index, scale) => {
- write!(f, "[{} + {} * {}]", base, index, scale)
+ if scale == 1 {
+ write!(f, "[{} + {}]", base, index)
+ } else {
+ write!(f, "[{} + {} * {}]", base, index, scale)
+ }
}
&Operand::RegIndexBaseScaleDisp(ref base, ref index, scale, disp) => {
- write!(f, "[{} + {} * {} + 0x{:x}]", base, index, scale, disp)
+ if scale == 1 {
+ write!(f, "[{} + {} + {:#x}]", base, index, disp)
+ } else {
+ write!(f, "[{} + {} * {} + {:#x}]", base, index, scale, disp)
+ }
},
&Operand::Nothing => { Ok(()) },
&Operand::Many(_) => { panic!("many not covered"); }
@@ -752,7 +760,7 @@ fn read_opcode(bytes_iter: &mut Iterator<Item=&u8>, instruction: &mut Instructio
instruction.opcode = Opcode::Invalid;
return Ok(OperandCode::Nothing);
},
- _ => { unsafe { unreachable_unchecked(); } }// panic!("unreachable?")
+ _ => { unsafe { unreachable_unchecked(); } }
}
continue;
}