all repos — mgba @ 5d19919df25054695ec16ac9f9af908ff6f4b27b

mGBA Game Boy Advance Emulator

src/arm/decompiler.h (view raw)

 1#ifndef ARM_DECOMPILER_H
 2#define ARM_DECOMPILER_H
 3
 4#include <stdint.h>
 5
 6union ARMOperand {
 7	uint8_t reg;
 8	int32_t immediate;
 9};
10
11struct ARMMemoryAccess {
12	uint8_t baseRegister;
13	union ARMOperand offset;
14};
15
16enum ARMOperandFormat {
17	ARM_OPERAND_NONE =               0x00000000,
18	ARM_OPERAND_REGISTER_1 =         0x00000001,
19	ARM_OPERAND_IMMEDIATE_1 =        0x00000002,
20	ARM_OPERAND_MEMORY_REGISTER_1 =  0x00000005,
21	ARM_OPERAND_MEMORY_IMMEDIATE_1 = 0x00000006,
22	ARM_OPERAND_MEMORY_OFFSET_1 =    0x00000007,
23	ARM_OPERAND_AFFECTED_1 =         0x00000080,
24	ARM_OPERAND_MEMORY_POST_INCR_1 = 0x00000097,
25	ARM_OPERAND_MEMORY_PRE_INCR_1 =  0x000000A7,
26};
27
28enum ThumbMnemonic {
29	THUMB_MN_ILL = 0,
30	THUMB_MN_ADC,
31	THUMB_MN_ADD,
32	THUMB_MN_AND,
33	THUMB_MN_ASR,
34	THUMB_MN_B,
35	THUMB_MN_BIC,
36	THUMB_MN_BL,
37	THUMB_MN_BLH,
38	THUMB_MN_BX,
39	THUMB_MN_CMN,
40	THUMB_MN_CMP,
41	THUMB_MN_EOR,
42	THUMB_MN_LDMIA,
43	THUMB_MN_LDR,
44	THUMB_MN_LDRB,
45	THUMB_MN_LDRH,
46	THUMB_MN_LDRSB,
47	THUMB_MN_LDRSH,
48	THUMB_MN_LSL,
49	THUMB_MN_LSR,
50	THUMB_MN_MOV,
51	THUMB_MN_MUL,
52	THUMB_MN_MVN,
53	THUMB_MN_NEG,
54	THUMB_MN_ORR,
55	THUMB_MN_POP,
56	THUMB_MN_PUSH,
57	THUMB_MN_ROR,
58	THUMB_MN_SBC,
59	THUMB_MN_STMIA,
60	THUMB_MN_STR,
61	THUMB_MN_STRB,
62	THUMB_MN_STRH,
63	THUMB_MN_SUB,
64	THUMB_MN_SWI,
65	THUMB_MN_TST
66};
67
68struct ThumbInstructionInfo {
69	uint16_t opcode;
70	enum ThumbMnemonic mnemonic;
71	union ARMOperand op1;
72	union ARMOperand op2;
73	union ARMOperand op3;
74	struct ARMMemoryAccess memory;
75	int immediateFormat;
76	int operandFormat;
77	int branches;
78	int accessesMemory;
79	int accessesHighRegisters;
80};
81
82void ARMDecodeThumb(uint16_t opcode, struct ThumbInstructionInfo* info);
83
84#endif