1 #pragma once
2 
3 
4 // opcode types
5 #define ARM_TYPE3 0
6 #define ARM_TYPE4 1
7 #define ARM_TYPE5 2
8 #define ARM_TYPE6 3
9 #define ARM_TYPE7 4
10 #define ARM_TYPE8 5
11 #define ARM_TYPE9 6
12 #define ARM_TYPE10 7
13 #define ARM_TYPE11 8
14 #define ARM_TYPE12 9
15 #define ARM_TYPE13 10
16 #define ARM_TYPE14 11
17 #define ARM_TYPE15 12
18 #define ARM_TYPE16 13
19 #define ARM_TYPE17 14
20 #define ARM_MISC 15
21 
22 // opcode flags
23 #define ARM_ARM9			0x00000001
24 #define ARM_S				0x00000002
25 #define ARM_D				0x00000004
26 #define ARM_N				0x00000008
27 #define ARM_M				0x00000010
28 #define ARM_IMMEDIATE		0x00000020
29 #define ARM_WORD			0x00000040
30 #define ARM_HALFWORD		0x00000080
31 #define ARM_EXCHANGE		0x00000100
32 #define ARM_UNCOND			0x00000200
33 #define ARM_REGISTER		0x00000400
34 #define ARM_LOAD			0x00000800
35 #define ARM_STORE			0x00001000
36 #define ARM_X				0x00002000
37 #define ARM_Y				0x00004000
38 #define ARM_SHIFT			0x00008000
39 #define ARM_POOL			0x00010000
40 #define ARM_ABS				0x00020000	// absolute immediate value for range check
41 #define ARM_BRANCH			0x00040000
42 #define ARM_ABSIMM			0x00080000	// ldr r0,[200h]
43 #define ARM_MRS				0x00100000	// differentiate between msr und mrs
44 #define ARM_SWI				0x00200000	// software interrupt
45 #define ARM_COPOP			0x00400000	// cp opcode number
46 #define ARM_COPINF			0x00800000	// cp information number
47 #define ARM_DN				0x01000000	// rn = rd
48 #define ARM_DM				0x02000000	// rm = rd
49 #define ARM_SIGN			0x04000000	// sign
50 #define ARM_RDEVEN			0x08000000	// rd has to be even
51 #define ARM_OPTIMIZE		0x10000000	// optimization
52 #define ARM_OPMOVMVN		0x20000000	// ... of mov/mvn
53 #define ARM_OPANDBIC		0x40000000	// ... of and/bic
54 #define ARM_OPCMPCMN		0x80000000	// ... of cmp/cmn
55 #define ARM_PCR			   0x100000000	// pc relative
56 
57 typedef struct {
58 	const char* name;
59 	const char* mask;
60 	unsigned int encoding;
61 	unsigned int type:4;
62 	int64_t flags;
63 } tArmOpcode;
64 
65 #define ARM_AMODE_IB 0
66 #define ARM_AMODE_IA 1
67 #define ARM_AMODE_DB 2
68 #define ARM_AMODE_DA 3
69 #define ARM_AMODE_ED 4
70 #define ARM_AMODE_FD 5
71 #define ARM_AMODE_EA 6
72 #define ARM_AMODE_FA 7
73 
74 typedef struct {
75 	unsigned char p:1;
76 	unsigned char u:1;
77 } tArmAddressingMode;
78 
79 extern const tArmOpcode ArmOpcodes[];
80 extern const unsigned char LdmModes[8];
81 extern const unsigned char StmModes[8];
82