fix: align disasm output correctly
This commit is contained in:
@@ -57,9 +57,18 @@ impl Instruction {
|
||||
impl fmt::Display for Instruction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{:04x}: ", self.start).unwrap();
|
||||
for b in self.raw.iter() {
|
||||
write!(f, "{:02x}", b).unwrap();
|
||||
}
|
||||
|
||||
write!(
|
||||
f,
|
||||
"{:<10}",
|
||||
self.raw
|
||||
.iter()
|
||||
.map(|b| format!("{:02x}", b))
|
||||
.collect::<Vec<String>>()
|
||||
.join("")
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
write!(f, "\t\t{}", self.opcode)
|
||||
}
|
||||
}
|
||||
@@ -330,14 +339,14 @@ impl std::fmt::Display for Displacement {
|
||||
match self {
|
||||
Self::IByte(b) => {
|
||||
if *b > 0 {
|
||||
write!(f, " + {}", b)
|
||||
write!(f, " + {:#x}", b)
|
||||
} else {
|
||||
write!(f, " - {:#x}", b * -1)
|
||||
}
|
||||
}
|
||||
Self::IWord(w) => {
|
||||
if *w > 0 {
|
||||
write!(f, " + {}", w)
|
||||
write!(f, " + {:#x}", w)
|
||||
} else {
|
||||
write!(f, " - {:#x}", w * -1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user