From 8009d734b5de63e493c31b87a5314d21a65a2f9a Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sat, 3 Sep 2022 23:50:18 +0300 Subject: [PATCH] power_insn: support verbose binary --- src/openpower/decoder/power_insn.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index d4baa447..1be04c4a 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -753,6 +753,14 @@ class WordInstruction(Instruction): def integer(cls, value, byteorder="little"): return super().integer(bits=32, value=value, byteorder=byteorder) + @property + def binary(self): + bits = [] + for idx in range(32): + bit = int(self[idx]) + bits.append(bit) + return "".join(map(str, bits)) + def spec(self, record): dynamic_operands = [] for operand in record.operands.dynamic: @@ -799,10 +807,15 @@ class WordInstruction(Instruction): if verbose: lindent = (" " * 4) rindent = (len(blob) - len(lindent)) + binary = self.binary spec = self.spec(record=record) opcode = self.opcode(record=record) mask = self.mask(record=record) yield f"{lindent}{'spec':{rindent}}{spec}" + yield f"{lindent}{'binary':{rindent}}{binary[0:8]} [0:8]" + yield f"{lindent}{' ':{rindent}}{binary[8:16]} [8:16]" + yield f"{lindent}{' ':{rindent}}{binary[16:24]} [16:24]" + yield f"{lindent}{' ':{rindent}}{binary[24:32]} [24:32]" yield f"{lindent}{'opcode':{rindent}}{opcode}" yield f"{lindent}{'mask':{rindent}}{mask}" for operand in record.operands: -- 2.30.2