From 1585d6f361b7173dab8a8ff111e634651be40d9f Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Wed, 31 Aug 2022 11:37:31 +0300 Subject: [PATCH] power_insn: introduce operand disassembly --- src/openpower/decoder/power_insn.py | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/openpower/decoder/power_insn.py b/src/openpower/decoder/power_insn.py index 512c74b5..f90cc32d 100644 --- a/src/openpower/decoder/power_insn.py +++ b/src/openpower/decoder/power_insn.py @@ -4,7 +4,6 @@ import dataclasses as _dataclasses import enum as _enum import functools as _functools import os as _os -import operator as _operator import pathlib as _pathlib import re as _re @@ -409,17 +408,6 @@ class Operand: pass -@_dataclasses.dataclass(eq=True, frozen=True) -class DynamicOperand(Operand): - name: str - - -@_dataclasses.dataclass(eq=True, frozen=True) -class StaticOperand(Operand): - name: str - value: int = None - - class Operands(tuple): def __new__(cls, iterable): operands = [] @@ -434,6 +422,20 @@ class Operands(tuple): return super().__new__(cls, operands) +@_dataclasses.dataclass(eq=True, frozen=True) +class DynamicOperand(Operand): + name: str + + def disassemble(self, value, record): + return str(int(value[record.fields[self.name]])) + + +@_dataclasses.dataclass(eq=True, frozen=True) +class StaticOperand(Operand): + name: str + value: int = None + + @_functools.total_ordering @_dataclasses.dataclass(eq=True, frozen=True) class Record: @@ -618,10 +620,10 @@ class WordInstruction(Instruction): else: operands = [] for operand in record.dynamic_operands: - operand = int(self[record.fields[operand.name]]) + operand = operand.disassemble(self, record) operands.append(operand) if operands: - operands = ",".join(map(str, operands)) + operands = ",".join(operands) operands = f" {operands}" else: operands = "" -- 2.30.2