2013-09-05 03:00:12 +00:00
|
|
|
// Copyright 2006 The Android Open Source Project
|
|
|
|
|
2014-09-06 18:37:19 +00:00
|
|
|
#pragma once
|
2013-09-05 03:00:12 +00:00
|
|
|
|
2014-09-06 18:37:19 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
2013-09-05 03:00:12 +00:00
|
|
|
|
|
|
|
// Note: this list of opcodes must match the list used to initialize
|
|
|
|
// the opflags[] array in opcode.cpp.
|
|
|
|
enum Opcode {
|
|
|
|
OP_INVALID,
|
|
|
|
OP_UNDEFINED,
|
|
|
|
OP_ADC,
|
|
|
|
OP_ADD,
|
|
|
|
OP_AND,
|
|
|
|
OP_B,
|
|
|
|
OP_BL,
|
|
|
|
OP_BIC,
|
|
|
|
OP_BKPT,
|
|
|
|
OP_BLX,
|
|
|
|
OP_BX,
|
|
|
|
OP_CDP,
|
2015-08-06 11:55:56 +00:00
|
|
|
OP_CLREX,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_CLZ,
|
|
|
|
OP_CMN,
|
|
|
|
OP_CMP,
|
|
|
|
OP_EOR,
|
|
|
|
OP_LDC,
|
|
|
|
OP_LDM,
|
|
|
|
OP_LDR,
|
|
|
|
OP_LDRB,
|
|
|
|
OP_LDRBT,
|
2015-08-06 11:55:56 +00:00
|
|
|
OP_LDREX,
|
|
|
|
OP_LDREXB,
|
|
|
|
OP_LDREXD,
|
|
|
|
OP_LDREXH,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_LDRH,
|
|
|
|
OP_LDRSB,
|
|
|
|
OP_LDRSH,
|
|
|
|
OP_LDRT,
|
|
|
|
OP_MCR,
|
|
|
|
OP_MLA,
|
|
|
|
OP_MOV,
|
|
|
|
OP_MRC,
|
|
|
|
OP_MRS,
|
|
|
|
OP_MSR,
|
|
|
|
OP_MUL,
|
|
|
|
OP_MVN,
|
2015-08-05 10:12:24 +00:00
|
|
|
OP_NOP,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_ORR,
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
OP_PKH,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_PLD,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_QADD16,
|
|
|
|
OP_QADD8,
|
|
|
|
OP_QASX,
|
|
|
|
OP_QSAX,
|
|
|
|
OP_QSUB16,
|
|
|
|
OP_QSUB8,
|
2015-08-09 11:52:51 +00:00
|
|
|
OP_REV,
|
|
|
|
OP_REV16,
|
|
|
|
OP_REVSH,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_RSB,
|
|
|
|
OP_RSC,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_SADD16,
|
|
|
|
OP_SADD8,
|
|
|
|
OP_SASX,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_SBC,
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
OP_SEL,
|
2015-08-05 10:12:24 +00:00
|
|
|
OP_SEV,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_SHADD16,
|
|
|
|
OP_SHADD8,
|
|
|
|
OP_SHASX,
|
|
|
|
OP_SHSAX,
|
|
|
|
OP_SHSUB16,
|
|
|
|
OP_SHSUB8,
|
2015-08-10 16:21:34 +00:00
|
|
|
OP_SMLAD,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_SMLAL,
|
2015-08-10 16:21:34 +00:00
|
|
|
OP_SMLALD,
|
|
|
|
OP_SMLSD,
|
|
|
|
OP_SMLSLD,
|
|
|
|
OP_SMMLA,
|
|
|
|
OP_SMMLS,
|
|
|
|
OP_SMMUL,
|
|
|
|
OP_SMUAD,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_SMULL,
|
2015-08-10 16:21:34 +00:00
|
|
|
OP_SMUSD,
|
2015-08-07 11:44:02 +00:00
|
|
|
OP_SSAT,
|
|
|
|
OP_SSAT16,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_SSAX,
|
|
|
|
OP_SSUB16,
|
|
|
|
OP_SSUB8,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_STC,
|
|
|
|
OP_STM,
|
|
|
|
OP_STR,
|
|
|
|
OP_STRB,
|
|
|
|
OP_STRBT,
|
2015-08-06 11:55:56 +00:00
|
|
|
OP_STREX,
|
|
|
|
OP_STREXB,
|
|
|
|
OP_STREXD,
|
|
|
|
OP_STREXH,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_STRH,
|
|
|
|
OP_STRT,
|
|
|
|
OP_SUB,
|
|
|
|
OP_SWI,
|
|
|
|
OP_SWP,
|
|
|
|
OP_SWPB,
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
OP_SXTAB,
|
|
|
|
OP_SXTAB16,
|
|
|
|
OP_SXTAH,
|
|
|
|
OP_SXTB,
|
|
|
|
OP_SXTB16,
|
|
|
|
OP_SXTH,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_TEQ,
|
|
|
|
OP_TST,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_UADD16,
|
|
|
|
OP_UADD8,
|
|
|
|
OP_UASX,
|
|
|
|
OP_UHADD16,
|
|
|
|
OP_UHADD8,
|
|
|
|
OP_UHASX,
|
|
|
|
OP_UHSAX,
|
|
|
|
OP_UHSUB16,
|
|
|
|
OP_UHSUB8,
|
2013-09-05 03:00:12 +00:00
|
|
|
OP_UMLAL,
|
|
|
|
OP_UMULL,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_UQADD16,
|
|
|
|
OP_UQADD8,
|
|
|
|
OP_UQASX,
|
|
|
|
OP_UQSAX,
|
|
|
|
OP_UQSUB16,
|
|
|
|
OP_UQSUB8,
|
2015-08-10 16:21:34 +00:00
|
|
|
OP_USAD8,
|
|
|
|
OP_USADA8,
|
2015-08-07 11:44:02 +00:00
|
|
|
OP_USAT,
|
|
|
|
OP_USAT16,
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
OP_USAX,
|
|
|
|
OP_USUB16,
|
|
|
|
OP_USUB8,
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
OP_UXTAB,
|
|
|
|
OP_UXTAB16,
|
|
|
|
OP_UXTAH,
|
|
|
|
OP_UXTB,
|
|
|
|
OP_UXTB16,
|
|
|
|
OP_UXTH,
|
2015-08-05 10:12:24 +00:00
|
|
|
OP_WFE,
|
|
|
|
OP_WFI,
|
|
|
|
OP_YIELD,
|
2013-09-05 03:00:12 +00:00
|
|
|
|
|
|
|
// Define thumb opcodes
|
|
|
|
OP_THUMB_UNDEFINED,
|
|
|
|
OP_THUMB_ADC,
|
|
|
|
OP_THUMB_ADD,
|
|
|
|
OP_THUMB_AND,
|
|
|
|
OP_THUMB_ASR,
|
|
|
|
OP_THUMB_B,
|
|
|
|
OP_THUMB_BIC,
|
|
|
|
OP_THUMB_BKPT,
|
|
|
|
OP_THUMB_BL,
|
|
|
|
OP_THUMB_BLX,
|
|
|
|
OP_THUMB_BX,
|
|
|
|
OP_THUMB_CMN,
|
|
|
|
OP_THUMB_CMP,
|
|
|
|
OP_THUMB_EOR,
|
|
|
|
OP_THUMB_LDMIA,
|
|
|
|
OP_THUMB_LDR,
|
|
|
|
OP_THUMB_LDRB,
|
|
|
|
OP_THUMB_LDRH,
|
|
|
|
OP_THUMB_LDRSB,
|
|
|
|
OP_THUMB_LDRSH,
|
|
|
|
OP_THUMB_LSL,
|
|
|
|
OP_THUMB_LSR,
|
|
|
|
OP_THUMB_MOV,
|
|
|
|
OP_THUMB_MUL,
|
|
|
|
OP_THUMB_MVN,
|
|
|
|
OP_THUMB_NEG,
|
|
|
|
OP_THUMB_ORR,
|
|
|
|
OP_THUMB_POP,
|
|
|
|
OP_THUMB_PUSH,
|
|
|
|
OP_THUMB_ROR,
|
|
|
|
OP_THUMB_SBC,
|
|
|
|
OP_THUMB_STMIA,
|
|
|
|
OP_THUMB_STR,
|
|
|
|
OP_THUMB_STRB,
|
|
|
|
OP_THUMB_STRH,
|
|
|
|
OP_THUMB_SUB,
|
|
|
|
OP_THUMB_SWI,
|
|
|
|
OP_THUMB_TST,
|
|
|
|
|
|
|
|
OP_END // must be last
|
|
|
|
};
|
|
|
|
|
2014-04-05 02:25:12 +00:00
|
|
|
class ARM_Disasm {
|
2013-09-05 03:00:12 +00:00
|
|
|
public:
|
2014-09-06 18:37:19 +00:00
|
|
|
static std::string Disassemble(uint32_t addr, uint32_t insn);
|
|
|
|
static Opcode Decode(uint32_t insn);
|
2013-09-05 03:00:12 +00:00
|
|
|
|
|
|
|
private:
|
2014-09-06 18:37:19 +00:00
|
|
|
static Opcode Decode00(uint32_t insn);
|
|
|
|
static Opcode Decode01(uint32_t insn);
|
|
|
|
static Opcode Decode10(uint32_t insn);
|
|
|
|
static Opcode Decode11(uint32_t insn);
|
2015-08-06 11:55:56 +00:00
|
|
|
static Opcode DecodeSyncPrimitive(uint32_t insn);
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
static Opcode DecodeParallelAddSub(uint32_t insn);
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
static Opcode DecodePackingSaturationReversal(uint32_t insn);
|
2014-09-06 18:37:19 +00:00
|
|
|
static Opcode DecodeMUL(uint32_t insn);
|
2015-08-05 10:12:24 +00:00
|
|
|
static Opcode DecodeMSRImmAndHints(uint32_t insn);
|
2015-08-10 16:21:34 +00:00
|
|
|
static Opcode DecodeMediaMulDiv(uint32_t insn);
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
static Opcode DecodeMedia(uint32_t insn);
|
2014-09-06 18:37:19 +00:00
|
|
|
static Opcode DecodeLDRH(uint32_t insn);
|
|
|
|
static Opcode DecodeALU(uint32_t insn);
|
2013-09-05 03:00:12 +00:00
|
|
|
|
2014-09-06 18:37:19 +00:00
|
|
|
static std::string DisassembleALU(Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleBranch(uint32_t addr, Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleBX(uint32_t insn);
|
|
|
|
static std::string DisassembleBKPT(uint32_t insn);
|
|
|
|
static std::string DisassembleCLZ(uint32_t insn);
|
2015-08-10 16:21:34 +00:00
|
|
|
static std::string DisassembleMediaMulDiv(Opcode opcode, uint32_t insn);
|
2014-09-06 18:37:19 +00:00
|
|
|
static std::string DisassembleMemblock(Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleMem(uint32_t insn);
|
|
|
|
static std::string DisassembleMemHalf(uint32_t insn);
|
|
|
|
static std::string DisassembleMCR(Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleMLA(Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleUMLAL(Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleMUL(Opcode opcode, uint32_t insn);
|
|
|
|
static std::string DisassembleMRS(uint32_t insn);
|
|
|
|
static std::string DisassembleMSR(uint32_t insn);
|
2015-08-05 10:12:24 +00:00
|
|
|
static std::string DisassembleNoOperands(Opcode opcode, uint32_t insn);
|
arm_disasm: ARMv6 parallel add/sub media instructions
{S, U, Q, UQ, SH, UH}{ADD16, ASX, SAX, SUB16, ADD8, SUB8}
2015-08-10 12:45:22 +00:00
|
|
|
static std::string DisassembleParallelAddSub(Opcode opcode, uint32_t insn);
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
static std::string DisassemblePKH(uint32_t insn);
|
2014-09-06 18:37:19 +00:00
|
|
|
static std::string DisassemblePLD(uint32_t insn);
|
2015-08-09 11:52:51 +00:00
|
|
|
static std::string DisassembleREV(Opcode opcode, uint32_t insn);
|
2015-08-06 11:55:56 +00:00
|
|
|
static std::string DisassembleREX(Opcode opcode, uint32_t insn);
|
2015-08-07 11:44:02 +00:00
|
|
|
static std::string DisassembleSAT(Opcode opcode, uint32_t insn);
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
static std::string DisassembleSEL(uint32_t insn);
|
2014-09-06 18:37:19 +00:00
|
|
|
static std::string DisassembleSWI(uint32_t insn);
|
|
|
|
static std::string DisassembleSWP(Opcode opcode, uint32_t insn);
|
arm_disasm: ARMv6 packing and sign-extend media instructions
PKH, SEL
SXTAB, SXTAB16, SXTB, SXTB16, SXTH, SXTAH
UXTAB, UXTAB16, UXTB, UXTB16, UXTH, UXTAH
2015-08-07 08:10:35 +00:00
|
|
|
static std::string DisassembleXT(Opcode opcode, uint32_t insn);
|
2013-09-05 03:00:12 +00:00
|
|
|
};
|