@_functools.total_ordering
class Style(_enum.Enum):
+ LEGACY = _enum.auto()
SHORT = _enum.auto()
NORMAL = _enum.auto()
VERBOSE = _enum.auto()
record = cls.record(db=db, entry=entry)
insn = cls.integer(value=0)
- opcode = record.section.opcode
- if opcode is None:
- opcode = record.ppc.opcode
- bits = record.section.bitsel
- for (src, dst) in enumerate(reversed(bits)):
- insn[dst] = ((opcode.value & (1 << src)) != 0)
-
for (op_cls, op_kwargs) in record.static_operands:
operand = op_cls(record=record, **op_kwargs)
operand.assemble(insn=insn)
def disassemble(self, db,
byteorder="little",
- style=Style.NORMAL,
- compatibility=False):
+ style=Style.NORMAL):
if style <= Style.SHORT:
blob = ""
else:
yield f"{blob}.long 0x{int(self):08x}"
return
- operands = tuple(map(_operator.itemgetter(1),
- self.dynamic_operands(db=db, style=style)))
- if operands:
- operands = ",".join(operands)
- yield f"{blob}{record.name} {operands}"
+ if style <= Style.LEGACY and record.ppc.unofficial:
+ yield f"{blob}.long 0x{int(self):08x}"
else:
- yield f"{blob}{record.name}"
+ operands = tuple(map(_operator.itemgetter(1),
+ self.dynamic_operands(db=db, style=style)))
+ if operands:
+ operands = ",".join(operands)
+ yield f"{blob}{record.name} {operands}"
+ else:
+ yield f"{blob}{record.name}"
if style >= Style.VERBOSE:
indent = (" " * 4)
insn.prefix.PO = 0x1
insn.prefix.id = 0x3
+
return insn
def disassemble(self, db,
byteorder="little",
style=Style.NORMAL):
+
def blob(insn):
if style <= Style.SHORT:
return ""
if len(operands) > 0: # if any separate with a space
operands = (" " + operands)
- yield f"{blob_prefix}{name}{specifiers}{operands}"
- if blob_suffix:
- yield f"{blob_suffix}"
+ if style <= Style.LEGACY:
+ yield f"{blob_prefix}.long 0x{int(self.prefix):08x}"
+ suffix = WordInstruction.integer(value=int(self.suffix))
+ yield from suffix.disassemble(db=db,
+ byteorder=byteorder, style=style)
+ else:
+ yield f"{blob_prefix}{name}{specifiers}{operands}"
+ if blob_suffix:
+ yield f"{blob_suffix}"
if style >= Style.VERBOSE:
indent = (" " * 4)
parser.add_argument("-v", "--verbose",
dest="style", default=_Style.NORMAL,
action="store_const", const=_Style.VERBOSE)
- parser.add_argument("-l", "--log",
+ parser.add_argument("-l", "--legacy",
+ dest="style", default=_Style.NORMAL,
+ action="store_const", const=_Style.LEGACY)
+ parser.add_argument("-L", "--log",
action="store_true", default=False)
args = dict(vars(parser.parse_args()))
if record is not None:
insn = WordInstruction.assemble(db=DB,
entry=opcode, arguments=fields)
- yield " ".join((
- f".long 0x{int(insn):08X}",
- "#",
- opcode,
- ",".join(fields),
- ))
+ yield from insn.disassemble(db=DB, style=Style.LEGACY)
return
# identify if is a svp64 mnemonic
entry=v30b_op_orig,
arguments=fields,
specifiers=opmodes)
- prefix = int(insn.prefix)
- suffix = int(insn.suffix)
- yield f".long 0x{prefix:08X}"
- yield from insn.suffix.disassemble(db=DB, style=Style.SHORT)
+ yield from insn.disassemble(db=DB, style=Style.LEGACY)
return
# look up the 32-bit op (original, with "." if it has it)
if record is not None:
insn = WordInstruction.assemble(db=DB,
entry=opcode, arguments=fields)
- yield " ".join((
- f".long 0x{int(insn):08X}",
- "#",
- opcode,
- ",".join(fields),
- ))
+ yield from insn.disassemble(db=DB, style=Style.LEGACY)
else:
if not v30b_op.endswith('.'):
v30b_op += rc