summaryrefslogtreecommitdiff
path: root/src/display.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-01-10 02:29:27 -0800
committeriximeow <me@iximeow.net>2020-01-12 17:00:47 -0800
commit1195e6fe7ec9db0aafdadaceac9290c80ba4eb50 (patch)
tree91524156f029729a59636ea341686275df8b0d1d /src/display.rs
parente70be7245eac6acd6dde565c69b55bf8f55653e9 (diff)
impl yaxpeax-arch instruction/decode interface
also fix panic on some immediate display in debug builds
Diffstat (limited to 'src/display.rs')
-rw-r--r--src/display.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/display.rs b/src/display.rs
index 036fb28..994880a 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -16,7 +16,7 @@ impl fmt::Display for Instruction {
(Some(Operand::Reg(a)), Some(Operand::Reg(b)), Some(Operand::Imm(offs))) => {
if a == b {
if offs < 0 {
- return write!(f, "b $-{:#x}", -offs);
+ return write!(f, "b $-{:#x}", offs.wrapping_neg());
} else {
return write!(f, "b $+{:#x}", offs);
}
@@ -44,7 +44,7 @@ impl fmt::Display for Instruction {
}
} else if let Operand::Imm(imm) = op {
if *imm < 0 {
- return write!(f, "-{:#x}", -imm);
+ return write!(f, "-{:#x}", imm.wrapping_neg());
} else {
return write!(f, "{:#x}", imm);
}
@@ -110,7 +110,7 @@ impl fmt::Display for Operand {
write!(f, "({})", name)
} else {
if *offs < 0 {
- write!(f, "-{:#x}({})", -offs, name)
+ write!(f, "-{:#x}({})", offs.wrapping_neg(), name)
} else {
write!(f, "{:#x}({})", offs, name)
}