|
|
1.1 root 1: /***
2: * 68k disassembler, written 2010 by Markus Fritze, www.sarnau.com
3: *
1.1.1.4 root 4: * This file is distributed under the GNU General Public License, version 2
5: * or at your option any later version. Read the file gpl.txt for details.
1.1 root 6: ***/
7:
1.1.1.7 root 8: #include "main.h"
1.1 root 9: #include <ctype.h>
1.1.1.7 root 10: #if HAVE_STRINGS_H
11: # include <strings.h>
12: #endif
1.1 root 13:
14: #include "sysdeps.h"
1.1.1.4 root 15: #include "configuration.h"
1.1 root 16: #include "newcpu.h"
1.1.1.7 root 17: #include "stMemory.h"
1.1.1.6 root 18: #ifdef WINUAE_FOR_HATARI
19: #include "debug.h"
20: #endif
1.1 root 21: #include "paths.h"
1.1.1.3 root 22: #include "profile.h"
1.1 root 23: #include "tos.h"
24: #include "68kDisass.h"
25:
26: #define ADDRESS_ON_PC 1
27: #define USE_SYMBOLS 1
28:
29: typedef enum {
30: doptNoBrackets = 1, // hide brackets around absolute addressing
31: doptOpcodesSmall = 2, // opcodes are small letters
32: doptRegisterSmall = 4, // register names are small letters
1.1.1.5 root 33: doptStackSP = 8 // stack pointer is named "SP" instead of "A7" (except for MOVEM)
1.1 root 34: } Diss68kOptions;
35:
36: static Diss68kOptions options = doptOpcodesSmall | doptRegisterSmall | doptStackSP | doptNoBrackets;
37:
1.1.1.4 root 38: /* all options */
39: static const Diss68kOptions optionsMask = doptOpcodesSmall | doptRegisterSmall | doptStackSP | doptNoBrackets;
40:
1.1 root 41: // values <0 will hide the group
1.1.1.4 root 42: static int optionPosAddress = 0; // current address
1.1.1.6 root 43: static int optionPosHexdump = 12; // 16-bit words at this address
1.1.1.4 root 44: static int optionPosLabel = 35; // label, if defined
45: static int optionPosOpcode = 47; // opcode
46: static int optionPosOperand = 57; // operands for the opcode
47: static int optionPosComment = 82; // comment, if defined
1.1 root 48:
49: /***
50: * Motorola 16-/32-Bit Microprocessor and coprocessor types
51: ***/
52: #define MC68000 0x000001 // 16-/32-Bit Microprocessor
53: #define MC68EC000 0x000002 // 16-/32-Bit Embedded Controller
54: #define MC68HC000 0x000004 // Low Power 16-/32-Bit Microprocessor
55: #define MC68008 0x000008 // 16-Bit Microprocessor with 8-Bit Data Bus
56: #define MC68010 0x000010 // 16-/32-Bit Virtual Memory Microprocessor
57: #define MC68020 0x000020 // 32-Bit Virtual Memory Microprocessor
58: #define MC68EC020 0x000040 // 32-Bit Embedded Controller (no PMMU)
59: #define MC68030 0x000080 // Second-Generation 32-Bit Enhanced Microprocessor
60: #define MC68EC030 0x000100 // 32-Bit Embedded Controller (no PMMU)
61: #define MC68040 0x000200 // Third-Generation 32-Bit Microprocessor
62: #define MC68LC040 0x000400 // Third-Generation 32-Bit Microprocessor (no FPU)
63: #define MC68EC040 0x000800 // 32-Bit Embedded Controller (no FPU, no PMMU)
64: #define MC68330 0x001000 // CPU32 Integrated CPU32 Processor
65: #define MC68340 0x002000 // CPU32 Integrated Processor with DMA
66: #define MC68060 0x004000 // Fourth-Generation 32-Bit Microprocessor
67: #define MC68LC060 0x008000 // Fourth-Generation 32-Bit Microprocessor (no FPU)
68: #define MC68EC060 0x010000 // Fourth-Generation 32-Bit Microprocessor (no FPU, no PMMU)
69: #define MC_CPU32 (MC68330|MC68340)
70:
71: #define MC_020 (MC68020|MC68EC020|MC68030|MC68EC030|MC68040|MC68LC040|MC68EC040|MC_CPU32|MC68060|MC68LC060|MC68EC060)
72: #define MC_ALL (MC68000|MC68EC000|MC68HC000|MC68008|MC68010|MC_020)
73:
74: #define MC68851 0x020000 // Paged Memory Management Unit
75:
76: #define MC68881 0x040000 // Floating-PointCoprocessor
77: #define MC68882 0x080000 // Enhanced Floating-Point Coprocessor
78:
79: #define MC_PMMU (MC68881|MC68882)
80: #define MC_FPU (MC68881|MC68882)
81:
82: static int optionCPUTypeMask = ( MC_ALL & ~MC68040 & ~MC_CPU32 & ~MC68060 ) | MC_PMMU | MC_FPU;
83:
84:
85: typedef enum {
86: dtNone,
87: dtByte, // a specific number of bytes, usually 1
88: dtWord, // one 16-bit value
89: dtLong, // one 32-bit value
90: dtOpcode, // an opcode of variable length
91: dtASCString, // a 0-byte terminated ASCII string
92: dtPointer, // a generic 32-bit pointer
93: dtFunctionPointer, // a 32-bit pointer to a function
1.1.1.5 root 94: dtStringArray // a specific number of ASCII bytes
1.1 root 95: } Disass68kDataType;
96:
97: typedef struct {
98: char *name;
99: char *comment;
100: Disass68kDataType type;
101: int size;
102: } disStructElement;
103:
104: typedef struct {
105: char *name; // name of the structure
106: int size; // size of structure
107: int count; // number of lines
108: disStructElement *elements; // array of all elements of the struct
109: } disStructEntry;
110:
111: static int disStructCounts;
112: static disStructEntry *disStructEntries;
113:
114: typedef struct {
115: long addr; // address of the label
116: Disass68kDataType type; // type of the data on the address
117: int size; // size of the label, references inside it are addressed via base address + offset
118: int count; // number of elements at this address with the given size
119: int structIndex; // -1 no struct to describe the element
120: char *name; // name of the label
121: char *comment; // optional comment
122: } disSymbolEntry;
123:
124: static int disSymbolCounts;
125: static disSymbolEntry *disSymbolEntries;
126:
127:
128: static inline unsigned short Disass68kGetWord(long addr)
129: {
1.1.1.6 root 130: if ( ! valid_address ( addr , 2 ) )
131: return 0;
132:
1.1.1.7 root 133: return STMemory_ReadWord ( addr );
1.1 root 134: }
135:
136: // Load a text file into memory, count the lines and replace the LF with 0-bytes.
137: static int Disass68kLoadTextFile(const char *filename, char **filebuf)
138: {
139: long index;
1.1.1.4 root 140: long fileLength;
1.1.1.6 root 141: int lineCount = 0;
1.1.1.4 root 142: char *fbuf;
143: FILE *f;
144:
1.1 root 145: if(filebuf)
146: *filebuf = NULL;
1.1.1.4 root 147: f = fopen(filename, "r");
1.1.1.6 root 148: if (!f)
1.1 root 149: return 0;
1.1.1.6 root 150: if (fseek(f, 0, SEEK_END))
151: goto out;
1.1.1.4 root 152: fileLength = ftell(f);
1.1.1.6 root 153: if (fileLength <= 0)
154: goto out;
155: if (fseek(f, 0, SEEK_SET))
156: goto out;
1.1.1.4 root 157: fbuf = malloc(fileLength);
1.1.1.6 root 158: if(!fbuf)
159: goto out;
1.1 root 160: if((size_t)fileLength != fread(fbuf, sizeof(char), fileLength, f))
1.1.1.4 root 161: {
162: free(fbuf);
1.1.1.6 root 163: goto out;
1.1.1.4 root 164: }
1.1.1.6 root 165:
1.1 root 166: for(index=0; index<fileLength; ++index)
167: {
168: if(fbuf[index] == '\r') // convert potential CR into a space (which we ignore at the end of the line anyway)
169: fbuf[index] = ' ';
170: if(fbuf[index] == '\n') // count LF and terminate line
171: {
172: ++lineCount;
173: fbuf[index] = 0;
174: }
175: }
176: if(filebuf)
177: *filebuf = fbuf;
1.1.1.6 root 178: out:
179: fclose(f);
1.1 root 180: return lineCount;
181: }
182:
183: static void Disass68kLoadStructInfo(const char *filename)
184: {
1.1.1.4 root 185: int i,j;
186: char *nextLine;
187: char *line;
1.1 root 188: char *fbuf = NULL;
1.1.1.4 root 189: int lineCount = Disass68kLoadTextFile(filename, &fbuf);
1.1 root 190: disStructEntry *se = NULL;
1.1.1.4 root 191:
192: if(!lineCount) return;
193:
1.1.1.8 root 194: se = realloc(disStructEntries, sizeof(disStructEntry) * (disStructCounts + lineCount));
195: if (!se)
196: {
197: perror("Disass68kLoadStructInfo");
198: free(disStructEntries);
199: disStructEntries = NULL;
200: free(fbuf);
201: return;
202: }
203: disStructEntries = se;
204: se = NULL;
1.1.1.4 root 205:
206: line = fbuf;
1.1 root 207:
208: for(i=0; i<lineCount; line = nextLine, ++i)
209: {
210: // strip spaces at the end of the line, remember the ptr to the next line
211: char *sp = line;
212: while(*sp++)
213: ;
214: nextLine = sp--;
1.1.1.5 root 215: while (isspace((unsigned char)*--sp))
1.1 root 216: *sp = 0;
217:
218: if(line[0] == '{')
219: {
220: se = &disStructEntries[disStructCounts];
221: se->name = strdup(line+1);
222: se->count = 0;
223: se->elements = malloc(sizeof(disStructElement) * lineCount); // lineCount is way too much, but safe
224: } else if(line[0] == '}') {
225: if(se)
226: {
227: se->size = 0;
228: for(j=0; j<se->count; ++j)
229: se->size += se->elements[j].size;
230: // printf("%s : %d bytes\n", se->name, se->size);
231: ++disStructCounts;
232: se = NULL;
233: }
234: } else if(line[0] == '#') {
235: disStructElement dse;
236: int val = 0;
237: int index = 2;
238: if(line[1] == 'A' || line[1] == 'B')
239: {
1.1.1.5 root 240: for(; isdigit((unsigned char)line[index]); ++index)
1.1 root 241: {
242: val *= 10;
243: val += line[index] - '0';
244: }
245: }
246: if(val == 0) val = 1;
247: dse.name = NULL;
248: switch(line[1])
249: {
250: case 'A': dse.type = dtStringArray; dse.size = val; dse.name = strdup(line + index + 1); break;
251: case 'B': dse.type = dtByte; dse.size = val; break;
252: case 'W': dse.type = dtWord; dse.size = 2; break;
253: case 'L': dse.type = dtLong; dse.size = 4; break;
254: case 'C': dse.type = dtOpcode; dse.size = 2; break;
255: case 'f': dse.type = dtFunctionPointer; dse.size = 4; break;
256: case 'p': dse.type = dtPointer; dse.size = 4; break;
257: default: dse.type = dtNone; dse.size = 0;
258: printf("Unknown type in \"%s\"\n", line); break;
259: }
260: if(!dse.name)
261: dse.name = strdup(line+3);
262: dse.comment = NULL;
263: if(se)
264: se->elements[se->count++] = dse;
265: }
266: }
267: free(fbuf);
268: }
269:
270: static void Disass68kLoadSymbols(const char *filename)
271: {
1.1.1.4 root 272: int i,j;
273: char *nextLine;
274: char *line;
1.1 root 275: char *fbuf = NULL;
1.1.1.8 root 276: int lineCount = Disass68kLoadTextFile(filename, &fbuf);
277: disSymbolEntry *nde;
278:
279: if (!lineCount)
280: return;
281:
282: nde = realloc(disSymbolEntries, sizeof(disSymbolEntry) * (disSymbolCounts + lineCount));
283: if (!nde)
284: {
285: perror("Disass68kLoadSymbols");
286: free(disSymbolEntries);
287: disSymbolEntries = NULL;
288: free(fbuf);
289: return;
290: }
291: disSymbolEntries = nde;
292:
1.1.1.4 root 293: line = fbuf;
1.1 root 294:
295: for(i=0; i<lineCount; line = nextLine, ++i)
296: {
1.1.1.4 root 297: long addr;
1.1 root 298: char *sp = line;
1.1.1.4 root 299: char *parameterPtr[10];
300: int parameterCount = 0;
301: char *str;
302: long size = 0;
303: int type = 0;
304:
305: // strip spaces at the end of the line, remember the ptr to the next line
1.1 root 306: while(*sp++)
307: ;
308: nextLine = sp--;
1.1.1.5 root 309: while(isspace((unsigned char)*--sp))
1.1 root 310: *sp = 0;
311:
312: // ignore empty lines
313: if(line[0] == 0)
314: continue;
315:
316: sscanf(line, "%lx",&addr);
317: disSymbolEntries[disSymbolCounts].addr = addr;
318: disSymbolEntries[disSymbolCounts].structIndex = -1;
319:
1.1.1.4 root 320: str = line;
1.1 root 321: do {
322: str = strchr(str, ',');
323: if(str)
324: {
325: char *ep = str;
1.1.1.5 root 326: while(isspace((unsigned char)*--ep))
1.1 root 327: *ep = 0;
328: *str++ = 0;
1.1.1.5 root 329: while(*str && isspace((unsigned char)*str))
1.1 root 330: ++str;
331: parameterPtr[parameterCount++] = str;
332: }
333: } while(str != NULL && parameterCount < 10);
334:
335: if(parameterCount != 3 && parameterCount != 4)
336: continue; // ignore line
337:
338: if(strlen(parameterPtr[0]) == 1)
339: {
340: switch(parameterPtr[0][0])
341: {
342: case 'A': type = dtASCString; size = 1; break; // ascii NULL
343: case 'B': type = dtByte; size = 1; break; // byte
344: case 'W': type = dtWord; size = 2; break; // word
345: case 'L': type = dtLong; size = 4; break; // long
346: case 'C': type = dtOpcode; size = 2; break; // code
347: case 'f': type = dtFunctionPointer; size = 4; break; // function pointer
348: case 'p': type = dtPointer; size = 4; break; // regular pointer
349: default: printf("ERROR: $%lx : %s\n", addr, parameterPtr[0]); continue;
350: }
351: } else {
352: for(j=0; j<disStructCounts; ++j)
353: {
354: disStructEntry *se = &disStructEntries[j];
355: if(se->name == NULL)
356: break;
357: if(strcmp(parameterPtr[0], se->name))
358: continue;
359: size = se->size;
360: disSymbolEntries[disSymbolCounts].structIndex = j;
361: }
362: }
363: if(!size)
364: continue;
365:
366: disSymbolEntries[disSymbolCounts].type = type;
367: disSymbolEntries[disSymbolCounts].size = size;
368: disSymbolEntries[disSymbolCounts].count = atol(parameterPtr[1]);
369: disSymbolEntries[disSymbolCounts].name = strdup(parameterPtr[2]);
370: disSymbolEntries[disSymbolCounts].comment = NULL;
371: if(parameterCount == 4)
372: disSymbolEntries[disSymbolCounts].comment = strdup(parameterPtr[3]);
373: ++disSymbolCounts;
374: }
375: free(fbuf);
376: }
377:
378: static void Disass68kInit(const char *baseDirectory)
379: {
1.1.1.2 root 380: char filename[FILENAME_MAX];
1.1 root 381:
382: disStructCounts = 0;
383: sprintf(filename, "%s/DisassStructs.txt", baseDirectory);
384: Disass68kLoadStructInfo(filename);
385: sprintf(filename, "%s/DisassStructs_%4.4X.txt", baseDirectory, TosVersion);
386: Disass68kLoadStructInfo(filename);
387:
388: disSymbolCounts = 0;
389: sprintf(filename, "%s/DisassSymbols.txt", baseDirectory);
390: Disass68kLoadSymbols(filename);
391: sprintf(filename, "%s/DisassSymbols_%4.4X.txt", baseDirectory, TosVersion);
392: Disass68kLoadSymbols(filename);
393: }
394:
395:
396:
397: static Disass68kDataType Disass68kType(long addr, char *addressLabel, char *commentBuffer, int *count)
398: {
399: int i,j;
400:
401: addressLabel[0] = 0;
402: commentBuffer[0] = 0;
403: for(i=0; i<disSymbolCounts; ++i)
404: {
1.1.1.4 root 405: const disStructEntry *se;
1.1 root 406: const disSymbolEntry *dse = &disSymbolEntries[i];
407: int offset = addr - dse->addr;
1.1.1.4 root 408:
1.1 root 409: if(offset < 0 || offset >= dse->count * dse->size)
410: continue;
411:
412: // no special struct that devices this value?
413: if(dse->structIndex < 0)
414: {
415: offset = (offset + dse->size - 1) / dse->size;
416: *count = dse->count - offset;
417: if(offset == 0) // only in the first line
418: {
419: strcpy(addressLabel, dse->name);
420: if(dse->comment)
421: strcpy(commentBuffer, dse->comment);
422: }
423: return dse->type;
424: }
425:
426: *count = 1;
1.1.1.4 root 427: se = &disStructEntries[dse->structIndex];
1.1 root 428: for(j=0; j<se->count; ++j)
429: {
430: const disStructElement *e = &se->elements[j];
431: if(offset < e->size)
432: {
433: if(e->type == dtStringArray)
434: *count = e->size;
435: if(j == 0)
436: strcpy(addressLabel, dse->name);
437:
438: sprintf(commentBuffer, "[%s]", e->name);
439: if(e->comment)
440: strcat(commentBuffer, e->comment);
441: return e->type;
442: }
443: offset -= e->size;
444: }
445: return dse->size;
446: }
447: return dtNone;
448: }
449:
450: /***
451: * Lookup a symbol name
452: ***/
453: static const char *Disass68kSymbolName(long addr, int size)
454: {
455: int i;
456:
457: for(i=0; i<disSymbolCounts; ++i)
458: {
1.1.1.4 root 459: static char symbolName[128];
1.1 root 460: const disSymbolEntry *dse = &disSymbolEntries[i];
1.1.1.4 root 461: int offset = addr - dse->addr;
462: int reminder;
463:
1.1 root 464: if(offset < 0 || offset >= dse->count * dse->size)
465: continue;
466:
467: if(dse->name[0] == 0)
468: return NULL;
469:
1.1.1.4 root 470: reminder = offset % dse->size;
1.1 root 471: offset /= dse->size;
472:
473: strcpy(symbolName, dse->name);
474: if(offset)
475: sprintf(symbolName+strlen(symbolName), "+%d*%d", dse->size, offset);
476: if(reminder)
477: sprintf(symbolName+strlen(symbolName), "+%d", reminder);
478: return symbolName;
479: }
480: return NULL;
481: }
482:
483: /***
484: * return a string pointer to display a register name
485: ***/
486: static const char *Disass68kRegname(int reg)
487: {
488: static char regName[3];
1.1.1.8 root 489:
490: if (reg == 0x0F && (options & doptStackSP) != 0)
1.1 root 491: {
1.1.1.8 root 492: /* display A7 as SP */
493: return (options & doptRegisterSmall) ? "sp" : "SP";
494: }
1.1 root 495:
1.1.1.8 root 496: if (reg >= 0x0 && reg <= 0x7)
497: {
498: regName[0] = (options & doptRegisterSmall) ? 'd' : 'D';
499: }
500: else if (reg >= 0x8 && reg <= 0xf)
501: {
502: regName[0] = (options & doptRegisterSmall) ? 'a' : 'A';
1.1 root 503: }
1.1.1.8 root 504: else
505: {
506: regName[0] = '?';
507: }
508:
509: regName[1] = '0' + (reg & 7);
510: regName[2] = 0;
511:
1.1 root 512: return regName;
513: }
514:
515: /***
516: * return a string pointer to display a register name
517: ***/
518: static const char *Disass68kNumber(int val)
519: {
520: static char numString[32];
521: if(val >= -9 && val <= 9)
522: {
523: sprintf(numString, "%d", val);
524: } else {
525: // 4 characters/numbers or underscore (e.g. for cookies)
1.1.1.5 root 526: unsigned char c0 = (val >> 24) & 0xFF;
527: unsigned char c1 = (val >> 16) & 0xFF;
528: unsigned char c2 = (val >> 8) & 0xFF;
529: unsigned char c3 = (val >> 0) & 0xFF;
1.1 root 530: if((isalnum(c0) || c0 == '_') && (isalnum(c1) || c1 == '_') && (isalnum(c2) || c2 == '_') && (isalnum(c3) || c3 == '_'))
531: {
532: sprintf(numString, "'%c%c%c%c'", c0, c1, c2, c3);
533: } else {
534: sprintf(numString, "$%x", val);
535: }
536: }
537: return numString;
538: }
539:
540: /***
541: * Supported registers for e.g. MOVEC
542: ***/
543: #define REG_CCR -1
544: #define REG_SR -2
545: #define REG_PC -3
546: #define REG_ZPC -4
547: #define REG_TT0 -8
548: #define REG_TT1 -9
549: #define REG_MMUSR -10
550: #define REG_USP 0x800
551: #define REG_SFC 0x000
552: #define REG_DFC 0x001
553: #define REG_TC 0x10000
554: #define REG_SRP 0x10002
555: #define REG_CRP 0x10003
556: #define REG_VAL 0x20000
557: #define REG_CACHES_NONE 0x20010
558: #define REG_CACHES_IC 0x20011
559: #define REG_CACHES_DC 0x20012
560: #define REG_CACHES_ICDC 0x20013
561: #define REG_FPU_FPCR 0x30004
562: #define REG_FPU_FPSR 0x30002
563: #define REG_FPU_FPIAR 0x30001
564:
565: static const char *Disass68kSpecialRegister(int reg)
566: {
567: static char buf[8];
568: const char *sp = NULL;
569: switch (reg)
570: {
571: case 0x000: sp = "SFC"; break;
572: case 0x001: sp = "DFC"; break;
573: case 0x002: sp = "CACR"; break;
574: case 0x003: sp = "TC"; break;
575: case 0x004: sp = "ITT0"; break; // IACR0 on an 68EC040 only
576: case 0x005: sp = "ITT1"; break; // IACR1 on an 68EC040 only
577: case 0x006: sp = "DTT0"; break; // DACR0 on an 68EC040 only
578: case 0x007: sp = "DTT1"; break; // DACR1 on an 68EC040 only
579: case 0x008: sp = "BUSCR"; break;
580:
581: case 0x800: sp = "USP"; break;
582: case 0x801: sp = "VBR"; break;
583: case 0x802: sp = "CAAR"; break;
584: case 0x803: sp = "MSP"; break;
585: case 0x804: sp = "ISP"; break;
586: case 0x805: sp = "MMUSR"; break;
587: case 0x806: sp = "URP"; break;
588: case 0x807: sp = "SRP"; break;
589: case 0x808: sp = "PCR"; break;
590:
591: // MMU register
592: case 0x10000: sp = "TC"; break;
593: case 0x10001: sp = "DRP"; break;
594: case 0x10002: sp = "SRP"; break;
595: case 0x10003: sp = "CRP"; break;
596: case 0x10004: sp = "CAL"; break;
597: case 0x10005: sp = "VAL"; break;
598: case 0x10006: sp = "SCCR"; break;
599: case 0x10007: sp = "ACR"; break;
600:
601: case REG_CCR: sp = "CCR"; break;
602: case REG_SR: sp = "SR"; break;
603: case REG_PC: sp = "PC"; break;
604: case REG_ZPC: sp = "ZPC"; break;
605: case REG_TT0: sp = "TT0"; break;
606: case REG_TT1: sp = "TT1"; break;
607: case REG_MMUSR: sp = "MMUSR"; break;
608:
609: case REG_VAL: sp = "VAL"; break;
610:
611: case REG_CACHES_NONE: sp = "NC"; break;
612: case REG_CACHES_IC: sp = "IC"; break;
613: case REG_CACHES_DC: sp = "DC"; break;
614: case REG_CACHES_ICDC: sp = "IC/DC"; break; // GCC lists this as "BC"
615:
616: case REG_FPU_FPCR: sp = "FPCR"; break;
617: case REG_FPU_FPSR: sp = "FPSR"; break;
618: case REG_FPU_FPIAR: sp = "FPIAR"; break;
619:
620: // unknown register => unknown opcode!
1.1.1.4 root 621: default: return NULL;
1.1 root 622: }
1.1.1.4 root 623:
1.1 root 624: if(options & doptRegisterSmall)
625: {
1.1.1.4 root 626: char *bp;
1.1 root 627: strcpy(buf, sp);
1.1.1.4 root 628: for (bp = buf; *bp; ++bp)
1.1.1.5 root 629: *bp = tolower((unsigned char)*bp);
1.1 root 630: return buf;
631: }
632: return sp;
633: }
634:
635: /***
636: * 680x0 EA disassembly, supports all address modes
637: *
638: * disassbuf = output buffer for the EA, empty string in case of an illegal EA
639: * addr = pointer to the address, which Disass68kGetWord() will allow to read memory.
640: * Incremented by the function to point behind the opcode, when done
641: * ea = 6-bit ea from the opcode
642: * size = addressed size of the opcode in bytes (e.g. 1,2,4 for MOVE.B, MOVE.W, MOVE.L), only used for immediate addressing
643: ***/
644:
645: #define EA_Dn 0x00001 // Dn
646: #define EA_An 0x00002 // An
647: #define EA_Ani 0x00004 // (An)
648: #define EA_Anip 0x00008 // (An)+
649: #define EA_piAn 0x00010 // -(An)
650: #define EA_dAn 0x00020 // d(An), d(An,Dn), etc.
651: #define EA_PCRel 0x00040 // d(PC), d(PC,Dn), etc.
652: #define EA_Abs 0x00080 // abs.w, abs.l
653: #define EA_Immed 0x00100 // #<val>
654:
655: #define EA_ImmedParameter 0x0200 // an immediate value as a parameter
656: #define EA_ValueParameter 0x0400 // an immediate value as a parameter without the "#"
657: #define EA_SpecialRegister 0x0800 // any special register e.g. SR,CCR,USP,etc
658: #define EA_PCDisplacement 0x1000 // PC relative jump, like for BRA and friends
659:
660: #define EA_All (EA_Dn | EA_An | EA_Ani | EA_Anip | EA_piAn | EA_dAn | EA_Abs | EA_Immed | EA_PCRel)
661: #define EA_Dest (EA_Dn | EA_An | EA_Ani | EA_Anip | EA_piAn | EA_dAn | EA_Abs)
662:
663: static char *Disass68kEA(char *disassbuf, char *commentBuffer, long *addr, long opcodeAddr, int ea, int size, int allowedEAs, int parameterValue, int disassFlag)
664: {
665: unsigned short eWord1;
666: unsigned short eWord2;
667: int xn,c,scale;
668: int reg = ea & 7;
669: const char *sp;
670: long val;
1.1.1.4 root 671: char regName[3];
672: signed long pcoffset;
673:
1.1 root 674: disassbuf[0] = 0;
675: switch(ea)
676: {
677: // M=000 = 0 Dn
678: // Data Register Direct Mode
679: // Dn
680: // M=001 = 1 An
681: // Address Register Direct Mode
682: // An
683: case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
684: if((allowedEAs & EA_Dn) != EA_Dn)
685: break;
686: sprintf(disassbuf, "%s", Disass68kRegname(ea & 0x0F));
687: break;
688: case 0x08: case 0x09: case 0x0A: case 0x0B: case 0x0C: case 0x0D: case 0x0E: case 0x0F:
689: if((allowedEAs & EA_An) != EA_An)
690: break;
691: sprintf(disassbuf, "%s", Disass68kRegname(ea & 0x0F));
692: break;
693:
694: // M=010 = 2
695: // Address Register Indirect Mode
696: // (An)
697: case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
698: if((allowedEAs & EA_Ani) != EA_Ani)
699: break;
700: sprintf(disassbuf, "(%s)", Disass68kRegname(reg | 8));
701: break;
702:
703: // M=011 = 3
704: // Address Register Indirect with Postincrement Mode
705: // (An) +
706: case 0x18: case 0x19: case 0x1A: case 0x1B: case 0x1C: case 0x1D: case 0x1E: case 0x1F:
707: if((allowedEAs & EA_Anip) != EA_Anip)
708: break;
709: sprintf(disassbuf, "(%s)+", Disass68kRegname(reg | 8));
710: break;
711:
712: // M=100 = 4
713: // Address Register Indirect with Predecrement Mode
714: // – (An)
715: case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
716: if((allowedEAs & EA_piAn) != EA_piAn)
717: break;
718: sprintf(disassbuf, "-(%s)", Disass68kRegname(reg | 8));
719: break;
720:
721: // M=101 = 5
722: // Address Register Indirect with Displacement Mode
723: // (d16,An)
724: case 0x28: case 0x29: case 0x2A: case 0x2B: case 0x2C: case 0x2D: case 0x2E: case 0x2F:
725: if((allowedEAs & EA_dAn) != EA_dAn)
726: break;
727: eWord1 = Disass68kGetWord(*addr); *addr += 2;
728: sprintf(disassbuf, "%s(%s)", Disass68kNumber(eWord1), Disass68kRegname(reg | 8));
729: break;
730:
731: // M=111 = 7, Xn/reg = 011 = 3
732: // Program Counter Indirect with Index (Base Displacement) Mode
733: // (bd, PC, Xn. SIZE*SCALE)
734: // Program Counter Memory Indirect Postindexed Mode
735: // ([bd,PC],Xn.SIZE*SCALE,od)
736: // Program Counter Memory Indirect Preindexed Mode
737: // ([bd,PC,Xn.SIZE*SCALE],od)
738: case 0x3B:
739: // This is equal to the following, except that instead of An, it is PC relative
740:
741: // M=110 = 6
742: // Address Register Indirect with Index (Base Displacement) Mode
743: // (bd,An,Xn.SIZE*SCALE)
744: // Memory Indirect Postindexed Mode
745: // ([bd,An],Xn.SIZE*SCALE,od)
746: // Memory Indirect Preindexed Mode
747: // ([bd, An, Xn.SIZE*SCALE], od)
748: case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
749: eWord1 = Disass68kGetWord(*addr); *addr += 2;
750: xn = (eWord1 >> 12) & 0x0F; // Register D0..D7/A0..A7
751: c = ((eWord1 >> 11) & 1) ? 'l' : 'w'; // Word/Long-Word Index Size 0 = Sign-Extended Word 1 = Long Word
752: scale = (eWord1 >> 9) & 3; // Scale Factor 00 = 1 01 = 2 10 = 4 11 = 8
1.1.1.4 root 753:
1.1 root 754: if(ea == 0x3B)
755: {
756: sp = Disass68kSpecialRegister(REG_PC);
757: if(!sp) return NULL;
758: strcpy(regName, sp);
759: } else {
760: sprintf(regName, "%s", Disass68kRegname(reg | 8));
761: }
762:
763: if((eWord1 & 0x0100) == 0)
764: {
1.1.1.4 root 765: const char *numStr;
766:
1.1 root 767: // BRIEF EXTENSION WORD FORMAT
768: if(ea == 0x3B)
769: {
770: if((allowedEAs & EA_PCRel) != EA_PCRel)
771: break;
772: } else {
773: if((allowedEAs & EA_dAn) != EA_dAn)
774: break;
775: }
776:
777: // Address Register Indirect with Index (8-Bit Displacement) Mode
778: // (d8 ,An, Xn.SIZE*SCALE)
1.1.1.4 root 779: numStr = Disass68kNumber(eWord1 & 0xFF);
1.1 root 780: if(numStr[0] == '0' && numStr[1] == 0)
781: numStr = "";
782:
783: // scale is only on 68020 and later supported
784: if(scale != 0 && (optionCPUTypeMask & MC_020) == 0)
785: return NULL;
786:
787: if(scale == 0)
788: {
789: #if ADDRESS_ON_PC
790: if(ea == 0x3B)
791: sprintf(disassbuf, "$%lx(%s,%s.%c)", (signed char)(eWord1 & 0xFF) + opcodeAddr + 2, Disass68kSpecialRegister(REG_PC), Disass68kRegname(xn), c);
792: else
793: #endif
794: sprintf(disassbuf, "%s(%s,%s.%c)", numStr, regName, Disass68kRegname(xn), c);
795: } else
796: {
797: #if ADDRESS_ON_PC
798: if(ea == 0x3B)
799: sprintf(disassbuf, "$%lx(%s,%s.%c*%d)", (signed char)(eWord1 & 0xFF) + opcodeAddr + 2, Disass68kSpecialRegister(REG_PC), Disass68kRegname(xn), c, 1 << scale);
800: else
801: #endif
802: sprintf(disassbuf, "%s(%s,%s.%c*%d)", numStr, regName, Disass68kRegname(xn), c, 1 << scale);
803: }
804: #if USE_SYMBOLS
805: if(ea == 0x3B)
806: {
807: const char *symStr = Disass68kSymbolName((signed char)(eWord1 & 0xFF) + opcodeAddr + 2, size);
808: if(symStr)
809: {
810: commentBuffer += strlen(commentBuffer);
811: sprintf(commentBuffer+strlen(commentBuffer), "%s", symStr);
812: }
813: }
814: #endif
815: #if !ADDRESS_ON_PC
816: if(ea == 0x3B)
817: {
818: commentBuffer += strlen(commentBuffer);
819: sprintf(commentBuffer+strlen(commentBuffer), "$%lx", (signed char)(eWord1 & 0xFF) + opcodeAddr + 2);
820: }
821: #endif
822: } else {
823: // FULL EXTENSION WORD FORMAT
824:
1.1.1.4 root 825: int bs = (eWord1 >> 7) & 1; // Base Register Suppress 0 = Base Register Added 1 = Base Register Suppressed
826: int is = (eWord1 >> 6) & 1; // Index Suppress 0 = Evaluate and Add Index Operand 1 = Suppress Index Operand
827: int bdSize = (eWord1 >> 4) & 3; // Base Displacement Size 00 = Reserved 01 = Null Displacement 10 = Word Displacement 11 = Long Displacement
828: int iis = eWord1 & 7; // Index/Indirect Selection Indirect and Indexing Operand Determined in Conjunction with Bit 6, Index Suppress
1.1 root 829: bool prefixComma;
1.1.1.4 root 830: long bd, od;
1.1 root 831:
832: // reserved, has to be 0
833: if((eWord1 & 8) != 0 || bdSize == 0 || (is && iis > 3) || iis == 4)
834: break;
835:
836: // full extension format is only supported on 68020 or later
837: if((optionCPUTypeMask & MC_020) == 0)
838: return NULL;
839:
840: if(ea == 0x3B)
841: {
842: if((allowedEAs & EA_PCRel) != EA_PCRel)
843: break;
844: } else {
845: if((allowedEAs & EA_dAn) != EA_dAn)
846: break;
847: }
848:
1.1.1.4 root 849: bd = 0;
1.1 root 850: switch(bdSize)
851: {
852: case 3:
853: bd = Disass68kGetWord(*addr); *addr += 2;
854: bd <<= 16;
1.1.1.9 ! root 855: /* fall through */
1.1 root 856: case 2:
857: bd |= Disass68kGetWord(*addr); *addr += 2;
858: break;
859: default:
860: break;
861: }
862:
863: prefixComma = false;
864: if(bdSize >= 2 && iis == 0)
865: sprintf(disassbuf, "%s", Disass68kNumber(bd));
866: strcat(disassbuf, "(");
867: if(iis != 0)
868: {
869: // the CPU32 doesn't support the memory indirect mode
870: if(optionCPUTypeMask & MC_CPU32)
871: return NULL;
872:
873: strcat(disassbuf, "[");
874: }
875: if(bdSize >= 2 && iis != 0)
876: {
877: sprintf(disassbuf+strlen(disassbuf), "%s", Disass68kNumber(bd));
878: prefixComma = true;
879: }
880: if(bdSize == 1 && ((bs && is && iis > 0) || (bs && iis >= 5)))
881: {
882: if(ea == 0x3B)
883: {
884: sp = Disass68kSpecialRegister(REG_ZPC);
885: if(!sp) return NULL;
886: strcat(disassbuf, sp);
887: } else {
888: strcat(disassbuf, "0");
889: }
890: }
891: if(!bs)
892: {
893: if(prefixComma)
894: strcat(disassbuf, ",");
895: strcat(disassbuf, regName);
896: prefixComma = true;
897: }
898: if(iis >= 5 && iis <= 7)
899: {
900: strcat(disassbuf, "]");
901: prefixComma = true;
902: }
903: if(!is)
904: {
905: if(prefixComma)
906: strcat(disassbuf, ",");
907: if(scale == 0)
908: {
909: sprintf(disassbuf+strlen(disassbuf), "%s.%c", Disass68kRegname(xn), c);
910: } else
911: {
912: sprintf(disassbuf+strlen(disassbuf), "%s.%c*%d", Disass68kRegname(xn), c, 1 << scale);
913: }
914: }
915: if(iis >= 1 && iis <= 3)
916: {
917: strcat(disassbuf, "]");
918: prefixComma = true;
919: }
1.1.1.4 root 920: od = 0;
1.1 root 921: switch(iis & 3)
922: {
923: case 3:
924: od = Disass68kGetWord(*addr); *addr += 2;
925: od <<= 16;
1.1.1.9 ! root 926: /* fall through */
1.1 root 927: case 2:
928: od |= Disass68kGetWord(*addr); *addr += 2;
929: if(prefixComma)
930: strcat(disassbuf, ",");
931: sprintf(disassbuf+strlen(disassbuf), "%s", Disass68kNumber(od));
932: break;
933: default:
934: break;
935: }
936: strcat(disassbuf, ")");
937: }
938: break;
939:
940: // M=111 = 7, Xn/reg = 000 = 0
941: // Absolute Short Addressing Mode
942: // (xxx).W
943: case 0x38:
944: if((allowedEAs & EA_Abs) != EA_Abs)
945: break;
946: eWord1 = Disass68kGetWord(*addr); *addr += 2;
947: val = eWord1;
948: if(eWord1 & 0x8000)
949: val |= 0xFFFF0000;
950: #if USE_SYMBOLS
951: sp = Disass68kSymbolName(val, size);
952: if(sp)
953: {
954: if(options & doptNoBrackets)
955: sprintf(disassbuf, "%s.w", sp);
956: else
957: sprintf(disassbuf, "(%s).w", sp);
958: break;
959: }
960: #endif
961: if(options & doptNoBrackets)
962: {
963: if(val & 0x80000000)
964: sprintf(disassbuf, "$%8.8lx.w", val);
965: else
966: sprintf(disassbuf, "$%4.4lx.w", val);
967: } else {
968: if(val & 0x80000000)
969: sprintf(disassbuf, "($%8.8lx).w", val);
970: else
971: sprintf(disassbuf, "($%4.4lx).w", val);
972: }
973: break;
974:
975: // M=111 = 7, Xn/reg = 001 = 1
976: // Absolute Long Addressing Mode
977: // (xxx).L
978: case 0x39:
979: if((allowedEAs & EA_Abs) != EA_Abs)
980: break;
981: eWord1 = Disass68kGetWord(*addr); *addr += 2;
982: eWord2 = Disass68kGetWord(*addr); *addr += 2;
983: #if USE_SYMBOLS
984: val = (eWord1 << 16) | eWord2;
985: sp = Disass68kSymbolName(val, size);
986: if(sp)
987: {
988: if(options & doptNoBrackets)
989: sprintf(disassbuf, "%s", sp);
990: else
991: sprintf(disassbuf, "(%s).l", sp);
992: break;
993: }
994: #endif
995: if(options & doptNoBrackets)
996: sprintf(disassbuf, "%s", Disass68kNumber((eWord1 << 16) | eWord2));
997: else
998: sprintf(disassbuf, "(%s).l", Disass68kNumber((eWord1 << 16) | eWord2));
999: break;
1000:
1001: // M=111 = 7, Xn/reg = 010 = 2
1002: // Program Counter Indirect with Displacement Mode
1003: // (d16,PC)
1004: case 0x3A:
1005: if((allowedEAs & EA_PCRel) != EA_PCRel)
1006: break;
1007: eWord1 = Disass68kGetWord(*addr); *addr += 2;
1008: sp = Disass68kSpecialRegister(REG_PC);
1009: if(!sp) return NULL;
1010: #if ADDRESS_ON_PC
1011: #if USE_SYMBOLS
1012: sp = Disass68kSymbolName(((signed short)eWord1 + *addr - 2), size);
1013: if(sp)
1014: {
1015: sprintf(disassbuf, "%s(%s)", sp, Disass68kSpecialRegister(REG_PC));
1016: } else {
1017: sprintf(disassbuf, "$%lx(%s)", (signed short)eWord1 + *addr - 2, Disass68kSpecialRegister(REG_PC));
1018: }
1019: #else
1020: sprintf(disassbuf, "$%lx(%s)", (signed short)eWord1 + *addr - 2, Disass68kSpecialRegister(REG_PC));
1021: #endif
1022: #else
1023: sprintf(disassbuf, "%s(%s)", Disass68kNumber(eWord1),sp);
1024: sprintf(commentBuffer+strlen(commentBuffer), "$%lx", (signed short)eWord1 + *addr - 2);
1025: #endif
1026: break;
1027:
1028: // M=111 = 7, Xn/reg = 100 = 4
1029: // Immediate Data
1030: // #<xxx>
1031: case 0x3C:
1032: if((allowedEAs & EA_Immed) != EA_Immed)
1033: break;
1034: eWord1 = Disass68kGetWord(*addr); *addr += 2;
1035: goto immed;
1036:
1037: case 0x0100: // Immediate Value as a parameter
1038: if((allowedEAs & EA_ImmedParameter) != EA_ImmedParameter)
1039: break;
1040: eWord1 = parameterValue;
1041: immed:
1042: switch(size)
1043: {
1044: case 1: eWord1 &= 0xFF;
1.1.1.8 root 1045: /* fall through */
1.1 root 1046: case 2:
1047: #if USE_SYMBOLS
1048: if(disassFlag)
1049: {
1050: val = eWord1;
1051: if(eWord1 & 0x8000)
1052: val |= 0xFFFF0000;
1053: sp = Disass68kSymbolName(val, size);
1054: if(sp)
1055: {
1056: sprintf(disassbuf, "#%s", sp);
1057: break;
1058: }
1059: }
1060: #endif
1061: sprintf(disassbuf, "#%s", Disass68kNumber(eWord1));
1062: break;
1063: case 4: eWord2 = Disass68kGetWord(*addr); *addr += 2;
1064: #if USE_SYMBOLS
1065: if(disassFlag)
1066: {
1067: val = (eWord1 << 16) | eWord2;
1068: sp = Disass68kSymbolName(val, size);
1069: if(sp)
1070: {
1071: sprintf(disassbuf, "#%s", sp);
1072: break;
1073: }
1074: }
1075: #endif
1076: sprintf(disassbuf, "#%s", Disass68kNumber((eWord1 << 16) | eWord2));
1077: break;
1078: }
1079: break;
1080:
1081: case 0x0103:
1082: if((allowedEAs & EA_ValueParameter) != EA_ValueParameter)
1083: break;
1084: sprintf(disassbuf, "%d", parameterValue);
1085: break;
1086:
1087: case 0x0101: // Special Registers as in the parameter
1088: if((allowedEAs & EA_SpecialRegister) != EA_SpecialRegister)
1089: break;
1090: sp = Disass68kSpecialRegister(parameterValue);
1091: if(!sp) return NULL;
1092: strcpy(disassbuf, sp);
1093: break;
1094:
1095: case 0x0102: // PC relative jump, like for BRA and friends
1096: if((allowedEAs & EA_PCDisplacement) != EA_PCDisplacement)
1097: break;
1.1.1.4 root 1098: pcoffset = 0;
1.1 root 1099: switch(size)
1100: {
1101: case 1: pcoffset = (signed char)parameterValue;
1102: break;
1103: case 2: eWord1 = Disass68kGetWord(*addr); *addr += 2;
1104: pcoffset = (signed short)eWord1;
1105: pcoffset -= 2;
1106: break;
1107: case 4: eWord1 = Disass68kGetWord(*addr); *addr += 2;
1108: eWord2 = Disass68kGetWord(*addr); *addr += 2;
1109: pcoffset = (signed int)((eWord1 << 16) | eWord2);
1110: pcoffset -= 4;
1111: break;
1112: }
1113: #if ADDRESS_ON_PC
1114: #if USE_SYMBOLS
1115: sp = Disass68kSymbolName((*addr + pcoffset), size);
1116: if(sp)
1117: {
1118: strcat(disassbuf, sp);
1119: } else {
1120: sprintf(disassbuf, "$%lx", *addr + pcoffset);
1121: }
1122: #else
1123: sprintf(disassbuf, "$%lx", *addr + pcoffset);
1124: #endif
1125: #else
1126: if(pcoffset < 0)
1127: {
1128: sprintf(disassbuf, "*-$%lx", -pcoffset - 2);
1129: } else {
1130: sprintf(disassbuf, "*+$%lx", pcoffset + 2);
1131: }
1132: sprintf(commentBuffer+strlen(commentBuffer), "$%lx", *addr + pcoffset);
1133: #endif
1134: break;
1135:
1136: default: // 0x3D..0x3F are reserved
1137: break;
1138:
1139: }
1140: if(disassbuf[0] == 0)
1141: return NULL;
1142: return disassbuf + strlen(disassbuf);
1143: }
1144:
1145: /***
1146: * Create a register list for the MOVEM opcode
1147: ***/
1148: static char *Disass68kReglist(char *buf, unsigned short reglist)
1149: {
1150: int bit;
1151: int lastBit = -99;
1152: int lastBitStart = -99;
1153: char regD = options & doptRegisterSmall ? 'd' : 'D';
1154: char regA = options & doptRegisterSmall ? 'a' : 'A';
1155: for(bit=0; bit<=15; ++bit)
1156: {
1157: // bit clear?
1158: if((reglist & (1 << bit)) == 0)
1159: {
1160: // do we have a run? => close it!
1161: if(lastBitStart >= 0 && lastBitStart != (bit - 1))
1162: {
1163: *buf++ = '-';
1164: *buf++ = ((bit-1) >= 8) ? regA : regD;
1165: *buf++ = '0' + ((bit-1) & 7);
1166: }
1167: lastBitStart = -1;
1168: continue;
1169: }
1170: // reset when switching from D to A
1171: if(bit == 8 && lastBitStart >= 0)
1172: {
1173: *buf++ = '-';
1174: *buf++ = regD;
1175: *buf++ = '7';
1176: lastBit = 0;
1177: lastBitStart = -99;
1178: }
1179: // separate bits, skip runs of bits to merge them later
1180: if(lastBit >= 0)
1181: {
1182: if(lastBit == bit - 1)
1183: {
1184: lastBit = bit;
1185: continue;
1186: }
1187: *buf++ = '/';
1188: }
1189: *buf++ = (bit >= 8) ? regA : regD;
1190: *buf++ = '0' + (bit & 7);
1191: lastBit = bit;
1192: lastBitStart = bit;
1193: }
1194: if(lastBitStart >= 0 && lastBitStart != (bit - 1))
1195: {
1196: *buf++ = '-';
1197: *buf++ = regA;
1198: *buf++ = '7';
1199: }
1200: if(lastBit < 0)
1201: {
1202: *buf++ = '0';
1203: }
1204: *buf = 0;
1205: return buf;
1206: }
1207:
1208: /***
1209: * Flip the bits in an unsigned short, for MOVEM RegList,-(An)
1210: ***/
1211: static unsigned short Disass68kFlipBits(unsigned short mask)
1212: {
1213: unsigned short retMask = 0;
1214: int i;
1215:
1216: for(i=0; i<=15; ++i)
1217: if(mask & (1 << i))
1218: retMask |= (1 << (15-i));
1219: return retMask;
1220: }
1221:
1222: /***
1223: * Create a register list for the MOVEM opcode
1224: ***/
1225: static char *Disass68kFPUReglist(char *buf, unsigned char reglist)
1226: {
1227: int bit;
1228: int lastBit = -99;
1229: int lastBitStart = -99;
1230: char regFP1 = options & doptRegisterSmall ? 'f' : 'F';
1231: char regFP2 = options & doptRegisterSmall ? 'p' : 'P';
1232: for(bit=0; bit<=7; ++bit)
1233: {
1234: // bit clear?
1235: if((reglist & (1 << bit)) == 0)
1236: {
1237: // do we have a run? => close it!
1238: if(lastBitStart >= 0 && lastBitStart != (bit - 1))
1239: {
1240: *buf++ = '-';
1241: *buf++ = regFP1;
1242: *buf++ = regFP2;
1243: *buf++ = '0' + ((bit-1) & 7);
1244: }
1245: lastBitStart = -1;
1246: continue;
1247: }
1248: // separate bits, skip runs of bits to merge them later
1249: if(lastBit >= 0)
1250: {
1251: if(lastBit == bit - 1)
1252: {
1253: lastBit = bit;
1254: continue;
1255: }
1256: *buf++ = '/';
1257: }
1258: *buf++ = regFP1;
1259: *buf++ = regFP2;
1260: *buf++ = '0' + (bit & 7);
1261: lastBit = bit;
1262: lastBitStart = bit;
1263: }
1264: if(lastBitStart >= 0 && lastBitStart != (bit - 1))
1265: {
1266: *buf++ = '-';
1267: *buf++ = regFP1;
1268: *buf++ = regFP2;
1269: *buf++ = '7';
1270: }
1271: if(lastBit < 0)
1272: {
1273: *buf++ = '0';
1274: }
1275: *buf = 0;
1276: return buf;
1277: }
1278:
1279:
1280: /***
1281: * List of special cases for the operands
1282: ***/
1283: typedef enum {
1284: ofNone,
1285: ofEa,
1286: ofDn,
1287: ofAn,
1288: ofAni,
1289: ofI,
1290: ofSpecReg,
1291: ofSpecExtReg,
1292: ofD16An,
1293: ofDestDn,
1294: ofDestAn,
1295: ofExtReg,
1296: ofExtAnip,
1297: ofExtReg0,
1298: ofExtRegA0,
1299: ofExtRegD04,
1300: ofExtRegA05,
1301: ofFPUReglist,
1302: ofFPUSRRegList,
1303: ofDestEa6,
1304: ofDestAbsL,
1305: ofIOpcode,
1306: ofCAS,
1307: ofCAS2,
1308: ofI3,
1309: ofExtIm,
1310: ofExtIm32,
1311: ofExtIm4,
1312: ofExtIm10,
1313: ofDisp,
1314: ofPiAn,
1315: ofDestPiAn,
1316: ofAnip,
1317: ofDestAnip,
1318: ofBFEa,
1319: ofRegList,
1320: ofExt4Dn,
1321: ofFPU,
1322: ofFPUMOVE,
1323: ofFMOVECR,
1324: ofFPU3Reg,
1.1.1.5 root 1325: ofLineA
1.1 root 1326: } Disass68kOpcodeFormat;
1327:
1328:
1329: /***
1330: * The order of the table is not important (with the exception of some FPU opcodes, which are commented further down),
1331: * as each opcode should decline if it doesn't match 100%. The 68k CPU also doesn't do guessing based on the context!
1332: ***/
1333: typedef const struct {
1334: int cpuMask;
1335: unsigned long opcodeMask[2*5];
1.1.1.4 root 1336: signed char operationSize[4];
1.1 root 1337: char op[5];
1338: const char *opcodeName;
1339: int parameter[5];
1340: int disassFlag;
1341: } OpcodeTableStruct;
1342:
1.1.1.6 root 1343: static OpcodeTableStruct OpcodeTable[] = {
1.1 root 1344: { MC_ALL, {0xff00, 0x0000}, {-1,6,2,0}, {ofI,ofEa}, "ORI.?",{0,EA_Immed|EA_PCRel|EA_An}},
1345: { MC_ALL, {0xf1c0, 0x0100}, {4}, {ofDestDn,ofEa}, "BTST",{0,EA_An|EA_Immed} },
1346: { MC_ALL, {0xf1c0, 0x0140}, {4}, {ofDestDn,ofEa}, "BCHG",{0,EA_Immed|EA_PCRel|EA_An}},
1347: { MC_ALL, {0xf1c0, 0x0180}, {4}, {ofDestDn,ofEa}, "BCLR",{0,EA_Immed|EA_PCRel|EA_An}},
1348: { MC_ALL, {0xf1c0, 0x01C0}, {4}, {ofDestDn,ofEa}, "BSET",{0,EA_Immed|EA_PCRel|EA_An}},
1349: { MC_ALL-MC68060, {0xf1f8, 0x0108}, {2}, {ofD16An,ofDestDn}, "MOVEP.W"},
1350: { MC_ALL-MC68060, {0xf1f8, 0x0148}, {4}, {ofD16An,ofDestDn}, "MOVEP.L"},
1351: { MC_ALL-MC68060, {0xf1f8, 0x0188}, {2}, {ofDestDn,ofD16An}, "MOVEP.W"},
1352: { MC_ALL-MC68060, {0xf1f8, 0x01C8}, {4}, {ofDestDn,ofD16An}, "MOVEP.L"},
1353: { MC_ALL, {0xff00, 0x0200}, {-1,6,2,0}, {ofI,ofEa}, "ANDI.?",{0,EA_Immed|EA_PCRel|EA_An}},
1354: { MC_ALL, {0xff00, 0x0400}, {-1,6,2,0}, {ofI,ofEa}, "SUBI.?",{0,EA_Immed|EA_PCRel|EA_An}},
1355: { MC_ALL, {0xff00, 0x0600}, {-1,6,2,0}, {ofI,ofEa}, "ADDI.?",{0,EA_Immed|EA_PCRel|EA_An}},
1356: { MC_ALL, {0xffc0, 0x0800}, {1}, {ofI,ofEa}, "BTST",{0,EA_An|EA_Immed} },
1357: { MC_ALL, {0xffc0, 0x0840}, {1}, {ofI,ofEa}, "BCHG",{0,EA_Immed|EA_PCRel|EA_An}},
1358: { MC_ALL, {0xffc0, 0x0880}, {1}, {ofI,ofEa}, "BCLR",{0,EA_Immed|EA_PCRel|EA_An}},
1359: { MC_ALL, {0xffc0, 0x08C0}, {1}, {ofI,ofEa}, "BSET",{0,EA_Immed|EA_PCRel|EA_An}},
1360: { MC_ALL, {0xff00, 0x0A00}, {-1,6,2,0}, {ofI,ofEa}, "EORI.?",{0,EA_Immed|EA_PCRel|EA_An}},
1361: { MC_ALL, {0xff00, 0x0C00}, {-1,6,2,0}, {ofI,ofEa}, "CMPI.?",{0,EA_Immed|EA_An}},
1362: { MC_ALL, {0xffff, 0x003C}, {1}, {ofEa,ofSpecReg}, "ORI",{0,REG_CCR} },
1363: { MC_ALL, {0xffff, 0x007C}, {2}, {ofEa,ofSpecReg}, "ORI",{0,REG_SR} },
1364: { MC_ALL, {0xffff, 0x023C}, {1}, {ofEa,ofSpecReg}, "ANDI",{0,REG_CCR} },
1365: { MC_ALL, {0xffff, 0x027C}, {2}, {ofEa,ofSpecReg}, "ANDI",{0,REG_SR} },
1366: { MC_ALL, {0xffff, 0x0A3C}, {1}, {ofEa,ofSpecReg}, "EORI",{0,REG_CCR} },
1367: { MC_ALL, {0xffff, 0x0A7C}, {2}, {ofEa,ofSpecReg}, "EORI",{0,REG_SR} },
1368: { MC68020, {0xffc0, 0x06C0}, {1}, {ofEa}, "CALLM",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn} },
1369: { MC68020, {0xfff0, 0x06C0}, {1}, {ofEa}, "RTM"},
1370: { MC_020, {0xf9c0, 0x00C0, 0x0fff,0x0000}, {-1,9,2,0}, {ofEa,ofExtReg}, "CMP2.?",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn} },
1371: { MC_020, {0xf9c0, 0x00C0, 0x0fff,0x0800}, {-1,9,2,0}, {ofEa,ofExtReg}, "CHK2.?",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn} },
1372: { MC_020&~MC_CPU32, {0xffc0, 0x0AC0, 0xFE38,0x0000}, {1}, {ofCAS,ofEa}, "CAS.B",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1373: { MC_020&~MC_CPU32, {0xffc0, 0x0CC0, 0xFE38,0x0000}, {2}, {ofCAS,ofEa}, "CAS.W",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1374: { MC_020&~MC_CPU32, {0xffc0, 0x0EC0, 0xFE38,0x0000}, {4}, {ofCAS,ofEa}, "CAS.L",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1375: { MC_020&~MC_CPU32, {0xffff, 0x0CFC, 0x0E38,0x0000, 0x0E38,0x0000}, {2}, {ofCAS2}, "CAS2.W"},
1376: { MC_020&~MC_CPU32, {0xffff, 0x0EFC, 0x0E38,0x0000, 0x0E38,0x0000}, {4}, {ofCAS2}, "CAS2.L"},
1377: { MC68010|MC_020, {0xff00, 0x0e00, 0x0fff,0x0000}, {-1,6,2,0}, {ofEa,ofExtReg}, "MOVES.?",{EA_Immed|EA_PCRel|EA_An|EA_Dn,0}},
1378: { MC68010|MC_020, {0xff00, 0x0e00, 0x0fff,0x0800}, {-1,6,2,0}, {ofExtReg,ofEa}, "MOVES.?",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1379:
1380: { MC_ALL, {0xf000, 0x1000}, {1}, {ofEa,ofDestEa6}, "MOVE.B"},
1381:
1382: { MC_ALL, {0xf000, 0x2000}, {4}, {ofEa,ofDestEa6}, "MOVE.L"},
1383: { MC_ALL, {0xf1c0, 0x2040}, {4}, {ofEa,ofDestAn}, "MOVEA.L",{0},1},
1384:
1385: { MC_ALL, {0xf000, 0x3000}, {2}, {ofEa,ofDestEa6}, "MOVE.W"},
1386: { MC_ALL, {0xf1c0, 0x3040}, {2}, {ofEa,ofDestAn}, "MOVEA.W",{0},1},
1387:
1388: { MC_ALL, {0xff00, 0x4000}, {-1,6,2,0}, {ofEa}, "NEGX.?",{EA_Immed|EA_PCRel|EA_An}},
1389: { MC_020, {0xf1c0, 0x4100}, {4}, {ofEa,ofDestDn}, "CHK.L", {EA_An,0}},
1390: { MC_ALL, {0xf1c0, 0x4180}, {2}, {ofEa,ofDestDn}, "CHK.W", {EA_An,0}},
1391: { MC_ALL, {0xf1c0, 0x41c0}, {4}, {ofEa,ofDestAn}, "LEA",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn,0},1 },
1392: { MC_ALL, {0xff00, 0x4200}, {-1,6,2,0}, {ofEa}, "CLR.?",{EA_Immed|EA_PCRel|EA_An}},
1393: { MC_ALL, {0xff00, 0x4400}, {-1,6,2,0}, {ofEa}, "NEG.?",{EA_Immed|EA_PCRel|EA_An}},
1394: { MC_ALL, {0xff00, 0x4600}, {-1,6,2,0}, {ofEa}, "NOT.?",{EA_Immed|EA_PCRel|EA_An}},
1395: { MC_ALL, {0xffc0, 0x40c0}, {2}, {ofSpecReg,ofEa}, "MOVE",{REG_SR,EA_Immed|EA_PCRel|EA_An} },
1396: { MC_ALL, {0xffc0, 0x42c0}, {1}, {ofSpecReg,ofEa}, "MOVE",{REG_CCR,EA_Immed|EA_PCRel|EA_An} },
1397: { MC_ALL, {0xffc0, 0x44c0}, {1}, {ofEa,ofSpecReg}, "MOVE",{EA_An,REG_CCR} },
1398: { MC_ALL, {0xffc0, 0x46c0}, {2}, {ofEa,ofSpecReg}, "MOVE",{EA_An,REG_SR} },
1399: { MC_ALL, {0xffc0, 0x4800}, {1}, {ofEa}, "NBCD",{EA_Immed|EA_PCRel|EA_An}},
1400: { MC_020, {0xfff8, 0x4808}, {4}, {ofEa,ofI}, "LINK.L"},
1401: { MC_ALL, {0xffc0, 0x4840}, {0}, {ofEa}, "PEA",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn},1 },
1402: { MC_ALL, {0xfff8, 0x4840}, {4}, {ofEa}, "SWAP"},
1403: { MC68010|MC_020, {0xfff8, 0x4848}, {0}, {ofIOpcode}, "BKPT",{0x07} },
1404: { MC_ALL, {0xffc0, 0x4880, 0x10000}, {2}, {ofRegList,ofEa}, "MOVEM.W",{0,EA_Dn|EA_An|EA_Immed|EA_Anip|EA_PCRel} },
1405: { MC_ALL, {0xffc0, 0x48c0, 0x10000}, {4}, {ofRegList,ofEa}, "MOVEM.L",{0,EA_Dn|EA_An|EA_Immed|EA_Anip|EA_PCRel} },
1406: { MC_ALL, {0xfff8, 0x4880}, {2}, {ofEa}, "EXT.W"},
1407: { MC_ALL, {0xfff8, 0x48c0}, {4}, {ofEa}, "EXT.L"},
1408: { MC_020, {0xfff8, 0x49c0}, {4}, {ofEa}, "EXTB.L"},
1409: { MC_ALL, {0xff00, 0x4a00}, {-1,6,2,0}, {ofEa}, "TST.?"},
1410: { MC_ALL, {0xffc0, 0x4ac0}, {1}, {ofEa}, "TAS",{EA_Immed|EA_PCRel|EA_An}},
1411: { MC_CPU32, {0xffff, 0x4afa}, {0}, {ofNone}, "BGND"},
1412: { MC_ALL, {0xffff, 0x4afc}, {0}, {ofNone}, "ILLEGAL"},
1413: { MC_020, {0xffc0, 0x4c00, 0x8ff8, 0x0000}, {4}, {ofEa,ofExtReg}, "MULU.L", {EA_An,0}},
1414: { MC_020, {0xffc0, 0x4c00, 0x8ff8, 0x0800}, {4}, {ofEa,ofExtReg}, "MULS.L", {EA_An,0}},
1415: { MC_020, {0xffc0, 0x4c40, 0x8ff8, 0x0000}, {4}, {ofEa,ofExtReg}, "DIVU.L", {EA_An,0}},
1416: { MC_020, {0xffc0, 0x4c40, 0x8ff8, 0x0800}, {4}, {ofEa,ofExtReg}, "DIVS.L", {EA_An,0}},
1417: { MC_020, {0xffc0, 0x4c00, 0x8ff8, 0x0400}, {4}, {ofEa,ofExtReg,ofExtReg0}, "MULU.L", {EA_An,0,0}},
1418: { MC_020, {0xffc0, 0x4c00, 0x8ff8, 0x0c00}, {4}, {ofEa,ofExtReg,ofExtReg0}, "MULS.L", {EA_An,0,0}},
1419: { MC_020, {0xffc0, 0x4c40, 0x8ff8, 0x0400}, {4}, {ofEa,ofExtReg,ofExtReg0}, "DIVU.L", {EA_An,0,0}},
1420: { MC_020, {0xffc0, 0x4c40, 0x8ff8, 0x0c00}, {4}, {ofEa,ofExtReg,ofExtReg0}, "DIVS.L", {EA_An,0,0}},
1421: { MC_ALL, {0xffc0, 0x4c80, 0x10000}, {2}, {ofEa,ofRegList}, "MOVEM.W",{EA_Dn|EA_An|EA_Immed|EA_piAn,0} },
1422: { MC_ALL, {0xffc0, 0x4cc0, 0x10000}, {4}, {ofEa,ofRegList}, "MOVEM.L",{EA_Dn|EA_An|EA_Immed|EA_piAn,0} },
1423: { MC_ALL, {0xfff0, 0x4e40}, {0}, {ofIOpcode}, "TRAP",{0x0f} },
1424: { MC_ALL, {0xfff8, 0x4e50}, {2}, {ofAn,ofI}, "LINK"},
1425: { MC_ALL, {0xfff8, 0x4e58}, {4}, {ofAn}, "UNLK"},
1426: { MC_ALL, {0xfff8, 0x4e60}, {4}, {ofAn,ofSpecReg}, "MOVE",{0,REG_USP} },
1427: { MC_ALL, {0xfff8, 0x4e68}, {4}, {ofSpecReg,ofAn}, "MOVE",{REG_USP,0} },
1428: { MC_ALL, {0xffff, 0x4e70}, {0}, {ofNone}, "RESET"},
1429: { MC_ALL, {0xffff, 0x4e71}, {0}, {ofNone}, "NOP"},
1430: { MC_ALL, {0xffff, 0x4e72}, {2}, {ofI}, "STOP"},
1431: { MC_ALL, {0xffff, 0x4e73}, {0}, {ofNone}, "RTE"},
1432: { MC68010|MC_020, {0xffff, 0x4e74}, {2}, {ofI}, "RTD"},
1433: { MC_ALL, {0xffff, 0x4e75}, {0}, {ofNone}, "RTS"},
1434: { MC_ALL, {0xffff, 0x4e76}, {0}, {ofNone}, "TRAPV"},
1435: { MC_ALL, {0xffff, 0x4e77}, {0}, {ofNone}, "RTR"},
1436: { MC68010|MC_020, {0xffff, 0x4e7a, 0x10000}, {4}, {ofSpecExtReg,ofExtReg}, "MOVEC"},
1437: { MC68010|MC_020, {0xffff, 0x4e7b, 0x10000}, {4}, {ofExtReg,ofSpecExtReg}, "MOVEC"},
1438: { MC_ALL, {0xffc0, 0x4e80}, {0}, {ofEa}, "JSR",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn} },
1439: { MC_ALL, {0xffc0, 0x4ec0}, {0}, {ofEa}, "JMP",{EA_Dn|EA_An|EA_Immed|EA_Anip|EA_piAn} },
1440:
1441: { MC_ALL, {0xf1c0, 0x5000}, {1}, {ofI3,ofEa}, "ADDQ.B",{0,EA_An|EA_Immed|EA_PCRel} },
1442: { MC_ALL, {0xf1c0, 0x5040}, {2}, {ofI3,ofEa}, "ADDQ.W",{0,EA_Immed|EA_PCRel} },
1443: { MC_ALL, {0xf1c0, 0x5080}, {4}, {ofI3,ofEa}, "ADDQ.L",{0,EA_Immed|EA_PCRel} },
1444: { MC_ALL, {0xf0c0, 0x50C0}, {1}, {ofEa}, "Sci",{EA_Immed|EA_PCRel|EA_An}},
1445: { MC_ALL, {0xf0f8, 0x50C8}, {2}, {ofDn,ofDisp}, "DBcd"},
1446: { MC_020, {0xf0ff, 0x50fa}, {2}, {ofI}, "TRAPci.W"},
1447: { MC_020, {0xf0ff, 0x50fb}, {4}, {ofI}, "TRAPci.L"},
1448: { MC_020, {0xf0ff, 0x50fc}, {0}, {ofNone}, "TRAPci"},
1449: { MC_ALL, {0xf1c0, 0x5100}, {1}, {ofI3,ofEa}, "SUBQ.B",{0,EA_An|EA_Immed|EA_PCRel} },
1450: { MC_ALL, {0xf1c0, 0x5140}, {2}, {ofI3,ofEa}, "SUBQ.W",{0,EA_Immed|EA_PCRel} },
1451: { MC_ALL, {0xf1c0, 0x5180}, {4}, {ofI3,ofEa}, "SUBQ.L",{0,EA_Immed|EA_PCRel} },
1452:
1453: { MC_ALL, {0xf0ff, 0x6000}, {2}, {ofDisp}, "Bcb"},
1454: { MC_ALL, {0xf000, 0x6000}, {1}, {ofDisp}, "Bcb.S"},
1455: { MC_020, {0xf0ff, 0x60FF}, {4}, {ofDisp}, "Bcb.L"},
1456:
1457: { MC_ALL, {0xf100, 0x7000}, {0}, {ofIOpcode,ofDestDn}, "MOVEQ", {0xFF,0}},
1458:
1459: { MC_ALL, {0xf100, 0x8000}, {-1,6,2,0}, {ofEa,ofDestDn}, "OR.?", {EA_An,0}},
1460: { MC_ALL, {0xf100, 0x8100}, {-1,6,2,0}, {ofDestDn,ofEa}, "OR.?",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1461: { MC_ALL, {0xf1f8, 0x8100}, {1}, {ofDn,ofDestDn}, "SBCD"},
1462: { MC_ALL, {0xf1f8, 0x8108}, {1}, {ofPiAn,ofDestPiAn}, "SBCD"},
1463: { MC_020&~MC_CPU32, {0xf1f8, 0x8140, 0x10000}, {0}, {ofDn,ofDestDn,ofExtIm}, "PACK"},
1464: { MC_020&~MC_CPU32, {0xf1f8, 0x8148, 0x10000}, {0}, {ofPiAn,ofDestPiAn,ofExtIm}, "PACK"},
1465: { MC_020&~MC_CPU32, {0xf1f8, 0x8180, 0x10000}, {0}, {ofDn,ofDestDn,ofExtIm}, "UNPK"},
1466: { MC_020&~MC_CPU32, {0xf1f8, 0x8188, 0x10000}, {0}, {ofPiAn,ofDestPiAn,ofExtIm}, "UNPK"},
1467: { MC_ALL, {0xf1c0, 0x80c0}, {2}, {ofEa,ofDestDn}, "DIVU.W", {EA_An,0}},
1468: { MC_ALL, {0xf1c0, 0x81c0}, {2}, {ofEa,ofDestDn}, "DIVS.W", {EA_An,0}},
1469:
1470: { MC_ALL, {0xf1c0, 0x9000}, {1}, {ofEa,ofDestDn}, "SUB.B", {EA_An,0}},
1471: { MC_ALL, {0xf1c0, 0x9040}, {2}, {ofEa,ofDestDn}, "SUB.W"},
1472: { MC_ALL, {0xf1c0, 0x9080}, {4}, {ofEa,ofDestDn}, "SUB.L"},
1473: { MC_ALL, {0xf1c0, 0x90c0}, {2}, {ofEa,ofDestAn}, "SUBA.W"},
1474: { MC_ALL, {0xf1c0, 0x91c0}, {4}, {ofEa,ofDestAn}, "SUBA.L"},
1475: { MC_ALL, {0xf100, 0x9100}, {-1,6,2,0}, {ofDestDn,ofEa}, "SUB.?",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1476: { MC_ALL, {0xf138, 0x9100}, {-1,6,2,0}, {ofDn,ofDestDn}, "SUBX.?"},
1477: { MC_ALL, {0xf138, 0x9108}, {-1,6,2,0}, {ofPiAn,ofDestPiAn}, "SUBX.?"},
1478:
1479: { MC_ALL, {0xf000, 0xa000}, {0}, {ofLineA}, "LINEA"},
1480:
1481: { MC_ALL, {0xf1c0, 0xb000}, {1}, {ofEa,ofDestDn}, "CMP.B", {EA_An,0}},
1482: { MC_ALL, {0xf1c0, 0xb040}, {2}, {ofEa,ofDestDn}, "CMP.W"},
1483: { MC_ALL, {0xf1c0, 0xb080}, {4}, {ofEa,ofDestDn}, "CMP.L"},
1484: { MC_ALL, {0xf1c0, 0xb0c0}, {2}, {ofEa,ofDestAn}, "CMPA.W"},
1485: { MC_ALL, {0xf1c0, 0xb1c0}, {4}, {ofEa,ofDestAn}, "CMPA.L"},
1486: { MC_ALL, {0xf100, 0xb100}, {-1,6,2,0}, {ofDestDn,ofEa}, "EOR.?",{0,EA_An|EA_Immed|EA_PCRel} },
1487: { MC_ALL, {0xf138, 0xb108}, {-1,6,2,0}, {ofAnip,ofDestAnip}, "CMPM.?"},
1488:
1489: { MC_ALL, {0xf100, 0xc000}, {-1,6,2,0}, {ofEa,ofDestDn}, "AND.?", {EA_An,0}},
1490: { MC_ALL, {0xf100, 0xc100}, {-1,6,2,0}, {ofDestDn,ofEa}, "AND.?",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1491: { MC_ALL, {0xf1f8, 0xc100}, {1}, {ofDn,ofDestDn}, "ABCD"},
1492: { MC_ALL, {0xf1f8, 0xc108}, {1}, {ofPiAn,ofDestPiAn}, "ABCD"},
1493: { MC_ALL, {0xf1f8, 0xc140}, {1}, {ofDestDn,ofDn}, "EXG"},
1494: { MC_ALL, {0xf1f8, 0xc148}, {1}, {ofDestAn,ofAn}, "EXG"},
1495: { MC_ALL, {0xf1f8, 0xc188}, {1}, {ofDestDn,ofAn}, "EXG"},
1496: { MC_ALL, {0xf1c0, 0xc0c0}, {2}, {ofEa,ofDestDn}, "MULU.W", {EA_An,0}},
1497: { MC_ALL, {0xf1c0, 0xc1c0}, {2}, {ofEa,ofDestDn}, "MULS.W", {EA_An,0}},
1498:
1499: { MC_ALL, {0xf1c0, 0xd000}, {1}, {ofEa,ofDestDn}, "ADD.B", {EA_An,0}},
1500: { MC_ALL, {0xf1c0, 0xd040}, {2}, {ofEa,ofDestDn}, "ADD.W"},
1501: { MC_ALL, {0xf1c0, 0xd080}, {4}, {ofEa,ofDestDn}, "ADD.L"},
1502: { MC_ALL, {0xf1c0, 0xd0c0}, {2}, {ofEa,ofDestAn}, "ADDA.W"},
1503: { MC_ALL, {0xf1c0, 0xd1c0}, {4}, {ofEa,ofDestAn}, "ADDA.L"},
1504: { MC_ALL, {0xf100, 0xd100}, {-1,6,2,0}, {ofDestDn,ofEa}, "ADD.?",{0,EA_Immed|EA_PCRel|EA_An|EA_Dn}},
1505: { MC_ALL, {0xf138, 0xd100}, {-1,6,2,0}, {ofDn,ofDestDn}, "ADDX.?"},
1506: { MC_ALL, {0xf138, 0xd108}, {-1,6,2,0}, {ofPiAn,ofDestPiAn}, "ADDX.?"},
1507:
1508: { MC_ALL, {0xf138, 0xe000}, {-1,6,2,0}, {ofI3,ofDn}, "ASR.?"},
1509: { MC_ALL, {0xf138, 0xe008}, {-1,6,2,0}, {ofI3,ofDn}, "LSR.?"},
1510: { MC_ALL, {0xf138, 0xe010}, {-1,6,2,0}, {ofI3,ofDn}, "ROXR.?"},
1511: { MC_ALL, {0xf138, 0xe018}, {-1,6,2,0}, {ofI3,ofDn}, "ROR.?"},
1512: { MC_ALL, {0xf138, 0xe020}, {-1,6,2,0}, {ofDestDn,ofDn}, "ASR.?"},
1513: { MC_ALL, {0xf138, 0xe028}, {-1,6,2,0}, {ofDestDn,ofDn}, "LSR.?"},
1514: { MC_ALL, {0xf138, 0xe030}, {-1,6,2,0}, {ofDestDn,ofDn}, "ROXR.?"},
1515: { MC_ALL, {0xf138, 0xe038}, {-1,6,2,0}, {ofDestDn,ofDn}, "ROR.?"},
1516: { MC_ALL, {0xf138, 0xe100}, {-1,6,2,0}, {ofI3,ofDn}, "ASL.?"},
1517: { MC_ALL, {0xf138, 0xe108}, {-1,6,2,0}, {ofI3,ofDn}, "LSL.?"},
1518: { MC_ALL, {0xf138, 0xe110}, {-1,6,2,0}, {ofI3,ofDn}, "ROXL.?"},
1519: { MC_ALL, {0xf138, 0xe118}, {-1,6,2,0}, {ofI3,ofDn}, "ROL.?"},
1520: { MC_ALL, {0xf138, 0xe120}, {-1,6,2,0}, {ofDestDn,ofDn}, "ASL.?"},
1521: { MC_ALL, {0xf138, 0xe128}, {-1,6,2,0}, {ofDestDn,ofDn}, "LSL.?"},
1522: { MC_ALL, {0xf138, 0xe130}, {-1,6,2,0}, {ofDestDn,ofDn}, "ROXL.?"},
1523: { MC_ALL, {0xf138, 0xe138}, {-1,6,2,0}, {ofDestDn,ofDn}, "ROL.?"},
1524: { MC_ALL, {0xffc0, 0xe0c0}, {1}, {ofEa}, "ASR",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1525: { MC_ALL, {0xffc0, 0xe1c0}, {1}, {ofEa}, "ASL",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1526: { MC_ALL, {0xffc0, 0xe2c0}, {1}, {ofEa}, "LSR",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1527: { MC_ALL, {0xffc0, 0xe3c0}, {1}, {ofEa}, "LSL",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1528: { MC_ALL, {0xffc0, 0xe4c0}, {1}, {ofEa}, "ROXR",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1529: { MC_ALL, {0xffc0, 0xe5c0}, {1}, {ofEa}, "ROXL",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1530: { MC_ALL, {0xffc0, 0xe6c0}, {1}, {ofEa}, "ROR",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1531: { MC_ALL, {0xffc0, 0xe7c0}, {1}, {ofEa}, "ROL",{EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1532: { MC_020&~MC_CPU32, {0xffc0, 0xe8c0, 0xf000, 0x0000}, {1}, {ofBFEa}, "BFTST",{EA_An|EA_piAn|EA_Anip|EA_Immed}},
1533: { MC_020&~MC_CPU32, {0xffc0, 0xe9c0, 0x8000, 0x0000}, {1}, {ofBFEa,ofExtReg}, "BFEXTU",{EA_An|EA_piAn|EA_Anip|EA_Immed}},
1534: { MC_020&~MC_CPU32, {0xffc0, 0xeac0, 0xf000, 0x0000}, {1}, {ofBFEa}, "BFCHG",{EA_An|EA_piAn|EA_Anip|EA_Immed|EA_PCRel} },
1535: { MC_020&~MC_CPU32, {0xffc0, 0xebc0, 0x8000, 0x0000}, {1}, {ofBFEa,ofExtReg}, "BFEXTS",{EA_An|EA_piAn|EA_Anip|EA_Immed}},
1536: { MC_020&~MC_CPU32, {0xffc0, 0xecc0, 0xf000, 0x0000}, {1}, {ofBFEa}, "BFCLR",{EA_An|EA_piAn|EA_Anip|EA_Immed|EA_PCRel} },
1537: { MC_020&~MC_CPU32, {0xffc0, 0xedc0, 0x8000, 0x0000}, {1}, {ofBFEa,ofExtReg}, "BFFFO",{EA_An|EA_piAn|EA_Anip|EA_Immed}},
1538: { MC_020&~MC_CPU32, {0xffc0, 0xeec0, 0xf000, 0x0000}, {1}, {ofBFEa}, "BFSET",{EA_An|EA_piAn|EA_Anip|EA_Immed}},
1539: { MC_020&~MC_CPU32, {0xffc0, 0xefc0, 0x8000, 0x0000}, {1}, {ofExtReg,ofBFEa}, "BFINS",{0,EA_An|EA_piAn|EA_Anip|EA_Immed|EA_PCRel} },
1540:
1541:
1542: #define PMMU_COPROC_ID 0 // 0 is the standard PMMU
1543:
1544: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x2000}, {0}, {ofSpecReg,ofEa}, "PLOADW",{REG_SFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1545: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x2001}, {0}, {ofSpecReg,ofEa}, "PLOADW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1546: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xfff8, 0x2008}, {0}, {ofExtReg0,ofEa}, "PLOADW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1547: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xfff0, 0x2010}, {0}, {ofExtIm4,ofEa}, "PLOADW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1548:
1549: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x2200}, {0}, {ofSpecReg,ofEa}, "PLOADR",{REG_SFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1550: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x2201}, {0}, {ofSpecReg,ofEa}, "PLOADR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1551: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xfff8, 0x2208}, {0}, {ofExtReg0,ofEa}, "PLOADR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1552: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xfff0, 0x2210}, {0}, {ofExtIm4,ofEa}, "PLOADR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1553:
1554: { MC_PMMU, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0xa000}, {0}, {ofEa}, "PFLUSHR",{EA_Dn|EA_An} },
1555:
1556: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0800}, {0}, {ofEa,ofSpecReg}, "PMOVE",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_TT0} },
1557: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0900}, {0}, {ofEa,ofSpecReg}, "PMOVEFD",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_TT0} },
1.1.1.8 root 1558: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0B00}, {0}, {ofSpecReg,ofEa}, "PMOVEFD",{REG_TT0,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1.1 root 1559: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0C00}, {0}, {ofEa,ofSpecReg}, "PMOVE",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_TT1} },
1.1.1.8 root 1560: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0C00}, {0}, {ofSpecReg,ofEa}, "PMOVE",{REG_TT0,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1.1 root 1561: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0D00}, {0}, {ofEa,ofSpecReg}, "PMOVEFD",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_TT1} },
1.1.1.8 root 1562: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0E00}, {0}, {ofSpecReg,ofEa}, "PMOVE",{REG_TT1,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1563: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x0F00}, {0}, {ofSpecReg,ofEa}, "PMOVEFD",{REG_TT1,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1.1 root 1564: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4000}, {0}, {ofEa,ofSpecReg}, "PMOVE",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_TC} },
1565: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4100}, {0}, {ofEa,ofSpecReg}, "PMOVEFD",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_TC} },
1.1.1.8 root 1566: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4200}, {0}, {ofSpecReg,ofEa}, "PMOVE",{REG_TC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1567: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4300}, {0}, {ofSpecReg,ofEa}, "PMOVEFD",{REG_TC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1.1 root 1568: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4800}, {0}, {ofEa,ofSpecReg}, "PMOVE",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_SRP} },
1569: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4900}, {0}, {ofEa,ofSpecReg}, "PMOVEFD",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_SRP} },
1.1.1.8 root 1570: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4A00}, {0}, {ofSpecReg,ofEa}, "PMOVE",{REG_SRP,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_SRP} },
1571: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4B00}, {0}, {ofSpecReg,ofEa}, "PMOVEFD",{REG_SRP,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_SRP} },
1.1 root 1572: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4C00}, {0}, {ofEa,ofSpecReg}, "PMOVE",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_CRP} },
1573: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4D00}, {0}, {ofEa,ofSpecReg}, "PMOVEFD",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_CRP} },
1.1.1.8 root 1574: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4e00}, {0}, {ofSpecReg,ofEa}, "PMOVE",{REG_CRP,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1575: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x4f00}, {0}, {ofSpecReg,ofEa}, "PMOVEFD",{REG_CRP,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1.1 root 1576: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x6000}, {0}, {ofEa,ofSpecReg}, "PMOVE",{EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel,REG_MMUSR} },
1.1.1.8 root 1577: { MC_PMMU|MC68030, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x6200}, {0}, {ofSpecReg,ofEa}, "PMOVE",{REG_MMUSR,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1.1 root 1578:
1579: { MC_PMMU, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xffff, 0x2800}, {0}, {ofSpecReg,ofEa}, "PVALID",{REG_VAL,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1580: { MC_PMMU, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xfff8, 0x2C00}, {0}, {ofExtRegA0,ofEa}, "PVALID",{0,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1581:
1582: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3ff, 0x8000}, {0}, {ofSpecReg,ofEa,ofExtIm10}, "PTESTW",{REG_SFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1583: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3ff, 0x8001}, {0}, {ofSpecReg,ofEa,ofExtIm10}, "PTESTW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1584: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3f8, 0x8008}, {0}, {ofExtReg0,ofEa,ofExtIm10}, "PTESTW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1585: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3f0, 0x8010}, {0}, {ofExtIm4,ofEa,ofExtIm10}, "PTESTW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1586:
1587: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3ff, 0x8200}, {0}, {ofSpecReg,ofEa,ofExtIm10}, "PTESTR",{REG_SFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1588: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3ff, 0x8201}, {0}, {ofSpecReg,ofEa,ofExtIm10}, "PTESTR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1589: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3f8, 0x8208}, {0}, {ofExtReg0,ofEa,ofExtIm10}, "PTESTR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1590: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe3f0, 0x8210}, {0}, {ofExtIm4,ofEa,ofExtIm10}, "PTESTR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1591:
1592: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe31f, 0x8100}, {0}, {ofSpecReg,ofEa,ofExtIm10,ofExtRegA05}, "PTESTW",{REG_SFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1593: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe31f, 0x8101}, {0}, {ofSpecReg,ofEa,ofExtIm10,ofExtRegA05}, "PTESTW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1594: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe318, 0x8108}, {0}, {ofExtReg0,ofEa,ofExtIm10,ofExtRegA05}, "PTESTW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1595: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe310, 0x8110}, {0}, {ofExtIm4,ofEa,ofExtIm10,ofExtRegA05}, "PTESTW",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1596:
1597: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe31f, 0x8300}, {0}, {ofSpecReg,ofEa,ofExtIm10,ofExtRegA05}, "PTESTR",{REG_SFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1598: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe31f, 0x8301}, {0}, {ofSpecReg,ofEa,ofExtIm10,ofExtRegA05}, "PTESTR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1599: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe318, 0x8308}, {0}, {ofExtReg0,ofEa,ofExtIm10,ofExtRegA05}, "PTESTR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1600: { MC_PMMU|MC68030|MC68040|MC68LC040, {0xffc0, 0xf000|(PMMU_COPROC_ID<<9), 0xe310, 0x8310}, {0}, {ofExtIm4,ofEa,ofExtIm10,ofExtRegA05}, "PTESTR",{REG_DFC,EA_Dn|EA_An|EA_Anip|EA_piAn|EA_Immed|EA_PCRel} },
1601:
1602: { MC_PMMU, {0xffc0, 0xf040|(PMMU_COPROC_ID<<9), 0xfff0, 0x8310}, {0}, {ofEa}, "PScp",{EA_An|EA_Immed|EA_PCRel} },
1603: { MC_PMMU, {0xfff8, 0xf048|(PMMU_COPROC_ID<<9), 0xfff0, 0x0000}, {2}, {ofDn,ofDisp}, "PDBcp"},
1604: { MC_PMMU, {0xffff, 0xf07A|(PMMU_COPROC_ID<<9), 0xfff0, 0x0000, 0x10000,0x0000}, {2}, {ofExtIm32}, "PTRAPcp.W" },
1605: { MC_PMMU, {0xffff, 0xf07B|(PMMU_COPROC_ID<<9), 0xfff0, 0x0000, 0x10000,0x0000}, {4}, {ofExtIm32}, "PTRAPcp.L" },
1606: { MC_PMMU, {0xffff, 0xf07C|(PMMU_COPROC_ID<<9), 0xfff0, 0x0000}, {0}, {ofNone}, "PTRAPcp" },
1607: { MC_PMMU, {0xfff0, 0xf080|(PMMU_COPROC_ID<<9)}, {2}, {ofDisp}, "PBcp.W"},
1608: { MC_PMMU, {0xfff0, 0xf0C0|(PMMU_COPROC_ID<<9)}, {4}, {ofDisp}, "PBcp.L"},
1609: { MC_PMMU, {0xffc0, 0xf100|(PMMU_COPROC_ID<<9)}, {0}, {ofEa}, "PSAVE",{EA_Dn|EA_An|EA_Anip|EA_Immed} },
1610: { MC_PMMU, {0xffc0, 0xf140|(PMMU_COPROC_ID<<9)}, {0}, {ofEa}, "PRESTORE",{EA_Dn|EA_An|EA_piAn|EA_Immed} },
1611:
1612:
1613: #define MC040_COPROC_ID 3 // 3 is the code for some 68040/68060 opcodes
1614:
1615: { MC68040|MC68060, {0xfff8, 0xf000|(MC040_COPROC_ID<<9), 0x8fff, 0x8000}, {0}, {ofAnip,ofDestAbsL}, "MOVE16"},
1616: { MC68040|MC68060, {0xfff8, 0xf008|(MC040_COPROC_ID<<9), 0x8fff, 0x8000}, {0}, {ofDestAbsL,ofAnip}, "MOVE16"},
1617: { MC68040|MC68060, {0xfff8, 0xf010|(MC040_COPROC_ID<<9), 0x8fff, 0x8000}, {0}, {ofAni,ofDestAbsL}, "MOVE16"},
1618: { MC68040|MC68060, {0xfff8, 0xf018|(MC040_COPROC_ID<<9), 0x8fff, 0x8000}, {0}, {ofDestAbsL,ofAni}, "MOVE16"},
1619: { MC68040|MC68060, {0xfff8, 0xf020|(MC040_COPROC_ID<<9), 0x8fff, 0x8000}, {0}, {ofAnip,ofExtAnip}, "MOVE16"},
1620:
1621:
1622: #define CPU32_COPROC_ID 4 // 4 is the code for some CPU32 opcodes
1623:
1624: { MC68040|MC68060, {0xfff8, 0xf008|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVL",{REG_CACHES_NONE} },
1625: { MC68040|MC68060, {0xfff8, 0xf048|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVL",{REG_CACHES_DC} },
1626: { MC68040|MC68060, {0xfff8, 0xf088|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVL",{REG_CACHES_IC} },
1627: { MC68040|MC68060, {0xfff8, 0xf0C8|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVL",{REG_CACHES_ICDC} },
1628:
1629: { MC68040|MC68060, {0xfff8, 0xf010|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVP",{REG_CACHES_NONE} },
1630: { MC68040|MC68060, {0xfff8, 0xf050|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVP",{REG_CACHES_DC} },
1631: { MC68040|MC68060, {0xfff8, 0xf090|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVP",{REG_CACHES_IC} },
1632: { MC68040|MC68060, {0xfff8, 0xf0D0|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVP",{REG_CACHES_ICDC} },
1633:
1634: { MC68040|MC68060, {0xfff8, 0xf018|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVA",{REG_CACHES_NONE} },
1635: { MC68040|MC68060, {0xfff8, 0xf058|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVA",{REG_CACHES_DC} },
1636: { MC68040|MC68060, {0xfff8, 0xf098|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVA",{REG_CACHES_IC} },
1637: { MC68040|MC68060, {0xfff8, 0xf0D8|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CINVA",{REG_CACHES_ICDC} },
1638:
1639: { MC68040|MC68060, {0xfff8, 0xf028|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHL",{REG_CACHES_NONE} },
1640: { MC68040|MC68060, {0xfff8, 0xf068|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHL",{REG_CACHES_DC} },
1641: { MC68040|MC68060, {0xfff8, 0xf0A8|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHL",{REG_CACHES_IC} },
1642: { MC68040|MC68060, {0xfff8, 0xf0E8|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHL",{REG_CACHES_ICDC} },
1643:
1644: { MC68040|MC68060, {0xfff8, 0xf030|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHP",{REG_CACHES_NONE} },
1645: { MC68040|MC68060, {0xfff8, 0xf070|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHP",{REG_CACHES_DC} },
1646: { MC68040|MC68060, {0xfff8, 0xf0B0|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHP",{REG_CACHES_IC} },
1647: { MC68040|MC68060, {0xfff8, 0xf0F0|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHP",{REG_CACHES_ICDC} },
1648:
1649: { MC68040|MC68060, {0xfff8, 0xf038|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHA",{REG_CACHES_NONE} },
1650: { MC68040|MC68060, {0xfff8, 0xf078|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHA",{REG_CACHES_DC} },
1651: { MC68040|MC68060, {0xfff8, 0xf0B8|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHA",{REG_CACHES_IC} },
1652: { MC68040|MC68060, {0xfff8, 0xf0F8|(CPU32_COPROC_ID<<9)}, {0}, {ofSpecReg,ofAn}, "CPUSHA",{REG_CACHES_ICDC} },
1653:
1654: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f08, 0x0100}, {-1,16+6,2,0}, {ofExt4Dn}, "TBLU.?" },
1655: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f3f, 0x0100}, {-1,16+6,2,0}, {ofExtReg,ofEa}, "TBLU.?",{EA_An|EA_An|EA_Anip|EA_Immed|EA_PCRel} },
1656: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f28, 0x0500}, {-1,16+6,2,0}, {ofExt4Dn}, "TBLUN.?" },
1657: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f3f, 0x0500}, {-1,16+6,2,0}, {ofExtReg,ofEa}, "TBLUN.?",{EA_An|EA_An|EA_Anip|EA_Immed|EA_PCRel} },
1658:
1659: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f08, 0x0900}, {-1,16+6,2,0}, {ofExt4Dn}, "TBLS.?" },
1660: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f3f, 0x0900}, {-1,16+6,2,0}, {ofExtReg,ofEa}, "TBLS.?",{EA_An|EA_An|EA_Anip|EA_Immed|EA_PCRel} },
1661: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f28, 0x0D00}, {-1,16+6,2,0}, {ofExt4Dn}, "TBLSN.?" },
1662: { MC_CPU32, {0xffc0, 0xf000|(CPU32_COPROC_ID<<9), 0x8f3f, 0x0D00}, {-1,16+6,2,0}, {ofExtReg,ofEa}, "TBLSN.?",{EA_An|EA_An|EA_Anip|EA_Immed|EA_PCRel} },
1663:
1664: { MC_CPU32, {0xffff, 0xf000|(CPU32_COPROC_ID<<9), 0xffff, 0x01C0}, {2}, {ofI}, "LPSTOP" },
1665:
1666:
1667: #define FPU_COPROC_ID 1 // 1 is the standard FPU, required to be 1 for the 68040 anyway
1668:
1669: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0000}, {-1,16+10,3,1}, {ofFPU}, "FMOVE.?" },
1670: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0001}, {-1,16+10,3,1}, {ofFPU}, "FINT.?" },
1671: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0002}, {-1,16+10,3,1}, {ofFPU}, "FSINH.?" },
1672: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0003}, {-1,16+10,3,1}, {ofFPU}, "FINTRZ.?" },
1673: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0004}, {-1,16+10,3,1}, {ofFPU}, "FSQRT.?" },
1674: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0006}, {-1,16+10,3,1}, {ofFPU}, "FLOGNP1.?" },
1675: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0008}, {-1,16+10,3,1}, {ofFPU}, "FETOXM1.?" },
1676: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0009}, {-1,16+10,3,1}, {ofFPU}, "FTANH.?" },
1677: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x000A}, {-1,16+10,3,1}, {ofFPU}, "FATAN.?" },
1678: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x000C}, {-1,16+10,3,1}, {ofFPU}, "FASIN.?" },
1679: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x000D}, {-1,16+10,3,1}, {ofFPU}, "FATANH.?" },
1680: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x000E}, {-1,16+10,3,1}, {ofFPU}, "FSIN.?" },
1681: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x000F}, {-1,16+10,3,1}, {ofFPU}, "FTAN.?" },
1682: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0010}, {-1,16+10,3,1}, {ofFPU}, "FETOX.?" },
1683: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0011}, {-1,16+10,3,1}, {ofFPU}, "FTWOTOX.?" },
1684: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0012}, {-1,16+10,3,1}, {ofFPU}, "FTENTOX.?" },
1685: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0014}, {-1,16+10,3,1}, {ofFPU}, "FLOGN.?" },
1686: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0015}, {-1,16+10,3,1}, {ofFPU}, "FLOG10.?" },
1687: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0016}, {-1,16+10,3,1}, {ofFPU}, "FLOG2.?" },
1688: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0018}, {-1,16+10,3,1}, {ofFPU}, "FABS.?" },
1689: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0019}, {-1,16+10,3,1}, {ofFPU}, "FCOSH.?" },
1690: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x001A}, {-1,16+10,3,1}, {ofFPU}, "FNEG.?" },
1691: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x001C}, {-1,16+10,3,1}, {ofFPU}, "FACOS.?" },
1692: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x001D}, {-1,16+10,3,1}, {ofFPU}, "FCOS.?" },
1693: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x001E}, {-1,16+10,3,1}, {ofFPU}, "FGETEXP.?" },
1694: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x001F}, {-1,16+10,3,1}, {ofFPU}, "FGETMAN.?" },
1695: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0020}, {-1,16+10,3,1}, {ofFPU}, "FDIV.?" },
1696: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0021}, {-1,16+10,3,1}, {ofFPU}, "FMOD.?" },
1697: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0022}, {-1,16+10,3,1}, {ofFPU}, "FADD.?" },
1698: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0023}, {-1,16+10,3,1}, {ofFPU}, "FMUL.?" },
1699: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0024}, {-1,16+10,3,1}, {ofFPU}, "FSGLDIV.?" },
1700: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0025}, {-1,16+10,3,1}, {ofFPU}, "FREM.?" },
1701: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0026}, {-1,16+10,3,1}, {ofFPU}, "FSCALE.?" },
1702: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0027}, {-1,16+10,3,1}, {ofFPU}, "FSGLMUL.?" },
1703: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0028}, {-1,16+10,3,1}, {ofFPU}, "FSUB.?" },
1704: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA078,0x0030}, {-1,16+10,3,1}, {ofFPU3Reg}, "FSINCOS.?" },
1705: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0038}, {-1,16+10,3,1}, {ofFPU}, "FCMP.?" },
1706: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x003A}, {-1,16+10,3,1}, {ofFPU}, "FTST.?" },
1707: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0040}, {-1,16+10,3,1}, {ofFPU}, "FSMOVE.?" },
1708: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0041}, {-1,16+10,3,1}, {ofFPU}, "FSSQRT.?" },
1709: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0042}, {-1,16+10,3,1}, {ofFPU}, "FSADD.?" },
1710: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0044}, {-1,16+10,3,1}, {ofFPU}, "FDMOVE.?" },
1711: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0045}, {-1,16+10,3,1}, {ofFPU}, "FDSQRT.?" },
1712: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0046}, {-1,16+10,3,1}, {ofFPU}, "FDADD.?" },
1713: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0058}, {-1,16+10,3,1}, {ofFPU}, "FSABS.?" },
1714: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x005A}, {-1,16+10,3,1}, {ofFPU}, "FSNEG.?" },
1715: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x005C}, {-1,16+10,3,1}, {ofFPU}, "FDABS.?" },
1716: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x005E}, {-1,16+10,3,1}, {ofFPU}, "FDNEG.?" },
1717: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0060}, {-1,16+10,3,1}, {ofFPU}, "FSDIV.?" },
1718: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0063}, {-1,16+10,3,1}, {ofFPU}, "FSMUL.?" },
1719: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0064}, {-1,16+10,3,1}, {ofFPU}, "FDDIV.?" },
1720: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0067}, {-1,16+10,3,1}, {ofFPU}, "FDMUL.?" },
1721: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x0068}, {-1,16+10,3,1}, {ofFPU}, "FSSUB.?" },
1722: { MC68040, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xA07F,0x006C}, {-1,16+10,3,1}, {ofFPU}, "FDSUB.?" },
1723: { MC68040|MC_FPU, {0xffff, 0xf000|(FPU_COPROC_ID<<9),0xFC00,0x5C00}, {0}, {ofFMOVECR}, "FMOVECR" },
1724:
1725: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xE000,0x6000}, {-1,16+10,3,1}, {ofFPUMOVE}, "FMOVE.?" },
1726:
1727: // these 3 are special versions of MOVEM with just one register, they have to be before the FMOVEM version
1728: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFFFF,0x8400}, {0}, {ofEa,ofSpecReg}, "FMOVE", {0,REG_FPU_FPIAR} },
1729: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFFFF,0x8800}, {0}, {ofEa,ofSpecReg}, "FMOVE", {EA_An,REG_FPU_FPSR} },
1730: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFFFF,0x9000}, {0}, {ofEa,ofSpecReg}, "FMOVE", {EA_An,REG_FPU_FPCR} },
1731: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xE3FF,0x8000}, {0}, {ofEa,ofFPUSRRegList}, "FMOVEM", {EA_Dn|EA_An,0} },
1732: // these 3 are special versions of MOVEM with just one register, they have to be before the FMOVEM version
1733: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFFFF,0xA400}, {0}, {ofSpecReg,ofEa}, "FMOVE", {REG_FPU_FPIAR,EA_Immed|EA_PCRel} },
1734: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFFFF,0xA800}, {0}, {ofSpecReg,ofEa}, "FMOVE", {REG_FPU_FPSR,EA_An|EA_Immed|EA_PCRel} },
1735: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFFFF,0xB000}, {0}, {ofSpecReg,ofEa}, "FMOVE", {REG_FPU_FPCR,EA_An|EA_Immed|EA_PCRel} },
1736: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xE3FF,0xA000}, {0}, {ofFPUSRRegList,ofEa}, "FMOVEM", {0,EA_Dn|EA_An|EA_Immed|EA_PCRel} },
1737:
1738: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFE00,0xC000}, {0}, {ofFPUReglist,ofEa}, "FMOVEM.X",{0,EA_Dn|EA_An|EA_Anip|EA_Immed} },
1739: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFE8F,0xC800}, {0}, {ofExtRegD04,ofEa}, "FMOVEM.X",{0,EA_Dn|EA_An|EA_piAn|EA_Immed} },
1740: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFE00,0xE000}, {0}, {ofEa,ofFPUReglist}, "FMOVEM.X",{EA_Dn|EA_An|EA_piAn|EA_Immed,0} },
1741: { MC68040|MC_FPU, {0xffc0, 0xf000|(FPU_COPROC_ID<<9),0xFE8F,0xE800}, {0}, {ofEa,ofExtRegD04}, "FMOVEM.X",{EA_Dn|EA_An|EA_Anip|EA_Immed|EA_PCRel} },
1742:
1743: { MC68040|MC_FPU, {0xffc0, 0xf040|(FPU_COPROC_ID<<9),0xFFC0,0x0000}, {0}, {ofEa}, "FScf.B",{EA_An|EA_Immed|EA_PCRel} },
1744: { MC68040|MC_FPU, {0xfff8, 0xf048|(FPU_COPROC_ID<<9),0xFFC0,0x0000}, {2}, {ofDn,ofDisp}, "FDBcf" },
1745: { MC68040|MC_FPU, {0xffff, 0xf07A|(FPU_COPROC_ID<<9), 0xfff0, 0x0000, 0x10000,0x0000}, {2}, {ofExtIm32}, "FTRAPcf.W" },
1746: { MC68040|MC_FPU, {0xffff, 0xf07B|(FPU_COPROC_ID<<9), 0xfff0, 0x0000, 0x10000,0x0000}, {4}, {ofExtIm32}, "FTRAPcf.L" },
1747: { MC68040|MC_FPU, {0xffff, 0xf07C|(FPU_COPROC_ID<<9), 0xfff0, 0x0000}, {0}, {ofNone}, "FTRAPcf" },
1748:
1749: // FNOP _has_ to be before FBcf.W, not worth to have a special case for that one
1750: { MC68040|MC_FPU, {0xffff, 0xf080|(FPU_COPROC_ID<<9),0xFFFF,0x0000}, {0}, {ofNone}, "FNOP" },
1751: { MC68040|MC_FPU, {0xffc0, 0xf080|(FPU_COPROC_ID<<9),0xFFFF,0x0000}, {2}, {ofDisp}, "FBcF.W" },
1752: { MC68040|MC_FPU, {0xffc0, 0xf0c0|(FPU_COPROC_ID<<9),0xFFFF,0x0000}, {4}, {ofDisp}, "FBcF.L" },
1753: { MC68040|MC68060|MC_FPU, {0xffc0, 0xf100|(FPU_COPROC_ID<<9)}, {0}, {ofEa}, "FSAVE", {EA_Dn|EA_An|EA_piAn|EA_Immed} },
1754: { MC68040|MC68060|MC_FPU, {0xffc0, 0xf140|(FPU_COPROC_ID<<9)}, {0}, {ofEa}, "FRESTORE", {EA_Dn|EA_An|EA_piAn|EA_Immed} },
1755:
1.1.1.4 root 1756: { 0 }
1.1 root 1757: };
1758:
1759: static int Disass68k(long addr, char *labelBuffer, char *opcodeBuffer, char *operandBuffer, char *commentBuffer)
1760: {
1761: long baseAddr = addr;
1.1.1.4 root 1762: int i;
1763: int count = 0;
1764: char addressLabel[256];
1765: char cmtBuffer[256];
1766: Disass68kDataType type;
1767: int index;
1768: long opcodeAddr;
1769:
1.1 root 1770: labelBuffer[0] = 0;
1771: opcodeBuffer[0] = 0;
1772: operandBuffer[0] = 0;
1773: commentBuffer[0] = 0;
1774:
1.1.1.4 root 1775: type = Disass68kType(baseAddr, addressLabel, cmtBuffer, &count);
1.1 root 1776: if(addressLabel[0])
1777: sprintf(labelBuffer, "%s:", addressLabel);
1778: sprintf(commentBuffer, "%s", cmtBuffer);
1779: switch(type)
1780: {
1.1.1.4 root 1781: case dtByte:
1782: if(count > 8)
1783: count = 8;
1784: strcpy(opcodeBuffer,"DC.B");
1785: for (i = 0; i < count; ++i)
1786: {
1787: char hbuf[16];
1788: unsigned short val;
1789:
1790: if((i & 7) > 0)
1791: strcat(operandBuffer, ",");
1792: val = Disass68kGetWord(addr+(i & ~1));
1793: if(i & 1)
1794: val &= 0xFF;
1795: else
1796: val = val >> 8;
1797: sprintf(hbuf,"$%2.2x", val);
1798: strcat(operandBuffer, hbuf);
1799: }
1800: return count;
1801:
1802: case dtWord:
1803: if(count > 4)
1804: count = 4;
1805: strcpy(opcodeBuffer,"DC.W");
1806: for (i = 0; i < count; ++i)
1807: {
1808: char hbuf[16];
1809: if((i & 3) > 0)
1810: strcat(operandBuffer, ",");
1811: sprintf(hbuf,"$%4.4x", Disass68kGetWord(addr+i*2));
1812: strcat(operandBuffer, hbuf);
1813: }
1814: return count * 2;
1815:
1816: case dtLong:
1817: if(count > 2)
1818: count = 2;
1819: strcpy(opcodeBuffer,"DC.L");
1820: for (i = 0; i < count; ++i)
1821: {
1822: char hbuf[16];
1823: if((i & 1) > 0)
1824: strcat(operandBuffer, ",");
1825: sprintf(hbuf,"$%8.8x", (Disass68kGetWord(addr+i*4) << 16) | Disass68kGetWord(addr+i*4+2));
1826: strcat(operandBuffer, hbuf);
1827: }
1828: return count * 4;
1.1 root 1829:
1830: case dtStringArray:
1.1.1.4 root 1831: {
1832: char *sp;
1833: strcpy(opcodeBuffer,"DC.B");
1834: strcat(operandBuffer, "'");
1835: sp = operandBuffer + strlen(operandBuffer);
1836: for (i = 0; i < count; ++i)
1837: {
1838: unsigned short val = Disass68kGetWord(addr+(i & ~1));
1839: if(i & 1)
1840: val &= 0xFF;
1841: else
1842: val = val >> 8;
1843: if(val == 0)
1844: break;
1845: switch(val)
1846: {
1847: case 9: *sp++ = '\\'; *sp++ = 't'; break;
1848: case 10: *sp++ = '\\'; *sp++ = 'n'; break;
1849: case 13: *sp++ = '\\'; *sp++ = 'r'; break;
1850: default:
1851: if(val >= 0x20 && val <= 0x7E)
1852: *sp++ = val;
1853: }
1854: }
1855: *sp = 0;
1856: strcat(sp, "'");
1857: return count;
1858: }
1.1 root 1859:
1860: case dtASCString:
1.1.1.4 root 1861: {
1.1.1.7 root 1862: unsigned short opcval = Disass68kGetWord(addr+0);
1863: count = 1;
1.1.1.4 root 1864: strcpy(opcodeBuffer,"DC.B");
1.1.1.7 root 1865: if ((opcval >> 8) == 0)
1.1.1.4 root 1866: {
1867: strcat(operandBuffer, "0");
1868: } else {
1869: char *sp;
1870: strcat(operandBuffer, "'");
1871: sp = operandBuffer + strlen(operandBuffer);
1872: for(i=0; ; ++i)
1873: {
1874: unsigned short val = Disass68kGetWord(addr+(i & ~1));
1875: if(i & 1)
1876: val &= 0xFF;
1877: else
1878: val = val >> 8;
1879: if(val == 0)
1880: break;
1881: switch(val)
1.1 root 1882: {
1.1.1.4 root 1883: case 9: *sp++ = '\\'; *sp++ = 't'; break;
1884: case 10: *sp++ = '\\'; *sp++ = 'n'; break;
1885: case 13: *sp++ = '\\'; *sp++ = 'r'; break;
1886: default:
1887: if(val >= 0x20 && val <= 0x7E)
1888: *sp++ = val;
1.1 root 1889: }
1.1.1.4 root 1890: ++count;
1891: }
1892: *sp = 0;
1893: strcat(sp, "',0");
1894: }
1895: return (count + 1) & ~1;
1896: }
1.1 root 1897:
1898: case dtPointer:
1899: case dtFunctionPointer:
1.1.1.4 root 1900: {
1901: const char *sp;
1.1.1.7 root 1902: int val;
1.1.1.4 root 1903: val = (Disass68kGetWord(addr) << 16) | Disass68kGetWord(addr+2);
1904: sp = Disass68kSymbolName(val, 2);
1905: strcpy(opcodeBuffer,"DC.L");
1906: if(sp)
1907: sprintf(operandBuffer,"%s", sp);
1908: else
1.1.1.6 root 1909: sprintf(operandBuffer,"$%8.8x", val);
1.1.1.4 root 1910: return 4;
1911: }
1.1 root 1912:
1913: default: break;
1914: }
1915:
1.1.1.4 root 1916: index = 0;
1917: opcodeAddr = addr;
1.1 root 1918: more:
1919: addr = opcodeAddr;
1920:
1921: opcodeBuffer[0] = 0;
1922: operandBuffer[0] = 0;
1923:
1924: commentBuffer[0] = 0;
1925: if(cmtBuffer[0])
1926: sprintf(commentBuffer, "%s ", cmtBuffer);
1927:
1928: while(1)
1929: {
1.1.1.4 root 1930: unsigned short opcode[5];
1.1 root 1931: OpcodeTableStruct *ots = &OpcodeTable[index++];
1.1.1.4 root 1932: int size;
1933: char sizeChar = 0;
1934: char *dbuf;
1935: int ea;
1.1.1.7 root 1936: int maxop;
1.1.1.4 root 1937:
1.1 root 1938: if(ots->opcodeName == NULL)
1939: break;
1940: if((ots->cpuMask & optionCPUTypeMask) == 0) // CPU doesn't match?
1941: continue;
1942:
1943: // search for the opcode plus up to 2 extension words
1944: for(i=0; i<5; ++i)
1945: {
1946: if(!ots->opcodeMask[i*2])
1.1.1.4 root 1947: {
1948: opcode[i] = 0;
1.1 root 1949: break;
1.1.1.4 root 1950: }
1.1 root 1951: opcode[i] = Disass68kGetWord(addr);
1952: if(((ots->opcodeMask[i*2] & 0xFFFF) & opcode[i]) != ots->opcodeMask[i*2+1])
1953: goto more;
1954: addr += 2;
1955: }
1956:
1957: // find out the size of the opcode operand
1.1.1.4 root 1958: size = ots->operationSize[0];
1.1 root 1959: if(size < 0) // custom size?
1960: {
1961: int opcodeOffset = ots->operationSize[1] >> 4;
1962: int bitShiftOffset = ots->operationSize[1] & 0x0F;
1963: int sizeBitMask = (opcode[opcodeOffset] >> bitShiftOffset) & ((1 << ots->operationSize[2]) - 1);
1964: switch(ots->operationSize[3])
1965: {
1966: case 0: // 2 Bit Size
1967: switch(sizeBitMask)
1968: {
1969: case 0: size = 1; sizeChar = 'B'; break;
1970: case 1: size = 2; sizeChar = 'W'; break;
1971: case 2: size = 4; sizeChar = 'L'; break;
1972: case 3: goto more; // illegal size mask
1973: }
1974: break;
1975: case 1: // 3 Bit FPU Size
1976: if((opcode[1] & 0x4000) == 0x0000) // Register => Register?
1977: sizeBitMask = 2; // => 'X' Format
1978: switch(sizeBitMask)
1979: {
1980: case 0: size = 4; sizeChar = 'L'; break;
1981: case 1: size = 4; sizeChar = 'S'; break;
1982: case 2: size = 12; sizeChar = 'X'; break;
1983: case 7: if((opcode[1] & 0xE000) != 0x6000) // MOVE.P <ea>,FPn{Dn-Factor}
1984: goto more; // illegal size mask
1985: case 3: size = 12; sizeChar = 'P'; break;
1986: case 4: size = 2; sizeChar = 'W'; break;
1987: case 5: size = 8; sizeChar = 'D'; break;
1988: case 6: size = 1; sizeChar = 'B'; break;
1989: }
1990: break;
1991: }
1992: }
1993:
1994: // copy the opcode plus a necessary TAB for the operand
1.1.1.4 root 1995: dbuf = opcodeBuffer;
1.1 root 1996: for(i=0; ots->opcodeName[i]; ++i)
1997: {
1998: char c = ots->opcodeName[i];
1999: if(c == 'c') // condition code
2000: {
2001: static const char *pmmuCond[16] = { "BS", "BC", "LS", "LC", "SS", "SC", "AS", "AC", "WS", "WC", "IS", "IC", "GS", "GC", "CS", "CC" };
2002: static const char *braCond[16] = { "RA", "SR", "HI", "LS", "CC", "CS", "NE", "EQ", "VC", "VS", "PL", "MI", "GE", "LT", "GT", "LE" };
2003: static const char *sccCond[16] = { "T", "F", "HI", "LS", "CC", "CS", "NE", "EQ", "VC", "VS", "PL", "MI", "GE", "LT", "GT", "LE" };
2004: static const char *dbCond[16] = { "T", "RA", "HI", "LS", "CC", "CS", "NE", "EQ", "VC", "VS", "PL", "MI", "GE", "LT", "GT", "LE" };
2005: static const char *fpuCond[64] = { "F", "EQ", "OGT", "OGE", "OLT", "OLE", "OGL", "OR", "UN", "UEQ", "UGT", "UGE", "ULT", "ULE", "NE", "T", "SF", "SEQ", "GT", "GE", "LT", "LE", "GL", "GLE", "NGLE", "NGL", "NLE", "NLT", "NGE", "NGT", "SNE", "ST" };
1.1.1.4 root 2006: char buf[8];
1.1 root 2007:
2008: const char *sp = NULL;
2009: switch(ots->opcodeName[++i])
2010: {
2011: case 'p': // PMMU conditions
2012: sp = pmmuCond[opcode[1] & 0xF];
2013: break;
2014: case 'b': // BRA conditions
2015: sp = braCond[(opcode[0] >> 8) & 0xF];
2016: break;
2017: case 'i': // Scc,TRAPcc conditions
2018: sp = sccCond[(opcode[0] >> 8) & 0xF];
2019: break;
2020: case 'd': // DBcc conditions
2021: sp = dbCond[(opcode[0] >> 8) & 0xF];
2022: break;
2023: case 'F': // FPU conditions (first word)
2024: sp = fpuCond[opcode[0] & 0x3F];
2025: break;
2026: case 'f': // FPU conditions (second word)
2027: sp = fpuCond[opcode[1] & 0x3F];
2028: break;
2029: }
2030: if(sp)
2031: {
2032: if(options & doptOpcodesSmall)
2033: {
1.1.1.4 root 2034: char *bp;
1.1 root 2035: strcpy(buf, sp);
2036: sp = buf;
1.1.1.4 root 2037: for (bp = buf; *bp; ++bp)
1.1.1.5 root 2038: *bp = tolower((unsigned char)*bp);
1.1 root 2039: }
2040: strcpy(dbuf, sp);
2041: dbuf += strlen(sp);
2042: continue;
2043: }
2044: goto more;
2045: }
2046: if(c == '?') // size mask
2047: c = sizeChar;
2048: if(options & doptOpcodesSmall)
1.1.1.5 root 2049: c = tolower((unsigned char)c);
1.1 root 2050: *dbuf++ = c;
2051: }
2052: *dbuf = 0;
2053:
2054: // Parse the EAs for all operands
1.1.1.4 root 2055: ea = opcode[0] & 0x3F;
1.1 root 2056: dbuf = operandBuffer;
1.1.1.5 root 2057:
1.1.1.7 root 2058: maxop = (int)(sizeof(ots->op)/sizeof(ots->op[0]));
1.1.1.5 root 2059: for(i=0; i<maxop; ++i)
1.1 root 2060: {
1.1.1.7 root 2061: int reg, val;
1.1.1.4 root 2062:
1.1 root 2063: switch(ots->op[i])
2064: {
2065: case ofNone: // nothing
2066: break;
2067:
2068: case ofEa:
2069: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ea, size, EA_All & ~(ots->parameter[i]), 0, ots->disassFlag);
2070: break;
2071:
2072: case ofDn:
2073: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (ea & 7) | 0x00, size, EA_Dn, 0, ots->disassFlag);
2074: break;
2075: case ofAn:
2076: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (ea & 7) | 0x08, size, EA_An, 0, ots->disassFlag);
2077: break;
2078: case ofAni:
2079: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (ea & 7) | 0x10, size, EA_Ani, 0, ots->disassFlag);
2080: break;
2081: case ofAnip:
2082: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (ea & 7) | 0x18, size, EA_Anip, 0, ots->disassFlag);
2083: break;
2084: case ofPiAn:
2085: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (ea & 7) | 0x20, size, EA_piAn, 0, ots->disassFlag);
2086: break;
2087: case ofD16An:
2088: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (ea & 7) | 0x28, size, EA_dAn, 0, ots->disassFlag);
2089: break;
2090:
2091: case ofI:
2092: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x3C, size, EA_Immed, 0, ots->disassFlag);
2093: break;
2094:
2095: case ofDestDn:
2096: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[0] >> 9) & 7) | 0x00, size, EA_Dn, 0, ots->disassFlag);
2097: break;
2098: case ofDestAn:
2099: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[0] >> 9) & 7) | 0x08, size, EA_An, 0, ots->disassFlag);
2100: break;
2101: case ofDestAnip:
2102: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[0] >> 9) & 7) | 0x18, size, EA_Anip, 0, ots->disassFlag);
2103: break;
2104: case ofDestPiAn:
2105: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[0] >> 9) & 7) | 0x20, size, EA_piAn, 0, ots->disassFlag);
2106: break;
2107: case ofDestEa6:
2108: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[0] >> 9) & 7) | (((opcode[0] >> 6) & 0x7) << 3), size, EA_Dest-EA_An, 0, ots->disassFlag);
2109: break;
2110: case ofDestAbsL:
2111: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x39, size, EA_Abs, 0, ots->disassFlag);
2112: break;
2113:
2114: case ofIOpcode:
2115: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 1, EA_ImmedParameter, opcode[0] & ots->parameter[i], ots->disassFlag);
2116: break;
2117: case ofI3:
2118: val = ((opcode[0] >> 9) & 7);
2119: if(!val) val = 8;
2120: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 1, EA_ImmedParameter, val, ots->disassFlag);
2121: break;
2122: case ofExtIm:
2123: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 2, EA_ImmedParameter, opcode[1], ots->disassFlag);
2124: break;
2125: case ofExtIm32:
2126: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, size, EA_ImmedParameter, opcode[2], ots->disassFlag);
2127: break;
2128: case ofExtIm4:
2129: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 2, EA_ImmedParameter, opcode[1] & 0x0F, ots->disassFlag);
2130: break;
2131: case ofExtIm10:
2132: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 2, EA_ImmedParameter, (opcode[1] >> 10) & 0x07, ots->disassFlag);
2133: break;
2134: case ofSpecReg:
2135: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0101, size, EA_SpecialRegister, ots->parameter[i], ots->disassFlag);
2136: break;
2137: case ofSpecExtReg:
2138: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0101, size, EA_SpecialRegister, opcode[1] & 0xFFF, ots->disassFlag);
2139: break;
2140: case ofExtReg0:
2141: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[1] & 0x07), size, EA_Dn, 0, ots->disassFlag);
2142: break;
2143: case ofExtRegA0:
2144: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[1] & 0x07) | 0x08, size, EA_An, 0, ots->disassFlag);
2145: break;
2146: case ofExtRegD04:
2147: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 4) & 0x07) | 0x00, size, EA_Dn, 0, ots->disassFlag);
2148: break;
2149: case ofExtRegA05:
2150: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 5) & 0x07) | 0x08, size, EA_An, 0, ots->disassFlag);
2151: break;
2152: case ofExtReg:
2153: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 12) & 0x0F), size, EA_Dn|EA_An, 0, ots->disassFlag);
2154: break;
2155: case ofExtAnip:
2156: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 12) & 7) | 0x18, size, EA_Anip, 0, ots->disassFlag);
2157: break;
2158:
2159: case ofDisp:
2160: // branch treats the displacement 0x00 and 0xFF as an indicator how many words follow
2161: // This test will decline a displacement with the wrong word offset
2162: if((opcode[0] & 0xF000) == 0x6000)
2163: {
2164: val = opcode[0] & 0xFF;
2165: if(val == 0x00 && size != 2) goto more;
2166: if(val == 0xFF && size != 4) goto more;
2167: }
2168: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0102, size, EA_PCDisplacement, opcode[0] & 0xFF, ots->disassFlag);
2169: break;
2170:
2171: case ofRegList:
2172: val = opcode[1];
2173: if((ea & 0x38) == 0x20) // -(An) has a flipped bitmask
2174: val = Disass68kFlipBits(val);
2175: dbuf = Disass68kReglist(dbuf, val);
2176: break;
2177:
2178: case ofFPU:
2179: { // default FPU opcode modes
2180: int src = (opcode[1] >> 10) & 7;
2181: int dest = (opcode[1] >> 7) & 7;
2182: char regFP1 = options & doptRegisterSmall ? 'f' : 'F';
2183: char regFP2 = options & doptRegisterSmall ? 'p' : 'P';
2184: if(opcode[1] & 0x4000)
2185: {
2186: // <ea>,FPn
2187: int mask = EA_All - EA_An;
2188: if(src != 0 && src != 4 && src != 6) // only .B,.W and .L allow Dn as a source
2189: mask -= EA_Dn;
2190: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ea, size, mask, 0, 0);
2191: if(!dbuf) goto more;
2192: *dbuf++ = ',';
2193: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+dest;
2194: *dbuf = 0;
2195: } else {
2196: // FPn,FPn or FPn
2197:
2198: // <ea> has to be 0
2199: if((opcode[0] & 0x3F) != 0) goto more;
2200:
2201: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+src;
2202: if(src != dest)
2203: {
2204: *dbuf++ = ',';
2205: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+dest;
2206: }
2207: *dbuf = 0;
2208: }
2209: }
2210: break;
2211: case ofFPUMOVE:
2212: { // MOVE <ea>,FPn{k-Factor}
2213: int src = (opcode[1] >> 10) & 7;
2214: // <ea>,FPn
2215: int mask = EA_All - EA_An;
2216: char regFP1 = options & doptRegisterSmall ? 'f' : 'F';
2217: char regFP2 = options & doptRegisterSmall ? 'p' : 'P';
2218: if(src != 0 && src != 4 && src != 6) // only .B,.W and .L allow Dn as a source
2219: mask -= EA_Dn;
2220: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ea, size, mask, 0, 0);
2221: if(!dbuf) goto more;
2222: *dbuf++ = ',';
2223: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+((opcode[1] >> 7) & 7);
2224: if(src == 3)
2225: {
2226: int kFactor = opcode[1] & 0x7F;
2227: if(kFactor & 0x40)
2228: kFactor |= 0x80;
2229: *dbuf++ = '{';
2230: sprintf(dbuf, "%d", (signed char)kFactor);
2231: dbuf += strlen(dbuf);
2232: *dbuf++ = '}';
2233: } else if(src == 7)
2234: {
2235: if((opcode[1] & 0x0F) != 0) goto more;
2236: *dbuf++ = '{';
2237: *dbuf++ = options & doptRegisterSmall ? 'd' : 'D';
2238: *dbuf++ = '0' + ((opcode[1] >> 4) & 7);
2239: *dbuf++ = '}';
2240: } else {
2241: if((opcode[1] & 0x7F) != 0) goto more;
2242: }
2243: *dbuf = 0;
2244: }
2245: break;
2246: case ofFMOVECR:
2247: { // MOVECR #const,FPn
2248: char regFP1 = options & doptRegisterSmall ? 'f' : 'F';
2249: char regFP2 = options & doptRegisterSmall ? 'p' : 'P';
2250: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 1, EA_ImmedParameter, opcode[1] & 0x7F, ots->disassFlag);
2251: if(!dbuf) goto more;
1.1.1.4 root 2252: reg = (opcode[1] >> 7) & 7;
1.1 root 2253: *dbuf++ = ',';
2254: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+reg;
2255: *dbuf = 0;
2256: switch(opcode[1] & 0x7F) // document the well-known constants
2257: {
2258: case 0x00: strcat(commentBuffer, "PI"); break;
2259: case 0x0B: strcat(commentBuffer, "Log10(2)"); break;
2260: case 0x0C: strcat(commentBuffer, "e"); break;
2261: case 0x0D: strcat(commentBuffer, "Log2(e)"); break;
2262: case 0x0E: strcat(commentBuffer, "Log10(e)"); break;
2263: case 0x0F: strcat(commentBuffer, "0.0"); break;
2264: case 0x30: strcat(commentBuffer, "1n(2)"); break;
2265: case 0x31: strcat(commentBuffer, "1n(10)"); break;
2266: case 0x32: strcat(commentBuffer, "100"); break;
2267: case 0x33: strcat(commentBuffer, "10^1"); break;
2268: case 0x34: strcat(commentBuffer, "10^2"); break;
2269: case 0x35: strcat(commentBuffer, "10^4"); break;
2270: case 0x36: strcat(commentBuffer, "10^8"); break;
2271: case 0x37: strcat(commentBuffer, "10^16"); break;
2272: case 0x38: strcat(commentBuffer, "10^32"); break;
2273: case 0x39: strcat(commentBuffer, "10^64"); break;
2274: case 0x3A: strcat(commentBuffer, "10^128"); break;
2275: case 0x3B: strcat(commentBuffer, "10^256"); break;
2276: case 0x3C: strcat(commentBuffer, "10^512"); break;
2277: case 0x3D: strcat(commentBuffer, "10^1024"); break;
2278: case 0x3E: strcat(commentBuffer, "10^2048"); break;
2279: case 0x3F: strcat(commentBuffer, "10^4096"); break;
2280: }
2281: }
2282: break;
2283: case ofFPUSRRegList:
2284: {
2285: int hasReg = 0;
2286: *dbuf = 0;
2287: if(opcode[1] & 0x0400)
2288: {
2289: strcat(dbuf, Disass68kSpecialRegister(REG_FPU_FPIAR));
2290: hasReg = 1;
2291: }
2292: if(opcode[1] & 0x0800)
2293: {
2294: if(hasReg) strcat(dbuf, "/");
2295: strcat(dbuf, Disass68kSpecialRegister(REG_FPU_FPSR));
2296: hasReg = 1;
2297: }
2298: if(opcode[1] & 0x1000)
2299: {
2300: if(hasReg) strcat(dbuf, "/");
2301: strcat(dbuf, Disass68kSpecialRegister(REG_FPU_FPCR));
2302: hasReg = 1;
2303: }
2304: if(!hasReg)
2305: strcat(dbuf, "0");
2306: dbuf += strlen(dbuf);
2307: }
2308: break;
2309: case ofFPUReglist: // FMOVEM
2310: {
2311: int mask = opcode[1] & 0xFF;
2312: if(opcode[1] & 0x0100)
2313: mask = Disass68kFlipBits(mask) >> 8;
2314: dbuf = Disass68kFPUReglist(dbuf, mask);
2315: }
2316: break;
2317: case ofFPU3Reg:
2318: { // FSINCOS
2319: int src = (opcode[1] >> 10) & 7;
2320: int dest = (opcode[1] >> 7) & 7;
2321: char regFP1 = options & doptRegisterSmall ? 'f' : 'F';
2322: char regFP2 = options & doptRegisterSmall ? 'p' : 'P';
2323: if(opcode[1] & 0x4000)
2324: {
2325: // <ea>,FPn
2326: int mask = EA_All - EA_An;
2327: if(src != 0 && src != 4 && src != 6) // only .B,.W and .L allow Dn as a source
2328: mask -= EA_Dn;
2329: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ea, size, mask, 0, 0);
2330: if(!dbuf) goto more;
2331: *dbuf++ = ',';
2332: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+(opcode[1] & 7);
2333: *dbuf++ = ',';
2334: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+dest;
2335: *dbuf = 0;
2336: } else {
2337: // FPn,FPn or FPn
2338:
2339: // <ea> has to be 0
2340: if((opcode[0] & 0x3F) != 0) goto more;
2341:
2342: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+src;
2343: *dbuf++ = ',';
2344: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+(opcode[1] & 7);
2345: *dbuf++ = ',';
2346: *dbuf++ = regFP1; *dbuf++ = regFP2; *dbuf++ = '0'+dest;
2347: *dbuf = 0;
2348: }
2349: }
2350: break;
2351:
2352: case ofCAS:
2353: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[1] & 0x07), size, EA_Dn, 0, ots->disassFlag);
2354: if(!dbuf) goto more;
2355: *dbuf++ = ',';
2356: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 6) & 0x07), size, EA_Dn, 0, ots->disassFlag);
2357: break;
2358: case ofCAS2:
2359: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[1] & 0x07), size, EA_Dn, 0, ots->disassFlag);
2360: if(!dbuf) goto more;
2361: *dbuf++ = ':';
2362: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[2] & 0x07), size, EA_Dn, 0, ots->disassFlag);
2363: if(!dbuf) goto more;
2364: *dbuf++ = ',';
2365: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 6) & 0x07), size, EA_Dn, 0, ots->disassFlag);
2366: if(!dbuf) goto more;
2367: *dbuf++ = ':';
2368: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[2] >> 6) & 0x07), size, EA_Dn, 0, ots->disassFlag);
2369: if(!dbuf) goto more;
2370: *dbuf++ = ',';
2371: *dbuf++ = '(';
2372: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 12) & 0x0F), size, EA_Dn|EA_An, 0, ots->disassFlag);
2373: if(!dbuf) goto more;
2374: *dbuf++ = ')';
2375: *dbuf++ = ':';
2376: *dbuf++ = '(';
2377: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[2] >> 12) & 0x0F), size, EA_Dn|EA_An, 0, ots->disassFlag);
2378: if(!dbuf) goto more;
2379: *dbuf++ = ')';
2380: *dbuf = 0;
2381: break;
2382: case ofExt4Dn:
2383: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[0] & 0x07), size, EA_Dn, 0, ots->disassFlag);
2384: if(!dbuf) goto more;
2385: *dbuf++ = ':';
2386: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, (opcode[1] & 0x07), size, EA_Dn, 0, ots->disassFlag);
2387: if(!dbuf) goto more;
2388: *dbuf++ = ',';
2389: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ((opcode[1] >> 12) & 0x07), size, EA_Dn, 0, ots->disassFlag);
2390: if(!dbuf) goto more;
2391: *dbuf = 0;
2392: break;
2393: case ofBFEa:
2394: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, ea, size, EA_All & ~(ots->parameter[i]), 0, ots->disassFlag);
2395: if(!dbuf) goto more;
2396: *dbuf++ = '{';
2397: val = (opcode[1] >> 6) & 0x1F;
2398: if(opcode[1] & 0x0800)
2399: {
2400: if(val & 0x18) goto more;
2401: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, val & 0x07, 1, EA_Dn, val, ots->disassFlag);
2402: } else {
2403: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0103, 1, EA_ValueParameter, val, ots->disassFlag);
2404: }
2405: *dbuf++ = ':';
2406: val = opcode[1] & 0x1F;
2407: if(opcode[1] & 0x0020)
2408: {
2409: if(val & 0x18) goto more;
2410: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, val & 0x07, 1, EA_Dn, val, ots->disassFlag);
2411: } else {
2412: if(val == 0) val = 32;
2413: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0103, 1, EA_ValueParameter, val, ots->disassFlag);
2414: }
2415: *dbuf++ = '}';
2416: *dbuf = 0;
2417: break;
2418: case ofLineA:
2419: {
2420: int lineAVal = opcode[0] & 0xFFF;
2421: const char *lineAStr[16] = { "Line-A Initialization",
2422: "Put pixel",
2423: "Get pixel",
2424: "Arbitrary line",
2425: "Horizontal line",
2426: "Filled rectangle",
2427: "Filled polygon",
2428: "Bit block transfer",
2429: "Text block transfer",
2430: "Show mouse",
2431: "Hide mouse",
2432: "Transform mouse",
2433: "Undraw sprite",
2434: "Draw sprite",
2435: "Copy raster form",
2436: "Seedfill"
2437: };
1.1.1.4 root 2438: dbuf = Disass68kEA(dbuf, commentBuffer, &addr, opcodeAddr, 0x0100, 2, EA_ImmedParameter, lineAVal, ots->disassFlag);
1.1 root 2439: if(lineAVal < 16)
2440: strcat(commentBuffer, lineAStr[lineAVal]);
2441: }
2442: break;
2443:
2444: default:
2445: goto more;
2446: }
2447: if(!dbuf) goto more;
2448:
2449: // does another operand follow => add separator
1.1.1.5 root 2450: if ( (i+1<maxop) && ( ots->op[i+1] != ofNone) )
1.1 root 2451: *dbuf++ = ',';
2452: }
2453: return addr-baseAddr;
2454: }
2455:
2456: // unknown opcode
2457: strcpy(opcodeBuffer, "DC.W");
2458: sprintf(operandBuffer,"$%4.4x", Disass68kGetWord(addr));
2459: return 2;
2460: }
2461:
2462: static void Disass68kComposeStr(char *dbuf, const char *str, int position, int maxPos)
2463: {
2464: int i;
2465: int len = strlen(dbuf);
2466: while(len < position) {
2467: dbuf[len++] = ' '; /* Will give harmless warning from GCC */
2468: }
2469: for(i=0; str[i] && (!maxPos || len+i<maxPos); ++i)
2470: dbuf[len+i] = str[i];
2471: if(str[i])
2472: dbuf[len+i-1] = '+';
2473: dbuf[len+i] = 0;
2474: }
2475:
2476: static void Disass68k_loop (FILE *f, uaecptr addr, uaecptr *nextpc, int cnt)
2477: {
2478: static bool isInit = false;
2479: if(!isInit)
2480: {
2481: Disass68kInit(Paths_GetHatariHome());
2482: isInit = true;
2483: }
2484:
1.1.1.4 root 2485: while (cnt-- > 0) {
1.1.1.6 root 2486: const int addrWidth = 8; // 6 on an ST (24 bit addressing), 8 on a TT (32 bit addressing)
1.1 root 2487: char lineBuffer[1024];
2488:
2489: char addressBuffer[32];
2490: char hexdumpBuffer[256];
1.1.1.9 ! root 2491: char labelBuffer[258];
1.1 root 2492: char opcodeBuffer[64];
2493: char operandBuffer[256];
1.1.1.9 ! root 2494: char commentBuffer[258];
1.1.1.4 root 2495: int plen, len, j;
2496:
2497: len = Disass68k(addr, labelBuffer, opcodeBuffer, operandBuffer, commentBuffer);
1.1 root 2498: if(!len) break;
2499:
2500: sprintf(addressBuffer, "$%*.*x :", addrWidth,addrWidth, addr);
2501:
2502: hexdumpBuffer[0] = 0;
1.1.1.4 root 2503: plen = len;
1.1 root 2504: if(plen > 80 && (!strncmp(opcodeBuffer, "DC.", 3) || !strncmp(opcodeBuffer, "dc.", 3)))
2505: plen = ((optionPosLabel - optionPosHexdump) / 5) * 2;
1.1.1.4 root 2506:
1.1 root 2507: for(j=0; j<plen; j += 2)
2508: {
2509: if(j > 0)
2510: strcat(hexdumpBuffer, " ");
2511: if(j + 2 > plen)
2512: {
2513: sprintf(hexdumpBuffer+strlen(hexdumpBuffer), "%2.2x", Disass68kGetWord(addr+j) >> 8);
2514: } else {
2515: sprintf(hexdumpBuffer+strlen(hexdumpBuffer), "%4.4x", Disass68kGetWord(addr+j));
2516: }
2517: }
2518:
2519: lineBuffer[0] = 0;
2520: if(optionPosAddress >= 0)
2521: Disass68kComposeStr(lineBuffer, addressBuffer, optionPosAddress, 0);
2522: if(optionPosHexdump >= 0)
2523: Disass68kComposeStr(lineBuffer, hexdumpBuffer, optionPosHexdump, optionPosLabel);
2524: if(optionPosLabel >= 0)
2525: Disass68kComposeStr(lineBuffer, labelBuffer, optionPosLabel, 0);
2526: if(optionPosOpcode >= 0)
2527: Disass68kComposeStr(lineBuffer, opcodeBuffer, optionPosOpcode, 0);
2528: if(optionPosOperand >= 0)
2529: {
2530: size_t l = strlen(lineBuffer);
2531: if(lineBuffer[l-1] != ' ') // force at least one space between opcode and operand
2532: {
2533: lineBuffer[l++] = ' ';
2534: lineBuffer[l] = 0;
2535: }
2536: Disass68kComposeStr(lineBuffer, operandBuffer, optionPosOperand, 0);
2537: }
1.1.1.4 root 2538: if (optionPosComment >= 0)
1.1.1.3 root 2539: {
1.1.1.8 root 2540: if (Profile_CpuAddressDataStr(commentBuffer, sizeof(commentBuffer), addr))
1.1.1.3 root 2541: {
2542: Disass68kComposeStr(lineBuffer, commentBuffer, optionPosComment+1, 0);
2543: }
1.1.1.4 root 2544: /* show comments only if profile data is missing */
2545: else if (commentBuffer[0])
2546: {
2547: Disass68kComposeStr(lineBuffer, " ;", optionPosComment, 0);
2548: Disass68kComposeStr(lineBuffer, commentBuffer, optionPosComment+3, 0);
2549: }
1.1.1.3 root 2550: }
1.1.1.4 root 2551: addr += len;
2552: if (f)
2553: fprintf(f, "%s\n", lineBuffer);
1.1 root 2554: // if(strstr(opcodeBuffer, "RTS") || strstr(opcodeBuffer, "RTE") || strstr(opcodeBuffer, "JMP")
2555: // || strstr(opcodeBuffer, "rts") || strstr(opcodeBuffer, "rte") || strstr(opcodeBuffer, "jmp"))
2556: // fprintf(f, "\n");
2557: }
2558: if (nextpc)
2559: *nextpc = addr;
2560: }
2561:
2562:
1.1.1.4 root 2563: /**
2564: * Calculate next PC address from given one, without output
2565: * @return next PC address
1.1 root 2566: */
1.1.1.4 root 2567: Uint32 Disasm_GetNextPC(Uint32 pc)
2568: {
2569: uaecptr nextpc;
2570: Disass68k_loop (NULL, pc, &nextpc, 1);
2571: return nextpc;
2572: }
1.1 root 2573:
1.1.1.4 root 2574: /**
2575: * Call disassembly using the selected disassembly method,
2576: * either internal UAE one, or the stand alone disassembler above,
2577: * whichever is selected in Hatari configuration
2578: */
2579: void Disasm (FILE *f, uaecptr addr, uaecptr *nextpc, int cnt)
1.1 root 2580: {
1.1.1.4 root 2581: if (ConfigureParams.Debugger.bDisasmUAE)
1.1.1.6 root 2582: #ifdef WINUAE_FOR_HATARI
1.1.1.9 ! root 2583: m68k_disasm_file (f, addr, nextpc, addr, cnt);
1.1.1.6 root 2584: #else
1.1.1.5 root 2585: m68k_disasm (f, addr, nextpc, cnt);
1.1.1.6 root 2586: #endif
1.1.1.4 root 2587: else
1.1.1.5 root 2588: Disass68k_loop (f, addr, nextpc, cnt);
1.1 root 2589: }
2590:
1.1.1.4 root 2591: static void Disasm_CheckOptionEngine(void)
2592: {
2593: if (ConfigureParams.Debugger.bDisasmUAE)
2594: fputs("WARNING: disassembly options are supported only for '--disasm ext'!\n", stderr);
2595: }
2596:
2597: /**
2598: * query disassembly output column positions.
2599: */
2600: void Disasm_GetColumns(int *pos)
2601: {
2602: pos[DISASM_COLUMN_ADDRESS] = optionPosAddress;
2603: pos[DISASM_COLUMN_HEXDUMP] = optionPosHexdump;
2604: pos[DISASM_COLUMN_LABEL] = optionPosLabel;
2605: pos[DISASM_COLUMN_OPCODE] = optionPosOpcode;
2606: pos[DISASM_COLUMN_OPERAND] = optionPosOperand;
2607: pos[DISASM_COLUMN_COMMENT] = optionPosComment;
2608: }
2609:
2610: /**
2611: * set disassembly output column positions.
2612: */
2613: void Disasm_SetColumns(int *pos)
2614: {
2615: Disasm_CheckOptionEngine();
2616: optionPosAddress = pos[DISASM_COLUMN_ADDRESS];
2617: optionPosHexdump = pos[DISASM_COLUMN_HEXDUMP];
2618: optionPosLabel = pos[DISASM_COLUMN_LABEL];
2619: optionPosOpcode = pos[DISASM_COLUMN_OPCODE];
2620: optionPosOperand = pos[DISASM_COLUMN_OPERAND];
2621: optionPosComment = pos[DISASM_COLUMN_COMMENT];
2622: }
2623:
2624: /**
2625: * function to disable given disassembly output 'column'.
2626: * input is current column positions in 'oldcols' array and
2627: * output is new column positions/values in 'newcols' array.
2628: * It's safe to use same array for both.
2629: */
2630: void Disasm_DisableColumn(int column, int *oldcols, int *newcols)
2631: {
2632: int i, diff = 0;
2633:
2634: assert(column >= 0 && column < DISASM_COLUMNS);
2635: if (column+1 < DISASM_COLUMNS)
2636: diff = oldcols[column+1] - oldcols[column];
2637:
2638: for (i = 0; i < DISASM_COLUMNS; i++)
2639: {
2640: if (i && oldcols[i-1] > oldcols[i])
2641: {
2642: printf("WARNING: disassembly columns aren't in the expected order!\n");
2643: return;
2644: }
2645: if (i < column)
2646: newcols[i] = oldcols[i];
2647: else if (i > column)
2648: newcols[i] = oldcols[i] - diff;
2649: else
2650: newcols[column] = DISASM_COLUMN_DISABLE;
2651: }
2652: }
2653:
2654: /**
2655: * Get current disassembly output option flags
2656: * @return current output flags
2657: */
2658: int Disasm_GetOptions(void)
2659: {
2660: return options;
2661: }
2662:
2663: /**
1.1.1.6 root 2664: * Set CPU and FPU mask used for disassembly (when changed from the UI or the options)
2665: */
1.1.1.9 ! root 2666: void Disasm_SetCPUType(int CPU, int FPU, bool bMMU)
1.1.1.6 root 2667: {
1.1.1.9 ! root 2668: switch (CPU)
! 2669: {
! 2670: case 0: optionCPUTypeMask = MC68000; break;
! 2671: case 1: optionCPUTypeMask = MC68010; break;
! 2672: case 2: optionCPUTypeMask = MC68020; break;
! 2673: case 3: optionCPUTypeMask = MC68030; break;
! 2674: case 4: optionCPUTypeMask = MC68040; break;
! 2675: default: optionCPUTypeMask = MC68000; break;
! 2676: }
1.1.1.6 root 2677:
1.1.1.9 ! root 2678: if (FPU != 0)
1.1.1.6 root 2679: optionCPUTypeMask |= MC_FPU;
2680:
1.1.1.9 ! root 2681: if (bMMU)
! 2682: optionCPUTypeMask |= MC_PMMU;
1.1.1.6 root 2683: }
2684:
2685: /**
1.1.1.4 root 2686: * Parse disasm command line option argument
2687: * @return error string (""=silent 'error') or NULL for success.
2688: */
2689: const char *Disasm_ParseOption(const char *arg)
2690: {
2691: if (strcasecmp(arg, "help") == 0)
2692: {
2693: const struct {
2694: int flag;
2695: const char *desc;
2696: } option[] = {
2697: { doptNoBrackets, "no brackets around absolute addressing" },
2698: { doptOpcodesSmall, "opcodes in small letters" },
2699: { doptRegisterSmall, "register names in small letters" },
2700: { doptStackSP, "stack pointer as 'SP', not 'A7'" },
2701: { 0, NULL }
2702: };
2703: int i;
2704: fputs("Disassembly settings:\n"
2705: "\tuae - use CPU core internal disassembler which has better\n"
2706: "\t instruction support\n"
2707: "\text - use external disassembler which has nicer output\n"
2708: "\t and supports options below\n"
2709: "\t<bitmask> - disassembly output option flags\n"
2710: "Flag values:\n", stderr);
2711: for (i = 0; option[i].desc; i++) {
2712: assert(option[i].flag == (1 << i));
2713: fprintf(stderr, "\t%d: %s\n", option[i].flag, option[i].desc);
2714: }
1.1.1.9 ! root 2715: fprintf(stderr, "Current settings are:\n\t--disasm %s --disasm 0x%x\n",
1.1.1.4 root 2716: ConfigureParams.Debugger.bDisasmUAE ? "uae" : "ext",
2717: ConfigureParams.Debugger.nDisasmOptions);
2718: return "";
2719: }
2720: if (strcasecmp(arg, "uae") == 0)
2721: {
2722: fputs("Selected UAE CPU core internal disassembler.\n", stderr);
2723: ConfigureParams.Debugger.bDisasmUAE = true;
2724: return NULL;
2725: }
2726: if (strcasecmp(arg, "ext") == 0)
2727: {
2728: fputs("Selected external disassembler.\n", stderr);
2729: fprintf(stderr, "Disassembly output flags are %d.\n", options);
2730: ConfigureParams.Debugger.bDisasmUAE = false;
2731: return NULL;
2732: }
1.1.1.5 root 2733: if (isdigit((unsigned char)*arg))
1.1.1.4 root 2734: {
1.1.1.9 ! root 2735: char *end;
! 2736: int newopt = strtol(arg, &end, 0);
! 2737: if (*end)
! 2738: {
! 2739: return "not a number";
! 2740: }
1.1.1.4 root 2741: if ((newopt|optionsMask) != optionsMask)
2742: {
2743: return "unknown flags in the bitmask";
2744: }
2745: fprintf(stderr, "Changed CPU disassembly output flags from %d to %d.\n", options, newopt);
2746: ConfigureParams.Debugger.nDisasmOptions = options = newopt;
2747: Disasm_CheckOptionEngine();
2748: return NULL;
2749: }
2750: return "invalid disasm option";
2751: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.