3 * (C) Copyright Apr 15 1995, Edmond J. Breen.
5 * This code may be copied for personal, non-profit use only.
15 static void showjmptab(InsT_t * inst, int i, int spaces)
24 for (k = 0; k < spaces; k++)
26 printf(" default %d\n", i + p->loc[0].ival);
27 for (j = 1; j < p->n; j += 2) {
28 for (k = 0; k < spaces; k++)
31 printf(" case %d: %d\n", p->loc[j].ival,
32 i + p->loc[j + 1].ival);
40 static void showcode(InsT_t * inst,int i)
42 static char str[30], *s;
45 switch (inst->opcode) {
46 case __eiclongjmp: s = "__eiclongjmp"; break;
47 case __eicsetjmp: s = "__eicsetjmp"; break;
48 case jmptab: s = "jmptab"; break;
49 case lval: sprintf(str, "lval %d %d",
53 case ixa: sprintf(str, "ixa %d %d",inst->val.ival, inst->ext);
55 case lda: sprintf(str, "lda %d %d",inst->val.ival, inst->ext);
58 case refchar: s = "refchar"; break;
59 case drefuchar: s = "drefuchar"; break;
60 case drefchar: s = "drefchar"; break;
61 case rvaluchar: sprintf(str, "rvaluchar %d %d",
64 case rvalchar: sprintf(str, "rvalchar %d %d",
67 case stochar: sprintf(str, "stochar %d %d",
71 case refshort: s = "refshort"; break;
72 case drefushort: s = "drefushort"; break;
73 case drefshort: s = "drefshort"; break;
74 case rvalushort: sprintf(str, "rvalushort %d %d",
77 case rvalshort: sprintf(str, "rvalshort %d %d",
80 case stoshort: sprintf(str, "stoshort %d %d",
85 case reffloat: s = "reffloat"; break;
86 case dreffloat: s = "dreffloat"; break;
87 case rvalfloat: sprintf(str, "rvalfloat %d %d",
90 case stofloat: sprintf(str, "stofloat %d %d",
94 case jmpFint: sprintf(str, "jmpFint %d", i + inst->val.ival); break;
95 case jmpFlng: sprintf(str, "jmpFlng %d", i + inst->val.ival); break;
96 case jmpFllng: sprintf(str, "jmpFllng %d", i + inst->val.ival); break;
97 case jmpFdbl: sprintf(str, "jmpFdbl %d", i + inst->val.ival); break;
98 case jmpFptr: sprintf(str, "jmpFptr %d", i + inst->val.ival); break;
100 case jmpTint: sprintf(str, "jmpTint %d", i + inst->val.ival); break;
101 case jmpTlng: sprintf(str, "jmpTlng %d", i + inst->val.ival); break;
102 case jmpTllng: sprintf(str, "jmpTllng %d", i + inst->val.ival); break;
103 case jmpTdbl: sprintf(str, "jmpTdbl %d", i + inst->val.ival); break;
104 case jmpTptr: sprintf(str, "jmpTptr %d", i + inst->val.ival); break;
106 case jmpu: sprintf(str, "jmpU %d", i + inst->val.ival); break;
107 case halt: s = "halt"; break;
108 case dupval: sprintf(str,"dupval %d",inst->val.ival); break;
109 case bump: sprintf(str,"bump %d", inst->val.ival); break;
110 case call: s = "call"; break;
112 case neguchar: s = "neguchar"; break;
114 case stodouble: sprintf(str, "stodouble %d %d",
117 case pushdouble: sprintf(str, "pushdouble %g", inst->val.dval); break;
118 case rvaldouble: sprintf(str, "rvaldouble %d %d",
122 case incdouble: s = "incdouble"; break;
123 case decdouble: s = "decdouble"; break;
124 case refdouble: s = "refdouble"; break;
125 case drefdouble: s = "drefdouble "; break;
126 case negdouble: s = "negdouble"; break;
127 case ltdouble: s = "ltdouble"; break;
128 case ledouble: s = "ledouble"; break;
129 case eqdouble: s = "eqdouble"; break;
130 case nedouble: s = "nedouble"; break;
131 case gtdouble: s = "gtdouble"; break;
132 case gedouble: s = "gedouble"; break;
133 case lordouble: s = "lordouble"; break;
134 case landdouble: s = "landdouble"; break;
135 case notdouble: s = "notdouble"; break;
136 case adddouble: s = "adddouble"; break;
137 case subdouble: s = "subdouble"; break;
138 case divdouble: s = "divdouble"; break;
139 case multdouble: s = "multdouble"; break;
140 case double2int: s = "double2int"; break;
141 case double2long: s = "double2long"; break;
142 case double2llong: s = "double2llong"; break;
143 case double2float: s = "double2float"; break;
145 case stoint: sprintf(str, "stoint %d %d",
148 case pushint: sprintf(str, "pushint %d", inst->val.ival); break;
149 case rvalint: sprintf(str, "rvalint %d %d",
152 case drefint: s = "drefint "; break;
153 case refint: s = "refint "; break;
154 case decint: sprintf(str, "decint %d", inst->val.ival); break;
155 case incint: sprintf(str, "incint %d", inst->val.ival); break;
156 case negint: s = "negint"; break;
157 case ltint: s = "ltint"; break;
158 case leint: s = "leint"; break;
159 case eqint: s = "eqint"; break;
160 case neint: s = "neint"; break;
161 case gtint: s = "gtint"; break;
162 case geint: s = "geint"; break;
163 case lorint: s = "lorint"; break;
164 case landint: s = "landint"; break;
165 case notint: s = "notint"; break;
166 case borint: s = "borint"; break;
167 case xorint: s = "xorint"; break;
168 case andint: s = "andint"; break;
169 case addint: s = "addint"; break;
170 case subint: s = "subint"; break;
171 case divint: s = "divint"; break;
172 case multint: s = "multint"; break;
173 case modint: s = "modint"; break;
174 case lshtint: s = "lshtint"; break;
175 case rshtint: s = "rshtint"; break;
176 case compint: s = "compint"; break;
177 case int2ptr: s = "int2ptr"; break;
178 case int2uchar: s = "int2uchar"; break;
179 case int2ushort: s = "int2ushort"; break;
181 case int2double: s = "int2double"; break;
182 case int2llong: s = "int2llong"; break;
183 case int2long: s = "int2llong"; break;
186 case stouint: sprintf(str, "stouint %d %d",
189 case pushuint: sprintf(str, "pushuint %u", inst->val.ival); break;
190 case rvaluint: sprintf(str, "rvaluint %d %d",
193 case drefuint: s = "drefuint "; break;
194 case refuint: s = "refuint "; break;
195 case decuint: sprintf(str, "decuint %d", inst->val.ival); break;
196 case incuint: sprintf(str, "incuint %d", inst->val.ival); break;
197 case neguint: s = "neguint"; break;
198 case ltuint: s = "ltuint"; break;
199 case leuint: s = "leuint"; break;
200 case equint: s = "equint"; break;
201 case neuint: s = "neuint"; break;
202 case gtuint: s = "gtuint"; break;
203 case geuint: s = "geuint"; break;
204 case loruint: s = "loruint"; break;
206 case notuint: s = "notuint"; break;
207 case boruint: s = "boruint"; break;
208 case xoruint: s = "xoruint"; break;
209 case anduint: s = "anduint"; break;
210 case adduint: s = "adduint"; break;
211 case subuint: s = "subuint"; break;
212 case divuint: s = "divuint"; break;
213 case multuint: s = "multuint"; break;
214 case moduint: s = "moduint"; break;
215 case lshtuint: s = "lshtuint"; break;
216 case rshtuint: s = "rshtuint"; break;
217 case compuint: s = "compuint"; break;
219 case uint2ptr: s = "uint2ptr"; break;
220 case uint2long: s = "uint2long"; break;
221 case uint2llong: s = "uint2llong"; break;
222 case uint2double: s = "uint2double"; break;
224 case stolong: sprintf(str, "stolong %d %d",
227 case stollong: sprintf(str, "stollong %d %d",
230 case pushlong: sprintf(str, "pushlong %ld", inst->val.lval); break;
231 case pushllong: sprintf(str, "pushllong %ld", inst->val.lval); break;
232 case rvallong: sprintf(str, "rvallong %d %d",
235 case rvalllong: sprintf(str, "rvalllong %d %d",
239 case dreflong: s = "dreflong "; break;
240 case reflong: s = "reflong "; break;
241 case declong: sprintf(str, "declong %d", inst->val.ival); break;
242 case inclong: sprintf(str, "inclong %d", inst->val.ival); break;
243 case neglong: s = "neglong"; break;
244 case ltlong: s = "ltlong"; break;
245 case lelong: s = "lelong"; break;
246 case eqlong: s = "eqlong"; break;
247 case nelong: s = "nelong"; break;
248 case gtlong: s = "gtlong"; break;
249 case gelong: s = "gelong"; break;
250 case lorlong: s = "lorlong"; break;
251 case landlong: s = "landlong"; break;
252 case notlong: s = "notlong"; break;
253 case borlong: s = "borlong"; break;
254 case xorlong: s = "xorlong"; break;
255 case andlong: s = "andlong"; break;
256 case addlong: s = "addlong"; break;
257 case sublong: s = "sublong"; break;
258 case divlong: s = "divlong"; break;
259 case multlong: s = "multlong"; break;
260 case modlong: s = "modlong"; break;
261 case lshtlong: s = "lshtlong"; break;
262 case rshtlong: s = "rshtlong"; break;
263 case complong: s = "complong"; break;
266 case drefllong: s = "drefllong "; break;
267 case refllong: s = "refllong "; break;
268 case decllong: sprintf(str, "decllong %d", inst->val.ival); break;
269 case incllong: sprintf(str, "incllong %d", inst->val.ival); break;
270 case negllong: s = "negllong"; break;
271 case ltllong: s = "ltllong"; break;
272 case lellong: s = "lellong"; break;
273 case eqllong: s = "eqllong"; break;
274 case nellong: s = "nellong"; break;
275 case gtllong: s = "gtllong"; break;
276 case gellong: s = "gellong"; break;
277 case lorllong: s = "lorllong"; break;
278 case landllong: s = "landllong"; break;
279 case notllong: s = "notllong"; break;
280 case borllong: s = "borllong"; break;
281 case xorllong: s = "xorllong"; break;
282 case andllong: s = "andllong"; break;
283 case addllong: s = "addllong"; break;
284 case subllong: s = "subllong"; break;
285 case divllong: s = "divllong"; break;
286 case multllong: s = "multllong"; break;
287 case modllong: s = "modllong"; break;
288 case lshtllong: s = "lshtllong"; break;
289 case rshtllong: s = "rshtllong"; break;
290 case compllong: s = "compllong"; break;
294 case long2ptr: s = "long2ptr"; break;
295 case long2int: s = "long2int"; break;
296 case long2double: s = "long2double"; break;
298 case llong2ptr: s = "llong2ptr"; break;
299 case llong2int: s = "llong2int"; break;
300 case llong2double: s = "llong2double"; break;
302 case stoulong: sprintf(str, "stoulong %d %d",
305 case pushulong: sprintf(str, "pushulong %u", inst->val.ival); break;
306 case rvalulong: sprintf(str, "rvalulong %d %d",
309 case drefulong: s = "drefulong"; break;
310 case refulong: s = "refulong"; break;
311 case deculong: sprintf(str, "deculong %d", inst->val.ival); break;
312 case inculong: sprintf(str, "inculong %d", inst->val.ival); break;
313 case negulong: s = "negulong"; break;
314 case ltulong: s = "ltulong"; break;
315 case leulong: s = "leulong"; break;
316 case equlong: s = "equlong"; break;
317 case neulong: s = "neulong"; break;
318 case gtulong: s = "gtulong"; break;
319 case geulong: s = "geulong"; break;
320 case lorulong: s = "lorulong"; break;
322 case notulong: s = "notulong"; break;
323 case borulong: s = "borulong"; break;
324 case xorulong: s = "xorulong"; break;
325 case andulong: s = "andulong"; break;
326 case addulong: s = "addulong"; break;
327 case subulong: s = "subulong"; break;
328 case divulong: s = "divulong"; break;
329 case multulong: s = "multulong"; break;
330 case modulong: s = "modulong"; break;
331 case lshtulong: s = "lshtulong"; break;
332 case rshtulong: s = "rshtulong"; break;
333 case compulong: s = "compulong"; break;
335 case ulong2ptr: s = "ulong2ptr"; break;
336 case ulong2int: s = "ulong2int"; break;
337 case ulong2double: s = "ulong2double"; break;
339 case drefptr: s = "drefptr"; break;
340 case drefuptr: s = "drefuptr"; break;
341 case refptr: s = "refptr"; break;
342 case refuptr: s = "refuptr"; break;
344 case stouptr: sprintf(str, "stouptr %d %d",
348 case stoptr: sprintf(str, "stoptr %d %d",
351 case pushptr: sprintf(str, "pushptr %p", inst->val.p.p); break;
353 case rvaluptr: sprintf(str, "rvaluptr %d %d",
356 case rvalptr: sprintf(str, "rvalptr %d %d",
359 case incptr: sprintf(str, "incptr %d", inst->val.ival); break;
360 case decptr: sprintf(str, "decptr %d", inst->val.ival); break;
361 case ltptr: s = "ltptr"; break;
362 case leptr: s = "leptr"; break;
363 case eqptr: s = "eqptr"; break;
364 case neptr: s = "neptr"; break;
365 case gtptr: s = "gtptr"; break;
366 case geptr: s = "geptr"; break;
367 case lorptr: s = "lorptr"; break;
368 case landptr: s = "landptr"; break;
369 case notptr: s = "notptr"; break;
370 case addptr2int: s = "addptr2int"; break;
371 case addint2ptr: s = "addint2ptr"; break;
372 case subptrint: s = "subptrint"; break;
373 case subptr: s = "subptr"; break;
374 case divptr: sprintf(str, "divptr %d", inst->val.ival); break;
375 case ptr2int: s = "ptr2int"; break;
376 case ptr2long: s = "ptr2long"; break;
378 case eiccall: s = "eiccall"; break;
379 case eicreturn: s = "eicreturn"; break;
381 case assigntype: sprintf(str, "assigntype %d",
384 case stoval: s = "stoval"; break;
385 case pushval: s = "pushval"; break;
386 case reducear: sprintf(str, "reducear %d",
387 inst->val.ival); break;
389 case checkar: sprintf(str, "checkar %d %d",
393 case refmem: sprintf(str, "refmem %d",
394 inst->val.ival); break;
395 case massign: sprintf(str, "massign %d %d",
399 case fmem: sprintf(str, "fmem %d %d",
402 case minit: sprintf(str, "mcpy %p %d",
406 case empty: s = "empty"; break;
410 sprintf(str, "UNKNOWN %d", inst->opcode);
413 printf("%-20.20s", s);
415 printf("%-20.20s", str);
419 void EiC_listcode(code_t * CODE)
421 extern int EiC_lineNums;
422 int i, j, t, k, cols, rows, sp;
423 if (CODE->nextinst < 11)
425 else if (CODE->nextinst < 21)
430 rows = CODE->nextinst / cols;
431 if (CODE->nextinst % cols)
439 for (j = 0; j < rows; ++j) {
440 for (t = 0, i = j; i < CODE->nextinst; i += rows, t++) {
442 printf("%4d:", CODE->inst[i].line);
444 showcode(&CODE->inst[i], i);
445 if (CODE->inst[i].opcode == jmptab) {
446 showjmptab(&CODE->inst[i], i, t * sp);
448 for (k = 0; k < t; k++)