/** @file Thumb Disassembler. Still a work in progress. Wrong output is a bug, so please fix it. Hex output means there is not yet an entry or a decode bug. gOpThumb[] are Thumb 16-bit, and gOpThumb2[] work on the 32-bit 16-bit stream of Thumb2 instruction. Then there are big case statements to print everything out. If you are adding instructions try to reuse existing case entries if possible. Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include #include #include #include extern CHAR8 *gCondition[]; extern CHAR8 *gReg[]; // Thumb address modes #define LOAD_STORE_FORMAT1 1 #define LOAD_STORE_FORMAT1_H 101 #define LOAD_STORE_FORMAT1_B 111 #define LOAD_STORE_FORMAT2 2 #define LOAD_STORE_FORMAT3 3 #define LOAD_STORE_FORMAT4 4 #define LOAD_STORE_MULTIPLE_FORMAT1 5 #define PUSH_FORMAT 6 #define POP_FORMAT 106 #define IMMED_8 7 #define CONDITIONAL_BRANCH 8 #define UNCONDITIONAL_BRANCH 9 #define UNCONDITIONAL_BRANCH_SHORT 109 #define BRANCH_EXCHANGE 10 #define DATA_FORMAT1 11 #define DATA_FORMAT2 12 #define DATA_FORMAT3 13 #define DATA_FORMAT4 14 #define DATA_FORMAT5 15 #define DATA_FORMAT6_SP 16 #define DATA_FORMAT6_PC 116 #define DATA_FORMAT7 17 #define DATA_FORMAT8 19 #define CPS_FORMAT 20 #define ENDIAN_FORMAT 21 #define DATA_CBZ 22 #define ADR_FORMAT 23 #define IT_BLOCK 24 // Thumb2 address modes #define B_T3 200 #define B_T4 201 #define BL_T2 202 #define POP_T2 203 #define POP_T3 204 #define STM_FORMAT 205 #define LDM_REG_IMM12_SIGNED 206 #define LDM_REG_IMM12_LSL 207 #define LDM_REG_IMM8 208 #define LDM_REG_IMM12 209 #define LDM_REG_INDIRECT_LSL 210 #define LDM_REG_IMM8_SIGNED 211 #define LDRD_REG_IMM8 212 #define LDREXB 213 #define LDREXD 214 #define SRS_FORMAT 215 #define RFE_FORMAT 216 #define LDRD_REG_IMM8_SIGNED 217 #define ADD_IMM12 218 #define ADD_IMM5 219 #define ADR_THUMB2 220 #define CMN_THUMB2 221 #define ASR_IMM5 222 #define ASR_3REG 223 #define BFC_THUMB2 224 #define CDP_THUMB2 225 #define THUMB2_NO_ARGS 226 #define THUMB2_2REGS 227 #define ADD_IMM5_2REG 228 #define CPD_THUMB2 229 #define THUMB2_4REGS 230 #define ADD_IMM12_1REG 231 #define THUMB2_IMM16 232 #define MRC_THUMB2 233 #define MRRC_THUMB2 234 #define THUMB2_MRS 235 #define THUMB2_MSR 236 typedef struct { CHAR8 *Start; UINT32 OpCode; UINT32 Mask; UINT32 AddressMode; } THUMB_INSTRUCTIONS; THUMB_INSTRUCTIONS gOpThumb[] = { // Thumb 16-bit instructions // Op Mask Format { "ADC" , 0x4140, 0xffc0, DATA_FORMAT5 }, // ADC , { "ADR", 0xa000, 0xf800, ADR_FORMAT }, // ADR ,