Compare commits

...

2 Commits

Author SHA1 Message Date
Luke Street e4f97adbdd Version 0.6.1 2023-11-22 00:11:33 -05:00
Luke Street 0ec7bf078b Highlight: Consider reg offsets and signed immediates equivalent
Fixes #32
2023-11-22 00:07:21 -05:00
4 changed files with 27 additions and 3 deletions

2
Cargo.lock generated
View File

@ -2658,7 +2658,7 @@ dependencies = [
[[package]]
name = "objdiff"
version = "0.6.0"
version = "0.6.1"
dependencies = [
"anyhow",
"byteorder",

View File

@ -1,6 +1,6 @@
[package]
name = "objdiff"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
rust-version = "1.70"
authors = ["Luke Street <luke@street.dev>"]

View File

@ -50,6 +50,30 @@ pub enum ObjInsArg {
BranchOffset(i32),
}
impl ObjInsArg {
pub fn loose_eq(&self, other: &ObjInsArg) -> bool {
match (self, other) {
(ObjInsArg::PpcArg(a), ObjInsArg::PpcArg(b)) => {
a == b
|| match (a, b) {
// Consider Simm and Offset equivalent
(ppc750cl::Argument::Simm(simm), ppc750cl::Argument::Offset(off))
| (ppc750cl::Argument::Offset(off), ppc750cl::Argument::Simm(simm)) => {
simm.0 == off.0
}
_ => false,
}
}
(ObjInsArg::MipsArg(a), ObjInsArg::MipsArg(b)) => a == b,
(ObjInsArg::MipsArgWithBase(a), ObjInsArg::MipsArgWithBase(b)) => a == b,
(ObjInsArg::Reloc, ObjInsArg::Reloc) => true,
(ObjInsArg::RelocWithBase, ObjInsArg::RelocWithBase) => true,
(ObjInsArg::BranchOffset(a), ObjInsArg::BranchOffset(b)) => a == b,
_ => false,
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct ObjInsArgDiff {
/// Incrementing index for coloring

View File

@ -194,7 +194,7 @@ fn write_ins(
HighlightKind::Address(v) => {
matches!(arg, ObjInsArg::BranchOffset(offset) if (offset + ins.address as i32 - base_addr as i32) as u32 == *v)
}
HighlightKind::Arg(v) => v == arg,
HighlightKind::Arg(v) => v.loose_eq(arg),
_ => false,
};
let color = if highlighted_arg {