From b14958d55dd098d43719ef0284fe3de2d8f7c020 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 5 Jan 2019 02:05:14 -0800 Subject: do not show *1 for SIB with scale == 1 --- src/lib.rs | 14 +++++++++++--- 1 file 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, instruction: &mut Instructio instruction.opcode = Opcode::Invalid; return Ok(OperandCode::Nothing); }, - _ => { unsafe { unreachable_unchecked(); } }// panic!("unreachable?") + _ => { unsafe { unreachable_unchecked(); } } } continue; } -- cgit v1.1