power_insn: forbid zero for non-zero operands
authorDmitry Selyutin <ghostmansd@gmail.com>
Sun, 30 Apr 2023 18:50:19 +0000 (21:50 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sun, 30 Apr 2023 18:50:19 +0000 (21:50 +0300)
src/openpower/decoder/power_insn.py

index 486d1d655198d44eba8cc4e01df7a2fb1a441934..b9d92508a7654fd563e42c5b0392986b89002902 100644 (file)
@@ -1148,6 +1148,8 @@ class NonZeroOperand(DynamicOperand):
             value = int(value, 0)
         if not isinstance(value, int):
             raise ValueError("non-integer operand")
+        if value == 0:
+            raise ValueError("non-zero operand")
         value -= 1
         return super().assemble(value=value, insn=insn)