power_insn: support verbose binary
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Sep 2022 20:50:18 +0000 (23:50 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 3 Sep 2022 20:51:23 +0000 (23:51 +0300)
src/openpower/decoder/power_insn.py

index d4baa44715b4902e8369567dd056cf14971ae4a5..1be04c4a426e64e0b37d1d0f46dc7b60d3d734e5 100644 (file)
@@ -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: