1 /* ======================================================================== */
2 /* ========================= LICENSING & COPYRIGHT ======================== */
3 /* ======================================================================== */
8 * A portable Motorola M680x0 processor emulation engine.
9 * Copyright 1998-2001 Karl Stenerud. All rights reserved.
11 * This code may be freely used for non-commercial purposes as long as this
12 * copyright notice remains unaltered in the source code and any binary files
13 * containing this code in compiled form.
15 * All other lisencing terms must be negotiated with the author
18 * The latest version of this code can be obtained at:
19 * http://kstenerud.cjb.net
24 /* ======================================================================== */
25 /* ================================ INCLUDES ============================== */
26 /* ======================================================================== */
33 /* ======================================================================== */
34 /* ============================ GENERAL DEFINES =========================== */
35 /* ======================================================================== */
37 /* unsigned int and int must be at least 32 bits wide */
39 #define uint unsigned int
41 /* Bit Isolation Functions */
42 #define BIT_0(A) ((A) & 0x00000001)
43 #define BIT_1(A) ((A) & 0x00000002)
44 #define BIT_2(A) ((A) & 0x00000004)
45 #define BIT_3(A) ((A) & 0x00000008)
46 #define BIT_4(A) ((A) & 0x00000010)
47 #define BIT_5(A) ((A) & 0x00000020)
48 #define BIT_6(A) ((A) & 0x00000040)
49 #define BIT_7(A) ((A) & 0x00000080)
50 #define BIT_8(A) ((A) & 0x00000100)
51 #define BIT_9(A) ((A) & 0x00000200)
52 #define BIT_A(A) ((A) & 0x00000400)
53 #define BIT_B(A) ((A) & 0x00000800)
54 #define BIT_C(A) ((A) & 0x00001000)
55 #define BIT_D(A) ((A) & 0x00002000)
56 #define BIT_E(A) ((A) & 0x00004000)
57 #define BIT_F(A) ((A) & 0x00008000)
58 #define BIT_10(A) ((A) & 0x00010000)
59 #define BIT_11(A) ((A) & 0x00020000)
60 #define BIT_12(A) ((A) & 0x00040000)
61 #define BIT_13(A) ((A) & 0x00080000)
62 #define BIT_14(A) ((A) & 0x00100000)
63 #define BIT_15(A) ((A) & 0x00200000)
64 #define BIT_16(A) ((A) & 0x00400000)
65 #define BIT_17(A) ((A) & 0x00800000)
66 #define BIT_18(A) ((A) & 0x01000000)
67 #define BIT_19(A) ((A) & 0x02000000)
68 #define BIT_1A(A) ((A) & 0x04000000)
69 #define BIT_1B(A) ((A) & 0x08000000)
70 #define BIT_1C(A) ((A) & 0x10000000)
71 #define BIT_1D(A) ((A) & 0x20000000)
72 #define BIT_1E(A) ((A) & 0x40000000)
73 #define BIT_1F(A) ((A) & 0x80000000)
75 /* These are the CPU types understood by this disassembler */
82 #define M68000_ONLY TYPE_68000
84 #define M68010_ONLY TYPE_68010
85 #define M68010_LESS (TYPE_68000 | TYPE_68010)
86 #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040)
88 #define M68020_ONLY TYPE_68020
89 #define M68020_LESS (TYPE_68010 | TYPE_68020)
90 #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040)
92 #define M68030_ONLY TYPE_68030
93 #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030)
94 #define M68030_PLUS (TYPE_68030 | TYPE_68040)
96 #define M68040_PLUS TYPE_68040
99 /* Extension word formats */
100 #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff)
101 #define EXT_FULL(A) BIT_8(A)
102 #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0)
103 #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A))
104 #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A))
105 #define EXT_INDEX_REGISTER(A) (((A)>>12)&7)
106 #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3)
107 #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0)
108 #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4)
109 #define EXT_INDEX_SCALE(A) (((A)>>9)&3)
110 #define EXT_INDEX_LONG(A) BIT_B(A)
111 #define EXT_INDEX_AR(A) BIT_F(A)
112 #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10)
113 #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20)
114 #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30)
115 #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44)
116 #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44)
117 #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44)
121 /* ======================================================================== */
122 /* =============================== PROTOTYPES ============================= */
123 /* ======================================================================== */
125 /* Read data at the PC and increment PC */
126 uint read_imm_8(void);
127 uint read_imm_16(void);
128 uint read_imm_32(void);
130 /* Read data at the PC but don't imcrement the PC */
131 uint peek_imm_8(void);
132 uint peek_imm_16(void);
133 uint peek_imm_32(void);
135 /* make signed integers 100% portably */
136 static int make_int_8(int value);
137 static int make_int_16(int value);
139 /* make a string of a hex value */
140 static char* make_signed_hex_str_8(uint val);
141 static char* make_signed_hex_str_16(uint val);
142 static char* make_signed_hex_str_32(uint val);
144 /* make string of ea mode */
145 static char* get_ea_mode_str(uint instruction, uint size);
147 char* get_ea_mode_str_8(uint instruction);
148 char* get_ea_mode_str_16(uint instruction);
149 char* get_ea_mode_str_32(uint instruction);
151 /* make string of immediate value */
152 static char* get_imm_str_s(uint size);
153 static char* get_imm_str_u(uint size);
155 char* get_imm_str_s8(void);
156 char* get_imm_str_s16(void);
157 char* get_imm_str_s32(void);
159 /* Stuff to build the opcode handler jump table */
160 static void build_opcode_table(void);
161 static int valid_ea(uint opcode, uint mask);
162 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr);
164 /* used to build opcode handler jump table */
167 void (*opcode_handler)(void); /* handler function */
168 uint mask; /* mask on opcode */
169 uint match; /* what to match after masking */
170 uint ea_mask; /* what ea modes are allowed */
175 /* ======================================================================== */
176 /* ================================= DATA ================================= */
177 /* ======================================================================== */
179 /* Opcode handler jump table */
180 static void (*g_instruction_table[0x10000])(void);
181 /* Flag if disassembler initialized */
182 static int g_initialized = 0;
184 /* Address mask to simulate address lines */
185 static unsigned int g_address_mask = 0xffffffff;
187 static char g_dasm_str[100]; /* string to hold disassembly */
188 static char g_helper_str[100]; /* string to hold helpful info */
189 static uint g_cpu_pc; /* program counter */
190 static uint g_cpu_ir; /* instruction register */
191 static uint g_cpu_type;
193 /* used by ops like asr, ror, addq, etc */
194 static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
196 static uint g_5bit_data_table[32] =
198 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
199 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
202 static char* g_cc[16] =
203 {"t", "f", "hi", "ls", "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi", "ge", "lt", "gt", "le"};
205 static char* g_cpcc[64] =
206 {/* 000 001 010 011 100 101 110 111 */
207 "f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */
208 "un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */
209 "sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */
210 "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */
211 "?", "?", "?", "?", "?", "?", "?", "?", /* 100 */
212 "?", "?", "?", "?", "?", "?", "?", "?", /* 101 */
213 "?", "?", "?", "?", "?", "?", "?", "?", /* 110 */
214 "?", "?", "?", "?", "?", "?", "?", "?" /* 111 */
218 /* ======================================================================== */
219 /* =========================== UTILITY FUNCTIONS ========================== */
220 /* ======================================================================== */
222 #define LIMIT_CPU_TYPES(ALLOWED_CPU_TYPES) \
223 if(!(g_cpu_type & ALLOWED_CPU_TYPES)) \
229 #define read_imm_8() (m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)&0xff)
230 #define read_imm_16() m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)
231 #define read_imm_32() m68k_read_disassembler_32(((g_cpu_pc+=4)-4)&g_address_mask)
233 #define peek_imm_8() (m68k_read_disassembler_16(g_cpu_pc & g_address_mask)&0xff)
234 #define peek_imm_16() m68k_read_disassembler_16(g_cpu_pc & g_address_mask)
235 #define peek_imm_32() m68k_read_disassembler_32(g_cpu_pc & g_address_mask)
237 /* Fake a split interface */
238 #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0)
239 #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1)
240 #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2)
242 #define get_imm_str_s8() get_imm_str_s(0)
243 #define get_imm_str_s16() get_imm_str_s(1)
244 #define get_imm_str_s32() get_imm_str_s(2)
246 #define get_imm_str_u8() get_imm_str_u(0)
247 #define get_imm_str_u16() get_imm_str_u(1)
248 #define get_imm_str_u32() get_imm_str_u(2)
251 /* 100% portable signed int generators */
252 static int make_int_8(int value)
254 return (value & 0x80) ? value | ~0xff : value & 0xff;
257 static int make_int_16(int value)
259 return (value & 0x8000) ? value | ~0xffff : value & 0xffff;
263 /* Get string representation of hex values */
264 static char* make_signed_hex_str_8(uint val)
271 sprintf(str, "-$80");
273 sprintf(str, "-$%X", (0-val) & 0x7f);
275 sprintf(str, "$%X", val & 0x7f);
280 static char* make_signed_hex_str_16(uint val)
287 sprintf(str, "-$8000");
288 else if(val & 0x8000)
289 sprintf(str, "-$%X", (0-val) & 0x7fff);
291 sprintf(str, "$%X", val & 0x7fff);
296 static char* make_signed_hex_str_32(uint val)
302 if(val == 0x80000000)
303 sprintf(str, "-$80000000");
304 else if(val & 0x80000000)
305 sprintf(str, "-$%X", (0-val) & 0x7fffffff);
307 sprintf(str, "$%X", val & 0x7fffffff);
313 /* make string of immediate value */
314 static char* get_imm_str_s(uint size)
318 sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8()));
320 sprintf(str, "#%s", make_signed_hex_str_16(read_imm_16()));
322 sprintf(str, "#%s", make_signed_hex_str_32(read_imm_32()));
326 static char* get_imm_str_u(uint size)
330 sprintf(str, "#$%X", read_imm_8() & 0xff);
332 sprintf(str, "#$%X", read_imm_16() & 0xffff);
334 sprintf(str, "#$%X", read_imm_32() & 0xffffffff);
338 /* Make string of effective address mode */
339 static char* get_ea_mode_str(uint instruction, uint size)
343 static char* mode = b2;
354 /* Switch buffers so we don't clobber on a double-call to this function */
355 mode = mode == b1 ? b2 : b1;
357 switch(instruction & 0x3f)
359 case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
360 /* data register direct */
361 sprintf(mode, "D%d", instruction&7);
363 case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
364 /* address register direct */
365 sprintf(mode, "A%d", instruction&7);
367 case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
368 /* address register indirect */
369 sprintf(mode, "(A%d)", instruction&7);
371 case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
372 /* address register indirect with postincrement */
373 sprintf(mode, "(A%d)+", instruction&7);
375 case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
376 /* address register indirect with predecrement */
377 sprintf(mode, "-(A%d)", instruction&7);
379 case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
380 /* address register indirect with displacement*/
381 sprintf(mode, "(%s,A%d)", make_signed_hex_str_16(read_imm_16()), instruction&7);
383 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
384 /* address register indirect with index */
385 extension = read_imm_16();
387 if(EXT_FULL(extension))
389 if(EXT_EFFECTIVE_ZERO(extension))
394 base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
395 outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
396 if(EXT_BASE_REGISTER_PRESENT(extension))
397 sprintf(base_reg, "A%d", instruction&7);
400 if(EXT_INDEX_REGISTER_PRESENT(extension))
402 sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
403 if(EXT_INDEX_SCALE(extension))
404 sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
408 preindex = (extension&7) > 0 && (extension&7) < 4;
409 postindex = (extension&7) > 4;
412 if(preindex || postindex)
416 strcat(mode, make_signed_hex_str_16(base));
423 strcat(mode, base_reg);
435 strcat(mode, index_reg);
447 strcat(mode, make_signed_hex_str_16(outer));
453 if(EXT_8BIT_DISPLACEMENT(extension) == 0)
454 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');
456 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');
457 if(EXT_INDEX_SCALE(extension))
458 sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
462 /* absolute short address */
463 sprintf(mode, "$%X.w", read_imm_16());
466 /* absolute long address */
467 sprintf(mode, "$%X.l", read_imm_32());
470 /* program counter with displacement */
471 temp_value = read_imm_16();
472 sprintf(mode, "(%s,PC)", make_signed_hex_str_16(temp_value));
473 sprintf(g_helper_str, "; ($%X)", (make_int_16(temp_value) + g_cpu_pc-2) & 0xffffffff);
476 /* program counter with index */
477 extension = read_imm_16();
479 if(EXT_FULL(extension))
481 if(EXT_EFFECTIVE_ZERO(extension))
486 base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
487 outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
488 if(EXT_BASE_REGISTER_PRESENT(extension))
489 strcpy(base_reg, "PC");
492 if(EXT_INDEX_REGISTER_PRESENT(extension))
494 sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
495 if(EXT_INDEX_SCALE(extension))
496 sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
500 preindex = (extension&7) > 0 && (extension&7) < 4;
501 postindex = (extension&7) > 4;
504 if(preindex || postindex)
508 strcat(mode, make_signed_hex_str_16(base));
515 strcat(mode, base_reg);
527 strcat(mode, index_reg);
539 strcat(mode, make_signed_hex_str_16(outer));
545 if(EXT_8BIT_DISPLACEMENT(extension) == 0)
546 sprintf(mode, "(PC,%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
548 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');
549 if(EXT_INDEX_SCALE(extension))
550 sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
555 sprintf(mode, "%s", get_imm_str_u(size));
558 sprintf(mode, "INVALID %X", instruction & 0x3f);
565 /* ======================================================================== */
566 /* ========================= INSTRUCTION HANDLERS ========================= */
567 /* ======================================================================== */
568 /* Instruction handler function names follow this convention:
570 * d68000_NAME_EXTENSIONS(void)
571 * where NAME is the name of the opcode it handles and EXTENSIONS are any
572 * extensions for special instances of that opcode.
575 * d68000_add_er_8(): add opcode, from effective address to register,
578 * d68000_asr_s_8(): arithmetic shift right, static count, size = byte
585 * rr : register to register
586 * mm : memory to memory
589 * er : effective address -> register
590 * re : register -> effective address
591 * ea : using effective address mode of operation
592 * d : data register direct
593 * a : address register direct
594 * ai : address register indirect
595 * pi : address register indirect with postincrement
596 * pd : address register indirect with predecrement
597 * di : address register indirect with displacement
598 * ix : address register indirect with index
603 static void d68000_illegal(void)
605 sprintf(g_dasm_str, "dc.w $%04x; ILLEGAL", g_cpu_ir);
608 static void d68000_1010(void)
610 sprintf(g_dasm_str, "dc.w $%04x; opcode 1010", g_cpu_ir);
614 static void d68000_1111(void)
616 sprintf(g_dasm_str, "dc.w $%04x; opcode 1111", g_cpu_ir);
620 static void d68000_abcd_rr(void)
622 sprintf(g_dasm_str, "abcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
626 static void d68000_abcd_mm(void)
628 sprintf(g_dasm_str, "abcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
631 static void d68000_add_er_8(void)
633 sprintf(g_dasm_str, "add.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
637 static void d68000_add_er_16(void)
639 sprintf(g_dasm_str, "add.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
642 static void d68000_add_er_32(void)
644 sprintf(g_dasm_str, "add.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
647 static void d68000_add_re_8(void)
649 sprintf(g_dasm_str, "add.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
652 static void d68000_add_re_16(void)
654 sprintf(g_dasm_str, "add.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
657 static void d68000_add_re_32(void)
659 sprintf(g_dasm_str, "add.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
662 static void d68000_adda_16(void)
664 sprintf(g_dasm_str, "adda.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
667 static void d68000_adda_32(void)
669 sprintf(g_dasm_str, "adda.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
672 static void d68000_addi_8(void)
674 char* str = get_imm_str_s8();
675 sprintf(g_dasm_str, "addi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
678 static void d68000_addi_16(void)
680 char* str = get_imm_str_s16();
681 sprintf(g_dasm_str, "addi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
684 static void d68000_addi_32(void)
686 char* str = get_imm_str_s32();
687 sprintf(g_dasm_str, "addi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
690 static void d68000_addq_8(void)
692 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));
695 static void d68000_addq_16(void)
697 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));
700 static void d68000_addq_32(void)
702 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));
705 static void d68000_addx_rr_8(void)
707 sprintf(g_dasm_str, "addx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
710 static void d68000_addx_rr_16(void)
712 sprintf(g_dasm_str, "addx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
715 static void d68000_addx_rr_32(void)
717 sprintf(g_dasm_str, "addx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
720 static void d68000_addx_mm_8(void)
722 sprintf(g_dasm_str, "addx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
725 static void d68000_addx_mm_16(void)
727 sprintf(g_dasm_str, "addx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
730 static void d68000_addx_mm_32(void)
732 sprintf(g_dasm_str, "addx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
735 static void d68000_and_er_8(void)
737 sprintf(g_dasm_str, "and.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
740 static void d68000_and_er_16(void)
742 sprintf(g_dasm_str, "and.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
745 static void d68000_and_er_32(void)
747 sprintf(g_dasm_str, "and.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
750 static void d68000_and_re_8(void)
752 sprintf(g_dasm_str, "and.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
755 static void d68000_and_re_16(void)
757 sprintf(g_dasm_str, "and.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
760 static void d68000_and_re_32(void)
762 sprintf(g_dasm_str, "and.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
765 static void d68000_andi_8(void)
767 char* str = get_imm_str_u8();
768 sprintf(g_dasm_str, "andi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
771 static void d68000_andi_16(void)
773 char* str = get_imm_str_u16();
774 sprintf(g_dasm_str, "andi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
777 static void d68000_andi_32(void)
779 char* str = get_imm_str_u32();
780 sprintf(g_dasm_str, "andi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
783 static void d68000_andi_to_ccr(void)
785 sprintf(g_dasm_str, "andi %s, CCR", get_imm_str_u8());
788 static void d68000_andi_to_sr(void)
790 sprintf(g_dasm_str, "andi %s, SR", get_imm_str_u16());
793 static void d68000_asr_s_8(void)
795 sprintf(g_dasm_str, "asr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
798 static void d68000_asr_s_16(void)
800 sprintf(g_dasm_str, "asr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
803 static void d68000_asr_s_32(void)
805 sprintf(g_dasm_str, "asr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
808 static void d68000_asr_r_8(void)
810 sprintf(g_dasm_str, "asr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
813 static void d68000_asr_r_16(void)
815 sprintf(g_dasm_str, "asr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
818 static void d68000_asr_r_32(void)
820 sprintf(g_dasm_str, "asr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
823 static void d68000_asr_ea(void)
825 sprintf(g_dasm_str, "asr.w %s", get_ea_mode_str_16(g_cpu_ir));
828 static void d68000_asl_s_8(void)
830 sprintf(g_dasm_str, "asl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
833 static void d68000_asl_s_16(void)
835 sprintf(g_dasm_str, "asl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
838 static void d68000_asl_s_32(void)
840 sprintf(g_dasm_str, "asl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
843 static void d68000_asl_r_8(void)
845 sprintf(g_dasm_str, "asl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
848 static void d68000_asl_r_16(void)
850 sprintf(g_dasm_str, "asl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
853 static void d68000_asl_r_32(void)
855 sprintf(g_dasm_str, "asl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
858 static void d68000_asl_ea(void)
860 sprintf(g_dasm_str, "asl.w %s", get_ea_mode_str_16(g_cpu_ir));
863 static void d68000_bcc_8(void)
865 uint temp_pc = g_cpu_pc;
866 sprintf(g_dasm_str, "b%-2s %X", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_8(g_cpu_ir));
869 static void d68000_bcc_16(void)
871 uint temp_pc = g_cpu_pc;
872 sprintf(g_dasm_str, "b%-2s %X", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_16(read_imm_16()));
875 static void d68020_bcc_32(void)
877 uint temp_pc = g_cpu_pc;
878 LIMIT_CPU_TYPES(M68020_PLUS);
879 sprintf(g_dasm_str, "b%-2s %X; (2+)", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + read_imm_32());
882 static void d68000_bchg_r(void)
884 sprintf(g_dasm_str, "bchg D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
887 static void d68000_bchg_s(void)
889 char* str = get_imm_str_u8();
890 sprintf(g_dasm_str, "bchg %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
893 static void d68000_bclr_r(void)
895 sprintf(g_dasm_str, "bclr D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
898 static void d68000_bclr_s(void)
900 char* str = get_imm_str_u8();
901 sprintf(g_dasm_str, "bclr %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
904 static void d68010_bkpt(void)
906 LIMIT_CPU_TYPES(M68010_PLUS);
907 sprintf(g_dasm_str, "bkpt #%d; (1+)", g_cpu_ir&7);
910 static void d68020_bfchg(void)
916 LIMIT_CPU_TYPES(M68020_PLUS);
918 extension = read_imm_16();
921 sprintf(offset, "D%d", (extension>>6)&7);
923 sprintf(offset, "%d", (extension>>6)&31);
925 sprintf(width, "D%d", extension&7);
927 sprintf(width, "%d", g_5bit_data_table[extension&31]);
928 sprintf(g_dasm_str, "bfchg %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
931 static void d68020_bfclr(void)
937 LIMIT_CPU_TYPES(M68020_PLUS);
939 extension = read_imm_16();
942 sprintf(offset, "D%d", (extension>>6)&7);
944 sprintf(offset, "%d", (extension>>6)&31);
946 sprintf(width, "D%d", extension&7);
948 sprintf(width, "%d", g_5bit_data_table[extension&31]);
949 sprintf(g_dasm_str, "bfclr %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
952 static void d68020_bfexts(void)
958 LIMIT_CPU_TYPES(M68020_PLUS);
960 extension = read_imm_16();
963 sprintf(offset, "D%d", (extension>>6)&7);
965 sprintf(offset, "%d", (extension>>6)&31);
967 sprintf(width, "D%d", extension&7);
969 sprintf(width, "%d", g_5bit_data_table[extension&31]);
970 sprintf(g_dasm_str, "bfexts D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
973 static void d68020_bfextu(void)
979 LIMIT_CPU_TYPES(M68020_PLUS);
981 extension = read_imm_16();
984 sprintf(offset, "D%d", (extension>>6)&7);
986 sprintf(offset, "%d", (extension>>6)&31);
988 sprintf(width, "D%d", extension&7);
990 sprintf(width, "%d", g_5bit_data_table[extension&31]);
991 sprintf(g_dasm_str, "bfextu D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
994 static void d68020_bfffo(void)
1000 LIMIT_CPU_TYPES(M68020_PLUS);
1002 extension = read_imm_16();
1004 if(BIT_B(extension))
1005 sprintf(offset, "D%d", (extension>>6)&7);
1007 sprintf(offset, "%d", (extension>>6)&31);
1008 if(BIT_5(extension))
1009 sprintf(width, "D%d", extension&7);
1011 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1012 sprintf(g_dasm_str, "bfffo D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
1015 static void d68020_bfins(void)
1021 LIMIT_CPU_TYPES(M68020_PLUS);
1023 extension = read_imm_16();
1025 if(BIT_B(extension))
1026 sprintf(offset, "D%d", (extension>>6)&7);
1028 sprintf(offset, "%d", (extension>>6)&31);
1029 if(BIT_5(extension))
1030 sprintf(width, "D%d", extension&7);
1032 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1033 sprintf(g_dasm_str, "bfins D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
1036 static void d68020_bfset(void)
1042 LIMIT_CPU_TYPES(M68020_PLUS);
1044 extension = read_imm_16();
1046 if(BIT_B(extension))
1047 sprintf(offset, "D%d", (extension>>6)&7);
1049 sprintf(offset, "%d", (extension>>6)&31);
1050 if(BIT_5(extension))
1051 sprintf(width, "D%d", extension&7);
1053 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1054 sprintf(g_dasm_str, "bfset %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
1057 static void d68020_bftst(void)
1063 LIMIT_CPU_TYPES(M68020_PLUS);
1065 extension = read_imm_16();
1067 if(BIT_B(extension))
1068 sprintf(offset, "D%d", (extension>>6)&7);
1070 sprintf(offset, "%d", (extension>>6)&31);
1071 if(BIT_5(extension))
1072 sprintf(width, "D%d", extension&7);
1074 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1075 sprintf(g_dasm_str, "bftst %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
1078 static void d68000_bra_8(void)
1080 uint temp_pc = g_cpu_pc;
1081 sprintf(g_dasm_str, "bra %X", temp_pc + make_int_8(g_cpu_ir));
1084 static void d68000_bra_16(void)
1086 uint temp_pc = g_cpu_pc;
1087 sprintf(g_dasm_str, "bra %X", temp_pc + make_int_16(read_imm_16()));
1090 static void d68020_bra_32(void)
1092 uint temp_pc = g_cpu_pc;
1093 LIMIT_CPU_TYPES(M68020_PLUS);
1094 sprintf(g_dasm_str, "bra %X; (2+)", temp_pc + read_imm_32());
1097 static void d68000_bset_r(void)
1099 sprintf(g_dasm_str, "bset D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1102 static void d68000_bset_s(void)
1104 char* str = get_imm_str_u8();
1105 sprintf(g_dasm_str, "bset %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1108 static void d68000_bsr_8(void)
1110 uint temp_pc = g_cpu_pc;
1111 sprintf(g_dasm_str, "bsr %X", temp_pc + make_int_8(g_cpu_ir));
1114 static void d68000_bsr_16(void)
1116 uint temp_pc = g_cpu_pc;
1117 sprintf(g_dasm_str, "bsr %X", temp_pc + make_int_16(read_imm_16()));
1120 static void d68020_bsr_32(void)
1122 uint temp_pc = g_cpu_pc;
1123 LIMIT_CPU_TYPES(M68020_PLUS);
1124 sprintf(g_dasm_str, "bsr %X; (2+)", temp_pc + peek_imm_32());
1127 static void d68000_btst_r(void)
1129 sprintf(g_dasm_str, "btst D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1132 static void d68000_btst_s(void)
1134 char* str = get_imm_str_u8();
1135 sprintf(g_dasm_str, "btst %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1138 static void d68020_callm(void)
1141 LIMIT_CPU_TYPES(M68020_ONLY);
1142 str = get_imm_str_u8();
1144 sprintf(g_dasm_str, "callm %s, %s; (2)", str, get_ea_mode_str_8(g_cpu_ir));
1147 static void d68020_cas_8(void)
1150 LIMIT_CPU_TYPES(M68020_PLUS);
1151 extension = read_imm_16();
1152 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));
1155 static void d68020_cas_16(void)
1158 LIMIT_CPU_TYPES(M68020_PLUS);
1159 extension = read_imm_16();
1160 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));
1163 static void d68020_cas_32(void)
1166 LIMIT_CPU_TYPES(M68020_PLUS);
1167 extension = read_imm_16();
1168 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));
1171 static void d68020_cas2_16(void)
1173 /* CAS2 Dc1:Dc2,Du1:Dc2:(Rn1):(Rn2)
1174 f e d c b a 9 8 7 6 5 4 3 2 1 0
1175 DARn1 0 0 0 Du1 0 0 0 Dc1
1176 DARn2 0 0 0 Du2 0 0 0 Dc2
1180 LIMIT_CPU_TYPES(M68020_PLUS);
1181 extension = read_imm_32();
1182 sprintf(g_dasm_str, "cas2.w D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)",
1183 (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
1184 BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
1185 BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
1188 static void d68020_cas2_32(void)
1191 LIMIT_CPU_TYPES(M68020_PLUS);
1192 extension = read_imm_32();
1193 sprintf(g_dasm_str, "cas2.l D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)",
1194 (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
1195 BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
1196 BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
1199 static void d68000_chk_16(void)
1201 sprintf(g_dasm_str, "chk.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1204 static void d68020_chk_32(void)
1206 LIMIT_CPU_TYPES(M68020_PLUS);
1207 sprintf(g_dasm_str, "chk.l %s, D%d; (2+)", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1210 static void d68020_chk2_cmp2_8(void)
1213 LIMIT_CPU_TYPES(M68020_PLUS);
1214 extension = read_imm_16();
1215 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);
1218 static void d68020_chk2_cmp2_16(void)
1221 LIMIT_CPU_TYPES(M68020_PLUS);
1222 extension = read_imm_16();
1223 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);
1226 static void d68020_chk2_cmp2_32(void)
1229 LIMIT_CPU_TYPES(M68020_PLUS);
1230 extension = read_imm_16();
1231 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);
1234 static void d68040_cinv(void)
1236 LIMIT_CPU_TYPES(M68040_PLUS);
1237 switch((g_cpu_ir>>3)&3)
1240 sprintf(g_dasm_str, "cinv (illegal scope); (4)");
1243 sprintf(g_dasm_str, "cinvl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1246 sprintf(g_dasm_str, "cinvp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1249 sprintf(g_dasm_str, "cinva %d; (4)", (g_cpu_ir>>6)&3);
1254 static void d68000_clr_8(void)
1256 sprintf(g_dasm_str, "clr.b %s", get_ea_mode_str_8(g_cpu_ir));
1259 static void d68000_clr_16(void)
1261 sprintf(g_dasm_str, "clr.w %s", get_ea_mode_str_16(g_cpu_ir));
1264 static void d68000_clr_32(void)
1266 sprintf(g_dasm_str, "clr.l %s", get_ea_mode_str_32(g_cpu_ir));
1269 static void d68000_cmp_8(void)
1271 sprintf(g_dasm_str, "cmp.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
1274 static void d68000_cmp_16(void)
1276 sprintf(g_dasm_str, "cmp.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1279 static void d68000_cmp_32(void)
1281 sprintf(g_dasm_str, "cmp.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1284 static void d68000_cmpa_16(void)
1286 sprintf(g_dasm_str, "cmpa.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1289 static void d68000_cmpa_32(void)
1291 sprintf(g_dasm_str, "cmpa.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1294 static void d68000_cmpi_8(void)
1296 char* str = get_imm_str_s8();
1297 sprintf(g_dasm_str, "cmpi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1300 static void d68020_cmpi_pcdi_8(void)
1303 LIMIT_CPU_TYPES(M68020_PLUS);
1304 str = get_imm_str_s8();
1305 sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
1308 static void d68020_cmpi_pcix_8(void)
1311 LIMIT_CPU_TYPES(M68020_PLUS);
1312 str = get_imm_str_s8();
1313 sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
1316 static void d68000_cmpi_16(void)
1319 //BUG!!! LIMIT_CPU_TYPES(M68020_PLUS);
1320 str = get_imm_str_s16();
1321 sprintf(g_dasm_str, "cmpi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
1324 static void d68020_cmpi_pcdi_16(void)
1327 LIMIT_CPU_TYPES(M68020_PLUS);
1328 str = get_imm_str_s16();
1329 sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
1332 static void d68020_cmpi_pcix_16(void)
1335 LIMIT_CPU_TYPES(M68020_PLUS);
1336 str = get_imm_str_s16();
1337 sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
1340 static void d68000_cmpi_32(void)
1343 //BUG!!! Argh! LIMIT_CPU_TYPES(M68020_PLUS);
1344 str = get_imm_str_s32();
1345 sprintf(g_dasm_str, "cmpi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
1348 static void d68020_cmpi_pcdi_32(void)
1351 LIMIT_CPU_TYPES(M68020_PLUS);
1352 str = get_imm_str_s32();
1353 sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
1356 static void d68020_cmpi_pcix_32(void)
1359 LIMIT_CPU_TYPES(M68020_PLUS);
1360 str = get_imm_str_s32();
1361 sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
1364 static void d68000_cmpm_8(void)
1366 sprintf(g_dasm_str, "cmpm.b (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
1369 static void d68000_cmpm_16(void)
1371 sprintf(g_dasm_str, "cmpm.w (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
1374 static void d68000_cmpm_32(void)
1376 sprintf(g_dasm_str, "cmpm.l (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
1379 static void d68020_cpbcc_16(void)
1382 uint new_pc = g_cpu_pc;
1383 LIMIT_CPU_TYPES(M68020_PLUS);
1384 extension = read_imm_16();
1385 new_pc += make_int_16(peek_imm_16());
1386 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);
1389 static void d68020_cpbcc_32(void)
1392 uint new_pc = g_cpu_pc;
1393 LIMIT_CPU_TYPES(M68020_PLUS);
1394 extension = read_imm_16();
1395 new_pc += peek_imm_32();
1396 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);
1399 static void d68020_cpdbcc(void)
1403 uint new_pc = g_cpu_pc;
1404 LIMIT_CPU_TYPES(M68020_PLUS);
1405 extension1 = read_imm_16();
1406 extension2 = read_imm_16();
1407 new_pc += make_int_16(peek_imm_16());
1408 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);
1411 static void d68020_cpgen(void)
1413 LIMIT_CPU_TYPES(M68020_PLUS);
1414 sprintf(g_dasm_str, "%dgen %s; (2-3)", (g_cpu_ir>>9)&7, get_imm_str_u32());
1417 static void d68020_cprestore(void)
1419 LIMIT_CPU_TYPES(M68020_PLUS);
1420 sprintf(g_dasm_str, "%drestore %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1423 static void d68020_cpsave(void)
1425 LIMIT_CPU_TYPES(M68020_PLUS);
1426 sprintf(g_dasm_str, "%dsave %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1429 static void d68020_cpscc(void)
1433 LIMIT_CPU_TYPES(M68020_PLUS);
1434 extension1 = read_imm_16();
1435 extension2 = read_imm_16();
1436 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);
1439 static void d68020_cptrapcc_0(void)
1443 LIMIT_CPU_TYPES(M68020_PLUS);
1444 extension1 = read_imm_16();
1445 extension2 = read_imm_16();
1446 sprintf(g_dasm_str, "%dtrap%-4s; (extension = %X) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], extension2);
1449 static void d68020_cptrapcc_16(void)
1453 LIMIT_CPU_TYPES(M68020_PLUS);
1454 extension1 = read_imm_16();
1455 extension2 = read_imm_16();
1456 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);
1459 static void d68020_cptrapcc_32(void)
1463 LIMIT_CPU_TYPES(M68020_PLUS);
1464 extension1 = read_imm_16();
1465 extension2 = read_imm_16();
1466 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);
1469 static void d68040_cpush(void)
1471 LIMIT_CPU_TYPES(M68040_PLUS);
1472 switch((g_cpu_ir>>3)&3)
1475 sprintf(g_dasm_str, "cpush (illegal scope); (4)");
1478 sprintf(g_dasm_str, "cpushl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1481 sprintf(g_dasm_str, "cpushp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1484 sprintf(g_dasm_str, "cpusha %d; (4)", (g_cpu_ir>>6)&3);
1489 static void d68000_dbra(void)
1491 uint temp_pc = g_cpu_pc;
1492 sprintf(g_dasm_str, "dbra D%d, %X", g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16()));
1495 static void d68000_dbcc(void)
1497 uint temp_pc = g_cpu_pc;
1498 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()));
1501 static void d68000_divs(void)
1503 sprintf(g_dasm_str, "divs.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1506 static void d68000_divu(void)
1508 sprintf(g_dasm_str, "divu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1511 static void d68020_divl(void)
1514 LIMIT_CPU_TYPES(M68020_PLUS);
1515 extension = read_imm_16();
1517 if(BIT_A(extension))
1518 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);
1519 else if((extension&7) == ((extension>>12)&7))
1520 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);
1522 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);
1525 static void d68000_eor_8(void)
1527 sprintf(g_dasm_str, "eor.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1530 static void d68000_eor_16(void)
1532 sprintf(g_dasm_str, "eor.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
1535 static void d68000_eor_32(void)
1537 sprintf(g_dasm_str, "eor.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
1540 static void d68000_eori_8(void)
1542 char* str = get_imm_str_u8();
1543 sprintf(g_dasm_str, "eori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1546 static void d68000_eori_16(void)
1548 char* str = get_imm_str_u16();
1549 sprintf(g_dasm_str, "eori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
1552 static void d68000_eori_32(void)
1554 char* str = get_imm_str_u32();
1555 sprintf(g_dasm_str, "eori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
1558 static void d68000_eori_to_ccr(void)
1560 sprintf(g_dasm_str, "eori %s, CCR", get_imm_str_u8());
1563 static void d68000_eori_to_sr(void)
1565 sprintf(g_dasm_str, "eori %s, SR", get_imm_str_u16());
1568 static void d68000_exg_dd(void)
1570 sprintf(g_dasm_str, "exg D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1573 static void d68000_exg_aa(void)
1575 sprintf(g_dasm_str, "exg A%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1578 static void d68000_exg_da(void)
1580 sprintf(g_dasm_str, "exg D%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1583 static void d68000_ext_16(void)
1585 sprintf(g_dasm_str, "ext.w D%d", g_cpu_ir&7);
1588 static void d68000_ext_32(void)
1590 sprintf(g_dasm_str, "ext.l D%d", g_cpu_ir&7);
1593 static void d68020_extb_32(void)
1595 LIMIT_CPU_TYPES(M68020_PLUS);
1596 sprintf(g_dasm_str, "extb.l D%d; (2+)", g_cpu_ir&7);
1599 static void d68000_jmp(void)
1601 sprintf(g_dasm_str, "jmp %s", get_ea_mode_str_32(g_cpu_ir));
1604 static void d68000_jsr(void)
1606 sprintf(g_dasm_str, "jsr %s", get_ea_mode_str_32(g_cpu_ir));
1609 static void d68000_lea(void)
1611 sprintf(g_dasm_str, "lea %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1614 static void d68000_link_16(void)
1616 sprintf(g_dasm_str, "link A%d, %s", g_cpu_ir&7, get_imm_str_s16());
1619 static void d68020_link_32(void)
1621 LIMIT_CPU_TYPES(M68020_PLUS);
1622 sprintf(g_dasm_str, "link A%d, %s; (2+)", g_cpu_ir&7, get_imm_str_s32());
1625 static void d68000_lsr_s_8(void)
1627 sprintf(g_dasm_str, "lsr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1630 static void d68000_lsr_s_16(void)
1632 sprintf(g_dasm_str, "lsr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1635 static void d68000_lsr_s_32(void)
1637 sprintf(g_dasm_str, "lsr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1640 static void d68000_lsr_r_8(void)
1642 sprintf(g_dasm_str, "lsr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1645 static void d68000_lsr_r_16(void)
1647 sprintf(g_dasm_str, "lsr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1650 static void d68000_lsr_r_32(void)
1652 sprintf(g_dasm_str, "lsr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1655 static void d68000_lsr_ea(void)
1657 sprintf(g_dasm_str, "lsr.w %s", get_ea_mode_str_32(g_cpu_ir));
1660 static void d68000_lsl_s_8(void)
1662 sprintf(g_dasm_str, "lsl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1665 static void d68000_lsl_s_16(void)
1667 sprintf(g_dasm_str, "lsl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1670 static void d68000_lsl_s_32(void)
1672 sprintf(g_dasm_str, "lsl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1675 static void d68000_lsl_r_8(void)
1677 sprintf(g_dasm_str, "lsl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1680 static void d68000_lsl_r_16(void)
1682 sprintf(g_dasm_str, "lsl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1685 static void d68000_lsl_r_32(void)
1687 sprintf(g_dasm_str, "lsl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1690 static void d68000_lsl_ea(void)
1692 sprintf(g_dasm_str, "lsl.w %s", get_ea_mode_str_32(g_cpu_ir));
1695 static void d68000_move_8(void)
1697 char* str = get_ea_mode_str_8(g_cpu_ir);
1698 sprintf(g_dasm_str, "move.b %s, %s", str, get_ea_mode_str_8(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
1701 static void d68000_move_16(void)
1703 char* str = get_ea_mode_str_16(g_cpu_ir);
1704 sprintf(g_dasm_str, "move.w %s, %s", str, get_ea_mode_str_16(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
1707 static void d68000_move_32(void)
1709 char* str = get_ea_mode_str_32(g_cpu_ir);
1710 sprintf(g_dasm_str, "move.l %s, %s", str, get_ea_mode_str_32(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
1713 static void d68000_movea_16(void)
1715 sprintf(g_dasm_str, "movea.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1718 static void d68000_movea_32(void)
1720 sprintf(g_dasm_str, "movea.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1723 static void d68000_move_to_ccr(void)
1725 sprintf(g_dasm_str, "move %s, CCR", get_ea_mode_str_8(g_cpu_ir));
1728 static void d68010_move_fr_ccr(void)
1730 LIMIT_CPU_TYPES(M68010_PLUS);
1731 sprintf(g_dasm_str, "move CCR, %s; (1+)", get_ea_mode_str_8(g_cpu_ir));
1734 static void d68000_move_fr_sr(void)
1736 sprintf(g_dasm_str, "move SR, %s", get_ea_mode_str_16(g_cpu_ir));
1739 static void d68000_move_to_sr(void)
1741 sprintf(g_dasm_str, "move %s, SR", get_ea_mode_str_16(g_cpu_ir));
1744 static void d68000_move_fr_usp(void)
1746 sprintf(g_dasm_str, "move USP, A%d", g_cpu_ir&7);
1749 static void d68000_move_to_usp(void)
1751 sprintf(g_dasm_str, "move A%d, USP", g_cpu_ir&7);
1754 static void d68010_movec(void)
1759 LIMIT_CPU_TYPES(M68010_PLUS);
1760 extension = read_imm_16();
1762 switch(extension & 0xfff)
1829 reg_name = make_signed_hex_str_16(extension & 0xfff);
1834 sprintf(g_dasm_str, "movec %c%d, %s; (%s)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, reg_name, processor);
1836 sprintf(g_dasm_str, "movec %s, %c%d; (%s)", reg_name, BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, processor);
1839 static void d68000_movem_pd_16(void)
1841 uint data = read_imm_16();
1850 if(data&(1<<(15-i)))
1855 if(data&(1<<(15-i)))
1858 strcat(buffer, "/");
1859 sprintf(buffer+strlen(buffer), "D%d", first);
1861 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
1874 strcat(buffer, "/");
1875 sprintf(buffer+strlen(buffer), "A%d", first);
1877 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
1880 sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
1883 static void d68000_movem_pd_32(void)
1885 uint data = read_imm_16();
1894 if(data&(1<<(15-i)))
1899 if(data&(1<<(15-i)))
1902 strcat(buffer, "/");
1903 sprintf(buffer+strlen(buffer), "D%d", first);
1905 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
1918 strcat(buffer, "/");
1919 sprintf(buffer+strlen(buffer), "A%d", first);
1921 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
1924 sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
1927 static void d68000_movem_er_16(void)
1929 uint data = read_imm_16();
1946 strcat(buffer, "/");
1947 sprintf(buffer+strlen(buffer), "D%d", first);
1949 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
1962 strcat(buffer, "/");
1963 sprintf(buffer+strlen(buffer), "A%d", first);
1965 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
1968 sprintf(g_dasm_str, "movem.w %s, %s", get_ea_mode_str_16(g_cpu_ir), buffer);
1971 static void d68000_movem_er_32(void)
1973 uint data = read_imm_16();
1990 strcat(buffer, "/");
1991 sprintf(buffer+strlen(buffer), "D%d", first);
1993 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
2006 strcat(buffer, "/");
2007 sprintf(buffer+strlen(buffer), "A%d", first);
2009 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
2012 sprintf(g_dasm_str, "movem.l %s, %s", get_ea_mode_str_32(g_cpu_ir), buffer);
2015 static void d68000_movem_re_16(void)
2017 uint data = read_imm_16();
2034 strcat(buffer, "/");
2035 sprintf(buffer+strlen(buffer), "D%d", first);
2037 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
2050 strcat(buffer, "/");
2051 sprintf(buffer+strlen(buffer), "A%d", first);
2053 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
2056 sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
2059 static void d68000_movem_re_32(void)
2061 uint data = read_imm_16();
2078 strcat(buffer, "/");
2079 sprintf(buffer+strlen(buffer), "D%d", first);
2081 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
2094 strcat(buffer, "/");
2095 sprintf(buffer+strlen(buffer), "A%d", first);
2097 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
2100 sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
2103 static void d68000_movep_re_16(void)
2105 sprintf(g_dasm_str, "movep.w D%d, ($%X,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
2108 static void d68000_movep_re_32(void)
2110 sprintf(g_dasm_str, "movep.l D%d, ($%X,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
2113 static void d68000_movep_er_16(void)
2115 sprintf(g_dasm_str, "movep.w ($%X,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
2118 static void d68000_movep_er_32(void)
2120 sprintf(g_dasm_str, "movep.l ($%X,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
2123 static void d68010_moves_8(void)
2126 LIMIT_CPU_TYPES(M68010_PLUS);
2127 extension = read_imm_16();
2128 if(BIT_B(extension))
2129 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));
2131 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);
2134 static void d68010_moves_16(void)
2137 LIMIT_CPU_TYPES(M68010_PLUS);
2138 extension = read_imm_16();
2139 if(BIT_B(extension))
2140 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));
2142 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);
2145 static void d68010_moves_32(void)
2148 LIMIT_CPU_TYPES(M68010_PLUS);
2149 extension = read_imm_16();
2150 if(BIT_B(extension))
2151 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));
2153 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);
2156 static void d68000_moveq(void)
2158 sprintf(g_dasm_str, "moveq #%s, D%d", make_signed_hex_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
2161 static void d68040_move16_pi_pi(void)
2163 LIMIT_CPU_TYPES(M68040_PLUS);
2164 sprintf(g_dasm_str, "move16 (A%d)+, (A%d)+; (4)", g_cpu_ir&7, (read_imm_16()>>12)&7);
2167 static void d68040_move16_pi_al(void)
2169 LIMIT_CPU_TYPES(M68040_PLUS);
2170 sprintf(g_dasm_str, "move16 (A%d)+, %s; (4)", g_cpu_ir&7, get_imm_str_u32());
2173 static void d68040_move16_al_pi(void)
2175 LIMIT_CPU_TYPES(M68040_PLUS);
2176 sprintf(g_dasm_str, "move16 %s, (A%d)+; (4)", get_imm_str_u32(), g_cpu_ir&7);
2179 static void d68040_move16_ai_al(void)
2181 LIMIT_CPU_TYPES(M68040_PLUS);
2182 sprintf(g_dasm_str, "move16 (A%d), %s; (4)", g_cpu_ir&7, get_imm_str_u32());
2185 static void d68040_move16_al_ai(void)
2187 LIMIT_CPU_TYPES(M68040_PLUS);
2188 sprintf(g_dasm_str, "move16 %s, (A%d); (4)", get_imm_str_u32(), g_cpu_ir&7);
2191 static void d68000_muls(void)
2193 sprintf(g_dasm_str, "muls.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2196 static void d68000_mulu(void)
2198 sprintf(g_dasm_str, "mulu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2201 static void d68020_mull(void)
2204 LIMIT_CPU_TYPES(M68020_PLUS);
2205 extension = read_imm_16();
2207 if(BIT_A(extension))
2208 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);
2210 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);
2213 static void d68000_nbcd(void)
2215 sprintf(g_dasm_str, "nbcd %s", get_ea_mode_str_8(g_cpu_ir));
2218 static void d68000_neg_8(void)
2220 sprintf(g_dasm_str, "neg.b %s", get_ea_mode_str_8(g_cpu_ir));
2223 static void d68000_neg_16(void)
2225 sprintf(g_dasm_str, "neg.w %s", get_ea_mode_str_16(g_cpu_ir));
2228 static void d68000_neg_32(void)
2230 sprintf(g_dasm_str, "neg.l %s", get_ea_mode_str_32(g_cpu_ir));
2233 static void d68000_negx_8(void)
2235 sprintf(g_dasm_str, "negx.b %s", get_ea_mode_str_8(g_cpu_ir));
2238 static void d68000_negx_16(void)
2240 sprintf(g_dasm_str, "negx.w %s", get_ea_mode_str_16(g_cpu_ir));
2243 static void d68000_negx_32(void)
2245 sprintf(g_dasm_str, "negx.l %s", get_ea_mode_str_32(g_cpu_ir));
2248 static void d68000_nop(void)
2250 sprintf(g_dasm_str, "nop");
2253 static void d68000_not_8(void)
2255 sprintf(g_dasm_str, "not.b %s", get_ea_mode_str_8(g_cpu_ir));
2258 static void d68000_not_16(void)
2260 sprintf(g_dasm_str, "not.w %s", get_ea_mode_str_16(g_cpu_ir));
2263 static void d68000_not_32(void)
2265 sprintf(g_dasm_str, "not.l %s", get_ea_mode_str_32(g_cpu_ir));
2268 static void d68000_or_er_8(void)
2270 sprintf(g_dasm_str, "or.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
2273 static void d68000_or_er_16(void)
2275 sprintf(g_dasm_str, "or.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2278 static void d68000_or_er_32(void)
2280 sprintf(g_dasm_str, "or.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
2283 static void d68000_or_re_8(void)
2285 sprintf(g_dasm_str, "or.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
2288 static void d68000_or_re_16(void)
2290 sprintf(g_dasm_str, "or.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
2293 static void d68000_or_re_32(void)
2295 sprintf(g_dasm_str, "or.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
2298 static void d68000_ori_8(void)
2300 char* str = get_imm_str_u8();
2301 sprintf(g_dasm_str, "ori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
2304 static void d68000_ori_16(void)
2306 char* str = get_imm_str_u16();
2307 sprintf(g_dasm_str, "ori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
2310 static void d68000_ori_32(void)
2312 char* str = get_imm_str_u32();
2313 sprintf(g_dasm_str, "ori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
2316 static void d68000_ori_to_ccr(void)
2318 sprintf(g_dasm_str, "ori %s, CCR", get_imm_str_u8());
2321 static void d68000_ori_to_sr(void)
2323 sprintf(g_dasm_str, "ori %s, SR", get_imm_str_u16());
2326 static void d68020_pack_rr(void)
2328 LIMIT_CPU_TYPES(M68020_PLUS);
2329 sprintf(g_dasm_str, "pack D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2332 static void d68020_pack_mm(void)
2334 LIMIT_CPU_TYPES(M68020_PLUS);
2335 sprintf(g_dasm_str, "pack -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2338 static void d68000_pea(void)
2340 sprintf(g_dasm_str, "pea %s", get_ea_mode_str_32(g_cpu_ir));
2343 static void d68000_reset(void)
2345 sprintf(g_dasm_str, "reset");
2348 static void d68000_ror_s_8(void)
2350 sprintf(g_dasm_str, "ror.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2353 static void d68000_ror_s_16(void)
2355 sprintf(g_dasm_str, "ror.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7],g_cpu_ir&7);
2358 static void d68000_ror_s_32(void)
2360 sprintf(g_dasm_str, "ror.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2363 static void d68000_ror_r_8(void)
2365 sprintf(g_dasm_str, "ror.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2368 static void d68000_ror_r_16(void)
2370 sprintf(g_dasm_str, "ror.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2373 static void d68000_ror_r_32(void)
2375 sprintf(g_dasm_str, "ror.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2378 static void d68000_ror_ea(void)
2380 sprintf(g_dasm_str, "ror.w %s", get_ea_mode_str_32(g_cpu_ir));
2383 static void d68000_rol_s_8(void)
2385 sprintf(g_dasm_str, "rol.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2388 static void d68000_rol_s_16(void)
2390 sprintf(g_dasm_str, "rol.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2393 static void d68000_rol_s_32(void)
2395 sprintf(g_dasm_str, "rol.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2398 static void d68000_rol_r_8(void)
2400 sprintf(g_dasm_str, "rol.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2403 static void d68000_rol_r_16(void)
2405 sprintf(g_dasm_str, "rol.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2408 static void d68000_rol_r_32(void)
2410 sprintf(g_dasm_str, "rol.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2413 static void d68000_rol_ea(void)
2415 sprintf(g_dasm_str, "rol.w %s", get_ea_mode_str_32(g_cpu_ir));
2418 static void d68000_roxr_s_8(void)
2420 sprintf(g_dasm_str, "roxr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2423 static void d68000_roxr_s_16(void)
2425 sprintf(g_dasm_str, "roxr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2429 static void d68000_roxr_s_32(void)
2431 sprintf(g_dasm_str, "roxr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2434 static void d68000_roxr_r_8(void)
2436 sprintf(g_dasm_str, "roxr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2439 static void d68000_roxr_r_16(void)
2441 sprintf(g_dasm_str, "roxr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2444 static void d68000_roxr_r_32(void)
2446 sprintf(g_dasm_str, "roxr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2449 static void d68000_roxr_ea(void)
2451 sprintf(g_dasm_str, "roxr.w %s", get_ea_mode_str_32(g_cpu_ir));
2454 static void d68000_roxl_s_8(void)
2456 sprintf(g_dasm_str, "roxl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2459 static void d68000_roxl_s_16(void)
2461 sprintf(g_dasm_str, "roxl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2464 static void d68000_roxl_s_32(void)
2466 sprintf(g_dasm_str, "roxl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2469 static void d68000_roxl_r_8(void)
2471 sprintf(g_dasm_str, "roxl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2474 static void d68000_roxl_r_16(void)
2476 sprintf(g_dasm_str, "roxl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2479 static void d68000_roxl_r_32(void)
2481 sprintf(g_dasm_str, "roxl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2484 static void d68000_roxl_ea(void)
2486 sprintf(g_dasm_str, "roxl.w %s", get_ea_mode_str_32(g_cpu_ir));
2489 static void d68010_rtd(void)
2491 LIMIT_CPU_TYPES(M68010_PLUS);
2492 sprintf(g_dasm_str, "rtd %s; (1+)", get_imm_str_s16());
2495 static void d68000_rte(void)
2497 sprintf(g_dasm_str, "rte");
2500 static void d68020_rtm(void)
2502 LIMIT_CPU_TYPES(M68020_ONLY);
2503 sprintf(g_dasm_str, "rtm %c%d; (2+)", BIT_3(g_cpu_ir) ? 'A' : 'D', g_cpu_ir&7);
2506 static void d68000_rtr(void)
2508 sprintf(g_dasm_str, "rtr");
2511 static void d68000_rts(void)
2513 sprintf(g_dasm_str, "rts");
2516 static void d68000_sbcd_rr(void)
2518 sprintf(g_dasm_str, "sbcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2521 static void d68000_sbcd_mm(void)
2523 sprintf(g_dasm_str, "sbcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2526 static void d68000_scc(void)
2528 sprintf(g_dasm_str, "s%-2s %s", g_cc[(g_cpu_ir>>8)&0xf], get_ea_mode_str_8(g_cpu_ir));
2531 static void d68000_stop(void)
2533 sprintf(g_dasm_str, "stop %s", get_imm_str_s16());
2536 static void d68000_sub_er_8(void)
2538 sprintf(g_dasm_str, "sub.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
2541 static void d68000_sub_er_16(void)
2543 sprintf(g_dasm_str, "sub.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2546 static void d68000_sub_er_32(void)
2548 sprintf(g_dasm_str, "sub.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
2551 static void d68000_sub_re_8(void)
2553 sprintf(g_dasm_str, "sub.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
2556 static void d68000_sub_re_16(void)
2558 sprintf(g_dasm_str, "sub.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
2561 static void d68000_sub_re_32(void)
2563 sprintf(g_dasm_str, "sub.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
2566 static void d68000_suba_16(void)
2568 sprintf(g_dasm_str, "suba.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2571 static void d68000_suba_32(void)
2573 sprintf(g_dasm_str, "suba.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
2576 static void d68000_subi_8(void)
2578 char* str = get_imm_str_s8();
2579 sprintf(g_dasm_str, "subi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
2582 static void d68000_subi_16(void)
2584 char* str = get_imm_str_s16();
2585 sprintf(g_dasm_str, "subi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
2588 static void d68000_subi_32(void)
2590 char* str = get_imm_str_s32();
2591 sprintf(g_dasm_str, "subi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
2594 static void d68000_subq_8(void)
2596 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));
2599 static void d68000_subq_16(void)
2601 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));
2604 static void d68000_subq_32(void)
2606 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));
2609 static void d68000_subx_rr_8(void)
2611 sprintf(g_dasm_str, "subx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2614 static void d68000_subx_rr_16(void)
2616 sprintf(g_dasm_str, "subx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2619 static void d68000_subx_rr_32(void)
2621 sprintf(g_dasm_str, "subx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2624 static void d68000_subx_mm_8(void)
2626 sprintf(g_dasm_str, "subx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2629 static void d68000_subx_mm_16(void)
2631 sprintf(g_dasm_str, "subx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2634 static void d68000_subx_mm_32(void)
2636 sprintf(g_dasm_str, "subx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2639 static void d68000_swap(void)
2641 sprintf(g_dasm_str, "swap D%d", g_cpu_ir&7);
2644 static void d68000_tas(void)
2646 sprintf(g_dasm_str, "tas %s", get_ea_mode_str_8(g_cpu_ir));
2649 static void d68000_trap(void)
2651 sprintf(g_dasm_str, "trap #$%X", g_cpu_ir&0xf);
2654 static void d68020_trapcc_0(void)
2656 LIMIT_CPU_TYPES(M68020_PLUS);
2657 sprintf(g_dasm_str, "trap%-2s; (2+)", g_cc[(g_cpu_ir>>8)&0xf]);
2660 static void d68020_trapcc_16(void)
2662 LIMIT_CPU_TYPES(M68020_PLUS);
2663 sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u16());
2666 static void d68020_trapcc_32(void)
2668 LIMIT_CPU_TYPES(M68020_PLUS);
2669 sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u32());
2672 static void d68000_trapv(void)
2674 sprintf(g_dasm_str, "trapv");
2677 static void d68000_tst_8(void)
2679 sprintf(g_dasm_str, "tst.b %s", get_ea_mode_str_8(g_cpu_ir));
2682 static void d68020_tst_pcdi_8(void)
2684 LIMIT_CPU_TYPES(M68020_PLUS);
2685 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
2688 static void d68020_tst_pcix_8(void)
2690 LIMIT_CPU_TYPES(M68020_PLUS);
2691 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
2694 static void d68020_tst_i_8(void)
2696 LIMIT_CPU_TYPES(M68020_PLUS);
2697 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
2700 static void d68000_tst_16(void)
2702 sprintf(g_dasm_str, "tst.w %s", get_ea_mode_str_16(g_cpu_ir));
2705 static void d68020_tst_a_16(void)
2707 LIMIT_CPU_TYPES(M68020_PLUS);
2708 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2711 static void d68020_tst_pcdi_16(void)
2713 LIMIT_CPU_TYPES(M68020_PLUS);
2714 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2717 static void d68020_tst_pcix_16(void)
2719 LIMIT_CPU_TYPES(M68020_PLUS);
2720 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2723 static void d68020_tst_i_16(void)
2725 LIMIT_CPU_TYPES(M68020_PLUS);
2726 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2729 static void d68000_tst_32(void)
2731 sprintf(g_dasm_str, "tst.l %s", get_ea_mode_str_32(g_cpu_ir));
2734 static void d68020_tst_a_32(void)
2736 LIMIT_CPU_TYPES(M68020_PLUS);
2737 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2740 static void d68020_tst_pcdi_32(void)
2742 LIMIT_CPU_TYPES(M68020_PLUS);
2743 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2746 static void d68020_tst_pcix_32(void)
2748 LIMIT_CPU_TYPES(M68020_PLUS);
2749 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2752 static void d68020_tst_i_32(void)
2754 LIMIT_CPU_TYPES(M68020_PLUS);
2755 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2758 static void d68000_unlk(void)
2760 sprintf(g_dasm_str, "unlk A%d", g_cpu_ir&7);
2763 static void d68020_unpk_rr(void)
2765 LIMIT_CPU_TYPES(M68020_PLUS);
2766 sprintf(g_dasm_str, "unpk D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2769 static void d68020_unpk_mm(void)
2771 LIMIT_CPU_TYPES(M68020_PLUS);
2772 sprintf(g_dasm_str, "unpk -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2777 /* ======================================================================== */
2778 /* ======================= INSTRUCTION TABLE BUILDER ====================== */
2779 /* ======================================================================== */
2782 800 = data register direct
2783 400 = address register direct
2784 200 = address register indirect
2785 100 = ARI postincrement
2786 80 = ARI pre-decrement
2787 40 = ARI displacement
2796 static opcode_struct g_opcode_info[] =
2798 /* opcode handler mask match ea mask */
2799 {d68000_1010 , 0xf000, 0xa000, 0x000},
2800 {d68000_1111 , 0xf000, 0xf000, 0x000},
2801 {d68000_abcd_rr , 0xf1f8, 0xc100, 0x000},
2802 {d68000_abcd_mm , 0xf1f8, 0xc108, 0x000},
2803 {d68000_add_er_8 , 0xf1c0, 0xd000, 0xbff},
2804 {d68000_add_er_16 , 0xf1c0, 0xd040, 0xfff},
2805 {d68000_add_er_32 , 0xf1c0, 0xd080, 0xfff},
2806 {d68000_add_re_8 , 0xf1c0, 0xd100, 0x3f8},
2807 {d68000_add_re_16 , 0xf1c0, 0xd140, 0x3f8},
2808 {d68000_add_re_32 , 0xf1c0, 0xd180, 0x3f8},
2809 {d68000_adda_16 , 0xf1c0, 0xd0c0, 0xfff},
2810 {d68000_adda_32 , 0xf1c0, 0xd1c0, 0xfff},
2811 {d68000_addi_8 , 0xffc0, 0x0600, 0xbf8},
2812 {d68000_addi_16 , 0xffc0, 0x0640, 0xbf8},
2813 {d68000_addi_32 , 0xffc0, 0x0680, 0xbf8},
2814 {d68000_addq_8 , 0xf1c0, 0x5000, 0xbf8},
2815 {d68000_addq_16 , 0xf1c0, 0x5040, 0xff8},
2816 {d68000_addq_32 , 0xf1c0, 0x5080, 0xff8},
2817 {d68000_addx_rr_8 , 0xf1f8, 0xd100, 0x000},
2818 {d68000_addx_rr_16 , 0xf1f8, 0xd140, 0x000},
2819 {d68000_addx_rr_32 , 0xf1f8, 0xd180, 0x000},
2820 {d68000_addx_mm_8 , 0xf1f8, 0xd108, 0x000},
2821 {d68000_addx_mm_16 , 0xf1f8, 0xd148, 0x000},
2822 {d68000_addx_mm_32 , 0xf1f8, 0xd188, 0x000},
2823 {d68000_and_er_8 , 0xf1c0, 0xc000, 0xbff},
2824 {d68000_and_er_16 , 0xf1c0, 0xc040, 0xbff},
2825 {d68000_and_er_32 , 0xf1c0, 0xc080, 0xbff},
2826 {d68000_and_re_8 , 0xf1c0, 0xc100, 0x3f8},
2827 {d68000_and_re_16 , 0xf1c0, 0xc140, 0x3f8},
2828 {d68000_and_re_32 , 0xf1c0, 0xc180, 0x3f8},
2829 {d68000_andi_to_ccr , 0xffff, 0x023c, 0x000},
2830 {d68000_andi_to_sr , 0xffff, 0x027c, 0x000},
2831 {d68000_andi_8 , 0xffc0, 0x0200, 0xbf8},
2832 {d68000_andi_16 , 0xffc0, 0x0240, 0xbf8},
2833 {d68000_andi_32 , 0xffc0, 0x0280, 0xbf8},
2834 {d68000_asr_s_8 , 0xf1f8, 0xe000, 0x000},
2835 {d68000_asr_s_16 , 0xf1f8, 0xe040, 0x000},
2836 {d68000_asr_s_32 , 0xf1f8, 0xe080, 0x000},
2837 {d68000_asr_r_8 , 0xf1f8, 0xe020, 0x000},
2838 {d68000_asr_r_16 , 0xf1f8, 0xe060, 0x000},
2839 {d68000_asr_r_32 , 0xf1f8, 0xe0a0, 0x000},
2840 {d68000_asr_ea , 0xffc0, 0xe0c0, 0x3f8},
2841 {d68000_asl_s_8 , 0xf1f8, 0xe100, 0x000},
2842 {d68000_asl_s_16 , 0xf1f8, 0xe140, 0x000},
2843 {d68000_asl_s_32 , 0xf1f8, 0xe180, 0x000},
2844 {d68000_asl_r_8 , 0xf1f8, 0xe120, 0x000},
2845 {d68000_asl_r_16 , 0xf1f8, 0xe160, 0x000},
2846 {d68000_asl_r_32 , 0xf1f8, 0xe1a0, 0x000},
2847 {d68000_asl_ea , 0xffc0, 0xe1c0, 0x3f8},
2848 {d68000_bcc_8 , 0xf000, 0x6000, 0x000},
2849 {d68000_bcc_16 , 0xf0ff, 0x6000, 0x000},
2850 {d68020_bcc_32 , 0xf0ff, 0x60ff, 0x000},
2851 {d68000_bchg_r , 0xf1c0, 0x0140, 0xbf8},
2852 {d68000_bchg_s , 0xffc0, 0x0840, 0xbf8},
2853 {d68000_bclr_r , 0xf1c0, 0x0180, 0xbf8},
2854 {d68000_bclr_s , 0xffc0, 0x0880, 0xbf8},
2855 {d68020_bfchg , 0xffc0, 0xeac0, 0xa78},
2856 {d68020_bfclr , 0xffc0, 0xecc0, 0xa78},
2857 {d68020_bfexts , 0xffc0, 0xebc0, 0xa7b},
2858 {d68020_bfextu , 0xffc0, 0xe9c0, 0xa7b},
2859 {d68020_bfffo , 0xffc0, 0xedc0, 0xa7b},
2860 {d68020_bfins , 0xffc0, 0xefc0, 0xa78},
2861 {d68020_bfset , 0xffc0, 0xeec0, 0xa78},
2862 {d68020_bftst , 0xffc0, 0xe8c0, 0xa7b},
2863 {d68010_bkpt , 0xfff8, 0x4848, 0x000},
2864 {d68000_bra_8 , 0xff00, 0x6000, 0x000},
2865 {d68000_bra_16 , 0xffff, 0x6000, 0x000},
2866 {d68020_bra_32 , 0xffff, 0x60ff, 0x000},
2867 {d68000_bset_r , 0xf1c0, 0x01c0, 0xbf8},
2868 {d68000_bset_s , 0xffc0, 0x08c0, 0xbf8},
2869 {d68000_bsr_8 , 0xff00, 0x6100, 0x000},
2870 {d68000_bsr_16 , 0xffff, 0x6100, 0x000},
2871 {d68020_bsr_32 , 0xffff, 0x61ff, 0x000},
2872 {d68000_btst_r , 0xf1c0, 0x0100, 0xbff},
2873 {d68000_btst_s , 0xffc0, 0x0800, 0xbfb},
2874 {d68020_callm , 0xffc0, 0x06c0, 0x27b},
2875 {d68020_cas_8 , 0xffc0, 0x0ac0, 0x3f8},
2876 {d68020_cas_16 , 0xffc0, 0x0cc0, 0x3f8},
2877 {d68020_cas_32 , 0xffc0, 0x0ec0, 0x3f8},
2878 {d68020_cas2_16 , 0xffff, 0x0cfc, 0x000},
2879 {d68020_cas2_32 , 0xffff, 0x0efc, 0x000},
2880 {d68000_chk_16 , 0xf1c0, 0x4180, 0xbff},
2881 {d68020_chk_32 , 0xf1c0, 0x4100, 0xbff},
2882 {d68020_chk2_cmp2_8 , 0xffc0, 0x00c0, 0x27b},
2883 {d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b},
2884 {d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b},
2885 {d68040_cinv , 0xff20, 0xf400, 0x000},
2886 {d68000_clr_8 , 0xffc0, 0x4200, 0xbf8},
2887 {d68000_clr_16 , 0xffc0, 0x4240, 0xbf8},
2888 {d68000_clr_32 , 0xffc0, 0x4280, 0xbf8},
2889 {d68000_cmp_8 , 0xf1c0, 0xb000, 0xbff},
2890 {d68000_cmp_16 , 0xf1c0, 0xb040, 0xfff},
2891 {d68000_cmp_32 , 0xf1c0, 0xb080, 0xfff},
2892 {d68000_cmpa_16 , 0xf1c0, 0xb0c0, 0xfff},
2893 {d68000_cmpa_32 , 0xf1c0, 0xb1c0, 0xfff},
2894 {d68000_cmpi_8 , 0xffc0, 0x0c00, 0xbf8},
2895 {d68020_cmpi_pcdi_8 , 0xffff, 0x0c3a, 0x000},
2896 {d68020_cmpi_pcix_8 , 0xffff, 0x0c3b, 0x000},
2897 {d68000_cmpi_16 , 0xffc0, 0x0c40, 0xbf8},
2898 {d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000},
2899 {d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000},
2900 {d68000_cmpi_32 , 0xffc0, 0x0c80, 0xbf8},
2901 {d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000},
2902 {d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000},
2903 {d68000_cmpm_8 , 0xf1f8, 0xb108, 0x000},
2904 {d68000_cmpm_16 , 0xf1f8, 0xb148, 0x000},
2905 {d68000_cmpm_32 , 0xf1f8, 0xb188, 0x000},
2906 {d68020_cpbcc_16 , 0xf1c0, 0xf080, 0x000},
2907 {d68020_cpbcc_32 , 0xf1c0, 0xf0c0, 0x000},
2908 {d68020_cpdbcc , 0xf1f8, 0xf048, 0x000},
2909 {d68020_cpgen , 0xf1c0, 0xf000, 0x000},
2910 {d68020_cprestore , 0xf1c0, 0xf140, 0x37f},
2911 {d68020_cpsave , 0xf1c0, 0xf100, 0x2f8},
2912 {d68020_cpscc , 0xf1c0, 0xf040, 0xbf8},
2913 {d68020_cptrapcc_0 , 0xf1ff, 0xf07c, 0x000},
2914 {d68020_cptrapcc_16 , 0xf1ff, 0xf07a, 0x000},
2915 {d68020_cptrapcc_32 , 0xf1ff, 0xf07b, 0x000},
2916 {d68040_cpush , 0xff20, 0xf420, 0x000},
2917 {d68000_dbcc , 0xf0f8, 0x50c8, 0x000},
2918 {d68000_dbra , 0xfff8, 0x51c8, 0x000},
2919 {d68000_divs , 0xf1c0, 0x81c0, 0xbff},
2920 {d68000_divu , 0xf1c0, 0x80c0, 0xbff},
2921 {d68020_divl , 0xffc0, 0x4c40, 0xbff},
2922 {d68000_eor_8 , 0xf1c0, 0xb100, 0xbf8},
2923 {d68000_eor_16 , 0xf1c0, 0xb140, 0xbf8},
2924 {d68000_eor_32 , 0xf1c0, 0xb180, 0xbf8},
2925 {d68000_eori_to_ccr , 0xffff, 0x0a3c, 0x000},
2926 {d68000_eori_to_sr , 0xffff, 0x0a7c, 0x000},
2927 {d68000_eori_8 , 0xffc0, 0x0a00, 0xbf8},
2928 {d68000_eori_16 , 0xffc0, 0x0a40, 0xbf8},
2929 {d68000_eori_32 , 0xffc0, 0x0a80, 0xbf8},
2930 {d68000_exg_dd , 0xf1f8, 0xc140, 0x000},
2931 {d68000_exg_aa , 0xf1f8, 0xc148, 0x000},
2932 {d68000_exg_da , 0xf1f8, 0xc188, 0x000},
2933 {d68020_extb_32 , 0xfff8, 0x49c0, 0x000},
2934 {d68000_ext_16 , 0xfff8, 0x4880, 0x000},
2935 {d68000_ext_32 , 0xfff8, 0x48c0, 0x000},
2936 {d68000_illegal , 0xffff, 0x4afc, 0x000},
2937 {d68000_jmp , 0xffc0, 0x4ec0, 0x27b},
2938 {d68000_jsr , 0xffc0, 0x4e80, 0x27b},
2939 {d68000_lea , 0xf1c0, 0x41c0, 0x27b},
2940 {d68000_link_16 , 0xfff8, 0x4e50, 0x000},
2941 {d68020_link_32 , 0xfff8, 0x4808, 0x000},
2942 {d68000_lsr_s_8 , 0xf1f8, 0xe008, 0x000},
2943 {d68000_lsr_s_16 , 0xf1f8, 0xe048, 0x000},
2944 {d68000_lsr_s_32 , 0xf1f8, 0xe088, 0x000},
2945 {d68000_lsr_r_8 , 0xf1f8, 0xe028, 0x000},
2946 {d68000_lsr_r_16 , 0xf1f8, 0xe068, 0x000},
2947 {d68000_lsr_r_32 , 0xf1f8, 0xe0a8, 0x000},
2948 {d68000_lsr_ea , 0xffc0, 0xe2c0, 0x3f8},
2949 {d68000_lsl_s_8 , 0xf1f8, 0xe108, 0x000},
2950 {d68000_lsl_s_16 , 0xf1f8, 0xe148, 0x000},
2951 {d68000_lsl_s_32 , 0xf1f8, 0xe188, 0x000},
2952 {d68000_lsl_r_8 , 0xf1f8, 0xe128, 0x000},
2953 {d68000_lsl_r_16 , 0xf1f8, 0xe168, 0x000},
2954 {d68000_lsl_r_32 , 0xf1f8, 0xe1a8, 0x000},
2955 {d68000_lsl_ea , 0xffc0, 0xe3c0, 0x3f8},
2956 {d68000_move_8 , 0xf000, 0x1000, 0xbff},
2957 {d68000_move_16 , 0xf000, 0x3000, 0xfff},
2958 {d68000_move_32 , 0xf000, 0x2000, 0xfff},
2959 {d68000_movea_16 , 0xf1c0, 0x3040, 0xfff},
2960 {d68000_movea_32 , 0xf1c0, 0x2040, 0xfff},
2961 {d68000_move_to_ccr , 0xffc0, 0x44c0, 0xbff},
2962 {d68010_move_fr_ccr , 0xffc0, 0x42c0, 0xbf8},
2963 {d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff},
2964 {d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8},
2965 {d68000_move_to_usp , 0xfff8, 0x4e60, 0x000},
2966 {d68000_move_fr_usp , 0xfff8, 0x4e68, 0x000},
2967 {d68010_movec , 0xfffe, 0x4e7a, 0x000},
2968 {d68000_movem_pd_16 , 0xfff8, 0x48a0, 0x000},
2969 {d68000_movem_pd_32 , 0xfff8, 0x48e0, 0x000},
2970 {d68000_movem_re_16 , 0xffc0, 0x4880, 0x2f8},
2971 {d68000_movem_re_32 , 0xffc0, 0x48c0, 0x2f8},
2972 {d68000_movem_er_16 , 0xffc0, 0x4c80, 0x37b},
2973 {d68000_movem_er_32 , 0xffc0, 0x4cc0, 0x37b},
2974 {d68000_movep_er_16 , 0xf1f8, 0x0108, 0x000},
2975 {d68000_movep_er_32 , 0xf1f8, 0x0148, 0x000},
2976 {d68000_movep_re_16 , 0xf1f8, 0x0188, 0x000},
2977 {d68000_movep_re_32 , 0xf1f8, 0x01c8, 0x000},
2978 {d68010_moves_8 , 0xffc0, 0x0e00, 0x3f8},
2979 {d68010_moves_16 , 0xffc0, 0x0e40, 0x3f8},
2980 {d68010_moves_32 , 0xffc0, 0x0e80, 0x3f8},
2981 {d68000_moveq , 0xf100, 0x7000, 0x000},
2982 {d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000},
2983 {d68040_move16_pi_al , 0xfff8, 0xf600, 0x000},
2984 {d68040_move16_al_pi , 0xfff8, 0xf608, 0x000},
2985 {d68040_move16_ai_al , 0xfff8, 0xf610, 0x000},
2986 {d68040_move16_al_ai , 0xfff8, 0xf618, 0x000},
2987 {d68000_muls , 0xf1c0, 0xc1c0, 0xbff},
2988 {d68000_mulu , 0xf1c0, 0xc0c0, 0xbff},
2989 {d68020_mull , 0xffc0, 0x4c00, 0xbff},
2990 {d68000_nbcd , 0xffc0, 0x4800, 0xbf8},
2991 {d68000_neg_8 , 0xffc0, 0x4400, 0xbf8},
2992 {d68000_neg_16 , 0xffc0, 0x4440, 0xbf8},
2993 {d68000_neg_32 , 0xffc0, 0x4480, 0xbf8},
2994 {d68000_negx_8 , 0xffc0, 0x4000, 0xbf8},
2995 {d68000_negx_16 , 0xffc0, 0x4040, 0xbf8},
2996 {d68000_negx_32 , 0xffc0, 0x4080, 0xbf8},
2997 {d68000_nop , 0xffff, 0x4e71, 0x000},
2998 {d68000_not_8 , 0xffc0, 0x4600, 0xbf8},
2999 {d68000_not_16 , 0xffc0, 0x4640, 0xbf8},
3000 {d68000_not_32 , 0xffc0, 0x4680, 0xbf8},
3001 {d68000_or_er_8 , 0xf1c0, 0x8000, 0xbff},
3002 {d68000_or_er_16 , 0xf1c0, 0x8040, 0xbff},
3003 {d68000_or_er_32 , 0xf1c0, 0x8080, 0xbff},
3004 {d68000_or_re_8 , 0xf1c0, 0x8100, 0x3f8},
3005 {d68000_or_re_16 , 0xf1c0, 0x8140, 0x3f8},
3006 {d68000_or_re_32 , 0xf1c0, 0x8180, 0x3f8},
3007 {d68000_ori_to_ccr , 0xffff, 0x003c, 0x000},
3008 {d68000_ori_to_sr , 0xffff, 0x007c, 0x000},
3009 {d68000_ori_8 , 0xffc0, 0x0000, 0xbf8},
3010 {d68000_ori_16 , 0xffc0, 0x0040, 0xbf8},
3011 {d68000_ori_32 , 0xffc0, 0x0080, 0xbf8},
3012 {d68020_pack_rr , 0xf1f8, 0x8140, 0x000},
3013 {d68020_pack_mm , 0xf1f8, 0x8148, 0x000},
3014 {d68000_pea , 0xffc0, 0x4840, 0x27b},
3015 {d68000_reset , 0xffff, 0x4e70, 0x000},
3016 {d68000_ror_s_8 , 0xf1f8, 0xe018, 0x000},
3017 {d68000_ror_s_16 , 0xf1f8, 0xe058, 0x000},
3018 {d68000_ror_s_32 , 0xf1f8, 0xe098, 0x000},
3019 {d68000_ror_r_8 , 0xf1f8, 0xe038, 0x000},
3020 {d68000_ror_r_16 , 0xf1f8, 0xe078, 0x000},
3021 {d68000_ror_r_32 , 0xf1f8, 0xe0b8, 0x000},
3022 {d68000_ror_ea , 0xffc0, 0xe6c0, 0x3f8},
3023 {d68000_rol_s_8 , 0xf1f8, 0xe118, 0x000},
3024 {d68000_rol_s_16 , 0xf1f8, 0xe158, 0x000},
3025 {d68000_rol_s_32 , 0xf1f8, 0xe198, 0x000},
3026 {d68000_rol_r_8 , 0xf1f8, 0xe138, 0x000},
3027 {d68000_rol_r_16 , 0xf1f8, 0xe178, 0x000},
3028 {d68000_rol_r_32 , 0xf1f8, 0xe1b8, 0x000},
3029 {d68000_rol_ea , 0xffc0, 0xe7c0, 0x3f8},
3030 {d68000_roxr_s_8 , 0xf1f8, 0xe010, 0x000},
3031 {d68000_roxr_s_16 , 0xf1f8, 0xe050, 0x000},
3032 {d68000_roxr_s_32 , 0xf1f8, 0xe090, 0x000},
3033 {d68000_roxr_r_8 , 0xf1f8, 0xe030, 0x000},
3034 {d68000_roxr_r_16 , 0xf1f8, 0xe070, 0x000},
3035 {d68000_roxr_r_32 , 0xf1f8, 0xe0b0, 0x000},
3036 {d68000_roxr_ea , 0xffc0, 0xe4c0, 0x3f8},
3037 {d68000_roxl_s_8 , 0xf1f8, 0xe110, 0x000},
3038 {d68000_roxl_s_16 , 0xf1f8, 0xe150, 0x000},
3039 {d68000_roxl_s_32 , 0xf1f8, 0xe190, 0x000},
3040 {d68000_roxl_r_8 , 0xf1f8, 0xe130, 0x000},
3041 {d68000_roxl_r_16 , 0xf1f8, 0xe170, 0x000},
3042 {d68000_roxl_r_32 , 0xf1f8, 0xe1b0, 0x000},
3043 {d68000_roxl_ea , 0xffc0, 0xe5c0, 0x3f8},
3044 {d68010_rtd , 0xffff, 0x4e74, 0x000},
3045 {d68000_rte , 0xffff, 0x4e73, 0x000},
3046 {d68020_rtm , 0xfff0, 0x06c0, 0x000},
3047 {d68000_rtr , 0xffff, 0x4e77, 0x000},
3048 {d68000_rts , 0xffff, 0x4e75, 0x000},
3049 {d68000_sbcd_rr , 0xf1f8, 0x8100, 0x000},
3050 {d68000_sbcd_mm , 0xf1f8, 0x8108, 0x000},
3051 {d68000_scc , 0xf0c0, 0x50c0, 0xbf8},
3052 {d68000_stop , 0xffff, 0x4e72, 0x000},
3053 {d68000_sub_er_8 , 0xf1c0, 0x9000, 0xbff},
3054 {d68000_sub_er_16 , 0xf1c0, 0x9040, 0xfff},
3055 {d68000_sub_er_32 , 0xf1c0, 0x9080, 0xfff},
3056 {d68000_sub_re_8 , 0xf1c0, 0x9100, 0x3f8},
3057 {d68000_sub_re_16 , 0xf1c0, 0x9140, 0x3f8},
3058 {d68000_sub_re_32 , 0xf1c0, 0x9180, 0x3f8},
3059 {d68000_suba_16 , 0xf1c0, 0x90c0, 0xfff},
3060 {d68000_suba_32 , 0xf1c0, 0x91c0, 0xfff},
3061 {d68000_subi_8 , 0xffc0, 0x0400, 0xbf8},
3062 {d68000_subi_16 , 0xffc0, 0x0440, 0xbf8},
3063 {d68000_subi_32 , 0xffc0, 0x0480, 0xbf8},
3064 {d68000_subq_8 , 0xf1c0, 0x5100, 0xbf8},
3065 {d68000_subq_16 , 0xf1c0, 0x5140, 0xff8},
3066 {d68000_subq_32 , 0xf1c0, 0x5180, 0xff8},
3067 {d68000_subx_rr_8 , 0xf1f8, 0x9100, 0x000},
3068 {d68000_subx_rr_16 , 0xf1f8, 0x9140, 0x000},
3069 {d68000_subx_rr_32 , 0xf1f8, 0x9180, 0x000},
3070 {d68000_subx_mm_8 , 0xf1f8, 0x9108, 0x000},
3071 {d68000_subx_mm_16 , 0xf1f8, 0x9148, 0x000},
3072 {d68000_subx_mm_32 , 0xf1f8, 0x9188, 0x000},
3073 {d68000_swap , 0xfff8, 0x4840, 0x000},
3074 {d68000_tas , 0xffc0, 0x4ac0, 0xbf8},
3075 {d68000_trap , 0xfff0, 0x4e40, 0x000},
3076 {d68020_trapcc_0 , 0xf0ff, 0x50fc, 0x000},
3077 {d68020_trapcc_16 , 0xf0ff, 0x50fa, 0x000},
3078 {d68020_trapcc_32 , 0xf0ff, 0x50fb, 0x000},
3079 {d68000_trapv , 0xffff, 0x4e76, 0x000},
3080 {d68000_tst_8 , 0xffc0, 0x4a00, 0xbf8},
3081 {d68020_tst_pcdi_8 , 0xffff, 0x4a3a, 0x000},
3082 {d68020_tst_pcix_8 , 0xffff, 0x4a3b, 0x000},
3083 {d68020_tst_i_8 , 0xffff, 0x4a3c, 0x000},
3084 {d68000_tst_16 , 0xffc0, 0x4a40, 0xbf8},
3085 {d68020_tst_a_16 , 0xfff8, 0x4a48, 0x000},
3086 {d68020_tst_pcdi_16 , 0xffff, 0x4a7a, 0x000},
3087 {d68020_tst_pcix_16 , 0xffff, 0x4a7b, 0x000},
3088 {d68020_tst_i_16 , 0xffff, 0x4a7c, 0x000},
3089 {d68000_tst_32 , 0xffc0, 0x4a80, 0xbf8},
3090 {d68020_tst_a_32 , 0xfff8, 0x4a88, 0x000},
3091 {d68020_tst_pcdi_32 , 0xffff, 0x4aba, 0x000},
3092 {d68020_tst_pcix_32 , 0xffff, 0x4abb, 0x000},
3093 {d68020_tst_i_32 , 0xffff, 0x4abc, 0x000},
3094 {d68000_unlk , 0xfff8, 0x4e58, 0x000},
3095 {d68020_unpk_rr , 0xf1f8, 0x8180, 0x000},
3096 {d68020_unpk_mm , 0xf1f8, 0x8188, 0x000},
3100 /* Check if opcode is using a valid ea mode */
3101 static int valid_ea(uint opcode, uint mask)
3106 switch(opcode & 0x3f)
3108 case 0x00: case 0x01: case 0x02: case 0x03:
3109 case 0x04: case 0x05: case 0x06: case 0x07:
3110 return (mask & 0x800) != 0;
3111 case 0x08: case 0x09: case 0x0a: case 0x0b:
3112 case 0x0c: case 0x0d: case 0x0e: case 0x0f:
3113 return (mask & 0x400) != 0;
3114 case 0x10: case 0x11: case 0x12: case 0x13:
3115 case 0x14: case 0x15: case 0x16: case 0x17:
3116 return (mask & 0x200) != 0;
3117 case 0x18: case 0x19: case 0x1a: case 0x1b:
3118 case 0x1c: case 0x1d: case 0x1e: case 0x1f:
3119 return (mask & 0x100) != 0;
3120 case 0x20: case 0x21: case 0x22: case 0x23:
3121 case 0x24: case 0x25: case 0x26: case 0x27:
3122 return (mask & 0x080) != 0;
3123 case 0x28: case 0x29: case 0x2a: case 0x2b:
3124 case 0x2c: case 0x2d: case 0x2e: case 0x2f:
3125 return (mask & 0x040) != 0;
3126 case 0x30: case 0x31: case 0x32: case 0x33:
3127 case 0x34: case 0x35: case 0x36: case 0x37:
3128 return (mask & 0x020) != 0;
3130 return (mask & 0x010) != 0;
3132 return (mask & 0x008) != 0;
3134 return (mask & 0x002) != 0;
3136 return (mask & 0x001) != 0;
3138 return (mask & 0x004) != 0;
3145 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr)
3147 uint a = ((const opcode_struct*)aptr)->mask;
3148 uint b = ((const opcode_struct*)bptr)->mask;
3150 a = ((a & 0xAAAA) >> 1) + (a & 0x5555);
3151 a = ((a & 0xCCCC) >> 2) + (a & 0x3333);
3152 a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F);
3153 a = ((a & 0xFF00) >> 8) + (a & 0x00FF);
3155 b = ((b & 0xAAAA) >> 1) + (b & 0x5555);
3156 b = ((b & 0xCCCC) >> 2) + (b & 0x3333);
3157 b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F);
3158 b = ((b & 0xFF00) >> 8) + (b & 0x00FF);
3160 return b - a; /* reversed to get greatest to least sorting */
3163 /* build the opcode handler jump table */
3164 static void build_opcode_table(void)
3168 opcode_struct* ostruct;
3169 uint opcode_info_length = 0;
3171 for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
3172 opcode_info_length++;
3174 qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits);
3176 for(i=0;i<0x10000;i++)
3178 g_instruction_table[i] = d68000_illegal; /* default to illegal */
3180 /* search through opcode info for a match */
3181 for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
3183 /* match opcode mask and allowed ea modes */
3184 if((opcode & ostruct->mask) == ostruct->match)
3186 /* Handle destination ea for move instructions */
3187 if((ostruct->opcode_handler == d68000_move_8 ||
3188 ostruct->opcode_handler == d68000_move_16 ||
3189 ostruct->opcode_handler == d68000_move_32) &&
3190 !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8))
3192 if(valid_ea(opcode, ostruct->ea_mask))
3194 g_instruction_table[i] = ostruct->opcode_handler;
3204 /* ======================================================================== */
3205 /* ================================= API ================================== */
3206 /* ======================================================================== */
3208 /* Disasemble one instruction at pc and store in str_buff */
3209 unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type)
3213 build_opcode_table();
3218 case M68K_CPU_TYPE_68000:
3219 g_cpu_type = TYPE_68000;
3220 g_address_mask = 0x00ffffff;
3222 case M68K_CPU_TYPE_68010:
3223 g_cpu_type = TYPE_68010;
3224 g_address_mask = 0x00ffffff;
3226 case M68K_CPU_TYPE_68EC020:
3227 g_cpu_type = TYPE_68020;
3228 g_address_mask = 0x00ffffff;
3230 case M68K_CPU_TYPE_68020:
3231 g_cpu_type = TYPE_68020;
3232 g_address_mask = 0xffffffff;
3234 case M68K_CPU_TYPE_68030:
3235 g_cpu_type = TYPE_68030;
3236 g_address_mask = 0xffffffff;
3238 case M68K_CPU_TYPE_68040:
3239 g_cpu_type = TYPE_68040;
3240 g_address_mask = 0xffffffff;
3247 g_helper_str[0] = 0;
3248 g_cpu_ir = read_imm_16();
3249 g_instruction_table[g_cpu_ir]();
3250 sprintf(str_buff, "%s%s", g_dasm_str, g_helper_str);
3251 return g_cpu_pc - pc;
3254 char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type)
3256 static char buff[100];
3258 m68k_disassemble(buff, pc, cpu_type);
3262 /* Check if the instruction is a valid one */
3263 unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type)
3267 build_opcode_table();
3271 instruction &= 0xffff;
3272 if(g_instruction_table[instruction] == d68000_illegal)
3277 case M68K_CPU_TYPE_68000:
3278 if(g_instruction_table[instruction] == d68010_bkpt)
3280 if(g_instruction_table[instruction] == d68010_move_fr_ccr)
3282 if(g_instruction_table[instruction] == d68010_movec)
3284 if(g_instruction_table[instruction] == d68010_moves_8)
3286 if(g_instruction_table[instruction] == d68010_moves_16)
3288 if(g_instruction_table[instruction] == d68010_moves_32)
3290 if(g_instruction_table[instruction] == d68010_rtd)
3292 case M68K_CPU_TYPE_68010:
3293 if(g_instruction_table[instruction] == d68020_bcc_32)
3295 if(g_instruction_table[instruction] == d68020_bfchg)
3297 if(g_instruction_table[instruction] == d68020_bfclr)
3299 if(g_instruction_table[instruction] == d68020_bfexts)
3301 if(g_instruction_table[instruction] == d68020_bfextu)
3303 if(g_instruction_table[instruction] == d68020_bfffo)
3305 if(g_instruction_table[instruction] == d68020_bfins)
3307 if(g_instruction_table[instruction] == d68020_bfset)
3309 if(g_instruction_table[instruction] == d68020_bftst)
3311 if(g_instruction_table[instruction] == d68020_bra_32)
3313 if(g_instruction_table[instruction] == d68020_bsr_32)
3315 if(g_instruction_table[instruction] == d68020_callm)
3317 if(g_instruction_table[instruction] == d68020_cas_8)
3319 if(g_instruction_table[instruction] == d68020_cas_16)
3321 if(g_instruction_table[instruction] == d68020_cas_32)
3323 if(g_instruction_table[instruction] == d68020_cas2_16)
3325 if(g_instruction_table[instruction] == d68020_cas2_32)
3327 if(g_instruction_table[instruction] == d68020_chk_32)
3329 if(g_instruction_table[instruction] == d68020_chk2_cmp2_8)
3331 if(g_instruction_table[instruction] == d68020_chk2_cmp2_16)
3333 if(g_instruction_table[instruction] == d68020_chk2_cmp2_32)
3335 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_8)
3337 if(g_instruction_table[instruction] == d68020_cmpi_pcix_8)
3339 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_16)
3341 if(g_instruction_table[instruction] == d68020_cmpi_pcix_16)
3343 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_32)
3345 if(g_instruction_table[instruction] == d68020_cmpi_pcix_32)
3347 if(g_instruction_table[instruction] == d68020_cpbcc_16)
3349 if(g_instruction_table[instruction] == d68020_cpbcc_32)
3351 if(g_instruction_table[instruction] == d68020_cpdbcc)
3353 if(g_instruction_table[instruction] == d68020_cpgen)
3355 if(g_instruction_table[instruction] == d68020_cprestore)
3357 if(g_instruction_table[instruction] == d68020_cpsave)
3359 if(g_instruction_table[instruction] == d68020_cpscc)
3361 if(g_instruction_table[instruction] == d68020_cptrapcc_0)
3363 if(g_instruction_table[instruction] == d68020_cptrapcc_16)
3365 if(g_instruction_table[instruction] == d68020_cptrapcc_32)
3367 if(g_instruction_table[instruction] == d68020_divl)
3369 if(g_instruction_table[instruction] == d68020_extb_32)
3371 if(g_instruction_table[instruction] == d68020_link_32)
3373 if(g_instruction_table[instruction] == d68020_mull)
3375 if(g_instruction_table[instruction] == d68020_pack_rr)
3377 if(g_instruction_table[instruction] == d68020_pack_mm)
3379 if(g_instruction_table[instruction] == d68020_rtm)
3381 if(g_instruction_table[instruction] == d68020_trapcc_0)
3383 if(g_instruction_table[instruction] == d68020_trapcc_16)
3385 if(g_instruction_table[instruction] == d68020_trapcc_32)
3387 if(g_instruction_table[instruction] == d68020_tst_pcdi_8)
3389 if(g_instruction_table[instruction] == d68020_tst_pcix_8)
3391 if(g_instruction_table[instruction] == d68020_tst_i_8)
3393 if(g_instruction_table[instruction] == d68020_tst_a_16)
3395 if(g_instruction_table[instruction] == d68020_tst_pcdi_16)
3397 if(g_instruction_table[instruction] == d68020_tst_pcix_16)
3399 if(g_instruction_table[instruction] == d68020_tst_i_16)
3401 if(g_instruction_table[instruction] == d68020_tst_a_32)
3403 if(g_instruction_table[instruction] == d68020_tst_pcdi_32)
3405 if(g_instruction_table[instruction] == d68020_tst_pcix_32)
3407 if(g_instruction_table[instruction] == d68020_tst_i_32)
3409 if(g_instruction_table[instruction] == d68020_unpk_rr)
3411 if(g_instruction_table[instruction] == d68020_unpk_mm)
3413 case M68K_CPU_TYPE_68EC020:
3414 case M68K_CPU_TYPE_68020:
3415 case M68K_CPU_TYPE_68030:
3416 if(g_instruction_table[instruction] == d68040_cinv)
3418 if(g_instruction_table[instruction] == d68040_cpush)
3420 if(g_instruction_table[instruction] == d68040_move16_pi_pi)
3422 if(g_instruction_table[instruction] == d68040_move16_pi_al)
3424 if(g_instruction_table[instruction] == d68040_move16_al_pi)
3426 if(g_instruction_table[instruction] == d68040_move16_ai_al)
3428 if(g_instruction_table[instruction] == d68040_move16_al_ai)
3431 if(cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 &&
3432 (g_instruction_table[instruction] == d68020_callm ||
3433 g_instruction_table[instruction] == d68020_rtm))
3441 /* ======================================================================== */
3442 /* ============================== END OF FILE ============================= */
3443 /* ======================================================================== */