diff --git a/archinfo/arch_pcode.py b/archinfo/arch_pcode.py index 512b174..6d18406 100644 --- a/archinfo/arch_pcode.py +++ b/archinfo/arch_pcode.py @@ -143,3 +143,9 @@ def _get_language_by_id(lang_id) -> "pypcode.ArchLanguage": if lang.id == lang_id: return lang raise ArchError("Language not found") + + def disasm(self, bytestring, addr=0, thumb=False): + ctx = pypcode.Context(self.name) + ctx.setVariableDefault("TMode", 1 if thumb else 0) + instructions = ctx.disassemble(bytestring, addr, 0, len(bytestring), 0).instructions + return "\n".join(f"{insn.addr.offset:#x}:\t{insn.mnem} {insn.body}" for insn in instructions)