From: Dmitry Selyutin Date: Sun, 6 Nov 2022 09:29:55 +0000 (+0300) Subject: power_insn: allow sign only for SignedOperand X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac330ff4331226446f002e5d7ad555f9443432d3;p=openpower-isa.git power_insn: allow sign only for SignedOperand --- diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 5a89a7eb..2f187a6f 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -538,6 +538,8 @@ class Operand: span = tuple(map(lambda bit: (bit + 32), span)) if isinstance(value, str): value = int(value, 0) + if value < 0: + raise ValueError("signed operands not allowed") insn[span] = value def disassemble(self, insn, record, @@ -563,6 +565,11 @@ class DynamicOperand(Operand): class SignedOperand(DynamicOperand): + def assemble(self, value, insn, record): + if isinstance(value, str): + value = int(value, 0) + return super().assemble(value=value, insn=insn, record=record) + def disassemble(self, insn, record, verbosity=Verbosity.NORMAL, indent=""): span = self.span(record=record)