ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/build68k.c
Revision: 1.4
Committed: 2001-03-19T13:11:40Z (23 years, 8 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: snapshot-15012002, snapshot-29052001, release-0_9-1
Changes since 1.3: +1 -0 lines
Log Message:
Additions:
- MOVE16 (Ay)+,(xxx).L
- MOVE16 (xxx).L,(Ay)+
- MOVE16 (Ay),(xxx).L
- MOVE16 (xxx).L,(Ay)

Fixes:
- MOVE16 (Ax)+,(Ay)+ where x == y: address register shall be incremented
  only once
- CINV, CPUSH: 'p' field matches correctly the instruction 'cache field'

File Contents

# Content
1 /*
2 * UAE - The Un*x Amiga Emulator
3 *
4 * Read 68000 CPU specs from file "table68k" and build table68k.c
5 *
6 * Copyright 1995,1996 Bernd Schmidt
7 */
8
9 #include <assert.h>
10 #include <ctype.h>
11 #include <stdio.h>
12
13 #include "sysdeps.h"
14 #include "readcpu.h"
15
16 static FILE *tablef;
17 static int nextch = 0;
18
19 static void getnextch(void)
20 {
21 do {
22 nextch = fgetc(tablef);
23 if (nextch == '%') {
24 do {
25 nextch = fgetc(tablef);
26 } while (nextch != EOF && nextch != '\n');
27 }
28 } while (nextch != EOF && isspace(nextch));
29 }
30
31 static int nextchtohex(void)
32 {
33 switch (isupper (nextch) ? tolower (nextch) : nextch) {
34 case '0': return 0;
35 case '1': return 1;
36 case '2': return 2;
37 case '3': return 3;
38 case '4': return 4;
39 case '5': return 5;
40 case '6': return 6;
41 case '7': return 7;
42 case '8': return 8;
43 case '9': return 9;
44 case 'a': return 10;
45 case 'b': return 11;
46 case 'c': return 12;
47 case 'd': return 13;
48 case 'e': return 14;
49 case 'f': return 15;
50 default: abort();
51 }
52 }
53
54 int main(int argc, char **argv)
55 {
56 int no_insns = 0;
57
58 printf ("#include \"sysdeps.h\"\n");
59 printf ("#include \"readcpu.h\"\n");
60 printf ("struct instr_def defs68k[] = {\n");
61 #if 0
62 tablef = fopen("table68k","r");
63 if (tablef == NULL) {
64 fprintf(stderr, "table68k not found\n");
65 exit(1);
66 }
67 #else
68 tablef = stdin;
69 #endif
70 getnextch();
71 while (nextch != EOF) {
72 int cpulevel, plevel, sduse;
73 int i;
74
75 char patbits[16];
76 char opcstr[256];
77 int bitpos[16];
78 int flagset[5], flaguse[5];
79
80 unsigned int bitmask,bitpattern;
81 int n_variable;
82
83 n_variable = 0;
84 bitmask = bitpattern = 0;
85 memset (bitpos, 0, sizeof(bitpos));
86 for(i=0; i<16; i++) {
87 int currbit;
88 bitmask <<= 1;
89 bitpattern <<= 1;
90
91 switch (nextch) {
92 case '0': currbit = bit0; bitmask |= 1; break;
93 case '1': currbit = bit1; bitmask |= 1; bitpattern |= 1; break;
94 case 'c': currbit = bitc; break;
95 case 'C': currbit = bitC; break;
96 case 'f': currbit = bitf; break;
97 case 'i': currbit = biti; break;
98 case 'I': currbit = bitI; break;
99 case 'j': currbit = bitj; break;
100 case 'J': currbit = bitJ; break;
101 case 'k': currbit = bitk; break;
102 case 'K': currbit = bitK; break;
103 case 's': currbit = bits; break;
104 case 'S': currbit = bitS; break;
105 case 'd': currbit = bitd; break;
106 case 'D': currbit = bitD; break;
107 case 'r': currbit = bitr; break;
108 case 'R': currbit = bitR; break;
109 case 'z': currbit = bitz; break;
110 case 'p': currbit = bitp; break;
111 default: abort();
112 }
113 if (!(bitmask & 1)) {
114 bitpos[n_variable] = currbit;
115 n_variable++;
116 }
117
118 if (nextch == '0' || nextch == '1')
119 bitmask |= 1;
120 if (nextch == '1')
121 bitpattern |= 1;
122 patbits[i] = nextch;
123 getnextch();
124 }
125
126 while (isspace(nextch) || nextch == ':') /* Get CPU and privilege level */
127 getnextch();
128
129 switch (nextch) {
130 case '0': cpulevel = 0; break;
131 case '1': cpulevel = 1; break;
132 case '2': cpulevel = 2; break;
133 case '3': cpulevel = 3; break;
134 case '4': cpulevel = 4; break;
135 case '5': cpulevel = 5; break;
136 default: abort();
137 }
138 getnextch();
139
140 switch (nextch) {
141 case '0': plevel = 0; break;
142 case '1': plevel = 1; break;
143 case '2': plevel = 2; break;
144 case '3': plevel = 3; break;
145 default: abort();
146 }
147 getnextch();
148
149 while (isspace(nextch)) /* Get flag set information */
150 getnextch();
151
152 if (nextch != ':')
153 abort();
154
155 for(i = 0; i < 5; i++) {
156 getnextch();
157 switch(nextch){
158 case '-': flagset[i] = fa_unset; break;
159 case '/': flagset[i] = fa_isjmp; break;
160 case '0': flagset[i] = fa_zero; break;
161 case '1': flagset[i] = fa_one; break;
162 case 'x': flagset[i] = fa_dontcare; break;
163 case '?': flagset[i] = fa_unknown; break;
164 default: flagset[i] = fa_set; break;
165 }
166 }
167
168 getnextch();
169 while (isspace(nextch))
170 getnextch();
171
172 if (nextch != ':') /* Get flag used information */
173 abort();
174
175 for(i = 0; i < 5; i++) {
176 getnextch();
177 switch(nextch){
178 case '-': flaguse[i] = fu_unused; break;
179 case '/': flaguse[i] = fu_isjmp; break;
180 case '+': flaguse[i] = fu_maybecc; break;
181 case '?': flaguse[i] = fu_unknown; break;
182 default: flaguse[i] = fu_used; break;
183 }
184 }
185
186 getnextch();
187 while (isspace(nextch))
188 getnextch();
189
190 if (nextch != ':') /* Get source/dest usage information */
191 abort();
192
193 getnextch();
194 sduse = nextchtohex() << 4;
195 getnextch();
196 sduse |= nextchtohex();
197
198 getnextch();
199 while (isspace(nextch))
200 getnextch();
201
202 if (nextch != ':')
203 abort();
204
205 fgets(opcstr, 250, tablef);
206 getnextch();
207 {
208 int j;
209 /* Remove superfluous spaces from the string */
210 char *opstrp = opcstr, *osendp;
211 int slen = 0;
212
213 while (isspace(*opstrp))
214 opstrp++;
215
216 osendp = opstrp;
217 while (*osendp) {
218 if (!isspace (*osendp))
219 slen = osendp - opstrp + 1;
220 osendp++;
221 }
222 opstrp[slen] = 0;
223
224 if (no_insns > 0)
225 printf(",\n");
226 no_insns++;
227 printf("{ %d, %d, {", bitpattern, n_variable);
228 for (j = 0; j < 16; j++) {
229 printf("%d", bitpos[j]);
230 if (j < 15)
231 printf(",");
232 }
233 printf ("}, %d, %d, %d, { ", bitmask, cpulevel, plevel);
234 for(i = 0; i < 5; i++) {
235 printf("{ %d, %d }%c ", flaguse[i], flagset[i], i == 4 ? ' ' : ',');
236 }
237 printf("}, %d, \"%s\"}", sduse, opstrp);
238 }
239 }
240 printf("};\nint n_defs68k = %d;\n", no_insns);
241 return 0;
242 }