Skip to content

Commit

Permalink
Implement disasm for ArchPcode
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Dec 11, 2024
1 parent cc94a21 commit 2ea530a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions archinfo/arch_pcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 2ea530a

Please sign in to comment.