From 2ea530a5fe31b029b2d6f03a48c1b4f7475366ff Mon Sep 17 00:00:00 2001 From: Kevin Phoenix Date: Tue, 10 Dec 2024 17:12:31 -0700 Subject: [PATCH] Implement disasm for ArchPcode --- archinfo/arch_pcode.py | 6 ++++++ 1 file changed, 6 insertions(+) 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)