From 30917045cff1bed6273cb40ad2d38271cbf64364 Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 12 Oct 2020 00:53:23 -0700 Subject: fix negative ip-relative operands showing as `$+-const` they are now `$-const` --- src/lib.rs | 56 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index d0c7768..16a9af8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1091,8 +1091,12 @@ impl fmt::Display for Instruction { return write!(f, "br{}{} {}{}", [".few", ".many"][self.operands[1].as_unsigned_imm() as usize], ["", ".clr"][self.operands[3].as_unsigned_imm() as usize], - if let Operand::ImmI64(_) = self.operands[0] { - "$+" + if let Operand::ImmI64(imm) = self.operands[0] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, @@ -1105,8 +1109,12 @@ impl fmt::Display for Instruction { [".sptk", ".spnt", ".dptk", ".dpnt"][self.operands[2].as_unsigned_imm() as usize], [".few", ".many"][self.operands[1].as_unsigned_imm() as usize], ["", ".clr"][self.operands[3].as_unsigned_imm() as usize], - if let Operand::ImmI64(_) = self.operands[0] { - "$+" + if let Operand::ImmI64(imm) = self.operands[0] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, @@ -1119,8 +1127,12 @@ impl fmt::Display for Instruction { [".few", ".many"][self.operands[2].as_unsigned_imm() as usize], ["", ".clr"][self.operands[4].as_unsigned_imm() as usize], self.operands[0], - if let Operand::ImmI64(_) = self.operands[1] { - "$+" + if let Operand::ImmI64(imm) = self.operands[1] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, @@ -1131,8 +1143,12 @@ impl fmt::Display for Instruction { [".sptk", ".spnt", ".dptk", ".dpnt"][self.operands[2].as_unsigned_imm() as usize], [".few", ".many"][self.operands[1].as_unsigned_imm() as usize], ["", ".clr"][self.operands[3].as_unsigned_imm() as usize], - if let Operand::ImmI64(_) = self.operands[0] { - "$+" + if let Operand::ImmI64(imm) = self.operands[0] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, @@ -1143,8 +1159,12 @@ impl fmt::Display for Instruction { [".sptk", ".spnt", ".dptk", ".dpnt"][self.operands[2].as_unsigned_imm() as usize], [".few", ".many"][self.operands[1].as_unsigned_imm() as usize], ["", ".clr"][self.operands[3].as_unsigned_imm() as usize], - if let Operand::ImmI64(_) = self.operands[0] { - "$+" + if let Operand::ImmI64(imm) = self.operands[0] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, @@ -1155,8 +1175,12 @@ impl fmt::Display for Instruction { [".sptk", ".spnt", ".dptk", ".dpnt"][self.operands[2].as_unsigned_imm() as usize], [".few", ".many"][self.operands[1].as_unsigned_imm() as usize], ["", ".clr"][self.operands[3].as_unsigned_imm() as usize], - if let Operand::ImmI64(_) = self.operands[0] { - "$+" + if let Operand::ImmI64(imm) = self.operands[0] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, @@ -1167,8 +1191,12 @@ impl fmt::Display for Instruction { [".sptk", ".spnt", ".dptk", ".dpnt"][self.operands[2].as_unsigned_imm() as usize], [".few", ".many"][self.operands[1].as_unsigned_imm() as usize], ["", ".clr"][self.operands[3].as_unsigned_imm() as usize], - if let Operand::ImmI64(_) = self.operands[0] { - "$+" + if let Operand::ImmI64(imm) = self.operands[0] { + if imm >= 0 { + "$+" + } else { + "$" + } } else { "" }, -- cgit v1.1