1 /* ======================================================================== */
\r
2 /* ========================= LICENSING & COPYRIGHT ======================== */
\r
3 /* ======================================================================== */
\r
8 * A portable Motorola M680x0 processor emulation engine.
\r
9 * Copyright 1998-2007 Karl Stenerud. All rights reserved.
\r
11 * This code may be freely used for non-commercial purposes as long as this
\r
12 * copyright notice remains unaltered in the source code and any binary files
\r
13 * containing this code in compiled form.
\r
15 * All other lisencing terms must be negotiated with the author
\r
18 * The latest version of this code can be obtained at:
\r
19 * http://kstenerud.cjb.net
\r
24 /* ======================================================================== */
\r
25 /* ================================ INCLUDES ============================== */
\r
26 /* ======================================================================== */
\r
37 /* ======================================================================== */
\r
38 /* ============================ GENERAL DEFINES =========================== */
\r
39 /* ======================================================================== */
\r
41 /* unsigned int and int must be at least 32 bits wide */
\r
43 #define uint unsigned int
\r
45 /* Bit Isolation Functions */
\r
46 #define BIT_0(A) ((A) & 0x00000001)
\r
47 #define BIT_1(A) ((A) & 0x00000002)
\r
48 #define BIT_2(A) ((A) & 0x00000004)
\r
49 #define BIT_3(A) ((A) & 0x00000008)
\r
50 #define BIT_4(A) ((A) & 0x00000010)
\r
51 #define BIT_5(A) ((A) & 0x00000020)
\r
52 #define BIT_6(A) ((A) & 0x00000040)
\r
53 #define BIT_7(A) ((A) & 0x00000080)
\r
54 #define BIT_8(A) ((A) & 0x00000100)
\r
55 #define BIT_9(A) ((A) & 0x00000200)
\r
56 #define BIT_A(A) ((A) & 0x00000400)
\r
57 #define BIT_B(A) ((A) & 0x00000800)
\r
58 #define BIT_C(A) ((A) & 0x00001000)
\r
59 #define BIT_D(A) ((A) & 0x00002000)
\r
60 #define BIT_E(A) ((A) & 0x00004000)
\r
61 #define BIT_F(A) ((A) & 0x00008000)
\r
62 #define BIT_10(A) ((A) & 0x00010000)
\r
63 #define BIT_11(A) ((A) & 0x00020000)
\r
64 #define BIT_12(A) ((A) & 0x00040000)
\r
65 #define BIT_13(A) ((A) & 0x00080000)
\r
66 #define BIT_14(A) ((A) & 0x00100000)
\r
67 #define BIT_15(A) ((A) & 0x00200000)
\r
68 #define BIT_16(A) ((A) & 0x00400000)
\r
69 #define BIT_17(A) ((A) & 0x00800000)
\r
70 #define BIT_18(A) ((A) & 0x01000000)
\r
71 #define BIT_19(A) ((A) & 0x02000000)
\r
72 #define BIT_1A(A) ((A) & 0x04000000)
\r
73 #define BIT_1B(A) ((A) & 0x08000000)
\r
74 #define BIT_1C(A) ((A) & 0x10000000)
\r
75 #define BIT_1D(A) ((A) & 0x20000000)
\r
76 #define BIT_1E(A) ((A) & 0x40000000)
\r
77 #define BIT_1F(A) ((A) & 0x80000000)
\r
79 /* These are the CPU types understood by this disassembler */
\r
80 #define TYPE_68000 1
\r
81 #define TYPE_68008 2
\r
82 #define TYPE_68010 4
\r
83 #define TYPE_68020 8
\r
84 #define TYPE_68030 16
\r
85 #define TYPE_68040 32
\r
87 #define M68000_ONLY (TYPE_68000 | TYPE_68008)
\r
89 #define M68010_ONLY TYPE_68010
\r
90 #define M68010_LESS (TYPE_68000 | TYPE_68008 | TYPE_68010)
\r
91 #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040)
\r
93 #define M68020_ONLY TYPE_68020
\r
94 #define M68020_LESS (TYPE_68010 | TYPE_68020)
\r
95 #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040)
\r
97 #define M68030_ONLY TYPE_68030
\r
98 #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030)
\r
99 #define M68030_PLUS (TYPE_68030 | TYPE_68040)
\r
101 #define M68040_PLUS TYPE_68040
\r
104 /* Extension word formats */
\r
105 #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff)
\r
106 #define EXT_FULL(A) BIT_8(A)
\r
107 #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0)
\r
108 #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A))
\r
109 #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A))
\r
110 #define EXT_INDEX_REGISTER(A) (((A)>>12)&7)
\r
111 #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3)
\r
112 #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0)
\r
113 #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4)
\r
114 #define EXT_INDEX_SCALE(A) (((A)>>9)&3)
\r
115 #define EXT_INDEX_LONG(A) BIT_B(A)
\r
116 #define EXT_INDEX_AR(A) BIT_F(A)
\r
117 #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10)
\r
118 #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20)
\r
119 #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30)
\r
120 #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44)
\r
121 #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44)
\r
122 #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44)
\r
126 #if M68K_COMPILE_FOR_MAME == OPT_ON
\r
127 #define SET_OPCODE_FLAGS(x) g_opcode_type = x;
\r
128 #define COMBINE_OPCODE_FLAGS(x) ((x) | g_opcode_type | DASMFLAG_SUPPORTED)
\r
130 #define SET_OPCODE_FLAGS(x)
\r
131 #define COMBINE_OPCODE_FLAGS(x) (x)
\r
135 /* ======================================================================== */
\r
136 /* =============================== PROTOTYPES ============================= */
\r
137 /* ======================================================================== */
\r
139 /* Read data at the PC and increment PC */
\r
140 uint read_imm_8(void);
\r
141 uint read_imm_16(void);
\r
142 uint read_imm_32(void);
\r
144 /* Read data at the PC but don't imcrement the PC */
\r
145 uint peek_imm_8(void);
\r
146 uint peek_imm_16(void);
\r
147 uint peek_imm_32(void);
\r
149 /* make signed integers 100% portably */
\r
150 static int make_int_8(int value);
\r
151 static int make_int_16(int value);
\r
153 /* make a string of a hex value */
\r
154 static char* make_signed_hex_str_8(uint val);
\r
155 static char* make_signed_hex_str_16(uint val);
\r
156 static char* make_signed_hex_str_32(uint val);
\r
158 /* make string of ea mode */
\r
159 static char* get_ea_mode_str(uint instruction, uint size);
\r
161 char* get_ea_mode_str_8(uint instruction);
\r
162 char* get_ea_mode_str_16(uint instruction);
\r
163 char* get_ea_mode_str_32(uint instruction);
\r
165 /* make string of immediate value */
\r
166 static char* get_imm_str_s(uint size);
\r
167 static char* get_imm_str_u(uint size);
\r
169 char* get_imm_str_s8(void);
\r
170 char* get_imm_str_s16(void);
\r
171 char* get_imm_str_s32(void);
\r
173 /* Stuff to build the opcode handler jump table */
\r
174 static void build_opcode_table(void);
\r
175 static int valid_ea(uint opcode, uint mask);
\r
176 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr);
\r
178 /* used to build opcode handler jump table */
\r
181 void (*opcode_handler)(void); /* handler function */
\r
182 uint mask; /* mask on opcode */
\r
183 uint match; /* what to match after masking */
\r
184 uint ea_mask; /* what ea modes are allowed */
\r
189 /* ======================================================================== */
\r
190 /* ================================= DATA ================================= */
\r
191 /* ======================================================================== */
\r
193 /* Opcode handler jump table */
\r
194 static void (*g_instruction_table[0x10000])(void);
\r
195 /* Flag if disassembler initialized */
\r
196 static int g_initialized = 0;
\r
198 /* Address mask to simulate address lines */
\r
199 static unsigned int g_address_mask = 0xffffffff;
\r
201 static char g_dasm_str[100]; /* string to hold disassembly */
\r
202 static char g_helper_str[100]; /* string to hold helpful info */
\r
203 static uint g_cpu_pc; /* program counter */
\r
204 static uint g_cpu_ir; /* instruction register */
\r
205 static uint g_cpu_type;
\r
206 static uint g_opcode_type;
\r
207 static const unsigned char* g_rawop;
\r
208 static uint g_rawbasepc;
\r
210 /* used by ops like asr, ror, addq, etc */
\r
211 static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
\r
213 static uint g_5bit_data_table[32] =
\r
215 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
\r
216 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
\r
219 static const char* g_cc[16] =
\r
220 {"t", "f", "hi", "ls", "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi", "ge", "lt", "gt", "le"};
\r
222 static const char* g_cpcc[64] =
\r
223 {/* 000 001 010 011 100 101 110 111 */
\r
224 "f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */
\r
225 "un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */
\r
226 "sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */
\r
227 "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */
\r
228 "?", "?", "?", "?", "?", "?", "?", "?", /* 100 */
\r
229 "?", "?", "?", "?", "?", "?", "?", "?", /* 101 */
\r
230 "?", "?", "?", "?", "?", "?", "?", "?", /* 110 */
\r
231 "?", "?", "?", "?", "?", "?", "?", "?" /* 111 */
\r
235 /* ======================================================================== */
\r
236 /* =========================== UTILITY FUNCTIONS ========================== */
\r
237 /* ======================================================================== */
\r
239 #define LIMIT_CPU_TYPES(ALLOWED_CPU_TYPES) \
\r
240 if(!(g_cpu_type & ALLOWED_CPU_TYPES)) \
\r
242 if((g_cpu_ir & 0xf000) == 0xf000) \
\r
244 else d68000_illegal(); \
\r
248 static uint dasm_read_imm_8(uint advance)
\r
252 result = g_rawop[g_cpu_pc + 1 - g_rawbasepc];
\r
254 result = m68k_read_disassembler_16(g_cpu_pc & g_address_mask) & 0xffff; // 0xff ???
\r
255 g_cpu_pc += advance;
\r
259 static uint dasm_read_imm_16(uint advance)
\r
263 result = (g_rawop[g_cpu_pc + 0 - g_rawbasepc] << 8) |
\r
264 g_rawop[g_cpu_pc + 1 - g_rawbasepc];
\r
266 result = m68k_read_disassembler_16(g_cpu_pc & g_address_mask) & 0xffff; // 0xff ???
\r
267 g_cpu_pc += advance;
\r
271 static uint dasm_read_imm_32(uint advance)
\r
275 result = (g_rawop[g_cpu_pc + 0 - g_rawbasepc] << 24) |
\r
276 (g_rawop[g_cpu_pc + 1 - g_rawbasepc] << 16) |
\r
277 (g_rawop[g_cpu_pc + 2 - g_rawbasepc] << 8) |
\r
278 g_rawop[g_cpu_pc + 3 - g_rawbasepc];
\r
280 result = m68k_read_disassembler_32(g_cpu_pc & g_address_mask) & 0xffff; // 0xff ???
\r
281 g_cpu_pc += advance;
\r
285 #define read_imm_8() dasm_read_imm_8(2)
\r
286 #define read_imm_16() dasm_read_imm_16(2)
\r
287 #define read_imm_32() dasm_read_imm_32(4)
\r
289 #define peek_imm_8() dasm_read_imm_8(0)
\r
290 #define peek_imm_16() dasm_read_imm_16(0)
\r
291 #define peek_imm_32() dasm_read_imm_32(0)
\r
293 /* Fake a split interface */
\r
294 #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0)
\r
295 #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1)
\r
296 #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2)
\r
298 #define get_imm_str_s8() get_imm_str_s(0)
\r
299 #define get_imm_str_s16() get_imm_str_s(1)
\r
300 #define get_imm_str_s32() get_imm_str_s(2)
\r
302 #define get_imm_str_u8() get_imm_str_u(0)
\r
303 #define get_imm_str_u16() get_imm_str_u(1)
\r
304 #define get_imm_str_u32() get_imm_str_u(2)
\r
307 /* 100% portable signed int generators */
\r
308 static int make_int_8(int value)
\r
310 return (value & 0x80) ? value | ~0xff : value & 0xff;
\r
313 static int make_int_16(int value)
\r
315 return (value & 0x8000) ? value | ~0xffff : value & 0xffff;
\r
319 /* Get string representation of hex values */
\r
320 static char* make_signed_hex_str_8(uint val)
\r
322 static char str[20];
\r
327 sprintf(str, "-$80");
\r
328 else if(val & 0x80)
\r
329 sprintf(str, "-$%x", (0-val) & 0x7f);
\r
331 sprintf(str, "$%x", val & 0x7f);
\r
336 static char* make_signed_hex_str_16(uint val)
\r
338 static char str[20];
\r
343 sprintf(str, "-$8000");
\r
344 else if(val & 0x8000)
\r
345 sprintf(str, "-$%x", (0-val) & 0x7fff);
\r
347 sprintf(str, "$%x", val & 0x7fff);
\r
352 static char* make_signed_hex_str_32(uint val)
\r
354 static char str[20];
\r
358 if(val == 0x80000000)
\r
359 sprintf(str, "-$80000000");
\r
360 else if(val & 0x80000000)
\r
361 sprintf(str, "-$%x", (0-val) & 0x7fffffff);
\r
363 sprintf(str, "$%x", val & 0x7fffffff);
\r
369 /* make string of immediate value */
\r
370 static char* get_imm_str_s(uint size)
\r
372 static char str[15];
\r
374 sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8()));
\r
376 sprintf(str, "#%s", make_signed_hex_str_16(read_imm_16()));
\r
378 sprintf(str, "#%s", make_signed_hex_str_32(read_imm_32()));
\r
382 static char* get_imm_str_u(uint size)
\r
384 static char str[15];
\r
386 sprintf(str, "#$%x", read_imm_8() & 0xff);
\r
388 sprintf(str, "#$%x", read_imm_16() & 0xffff);
\r
390 sprintf(str, "#$%x", read_imm_32() & 0xffffffff);
\r
394 /* Make string of effective address mode */
\r
395 static char* get_ea_mode_str(uint instruction, uint size)
\r
397 static char b1[64];
\r
398 static char b2[64];
\r
399 static char* mode = b2;
\r
409 char invalid_mode = 0;
\r
411 /* Switch buffers so we don't clobber on a double-call to this function */
\r
412 mode = mode == b1 ? b2 : b1;
\r
414 switch(instruction & 0x3f)
\r
416 case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
\r
417 /* data register direct */
\r
418 sprintf(mode, "D%d", instruction&7);
\r
420 case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
\r
421 /* address register direct */
\r
422 sprintf(mode, "A%d", instruction&7);
\r
424 case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
\r
425 /* address register indirect */
\r
426 sprintf(mode, "(A%d)", instruction&7);
\r
428 case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
\r
429 /* address register indirect with postincrement */
\r
430 sprintf(mode, "(A%d)+", instruction&7);
\r
432 case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
\r
433 /* address register indirect with predecrement */
\r
434 sprintf(mode, "-(A%d)", instruction&7);
\r
436 case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
\r
437 /* address register indirect with displacement*/
\r
438 sprintf(mode, "(%s,A%d)", make_signed_hex_str_16(read_imm_16()), instruction&7);
\r
440 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
\r
441 /* address register indirect with index */
\r
442 extension = read_imm_16();
\r
444 if((g_cpu_type & M68010_LESS) && EXT_INDEX_SCALE(extension))
\r
450 if(EXT_FULL(extension))
\r
452 if(g_cpu_type & M68010_LESS)
\r
458 if(EXT_EFFECTIVE_ZERO(extension))
\r
464 base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
\r
465 outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
\r
466 if(EXT_BASE_REGISTER_PRESENT(extension))
\r
467 sprintf(base_reg, "A%d", instruction&7);
\r
470 if(EXT_INDEX_REGISTER_PRESENT(extension))
\r
472 sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
\r
473 if(EXT_INDEX_SCALE(extension))
\r
474 sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
\r
478 preindex = (extension&7) > 0 && (extension&7) < 4;
\r
479 postindex = (extension&7) > 4;
\r
482 if(preindex || postindex)
\r
486 strcat(mode, make_signed_hex_str_16(base));
\r
493 strcat(mode, base_reg);
\r
505 strcat(mode, index_reg);
\r
517 strcat(mode, make_signed_hex_str_16(outer));
\r
523 if(EXT_8BIT_DISPLACEMENT(extension) == 0)
\r
524 sprintf(mode, "(A%d,%c%d.%c", instruction&7, EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
\r
526 sprintf(mode, "(%s,A%d,%c%d.%c", make_signed_hex_str_8(extension), instruction&7, EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
\r
527 if(EXT_INDEX_SCALE(extension))
\r
528 sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
\r
532 /* absolute short address */
\r
533 sprintf(mode, "$%x.w", read_imm_16());
\r
536 /* absolute long address */
\r
537 sprintf(mode, "$%x.l", read_imm_32());
\r
540 /* program counter with displacement */
\r
541 temp_value = read_imm_16();
\r
542 sprintf(mode, "(%s,PC)", make_signed_hex_str_16(temp_value));
\r
543 sprintf(g_helper_str, "; ($%x)", (make_int_16(temp_value) + g_cpu_pc-2) & 0xffffffff);
\r
546 /* program counter with index */
\r
547 extension = read_imm_16();
\r
549 if((g_cpu_type & M68010_LESS) && EXT_INDEX_SCALE(extension))
\r
555 if(EXT_FULL(extension))
\r
557 if(g_cpu_type & M68010_LESS)
\r
563 if(EXT_EFFECTIVE_ZERO(extension))
\r
568 base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
\r
569 outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
\r
570 if(EXT_BASE_REGISTER_PRESENT(extension))
\r
571 strcpy(base_reg, "PC");
\r
574 if(EXT_INDEX_REGISTER_PRESENT(extension))
\r
576 sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
\r
577 if(EXT_INDEX_SCALE(extension))
\r
578 sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
\r
582 preindex = (extension&7) > 0 && (extension&7) < 4;
\r
583 postindex = (extension&7) > 4;
\r
586 if(preindex || postindex)
\r
590 strcat(mode, make_signed_hex_str_16(base));
\r
597 strcat(mode, base_reg);
\r
609 strcat(mode, index_reg);
\r
621 strcat(mode, make_signed_hex_str_16(outer));
\r
627 if(EXT_8BIT_DISPLACEMENT(extension) == 0)
\r
628 sprintf(mode, "(PC,%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
\r
630 sprintf(mode, "(%s,PC,%c%d.%c", make_signed_hex_str_8(extension), EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
\r
631 if(EXT_INDEX_SCALE(extension))
\r
632 sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
\r
637 sprintf(mode, "%s", get_imm_str_u(size));
\r
644 sprintf(mode, "INVALID %x", instruction & 0x3f);
\r
651 /* ======================================================================== */
\r
652 /* ========================= INSTRUCTION HANDLERS ========================= */
\r
653 /* ======================================================================== */
\r
654 /* Instruction handler function names follow this convention:
\r
656 * d68000_NAME_EXTENSIONS(void)
\r
657 * where NAME is the name of the opcode it handles and EXTENSIONS are any
\r
658 * extensions for special instances of that opcode.
\r
661 * d68000_add_er_8(): add opcode, from effective address to register,
\r
664 * d68000_asr_s_8(): arithmetic shift right, static count, size = byte
\r
667 * Common extensions:
\r
671 * rr : register to register
\r
672 * mm : memory to memory
\r
675 * er : effective address -> register
\r
676 * re : register -> effective address
\r
677 * ea : using effective address mode of operation
\r
678 * d : data register direct
\r
679 * a : address register direct
\r
680 * ai : address register indirect
\r
681 * pi : address register indirect with postincrement
\r
682 * pd : address register indirect with predecrement
\r
683 * di : address register indirect with displacement
\r
684 * ix : address register indirect with index
\r
685 * aw : absolute word
\r
686 * al : absolute long
\r
689 static void d68000_illegal(void)
\r
691 sprintf(g_dasm_str, "dc.w $%04x; ILLEGAL", g_cpu_ir);
\r
694 static void d68000_1010(void)
\r
696 sprintf(g_dasm_str, "dc.w $%04x; opcode 1010", g_cpu_ir);
\r
700 static void d68000_1111(void)
\r
702 sprintf(g_dasm_str, "dc.w $%04x; opcode 1111", g_cpu_ir);
\r
706 static void d68000_abcd_rr(void)
\r
708 sprintf(g_dasm_str, "abcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
712 static void d68000_abcd_mm(void)
\r
714 sprintf(g_dasm_str, "abcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
717 static void d68000_add_er_8(void)
\r
719 sprintf(g_dasm_str, "add.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
723 static void d68000_add_er_16(void)
\r
725 sprintf(g_dasm_str, "add.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
728 static void d68000_add_er_32(void)
\r
730 sprintf(g_dasm_str, "add.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
733 static void d68000_add_re_8(void)
\r
735 sprintf(g_dasm_str, "add.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
738 static void d68000_add_re_16(void)
\r
740 sprintf(g_dasm_str, "add.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
\r
743 static void d68000_add_re_32(void)
\r
745 sprintf(g_dasm_str, "add.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
\r
748 static void d68000_adda_16(void)
\r
750 sprintf(g_dasm_str, "adda.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
753 static void d68000_adda_32(void)
\r
755 sprintf(g_dasm_str, "adda.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
758 static void d68000_addi_8(void)
\r
760 char* str = get_imm_str_s8();
\r
761 sprintf(g_dasm_str, "addi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
764 static void d68000_addi_16(void)
\r
766 char* str = get_imm_str_s16();
\r
767 sprintf(g_dasm_str, "addi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
\r
770 static void d68000_addi_32(void)
\r
772 char* str = get_imm_str_s32();
\r
773 sprintf(g_dasm_str, "addi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
\r
776 static void d68000_addq_8(void)
\r
778 sprintf(g_dasm_str, "addq.b #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_8(g_cpu_ir));
\r
781 static void d68000_addq_16(void)
\r
783 sprintf(g_dasm_str, "addq.w #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_16(g_cpu_ir));
\r
786 static void d68000_addq_32(void)
\r
788 sprintf(g_dasm_str, "addq.l #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_32(g_cpu_ir));
\r
791 static void d68000_addx_rr_8(void)
\r
793 sprintf(g_dasm_str, "addx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
796 static void d68000_addx_rr_16(void)
\r
798 sprintf(g_dasm_str, "addx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
801 static void d68000_addx_rr_32(void)
\r
803 sprintf(g_dasm_str, "addx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
806 static void d68000_addx_mm_8(void)
\r
808 sprintf(g_dasm_str, "addx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
811 static void d68000_addx_mm_16(void)
\r
813 sprintf(g_dasm_str, "addx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
816 static void d68000_addx_mm_32(void)
\r
818 sprintf(g_dasm_str, "addx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
821 static void d68000_and_er_8(void)
\r
823 sprintf(g_dasm_str, "and.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
826 static void d68000_and_er_16(void)
\r
828 sprintf(g_dasm_str, "and.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
831 static void d68000_and_er_32(void)
\r
833 sprintf(g_dasm_str, "and.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
836 static void d68000_and_re_8(void)
\r
838 sprintf(g_dasm_str, "and.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
841 static void d68000_and_re_16(void)
\r
843 sprintf(g_dasm_str, "and.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
\r
846 static void d68000_and_re_32(void)
\r
848 sprintf(g_dasm_str, "and.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
\r
851 static void d68000_andi_8(void)
\r
853 char* str = get_imm_str_u8();
\r
854 sprintf(g_dasm_str, "andi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
857 static void d68000_andi_16(void)
\r
859 char* str = get_imm_str_u16();
\r
860 sprintf(g_dasm_str, "andi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
\r
863 static void d68000_andi_32(void)
\r
865 char* str = get_imm_str_u32();
\r
866 sprintf(g_dasm_str, "andi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
\r
869 static void d68000_andi_to_ccr(void)
\r
871 sprintf(g_dasm_str, "andi %s, CCR", get_imm_str_u8());
\r
874 static void d68000_andi_to_sr(void)
\r
876 sprintf(g_dasm_str, "andi %s, SR", get_imm_str_u16());
\r
879 static void d68000_asr_s_8(void)
\r
881 sprintf(g_dasm_str, "asr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
884 static void d68000_asr_s_16(void)
\r
886 sprintf(g_dasm_str, "asr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
889 static void d68000_asr_s_32(void)
\r
891 sprintf(g_dasm_str, "asr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
894 static void d68000_asr_r_8(void)
\r
896 sprintf(g_dasm_str, "asr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
899 static void d68000_asr_r_16(void)
\r
901 sprintf(g_dasm_str, "asr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
904 static void d68000_asr_r_32(void)
\r
906 sprintf(g_dasm_str, "asr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
909 static void d68000_asr_ea(void)
\r
911 sprintf(g_dasm_str, "asr.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
914 static void d68000_asl_s_8(void)
\r
916 sprintf(g_dasm_str, "asl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
919 static void d68000_asl_s_16(void)
\r
921 sprintf(g_dasm_str, "asl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
924 static void d68000_asl_s_32(void)
\r
926 sprintf(g_dasm_str, "asl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
929 static void d68000_asl_r_8(void)
\r
931 sprintf(g_dasm_str, "asl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
934 static void d68000_asl_r_16(void)
\r
936 sprintf(g_dasm_str, "asl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
939 static void d68000_asl_r_32(void)
\r
941 sprintf(g_dasm_str, "asl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
944 static void d68000_asl_ea(void)
\r
946 sprintf(g_dasm_str, "asl.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
949 static void d68000_bcc_8(void)
\r
951 uint temp_pc = g_cpu_pc;
\r
952 sprintf(g_dasm_str, "b%-2s $%x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_8(g_cpu_ir));
\r
955 static void d68000_bcc_16(void)
\r
957 uint temp_pc = g_cpu_pc;
\r
958 sprintf(g_dasm_str, "b%-2s $%x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_16(read_imm_16()));
\r
961 static void d68020_bcc_32(void)
\r
963 uint temp_pc = g_cpu_pc;
\r
964 LIMIT_CPU_TYPES(M68020_PLUS);
\r
965 sprintf(g_dasm_str, "b%-2s $%x; (2+)", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + read_imm_32());
\r
968 static void d68000_bchg_r(void)
\r
970 sprintf(g_dasm_str, "bchg D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
973 static void d68000_bchg_s(void)
\r
975 char* str = get_imm_str_u8();
\r
976 sprintf(g_dasm_str, "bchg %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
979 static void d68000_bclr_r(void)
\r
981 sprintf(g_dasm_str, "bclr D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
984 static void d68000_bclr_s(void)
\r
986 char* str = get_imm_str_u8();
\r
987 sprintf(g_dasm_str, "bclr %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
990 static void d68010_bkpt(void)
\r
992 LIMIT_CPU_TYPES(M68010_PLUS);
\r
993 sprintf(g_dasm_str, "bkpt #%d; (1+)", g_cpu_ir&7);
\r
996 static void d68020_bfchg(void)
\r
1002 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1004 extension = read_imm_16();
\r
1006 if(BIT_B(extension))
\r
1007 sprintf(offset, "D%d", (extension>>6)&7);
\r
1009 sprintf(offset, "%d", (extension>>6)&31);
\r
1010 if(BIT_5(extension))
\r
1011 sprintf(width, "D%d", extension&7);
\r
1013 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1014 sprintf(g_dasm_str, "bfchg %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1017 static void d68020_bfclr(void)
\r
1023 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1025 extension = read_imm_16();
\r
1027 if(BIT_B(extension))
\r
1028 sprintf(offset, "D%d", (extension>>6)&7);
\r
1030 sprintf(offset, "%d", (extension>>6)&31);
\r
1031 if(BIT_5(extension))
\r
1032 sprintf(width, "D%d", extension&7);
\r
1034 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1035 sprintf(g_dasm_str, "bfclr %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1038 static void d68020_bfexts(void)
\r
1044 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1046 extension = read_imm_16();
\r
1048 if(BIT_B(extension))
\r
1049 sprintf(offset, "D%d", (extension>>6)&7);
\r
1051 sprintf(offset, "%d", (extension>>6)&31);
\r
1052 if(BIT_5(extension))
\r
1053 sprintf(width, "D%d", extension&7);
\r
1055 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1056 sprintf(g_dasm_str, "bfexts D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1059 static void d68020_bfextu(void)
\r
1065 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1067 extension = read_imm_16();
\r
1069 if(BIT_B(extension))
\r
1070 sprintf(offset, "D%d", (extension>>6)&7);
\r
1072 sprintf(offset, "%d", (extension>>6)&31);
\r
1073 if(BIT_5(extension))
\r
1074 sprintf(width, "D%d", extension&7);
\r
1076 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1077 sprintf(g_dasm_str, "bfextu D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1080 static void d68020_bfffo(void)
\r
1086 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1088 extension = read_imm_16();
\r
1090 if(BIT_B(extension))
\r
1091 sprintf(offset, "D%d", (extension>>6)&7);
\r
1093 sprintf(offset, "%d", (extension>>6)&31);
\r
1094 if(BIT_5(extension))
\r
1095 sprintf(width, "D%d", extension&7);
\r
1097 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1098 sprintf(g_dasm_str, "bfffo D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1101 static void d68020_bfins(void)
\r
1107 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1109 extension = read_imm_16();
\r
1111 if(BIT_B(extension))
\r
1112 sprintf(offset, "D%d", (extension>>6)&7);
\r
1114 sprintf(offset, "%d", (extension>>6)&31);
\r
1115 if(BIT_5(extension))
\r
1116 sprintf(width, "D%d", extension&7);
\r
1118 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1119 sprintf(g_dasm_str, "bfins D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1122 static void d68020_bfset(void)
\r
1128 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1130 extension = read_imm_16();
\r
1132 if(BIT_B(extension))
\r
1133 sprintf(offset, "D%d", (extension>>6)&7);
\r
1135 sprintf(offset, "%d", (extension>>6)&31);
\r
1136 if(BIT_5(extension))
\r
1137 sprintf(width, "D%d", extension&7);
\r
1139 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1140 sprintf(g_dasm_str, "bfset %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1143 static void d68020_bftst(void)
\r
1149 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1151 extension = read_imm_16();
\r
1153 if(BIT_B(extension))
\r
1154 sprintf(offset, "D%d", (extension>>6)&7);
\r
1156 sprintf(offset, "%d", (extension>>6)&31);
\r
1157 if(BIT_5(extension))
\r
1158 sprintf(width, "D%d", extension&7);
\r
1160 sprintf(width, "%d", g_5bit_data_table[extension&31]);
\r
1161 sprintf(g_dasm_str, "bftst %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
\r
1164 static void d68000_bra_8(void)
\r
1166 uint temp_pc = g_cpu_pc;
\r
1167 sprintf(g_dasm_str, "bra $%x", temp_pc + make_int_8(g_cpu_ir));
\r
1170 static void d68000_bra_16(void)
\r
1172 uint temp_pc = g_cpu_pc;
\r
1173 sprintf(g_dasm_str, "bra $%x", temp_pc + make_int_16(read_imm_16()));
\r
1176 static void d68020_bra_32(void)
\r
1178 uint temp_pc = g_cpu_pc;
\r
1179 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1180 sprintf(g_dasm_str, "bra $%x; (2+)", temp_pc + read_imm_32());
\r
1183 static void d68000_bset_r(void)
\r
1185 sprintf(g_dasm_str, "bset D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
1188 static void d68000_bset_s(void)
\r
1190 char* str = get_imm_str_u8();
\r
1191 sprintf(g_dasm_str, "bset %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
1194 static void d68000_bsr_8(void)
\r
1196 uint temp_pc = g_cpu_pc;
\r
1197 sprintf(g_dasm_str, "bsr $%x", temp_pc + make_int_8(g_cpu_ir));
\r
1198 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1201 static void d68000_bsr_16(void)
\r
1203 uint temp_pc = g_cpu_pc;
\r
1204 sprintf(g_dasm_str, "bsr $%x", temp_pc + make_int_16(read_imm_16()));
\r
1205 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1208 static void d68020_bsr_32(void)
\r
1210 uint temp_pc = g_cpu_pc;
\r
1211 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1212 sprintf(g_dasm_str, "bsr $%x; (2+)", temp_pc + read_imm_32());
\r
1213 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1216 static void d68000_btst_r(void)
\r
1218 sprintf(g_dasm_str, "btst D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
1221 static void d68000_btst_s(void)
\r
1223 char* str = get_imm_str_u8();
\r
1224 sprintf(g_dasm_str, "btst %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
1227 static void d68020_callm(void)
\r
1230 LIMIT_CPU_TYPES(M68020_ONLY);
\r
1231 str = get_imm_str_u8();
\r
1233 sprintf(g_dasm_str, "callm %s, %s; (2)", str, get_ea_mode_str_8(g_cpu_ir));
\r
1236 static void d68020_cas_8(void)
\r
1239 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1240 extension = read_imm_16();
\r
1241 sprintf(g_dasm_str, "cas.b D%d, D%d, %s; (2+)", extension&7, (extension>>8)&7, get_ea_mode_str_8(g_cpu_ir));
\r
1244 static void d68020_cas_16(void)
\r
1247 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1248 extension = read_imm_16();
\r
1249 sprintf(g_dasm_str, "cas.w D%d, D%d, %s; (2+)", extension&7, (extension>>8)&7, get_ea_mode_str_16(g_cpu_ir));
\r
1252 static void d68020_cas_32(void)
\r
1255 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1256 extension = read_imm_16();
\r
1257 sprintf(g_dasm_str, "cas.l D%d, D%d, %s; (2+)", extension&7, (extension>>8)&7, get_ea_mode_str_32(g_cpu_ir));
\r
1260 static void d68020_cas2_16(void)
\r
1262 /* CAS2 Dc1:Dc2,Du1:Dc2:(Rn1):(Rn2)
\r
1263 f e d c b a 9 8 7 6 5 4 3 2 1 0
\r
1264 DARn1 0 0 0 Du1 0 0 0 Dc1
\r
1265 DARn2 0 0 0 Du2 0 0 0 Dc2
\r
1269 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1270 extension = read_imm_32();
\r
1271 sprintf(g_dasm_str, "cas2.w D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)",
\r
1272 (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
\r
1273 BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
\r
1274 BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
1277 static void d68020_cas2_32(void)
\r
1280 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1281 extension = read_imm_32();
\r
1282 sprintf(g_dasm_str, "cas2.l D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)",
\r
1283 (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
\r
1284 BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
\r
1285 BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
1288 static void d68000_chk_16(void)
\r
1290 sprintf(g_dasm_str, "chk.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1291 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1294 static void d68020_chk_32(void)
\r
1296 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1297 sprintf(g_dasm_str, "chk.l %s, D%d; (2+)", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1298 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1301 static void d68020_chk2_cmp2_8(void)
\r
1304 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1305 extension = read_imm_16();
\r
1306 sprintf(g_dasm_str, "%s.b %s, %c%d; (2+)", BIT_B(extension) ? "chk2" : "cmp2", get_ea_mode_str_8(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
1309 static void d68020_chk2_cmp2_16(void)
\r
1312 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1313 extension = read_imm_16();
\r
1314 sprintf(g_dasm_str, "%s.w %s, %c%d; (2+)", BIT_B(extension) ? "chk2" : "cmp2", get_ea_mode_str_16(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
1317 static void d68020_chk2_cmp2_32(void)
\r
1320 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1321 extension = read_imm_16();
\r
1322 sprintf(g_dasm_str, "%s.l %s, %c%d; (2+)", BIT_B(extension) ? "chk2" : "cmp2", get_ea_mode_str_32(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
1325 static void d68040_cinv(void)
\r
1327 LIMIT_CPU_TYPES(M68040_PLUS);
\r
1328 switch((g_cpu_ir>>3)&3)
\r
1331 sprintf(g_dasm_str, "cinv (illegal scope); (4)");
\r
1334 sprintf(g_dasm_str, "cinvl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
\r
1337 sprintf(g_dasm_str, "cinvp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
\r
1340 sprintf(g_dasm_str, "cinva %d; (4)", (g_cpu_ir>>6)&3);
\r
1345 static void d68000_clr_8(void)
\r
1347 sprintf(g_dasm_str, "clr.b %s", get_ea_mode_str_8(g_cpu_ir));
\r
1350 static void d68000_clr_16(void)
\r
1352 sprintf(g_dasm_str, "clr.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
1355 static void d68000_clr_32(void)
\r
1357 sprintf(g_dasm_str, "clr.l %s", get_ea_mode_str_32(g_cpu_ir));
\r
1360 static void d68000_cmp_8(void)
\r
1362 sprintf(g_dasm_str, "cmp.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1365 static void d68000_cmp_16(void)
\r
1367 sprintf(g_dasm_str, "cmp.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1370 static void d68000_cmp_32(void)
\r
1372 sprintf(g_dasm_str, "cmp.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1375 static void d68000_cmpa_16(void)
\r
1377 sprintf(g_dasm_str, "cmpa.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1380 static void d68000_cmpa_32(void)
\r
1382 sprintf(g_dasm_str, "cmpa.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1385 static void d68000_cmpi_8(void)
\r
1387 char* str = get_imm_str_s8();
\r
1388 sprintf(g_dasm_str, "cmpi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
1391 static void d68020_cmpi_pcdi_8(void)
\r
1394 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1395 str = get_imm_str_s8();
\r
1396 sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
\r
1399 static void d68020_cmpi_pcix_8(void)
\r
1402 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1403 str = get_imm_str_s8();
\r
1404 sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
\r
1407 static void d68000_cmpi_16(void)
\r
1410 str = get_imm_str_s16();
\r
1411 sprintf(g_dasm_str, "cmpi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
\r
1414 static void d68020_cmpi_pcdi_16(void)
\r
1417 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1418 str = get_imm_str_s16();
\r
1419 sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
\r
1422 static void d68020_cmpi_pcix_16(void)
\r
1425 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1426 str = get_imm_str_s16();
\r
1427 sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
\r
1430 static void d68000_cmpi_32(void)
\r
1433 str = get_imm_str_s32();
\r
1434 sprintf(g_dasm_str, "cmpi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
\r
1437 static void d68020_cmpi_pcdi_32(void)
\r
1440 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1441 str = get_imm_str_s32();
\r
1442 sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
\r
1445 static void d68020_cmpi_pcix_32(void)
\r
1448 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1449 str = get_imm_str_s32();
\r
1450 sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
\r
1453 static void d68000_cmpm_8(void)
\r
1455 sprintf(g_dasm_str, "cmpm.b (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
1458 static void d68000_cmpm_16(void)
\r
1460 sprintf(g_dasm_str, "cmpm.w (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
1463 static void d68000_cmpm_32(void)
\r
1465 sprintf(g_dasm_str, "cmpm.l (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
1468 static void d68020_cpbcc_16(void)
\r
1471 uint new_pc = g_cpu_pc;
\r
1472 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1473 extension = read_imm_16();
\r
1474 new_pc += make_int_16(read_imm_16());
\r
1475 sprintf(g_dasm_str, "%db%-4s %s; %x (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[g_cpu_ir&0x3f], get_imm_str_s16(), new_pc, extension);
\r
1478 static void d68020_cpbcc_32(void)
\r
1481 uint new_pc = g_cpu_pc;
\r
1482 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1483 extension = read_imm_16();
\r
1484 new_pc += read_imm_32();
\r
1485 sprintf(g_dasm_str, "%db%-4s %s; %x (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[g_cpu_ir&0x3f], get_imm_str_s16(), new_pc, extension);
\r
1488 static void d68020_cpdbcc(void)
\r
1492 uint new_pc = g_cpu_pc;
\r
1493 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1494 extension1 = read_imm_16();
\r
1495 extension2 = read_imm_16();
\r
1496 new_pc += make_int_16(read_imm_16());
\r
1497 sprintf(g_dasm_str, "%ddb%-4s D%d,%s; %x (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], g_cpu_ir&7, get_imm_str_s16(), new_pc, extension2);
\r
1500 static void d68020_cpgen(void)
\r
1502 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1503 sprintf(g_dasm_str, "%dgen %s; (2-3)", (g_cpu_ir>>9)&7, get_imm_str_u32());
\r
1506 static void d68020_cprestore(void)
\r
1508 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1509 sprintf(g_dasm_str, "%drestore %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
1512 static void d68020_cpsave(void)
\r
1514 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1515 sprintf(g_dasm_str, "%dsave %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
1518 static void d68020_cpscc(void)
\r
1522 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1523 extension1 = read_imm_16();
\r
1524 extension2 = read_imm_16();
\r
1525 sprintf(g_dasm_str, "%ds%-4s %s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], get_ea_mode_str_8(g_cpu_ir), extension2);
\r
1528 static void d68020_cptrapcc_0(void)
\r
1532 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1533 extension1 = read_imm_16();
\r
1534 extension2 = read_imm_16();
\r
1535 sprintf(g_dasm_str, "%dtrap%-4s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], extension2);
\r
1538 static void d68020_cptrapcc_16(void)
\r
1542 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1543 extension1 = read_imm_16();
\r
1544 extension2 = read_imm_16();
\r
1545 sprintf(g_dasm_str, "%dtrap%-4s %s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], get_imm_str_u16(), extension2);
\r
1548 static void d68020_cptrapcc_32(void)
\r
1552 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1553 extension1 = read_imm_16();
\r
1554 extension2 = read_imm_16();
\r
1555 sprintf(g_dasm_str, "%dtrap%-4s %s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], get_imm_str_u32(), extension2);
\r
1558 static void d68040_cpush(void)
\r
1560 LIMIT_CPU_TYPES(M68040_PLUS);
\r
1561 switch((g_cpu_ir>>3)&3)
\r
1564 sprintf(g_dasm_str, "cpush (illegal scope); (4)");
\r
1567 sprintf(g_dasm_str, "cpushl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
\r
1570 sprintf(g_dasm_str, "cpushp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
\r
1573 sprintf(g_dasm_str, "cpusha %d; (4)", (g_cpu_ir>>6)&3);
\r
1578 static void d68000_dbra(void)
\r
1580 uint temp_pc = g_cpu_pc;
\r
1581 sprintf(g_dasm_str, "dbra D%d, $%x", g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16()));
\r
1582 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1585 static void d68000_dbcc(void)
\r
1587 uint temp_pc = g_cpu_pc;
\r
1588 sprintf(g_dasm_str, "db%-2s D%d, $%x", g_cc[(g_cpu_ir>>8)&0xf], g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16()));
\r
1589 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1592 static void d68000_divs(void)
\r
1594 sprintf(g_dasm_str, "divs.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1597 static void d68000_divu(void)
\r
1599 sprintf(g_dasm_str, "divu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1602 static void d68020_divl(void)
\r
1605 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1606 extension = read_imm_16();
\r
1608 if(BIT_A(extension))
\r
1609 sprintf(g_dasm_str, "div%c.l %s, D%d:D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), extension&7, (extension>>12)&7);
\r
1610 else if((extension&7) == ((extension>>12)&7))
\r
1611 sprintf(g_dasm_str, "div%c.l %s, D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), (extension>>12)&7);
\r
1613 sprintf(g_dasm_str, "div%cl.l %s, D%d:D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), extension&7, (extension>>12)&7);
\r
1616 static void d68000_eor_8(void)
\r
1618 sprintf(g_dasm_str, "eor.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
1621 static void d68000_eor_16(void)
\r
1623 sprintf(g_dasm_str, "eor.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
\r
1626 static void d68000_eor_32(void)
\r
1628 sprintf(g_dasm_str, "eor.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
\r
1631 static void d68000_eori_8(void)
\r
1633 char* str = get_imm_str_u8();
\r
1634 sprintf(g_dasm_str, "eori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
1637 static void d68000_eori_16(void)
\r
1639 char* str = get_imm_str_u16();
\r
1640 sprintf(g_dasm_str, "eori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
\r
1643 static void d68000_eori_32(void)
\r
1645 char* str = get_imm_str_u32();
\r
1646 sprintf(g_dasm_str, "eori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
\r
1649 static void d68000_eori_to_ccr(void)
\r
1651 sprintf(g_dasm_str, "eori %s, CCR", get_imm_str_u8());
\r
1654 static void d68000_eori_to_sr(void)
\r
1656 sprintf(g_dasm_str, "eori %s, SR", get_imm_str_u16());
\r
1659 static void d68000_exg_dd(void)
\r
1661 sprintf(g_dasm_str, "exg D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1664 static void d68000_exg_aa(void)
\r
1666 sprintf(g_dasm_str, "exg A%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1669 static void d68000_exg_da(void)
\r
1671 sprintf(g_dasm_str, "exg D%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1674 static void d68000_ext_16(void)
\r
1676 sprintf(g_dasm_str, "ext.w D%d", g_cpu_ir&7);
\r
1679 static void d68000_ext_32(void)
\r
1681 sprintf(g_dasm_str, "ext.l D%d", g_cpu_ir&7);
\r
1684 static void d68020_extb_32(void)
\r
1686 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1687 sprintf(g_dasm_str, "extb.l D%d; (2+)", g_cpu_ir&7);
\r
1690 static void d68040_fpu(void)
\r
1692 char float_data_format[8][3] =
\r
1694 ".l", ".s", ".x", ".p", ".w", ".d", ".b", ".?"
\r
1697 char mnemonic[40];
\r
1698 uint w2, src, dst_reg;
\r
1699 LIMIT_CPU_TYPES(M68040_PLUS);
\r
1700 w2 = read_imm_16();
\r
1702 src = (w2 >> 10) & 0x7;
\r
1703 dst_reg = (w2 >> 7) & 0x7;
\r
1705 switch ((w2 >> 13) & 0x7)
\r
1712 case 0x00: sprintf(mnemonic, "fmove"); break;
\r
1713 case 0x01: sprintf(mnemonic, "fint"); break;
\r
1714 case 0x02: sprintf(mnemonic, "fsinh"); break;
\r
1715 case 0x03: sprintf(mnemonic, "fintrz"); break;
\r
1716 case 0x04: sprintf(mnemonic, "fsqrt"); break;
\r
1717 case 0x06: sprintf(mnemonic, "flognp1"); break;
\r
1718 case 0x08: sprintf(mnemonic, "fetoxm1"); break;
\r
1719 case 0x09: sprintf(mnemonic, "ftanh1"); break;
\r
1720 case 0x0a: sprintf(mnemonic, "fatan"); break;
\r
1721 case 0x0c: sprintf(mnemonic, "fasin"); break;
\r
1722 case 0x0d: sprintf(mnemonic, "fatanh"); break;
\r
1723 case 0x0e: sprintf(mnemonic, "fsin"); break;
\r
1724 case 0x0f: sprintf(mnemonic, "ftan"); break;
\r
1725 case 0x10: sprintf(mnemonic, "fetox"); break;
\r
1726 case 0x11: sprintf(mnemonic, "ftwotox"); break;
\r
1727 case 0x12: sprintf(mnemonic, "ftentox"); break;
\r
1728 case 0x14: sprintf(mnemonic, "flogn"); break;
\r
1729 case 0x15: sprintf(mnemonic, "flog10"); break;
\r
1730 case 0x16: sprintf(mnemonic, "flog2"); break;
\r
1731 case 0x18: sprintf(mnemonic, "fabs"); break;
\r
1732 case 0x19: sprintf(mnemonic, "fcosh"); break;
\r
1733 case 0x1a: sprintf(mnemonic, "fneg"); break;
\r
1734 case 0x1c: sprintf(mnemonic, "facos"); break;
\r
1735 case 0x1d: sprintf(mnemonic, "fcos"); break;
\r
1736 case 0x1e: sprintf(mnemonic, "fgetexp"); break;
\r
1737 case 0x1f: sprintf(mnemonic, "fgetman"); break;
\r
1738 case 0x20: sprintf(mnemonic, "fdiv"); break;
\r
1739 case 0x21: sprintf(mnemonic, "fmod"); break;
\r
1740 case 0x22: sprintf(mnemonic, "fadd"); break;
\r
1741 case 0x23: sprintf(mnemonic, "fmul"); break;
\r
1742 case 0x24: sprintf(mnemonic, "fsgldiv"); break;
\r
1743 case 0x25: sprintf(mnemonic, "frem"); break;
\r
1744 case 0x26: sprintf(mnemonic, "fscale"); break;
\r
1745 case 0x27: sprintf(mnemonic, "fsglmul"); break;
\r
1746 case 0x28: sprintf(mnemonic, "fsub"); break;
\r
1747 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
\r
1748 sprintf(mnemonic, "fsincos"); break;
\r
1749 case 0x38: sprintf(mnemonic, "fcmp"); break;
\r
1750 case 0x3a: sprintf(mnemonic, "ftst"); break;
\r
1751 case 0x41: sprintf(mnemonic, "fssqrt"); break;
\r
1752 case 0x45: sprintf(mnemonic, "fdsqrt"); break;
\r
1753 case 0x58: sprintf(mnemonic, "fsabs"); break;
\r
1754 case 0x5a: sprintf(mnemonic, "fsneg"); break;
\r
1755 case 0x5c: sprintf(mnemonic, "fdabs"); break;
\r
1756 case 0x5e: sprintf(mnemonic, "fdneg"); break;
\r
1757 case 0x60: sprintf(mnemonic, "fsdiv"); break;
\r
1758 case 0x62: sprintf(mnemonic, "fsadd"); break;
\r
1759 case 0x63: sprintf(mnemonic, "fsmul"); break;
\r
1760 case 0x64: sprintf(mnemonic, "fddiv"); break;
\r
1761 case 0x66: sprintf(mnemonic, "fdadd"); break;
\r
1762 case 0x67: sprintf(mnemonic, "fdmul"); break;
\r
1763 case 0x68: sprintf(mnemonic, "fssub"); break;
\r
1764 case 0x6c: sprintf(mnemonic, "fdsub"); break;
\r
1766 default: sprintf(mnemonic, "FPU (?)"); break;
\r
1771 sprintf(g_dasm_str, "%s%s %s, FP%d", mnemonic, float_data_format[src], get_ea_mode_str_32(g_cpu_ir), dst_reg);
\r
1775 sprintf(g_dasm_str, "%s.x FP%d, FP%d", mnemonic, src, dst_reg);
\r
1782 sprintf(g_dasm_str, "fmove /todo");
\r
1789 sprintf(g_dasm_str, "fmove /todo");
\r
1796 sprintf(g_dasm_str, "fmovem /todo");
\r
1802 sprintf(g_dasm_str, "FPU (?) ");
\r
1808 static void d68000_jmp(void)
\r
1810 sprintf(g_dasm_str, "jmp %s", get_ea_mode_str_32(g_cpu_ir));
\r
1813 static void d68000_jsr(void)
\r
1815 sprintf(g_dasm_str, "jsr %s", get_ea_mode_str_32(g_cpu_ir));
\r
1816 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
1819 static void d68000_lea(void)
\r
1821 sprintf(g_dasm_str, "lea %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1824 static void d68000_link_16(void)
\r
1826 sprintf(g_dasm_str, "link A%d, %s", g_cpu_ir&7, get_imm_str_s16());
\r
1829 static void d68020_link_32(void)
\r
1831 LIMIT_CPU_TYPES(M68020_PLUS);
\r
1832 sprintf(g_dasm_str, "link A%d, %s; (2+)", g_cpu_ir&7, get_imm_str_s32());
\r
1835 static void d68000_lsr_s_8(void)
\r
1837 sprintf(g_dasm_str, "lsr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
1840 static void d68000_lsr_s_16(void)
\r
1842 sprintf(g_dasm_str, "lsr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
1845 static void d68000_lsr_s_32(void)
\r
1847 sprintf(g_dasm_str, "lsr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
1850 static void d68000_lsr_r_8(void)
\r
1852 sprintf(g_dasm_str, "lsr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1855 static void d68000_lsr_r_16(void)
\r
1857 sprintf(g_dasm_str, "lsr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1860 static void d68000_lsr_r_32(void)
\r
1862 sprintf(g_dasm_str, "lsr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1865 static void d68000_lsr_ea(void)
\r
1867 sprintf(g_dasm_str, "lsr.w %s", get_ea_mode_str_32(g_cpu_ir));
\r
1870 static void d68000_lsl_s_8(void)
\r
1872 sprintf(g_dasm_str, "lsl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
1875 static void d68000_lsl_s_16(void)
\r
1877 sprintf(g_dasm_str, "lsl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
1880 static void d68000_lsl_s_32(void)
\r
1882 sprintf(g_dasm_str, "lsl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
1885 static void d68000_lsl_r_8(void)
\r
1887 sprintf(g_dasm_str, "lsl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1890 static void d68000_lsl_r_16(void)
\r
1892 sprintf(g_dasm_str, "lsl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1895 static void d68000_lsl_r_32(void)
\r
1897 sprintf(g_dasm_str, "lsl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
1900 static void d68000_lsl_ea(void)
\r
1902 sprintf(g_dasm_str, "lsl.w %s", get_ea_mode_str_32(g_cpu_ir));
\r
1905 static void d68000_move_8(void)
\r
1907 char* str = get_ea_mode_str_8(g_cpu_ir);
\r
1908 sprintf(g_dasm_str, "move.b %s, %s", str, get_ea_mode_str_8(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
\r
1911 static void d68000_move_16(void)
\r
1913 char* str = get_ea_mode_str_16(g_cpu_ir);
\r
1914 sprintf(g_dasm_str, "move.w %s, %s", str, get_ea_mode_str_16(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
\r
1917 static void d68000_move_32(void)
\r
1919 char* str = get_ea_mode_str_32(g_cpu_ir);
\r
1920 sprintf(g_dasm_str, "move.l %s, %s", str, get_ea_mode_str_32(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
\r
1923 static void d68000_movea_16(void)
\r
1925 sprintf(g_dasm_str, "movea.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1928 static void d68000_movea_32(void)
\r
1930 sprintf(g_dasm_str, "movea.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
1933 static void d68000_move_to_ccr(void)
\r
1935 sprintf(g_dasm_str, "move %s, CCR", get_ea_mode_str_8(g_cpu_ir));
\r
1938 static void d68010_move_fr_ccr(void)
\r
1940 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1941 sprintf(g_dasm_str, "move CCR, %s; (1+)", get_ea_mode_str_8(g_cpu_ir));
\r
1944 static void d68000_move_fr_sr(void)
\r
1946 sprintf(g_dasm_str, "move SR, %s", get_ea_mode_str_16(g_cpu_ir));
\r
1949 static void d68000_move_to_sr(void)
\r
1951 sprintf(g_dasm_str, "move %s, SR", get_ea_mode_str_16(g_cpu_ir));
\r
1954 static void d68000_move_fr_usp(void)
\r
1956 sprintf(g_dasm_str, "move USP, A%d", g_cpu_ir&7);
\r
1959 static void d68000_move_to_usp(void)
\r
1961 sprintf(g_dasm_str, "move A%d, USP", g_cpu_ir&7);
\r
1964 static void d68010_movec(void)
\r
1967 const char* reg_name;
\r
1968 const char* processor;
\r
1969 LIMIT_CPU_TYPES(M68010_PLUS);
\r
1970 extension = read_imm_16();
\r
1972 switch(extension & 0xfff)
\r
1991 reg_name = "CACR";
\r
1995 reg_name = "CAAR";
\r
1996 processor = "2,3";
\r
2011 reg_name = "ITT0";
\r
2015 reg_name = "ITT1";
\r
2019 reg_name = "DTT0";
\r
2023 reg_name = "DTT1";
\r
2027 reg_name = "MMUSR";
\r
2039 reg_name = make_signed_hex_str_16(extension & 0xfff);
\r
2043 if(BIT_0(g_cpu_ir))
\r
2044 sprintf(g_dasm_str, "movec %c%d, %s; (%s)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, reg_name, processor);
\r
2046 sprintf(g_dasm_str, "movec %s, %c%d; (%s)", reg_name, BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, processor);
\r
2049 static void d68000_movem_pd_16(void)
\r
2051 uint data = read_imm_16();
\r
2060 if(data&(1<<(15-i)))
\r
2064 while(i<7 && (data&(1<<(15-(i+1)))))
\r
2069 if(buffer[0] != 0)
\r
2070 strcat(buffer, "/");
\r
2071 sprintf(buffer+strlen(buffer), "D%d", first);
\r
2072 if(run_length > 0)
\r
2073 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
\r
2078 if(data&(1<<(7-i)))
\r
2082 while(i<7 && (data&(1<<(7-(i+1)))))
\r
2087 if(buffer[0] != 0)
\r
2088 strcat(buffer, "/");
\r
2089 sprintf(buffer+strlen(buffer), "A%d", first);
\r
2090 if(run_length > 0)
\r
2091 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
\r
2094 sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
\r
2097 static void d68000_movem_pd_32(void)
\r
2099 uint data = read_imm_16();
\r
2108 if(data&(1<<(15-i)))
\r
2112 while(i<7 && (data&(1<<(15-(i+1)))))
\r
2117 if(buffer[0] != 0)
\r
2118 strcat(buffer, "/");
\r
2119 sprintf(buffer+strlen(buffer), "D%d", first);
\r
2120 if(run_length > 0)
\r
2121 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
\r
2126 if(data&(1<<(7-i)))
\r
2130 while(i<7 && (data&(1<<(7-(i+1)))))
\r
2135 if(buffer[0] != 0)
\r
2136 strcat(buffer, "/");
\r
2137 sprintf(buffer+strlen(buffer), "A%d", first);
\r
2138 if(run_length > 0)
\r
2139 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
\r
2142 sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
\r
2145 static void d68000_movem_er_16(void)
\r
2147 uint data = read_imm_16();
\r
2160 while(i<7 && (data&(1<<(i+1))))
\r
2165 if(buffer[0] != 0)
\r
2166 strcat(buffer, "/");
\r
2167 sprintf(buffer+strlen(buffer), "D%d", first);
\r
2168 if(run_length > 0)
\r
2169 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
\r
2174 if(data&(1<<(i+8)))
\r
2178 while(i<7 && (data&(1<<(i+8+1))))
\r
2183 if(buffer[0] != 0)
\r
2184 strcat(buffer, "/");
\r
2185 sprintf(buffer+strlen(buffer), "A%d", first);
\r
2186 if(run_length > 0)
\r
2187 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
\r
2190 sprintf(g_dasm_str, "movem.w %s, %s", get_ea_mode_str_16(g_cpu_ir), buffer);
\r
2193 static void d68000_movem_er_32(void)
\r
2195 uint data = read_imm_16();
\r
2208 while(i<7 && (data&(1<<(i+1))))
\r
2213 if(buffer[0] != 0)
\r
2214 strcat(buffer, "/");
\r
2215 sprintf(buffer+strlen(buffer), "D%d", first);
\r
2216 if(run_length > 0)
\r
2217 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
\r
2222 if(data&(1<<(i+8)))
\r
2226 while(i<7 && (data&(1<<(i+8+1))))
\r
2231 if(buffer[0] != 0)
\r
2232 strcat(buffer, "/");
\r
2233 sprintf(buffer+strlen(buffer), "A%d", first);
\r
2234 if(run_length > 0)
\r
2235 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
\r
2238 sprintf(g_dasm_str, "movem.l %s, %s", get_ea_mode_str_32(g_cpu_ir), buffer);
\r
2241 static void d68000_movem_re_16(void)
\r
2243 uint data = read_imm_16();
\r
2256 while(i<7 && (data&(1<<(i+1))))
\r
2261 if(buffer[0] != 0)
\r
2262 strcat(buffer, "/");
\r
2263 sprintf(buffer+strlen(buffer), "D%d", first);
\r
2264 if(run_length > 0)
\r
2265 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
\r
2270 if(data&(1<<(i+8)))
\r
2274 while(i<7 && (data&(1<<(i+8+1))))
\r
2279 if(buffer[0] != 0)
\r
2280 strcat(buffer, "/");
\r
2281 sprintf(buffer+strlen(buffer), "A%d", first);
\r
2282 if(run_length > 0)
\r
2283 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
\r
2286 sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
\r
2289 static void d68000_movem_re_32(void)
\r
2291 uint data = read_imm_16();
\r
2304 while(i<7 && (data&(1<<(i+1))))
\r
2309 if(buffer[0] != 0)
\r
2310 strcat(buffer, "/");
\r
2311 sprintf(buffer+strlen(buffer), "D%d", first);
\r
2312 if(run_length > 0)
\r
2313 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
\r
2318 if(data&(1<<(i+8)))
\r
2322 while(i<7 && (data&(1<<(i+8+1))))
\r
2327 if(buffer[0] != 0)
\r
2328 strcat(buffer, "/");
\r
2329 sprintf(buffer+strlen(buffer), "A%d", first);
\r
2330 if(run_length > 0)
\r
2331 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
\r
2334 sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
\r
2337 static void d68000_movep_re_16(void)
\r
2339 sprintf(g_dasm_str, "movep.w D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
\r
2342 static void d68000_movep_re_32(void)
\r
2344 sprintf(g_dasm_str, "movep.l D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
\r
2347 static void d68000_movep_er_16(void)
\r
2349 sprintf(g_dasm_str, "movep.w ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2352 static void d68000_movep_er_32(void)
\r
2354 sprintf(g_dasm_str, "movep.l ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2357 static void d68010_moves_8(void)
\r
2360 LIMIT_CPU_TYPES(M68010_PLUS);
\r
2361 extension = read_imm_16();
\r
2362 if(BIT_B(extension))
\r
2363 sprintf(g_dasm_str, "moves.b %c%d, %s; (1+)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir));
\r
2365 sprintf(g_dasm_str, "moves.b %s, %c%d; (1+)", get_ea_mode_str_8(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
2368 static void d68010_moves_16(void)
\r
2371 LIMIT_CPU_TYPES(M68010_PLUS);
\r
2372 extension = read_imm_16();
\r
2373 if(BIT_B(extension))
\r
2374 sprintf(g_dasm_str, "moves.w %c%d, %s; (1+)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, get_ea_mode_str_16(g_cpu_ir));
\r
2376 sprintf(g_dasm_str, "moves.w %s, %c%d; (1+)", get_ea_mode_str_16(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
2379 static void d68010_moves_32(void)
\r
2382 LIMIT_CPU_TYPES(M68010_PLUS);
\r
2383 extension = read_imm_16();
\r
2384 if(BIT_B(extension))
\r
2385 sprintf(g_dasm_str, "moves.l %c%d, %s; (1+)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, get_ea_mode_str_32(g_cpu_ir));
\r
2387 sprintf(g_dasm_str, "moves.l %s, %c%d; (1+)", get_ea_mode_str_32(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
\r
2390 static void d68000_moveq(void)
\r
2392 sprintf(g_dasm_str, "moveq #%s, D%d", make_signed_hex_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2395 static void d68040_move16_pi_pi(void)
\r
2397 LIMIT_CPU_TYPES(M68040_PLUS);
\r
2398 sprintf(g_dasm_str, "move16 (A%d)+, (A%d)+; (4)", g_cpu_ir&7, (read_imm_16()>>12)&7);
\r
2401 static void d68040_move16_pi_al(void)
\r
2403 LIMIT_CPU_TYPES(M68040_PLUS);
\r
2404 sprintf(g_dasm_str, "move16 (A%d)+, %s; (4)", g_cpu_ir&7, get_imm_str_u32());
\r
2407 static void d68040_move16_al_pi(void)
\r
2409 LIMIT_CPU_TYPES(M68040_PLUS);
\r
2410 sprintf(g_dasm_str, "move16 %s, (A%d)+; (4)", get_imm_str_u32(), g_cpu_ir&7);
\r
2413 static void d68040_move16_ai_al(void)
\r
2415 LIMIT_CPU_TYPES(M68040_PLUS);
\r
2416 sprintf(g_dasm_str, "move16 (A%d), %s; (4)", g_cpu_ir&7, get_imm_str_u32());
\r
2419 static void d68040_move16_al_ai(void)
\r
2421 LIMIT_CPU_TYPES(M68040_PLUS);
\r
2422 sprintf(g_dasm_str, "move16 %s, (A%d); (4)", get_imm_str_u32(), g_cpu_ir&7);
\r
2425 static void d68000_muls(void)
\r
2427 sprintf(g_dasm_str, "muls.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2430 static void d68000_mulu(void)
\r
2432 sprintf(g_dasm_str, "mulu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2435 static void d68020_mull(void)
\r
2438 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2439 extension = read_imm_16();
\r
2441 if(BIT_A(extension))
\r
2442 sprintf(g_dasm_str, "mul%c.l %s, D%d-D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), extension&7, (extension>>12)&7);
\r
2444 sprintf(g_dasm_str, "mul%c.l %s, D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), (extension>>12)&7);
\r
2447 static void d68000_nbcd(void)
\r
2449 sprintf(g_dasm_str, "nbcd %s", get_ea_mode_str_8(g_cpu_ir));
\r
2452 static void d68000_neg_8(void)
\r
2454 sprintf(g_dasm_str, "neg.b %s", get_ea_mode_str_8(g_cpu_ir));
\r
2457 static void d68000_neg_16(void)
\r
2459 sprintf(g_dasm_str, "neg.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
2462 static void d68000_neg_32(void)
\r
2464 sprintf(g_dasm_str, "neg.l %s", get_ea_mode_str_32(g_cpu_ir));
\r
2467 static void d68000_negx_8(void)
\r
2469 sprintf(g_dasm_str, "negx.b %s", get_ea_mode_str_8(g_cpu_ir));
\r
2472 static void d68000_negx_16(void)
\r
2474 sprintf(g_dasm_str, "negx.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
2477 static void d68000_negx_32(void)
\r
2479 sprintf(g_dasm_str, "negx.l %s", get_ea_mode_str_32(g_cpu_ir));
\r
2482 static void d68000_nop(void)
\r
2484 sprintf(g_dasm_str, "nop");
\r
2487 static void d68000_not_8(void)
\r
2489 sprintf(g_dasm_str, "not.b %s", get_ea_mode_str_8(g_cpu_ir));
\r
2492 static void d68000_not_16(void)
\r
2494 sprintf(g_dasm_str, "not.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
2497 static void d68000_not_32(void)
\r
2499 sprintf(g_dasm_str, "not.l %s", get_ea_mode_str_32(g_cpu_ir));
\r
2502 static void d68000_or_er_8(void)
\r
2504 sprintf(g_dasm_str, "or.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2507 static void d68000_or_er_16(void)
\r
2509 sprintf(g_dasm_str, "or.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2512 static void d68000_or_er_32(void)
\r
2514 sprintf(g_dasm_str, "or.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2517 static void d68000_or_re_8(void)
\r
2519 sprintf(g_dasm_str, "or.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
2522 static void d68000_or_re_16(void)
\r
2524 sprintf(g_dasm_str, "or.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
\r
2527 static void d68000_or_re_32(void)
\r
2529 sprintf(g_dasm_str, "or.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
\r
2532 static void d68000_ori_8(void)
\r
2534 char* str = get_imm_str_u8();
\r
2535 sprintf(g_dasm_str, "ori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
2538 static void d68000_ori_16(void)
\r
2540 char* str = get_imm_str_u16();
\r
2541 sprintf(g_dasm_str, "ori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
\r
2544 static void d68000_ori_32(void)
\r
2546 char* str = get_imm_str_u32();
\r
2547 sprintf(g_dasm_str, "ori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
\r
2550 static void d68000_ori_to_ccr(void)
\r
2552 sprintf(g_dasm_str, "ori %s, CCR", get_imm_str_u8());
\r
2555 static void d68000_ori_to_sr(void)
\r
2557 sprintf(g_dasm_str, "ori %s, SR", get_imm_str_u16());
\r
2560 static void d68020_pack_rr(void)
\r
2562 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2563 sprintf(g_dasm_str, "pack D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
\r
2566 static void d68020_pack_mm(void)
\r
2568 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2569 sprintf(g_dasm_str, "pack -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
\r
2572 static void d68000_pea(void)
\r
2574 sprintf(g_dasm_str, "pea %s", get_ea_mode_str_32(g_cpu_ir));
\r
2577 static void d68040_pflush(void)
\r
2579 LIMIT_CPU_TYPES(M68040_PLUS);
\r
2581 if (g_cpu_ir & 0x10)
\r
2583 sprintf(g_dasm_str, "pflusha%s", (g_cpu_ir & 8) ? "" : "n");
\r
2587 sprintf(g_dasm_str, "pflush%s(A%d)", (g_cpu_ir & 8) ? "" : "n", g_cpu_ir & 7);
\r
2591 static void d68000_reset(void)
\r
2593 sprintf(g_dasm_str, "reset");
\r
2596 static void d68000_ror_s_8(void)
\r
2598 sprintf(g_dasm_str, "ror.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2601 static void d68000_ror_s_16(void)
\r
2603 sprintf(g_dasm_str, "ror.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7],g_cpu_ir&7);
\r
2606 static void d68000_ror_s_32(void)
\r
2608 sprintf(g_dasm_str, "ror.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2611 static void d68000_ror_r_8(void)
\r
2613 sprintf(g_dasm_str, "ror.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2616 static void d68000_ror_r_16(void)
\r
2618 sprintf(g_dasm_str, "ror.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2621 static void d68000_ror_r_32(void)
\r
2623 sprintf(g_dasm_str, "ror.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2626 static void d68000_ror_ea(void)
\r
2628 sprintf(g_dasm_str, "ror.w %s", get_ea_mode_str_32(g_cpu_ir));
\r
2631 static void d68000_rol_s_8(void)
\r
2633 sprintf(g_dasm_str, "rol.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2636 static void d68000_rol_s_16(void)
\r
2638 sprintf(g_dasm_str, "rol.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2641 static void d68000_rol_s_32(void)
\r
2643 sprintf(g_dasm_str, "rol.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2646 static void d68000_rol_r_8(void)
\r
2648 sprintf(g_dasm_str, "rol.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2651 static void d68000_rol_r_16(void)
\r
2653 sprintf(g_dasm_str, "rol.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2656 static void d68000_rol_r_32(void)
\r
2658 sprintf(g_dasm_str, "rol.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2661 static void d68000_rol_ea(void)
\r
2663 sprintf(g_dasm_str, "rol.w %s", get_ea_mode_str_32(g_cpu_ir));
\r
2666 static void d68000_roxr_s_8(void)
\r
2668 sprintf(g_dasm_str, "roxr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2671 static void d68000_roxr_s_16(void)
\r
2673 sprintf(g_dasm_str, "roxr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2677 static void d68000_roxr_s_32(void)
\r
2679 sprintf(g_dasm_str, "roxr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2682 static void d68000_roxr_r_8(void)
\r
2684 sprintf(g_dasm_str, "roxr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2687 static void d68000_roxr_r_16(void)
\r
2689 sprintf(g_dasm_str, "roxr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2692 static void d68000_roxr_r_32(void)
\r
2694 sprintf(g_dasm_str, "roxr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2697 static void d68000_roxr_ea(void)
\r
2699 sprintf(g_dasm_str, "roxr.w %s", get_ea_mode_str_32(g_cpu_ir));
\r
2702 static void d68000_roxl_s_8(void)
\r
2704 sprintf(g_dasm_str, "roxl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2707 static void d68000_roxl_s_16(void)
\r
2709 sprintf(g_dasm_str, "roxl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2712 static void d68000_roxl_s_32(void)
\r
2714 sprintf(g_dasm_str, "roxl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
\r
2717 static void d68000_roxl_r_8(void)
\r
2719 sprintf(g_dasm_str, "roxl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2722 static void d68000_roxl_r_16(void)
\r
2724 sprintf(g_dasm_str, "roxl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2727 static void d68000_roxl_r_32(void)
\r
2729 sprintf(g_dasm_str, "roxl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
\r
2732 static void d68000_roxl_ea(void)
\r
2734 sprintf(g_dasm_str, "roxl.w %s", get_ea_mode_str_32(g_cpu_ir));
\r
2737 static void d68010_rtd(void)
\r
2739 LIMIT_CPU_TYPES(M68010_PLUS);
\r
2740 sprintf(g_dasm_str, "rtd %s; (1+)", get_imm_str_s16());
\r
2741 SET_OPCODE_FLAGS(DASMFLAG_STEP_OUT);
\r
2744 static void d68000_rte(void)
\r
2746 sprintf(g_dasm_str, "rte");
\r
2747 SET_OPCODE_FLAGS(DASMFLAG_STEP_OUT);
\r
2750 static void d68020_rtm(void)
\r
2752 LIMIT_CPU_TYPES(M68020_ONLY);
\r
2753 sprintf(g_dasm_str, "rtm %c%d; (2+)", BIT_3(g_cpu_ir) ? 'A' : 'D', g_cpu_ir&7);
\r
2754 SET_OPCODE_FLAGS(DASMFLAG_STEP_OUT);
\r
2757 static void d68000_rtr(void)
\r
2759 sprintf(g_dasm_str, "rtr");
\r
2760 SET_OPCODE_FLAGS(DASMFLAG_STEP_OUT);
\r
2763 static void d68000_rts(void)
\r
2765 sprintf(g_dasm_str, "rts");
\r
2766 SET_OPCODE_FLAGS(DASMFLAG_STEP_OUT);
\r
2769 static void d68000_sbcd_rr(void)
\r
2771 sprintf(g_dasm_str, "sbcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2774 static void d68000_sbcd_mm(void)
\r
2776 sprintf(g_dasm_str, "sbcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2779 static void d68000_scc(void)
\r
2781 sprintf(g_dasm_str, "s%-2s %s", g_cc[(g_cpu_ir>>8)&0xf], get_ea_mode_str_8(g_cpu_ir));
\r
2784 static void d68000_stop(void)
\r
2786 sprintf(g_dasm_str, "stop %s", get_imm_str_s16());
\r
2789 static void d68000_sub_er_8(void)
\r
2791 sprintf(g_dasm_str, "sub.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2794 static void d68000_sub_er_16(void)
\r
2796 sprintf(g_dasm_str, "sub.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2799 static void d68000_sub_er_32(void)
\r
2801 sprintf(g_dasm_str, "sub.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2804 static void d68000_sub_re_8(void)
\r
2806 sprintf(g_dasm_str, "sub.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
\r
2809 static void d68000_sub_re_16(void)
\r
2811 sprintf(g_dasm_str, "sub.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
\r
2814 static void d68000_sub_re_32(void)
\r
2816 sprintf(g_dasm_str, "sub.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
\r
2819 static void d68000_suba_16(void)
\r
2821 sprintf(g_dasm_str, "suba.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2824 static void d68000_suba_32(void)
\r
2826 sprintf(g_dasm_str, "suba.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
\r
2829 static void d68000_subi_8(void)
\r
2831 char* str = get_imm_str_s8();
\r
2832 sprintf(g_dasm_str, "subi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
\r
2835 static void d68000_subi_16(void)
\r
2837 char* str = get_imm_str_s16();
\r
2838 sprintf(g_dasm_str, "subi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
\r
2841 static void d68000_subi_32(void)
\r
2843 char* str = get_imm_str_s32();
\r
2844 sprintf(g_dasm_str, "subi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
\r
2847 static void d68000_subq_8(void)
\r
2849 sprintf(g_dasm_str, "subq.b #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_8(g_cpu_ir));
\r
2852 static void d68000_subq_16(void)
\r
2854 sprintf(g_dasm_str, "subq.w #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_16(g_cpu_ir));
\r
2857 static void d68000_subq_32(void)
\r
2859 sprintf(g_dasm_str, "subq.l #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_32(g_cpu_ir));
\r
2862 static void d68000_subx_rr_8(void)
\r
2864 sprintf(g_dasm_str, "subx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2867 static void d68000_subx_rr_16(void)
\r
2869 sprintf(g_dasm_str, "subx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2872 static void d68000_subx_rr_32(void)
\r
2874 sprintf(g_dasm_str, "subx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2877 static void d68000_subx_mm_8(void)
\r
2879 sprintf(g_dasm_str, "subx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2882 static void d68000_subx_mm_16(void)
\r
2884 sprintf(g_dasm_str, "subx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2887 static void d68000_subx_mm_32(void)
\r
2889 sprintf(g_dasm_str, "subx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
\r
2892 static void d68000_swap(void)
\r
2894 sprintf(g_dasm_str, "swap D%d", g_cpu_ir&7);
\r
2897 static void d68000_tas(void)
\r
2899 sprintf(g_dasm_str, "tas %s", get_ea_mode_str_8(g_cpu_ir));
\r
2902 static void d68000_trap(void)
\r
2904 sprintf(g_dasm_str, "trap #$%x", g_cpu_ir&0xf);
\r
2907 static void d68020_trapcc_0(void)
\r
2909 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2910 sprintf(g_dasm_str, "trap%-2s; (2+)", g_cc[(g_cpu_ir>>8)&0xf]);
\r
2911 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
2914 static void d68020_trapcc_16(void)
\r
2916 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2917 sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u16());
\r
2918 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
2921 static void d68020_trapcc_32(void)
\r
2923 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2924 sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u32());
\r
2925 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
2928 static void d68000_trapv(void)
\r
2930 sprintf(g_dasm_str, "trapv");
\r
2931 SET_OPCODE_FLAGS(DASMFLAG_STEP_OVER);
\r
2934 static void d68000_tst_8(void)
\r
2936 sprintf(g_dasm_str, "tst.b %s", get_ea_mode_str_8(g_cpu_ir));
\r
2939 static void d68020_tst_pcdi_8(void)
\r
2941 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2942 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
\r
2945 static void d68020_tst_pcix_8(void)
\r
2947 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2948 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
\r
2951 static void d68020_tst_i_8(void)
\r
2953 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2954 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
\r
2957 static void d68000_tst_16(void)
\r
2959 sprintf(g_dasm_str, "tst.w %s", get_ea_mode_str_16(g_cpu_ir));
\r
2962 static void d68020_tst_a_16(void)
\r
2964 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2965 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
\r
2968 static void d68020_tst_pcdi_16(void)
\r
2970 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2971 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
\r
2974 static void d68020_tst_pcix_16(void)
\r
2976 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2977 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
\r
2980 static void d68020_tst_i_16(void)
\r
2982 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2983 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
\r
2986 static void d68000_tst_32(void)
\r
2988 sprintf(g_dasm_str, "tst.l %s", get_ea_mode_str_32(g_cpu_ir));
\r
2991 static void d68020_tst_a_32(void)
\r
2993 LIMIT_CPU_TYPES(M68020_PLUS);
\r
2994 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
\r
2997 static void d68020_tst_pcdi_32(void)
\r
2999 LIMIT_CPU_TYPES(M68020_PLUS);
\r
3000 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
\r
3003 static void d68020_tst_pcix_32(void)
\r
3005 LIMIT_CPU_TYPES(M68020_PLUS);
\r
3006 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
\r
3009 static void d68020_tst_i_32(void)
\r
3011 LIMIT_CPU_TYPES(M68020_PLUS);
\r
3012 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
\r
3015 static void d68000_unlk(void)
\r
3017 sprintf(g_dasm_str, "unlk A%d", g_cpu_ir&7);
\r
3020 static void d68020_unpk_rr(void)
\r
3022 LIMIT_CPU_TYPES(M68020_PLUS);
\r
3023 sprintf(g_dasm_str, "unpk D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
\r
3026 static void d68020_unpk_mm(void)
\r
3028 LIMIT_CPU_TYPES(M68020_PLUS);
\r
3029 sprintf(g_dasm_str, "unpk -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
\r
3034 /* ======================================================================== */
\r
3035 /* ======================= INSTRUCTION TABLE BUILDER ====================== */
\r
3036 /* ======================================================================== */
\r
3039 800 = data register direct
\r
3040 400 = address register direct
\r
3041 200 = address register indirect
\r
3042 100 = ARI postincrement
\r
3043 80 = ARI pre-decrement
\r
3044 40 = ARI displacement
\r
3046 10 = absolute short
\r
3048 4 = immediate / sr
\r
3049 2 = pc displacement
\r
3053 static opcode_struct g_opcode_info[] =
\r
3055 /* opcode handler mask match ea mask */
\r
3056 {d68000_1010 , 0xf000, 0xa000, 0x000},
\r
3057 {d68000_1111 , 0xf000, 0xf000, 0x000},
\r
3058 {d68000_abcd_rr , 0xf1f8, 0xc100, 0x000},
\r
3059 {d68000_abcd_mm , 0xf1f8, 0xc108, 0x000},
\r
3060 {d68000_add_er_8 , 0xf1c0, 0xd000, 0xbff},
\r
3061 {d68000_add_er_16 , 0xf1c0, 0xd040, 0xfff},
\r
3062 {d68000_add_er_32 , 0xf1c0, 0xd080, 0xfff},
\r
3063 {d68000_add_re_8 , 0xf1c0, 0xd100, 0x3f8},
\r
3064 {d68000_add_re_16 , 0xf1c0, 0xd140, 0x3f8},
\r
3065 {d68000_add_re_32 , 0xf1c0, 0xd180, 0x3f8},
\r
3066 {d68000_adda_16 , 0xf1c0, 0xd0c0, 0xfff},
\r
3067 {d68000_adda_32 , 0xf1c0, 0xd1c0, 0xfff},
\r
3068 {d68000_addi_8 , 0xffc0, 0x0600, 0xbf8},
\r
3069 {d68000_addi_16 , 0xffc0, 0x0640, 0xbf8},
\r
3070 {d68000_addi_32 , 0xffc0, 0x0680, 0xbf8},
\r
3071 {d68000_addq_8 , 0xf1c0, 0x5000, 0xbf8},
\r
3072 {d68000_addq_16 , 0xf1c0, 0x5040, 0xff8},
\r
3073 {d68000_addq_32 , 0xf1c0, 0x5080, 0xff8},
\r
3074 {d68000_addx_rr_8 , 0xf1f8, 0xd100, 0x000},
\r
3075 {d68000_addx_rr_16 , 0xf1f8, 0xd140, 0x000},
\r
3076 {d68000_addx_rr_32 , 0xf1f8, 0xd180, 0x000},
\r
3077 {d68000_addx_mm_8 , 0xf1f8, 0xd108, 0x000},
\r
3078 {d68000_addx_mm_16 , 0xf1f8, 0xd148, 0x000},
\r
3079 {d68000_addx_mm_32 , 0xf1f8, 0xd188, 0x000},
\r
3080 {d68000_and_er_8 , 0xf1c0, 0xc000, 0xbff},
\r
3081 {d68000_and_er_16 , 0xf1c0, 0xc040, 0xbff},
\r
3082 {d68000_and_er_32 , 0xf1c0, 0xc080, 0xbff},
\r
3083 {d68000_and_re_8 , 0xf1c0, 0xc100, 0x3f8},
\r
3084 {d68000_and_re_16 , 0xf1c0, 0xc140, 0x3f8},
\r
3085 {d68000_and_re_32 , 0xf1c0, 0xc180, 0x3f8},
\r
3086 {d68000_andi_to_ccr , 0xffff, 0x023c, 0x000},
\r
3087 {d68000_andi_to_sr , 0xffff, 0x027c, 0x000},
\r
3088 {d68000_andi_8 , 0xffc0, 0x0200, 0xbf8},
\r
3089 {d68000_andi_16 , 0xffc0, 0x0240, 0xbf8},
\r
3090 {d68000_andi_32 , 0xffc0, 0x0280, 0xbf8},
\r
3091 {d68000_asr_s_8 , 0xf1f8, 0xe000, 0x000},
\r
3092 {d68000_asr_s_16 , 0xf1f8, 0xe040, 0x000},
\r
3093 {d68000_asr_s_32 , 0xf1f8, 0xe080, 0x000},
\r
3094 {d68000_asr_r_8 , 0xf1f8, 0xe020, 0x000},
\r
3095 {d68000_asr_r_16 , 0xf1f8, 0xe060, 0x000},
\r
3096 {d68000_asr_r_32 , 0xf1f8, 0xe0a0, 0x000},
\r
3097 {d68000_asr_ea , 0xffc0, 0xe0c0, 0x3f8},
\r
3098 {d68000_asl_s_8 , 0xf1f8, 0xe100, 0x000},
\r
3099 {d68000_asl_s_16 , 0xf1f8, 0xe140, 0x000},
\r
3100 {d68000_asl_s_32 , 0xf1f8, 0xe180, 0x000},
\r
3101 {d68000_asl_r_8 , 0xf1f8, 0xe120, 0x000},
\r
3102 {d68000_asl_r_16 , 0xf1f8, 0xe160, 0x000},
\r
3103 {d68000_asl_r_32 , 0xf1f8, 0xe1a0, 0x000},
\r
3104 {d68000_asl_ea , 0xffc0, 0xe1c0, 0x3f8},
\r
3105 {d68000_bcc_8 , 0xf000, 0x6000, 0x000},
\r
3106 {d68000_bcc_16 , 0xf0ff, 0x6000, 0x000},
\r
3107 {d68020_bcc_32 , 0xf0ff, 0x60ff, 0x000},
\r
3108 {d68000_bchg_r , 0xf1c0, 0x0140, 0xbf8},
\r
3109 {d68000_bchg_s , 0xffc0, 0x0840, 0xbf8},
\r
3110 {d68000_bclr_r , 0xf1c0, 0x0180, 0xbf8},
\r
3111 {d68000_bclr_s , 0xffc0, 0x0880, 0xbf8},
\r
3112 {d68020_bfchg , 0xffc0, 0xeac0, 0xa78},
\r
3113 {d68020_bfclr , 0xffc0, 0xecc0, 0xa78},
\r
3114 {d68020_bfexts , 0xffc0, 0xebc0, 0xa7b},
\r
3115 {d68020_bfextu , 0xffc0, 0xe9c0, 0xa7b},
\r
3116 {d68020_bfffo , 0xffc0, 0xedc0, 0xa7b},
\r
3117 {d68020_bfins , 0xffc0, 0xefc0, 0xa78},
\r
3118 {d68020_bfset , 0xffc0, 0xeec0, 0xa78},
\r
3119 {d68020_bftst , 0xffc0, 0xe8c0, 0xa7b},
\r
3120 {d68010_bkpt , 0xfff8, 0x4848, 0x000},
\r
3121 {d68000_bra_8 , 0xff00, 0x6000, 0x000},
\r
3122 {d68000_bra_16 , 0xffff, 0x6000, 0x000},
\r
3123 {d68020_bra_32 , 0xffff, 0x60ff, 0x000},
\r
3124 {d68000_bset_r , 0xf1c0, 0x01c0, 0xbf8},
\r
3125 {d68000_bset_s , 0xffc0, 0x08c0, 0xbf8},
\r
3126 {d68000_bsr_8 , 0xff00, 0x6100, 0x000},
\r
3127 {d68000_bsr_16 , 0xffff, 0x6100, 0x000},
\r
3128 {d68020_bsr_32 , 0xffff, 0x61ff, 0x000},
\r
3129 {d68000_btst_r , 0xf1c0, 0x0100, 0xbff},
\r
3130 {d68000_btst_s , 0xffc0, 0x0800, 0xbfb},
\r
3131 {d68020_callm , 0xffc0, 0x06c0, 0x27b},
\r
3132 {d68020_cas_8 , 0xffc0, 0x0ac0, 0x3f8},
\r
3133 {d68020_cas_16 , 0xffc0, 0x0cc0, 0x3f8},
\r
3134 {d68020_cas_32 , 0xffc0, 0x0ec0, 0x3f8},
\r
3135 {d68020_cas2_16 , 0xffff, 0x0cfc, 0x000},
\r
3136 {d68020_cas2_32 , 0xffff, 0x0efc, 0x000},
\r
3137 {d68000_chk_16 , 0xf1c0, 0x4180, 0xbff},
\r
3138 {d68020_chk_32 , 0xf1c0, 0x4100, 0xbff},
\r
3139 {d68020_chk2_cmp2_8 , 0xffc0, 0x00c0, 0x27b},
\r
3140 {d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b},
\r
3141 {d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b},
\r
3142 {d68040_cinv , 0xff20, 0xf400, 0x000},
\r
3143 {d68000_clr_8 , 0xffc0, 0x4200, 0xbf8},
\r
3144 {d68000_clr_16 , 0xffc0, 0x4240, 0xbf8},
\r
3145 {d68000_clr_32 , 0xffc0, 0x4280, 0xbf8},
\r
3146 {d68000_cmp_8 , 0xf1c0, 0xb000, 0xbff},
\r
3147 {d68000_cmp_16 , 0xf1c0, 0xb040, 0xfff},
\r
3148 {d68000_cmp_32 , 0xf1c0, 0xb080, 0xfff},
\r
3149 {d68000_cmpa_16 , 0xf1c0, 0xb0c0, 0xfff},
\r
3150 {d68000_cmpa_32 , 0xf1c0, 0xb1c0, 0xfff},
\r
3151 {d68000_cmpi_8 , 0xffc0, 0x0c00, 0xbf8},
\r
3152 {d68020_cmpi_pcdi_8 , 0xffff, 0x0c3a, 0x000},
\r
3153 {d68020_cmpi_pcix_8 , 0xffff, 0x0c3b, 0x000},
\r
3154 {d68000_cmpi_16 , 0xffc0, 0x0c40, 0xbf8},
\r
3155 {d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000},
\r
3156 {d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000},
\r
3157 {d68000_cmpi_32 , 0xffc0, 0x0c80, 0xbf8},
\r
3158 {d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000},
\r
3159 {d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000},
\r
3160 {d68000_cmpm_8 , 0xf1f8, 0xb108, 0x000},
\r
3161 {d68000_cmpm_16 , 0xf1f8, 0xb148, 0x000},
\r
3162 {d68000_cmpm_32 , 0xf1f8, 0xb188, 0x000},
\r
3163 {d68020_cpbcc_16 , 0xf1c0, 0xf080, 0x000},
\r
3164 {d68020_cpbcc_32 , 0xf1c0, 0xf0c0, 0x000},
\r
3165 {d68020_cpdbcc , 0xf1f8, 0xf048, 0x000},
\r
3166 {d68020_cpgen , 0xf1c0, 0xf000, 0x000},
\r
3167 {d68020_cprestore , 0xf1c0, 0xf140, 0x37f},
\r
3168 {d68020_cpsave , 0xf1c0, 0xf100, 0x2f8},
\r
3169 {d68020_cpscc , 0xf1c0, 0xf040, 0xbf8},
\r
3170 {d68020_cptrapcc_0 , 0xf1ff, 0xf07c, 0x000},
\r
3171 {d68020_cptrapcc_16 , 0xf1ff, 0xf07a, 0x000},
\r
3172 {d68020_cptrapcc_32 , 0xf1ff, 0xf07b, 0x000},
\r
3173 {d68040_cpush , 0xff20, 0xf420, 0x000},
\r
3174 {d68000_dbcc , 0xf0f8, 0x50c8, 0x000},
\r
3175 {d68000_dbra , 0xfff8, 0x51c8, 0x000},
\r
3176 {d68000_divs , 0xf1c0, 0x81c0, 0xbff},
\r
3177 {d68000_divu , 0xf1c0, 0x80c0, 0xbff},
\r
3178 {d68020_divl , 0xffc0, 0x4c40, 0xbff},
\r
3179 {d68000_eor_8 , 0xf1c0, 0xb100, 0xbf8},
\r
3180 {d68000_eor_16 , 0xf1c0, 0xb140, 0xbf8},
\r
3181 {d68000_eor_32 , 0xf1c0, 0xb180, 0xbf8},
\r
3182 {d68000_eori_to_ccr , 0xffff, 0x0a3c, 0x000},
\r
3183 {d68000_eori_to_sr , 0xffff, 0x0a7c, 0x000},
\r
3184 {d68000_eori_8 , 0xffc0, 0x0a00, 0xbf8},
\r
3185 {d68000_eori_16 , 0xffc0, 0x0a40, 0xbf8},
\r
3186 {d68000_eori_32 , 0xffc0, 0x0a80, 0xbf8},
\r
3187 {d68000_exg_dd , 0xf1f8, 0xc140, 0x000},
\r
3188 {d68000_exg_aa , 0xf1f8, 0xc148, 0x000},
\r
3189 {d68000_exg_da , 0xf1f8, 0xc188, 0x000},
\r
3190 {d68020_extb_32 , 0xfff8, 0x49c0, 0x000},
\r
3191 {d68000_ext_16 , 0xfff8, 0x4880, 0x000},
\r
3192 {d68000_ext_32 , 0xfff8, 0x48c0, 0x000},
\r
3193 {d68040_fpu , 0xffc0, 0xf200, 0x000},
\r
3194 {d68000_illegal , 0xffff, 0x4afc, 0x000},
\r
3195 {d68000_jmp , 0xffc0, 0x4ec0, 0x27b},
\r
3196 {d68000_jsr , 0xffc0, 0x4e80, 0x27b},
\r
3197 {d68000_lea , 0xf1c0, 0x41c0, 0x27b},
\r
3198 {d68000_link_16 , 0xfff8, 0x4e50, 0x000},
\r
3199 {d68020_link_32 , 0xfff8, 0x4808, 0x000},
\r
3200 {d68000_lsr_s_8 , 0xf1f8, 0xe008, 0x000},
\r
3201 {d68000_lsr_s_16 , 0xf1f8, 0xe048, 0x000},
\r
3202 {d68000_lsr_s_32 , 0xf1f8, 0xe088, 0x000},
\r
3203 {d68000_lsr_r_8 , 0xf1f8, 0xe028, 0x000},
\r
3204 {d68000_lsr_r_16 , 0xf1f8, 0xe068, 0x000},
\r
3205 {d68000_lsr_r_32 , 0xf1f8, 0xe0a8, 0x000},
\r
3206 {d68000_lsr_ea , 0xffc0, 0xe2c0, 0x3f8},
\r
3207 {d68000_lsl_s_8 , 0xf1f8, 0xe108, 0x000},
\r
3208 {d68000_lsl_s_16 , 0xf1f8, 0xe148, 0x000},
\r
3209 {d68000_lsl_s_32 , 0xf1f8, 0xe188, 0x000},
\r
3210 {d68000_lsl_r_8 , 0xf1f8, 0xe128, 0x000},
\r
3211 {d68000_lsl_r_16 , 0xf1f8, 0xe168, 0x000},
\r
3212 {d68000_lsl_r_32 , 0xf1f8, 0xe1a8, 0x000},
\r
3213 {d68000_lsl_ea , 0xffc0, 0xe3c0, 0x3f8},
\r
3214 {d68000_move_8 , 0xf000, 0x1000, 0xbff},
\r
3215 {d68000_move_16 , 0xf000, 0x3000, 0xfff},
\r
3216 {d68000_move_32 , 0xf000, 0x2000, 0xfff},
\r
3217 {d68000_movea_16 , 0xf1c0, 0x3040, 0xfff},
\r
3218 {d68000_movea_32 , 0xf1c0, 0x2040, 0xfff},
\r
3219 {d68000_move_to_ccr , 0xffc0, 0x44c0, 0xbff},
\r
3220 {d68010_move_fr_ccr , 0xffc0, 0x42c0, 0xbf8},
\r
3221 {d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff},
\r
3222 {d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8},
\r
3223 {d68000_move_to_usp , 0xfff8, 0x4e60, 0x000},
\r
3224 {d68000_move_fr_usp , 0xfff8, 0x4e68, 0x000},
\r
3225 {d68010_movec , 0xfffe, 0x4e7a, 0x000},
\r
3226 {d68000_movem_pd_16 , 0xfff8, 0x48a0, 0x000},
\r
3227 {d68000_movem_pd_32 , 0xfff8, 0x48e0, 0x000},
\r
3228 {d68000_movem_re_16 , 0xffc0, 0x4880, 0x2f8},
\r
3229 {d68000_movem_re_32 , 0xffc0, 0x48c0, 0x2f8},
\r
3230 {d68000_movem_er_16 , 0xffc0, 0x4c80, 0x37b},
\r
3231 {d68000_movem_er_32 , 0xffc0, 0x4cc0, 0x37b},
\r
3232 {d68000_movep_er_16 , 0xf1f8, 0x0108, 0x000},
\r
3233 {d68000_movep_er_32 , 0xf1f8, 0x0148, 0x000},
\r
3234 {d68000_movep_re_16 , 0xf1f8, 0x0188, 0x000},
\r
3235 {d68000_movep_re_32 , 0xf1f8, 0x01c8, 0x000},
\r
3236 {d68010_moves_8 , 0xffc0, 0x0e00, 0x3f8},
\r
3237 {d68010_moves_16 , 0xffc0, 0x0e40, 0x3f8},
\r
3238 {d68010_moves_32 , 0xffc0, 0x0e80, 0x3f8},
\r
3239 {d68000_moveq , 0xf100, 0x7000, 0x000},
\r
3240 {d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000},
\r
3241 {d68040_move16_pi_al , 0xfff8, 0xf600, 0x000},
\r
3242 {d68040_move16_al_pi , 0xfff8, 0xf608, 0x000},
\r
3243 {d68040_move16_ai_al , 0xfff8, 0xf610, 0x000},
\r
3244 {d68040_move16_al_ai , 0xfff8, 0xf618, 0x000},
\r
3245 {d68000_muls , 0xf1c0, 0xc1c0, 0xbff},
\r
3246 {d68000_mulu , 0xf1c0, 0xc0c0, 0xbff},
\r
3247 {d68020_mull , 0xffc0, 0x4c00, 0xbff},
\r
3248 {d68000_nbcd , 0xffc0, 0x4800, 0xbf8},
\r
3249 {d68000_neg_8 , 0xffc0, 0x4400, 0xbf8},
\r
3250 {d68000_neg_16 , 0xffc0, 0x4440, 0xbf8},
\r
3251 {d68000_neg_32 , 0xffc0, 0x4480, 0xbf8},
\r
3252 {d68000_negx_8 , 0xffc0, 0x4000, 0xbf8},
\r
3253 {d68000_negx_16 , 0xffc0, 0x4040, 0xbf8},
\r
3254 {d68000_negx_32 , 0xffc0, 0x4080, 0xbf8},
\r
3255 {d68000_nop , 0xffff, 0x4e71, 0x000},
\r
3256 {d68000_not_8 , 0xffc0, 0x4600, 0xbf8},
\r
3257 {d68000_not_16 , 0xffc0, 0x4640, 0xbf8},
\r
3258 {d68000_not_32 , 0xffc0, 0x4680, 0xbf8},
\r
3259 {d68000_or_er_8 , 0xf1c0, 0x8000, 0xbff},
\r
3260 {d68000_or_er_16 , 0xf1c0, 0x8040, 0xbff},
\r
3261 {d68000_or_er_32 , 0xf1c0, 0x8080, 0xbff},
\r
3262 {d68000_or_re_8 , 0xf1c0, 0x8100, 0x3f8},
\r
3263 {d68000_or_re_16 , 0xf1c0, 0x8140, 0x3f8},
\r
3264 {d68000_or_re_32 , 0xf1c0, 0x8180, 0x3f8},
\r
3265 {d68000_ori_to_ccr , 0xffff, 0x003c, 0x000},
\r
3266 {d68000_ori_to_sr , 0xffff, 0x007c, 0x000},
\r
3267 {d68000_ori_8 , 0xffc0, 0x0000, 0xbf8},
\r
3268 {d68000_ori_16 , 0xffc0, 0x0040, 0xbf8},
\r
3269 {d68000_ori_32 , 0xffc0, 0x0080, 0xbf8},
\r
3270 {d68020_pack_rr , 0xf1f8, 0x8140, 0x000},
\r
3271 {d68020_pack_mm , 0xf1f8, 0x8148, 0x000},
\r
3272 {d68000_pea , 0xffc0, 0x4840, 0x27b},
\r
3273 {d68040_pflush , 0xffe0, 0xf500, 0x000},
\r
3274 {d68000_reset , 0xffff, 0x4e70, 0x000},
\r
3275 {d68000_ror_s_8 , 0xf1f8, 0xe018, 0x000},
\r
3276 {d68000_ror_s_16 , 0xf1f8, 0xe058, 0x000},
\r
3277 {d68000_ror_s_32 , 0xf1f8, 0xe098, 0x000},
\r
3278 {d68000_ror_r_8 , 0xf1f8, 0xe038, 0x000},
\r
3279 {d68000_ror_r_16 , 0xf1f8, 0xe078, 0x000},
\r
3280 {d68000_ror_r_32 , 0xf1f8, 0xe0b8, 0x000},
\r
3281 {d68000_ror_ea , 0xffc0, 0xe6c0, 0x3f8},
\r
3282 {d68000_rol_s_8 , 0xf1f8, 0xe118, 0x000},
\r
3283 {d68000_rol_s_16 , 0xf1f8, 0xe158, 0x000},
\r
3284 {d68000_rol_s_32 , 0xf1f8, 0xe198, 0x000},
\r
3285 {d68000_rol_r_8 , 0xf1f8, 0xe138, 0x000},
\r
3286 {d68000_rol_r_16 , 0xf1f8, 0xe178, 0x000},
\r
3287 {d68000_rol_r_32 , 0xf1f8, 0xe1b8, 0x000},
\r
3288 {d68000_rol_ea , 0xffc0, 0xe7c0, 0x3f8},
\r
3289 {d68000_roxr_s_8 , 0xf1f8, 0xe010, 0x000},
\r
3290 {d68000_roxr_s_16 , 0xf1f8, 0xe050, 0x000},
\r
3291 {d68000_roxr_s_32 , 0xf1f8, 0xe090, 0x000},
\r
3292 {d68000_roxr_r_8 , 0xf1f8, 0xe030, 0x000},
\r
3293 {d68000_roxr_r_16 , 0xf1f8, 0xe070, 0x000},
\r
3294 {d68000_roxr_r_32 , 0xf1f8, 0xe0b0, 0x000},
\r
3295 {d68000_roxr_ea , 0xffc0, 0xe4c0, 0x3f8},
\r
3296 {d68000_roxl_s_8 , 0xf1f8, 0xe110, 0x000},
\r
3297 {d68000_roxl_s_16 , 0xf1f8, 0xe150, 0x000},
\r
3298 {d68000_roxl_s_32 , 0xf1f8, 0xe190, 0x000},
\r
3299 {d68000_roxl_r_8 , 0xf1f8, 0xe130, 0x000},
\r
3300 {d68000_roxl_r_16 , 0xf1f8, 0xe170, 0x000},
\r
3301 {d68000_roxl_r_32 , 0xf1f8, 0xe1b0, 0x000},
\r
3302 {d68000_roxl_ea , 0xffc0, 0xe5c0, 0x3f8},
\r
3303 {d68010_rtd , 0xffff, 0x4e74, 0x000},
\r
3304 {d68000_rte , 0xffff, 0x4e73, 0x000},
\r
3305 {d68020_rtm , 0xfff0, 0x06c0, 0x000},
\r
3306 {d68000_rtr , 0xffff, 0x4e77, 0x000},
\r
3307 {d68000_rts , 0xffff, 0x4e75, 0x000},
\r
3308 {d68000_sbcd_rr , 0xf1f8, 0x8100, 0x000},
\r
3309 {d68000_sbcd_mm , 0xf1f8, 0x8108, 0x000},
\r
3310 {d68000_scc , 0xf0c0, 0x50c0, 0xbf8},
\r
3311 {d68000_stop , 0xffff, 0x4e72, 0x000},
\r
3312 {d68000_sub_er_8 , 0xf1c0, 0x9000, 0xbff},
\r
3313 {d68000_sub_er_16 , 0xf1c0, 0x9040, 0xfff},
\r
3314 {d68000_sub_er_32 , 0xf1c0, 0x9080, 0xfff},
\r
3315 {d68000_sub_re_8 , 0xf1c0, 0x9100, 0x3f8},
\r
3316 {d68000_sub_re_16 , 0xf1c0, 0x9140, 0x3f8},
\r
3317 {d68000_sub_re_32 , 0xf1c0, 0x9180, 0x3f8},
\r
3318 {d68000_suba_16 , 0xf1c0, 0x90c0, 0xfff},
\r
3319 {d68000_suba_32 , 0xf1c0, 0x91c0, 0xfff},
\r
3320 {d68000_subi_8 , 0xffc0, 0x0400, 0xbf8},
\r
3321 {d68000_subi_16 , 0xffc0, 0x0440, 0xbf8},
\r
3322 {d68000_subi_32 , 0xffc0, 0x0480, 0xbf8},
\r
3323 {d68000_subq_8 , 0xf1c0, 0x5100, 0xbf8},
\r
3324 {d68000_subq_16 , 0xf1c0, 0x5140, 0xff8},
\r
3325 {d68000_subq_32 , 0xf1c0, 0x5180, 0xff8},
\r
3326 {d68000_subx_rr_8 , 0xf1f8, 0x9100, 0x000},
\r
3327 {d68000_subx_rr_16 , 0xf1f8, 0x9140, 0x000},
\r
3328 {d68000_subx_rr_32 , 0xf1f8, 0x9180, 0x000},
\r
3329 {d68000_subx_mm_8 , 0xf1f8, 0x9108, 0x000},
\r
3330 {d68000_subx_mm_16 , 0xf1f8, 0x9148, 0x000},
\r
3331 {d68000_subx_mm_32 , 0xf1f8, 0x9188, 0x000},
\r
3332 {d68000_swap , 0xfff8, 0x4840, 0x000},
\r
3333 {d68000_tas , 0xffc0, 0x4ac0, 0xbf8},
\r
3334 {d68000_trap , 0xfff0, 0x4e40, 0x000},
\r
3335 {d68020_trapcc_0 , 0xf0ff, 0x50fc, 0x000},
\r
3336 {d68020_trapcc_16 , 0xf0ff, 0x50fa, 0x000},
\r
3337 {d68020_trapcc_32 , 0xf0ff, 0x50fb, 0x000},
\r
3338 {d68000_trapv , 0xffff, 0x4e76, 0x000},
\r
3339 {d68000_tst_8 , 0xffc0, 0x4a00, 0xbf8},
\r
3340 {d68020_tst_pcdi_8 , 0xffff, 0x4a3a, 0x000},
\r
3341 {d68020_tst_pcix_8 , 0xffff, 0x4a3b, 0x000},
\r
3342 {d68020_tst_i_8 , 0xffff, 0x4a3c, 0x000},
\r
3343 {d68000_tst_16 , 0xffc0, 0x4a40, 0xbf8},
\r
3344 {d68020_tst_a_16 , 0xfff8, 0x4a48, 0x000},
\r
3345 {d68020_tst_pcdi_16 , 0xffff, 0x4a7a, 0x000},
\r
3346 {d68020_tst_pcix_16 , 0xffff, 0x4a7b, 0x000},
\r
3347 {d68020_tst_i_16 , 0xffff, 0x4a7c, 0x000},
\r
3348 {d68000_tst_32 , 0xffc0, 0x4a80, 0xbf8},
\r
3349 {d68020_tst_a_32 , 0xfff8, 0x4a88, 0x000},
\r
3350 {d68020_tst_pcdi_32 , 0xffff, 0x4aba, 0x000},
\r
3351 {d68020_tst_pcix_32 , 0xffff, 0x4abb, 0x000},
\r
3352 {d68020_tst_i_32 , 0xffff, 0x4abc, 0x000},
\r
3353 {d68000_unlk , 0xfff8, 0x4e58, 0x000},
\r
3354 {d68020_unpk_rr , 0xf1f8, 0x8180, 0x000},
\r
3355 {d68020_unpk_mm , 0xf1f8, 0x8188, 0x000},
\r
3359 /* Check if opcode is using a valid ea mode */
\r
3360 static int valid_ea(uint opcode, uint mask)
\r
3365 switch(opcode & 0x3f)
\r
3367 case 0x00: case 0x01: case 0x02: case 0x03:
\r
3368 case 0x04: case 0x05: case 0x06: case 0x07:
\r
3369 return (mask & 0x800) != 0;
\r
3370 case 0x08: case 0x09: case 0x0a: case 0x0b:
\r
3371 case 0x0c: case 0x0d: case 0x0e: case 0x0f:
\r
3372 return (mask & 0x400) != 0;
\r
3373 case 0x10: case 0x11: case 0x12: case 0x13:
\r
3374 case 0x14: case 0x15: case 0x16: case 0x17:
\r
3375 return (mask & 0x200) != 0;
\r
3376 case 0x18: case 0x19: case 0x1a: case 0x1b:
\r
3377 case 0x1c: case 0x1d: case 0x1e: case 0x1f:
\r
3378 return (mask & 0x100) != 0;
\r
3379 case 0x20: case 0x21: case 0x22: case 0x23:
\r
3380 case 0x24: case 0x25: case 0x26: case 0x27:
\r
3381 return (mask & 0x080) != 0;
\r
3382 case 0x28: case 0x29: case 0x2a: case 0x2b:
\r
3383 case 0x2c: case 0x2d: case 0x2e: case 0x2f:
\r
3384 return (mask & 0x040) != 0;
\r
3385 case 0x30: case 0x31: case 0x32: case 0x33:
\r
3386 case 0x34: case 0x35: case 0x36: case 0x37:
\r
3387 return (mask & 0x020) != 0;
\r
3389 return (mask & 0x010) != 0;
\r
3391 return (mask & 0x008) != 0;
\r
3393 return (mask & 0x002) != 0;
\r
3395 return (mask & 0x001) != 0;
\r
3397 return (mask & 0x004) != 0;
\r
3403 /* Used by qsort */
\r
3404 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr)
\r
3406 uint a = ((const opcode_struct*)aptr)->mask;
\r
3407 uint b = ((const opcode_struct*)bptr)->mask;
\r
3409 a = ((a & 0xAAAA) >> 1) + (a & 0x5555);
\r
3410 a = ((a & 0xCCCC) >> 2) + (a & 0x3333);
\r
3411 a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F);
\r
3412 a = ((a & 0xFF00) >> 8) + (a & 0x00FF);
\r
3414 b = ((b & 0xAAAA) >> 1) + (b & 0x5555);
\r
3415 b = ((b & 0xCCCC) >> 2) + (b & 0x3333);
\r
3416 b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F);
\r
3417 b = ((b & 0xFF00) >> 8) + (b & 0x00FF);
\r
3419 return b - a; /* reversed to get greatest to least sorting */
\r
3422 /* build the opcode handler jump table */
\r
3423 static void build_opcode_table(void)
\r
3427 opcode_struct* ostruct;
\r
3428 uint opcode_info_length = 0;
\r
3430 for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
\r
3431 opcode_info_length++;
\r
3433 qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits);
\r
3435 for(i=0;i<0x10000;i++)
\r
3437 g_instruction_table[i] = d68000_illegal; /* default to illegal */
\r
3439 /* search through opcode info for a match */
\r
3440 for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
\r
3442 /* match opcode mask and allowed ea modes */
\r
3443 if((opcode & ostruct->mask) == ostruct->match)
\r
3445 /* Handle destination ea for move instructions */
\r
3446 if((ostruct->opcode_handler == d68000_move_8 ||
\r
3447 ostruct->opcode_handler == d68000_move_16 ||
\r
3448 ostruct->opcode_handler == d68000_move_32) &&
\r
3449 !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8))
\r
3451 if(valid_ea(opcode, ostruct->ea_mask))
\r
3453 g_instruction_table[i] = ostruct->opcode_handler;
\r
3463 /* ======================================================================== */
\r
3464 /* ================================= API ================================== */
\r
3465 /* ======================================================================== */
\r
3467 /* Disasemble one instruction at pc and store in str_buff */
\r
3468 unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type)
\r
3470 if(!g_initialized)
\r
3472 build_opcode_table();
\r
3473 g_initialized = 1;
\r
3477 case M68K_CPU_TYPE_68000:
\r
3478 g_cpu_type = TYPE_68000;
\r
3479 g_address_mask = 0x00ffffff;
\r
3481 case M68K_CPU_TYPE_68008:
\r
3482 g_cpu_type = TYPE_68008;
\r
3483 g_address_mask = 0x003fffff;
\r
3485 case M68K_CPU_TYPE_68010:
\r
3486 g_cpu_type = TYPE_68010;
\r
3487 g_address_mask = 0x00ffffff;
\r
3489 case M68K_CPU_TYPE_68EC020:
\r
3490 g_cpu_type = TYPE_68020;
\r
3491 g_address_mask = 0x00ffffff;
\r
3493 case M68K_CPU_TYPE_68020:
\r
3494 g_cpu_type = TYPE_68020;
\r
3495 g_address_mask = 0xffffffff;
\r
3497 case M68K_CPU_TYPE_68030:
\r
3498 g_cpu_type = TYPE_68030;
\r
3499 g_address_mask = 0xffffffff;
\r
3501 case M68K_CPU_TYPE_68040:
\r
3502 g_cpu_type = TYPE_68040;
\r
3503 g_address_mask = 0xffffffff;
\r
3510 g_helper_str[0] = 0;
\r
3511 g_cpu_ir = read_imm_16();
\r
3512 g_opcode_type = 0;
\r
3513 g_instruction_table[g_cpu_ir]();
\r
3514 sprintf(str_buff, "%s%s", g_dasm_str, g_helper_str);
\r
3515 return COMBINE_OPCODE_FLAGS(g_cpu_pc - pc);
\r
3518 char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type)
\r
3520 static char buff[100];
\r
3522 m68k_disassemble(buff, pc, cpu_type);
\r
3526 unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type)
\r
3528 unsigned int result;
\r
3532 result = m68k_disassemble(str_buff, pc, cpu_type);
\r
3537 /* Check if the instruction is a valid one */
\r
3538 unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type)
\r
3540 if(!g_initialized)
\r
3542 build_opcode_table();
\r
3543 g_initialized = 1;
\r
3546 instruction &= 0xffff;
\r
3547 if(g_instruction_table[instruction] == d68000_illegal)
\r
3552 case M68K_CPU_TYPE_68000:
\r
3553 case M68K_CPU_TYPE_68008:
\r
3554 if(g_instruction_table[instruction] == d68010_bkpt)
\r
3556 if(g_instruction_table[instruction] == d68010_move_fr_ccr)
\r
3558 if(g_instruction_table[instruction] == d68010_movec)
\r
3560 if(g_instruction_table[instruction] == d68010_moves_8)
\r
3562 if(g_instruction_table[instruction] == d68010_moves_16)
\r
3564 if(g_instruction_table[instruction] == d68010_moves_32)
\r
3566 if(g_instruction_table[instruction] == d68010_rtd)
\r
3568 case M68K_CPU_TYPE_68010:
\r
3569 if(g_instruction_table[instruction] == d68020_bcc_32)
\r
3571 if(g_instruction_table[instruction] == d68020_bfchg)
\r
3573 if(g_instruction_table[instruction] == d68020_bfclr)
\r
3575 if(g_instruction_table[instruction] == d68020_bfexts)
\r
3577 if(g_instruction_table[instruction] == d68020_bfextu)
\r
3579 if(g_instruction_table[instruction] == d68020_bfffo)
\r
3581 if(g_instruction_table[instruction] == d68020_bfins)
\r
3583 if(g_instruction_table[instruction] == d68020_bfset)
\r
3585 if(g_instruction_table[instruction] == d68020_bftst)
\r
3587 if(g_instruction_table[instruction] == d68020_bra_32)
\r
3589 if(g_instruction_table[instruction] == d68020_bsr_32)
\r
3591 if(g_instruction_table[instruction] == d68020_callm)
\r
3593 if(g_instruction_table[instruction] == d68020_cas_8)
\r
3595 if(g_instruction_table[instruction] == d68020_cas_16)
\r
3597 if(g_instruction_table[instruction] == d68020_cas_32)
\r
3599 if(g_instruction_table[instruction] == d68020_cas2_16)
\r
3601 if(g_instruction_table[instruction] == d68020_cas2_32)
\r
3603 if(g_instruction_table[instruction] == d68020_chk_32)
\r
3605 if(g_instruction_table[instruction] == d68020_chk2_cmp2_8)
\r
3607 if(g_instruction_table[instruction] == d68020_chk2_cmp2_16)
\r
3609 if(g_instruction_table[instruction] == d68020_chk2_cmp2_32)
\r
3611 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_8)
\r
3613 if(g_instruction_table[instruction] == d68020_cmpi_pcix_8)
\r
3615 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_16)
\r
3617 if(g_instruction_table[instruction] == d68020_cmpi_pcix_16)
\r
3619 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_32)
\r
3621 if(g_instruction_table[instruction] == d68020_cmpi_pcix_32)
\r
3623 if(g_instruction_table[instruction] == d68020_cpbcc_16)
\r
3625 if(g_instruction_table[instruction] == d68020_cpbcc_32)
\r
3627 if(g_instruction_table[instruction] == d68020_cpdbcc)
\r
3629 if(g_instruction_table[instruction] == d68020_cpgen)
\r
3631 if(g_instruction_table[instruction] == d68020_cprestore)
\r
3633 if(g_instruction_table[instruction] == d68020_cpsave)
\r
3635 if(g_instruction_table[instruction] == d68020_cpscc)
\r
3637 if(g_instruction_table[instruction] == d68020_cptrapcc_0)
\r
3639 if(g_instruction_table[instruction] == d68020_cptrapcc_16)
\r
3641 if(g_instruction_table[instruction] == d68020_cptrapcc_32)
\r
3643 if(g_instruction_table[instruction] == d68020_divl)
\r
3645 if(g_instruction_table[instruction] == d68020_extb_32)
\r
3647 if(g_instruction_table[instruction] == d68020_link_32)
\r
3649 if(g_instruction_table[instruction] == d68020_mull)
\r
3651 if(g_instruction_table[instruction] == d68020_pack_rr)
\r
3653 if(g_instruction_table[instruction] == d68020_pack_mm)
\r
3655 if(g_instruction_table[instruction] == d68020_rtm)
\r
3657 if(g_instruction_table[instruction] == d68020_trapcc_0)
\r
3659 if(g_instruction_table[instruction] == d68020_trapcc_16)
\r
3661 if(g_instruction_table[instruction] == d68020_trapcc_32)
\r
3663 if(g_instruction_table[instruction] == d68020_tst_pcdi_8)
\r
3665 if(g_instruction_table[instruction] == d68020_tst_pcix_8)
\r
3667 if(g_instruction_table[instruction] == d68020_tst_i_8)
\r
3669 if(g_instruction_table[instruction] == d68020_tst_a_16)
\r
3671 if(g_instruction_table[instruction] == d68020_tst_pcdi_16)
\r
3673 if(g_instruction_table[instruction] == d68020_tst_pcix_16)
\r
3675 if(g_instruction_table[instruction] == d68020_tst_i_16)
\r
3677 if(g_instruction_table[instruction] == d68020_tst_a_32)
\r
3679 if(g_instruction_table[instruction] == d68020_tst_pcdi_32)
\r
3681 if(g_instruction_table[instruction] == d68020_tst_pcix_32)
\r
3683 if(g_instruction_table[instruction] == d68020_tst_i_32)
\r
3685 if(g_instruction_table[instruction] == d68020_unpk_rr)
\r
3687 if(g_instruction_table[instruction] == d68020_unpk_mm)
\r
3689 case M68K_CPU_TYPE_68EC020:
\r
3690 case M68K_CPU_TYPE_68020:
\r
3691 case M68K_CPU_TYPE_68030:
\r
3692 if(g_instruction_table[instruction] == d68040_cinv)
\r
3694 if(g_instruction_table[instruction] == d68040_cpush)
\r
3696 if(g_instruction_table[instruction] == d68040_move16_pi_pi)
\r
3698 if(g_instruction_table[instruction] == d68040_move16_pi_al)
\r
3700 if(g_instruction_table[instruction] == d68040_move16_al_pi)
\r
3702 if(g_instruction_table[instruction] == d68040_move16_ai_al)
\r
3704 if(g_instruction_table[instruction] == d68040_move16_al_ai)
\r
3706 if(g_instruction_table[instruction] == d68040_pflush)
\r
3708 case M68K_CPU_TYPE_68040:
\r
3709 if(g_instruction_table[instruction] == d68020_cpbcc_16)
\r
3711 if(g_instruction_table[instruction] == d68020_cpbcc_32)
\r
3713 if(g_instruction_table[instruction] == d68020_cpdbcc)
\r
3715 if(g_instruction_table[instruction] == d68020_cpgen)
\r
3717 if(g_instruction_table[instruction] == d68020_cprestore)
\r
3719 if(g_instruction_table[instruction] == d68020_cpsave)
\r
3721 if(g_instruction_table[instruction] == d68020_cpscc)
\r
3723 if(g_instruction_table[instruction] == d68020_cptrapcc_0)
\r
3725 if(g_instruction_table[instruction] == d68020_cptrapcc_16)
\r
3727 if(g_instruction_table[instruction] == d68020_cptrapcc_32)
\r
3730 if(cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 &&
\r
3731 (g_instruction_table[instruction] == d68020_callm ||
\r
3732 g_instruction_table[instruction] == d68020_rtm))
\r
3740 /* ======================================================================== */
\r
3741 /* ============================== END OF FILE ============================= */
\r
3742 /* ======================================================================== */
\r