aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2019-03-29 19:12:47 -0700
committeriximeow <me@iximeow.net>2020-01-12 16:10:13 -0800
commit037090417a97690cb161899869f864eaa45082dc (patch)
treea466afc0366ebef63719ef0e727ea4dcdf642441
parent89838362bc43352c1cc2b5e6bc970aa0137cbc3b (diff)
try cleaning up hex display a bit
-rw-r--r--src/display.rs45
1 files changed, 5 insertions, 40 deletions
diff --git a/src/display.rs b/src/display.rs
index 34b1ce6..daa2c34 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -8,6 +8,7 @@ use std::fmt;
use std::hint::unreachable_unchecked;
use yaxpeax_arch::{Arch, Colorize, ColorSettings, Decodable, LengthedInstruction, ShowContextual, YaxColors};
+use yaxpeax_arch::display::*;
use ::{RegSpec, RegisterBank, Opcode, Operand, Instruction};
@@ -75,65 +76,29 @@ impl <T: std::fmt::Write> Colorize<T> for Operand {
write!(f, "{}", colors.number(format!("{:#x}", imm)))
}
&Operand::ImmediateI8(imm) => {
- let (sign, imm) = if imm < 0 {
- (true, -imm)
- } else {
- (false, imm)
- };
write!(f, "{}",
- colors.number(format!("{}{:#x}",
- if sign { "-" } else { "" },
- imm))
- )
+ colors.number(signed_i8_hex(imm)))
},
&Operand::ImmediateU16(imm) => {
write!(f, "{}", colors.number(format!("{:#x}", imm)))
}
&Operand::ImmediateI16(imm) => {
- let (sign, imm) = if imm < 0 {
- (true, -imm)
- } else {
- (false, imm)
- };
write!(f, "{}",
- colors.number(format!("{}{:#x}",
- if sign { "-" } else { "" },
- imm))
- )
+ colors.number(signed_i16_hex(imm)))
},
&Operand::ImmediateU32(imm) => {
write!(f, "{}", colors.number(format!("{:#x}", imm)))
}
&Operand::ImmediateI32(imm) => {
- let (sign, imm) = if imm == std::i32::MIN {
- (false, imm)
- } else if imm < 0 {
- (true, -imm)
- } else {
- (false, imm)
- };
write!(f, "{}",
- colors.number(format!("{}{:#x}",
- if sign { "-" } else { "" },
- imm))
- )
+ colors.number(signed_i32_hex(imm)))
},
&Operand::ImmediateU64(imm) => {
write!(f, "{}", colors.number(format!("{:#x}", imm)))
}
&Operand::ImmediateI64(imm) => {
- let (sign, imm) = if imm == std::i64::MIN {
- (false, imm)
- } else if imm < 0 {
- (true, -imm)
- } else {
- (false, imm)
- };
write!(f, "{}",
- colors.number(format!("{}{:#x}",
- if sign { "-" } else { "" },
- imm))
- )
+ colors.number(signed_i64_hex(imm)))
},
&Operand::Register(ref spec) => {
write!(f, "{}", colors.register(spec))