power_insn: support non-zero operands
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 6 Nov 2022 09:29:55 +0000 (12:29 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 15 Jan 2023 19:47:22 +0000 (22:47 +0300)
src/openpower/decoder/power_insn.py

index 2f187a6fa7614c02f1e7b7a8bb5cb10a89ddb517..9d77cbdbefd8d2e53c515d0e5b409fbcec3b35fe 100644 (file)
@@ -615,6 +615,14 @@ class ImmediateOperand(DynamicOperand):
 
 
 class NonZeroOperand(DynamicOperand):
+    def assemble(self, value, insn, record):
+        if isinstance(value, str):
+            value = int(value, 0)
+        if not isinstance(value, int):
+            raise ValueError("non-integer operand")
+        value -= 1
+        return super().assemble(value=value, insn=insn, record=record)
+
     def disassemble(self, insn, record,
             verbosity=Verbosity.NORMAL, indent=""):
         span = self.span(record=record)