31 "eq",
"ne",
"cs",
"cc",
"mi",
"pl",
"vs",
"vc",
32 "hi",
"ls",
"ge",
"lt",
"gt",
"le",
"",
"" };
35 "and",
"eor",
"sub",
"rsb",
"add",
"adc",
"sbc",
"rsc",
36 "tst",
"teq",
"cmp",
"cmn",
"orr",
"mov",
"bic",
"mvn" };
39 static char *uppercase(
char *l)
41 static char staticbuf[1000];
44 while (*l && i <
sizeof(staticbuf)) {
46 if (u >=
'a' && u <=
'z')
50 if (i ==
sizeof(staticbuf))
57 int main(
int argc,
char *argv[])
59 int n, a,
reg, pc, s, c;
61 printf(
"\n/* AUTOMATICALLY GENERATED! Do not edit. */\n\n");
62 printf(
"#include <stdio.h>\n#include <stdlib.h>\n"
63 "#include \"cpu.h\"\n"
64 "#include \"misc.h\"\n"
65 "#define DYNTRANS_PC_TO_POINTERS arm_pc_to_pointers\n"
66 "#include \"quick_pc_to_pointers.h\"\n"
67 "#define reg(x) (*((uint32_t *)(x)))\n");
68 printf(
"extern void arm_instr_nop(struct cpu *, "
69 "struct arm_instr_call *);\n");
70 printf(
"extern void arm_instr_invalid(struct cpu *, "
71 "struct arm_instr_call *);\n");
72 printf(
"extern void arm_pc_to_pointers(struct cpu *);\n");
75 for (pc=0; pc<=1; pc++)
77 for (a=0; a<16; a++) {
78 if (a >= 8 && a <= 11 && s == 0)
82 printf(
"#define A__NAME arm_instr_%s%s%s%s\n",
83 op[a], s?
"s" :
"", pc?
"_pc" :
"",
reg?
84 (
reg==2?
"_regshort" :
"_reg") :
"");
87 printf(
"#define A__NAME__%s arm_instr_%s%s%s%s__%s\n",
88 cond[c],
op[a], s?
"s" :
"", pc?
"_pc" :
"",
89 reg? (
reg==2?
"_regshort" :
"_reg") :
"",
cond[c]);
90 if (s) printf(
"#define A__S\n");
92 case 1: printf(
"#define A__REG\n");
break;
93 case 2: printf(
"#define A__REGSHORT\n");
break;
95 if (pc) printf(
"#define A__PC\n");
96 printf(
"#define A__%s\n", uppercase(
op[a]));
97 printf(
"#include \"cpu_arm_instr_dpi.cc\"\n");
98 printf(
"#undef A__%s\n", uppercase(
op[a]));
99 if (s) printf(
"#undef A__S\n");
101 case 1: printf(
"#undef A__REG\n");
break;
102 case 2: printf(
"#undef A__REGSHORT\n");
break;
104 if (pc) printf(
"#undef A__PC\n");
106 printf(
"#undef A__NAME__%s\n",
cond[c]);
107 printf(
"#undef A__NAME\n");
110 printf(
"\n\tvoid (*arm_dpi_instr[2 * 2 * 2 * 16 * 16])(struct cpu *,\n"
111 "\t\tstruct arm_instr_call *) = {\n");
114 for (pc=0; pc<=1; pc++)
117 for (c=0; c<16; c++) {
119 printf(
"\tarm_instr_nop");
120 else if (a >= 8 && a <= 11 && s == 0)
121 printf(
"\tarm_instr_invalid");
123 printf(
"\tarm_instr_%s%s%s%s%s%s",
124 op[a], s?
"s" :
"", pc?
"_pc" :
"",
126 c!=14?
"__" :
"",
cond[c]);
128 if (n != 2 * 2 * 2 * 16 * 16)
135 printf(
"\n\tvoid (*arm_dpi_instr_regshort[2 * 16 * 16])(struct cpu *,\n"
136 "\t\tstruct arm_instr_call *) = {\n");
140 for (c=0; c<16; c++) {
142 printf(
"\tarm_instr_nop");
143 else if (a >= 8 && a <= 11 && s == 0)
144 printf(
"\tarm_instr_invalid");
146 printf(
"\tarm_instr_%s%s_regshort%s%s",
148 c!=14?
"__" :
"",
cond[c]);
150 if (n != 2 * 16 * 16)