1 /* ======================================================================== */
2 /* ========================= LICENSING & COPYRIGHT ======================== */
3 /* ======================================================================== */
8 * A portable Motorola M680x0 processor emulation engine.
9 * Copyright 1998-2001 Karl Stenerud. All rights reserved.
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32 /* ======================================================================== */
33 /* ================================ INCLUDES ============================== */
34 /* ======================================================================== */
45 /* ======================================================================== */
46 /* ============================ GENERAL DEFINES =========================== */
47 /* ======================================================================== */
49 /* unsigned int and int must be at least 32 bits wide */
51 #define uint unsigned int
53 /* Bit Isolation Functions */
54 #define BIT_0(A) ((A) & 0x00000001)
55 #define BIT_1(A) ((A) & 0x00000002)
56 #define BIT_2(A) ((A) & 0x00000004)
57 #define BIT_3(A) ((A) & 0x00000008)
58 #define BIT_4(A) ((A) & 0x00000010)
59 #define BIT_5(A) ((A) & 0x00000020)
60 #define BIT_6(A) ((A) & 0x00000040)
61 #define BIT_7(A) ((A) & 0x00000080)
62 #define BIT_8(A) ((A) & 0x00000100)
63 #define BIT_9(A) ((A) & 0x00000200)
64 #define BIT_A(A) ((A) & 0x00000400)
65 #define BIT_B(A) ((A) & 0x00000800)
66 #define BIT_C(A) ((A) & 0x00001000)
67 #define BIT_D(A) ((A) & 0x00002000)
68 #define BIT_E(A) ((A) & 0x00004000)
69 #define BIT_F(A) ((A) & 0x00008000)
70 #define BIT_10(A) ((A) & 0x00010000)
71 #define BIT_11(A) ((A) & 0x00020000)
72 #define BIT_12(A) ((A) & 0x00040000)
73 #define BIT_13(A) ((A) & 0x00080000)
74 #define BIT_14(A) ((A) & 0x00100000)
75 #define BIT_15(A) ((A) & 0x00200000)
76 #define BIT_16(A) ((A) & 0x00400000)
77 #define BIT_17(A) ((A) & 0x00800000)
78 #define BIT_18(A) ((A) & 0x01000000)
79 #define BIT_19(A) ((A) & 0x02000000)
80 #define BIT_1A(A) ((A) & 0x04000000)
81 #define BIT_1B(A) ((A) & 0x08000000)
82 #define BIT_1C(A) ((A) & 0x10000000)
83 #define BIT_1D(A) ((A) & 0x20000000)
84 #define BIT_1E(A) ((A) & 0x40000000)
85 #define BIT_1F(A) ((A) & 0x80000000)
87 /* These are the CPU types understood by this disassembler */
94 #define M68000_ONLY TYPE_68000
96 #define M68010_ONLY TYPE_68010
97 #define M68010_LESS (TYPE_68000 | TYPE_68010)
98 #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040)
100 #define M68020_ONLY TYPE_68020
101 #define M68020_LESS (TYPE_68010 | TYPE_68020)
102 #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040)
104 #define M68030_ONLY TYPE_68030
105 #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030)
106 #define M68030_PLUS (TYPE_68030 | TYPE_68040)
108 #define M68040_PLUS TYPE_68040
111 /* Extension word formats */
112 #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff)
113 #define EXT_FULL(A) BIT_8(A)
114 #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0)
115 #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A))
116 #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A))
117 #define EXT_INDEX_REGISTER(A) (((A)>>12)&7)
118 #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3)
119 #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0)
120 #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4)
121 #define EXT_INDEX_SCALE(A) (((A)>>9)&3)
122 #define EXT_INDEX_LONG(A) BIT_B(A)
123 #define EXT_INDEX_AR(A) BIT_F(A)
124 #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10)
125 #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20)
126 #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30)
127 #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44)
128 #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44)
129 #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44)
133 /* ======================================================================== */
134 /* =============================== PROTOTYPES ============================= */
135 /* ======================================================================== */
137 /* Read data at the PC and increment PC */
138 uint read_imm_8(void);
139 uint read_imm_16(void);
140 uint read_imm_32(void);
142 /* Read data at the PC but don't imcrement the PC */
143 uint peek_imm_8(void);
144 uint peek_imm_16(void);
145 uint peek_imm_32(void);
147 /* make signed integers 100% portably */
148 static int make_int_8(int value);
149 static int make_int_16(int value);
151 /* make a string of a hex value */
152 static char* make_signed_hex_str_8(uint val);
153 static char* make_signed_hex_str_16(uint val);
154 static char* make_signed_hex_str_32(uint val);
156 /* make string of ea mode */
157 static char* get_ea_mode_str(uint instruction, uint size);
159 char* get_ea_mode_str_8(uint instruction);
160 char* get_ea_mode_str_16(uint instruction);
161 char* get_ea_mode_str_32(uint instruction);
163 /* make string of immediate value */
164 static char* get_imm_str_s(uint size);
165 static char* get_imm_str_u(uint size);
167 char* get_imm_str_s8(void);
168 char* get_imm_str_s16(void);
169 char* get_imm_str_s32(void);
171 /* Stuff to build the opcode handler jump table */
172 static void build_opcode_table(void);
173 static int valid_ea(uint opcode, uint mask);
174 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr);
176 /* used to build opcode handler jump table */
179 void (*opcode_handler)(void); /* handler function */
180 uint mask; /* mask on opcode */
181 uint match; /* what to match after masking */
182 uint ea_mask; /* what ea modes are allowed */
187 /* ======================================================================== */
188 /* ================================= DATA ================================= */
189 /* ======================================================================== */
191 /* Opcode handler jump table */
192 static void (*g_instruction_table[0x10000])(void);
193 /* Flag if disassembler initialized */
194 static int g_initialized = 0;
196 /* Address mask to simulate address lines */
197 static unsigned int g_address_mask = 0xffffffff;
199 static char g_dasm_str[100]; /* string to hold disassembly */
200 static char g_helper_str[100]; /* string to hold helpful info */
201 static uint g_cpu_pc; /* program counter */
202 static uint g_cpu_ir; /* instruction register */
203 static uint g_cpu_type;
205 /* used by ops like asr, ror, addq, etc */
206 static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
208 static uint g_5bit_data_table[32] =
210 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
211 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
214 static char* g_cc[16] =
215 {"t", "f", "hi", "ls", "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi", "ge", "lt", "gt", "le"};
217 static char* g_cpcc[64] =
218 {/* 000 001 010 011 100 101 110 111 */
219 "f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */
220 "un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */
221 "sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */
222 "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */
223 "?", "?", "?", "?", "?", "?", "?", "?", /* 100 */
224 "?", "?", "?", "?", "?", "?", "?", "?", /* 101 */
225 "?", "?", "?", "?", "?", "?", "?", "?", /* 110 */
226 "?", "?", "?", "?", "?", "?", "?", "?" /* 111 */
230 /* ======================================================================== */
231 /* =========================== UTILITY FUNCTIONS ========================== */
232 /* ======================================================================== */
234 #define LIMIT_CPU_TYPES(ALLOWED_CPU_TYPES) \
235 if(!(g_cpu_type & ALLOWED_CPU_TYPES)) \
241 #define read_imm_8() (m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)&0xff)
242 #define read_imm_16() m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)
243 #define read_imm_32() m68k_read_disassembler_32(((g_cpu_pc+=4)-4)&g_address_mask)
245 #define peek_imm_8() (m68k_read_disassembler_16(g_cpu_pc & g_address_mask)&0xff)
246 #define peek_imm_16() m68k_read_disassembler_16(g_cpu_pc & g_address_mask)
247 #define peek_imm_32() m68k_read_disassembler_32(g_cpu_pc & g_address_mask)
249 /* Fake a split interface */
250 #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0)
251 #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1)
252 #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2)
254 #define get_imm_str_s8() get_imm_str_s(0)
255 #define get_imm_str_s16() get_imm_str_s(1)
256 #define get_imm_str_s32() get_imm_str_s(2)
258 #define get_imm_str_u8() get_imm_str_u(0)
259 #define get_imm_str_u16() get_imm_str_u(1)
260 #define get_imm_str_u32() get_imm_str_u(2)
263 /* 100% portable signed int generators */
264 static int make_int_8(int value)
266 return (value & 0x80) ? value | ~0xff : value & 0xff;
269 static int make_int_16(int value)
271 return (value & 0x8000) ? value | ~0xffff : value & 0xffff;
275 /* Get string representation of hex values */
276 static char* make_signed_hex_str_8(uint val)
283 sprintf(str, "-$80");
285 sprintf(str, "-$%x", (0-val) & 0x7f);
287 sprintf(str, "$%x", val & 0x7f);
292 static char* make_signed_hex_str_16(uint val)
299 sprintf(str, "-$8000");
300 else if(val & 0x8000)
301 sprintf(str, "-$%x", (0-val) & 0x7fff);
303 sprintf(str, "$%x", val & 0x7fff);
308 static char* make_signed_hex_str_32(uint val)
314 if(val == 0x80000000)
315 sprintf(str, "-$80000000");
316 else if(val & 0x80000000)
317 sprintf(str, "-$%x", (0-val) & 0x7fffffff);
319 sprintf(str, "$%x", val & 0x7fffffff);
325 /* make string of immediate value */
326 static char* get_imm_str_s(uint size)
330 sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8()));
332 sprintf(str, "#%s", make_signed_hex_str_16(read_imm_16()));
334 sprintf(str, "#%s", make_signed_hex_str_32(read_imm_32()));
338 static char* get_imm_str_u(uint size)
342 sprintf(str, "#$%x", read_imm_8() & 0xff);
344 sprintf(str, "#$%x", read_imm_16() & 0xffff);
346 sprintf(str, "#$%x", read_imm_32() & 0xffffffff);
350 /* Make string of effective address mode */
351 static char* get_ea_mode_str(uint instruction, uint size)
355 static char* mode = b2;
366 /* Switch buffers so we don't clobber on a double-call to this function */
367 mode = mode == b1 ? b2 : b1;
369 switch(instruction & 0x3f)
371 case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
372 /* data register direct */
373 sprintf(mode, "D%d", instruction&7);
375 case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
376 /* address register direct */
377 sprintf(mode, "A%d", instruction&7);
379 case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
380 /* address register indirect */
381 sprintf(mode, "(A%d)", instruction&7);
383 case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
384 /* address register indirect with postincrement */
385 sprintf(mode, "(A%d)+", instruction&7);
387 case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
388 /* address register indirect with predecrement */
389 sprintf(mode, "-(A%d)", instruction&7);
391 case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
392 /* address register indirect with displacement*/
393 sprintf(mode, "(%s,A%d)", make_signed_hex_str_16(read_imm_16()), instruction&7);
395 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
396 /* address register indirect with index */
397 extension = read_imm_16();
399 if(EXT_FULL(extension))
401 if(EXT_EFFECTIVE_ZERO(extension))
406 base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
407 outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
408 if(EXT_BASE_REGISTER_PRESENT(extension))
409 sprintf(base_reg, "A%d", instruction&7);
412 if(EXT_INDEX_REGISTER_PRESENT(extension))
414 sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
415 if(EXT_INDEX_SCALE(extension))
416 sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
420 preindex = (extension&7) > 0 && (extension&7) < 4;
421 postindex = (extension&7) > 4;
424 if(preindex || postindex)
428 strcat(mode, make_signed_hex_str_16(base));
435 strcat(mode, base_reg);
447 strcat(mode, index_reg);
459 strcat(mode, make_signed_hex_str_16(outer));
465 if(EXT_8BIT_DISPLACEMENT(extension) == 0)
466 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');
468 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');
469 if(EXT_INDEX_SCALE(extension))
470 sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
474 /* absolute short address */
475 sprintf(mode, "$%x.w", read_imm_16());
478 /* absolute long address */
479 sprintf(mode, "$%x.l", read_imm_32());
482 /* program counter with displacement */
483 temp_value = read_imm_16();
484 sprintf(mode, "(%s,PC)", make_signed_hex_str_16(temp_value));
485 sprintf(g_helper_str, "; ($%x)", (make_int_16(temp_value) + g_cpu_pc-2) & 0xffffffff);
488 /* program counter with index */
489 extension = read_imm_16();
491 if(EXT_FULL(extension))
493 if(EXT_EFFECTIVE_ZERO(extension))
498 base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
499 outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
500 if(EXT_BASE_REGISTER_PRESENT(extension))
501 strcpy(base_reg, "PC");
504 if(EXT_INDEX_REGISTER_PRESENT(extension))
506 sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
507 if(EXT_INDEX_SCALE(extension))
508 sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
512 preindex = (extension&7) > 0 && (extension&7) < 4;
513 postindex = (extension&7) > 4;
516 if(preindex || postindex)
520 strcat(mode, make_signed_hex_str_16(base));
527 strcat(mode, base_reg);
539 strcat(mode, index_reg);
551 strcat(mode, make_signed_hex_str_16(outer));
557 if(EXT_8BIT_DISPLACEMENT(extension) == 0)
558 sprintf(mode, "(PC,%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
560 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');
561 if(EXT_INDEX_SCALE(extension))
562 sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
567 sprintf(mode, "%s", get_imm_str_u(size));
570 sprintf(mode, "INVALID %x", instruction & 0x3f);
577 /* ======================================================================== */
578 /* ========================= INSTRUCTION HANDLERS ========================= */
579 /* ======================================================================== */
580 /* Instruction handler function names follow this convention:
582 * d68000_NAME_EXTENSIONS(void)
583 * where NAME is the name of the opcode it handles and EXTENSIONS are any
584 * extensions for special instances of that opcode.
587 * d68000_add_er_8(): add opcode, from effective address to register,
590 * d68000_asr_s_8(): arithmetic shift right, static count, size = byte
597 * rr : register to register
598 * mm : memory to memory
601 * er : effective address -> register
602 * re : register -> effective address
603 * ea : using effective address mode of operation
604 * d : data register direct
605 * a : address register direct
606 * ai : address register indirect
607 * pi : address register indirect with postincrement
608 * pd : address register indirect with predecrement
609 * di : address register indirect with displacement
610 * ix : address register indirect with index
615 static void d68000_illegal(void)
617 sprintf(g_dasm_str, "dc.w $%04x; ILLEGAL", g_cpu_ir);
620 static void d68000_1010(void)
622 sprintf(g_dasm_str, "dc.w $%04x; opcode 1010", g_cpu_ir);
626 static void d68000_1111(void)
628 sprintf(g_dasm_str, "dc.w $%04x; opcode 1111", g_cpu_ir);
632 static void d68000_abcd_rr(void)
634 sprintf(g_dasm_str, "abcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
638 static void d68000_abcd_mm(void)
640 sprintf(g_dasm_str, "abcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
643 static void d68000_add_er_8(void)
645 sprintf(g_dasm_str, "add.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
649 static void d68000_add_er_16(void)
651 sprintf(g_dasm_str, "add.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
654 static void d68000_add_er_32(void)
656 sprintf(g_dasm_str, "add.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
659 static void d68000_add_re_8(void)
661 sprintf(g_dasm_str, "add.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
664 static void d68000_add_re_16(void)
666 sprintf(g_dasm_str, "add.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
669 static void d68000_add_re_32(void)
671 sprintf(g_dasm_str, "add.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
674 static void d68000_adda_16(void)
676 sprintf(g_dasm_str, "adda.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
679 static void d68000_adda_32(void)
681 sprintf(g_dasm_str, "adda.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
684 static void d68000_addi_8(void)
686 char* str = get_imm_str_s8();
687 sprintf(g_dasm_str, "addi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
690 static void d68000_addi_16(void)
692 char* str = get_imm_str_s16();
693 sprintf(g_dasm_str, "addi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
696 static void d68000_addi_32(void)
698 char* str = get_imm_str_s32();
699 sprintf(g_dasm_str, "addi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
702 static void d68000_addq_8(void)
704 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));
707 static void d68000_addq_16(void)
709 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));
712 static void d68000_addq_32(void)
714 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));
717 static void d68000_addx_rr_8(void)
719 sprintf(g_dasm_str, "addx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
722 static void d68000_addx_rr_16(void)
724 sprintf(g_dasm_str, "addx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
727 static void d68000_addx_rr_32(void)
729 sprintf(g_dasm_str, "addx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
732 static void d68000_addx_mm_8(void)
734 sprintf(g_dasm_str, "addx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
737 static void d68000_addx_mm_16(void)
739 sprintf(g_dasm_str, "addx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
742 static void d68000_addx_mm_32(void)
744 sprintf(g_dasm_str, "addx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
747 static void d68000_and_er_8(void)
749 sprintf(g_dasm_str, "and.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
752 static void d68000_and_er_16(void)
754 sprintf(g_dasm_str, "and.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
757 static void d68000_and_er_32(void)
759 sprintf(g_dasm_str, "and.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
762 static void d68000_and_re_8(void)
764 sprintf(g_dasm_str, "and.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
767 static void d68000_and_re_16(void)
769 sprintf(g_dasm_str, "and.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
772 static void d68000_and_re_32(void)
774 sprintf(g_dasm_str, "and.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
777 static void d68000_andi_8(void)
779 char* str = get_imm_str_u8();
780 sprintf(g_dasm_str, "andi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
783 static void d68000_andi_16(void)
785 char* str = get_imm_str_u16();
786 sprintf(g_dasm_str, "andi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
789 static void d68000_andi_32(void)
791 char* str = get_imm_str_u32();
792 sprintf(g_dasm_str, "andi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
795 static void d68000_andi_to_ccr(void)
797 sprintf(g_dasm_str, "andi %s, CCR", get_imm_str_u8());
800 static void d68000_andi_to_sr(void)
802 sprintf(g_dasm_str, "andi %s, SR", get_imm_str_u16());
805 static void d68000_asr_s_8(void)
807 sprintf(g_dasm_str, "asr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
810 static void d68000_asr_s_16(void)
812 sprintf(g_dasm_str, "asr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
815 static void d68000_asr_s_32(void)
817 sprintf(g_dasm_str, "asr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
820 static void d68000_asr_r_8(void)
822 sprintf(g_dasm_str, "asr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
825 static void d68000_asr_r_16(void)
827 sprintf(g_dasm_str, "asr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
830 static void d68000_asr_r_32(void)
832 sprintf(g_dasm_str, "asr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
835 static void d68000_asr_ea(void)
837 sprintf(g_dasm_str, "asr.w %s", get_ea_mode_str_16(g_cpu_ir));
840 static void d68000_asl_s_8(void)
842 sprintf(g_dasm_str, "asl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
845 static void d68000_asl_s_16(void)
847 sprintf(g_dasm_str, "asl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
850 static void d68000_asl_s_32(void)
852 sprintf(g_dasm_str, "asl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
855 static void d68000_asl_r_8(void)
857 sprintf(g_dasm_str, "asl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
860 static void d68000_asl_r_16(void)
862 sprintf(g_dasm_str, "asl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
865 static void d68000_asl_r_32(void)
867 sprintf(g_dasm_str, "asl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
870 static void d68000_asl_ea(void)
872 sprintf(g_dasm_str, "asl.w %s", get_ea_mode_str_16(g_cpu_ir));
875 static void d68000_bcc_8(void)
877 uint temp_pc = g_cpu_pc;
878 sprintf(g_dasm_str, "b%-2s %x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_8(g_cpu_ir));
881 static void d68000_bcc_16(void)
883 uint temp_pc = g_cpu_pc;
884 sprintf(g_dasm_str, "b%-2s %x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_16(read_imm_16()));
887 static void d68020_bcc_32(void)
889 uint temp_pc = g_cpu_pc;
890 LIMIT_CPU_TYPES(M68020_PLUS);
891 sprintf(g_dasm_str, "b%-2s %x; (2+)", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + read_imm_32());
894 static void d68000_bchg_r(void)
896 sprintf(g_dasm_str, "bchg D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
899 static void d68000_bchg_s(void)
901 char* str = get_imm_str_u8();
902 sprintf(g_dasm_str, "bchg %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
905 static void d68000_bclr_r(void)
907 sprintf(g_dasm_str, "bclr D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
910 static void d68000_bclr_s(void)
912 char* str = get_imm_str_u8();
913 sprintf(g_dasm_str, "bclr %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
916 static void d68010_bkpt(void)
918 LIMIT_CPU_TYPES(M68010_PLUS);
919 sprintf(g_dasm_str, "bkpt #%d; (1+)", g_cpu_ir&7);
922 static void d68020_bfchg(void)
928 LIMIT_CPU_TYPES(M68020_PLUS);
930 extension = read_imm_16();
933 sprintf(offset, "D%d", (extension>>6)&7);
935 sprintf(offset, "%d", (extension>>6)&31);
937 sprintf(width, "D%d", extension&7);
939 sprintf(width, "%d", g_5bit_data_table[extension&31]);
940 sprintf(g_dasm_str, "bfchg %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
943 static void d68020_bfclr(void)
949 LIMIT_CPU_TYPES(M68020_PLUS);
951 extension = read_imm_16();
954 sprintf(offset, "D%d", (extension>>6)&7);
956 sprintf(offset, "%d", (extension>>6)&31);
958 sprintf(width, "D%d", extension&7);
960 sprintf(width, "%d", g_5bit_data_table[extension&31]);
961 sprintf(g_dasm_str, "bfclr %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
964 static void d68020_bfexts(void)
970 LIMIT_CPU_TYPES(M68020_PLUS);
972 extension = read_imm_16();
975 sprintf(offset, "D%d", (extension>>6)&7);
977 sprintf(offset, "%d", (extension>>6)&31);
979 sprintf(width, "D%d", extension&7);
981 sprintf(width, "%d", g_5bit_data_table[extension&31]);
982 sprintf(g_dasm_str, "bfexts %s {%s:%s}, D%d; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width, (extension>>12)&7);
985 static void d68020_bfextu(void)
991 LIMIT_CPU_TYPES(M68020_PLUS);
993 extension = read_imm_16();
996 sprintf(offset, "D%d", (extension>>6)&7);
998 sprintf(offset, "%d", (extension>>6)&31);
1000 sprintf(width, "D%d", extension&7);
1002 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1003 sprintf(g_dasm_str, "bfextu %s {%s:%s}, D%d; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width, (extension>>12)&7);
1006 static void d68020_bfffo(void)
1012 LIMIT_CPU_TYPES(M68020_PLUS);
1014 extension = read_imm_16();
1016 if(BIT_B(extension))
1017 sprintf(offset, "D%d", (extension>>6)&7);
1019 sprintf(offset, "%d", (extension>>6)&31);
1020 if(BIT_5(extension))
1021 sprintf(width, "D%d", extension&7);
1023 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1024 sprintf(g_dasm_str, "bfffo %s {%s:%s}, D%d; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width, (extension>>12)&7);
1027 static void d68020_bfins(void)
1033 LIMIT_CPU_TYPES(M68020_PLUS);
1035 extension = read_imm_16();
1037 if(BIT_B(extension))
1038 sprintf(offset, "D%d", (extension>>6)&7);
1040 sprintf(offset, "%d", (extension>>6)&31);
1041 if(BIT_5(extension))
1042 sprintf(width, "D%d", extension&7);
1044 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1045 sprintf(g_dasm_str, "bfins D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
1048 static void d68020_bfset(void)
1054 LIMIT_CPU_TYPES(M68020_PLUS);
1056 extension = read_imm_16();
1058 if(BIT_B(extension))
1059 sprintf(offset, "D%d", (extension>>6)&7);
1061 sprintf(offset, "%d", (extension>>6)&31);
1062 if(BIT_5(extension))
1063 sprintf(width, "D%d", extension&7);
1065 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1066 sprintf(g_dasm_str, "bfset %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
1069 static void d68020_bftst(void)
1075 LIMIT_CPU_TYPES(M68020_PLUS);
1077 extension = read_imm_16();
1079 if(BIT_B(extension))
1080 sprintf(offset, "D%d", (extension>>6)&7);
1082 sprintf(offset, "%d", (extension>>6)&31);
1083 if(BIT_5(extension))
1084 sprintf(width, "D%d", extension&7);
1086 sprintf(width, "%d", g_5bit_data_table[extension&31]);
1087 sprintf(g_dasm_str, "bftst %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
1090 static void d68000_bra_8(void)
1092 uint temp_pc = g_cpu_pc;
1093 sprintf(g_dasm_str, "bra %x", temp_pc + make_int_8(g_cpu_ir));
1096 static void d68000_bra_16(void)
1098 uint temp_pc = g_cpu_pc;
1099 sprintf(g_dasm_str, "bra %x", temp_pc + make_int_16(read_imm_16()));
1102 static void d68020_bra_32(void)
1104 uint temp_pc = g_cpu_pc;
1105 LIMIT_CPU_TYPES(M68020_PLUS);
1106 sprintf(g_dasm_str, "bra %x; (2+)", temp_pc + read_imm_32());
1109 static void d68000_bset_r(void)
1111 sprintf(g_dasm_str, "bset D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1114 static void d68000_bset_s(void)
1116 char* str = get_imm_str_u8();
1117 sprintf(g_dasm_str, "bset %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1120 static void d68000_bsr_8(void)
1122 uint temp_pc = g_cpu_pc;
1123 sprintf(g_dasm_str, "bsr %x", temp_pc + make_int_8(g_cpu_ir));
1126 static void d68000_bsr_16(void)
1128 uint temp_pc = g_cpu_pc;
1129 sprintf(g_dasm_str, "bsr %x", temp_pc + make_int_16(read_imm_16()));
1132 static void d68020_bsr_32(void)
1134 uint temp_pc = g_cpu_pc;
1135 LIMIT_CPU_TYPES(M68020_PLUS);
1136 sprintf(g_dasm_str, "bsr %x; (2+)", temp_pc + peek_imm_32());
1139 static void d68000_btst_r(void)
1141 sprintf(g_dasm_str, "btst D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1144 static void d68000_btst_s(void)
1146 char* str = get_imm_str_u8();
1147 sprintf(g_dasm_str, "btst %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1150 static void d68020_callm(void)
1153 LIMIT_CPU_TYPES(M68020_ONLY);
1154 str = get_imm_str_u8();
1156 sprintf(g_dasm_str, "callm %s, %s; (2)", str, get_ea_mode_str_8(g_cpu_ir));
1159 static void d68020_cas_8(void)
1162 LIMIT_CPU_TYPES(M68020_PLUS);
1163 extension = read_imm_16();
1164 sprintf(g_dasm_str, "cas.b D%d, D%d, %s; (2+)", extension&7, (extension>>6)&7, get_ea_mode_str_8(g_cpu_ir));
1167 static void d68020_cas_16(void)
1170 LIMIT_CPU_TYPES(M68020_PLUS);
1171 extension = read_imm_16();
1172 sprintf(g_dasm_str, "cas.w D%d, D%d, %s; (2+)", extension&7, (extension>>6)&7, get_ea_mode_str_16(g_cpu_ir));
1175 static void d68020_cas_32(void)
1178 LIMIT_CPU_TYPES(M68020_PLUS);
1179 extension = read_imm_16();
1180 sprintf(g_dasm_str, "cas.l D%d, D%d, %s; (2+)", extension&7, (extension>>6)&7, get_ea_mode_str_32(g_cpu_ir));
1183 static void d68020_cas2_16(void)
1185 /* CAS2 Dc1:Dc2,Du1:Dc2:(Rn1):(Rn2)
1186 f e d c b a 9 8 7 6 5 4 3 2 1 0
1187 DARn1 0 0 0 Du1 0 0 0 Dc1
1188 DARn2 0 0 0 Du2 0 0 0 Dc2
1192 LIMIT_CPU_TYPES(M68020_PLUS);
1193 extension = read_imm_32();
1194 sprintf(g_dasm_str, "cas2.w D%d:D%d, D%d:D%d, (%c%d):(%c%d); (2+)",
1195 (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
1196 BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
1197 BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
1200 static void d68020_cas2_32(void)
1203 LIMIT_CPU_TYPES(M68020_PLUS);
1204 extension = read_imm_32();
1205 sprintf(g_dasm_str, "cas2.l D%d:D%d, D%d:D%d, (%c%d):(%c%d); (2+)",
1206 (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
1207 BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
1208 BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
1211 static void d68000_chk_16(void)
1213 sprintf(g_dasm_str, "chk.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1216 static void d68020_chk_32(void)
1218 LIMIT_CPU_TYPES(M68020_PLUS);
1219 sprintf(g_dasm_str, "chk.l %s, D%d; (2+)", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1222 static void d68020_chk2_cmp2_8(void)
1225 LIMIT_CPU_TYPES(M68020_PLUS);
1226 extension = read_imm_16();
1227 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);
1230 static void d68020_chk2_cmp2_16(void)
1233 LIMIT_CPU_TYPES(M68020_PLUS);
1234 extension = read_imm_16();
1235 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);
1238 static void d68020_chk2_cmp2_32(void)
1241 LIMIT_CPU_TYPES(M68020_PLUS);
1242 extension = read_imm_16();
1243 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);
1246 static void d68040_cinv(void)
1248 LIMIT_CPU_TYPES(M68040_PLUS);
1249 switch((g_cpu_ir>>3)&3)
1252 sprintf(g_dasm_str, "cinv (illegal scope); (4)");
1255 sprintf(g_dasm_str, "cinvl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1258 sprintf(g_dasm_str, "cinvp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1261 sprintf(g_dasm_str, "cinva %d; (4)", (g_cpu_ir>>6)&3);
1266 static void d68000_clr_8(void)
1268 sprintf(g_dasm_str, "clr.b %s", get_ea_mode_str_8(g_cpu_ir));
1271 static void d68000_clr_16(void)
1273 sprintf(g_dasm_str, "clr.w %s", get_ea_mode_str_16(g_cpu_ir));
1276 static void d68000_clr_32(void)
1278 sprintf(g_dasm_str, "clr.l %s", get_ea_mode_str_32(g_cpu_ir));
1281 static void d68000_cmp_8(void)
1283 sprintf(g_dasm_str, "cmp.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
1286 static void d68000_cmp_16(void)
1288 sprintf(g_dasm_str, "cmp.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1291 static void d68000_cmp_32(void)
1293 sprintf(g_dasm_str, "cmp.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1296 static void d68000_cmpa_16(void)
1298 sprintf(g_dasm_str, "cmpa.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1301 static void d68000_cmpa_32(void)
1303 sprintf(g_dasm_str, "cmpa.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1306 static void d68000_cmpi_8(void)
1308 char* str = get_imm_str_s8();
1309 sprintf(g_dasm_str, "cmpi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1312 static void d68020_cmpi_pcdi_8(void)
1315 LIMIT_CPU_TYPES(M68010_PLUS);
1316 str = get_imm_str_s8();
1317 sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
1320 static void d68020_cmpi_pcix_8(void)
1323 LIMIT_CPU_TYPES(M68010_PLUS);
1324 str = get_imm_str_s8();
1325 sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
1328 static void d68000_cmpi_16(void)
1331 str = get_imm_str_s16();
1332 sprintf(g_dasm_str, "cmpi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
1335 static void d68020_cmpi_pcdi_16(void)
1338 LIMIT_CPU_TYPES(M68010_PLUS);
1339 str = get_imm_str_s16();
1340 sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
1343 static void d68020_cmpi_pcix_16(void)
1346 LIMIT_CPU_TYPES(M68010_PLUS);
1347 str = get_imm_str_s16();
1348 sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
1351 static void d68000_cmpi_32(void)
1354 str = get_imm_str_s32();
1355 sprintf(g_dasm_str, "cmpi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
1358 static void d68020_cmpi_pcdi_32(void)
1361 LIMIT_CPU_TYPES(M68010_PLUS);
1362 str = get_imm_str_s32();
1363 sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
1366 static void d68020_cmpi_pcix_32(void)
1369 LIMIT_CPU_TYPES(M68010_PLUS);
1370 str = get_imm_str_s32();
1371 sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
1374 static void d68000_cmpm_8(void)
1376 sprintf(g_dasm_str, "cmpm.b (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
1379 static void d68000_cmpm_16(void)
1381 sprintf(g_dasm_str, "cmpm.w (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
1384 static void d68000_cmpm_32(void)
1386 sprintf(g_dasm_str, "cmpm.l (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
1389 static void d68020_cpbcc_16(void)
1392 uint new_pc = g_cpu_pc;
1393 LIMIT_CPU_TYPES(M68020_PLUS);
1394 extension = read_imm_16();
1395 new_pc += make_int_16(peek_imm_16());
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_cpbcc_32(void)
1402 uint new_pc = g_cpu_pc;
1403 LIMIT_CPU_TYPES(M68020_PLUS);
1404 extension = read_imm_16();
1405 new_pc += peek_imm_32();
1406 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);
1409 static void d68020_cpdbcc(void)
1413 uint new_pc = g_cpu_pc;
1414 LIMIT_CPU_TYPES(M68020_PLUS);
1415 extension1 = read_imm_16();
1416 extension2 = read_imm_16();
1417 new_pc += make_int_16(peek_imm_16());
1418 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);
1421 static void d68020_cpgen(void)
1423 LIMIT_CPU_TYPES(M68020_PLUS);
1424 sprintf(g_dasm_str, "%dgen %s; (2-3)", (g_cpu_ir>>9)&7, get_imm_str_u32());
1427 static void d68020_cprestore(void)
1429 LIMIT_CPU_TYPES(M68020_PLUS);
1430 sprintf(g_dasm_str, "%drestore %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1433 static void d68020_cpsave(void)
1435 LIMIT_CPU_TYPES(M68020_PLUS);
1436 sprintf(g_dasm_str, "%dsave %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1439 static void d68020_cpscc(void)
1443 LIMIT_CPU_TYPES(M68020_PLUS);
1444 extension1 = read_imm_16();
1445 extension2 = read_imm_16();
1446 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);
1449 static void d68020_cptrapcc_0(void)
1453 LIMIT_CPU_TYPES(M68020_PLUS);
1454 extension1 = read_imm_16();
1455 extension2 = read_imm_16();
1456 sprintf(g_dasm_str, "%dtrap%-4s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], extension2);
1459 static void d68020_cptrapcc_16(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_u16(), extension2);
1469 static void d68020_cptrapcc_32(void)
1473 LIMIT_CPU_TYPES(M68020_PLUS);
1474 extension1 = read_imm_16();
1475 extension2 = read_imm_16();
1476 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);
1479 static void d68040_cpush(void)
1481 LIMIT_CPU_TYPES(M68040_PLUS);
1482 switch((g_cpu_ir>>3)&3)
1485 sprintf(g_dasm_str, "cpush (illegal scope); (4)");
1488 sprintf(g_dasm_str, "cpushl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1491 sprintf(g_dasm_str, "cpushp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
1494 sprintf(g_dasm_str, "cpusha %d; (4)", (g_cpu_ir>>6)&3);
1499 static void d68000_dbra(void)
1501 uint temp_pc = g_cpu_pc;
1502 sprintf(g_dasm_str, "dbra D%d, %x", g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16()));
1505 static void d68000_dbcc(void)
1507 uint temp_pc = g_cpu_pc;
1508 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()));
1511 static void d68000_divs(void)
1513 sprintf(g_dasm_str, "divs.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1516 static void d68000_divu(void)
1518 sprintf(g_dasm_str, "divu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1521 static void d68020_divl(void)
1524 LIMIT_CPU_TYPES(M68020_PLUS);
1525 extension = read_imm_16();
1527 if(BIT_A(extension))
1528 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);
1529 else if((extension&7) == ((extension>>12)&7))
1530 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);
1532 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);
1535 static void d68000_eor_8(void)
1537 sprintf(g_dasm_str, "eor.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
1540 static void d68000_eor_16(void)
1542 sprintf(g_dasm_str, "eor.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
1545 static void d68000_eor_32(void)
1547 sprintf(g_dasm_str, "eor.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
1550 static void d68000_eori_8(void)
1552 char* str = get_imm_str_u8();
1553 sprintf(g_dasm_str, "eori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
1556 static void d68000_eori_16(void)
1558 char* str = get_imm_str_u16();
1559 sprintf(g_dasm_str, "eori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
1562 static void d68000_eori_32(void)
1564 char* str = get_imm_str_u32();
1565 sprintf(g_dasm_str, "eori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
1568 static void d68000_eori_to_ccr(void)
1570 sprintf(g_dasm_str, "eori %s, CCR", get_imm_str_u8());
1573 static void d68000_eori_to_sr(void)
1575 sprintf(g_dasm_str, "eori %s, SR", get_imm_str_u16());
1578 static void d68000_exg_dd(void)
1580 sprintf(g_dasm_str, "exg D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1583 static void d68000_exg_aa(void)
1585 sprintf(g_dasm_str, "exg A%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1588 static void d68000_exg_da(void)
1590 sprintf(g_dasm_str, "exg D%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1593 static void d68000_ext_16(void)
1595 sprintf(g_dasm_str, "ext.w D%d", g_cpu_ir&7);
1598 static void d68000_ext_32(void)
1600 sprintf(g_dasm_str, "ext.l D%d", g_cpu_ir&7);
1603 static void d68020_extb_32(void)
1605 LIMIT_CPU_TYPES(M68020_PLUS);
1606 sprintf(g_dasm_str, "extb.l D%d; (2+)", g_cpu_ir&7);
1609 static void d68000_jmp(void)
1611 sprintf(g_dasm_str, "jmp %s", get_ea_mode_str_32(g_cpu_ir));
1614 static void d68000_jsr(void)
1616 sprintf(g_dasm_str, "jsr %s", get_ea_mode_str_32(g_cpu_ir));
1619 static void d68000_lea(void)
1621 sprintf(g_dasm_str, "lea %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1624 static void d68000_link_16(void)
1626 sprintf(g_dasm_str, "link A%d, %s", g_cpu_ir&7, get_imm_str_s16());
1629 static void d68020_link_32(void)
1631 LIMIT_CPU_TYPES(M68020_PLUS);
1632 sprintf(g_dasm_str, "link A%d, %s; (2+)", g_cpu_ir&7, get_imm_str_s32());
1635 static void d68000_lsr_s_8(void)
1637 sprintf(g_dasm_str, "lsr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1640 static void d68000_lsr_s_16(void)
1642 sprintf(g_dasm_str, "lsr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1645 static void d68000_lsr_s_32(void)
1647 sprintf(g_dasm_str, "lsr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1650 static void d68000_lsr_r_8(void)
1652 sprintf(g_dasm_str, "lsr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1655 static void d68000_lsr_r_16(void)
1657 sprintf(g_dasm_str, "lsr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1660 static void d68000_lsr_r_32(void)
1662 sprintf(g_dasm_str, "lsr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1665 static void d68000_lsr_ea(void)
1667 sprintf(g_dasm_str, "lsr.w %s", get_ea_mode_str_32(g_cpu_ir));
1670 static void d68000_lsl_s_8(void)
1672 sprintf(g_dasm_str, "lsl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1675 static void d68000_lsl_s_16(void)
1677 sprintf(g_dasm_str, "lsl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1680 static void d68000_lsl_s_32(void)
1682 sprintf(g_dasm_str, "lsl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
1685 static void d68000_lsl_r_8(void)
1687 sprintf(g_dasm_str, "lsl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1690 static void d68000_lsl_r_16(void)
1692 sprintf(g_dasm_str, "lsl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1695 static void d68000_lsl_r_32(void)
1697 sprintf(g_dasm_str, "lsl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
1700 static void d68000_lsl_ea(void)
1702 sprintf(g_dasm_str, "lsl.w %s", get_ea_mode_str_32(g_cpu_ir));
1705 static void d68000_move_8(void)
1707 char* str = get_ea_mode_str_8(g_cpu_ir);
1708 sprintf(g_dasm_str, "move.b %s, %s", str, get_ea_mode_str_8(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
1711 static void d68000_move_16(void)
1713 char* str = get_ea_mode_str_16(g_cpu_ir);
1714 sprintf(g_dasm_str, "move.w %s, %s", str, get_ea_mode_str_16(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
1717 static void d68000_move_32(void)
1719 char* str = get_ea_mode_str_32(g_cpu_ir);
1720 sprintf(g_dasm_str, "move.l %s, %s", str, get_ea_mode_str_32(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
1723 static void d68000_movea_16(void)
1725 sprintf(g_dasm_str, "movea.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
1728 static void d68000_movea_32(void)
1730 sprintf(g_dasm_str, "movea.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
1733 static void d68000_move_to_ccr(void)
1735 sprintf(g_dasm_str, "move %s, CCR", get_ea_mode_str_8(g_cpu_ir));
1738 static void d68010_move_fr_ccr(void)
1740 LIMIT_CPU_TYPES(M68010_PLUS);
1741 sprintf(g_dasm_str, "move CCR, %s; (1+)", get_ea_mode_str_8(g_cpu_ir));
1744 static void d68000_move_fr_sr(void)
1746 sprintf(g_dasm_str, "move SR, %s", get_ea_mode_str_16(g_cpu_ir));
1749 static void d68000_move_to_sr(void)
1751 sprintf(g_dasm_str, "move %s, SR", get_ea_mode_str_16(g_cpu_ir));
1754 static void d68000_move_fr_usp(void)
1756 sprintf(g_dasm_str, "move USP, A%d", g_cpu_ir&7);
1759 static void d68000_move_to_usp(void)
1761 sprintf(g_dasm_str, "move A%d, USP", g_cpu_ir&7);
1764 static void d68010_movec(void)
1769 LIMIT_CPU_TYPES(M68010_PLUS);
1770 extension = read_imm_16();
1772 switch(extension & 0xfff)
1839 reg_name = make_signed_hex_str_16(extension & 0xfff);
1844 sprintf(g_dasm_str, "movec %c%d, %s; (%s)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, reg_name, processor);
1846 sprintf(g_dasm_str, "movec %s, %c%d; (%s)", reg_name, BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, processor);
1849 static void d68000_movem_pd_16(void)
1851 uint data = read_imm_16();
1860 if(data&(1<<(15-i)))
1864 while(i<7 && (data&(1<<(15-(i+1)))))
1870 strcat(buffer, "/");
1871 sprintf(buffer+strlen(buffer), "D%d", first);
1873 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
1882 while(i<7 && (data&(1<<(7-(i+1)))))
1888 strcat(buffer, "/");
1889 sprintf(buffer+strlen(buffer), "A%d", first);
1891 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
1894 sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
1897 static void d68000_movem_pd_32(void)
1899 uint data = read_imm_16();
1908 if(data&(1<<(15-i)))
1912 while(i<7 && (data&(1<<(15-(i+1)))))
1918 strcat(buffer, "/");
1919 sprintf(buffer+strlen(buffer), "D%d", first);
1921 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
1930 while(i<7 && (data&(1<<(7-(i+1)))))
1936 strcat(buffer, "/");
1937 sprintf(buffer+strlen(buffer), "A%d", first);
1939 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
1942 sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
1945 static void d68000_movem_er_16(void)
1947 uint data = read_imm_16();
1960 while(i<7 && (data&(1<<(i+1))))
1966 strcat(buffer, "/");
1967 sprintf(buffer+strlen(buffer), "D%d", first);
1969 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
1978 while(i<7 && (data&(1<<(i+8+1))))
1984 strcat(buffer, "/");
1985 sprintf(buffer+strlen(buffer), "A%d", first);
1987 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
1990 sprintf(g_dasm_str, "movem.w %s, %s", get_ea_mode_str_16(g_cpu_ir), buffer);
1993 static void d68000_movem_er_32(void)
1995 uint data = read_imm_16();
2008 while(i<7 && (data&(1<<(i+1))))
2014 strcat(buffer, "/");
2015 sprintf(buffer+strlen(buffer), "D%d", first);
2017 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
2026 while(i<7 && (data&(1<<(i+8+1))))
2032 strcat(buffer, "/");
2033 sprintf(buffer+strlen(buffer), "A%d", first);
2035 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
2038 sprintf(g_dasm_str, "movem.l %s, %s", get_ea_mode_str_32(g_cpu_ir), buffer);
2041 static void d68000_movem_re_16(void)
2043 uint data = read_imm_16();
2056 while(i<7 && (data&(1<<(i+1))))
2062 strcat(buffer, "/");
2063 sprintf(buffer+strlen(buffer), "D%d", first);
2065 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
2074 while(i<7 && (data&(1<<(i+8+1))))
2080 strcat(buffer, "/");
2081 sprintf(buffer+strlen(buffer), "A%d", first);
2083 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
2086 sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
2089 static void d68000_movem_re_32(void)
2091 uint data = read_imm_16();
2104 while(i<7 && (data&(1<<(i+1))))
2110 strcat(buffer, "/");
2111 sprintf(buffer+strlen(buffer), "D%d", first);
2113 sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
2122 while(i<7 && (data&(1<<(i+8+1))))
2128 strcat(buffer, "/");
2129 sprintf(buffer+strlen(buffer), "A%d", first);
2131 sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
2134 sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
2137 static void d68000_movep_re_16(void)
2139 sprintf(g_dasm_str, "movep.w D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
2142 static void d68000_movep_re_32(void)
2144 sprintf(g_dasm_str, "movep.l D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
2147 static void d68000_movep_er_16(void)
2149 sprintf(g_dasm_str, "movep.w ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
2152 static void d68000_movep_er_32(void)
2154 sprintf(g_dasm_str, "movep.l ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
2157 static void d68010_moves_8(void)
2160 LIMIT_CPU_TYPES(M68010_PLUS);
2161 extension = read_imm_16();
2162 if(BIT_B(extension))
2163 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));
2165 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);
2168 static void d68010_moves_16(void)
2171 LIMIT_CPU_TYPES(M68010_PLUS);
2172 extension = read_imm_16();
2173 if(BIT_B(extension))
2174 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));
2176 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);
2179 static void d68010_moves_32(void)
2182 LIMIT_CPU_TYPES(M68010_PLUS);
2183 extension = read_imm_16();
2184 if(BIT_B(extension))
2185 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));
2187 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);
2190 static void d68000_moveq(void)
2192 sprintf(g_dasm_str, "moveq #%s, D%d", make_signed_hex_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
2195 static void d68040_move16_pi_pi(void)
2197 LIMIT_CPU_TYPES(M68040_PLUS);
2198 sprintf(g_dasm_str, "move16 (A%d)+, (A%d)+; (4)", g_cpu_ir&7, (read_imm_16()>>12)&7);
2201 static void d68040_move16_pi_al(void)
2203 LIMIT_CPU_TYPES(M68040_PLUS);
2204 sprintf(g_dasm_str, "move16 (A%d)+, %s; (4)", g_cpu_ir&7, get_imm_str_u32());
2207 static void d68040_move16_al_pi(void)
2209 LIMIT_CPU_TYPES(M68040_PLUS);
2210 sprintf(g_dasm_str, "move16 %s, (A%d)+; (4)", get_imm_str_u32(), g_cpu_ir&7);
2213 static void d68040_move16_ai_al(void)
2215 LIMIT_CPU_TYPES(M68040_PLUS);
2216 sprintf(g_dasm_str, "move16 (A%d), %s; (4)", g_cpu_ir&7, get_imm_str_u32());
2219 static void d68040_move16_al_ai(void)
2221 LIMIT_CPU_TYPES(M68040_PLUS);
2222 sprintf(g_dasm_str, "move16 %s, (A%d); (4)", get_imm_str_u32(), g_cpu_ir&7);
2225 static void d68000_muls(void)
2227 sprintf(g_dasm_str, "muls.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2230 static void d68000_mulu(void)
2232 sprintf(g_dasm_str, "mulu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2235 static void d68020_mull(void)
2238 LIMIT_CPU_TYPES(M68020_PLUS);
2239 extension = read_imm_16();
2241 if(BIT_A(extension))
2242 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);
2244 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);
2247 static void d68000_nbcd(void)
2249 sprintf(g_dasm_str, "nbcd %s", get_ea_mode_str_8(g_cpu_ir));
2252 static void d68000_neg_8(void)
2254 sprintf(g_dasm_str, "neg.b %s", get_ea_mode_str_8(g_cpu_ir));
2257 static void d68000_neg_16(void)
2259 sprintf(g_dasm_str, "neg.w %s", get_ea_mode_str_16(g_cpu_ir));
2262 static void d68000_neg_32(void)
2264 sprintf(g_dasm_str, "neg.l %s", get_ea_mode_str_32(g_cpu_ir));
2267 static void d68000_negx_8(void)
2269 sprintf(g_dasm_str, "negx.b %s", get_ea_mode_str_8(g_cpu_ir));
2272 static void d68000_negx_16(void)
2274 sprintf(g_dasm_str, "negx.w %s", get_ea_mode_str_16(g_cpu_ir));
2277 static void d68000_negx_32(void)
2279 sprintf(g_dasm_str, "negx.l %s", get_ea_mode_str_32(g_cpu_ir));
2282 static void d68000_nop(void)
2284 sprintf(g_dasm_str, "nop");
2287 static void d68000_not_8(void)
2289 sprintf(g_dasm_str, "not.b %s", get_ea_mode_str_8(g_cpu_ir));
2292 static void d68000_not_16(void)
2294 sprintf(g_dasm_str, "not.w %s", get_ea_mode_str_16(g_cpu_ir));
2297 static void d68000_not_32(void)
2299 sprintf(g_dasm_str, "not.l %s", get_ea_mode_str_32(g_cpu_ir));
2302 static void d68000_or_er_8(void)
2304 sprintf(g_dasm_str, "or.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
2307 static void d68000_or_er_16(void)
2309 sprintf(g_dasm_str, "or.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2312 static void d68000_or_er_32(void)
2314 sprintf(g_dasm_str, "or.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
2317 static void d68000_or_re_8(void)
2319 sprintf(g_dasm_str, "or.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
2322 static void d68000_or_re_16(void)
2324 sprintf(g_dasm_str, "or.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
2327 static void d68000_or_re_32(void)
2329 sprintf(g_dasm_str, "or.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
2332 static void d68000_ori_8(void)
2334 char* str = get_imm_str_u8();
2335 sprintf(g_dasm_str, "ori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
2338 static void d68000_ori_16(void)
2340 char* str = get_imm_str_u16();
2341 sprintf(g_dasm_str, "ori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
2344 static void d68000_ori_32(void)
2346 char* str = get_imm_str_u32();
2347 sprintf(g_dasm_str, "ori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
2350 static void d68000_ori_to_ccr(void)
2352 sprintf(g_dasm_str, "ori %s, CCR", get_imm_str_u8());
2355 static void d68000_ori_to_sr(void)
2357 sprintf(g_dasm_str, "ori %s, SR", get_imm_str_u16());
2360 static void d68020_pack_rr(void)
2362 LIMIT_CPU_TYPES(M68020_PLUS);
2363 sprintf(g_dasm_str, "pack D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2366 static void d68020_pack_mm(void)
2368 LIMIT_CPU_TYPES(M68020_PLUS);
2369 sprintf(g_dasm_str, "pack -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2372 static void d68000_pea(void)
2374 sprintf(g_dasm_str, "pea %s", get_ea_mode_str_32(g_cpu_ir));
2377 static void d68000_reset(void)
2379 sprintf(g_dasm_str, "reset");
2382 static void d68000_ror_s_8(void)
2384 sprintf(g_dasm_str, "ror.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2387 static void d68000_ror_s_16(void)
2389 sprintf(g_dasm_str, "ror.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7],g_cpu_ir&7);
2392 static void d68000_ror_s_32(void)
2394 sprintf(g_dasm_str, "ror.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2397 static void d68000_ror_r_8(void)
2399 sprintf(g_dasm_str, "ror.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2402 static void d68000_ror_r_16(void)
2404 sprintf(g_dasm_str, "ror.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2407 static void d68000_ror_r_32(void)
2409 sprintf(g_dasm_str, "ror.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2412 static void d68000_ror_ea(void)
2414 sprintf(g_dasm_str, "ror.w %s", get_ea_mode_str_32(g_cpu_ir));
2417 static void d68000_rol_s_8(void)
2419 sprintf(g_dasm_str, "rol.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2422 static void d68000_rol_s_16(void)
2424 sprintf(g_dasm_str, "rol.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2427 static void d68000_rol_s_32(void)
2429 sprintf(g_dasm_str, "rol.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2432 static void d68000_rol_r_8(void)
2434 sprintf(g_dasm_str, "rol.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2437 static void d68000_rol_r_16(void)
2439 sprintf(g_dasm_str, "rol.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2442 static void d68000_rol_r_32(void)
2444 sprintf(g_dasm_str, "rol.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2447 static void d68000_rol_ea(void)
2449 sprintf(g_dasm_str, "rol.w %s", get_ea_mode_str_32(g_cpu_ir));
2452 static void d68000_roxr_s_8(void)
2454 sprintf(g_dasm_str, "roxr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2457 static void d68000_roxr_s_16(void)
2459 sprintf(g_dasm_str, "roxr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2463 static void d68000_roxr_s_32(void)
2465 sprintf(g_dasm_str, "roxr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2468 static void d68000_roxr_r_8(void)
2470 sprintf(g_dasm_str, "roxr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2473 static void d68000_roxr_r_16(void)
2475 sprintf(g_dasm_str, "roxr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2478 static void d68000_roxr_r_32(void)
2480 sprintf(g_dasm_str, "roxr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2483 static void d68000_roxr_ea(void)
2485 sprintf(g_dasm_str, "roxr.w %s", get_ea_mode_str_32(g_cpu_ir));
2488 static void d68000_roxl_s_8(void)
2490 sprintf(g_dasm_str, "roxl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2493 static void d68000_roxl_s_16(void)
2495 sprintf(g_dasm_str, "roxl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2498 static void d68000_roxl_s_32(void)
2500 sprintf(g_dasm_str, "roxl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
2503 static void d68000_roxl_r_8(void)
2505 sprintf(g_dasm_str, "roxl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2508 static void d68000_roxl_r_16(void)
2510 sprintf(g_dasm_str, "roxl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2513 static void d68000_roxl_r_32(void)
2515 sprintf(g_dasm_str, "roxl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
2518 static void d68000_roxl_ea(void)
2520 sprintf(g_dasm_str, "roxl.w %s", get_ea_mode_str_32(g_cpu_ir));
2523 static void d68010_rtd(void)
2525 LIMIT_CPU_TYPES(M68010_PLUS);
2526 sprintf(g_dasm_str, "rtd %s; (1+)", get_imm_str_s16());
2529 static void d68000_rte(void)
2531 sprintf(g_dasm_str, "rte");
2534 static void d68020_rtm(void)
2536 LIMIT_CPU_TYPES(M68020_ONLY);
2537 sprintf(g_dasm_str, "rtm %c%d; (2+)", BIT_3(g_cpu_ir) ? 'A' : 'D', g_cpu_ir&7);
2540 static void d68000_rtr(void)
2542 sprintf(g_dasm_str, "rtr");
2545 static void d68000_rts(void)
2547 sprintf(g_dasm_str, "rts");
2550 static void d68000_sbcd_rr(void)
2552 sprintf(g_dasm_str, "sbcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2555 static void d68000_sbcd_mm(void)
2557 sprintf(g_dasm_str, "sbcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2560 static void d68000_scc(void)
2562 sprintf(g_dasm_str, "s%-2s %s", g_cc[(g_cpu_ir>>8)&0xf], get_ea_mode_str_8(g_cpu_ir));
2565 static void d68000_stop(void)
2567 sprintf(g_dasm_str, "stop %s", get_imm_str_s16());
2570 static void d68000_sub_er_8(void)
2572 sprintf(g_dasm_str, "sub.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
2575 static void d68000_sub_er_16(void)
2577 sprintf(g_dasm_str, "sub.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2580 static void d68000_sub_er_32(void)
2582 sprintf(g_dasm_str, "sub.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
2585 static void d68000_sub_re_8(void)
2587 sprintf(g_dasm_str, "sub.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
2590 static void d68000_sub_re_16(void)
2592 sprintf(g_dasm_str, "sub.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
2595 static void d68000_sub_re_32(void)
2597 sprintf(g_dasm_str, "sub.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
2600 static void d68000_suba_16(void)
2602 sprintf(g_dasm_str, "suba.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
2605 static void d68000_suba_32(void)
2607 sprintf(g_dasm_str, "suba.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
2610 static void d68000_subi_8(void)
2612 char* str = get_imm_str_s8();
2613 sprintf(g_dasm_str, "subi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
2616 static void d68000_subi_16(void)
2618 char* str = get_imm_str_s16();
2619 sprintf(g_dasm_str, "subi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
2622 static void d68000_subi_32(void)
2624 char* str = get_imm_str_s32();
2625 sprintf(g_dasm_str, "subi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
2628 static void d68000_subq_8(void)
2630 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));
2633 static void d68000_subq_16(void)
2635 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));
2638 static void d68000_subq_32(void)
2640 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));
2643 static void d68000_subx_rr_8(void)
2645 sprintf(g_dasm_str, "subx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2648 static void d68000_subx_rr_16(void)
2650 sprintf(g_dasm_str, "subx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2653 static void d68000_subx_rr_32(void)
2655 sprintf(g_dasm_str, "subx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2658 static void d68000_subx_mm_8(void)
2660 sprintf(g_dasm_str, "subx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2663 static void d68000_subx_mm_16(void)
2665 sprintf(g_dasm_str, "subx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2668 static void d68000_subx_mm_32(void)
2670 sprintf(g_dasm_str, "subx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
2673 static void d68000_swap(void)
2675 sprintf(g_dasm_str, "swap D%d", g_cpu_ir&7);
2678 static void d68000_tas(void)
2680 sprintf(g_dasm_str, "tas %s", get_ea_mode_str_8(g_cpu_ir));
2683 static void d68000_trap(void)
2685 sprintf(g_dasm_str, "trap #$%x", g_cpu_ir&0xf);
2688 static void d68020_trapcc_0(void)
2690 LIMIT_CPU_TYPES(M68020_PLUS);
2691 sprintf(g_dasm_str, "trap%-2s; (2+)", g_cc[(g_cpu_ir>>8)&0xf]);
2694 static void d68020_trapcc_16(void)
2696 LIMIT_CPU_TYPES(M68020_PLUS);
2697 sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u16());
2700 static void d68020_trapcc_32(void)
2702 LIMIT_CPU_TYPES(M68020_PLUS);
2703 sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u32());
2706 static void d68000_trapv(void)
2708 sprintf(g_dasm_str, "trapv");
2711 static void d68000_tst_8(void)
2713 sprintf(g_dasm_str, "tst.b %s", get_ea_mode_str_8(g_cpu_ir));
2716 static void d68020_tst_pcdi_8(void)
2718 LIMIT_CPU_TYPES(M68020_PLUS);
2719 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
2722 static void d68020_tst_pcix_8(void)
2724 LIMIT_CPU_TYPES(M68020_PLUS);
2725 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
2728 static void d68020_tst_i_8(void)
2730 LIMIT_CPU_TYPES(M68020_PLUS);
2731 sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
2734 static void d68000_tst_16(void)
2736 sprintf(g_dasm_str, "tst.w %s", get_ea_mode_str_16(g_cpu_ir));
2739 static void d68020_tst_a_16(void)
2741 LIMIT_CPU_TYPES(M68020_PLUS);
2742 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2745 static void d68020_tst_pcdi_16(void)
2747 LIMIT_CPU_TYPES(M68020_PLUS);
2748 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2751 static void d68020_tst_pcix_16(void)
2753 LIMIT_CPU_TYPES(M68020_PLUS);
2754 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2757 static void d68020_tst_i_16(void)
2759 LIMIT_CPU_TYPES(M68020_PLUS);
2760 sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
2763 static void d68000_tst_32(void)
2765 sprintf(g_dasm_str, "tst.l %s", get_ea_mode_str_32(g_cpu_ir));
2768 static void d68020_tst_a_32(void)
2770 LIMIT_CPU_TYPES(M68020_PLUS);
2771 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2774 static void d68020_tst_pcdi_32(void)
2776 LIMIT_CPU_TYPES(M68020_PLUS);
2777 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2780 static void d68020_tst_pcix_32(void)
2782 LIMIT_CPU_TYPES(M68020_PLUS);
2783 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2786 static void d68020_tst_i_32(void)
2788 LIMIT_CPU_TYPES(M68020_PLUS);
2789 sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
2792 static void d68000_unlk(void)
2794 sprintf(g_dasm_str, "unlk A%d", g_cpu_ir&7);
2797 static void d68020_unpk_rr(void)
2799 LIMIT_CPU_TYPES(M68020_PLUS);
2800 sprintf(g_dasm_str, "unpk D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2803 static void d68020_unpk_mm(void)
2805 LIMIT_CPU_TYPES(M68020_PLUS);
2806 sprintf(g_dasm_str, "unpk -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
2811 /* ======================================================================== */
2812 /* ======================= INSTRUCTION TABLE BUILDER ====================== */
2813 /* ======================================================================== */
2816 800 = data register direct
2817 400 = address register direct
2818 200 = address register indirect
2819 100 = ARI postincrement
2820 80 = ARI pre-decrement
2821 40 = ARI displacement
2830 static opcode_struct g_opcode_info[] =
2832 /* opcode handler mask match ea mask */
2833 {d68000_1010 , 0xf000, 0xa000, 0x000},
2834 {d68000_1111 , 0xf000, 0xf000, 0x000},
2835 {d68000_abcd_rr , 0xf1f8, 0xc100, 0x000},
2836 {d68000_abcd_mm , 0xf1f8, 0xc108, 0x000},
2837 {d68000_add_er_8 , 0xf1c0, 0xd000, 0xbff},
2838 {d68000_add_er_16 , 0xf1c0, 0xd040, 0xfff},
2839 {d68000_add_er_32 , 0xf1c0, 0xd080, 0xfff},
2840 {d68000_add_re_8 , 0xf1c0, 0xd100, 0x3f8},
2841 {d68000_add_re_16 , 0xf1c0, 0xd140, 0x3f8},
2842 {d68000_add_re_32 , 0xf1c0, 0xd180, 0x3f8},
2843 {d68000_adda_16 , 0xf1c0, 0xd0c0, 0xfff},
2844 {d68000_adda_32 , 0xf1c0, 0xd1c0, 0xfff},
2845 {d68000_addi_8 , 0xffc0, 0x0600, 0xbf8},
2846 {d68000_addi_16 , 0xffc0, 0x0640, 0xbf8},
2847 {d68000_addi_32 , 0xffc0, 0x0680, 0xbf8},
2848 {d68000_addq_8 , 0xf1c0, 0x5000, 0xbf8},
2849 {d68000_addq_16 , 0xf1c0, 0x5040, 0xff8},
2850 {d68000_addq_32 , 0xf1c0, 0x5080, 0xff8},
2851 {d68000_addx_rr_8 , 0xf1f8, 0xd100, 0x000},
2852 {d68000_addx_rr_16 , 0xf1f8, 0xd140, 0x000},
2853 {d68000_addx_rr_32 , 0xf1f8, 0xd180, 0x000},
2854 {d68000_addx_mm_8 , 0xf1f8, 0xd108, 0x000},
2855 {d68000_addx_mm_16 , 0xf1f8, 0xd148, 0x000},
2856 {d68000_addx_mm_32 , 0xf1f8, 0xd188, 0x000},
2857 {d68000_and_er_8 , 0xf1c0, 0xc000, 0xbff},
2858 {d68000_and_er_16 , 0xf1c0, 0xc040, 0xbff},
2859 {d68000_and_er_32 , 0xf1c0, 0xc080, 0xbff},
2860 {d68000_and_re_8 , 0xf1c0, 0xc100, 0x3f8},
2861 {d68000_and_re_16 , 0xf1c0, 0xc140, 0x3f8},
2862 {d68000_and_re_32 , 0xf1c0, 0xc180, 0x3f8},
2863 {d68000_andi_to_ccr , 0xffff, 0x023c, 0x000},
2864 {d68000_andi_to_sr , 0xffff, 0x027c, 0x000},
2865 {d68000_andi_8 , 0xffc0, 0x0200, 0xbf8},
2866 {d68000_andi_16 , 0xffc0, 0x0240, 0xbf8},
2867 {d68000_andi_32 , 0xffc0, 0x0280, 0xbf8},
2868 {d68000_asr_s_8 , 0xf1f8, 0xe000, 0x000},
2869 {d68000_asr_s_16 , 0xf1f8, 0xe040, 0x000},
2870 {d68000_asr_s_32 , 0xf1f8, 0xe080, 0x000},
2871 {d68000_asr_r_8 , 0xf1f8, 0xe020, 0x000},
2872 {d68000_asr_r_16 , 0xf1f8, 0xe060, 0x000},
2873 {d68000_asr_r_32 , 0xf1f8, 0xe0a0, 0x000},
2874 {d68000_asr_ea , 0xffc0, 0xe0c0, 0x3f8},
2875 {d68000_asl_s_8 , 0xf1f8, 0xe100, 0x000},
2876 {d68000_asl_s_16 , 0xf1f8, 0xe140, 0x000},
2877 {d68000_asl_s_32 , 0xf1f8, 0xe180, 0x000},
2878 {d68000_asl_r_8 , 0xf1f8, 0xe120, 0x000},
2879 {d68000_asl_r_16 , 0xf1f8, 0xe160, 0x000},
2880 {d68000_asl_r_32 , 0xf1f8, 0xe1a0, 0x000},
2881 {d68000_asl_ea , 0xffc0, 0xe1c0, 0x3f8},
2882 {d68000_bcc_8 , 0xf000, 0x6000, 0x000},
2883 {d68000_bcc_16 , 0xf0ff, 0x6000, 0x000},
2884 {d68020_bcc_32 , 0xf0ff, 0x60ff, 0x000},
2885 {d68000_bchg_r , 0xf1c0, 0x0140, 0xbf8},
2886 {d68000_bchg_s , 0xffc0, 0x0840, 0xbf8},
2887 {d68000_bclr_r , 0xf1c0, 0x0180, 0xbf8},
2888 {d68000_bclr_s , 0xffc0, 0x0880, 0xbf8},
2889 {d68020_bfchg , 0xffc0, 0xeac0, 0xa78},
2890 {d68020_bfclr , 0xffc0, 0xecc0, 0xa78},
2891 {d68020_bfexts , 0xffc0, 0xebc0, 0xa7b},
2892 {d68020_bfextu , 0xffc0, 0xe9c0, 0xa7b},
2893 {d68020_bfffo , 0xffc0, 0xedc0, 0xa7b},
2894 {d68020_bfins , 0xffc0, 0xefc0, 0xa78},
2895 {d68020_bfset , 0xffc0, 0xeec0, 0xa78},
2896 {d68020_bftst , 0xffc0, 0xe8c0, 0xa7b},
2897 {d68010_bkpt , 0xfff8, 0x4848, 0x000},
2898 {d68000_bra_8 , 0xff00, 0x6000, 0x000},
2899 {d68000_bra_16 , 0xffff, 0x6000, 0x000},
2900 {d68020_bra_32 , 0xffff, 0x60ff, 0x000},
2901 {d68000_bset_r , 0xf1c0, 0x01c0, 0xbf8},
2902 {d68000_bset_s , 0xffc0, 0x08c0, 0xbf8},
2903 {d68000_bsr_8 , 0xff00, 0x6100, 0x000},
2904 {d68000_bsr_16 , 0xffff, 0x6100, 0x000},
2905 {d68020_bsr_32 , 0xffff, 0x61ff, 0x000},
2906 {d68000_btst_r , 0xf1c0, 0x0100, 0xbff},
2907 {d68000_btst_s , 0xffc0, 0x0800, 0xbfb},
2908 {d68020_callm , 0xffc0, 0x06c0, 0x27b},
2909 {d68020_cas_8 , 0xffc0, 0x0ac0, 0x3f8},
2910 {d68020_cas_16 , 0xffc0, 0x0cc0, 0x3f8},
2911 {d68020_cas_32 , 0xffc0, 0x0ec0, 0x3f8},
2912 {d68020_cas2_16 , 0xffff, 0x0cfc, 0x000},
2913 {d68020_cas2_32 , 0xffff, 0x0efc, 0x000},
2914 {d68000_chk_16 , 0xf1c0, 0x4180, 0xbff},
2915 {d68020_chk_32 , 0xf1c0, 0x4100, 0xbff},
2916 {d68020_chk2_cmp2_8 , 0xffc0, 0x00c0, 0x27b},
2917 {d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b},
2918 {d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b},
2919 {d68040_cinv , 0xff20, 0xf400, 0x000},
2920 {d68000_clr_8 , 0xffc0, 0x4200, 0xbf8},
2921 {d68000_clr_16 , 0xffc0, 0x4240, 0xbf8},
2922 {d68000_clr_32 , 0xffc0, 0x4280, 0xbf8},
2923 {d68000_cmp_8 , 0xf1c0, 0xb000, 0xbff},
2924 {d68000_cmp_16 , 0xf1c0, 0xb040, 0xfff},
2925 {d68000_cmp_32 , 0xf1c0, 0xb080, 0xfff},
2926 {d68000_cmpa_16 , 0xf1c0, 0xb0c0, 0xfff},
2927 {d68000_cmpa_32 , 0xf1c0, 0xb1c0, 0xfff},
2928 {d68000_cmpi_8 , 0xffc0, 0x0c00, 0xbf8},
2929 {d68020_cmpi_pcdi_8 , 0xffff, 0x0c3a, 0x000},
2930 {d68020_cmpi_pcix_8 , 0xffff, 0x0c3b, 0x000},
2931 {d68000_cmpi_16 , 0xffc0, 0x0c40, 0xbf8},
2932 {d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000},
2933 {d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000},
2934 {d68000_cmpi_32 , 0xffc0, 0x0c80, 0xbf8},
2935 {d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000},
2936 {d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000},
2937 {d68000_cmpm_8 , 0xf1f8, 0xb108, 0x000},
2938 {d68000_cmpm_16 , 0xf1f8, 0xb148, 0x000},
2939 {d68000_cmpm_32 , 0xf1f8, 0xb188, 0x000},
2940 {d68020_cpbcc_16 , 0xf1c0, 0xf080, 0x000},
2941 {d68020_cpbcc_32 , 0xf1c0, 0xf0c0, 0x000},
2942 {d68020_cpdbcc , 0xf1f8, 0xf048, 0x000},
2943 {d68020_cpgen , 0xf1c0, 0xf000, 0x000},
2944 {d68020_cprestore , 0xf1c0, 0xf140, 0x37f},
2945 {d68020_cpsave , 0xf1c0, 0xf100, 0x2f8},
2946 {d68020_cpscc , 0xf1c0, 0xf040, 0xbf8},
2947 {d68020_cptrapcc_0 , 0xf1ff, 0xf07c, 0x000},
2948 {d68020_cptrapcc_16 , 0xf1ff, 0xf07a, 0x000},
2949 {d68020_cptrapcc_32 , 0xf1ff, 0xf07b, 0x000},
2950 {d68040_cpush , 0xff20, 0xf420, 0x000},
2951 {d68000_dbcc , 0xf0f8, 0x50c8, 0x000},
2952 {d68000_dbra , 0xfff8, 0x51c8, 0x000},
2953 {d68000_divs , 0xf1c0, 0x81c0, 0xbff},
2954 {d68000_divu , 0xf1c0, 0x80c0, 0xbff},
2955 {d68020_divl , 0xffc0, 0x4c40, 0xbff},
2956 {d68000_eor_8 , 0xf1c0, 0xb100, 0xbf8},
2957 {d68000_eor_16 , 0xf1c0, 0xb140, 0xbf8},
2958 {d68000_eor_32 , 0xf1c0, 0xb180, 0xbf8},
2959 {d68000_eori_to_ccr , 0xffff, 0x0a3c, 0x000},
2960 {d68000_eori_to_sr , 0xffff, 0x0a7c, 0x000},
2961 {d68000_eori_8 , 0xffc0, 0x0a00, 0xbf8},
2962 {d68000_eori_16 , 0xffc0, 0x0a40, 0xbf8},
2963 {d68000_eori_32 , 0xffc0, 0x0a80, 0xbf8},
2964 {d68000_exg_dd , 0xf1f8, 0xc140, 0x000},
2965 {d68000_exg_aa , 0xf1f8, 0xc148, 0x000},
2966 {d68000_exg_da , 0xf1f8, 0xc188, 0x000},
2967 {d68020_extb_32 , 0xfff8, 0x49c0, 0x000},
2968 {d68000_ext_16 , 0xfff8, 0x4880, 0x000},
2969 {d68000_ext_32 , 0xfff8, 0x48c0, 0x000},
2970 {d68000_illegal , 0xffff, 0x4afc, 0x000},
2971 {d68000_jmp , 0xffc0, 0x4ec0, 0x27b},
2972 {d68000_jsr , 0xffc0, 0x4e80, 0x27b},
2973 {d68000_lea , 0xf1c0, 0x41c0, 0x27b},
2974 {d68000_link_16 , 0xfff8, 0x4e50, 0x000},
2975 {d68020_link_32 , 0xfff8, 0x4808, 0x000},
2976 {d68000_lsr_s_8 , 0xf1f8, 0xe008, 0x000},
2977 {d68000_lsr_s_16 , 0xf1f8, 0xe048, 0x000},
2978 {d68000_lsr_s_32 , 0xf1f8, 0xe088, 0x000},
2979 {d68000_lsr_r_8 , 0xf1f8, 0xe028, 0x000},
2980 {d68000_lsr_r_16 , 0xf1f8, 0xe068, 0x000},
2981 {d68000_lsr_r_32 , 0xf1f8, 0xe0a8, 0x000},
2982 {d68000_lsr_ea , 0xffc0, 0xe2c0, 0x3f8},
2983 {d68000_lsl_s_8 , 0xf1f8, 0xe108, 0x000},
2984 {d68000_lsl_s_16 , 0xf1f8, 0xe148, 0x000},
2985 {d68000_lsl_s_32 , 0xf1f8, 0xe188, 0x000},
2986 {d68000_lsl_r_8 , 0xf1f8, 0xe128, 0x000},
2987 {d68000_lsl_r_16 , 0xf1f8, 0xe168, 0x000},
2988 {d68000_lsl_r_32 , 0xf1f8, 0xe1a8, 0x000},
2989 {d68000_lsl_ea , 0xffc0, 0xe3c0, 0x3f8},
2990 {d68000_move_8 , 0xf000, 0x1000, 0xbff},
2991 {d68000_move_16 , 0xf000, 0x3000, 0xfff},
2992 {d68000_move_32 , 0xf000, 0x2000, 0xfff},
2993 {d68000_movea_16 , 0xf1c0, 0x3040, 0xfff},
2994 {d68000_movea_32 , 0xf1c0, 0x2040, 0xfff},
2995 {d68000_move_to_ccr , 0xffc0, 0x44c0, 0xbff},
2996 {d68010_move_fr_ccr , 0xffc0, 0x42c0, 0xbf8},
2997 {d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff},
2998 {d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8},
2999 {d68000_move_to_usp , 0xfff8, 0x4e60, 0x000},
3000 {d68000_move_fr_usp , 0xfff8, 0x4e68, 0x000},
3001 {d68010_movec , 0xfffe, 0x4e7a, 0x000},
3002 {d68000_movem_pd_16 , 0xfff8, 0x48a0, 0x000},
3003 {d68000_movem_pd_32 , 0xfff8, 0x48e0, 0x000},
3004 {d68000_movem_re_16 , 0xffc0, 0x4880, 0x2f8},
3005 {d68000_movem_re_32 , 0xffc0, 0x48c0, 0x2f8},
3006 {d68000_movem_er_16 , 0xffc0, 0x4c80, 0x37b},
3007 {d68000_movem_er_32 , 0xffc0, 0x4cc0, 0x37b},
3008 {d68000_movep_er_16 , 0xf1f8, 0x0108, 0x000},
3009 {d68000_movep_er_32 , 0xf1f8, 0x0148, 0x000},
3010 {d68000_movep_re_16 , 0xf1f8, 0x0188, 0x000},
3011 {d68000_movep_re_32 , 0xf1f8, 0x01c8, 0x000},
3012 {d68010_moves_8 , 0xffc0, 0x0e00, 0x3f8},
3013 {d68010_moves_16 , 0xffc0, 0x0e40, 0x3f8},
3014 {d68010_moves_32 , 0xffc0, 0x0e80, 0x3f8},
3015 {d68000_moveq , 0xf100, 0x7000, 0x000},
3016 {d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000},
3017 {d68040_move16_pi_al , 0xfff8, 0xf600, 0x000},
3018 {d68040_move16_al_pi , 0xfff8, 0xf608, 0x000},
3019 {d68040_move16_ai_al , 0xfff8, 0xf610, 0x000},
3020 {d68040_move16_al_ai , 0xfff8, 0xf618, 0x000},
3021 {d68000_muls , 0xf1c0, 0xc1c0, 0xbff},
3022 {d68000_mulu , 0xf1c0, 0xc0c0, 0xbff},
3023 {d68020_mull , 0xffc0, 0x4c00, 0xbff},
3024 {d68000_nbcd , 0xffc0, 0x4800, 0xbf8},
3025 {d68000_neg_8 , 0xffc0, 0x4400, 0xbf8},
3026 {d68000_neg_16 , 0xffc0, 0x4440, 0xbf8},
3027 {d68000_neg_32 , 0xffc0, 0x4480, 0xbf8},
3028 {d68000_negx_8 , 0xffc0, 0x4000, 0xbf8},
3029 {d68000_negx_16 , 0xffc0, 0x4040, 0xbf8},
3030 {d68000_negx_32 , 0xffc0, 0x4080, 0xbf8},
3031 {d68000_nop , 0xffff, 0x4e71, 0x000},
3032 {d68000_not_8 , 0xffc0, 0x4600, 0xbf8},
3033 {d68000_not_16 , 0xffc0, 0x4640, 0xbf8},
3034 {d68000_not_32 , 0xffc0, 0x4680, 0xbf8},
3035 {d68000_or_er_8 , 0xf1c0, 0x8000, 0xbff},
3036 {d68000_or_er_16 , 0xf1c0, 0x8040, 0xbff},
3037 {d68000_or_er_32 , 0xf1c0, 0x8080, 0xbff},
3038 {d68000_or_re_8 , 0xf1c0, 0x8100, 0x3f8},
3039 {d68000_or_re_16 , 0xf1c0, 0x8140, 0x3f8},
3040 {d68000_or_re_32 , 0xf1c0, 0x8180, 0x3f8},
3041 {d68000_ori_to_ccr , 0xffff, 0x003c, 0x000},
3042 {d68000_ori_to_sr , 0xffff, 0x007c, 0x000},
3043 {d68000_ori_8 , 0xffc0, 0x0000, 0xbf8},
3044 {d68000_ori_16 , 0xffc0, 0x0040, 0xbf8},
3045 {d68000_ori_32 , 0xffc0, 0x0080, 0xbf8},
3046 {d68020_pack_rr , 0xf1f8, 0x8140, 0x000},
3047 {d68020_pack_mm , 0xf1f8, 0x8148, 0x000},
3048 {d68000_pea , 0xffc0, 0x4840, 0x27b},
3049 {d68000_reset , 0xffff, 0x4e70, 0x000},
3050 {d68000_ror_s_8 , 0xf1f8, 0xe018, 0x000},
3051 {d68000_ror_s_16 , 0xf1f8, 0xe058, 0x000},
3052 {d68000_ror_s_32 , 0xf1f8, 0xe098, 0x000},
3053 {d68000_ror_r_8 , 0xf1f8, 0xe038, 0x000},
3054 {d68000_ror_r_16 , 0xf1f8, 0xe078, 0x000},
3055 {d68000_ror_r_32 , 0xf1f8, 0xe0b8, 0x000},
3056 {d68000_ror_ea , 0xffc0, 0xe6c0, 0x3f8},
3057 {d68000_rol_s_8 , 0xf1f8, 0xe118, 0x000},
3058 {d68000_rol_s_16 , 0xf1f8, 0xe158, 0x000},
3059 {d68000_rol_s_32 , 0xf1f8, 0xe198, 0x000},
3060 {d68000_rol_r_8 , 0xf1f8, 0xe138, 0x000},
3061 {d68000_rol_r_16 , 0xf1f8, 0xe178, 0x000},
3062 {d68000_rol_r_32 , 0xf1f8, 0xe1b8, 0x000},
3063 {d68000_rol_ea , 0xffc0, 0xe7c0, 0x3f8},
3064 {d68000_roxr_s_8 , 0xf1f8, 0xe010, 0x000},
3065 {d68000_roxr_s_16 , 0xf1f8, 0xe050, 0x000},
3066 {d68000_roxr_s_32 , 0xf1f8, 0xe090, 0x000},
3067 {d68000_roxr_r_8 , 0xf1f8, 0xe030, 0x000},
3068 {d68000_roxr_r_16 , 0xf1f8, 0xe070, 0x000},
3069 {d68000_roxr_r_32 , 0xf1f8, 0xe0b0, 0x000},
3070 {d68000_roxr_ea , 0xffc0, 0xe4c0, 0x3f8},
3071 {d68000_roxl_s_8 , 0xf1f8, 0xe110, 0x000},
3072 {d68000_roxl_s_16 , 0xf1f8, 0xe150, 0x000},
3073 {d68000_roxl_s_32 , 0xf1f8, 0xe190, 0x000},
3074 {d68000_roxl_r_8 , 0xf1f8, 0xe130, 0x000},
3075 {d68000_roxl_r_16 , 0xf1f8, 0xe170, 0x000},
3076 {d68000_roxl_r_32 , 0xf1f8, 0xe1b0, 0x000},
3077 {d68000_roxl_ea , 0xffc0, 0xe5c0, 0x3f8},
3078 {d68010_rtd , 0xffff, 0x4e74, 0x000},
3079 {d68000_rte , 0xffff, 0x4e73, 0x000},
3080 {d68020_rtm , 0xfff0, 0x06c0, 0x000},
3081 {d68000_rtr , 0xffff, 0x4e77, 0x000},
3082 {d68000_rts , 0xffff, 0x4e75, 0x000},
3083 {d68000_sbcd_rr , 0xf1f8, 0x8100, 0x000},
3084 {d68000_sbcd_mm , 0xf1f8, 0x8108, 0x000},
3085 {d68000_scc , 0xf0c0, 0x50c0, 0xbf8},
3086 {d68000_stop , 0xffff, 0x4e72, 0x000},
3087 {d68000_sub_er_8 , 0xf1c0, 0x9000, 0xbff},
3088 {d68000_sub_er_16 , 0xf1c0, 0x9040, 0xfff},
3089 {d68000_sub_er_32 , 0xf1c0, 0x9080, 0xfff},
3090 {d68000_sub_re_8 , 0xf1c0, 0x9100, 0x3f8},
3091 {d68000_sub_re_16 , 0xf1c0, 0x9140, 0x3f8},
3092 {d68000_sub_re_32 , 0xf1c0, 0x9180, 0x3f8},
3093 {d68000_suba_16 , 0xf1c0, 0x90c0, 0xfff},
3094 {d68000_suba_32 , 0xf1c0, 0x91c0, 0xfff},
3095 {d68000_subi_8 , 0xffc0, 0x0400, 0xbf8},
3096 {d68000_subi_16 , 0xffc0, 0x0440, 0xbf8},
3097 {d68000_subi_32 , 0xffc0, 0x0480, 0xbf8},
3098 {d68000_subq_8 , 0xf1c0, 0x5100, 0xbf8},
3099 {d68000_subq_16 , 0xf1c0, 0x5140, 0xff8},
3100 {d68000_subq_32 , 0xf1c0, 0x5180, 0xff8},
3101 {d68000_subx_rr_8 , 0xf1f8, 0x9100, 0x000},
3102 {d68000_subx_rr_16 , 0xf1f8, 0x9140, 0x000},
3103 {d68000_subx_rr_32 , 0xf1f8, 0x9180, 0x000},
3104 {d68000_subx_mm_8 , 0xf1f8, 0x9108, 0x000},
3105 {d68000_subx_mm_16 , 0xf1f8, 0x9148, 0x000},
3106 {d68000_subx_mm_32 , 0xf1f8, 0x9188, 0x000},
3107 {d68000_swap , 0xfff8, 0x4840, 0x000},
3108 {d68000_tas , 0xffc0, 0x4ac0, 0xbf8},
3109 {d68000_trap , 0xfff0, 0x4e40, 0x000},
3110 {d68020_trapcc_0 , 0xf0ff, 0x50fc, 0x000},
3111 {d68020_trapcc_16 , 0xf0ff, 0x50fa, 0x000},
3112 {d68020_trapcc_32 , 0xf0ff, 0x50fb, 0x000},
3113 {d68000_trapv , 0xffff, 0x4e76, 0x000},
3114 {d68000_tst_8 , 0xffc0, 0x4a00, 0xbf8},
3115 {d68020_tst_pcdi_8 , 0xffff, 0x4a3a, 0x000},
3116 {d68020_tst_pcix_8 , 0xffff, 0x4a3b, 0x000},
3117 {d68020_tst_i_8 , 0xffff, 0x4a3c, 0x000},
3118 {d68000_tst_16 , 0xffc0, 0x4a40, 0xbf8},
3119 {d68020_tst_a_16 , 0xfff8, 0x4a48, 0x000},
3120 {d68020_tst_pcdi_16 , 0xffff, 0x4a7a, 0x000},
3121 {d68020_tst_pcix_16 , 0xffff, 0x4a7b, 0x000},
3122 {d68020_tst_i_16 , 0xffff, 0x4a7c, 0x000},
3123 {d68000_tst_32 , 0xffc0, 0x4a80, 0xbf8},
3124 {d68020_tst_a_32 , 0xfff8, 0x4a88, 0x000},
3125 {d68020_tst_pcdi_32 , 0xffff, 0x4aba, 0x000},
3126 {d68020_tst_pcix_32 , 0xffff, 0x4abb, 0x000},
3127 {d68020_tst_i_32 , 0xffff, 0x4abc, 0x000},
3128 {d68000_unlk , 0xfff8, 0x4e58, 0x000},
3129 {d68020_unpk_rr , 0xf1f8, 0x8180, 0x000},
3130 {d68020_unpk_mm , 0xf1f8, 0x8188, 0x000},
3134 /* Check if opcode is using a valid ea mode */
3135 static int valid_ea(uint opcode, uint mask)
3140 switch(opcode & 0x3f)
3142 case 0x00: case 0x01: case 0x02: case 0x03:
3143 case 0x04: case 0x05: case 0x06: case 0x07:
3144 return (mask & 0x800) != 0;
3145 case 0x08: case 0x09: case 0x0a: case 0x0b:
3146 case 0x0c: case 0x0d: case 0x0e: case 0x0f:
3147 return (mask & 0x400) != 0;
3148 case 0x10: case 0x11: case 0x12: case 0x13:
3149 case 0x14: case 0x15: case 0x16: case 0x17:
3150 return (mask & 0x200) != 0;
3151 case 0x18: case 0x19: case 0x1a: case 0x1b:
3152 case 0x1c: case 0x1d: case 0x1e: case 0x1f:
3153 return (mask & 0x100) != 0;
3154 case 0x20: case 0x21: case 0x22: case 0x23:
3155 case 0x24: case 0x25: case 0x26: case 0x27:
3156 return (mask & 0x080) != 0;
3157 case 0x28: case 0x29: case 0x2a: case 0x2b:
3158 case 0x2c: case 0x2d: case 0x2e: case 0x2f:
3159 return (mask & 0x040) != 0;
3160 case 0x30: case 0x31: case 0x32: case 0x33:
3161 case 0x34: case 0x35: case 0x36: case 0x37:
3162 return (mask & 0x020) != 0;
3164 return (mask & 0x010) != 0;
3166 return (mask & 0x008) != 0;
3168 return (mask & 0x002) != 0;
3170 return (mask & 0x001) != 0;
3172 return (mask & 0x004) != 0;
3179 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr)
3181 uint a = ((const opcode_struct*)aptr)->mask;
3182 uint b = ((const opcode_struct*)bptr)->mask;
3184 a = ((a & 0xAAAA) >> 1) + (a & 0x5555);
3185 a = ((a & 0xCCCC) >> 2) + (a & 0x3333);
3186 a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F);
3187 a = ((a & 0xFF00) >> 8) + (a & 0x00FF);
3189 b = ((b & 0xAAAA) >> 1) + (b & 0x5555);
3190 b = ((b & 0xCCCC) >> 2) + (b & 0x3333);
3191 b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F);
3192 b = ((b & 0xFF00) >> 8) + (b & 0x00FF);
3194 return b - a; /* reversed to get greatest to least sorting */
3197 /* build the opcode handler jump table */
3198 static void build_opcode_table(void)
3202 opcode_struct* ostruct;
3203 uint opcode_info_length = 0;
3205 for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
3206 opcode_info_length++;
3208 qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits);
3210 for(i=0;i<0x10000;i++)
3212 g_instruction_table[i] = d68000_illegal; /* default to illegal */
3214 /* search through opcode info for a match */
3215 for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
3217 /* match opcode mask and allowed ea modes */
3218 if((opcode & ostruct->mask) == ostruct->match)
3220 /* Handle destination ea for move instructions */
3221 if((ostruct->opcode_handler == d68000_move_8 ||
3222 ostruct->opcode_handler == d68000_move_16 ||
3223 ostruct->opcode_handler == d68000_move_32) &&
3224 !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8))
3226 if(valid_ea(opcode, ostruct->ea_mask))
3228 g_instruction_table[i] = ostruct->opcode_handler;
3238 /* ======================================================================== */
3239 /* ================================= API ================================== */
3240 /* ======================================================================== */
3242 /* Disasemble one instruction at pc and store in str_buff */
3243 unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type)
3247 build_opcode_table();
3252 case M68K_CPU_TYPE_68000:
3253 g_cpu_type = TYPE_68000;
3254 g_address_mask = 0x00ffffff;
3256 case M68K_CPU_TYPE_68010:
3257 g_cpu_type = TYPE_68010;
3258 g_address_mask = 0x00ffffff;
3260 case M68K_CPU_TYPE_68EC020:
3261 g_cpu_type = TYPE_68020;
3262 g_address_mask = 0x00ffffff;
3264 case M68K_CPU_TYPE_68020:
3265 g_cpu_type = TYPE_68020;
3266 g_address_mask = 0xffffffff;
3268 case M68K_CPU_TYPE_68030:
3269 g_cpu_type = TYPE_68030;
3270 g_address_mask = 0xffffffff;
3272 case M68K_CPU_TYPE_68040:
3273 g_cpu_type = TYPE_68040;
3274 g_address_mask = 0xffffffff;
3281 g_helper_str[0] = 0;
3282 g_cpu_ir = read_imm_16();
3283 g_instruction_table[g_cpu_ir]();
3284 sprintf(str_buff, "%s%s", g_dasm_str, g_helper_str);
3285 return g_cpu_pc - pc;
3288 char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type)
3290 static char buff[100];
3292 m68k_disassemble(buff, pc, cpu_type);
3296 /* Check if the instruction is a valid one */
3297 unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type)
3301 build_opcode_table();
3305 instruction &= 0xffff;
3306 if(g_instruction_table[instruction] == d68000_illegal)
3311 case M68K_CPU_TYPE_68000:
3312 if(g_instruction_table[instruction] == d68010_bkpt)
3314 if(g_instruction_table[instruction] == d68010_move_fr_ccr)
3316 if(g_instruction_table[instruction] == d68010_movec)
3318 if(g_instruction_table[instruction] == d68010_moves_8)
3320 if(g_instruction_table[instruction] == d68010_moves_16)
3322 if(g_instruction_table[instruction] == d68010_moves_32)
3324 if(g_instruction_table[instruction] == d68010_rtd)
3326 case M68K_CPU_TYPE_68010:
3327 if(g_instruction_table[instruction] == d68020_bcc_32)
3329 if(g_instruction_table[instruction] == d68020_bfchg)
3331 if(g_instruction_table[instruction] == d68020_bfclr)
3333 if(g_instruction_table[instruction] == d68020_bfexts)
3335 if(g_instruction_table[instruction] == d68020_bfextu)
3337 if(g_instruction_table[instruction] == d68020_bfffo)
3339 if(g_instruction_table[instruction] == d68020_bfins)
3341 if(g_instruction_table[instruction] == d68020_bfset)
3343 if(g_instruction_table[instruction] == d68020_bftst)
3345 if(g_instruction_table[instruction] == d68020_bra_32)
3347 if(g_instruction_table[instruction] == d68020_bsr_32)
3349 if(g_instruction_table[instruction] == d68020_callm)
3351 if(g_instruction_table[instruction] == d68020_cas_8)
3353 if(g_instruction_table[instruction] == d68020_cas_16)
3355 if(g_instruction_table[instruction] == d68020_cas_32)
3357 if(g_instruction_table[instruction] == d68020_cas2_16)
3359 if(g_instruction_table[instruction] == d68020_cas2_32)
3361 if(g_instruction_table[instruction] == d68020_chk_32)
3363 if(g_instruction_table[instruction] == d68020_chk2_cmp2_8)
3365 if(g_instruction_table[instruction] == d68020_chk2_cmp2_16)
3367 if(g_instruction_table[instruction] == d68020_chk2_cmp2_32)
3369 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_8)
3371 if(g_instruction_table[instruction] == d68020_cmpi_pcix_8)
3373 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_16)
3375 if(g_instruction_table[instruction] == d68020_cmpi_pcix_16)
3377 if(g_instruction_table[instruction] == d68020_cmpi_pcdi_32)
3379 if(g_instruction_table[instruction] == d68020_cmpi_pcix_32)
3381 if(g_instruction_table[instruction] == d68020_cpbcc_16)
3383 if(g_instruction_table[instruction] == d68020_cpbcc_32)
3385 if(g_instruction_table[instruction] == d68020_cpdbcc)
3387 if(g_instruction_table[instruction] == d68020_cpgen)
3389 if(g_instruction_table[instruction] == d68020_cprestore)
3391 if(g_instruction_table[instruction] == d68020_cpsave)
3393 if(g_instruction_table[instruction] == d68020_cpscc)
3395 if(g_instruction_table[instruction] == d68020_cptrapcc_0)
3397 if(g_instruction_table[instruction] == d68020_cptrapcc_16)
3399 if(g_instruction_table[instruction] == d68020_cptrapcc_32)
3401 if(g_instruction_table[instruction] == d68020_divl)
3403 if(g_instruction_table[instruction] == d68020_extb_32)
3405 if(g_instruction_table[instruction] == d68020_link_32)
3407 if(g_instruction_table[instruction] == d68020_mull)
3409 if(g_instruction_table[instruction] == d68020_pack_rr)
3411 if(g_instruction_table[instruction] == d68020_pack_mm)
3413 if(g_instruction_table[instruction] == d68020_rtm)
3415 if(g_instruction_table[instruction] == d68020_trapcc_0)
3417 if(g_instruction_table[instruction] == d68020_trapcc_16)
3419 if(g_instruction_table[instruction] == d68020_trapcc_32)
3421 if(g_instruction_table[instruction] == d68020_tst_pcdi_8)
3423 if(g_instruction_table[instruction] == d68020_tst_pcix_8)
3425 if(g_instruction_table[instruction] == d68020_tst_i_8)
3427 if(g_instruction_table[instruction] == d68020_tst_a_16)
3429 if(g_instruction_table[instruction] == d68020_tst_pcdi_16)
3431 if(g_instruction_table[instruction] == d68020_tst_pcix_16)
3433 if(g_instruction_table[instruction] == d68020_tst_i_16)
3435 if(g_instruction_table[instruction] == d68020_tst_a_32)
3437 if(g_instruction_table[instruction] == d68020_tst_pcdi_32)
3439 if(g_instruction_table[instruction] == d68020_tst_pcix_32)
3441 if(g_instruction_table[instruction] == d68020_tst_i_32)
3443 if(g_instruction_table[instruction] == d68020_unpk_rr)
3445 if(g_instruction_table[instruction] == d68020_unpk_mm)
3447 case M68K_CPU_TYPE_68EC020:
3448 case M68K_CPU_TYPE_68020:
3449 case M68K_CPU_TYPE_68030:
3450 if(g_instruction_table[instruction] == d68040_cinv)
3452 if(g_instruction_table[instruction] == d68040_cpush)
3454 if(g_instruction_table[instruction] == d68040_move16_pi_pi)
3456 if(g_instruction_table[instruction] == d68040_move16_pi_al)
3458 if(g_instruction_table[instruction] == d68040_move16_al_pi)
3460 if(g_instruction_table[instruction] == d68040_move16_ai_al)
3462 if(g_instruction_table[instruction] == d68040_move16_al_ai)
3465 if(cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 &&
3466 (g_instruction_table[instruction] == d68020_callm ||
3467 g_instruction_table[instruction] == d68020_rtm))
3475 /* ======================================================================== */
3476 /* ============================== END OF FILE ============================= */
3477 /* ======================================================================== */