4 |
|
* Read 68000 CPU specs from file "table68k" and build table68k.c |
5 |
|
* |
6 |
|
* Copyright 1995,1996 Bernd Schmidt |
7 |
+ |
* |
8 |
+ |
* This program is free software; you can redistribute it and/or modify |
9 |
+ |
* it under the terms of the GNU General Public License as published by |
10 |
+ |
* the Free Software Foundation; either version 2 of the License, or |
11 |
+ |
* (at your option) any later version. |
12 |
+ |
* |
13 |
+ |
* This program is distributed in the hope that it will be useful, |
14 |
+ |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
+ |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
+ |
* GNU General Public License for more details. |
17 |
+ |
* |
18 |
+ |
* You should have received a copy of the GNU General Public License |
19 |
+ |
* along with this program; if not, write to the Free Software |
20 |
+ |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
|
*/ |
22 |
|
|
23 |
|
#include <assert.h> |
72 |
|
printf ("#include \"sysdeps.h\"\n"); |
73 |
|
printf ("#include \"readcpu.h\"\n"); |
74 |
|
printf ("struct instr_def defs68k[] = {\n"); |
75 |
< |
#if 0 |
76 |
< |
tablef = fopen("table68k","r"); |
75 |
> |
#ifdef WIN32 |
76 |
> |
tablef = fopen(argc > 1 ? argv[1] : "table68k","r"); |
77 |
|
if (tablef == NULL) { |
78 |
|
fprintf(stderr, "table68k not found\n"); |
79 |
|
exit(1); |
90 |
|
char opcstr[256]; |
91 |
|
int bitpos[16]; |
92 |
|
int flagset[5], flaguse[5]; |
93 |
+ |
char cflow; |
94 |
|
|
95 |
|
unsigned int bitmask,bitpattern; |
96 |
|
int n_variable; |
122 |
|
case 'r': currbit = bitr; break; |
123 |
|
case 'R': currbit = bitR; break; |
124 |
|
case 'z': currbit = bitz; break; |
125 |
+ |
case 'E': currbit = bitE; break; |
126 |
+ |
case 'p': currbit = bitp; break; |
127 |
|
default: abort(); |
128 |
|
} |
129 |
|
if (!(bitmask & 1)) { |
148 |
|
case '2': cpulevel = 2; break; |
149 |
|
case '3': cpulevel = 3; break; |
150 |
|
case '4': cpulevel = 4; break; |
151 |
+ |
case '5': cpulevel = 5; break; |
152 |
|
default: abort(); |
153 |
|
} |
154 |
|
getnextch(); |
172 |
|
getnextch(); |
173 |
|
switch(nextch){ |
174 |
|
case '-': flagset[i] = fa_unset; break; |
157 |
– |
case '/': flagset[i] = fa_isjmp; break; |
175 |
|
case '0': flagset[i] = fa_zero; break; |
176 |
|
case '1': flagset[i] = fa_one; break; |
177 |
|
case 'x': flagset[i] = fa_dontcare; break; |
191 |
|
getnextch(); |
192 |
|
switch(nextch){ |
193 |
|
case '-': flaguse[i] = fu_unused; break; |
177 |
– |
case '/': flaguse[i] = fu_isjmp; break; |
178 |
– |
case '+': flaguse[i] = fu_maybecc; break; |
194 |
|
case '?': flaguse[i] = fu_unknown; break; |
195 |
|
default: flaguse[i] = fu_used; break; |
196 |
|
} |
200 |
|
while (isspace(nextch)) |
201 |
|
getnextch(); |
202 |
|
|
203 |
+ |
if (nextch != ':') /* Get control flow information */ |
204 |
+ |
abort(); |
205 |
+ |
|
206 |
+ |
cflow = 0; |
207 |
+ |
for(i = 0; i < 2; i++) { |
208 |
+ |
getnextch(); |
209 |
+ |
switch(nextch){ |
210 |
+ |
case '-': break; |
211 |
+ |
case 'R': cflow |= fl_return; break; |
212 |
+ |
case 'B': cflow |= fl_branch; break; |
213 |
+ |
case 'J': cflow |= fl_jump; break; |
214 |
+ |
case 'T': cflow |= fl_trap; break; |
215 |
+ |
default: abort(); |
216 |
+ |
} |
217 |
+ |
} |
218 |
+ |
|
219 |
+ |
getnextch(); |
220 |
+ |
while (isspace(nextch)) |
221 |
+ |
getnextch(); |
222 |
+ |
|
223 |
|
if (nextch != ':') /* Get source/dest usage information */ |
224 |
|
abort(); |
225 |
|
|
267 |
|
for(i = 0; i < 5; i++) { |
268 |
|
printf("{ %d, %d }%c ", flaguse[i], flagset[i], i == 4 ? ' ' : ','); |
269 |
|
} |
270 |
< |
printf("}, %d, \"%s\"}", sduse, opstrp); |
270 |
> |
printf("}, %d, %d, \"%s\"}", cflow, sduse, opstrp); |
271 |
|
} |
272 |
|
} |
273 |
|
printf("};\nint n_defs68k = %d;\n", no_insns); |
274 |
< |
fclose(tablef); |
274 |
> |
fflush(stdout); |
275 |
|
return 0; |
276 |
|
} |