power_insn: support non-zero operands
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 6 Nov 2022 09:29:55 +0000 (12:29 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:16 +0000 (19:51 +0100)
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)