nr_bytes = (len(self.__class__) // 8)
return int(self).to_bytes(nr_bytes, byteorder=byteorder)
- def record(self, db):
- record = db[self]
+ @classmethod
+ def record(cls, db, entry):
+ record = db[entry]
if record is None:
- raise KeyError(self)
+ raise KeyError(entry)
return record
def spec(self, db, prefix):
- record = self.record(db=db)
+ record = self.record(db=db, entry=self)
dynamic_operands = tuple(map(_operator.itemgetter(0),
self.dynamic_operands(db=db)))
return f"{prefix}{record.name}{operands}"
def dynamic_operands(self, db, verbosity=Verbosity.NORMAL):
- record = self.record(db=db)
+ record = self.record(db=db, entry=self)
imm = False
imm_name = ""
yield (name, value)
def static_operands(self, db):
- record = self.record(db=db)
+ record = self.record(db=db, entry=self)
for operand in record.static_operands:
yield (operand.name, operand.value)
_: _Field = range(0, 32)
PO: _Field = range(0, 6)
+ @classmethod
+ def record(cls, db, entry):
+ record = super().record(db=db, entry=entry)
+ return _dataclasses.replace(record, svp64=None)
+
@classmethod
def integer(cls, value, byteorder="little"):
return super().integer(bits=32, value=value, byteorder=byteorder)
if arguments is None:
arguments = ()
- record = db[opcode]
- record = _dataclasses.replace(record, svp64=None)
+ record = cls.record(db=db, entry=opcode)
insn = cls.integer(value=0)
for operand in record.static_operands:
operand.assemble(insn=insn)
blob = " ".join(map(lambda byte: f"{byte:02x}", blob))
blob += " "
- record = db[self]
+ record = self.record(db=db, entry=self)
if record is None:
yield f"{blob}.long 0x{int(self):08x}"
return
prefix: Prefix
- def record(self, db):
- record = db[self.suffix]
- if record is None:
- raise KeyError(self)
- return record
+ @classmethod
+ def record(cls, db, entry):
+ if isinstance(entry, SVP64Instruction):
+ entry = entry.suffix
+ return super().record(db=db, entry=entry)
@property
def binary(self):
if specifiers is None:
specifiers = ()
- record = db[opcode]
+ record = cls.record(db=db, entry=opcode)
insn = cls.integer(value=0)
specifiers = Specifiers(items=specifiers, record=record)
blob = " ".join(map(lambda byte: f"{byte:02x}", blob))
return f"{blob} "
- record = self.record(db=db)
+ record = self.record(db=db, entry=self)
blob_prefix = blob(self.prefix)
blob_suffix = blob(self.suffix)
if record is None or record.svp64 is None: