| 203 | } |
| 204 | |
| 205 | fn write_instruction_part( |
| 206 | out: &mut String, |
| 207 | part: &InstructionPart, |
| 208 | separator: &str, |
| 209 | reloc: Option<obj::ResolvedRelocation>, |
| 210 | ) { |
| 211 | match part { |
| 212 | InstructionPart::Basic(s) => out.push_str(s), |
| 213 | InstructionPart::Opcode(s, _) => { |
| 214 | out.push_str(s); |
| 215 | out.push(' '); |
| 216 | } |
| 217 | InstructionPart::Arg(arg) => match arg { |
| 218 | obj::InstructionArg::Value(v) => { |
| 219 | let _ = write!(out, "{}", v); |
| 220 | } |
| 221 | obj::InstructionArg::Reloc => { |
| 222 | if let Some(resolved) = reloc { |
| 223 | out.push_str(&resolved.symbol.name); |
| 224 | if resolved.relocation.addend != 0 { |
| 225 | if resolved.relocation.addend < 0 { |
| 226 | let _ = write!(out, "-{:#x}", -resolved.relocation.addend); |
| 227 | } else { |
| 228 | let _ = write!(out, "+{:#x}", resolved.relocation.addend); |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | obj::InstructionArg::BranchDest(dest) => { |
| 234 | let _ = write!(out, "{:#x}", dest); |
| 235 | } |
| 236 | }, |
| 237 | InstructionPart::Separator => out.push_str(separator), |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | impl diff_instruction_part::Part { |
| 242 | fn from(part: &InstructionPart) -> Self { |