Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 104 lines (84 sloc) 3.186 kB
2396921 new improved EDA
George Hotz authored
1 // InstructionFactoryARM.h -- May 9, 2009
2 // by geohot
3 // part of "The Embedded Disassembler"
4 // released under GPLv3, see http://gplv3.fsf.org/
5
a0410d0 more
George Hotz authored
6 #ifndef EDA_INSTRUCTIONFACTORYARM_H_
7 #define EDA_INSTRUCTIONFACTORYARM_H_
8
9 #include <string>
10 using namespace std;
11
78972f0 simulated first instruction
unknown authored
12 #include "logic.h"
13
14 #include "data.h"
15
16 using namespace eda;
17
18 class InstructionFactoryARM : public InstructionFactory {
19 public:
20 Address* Process(Address* start);
21 void InitRegisters(Memory* m);
c5ee989 Added relative addressing. Added more XML commands.
unknown authored
22 void StateToXML(std::ostringstream& out);
23 // Convert raw register to real instruction pointer
1d657e9 Control Flow + Functions
unknown authored
24 uint32_t TranslateToProgramCounter(uint32_t in) {
c5ee989 Added relative addressing. Added more XML commands.
unknown authored
25 // ARM PC is 8 ahead of the real program counter
26 return in-8;
27 }
1d657e9 Control Flow + Functions
unknown authored
28
29 uint32_t TranslateFromProgramCounter(uint32_t in) {
30 // ARM PC is 8 ahead of the real program counter
31 return in+8;
32 }
78972f0 simulated first instruction
unknown authored
33 };
34
2396921 new improved EDA
George Hotz authored
35 namespace ARM {
78972f0 simulated first instruction
unknown authored
36
2396921 new improved EDA
George Hotz authored
37 const string conditions[16] = { "EQ", "NE", "HS", "LO", "MI", "PL",
38 "VS", "VC", "HI", "LS", "GE", "LT", "GT", "LE", "", "" };
39 const string registers[18] = { "R0", "R1", "R2", "R3", "R4", "R5", "R6",
40 "R7", "R8", "R9", "R10", "R11", "R12", "SP", "LR", "PC", "CPSR", "SPSR" };
41 const string opcodes[16] = { "AND", "XOR", "SUB", "RSB", "ADD", "ADC",
42 "SBC", "RSC", "TST", "TEQ", "CMP", "CMN", "ORR", "MOV", "BIC", "MVN" };
43 const string shifts[4] = { "LSL", "LSR", "ASR", "ROR" };
44
45 // All based off CPSR, CPSR is NZCV...
1674ae8 sort of runs
George Hotz authored
46 const string Z = "(([`CPSR`] >> 30) & 1)";
47 const string C = "(([`CPSR`] >> 29) & 1)";
48 const string N = "(([`CPSR`] >> 31) & 1)";
49 const string V = "(([`CPSR`] >> 28) & 1)";
2396921 new improved EDA
George Hotz authored
50
51 const string conditions_absolute[16] = {
52 Z, // EQ, Z set
53 "~"+Z, // NE, Z clear
54 C, // HS, C set
55 "~"+C, // LO, C clear
56 N, // MI, N set
57 "~"+N, // PL, N clear
58 V, // VS, V set
59 "~"+V, // VC, V clear
60 C+"&~"+Z, // HI, C set and Z clear
61 Z+"|~"+C, // LS, C clear or Z set
62 //GE, N set and V set or N clear and V clear
63 "~("+N+"^"+V+")",
64 //LT, N set and V clear or N clear and V set
65 N+"^"+V,
66 //GT, Z clear and either N set and V set or N clear and V clear
67 "~"+Z+"&~("+N+"^"+V+")",
fcb52fd Big changes are coming...
unknown authored
68 //LE, Z set and either N set and V clear or N set and V clear
69 Z+"|("+N+"^"+V+")",
2396921 new improved EDA
George Hotz authored
70 "1",
71 "1"
72 };
73
74 const string opcodes_absolute[16] = {
75 // C is update carry
76 // NS is no store
77 // NF is no first(Rn)
1674ae8 sort of runs
George Hotz authored
78 //AND XOR SUB RSB ADD ADC SBC RSC TST TEQ CMP CMN ORR MOV BIC MVN
79 // C C C NS NS NS NS NF NF
d8725a0 Frontend does something
unknown authored
80 "&(","^(","-(","*-1+(","+(","+(","-(","*-1+(","&(","^(","-(","+(","|(","(", "&(~","(~"
2396921 new improved EDA
George Hotz authored
81 };
82
a0410d0 more
George Hotz authored
83 #define F_C 1
84 #define F_NS 2
85 #define F_NF 4
86
87 const int opcodes_flags[16] = {
1674ae8 sort of runs
George Hotz authored
88 //AND XOR SUB RSB ADD ADC SBC RSC TST TEQ CMP CMN ORR MOV BIC MVN
89 // C C C NS NS NS NS NF NF
90 0, 0, 0, 0, 0, F_C,F_C,F_C, F_NS,F_NS,F_NS,F_NS,0, F_NF,0, F_NF
a0410d0 more
George Hotz authored
91 };
92
93 const string shifts_absolute[4] = { "<<", ">>", ">>>", ">/>" };
94
852e176 Integrated funman's MRC/MCR/SWI instructions
unknown authored
95 const string coprocessors[16] = { "P0", "P1", "P2", "P3", "P4", "P5", "P6",
96 "P7", "P8", "P9", "P10", "P11", "P12", "P13", "P14", "P15" };
97
98 const string cp_registers[16] = { "C0", "C1", "C2", "C3", "C4", "C5", "C6",
99 "C7", "C8", "C9", "C10", "C11", "C12", "C13", "C14", "C15" };
100
2396921 new improved EDA
George Hotz authored
101 }
a0410d0 more
George Hotz authored
102
103 #endif
Something went wrong with that request. Please try again.