src/musashi/m68kdasm.c

changeset 0
8bf1bf91a36d
     1.1 diff -r 000000000000 -r 8bf1bf91a36d src/musashi/m68kdasm.c
     1.2 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 +++ b/src/musashi/m68kdasm.c	Sat Nov 27 01:13:12 2010 +0000
     1.4 @@ -0,0 +1,3443 @@
     1.5 +/* ======================================================================== */
     1.6 +/* ========================= LICENSING & COPYRIGHT ======================== */
     1.7 +/* ======================================================================== */
     1.8 +/*
     1.9 + *                                  MUSASHI
    1.10 + *                                Version 3.3
    1.11 + *
    1.12 + * A portable Motorola M680x0 processor emulation engine.
    1.13 + * Copyright 1998-2001 Karl Stenerud.  All rights reserved.
    1.14 + *
    1.15 + * This code may be freely used for non-commercial purposes as long as this
    1.16 + * copyright notice remains unaltered in the source code and any binary files
    1.17 + * containing this code in compiled form.
    1.18 + *
    1.19 + * All other lisencing terms must be negotiated with the author
    1.20 + * (Karl Stenerud).
    1.21 + *
    1.22 + * The latest version of this code can be obtained at:
    1.23 + * http://kstenerud.cjb.net
    1.24 + */
    1.25 +
    1.26 +
    1.27 +
    1.28 +/* ======================================================================== */
    1.29 +/* ================================ INCLUDES ============================== */
    1.30 +/* ======================================================================== */
    1.31 +
    1.32 +#include <stdlib.h>
    1.33 +#include <stdio.h>
    1.34 +#include <string.h>
    1.35 +#include "m68k.h"
    1.36 +
    1.37 +/* ======================================================================== */
    1.38 +/* ============================ GENERAL DEFINES =========================== */
    1.39 +/* ======================================================================== */
    1.40 +
    1.41 +/* unsigned int and int must be at least 32 bits wide */
    1.42 +#undef uint
    1.43 +#define uint unsigned int
    1.44 +
    1.45 +/* Bit Isolation Functions */
    1.46 +#define BIT_0(A)  ((A) & 0x00000001)
    1.47 +#define BIT_1(A)  ((A) & 0x00000002)
    1.48 +#define BIT_2(A)  ((A) & 0x00000004)
    1.49 +#define BIT_3(A)  ((A) & 0x00000008)
    1.50 +#define BIT_4(A)  ((A) & 0x00000010)
    1.51 +#define BIT_5(A)  ((A) & 0x00000020)
    1.52 +#define BIT_6(A)  ((A) & 0x00000040)
    1.53 +#define BIT_7(A)  ((A) & 0x00000080)
    1.54 +#define BIT_8(A)  ((A) & 0x00000100)
    1.55 +#define BIT_9(A)  ((A) & 0x00000200)
    1.56 +#define BIT_A(A)  ((A) & 0x00000400)
    1.57 +#define BIT_B(A)  ((A) & 0x00000800)
    1.58 +#define BIT_C(A)  ((A) & 0x00001000)
    1.59 +#define BIT_D(A)  ((A) & 0x00002000)
    1.60 +#define BIT_E(A)  ((A) & 0x00004000)
    1.61 +#define BIT_F(A)  ((A) & 0x00008000)
    1.62 +#define BIT_10(A) ((A) & 0x00010000)
    1.63 +#define BIT_11(A) ((A) & 0x00020000)
    1.64 +#define BIT_12(A) ((A) & 0x00040000)
    1.65 +#define BIT_13(A) ((A) & 0x00080000)
    1.66 +#define BIT_14(A) ((A) & 0x00100000)
    1.67 +#define BIT_15(A) ((A) & 0x00200000)
    1.68 +#define BIT_16(A) ((A) & 0x00400000)
    1.69 +#define BIT_17(A) ((A) & 0x00800000)
    1.70 +#define BIT_18(A) ((A) & 0x01000000)
    1.71 +#define BIT_19(A) ((A) & 0x02000000)
    1.72 +#define BIT_1A(A) ((A) & 0x04000000)
    1.73 +#define BIT_1B(A) ((A) & 0x08000000)
    1.74 +#define BIT_1C(A) ((A) & 0x10000000)
    1.75 +#define BIT_1D(A) ((A) & 0x20000000)
    1.76 +#define BIT_1E(A) ((A) & 0x40000000)
    1.77 +#define BIT_1F(A) ((A) & 0x80000000)
    1.78 +
    1.79 +/* These are the CPU types understood by this disassembler */
    1.80 +#define TYPE_68000 1
    1.81 +#define TYPE_68010 2
    1.82 +#define TYPE_68020 4
    1.83 +#define TYPE_68030 8
    1.84 +#define TYPE_68040 16
    1.85 +
    1.86 +#define M68000_ONLY		TYPE_68000
    1.87 +
    1.88 +#define M68010_ONLY		TYPE_68010
    1.89 +#define M68010_LESS		(TYPE_68000 | TYPE_68010)
    1.90 +#define M68010_PLUS		(TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040)
    1.91 +
    1.92 +#define M68020_ONLY 	TYPE_68020
    1.93 +#define M68020_LESS 	(TYPE_68010 | TYPE_68020)
    1.94 +#define M68020_PLUS		(TYPE_68020 | TYPE_68030 | TYPE_68040)
    1.95 +
    1.96 +#define M68030_ONLY 	TYPE_68030
    1.97 +#define M68030_LESS 	(TYPE_68010 | TYPE_68020 | TYPE_68030)
    1.98 +#define M68030_PLUS		(TYPE_68030 | TYPE_68040)
    1.99 +
   1.100 +#define M68040_PLUS		TYPE_68040
   1.101 +
   1.102 +
   1.103 +/* Extension word formats */
   1.104 +#define EXT_8BIT_DISPLACEMENT(A)          ((A)&0xff)
   1.105 +#define EXT_FULL(A)                       BIT_8(A)
   1.106 +#define EXT_EFFECTIVE_ZERO(A)             (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0)
   1.107 +#define EXT_BASE_REGISTER_PRESENT(A)      (!BIT_7(A))
   1.108 +#define EXT_INDEX_REGISTER_PRESENT(A)     (!BIT_6(A))
   1.109 +#define EXT_INDEX_REGISTER(A)             (((A)>>12)&7)
   1.110 +#define EXT_INDEX_PRE_POST(A)             (EXT_INDEX_PRESENT(A) && (A)&3)
   1.111 +#define EXT_INDEX_PRE(A)                  (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0)
   1.112 +#define EXT_INDEX_POST(A)                 (EXT_INDEX_PRESENT(A) && ((A)&7) > 4)
   1.113 +#define EXT_INDEX_SCALE(A)                (((A)>>9)&3)
   1.114 +#define EXT_INDEX_LONG(A)                 BIT_B(A)
   1.115 +#define EXT_INDEX_AR(A)                   BIT_F(A)
   1.116 +#define EXT_BASE_DISPLACEMENT_PRESENT(A)  (((A)&0x30) > 0x10)
   1.117 +#define EXT_BASE_DISPLACEMENT_WORD(A)     (((A)&0x30) == 0x20)
   1.118 +#define EXT_BASE_DISPLACEMENT_LONG(A)     (((A)&0x30) == 0x30)
   1.119 +#define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44)
   1.120 +#define EXT_OUTER_DISPLACEMENT_WORD(A)    (((A)&3) == 2 && ((A)&0x47) < 0x44)
   1.121 +#define EXT_OUTER_DISPLACEMENT_LONG(A)    (((A)&3) == 3 && ((A)&0x47) < 0x44)
   1.122 +
   1.123 +
   1.124 +
   1.125 +/* ======================================================================== */
   1.126 +/* =============================== PROTOTYPES ============================= */
   1.127 +/* ======================================================================== */
   1.128 +
   1.129 +/* Read data at the PC and increment PC */
   1.130 +uint  read_imm_8(void);
   1.131 +uint  read_imm_16(void);
   1.132 +uint  read_imm_32(void);
   1.133 +
   1.134 +/* Read data at the PC but don't imcrement the PC */
   1.135 +uint  peek_imm_8(void);
   1.136 +uint  peek_imm_16(void);
   1.137 +uint  peek_imm_32(void);
   1.138 +
   1.139 +/* make signed integers 100% portably */
   1.140 +static int make_int_8(int value);
   1.141 +static int make_int_16(int value);
   1.142 +
   1.143 +/* make a string of a hex value */
   1.144 +static char* make_signed_hex_str_8(uint val);
   1.145 +static char* make_signed_hex_str_16(uint val);
   1.146 +static char* make_signed_hex_str_32(uint val);
   1.147 +
   1.148 +/* make string of ea mode */
   1.149 +static char* get_ea_mode_str(uint instruction, uint size);
   1.150 +
   1.151 +char* get_ea_mode_str_8(uint instruction);
   1.152 +char* get_ea_mode_str_16(uint instruction);
   1.153 +char* get_ea_mode_str_32(uint instruction);
   1.154 +
   1.155 +/* make string of immediate value */
   1.156 +static char* get_imm_str_s(uint size);
   1.157 +static char* get_imm_str_u(uint size);
   1.158 +
   1.159 +char* get_imm_str_s8(void);
   1.160 +char* get_imm_str_s16(void);
   1.161 +char* get_imm_str_s32(void);
   1.162 +
   1.163 +/* Stuff to build the opcode handler jump table */
   1.164 +static void  build_opcode_table(void);
   1.165 +static int   valid_ea(uint opcode, uint mask);
   1.166 +static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr);
   1.167 +
   1.168 +/* used to build opcode handler jump table */
   1.169 +typedef struct
   1.170 +{
   1.171 +	void (*opcode_handler)(void); /* handler function */
   1.172 +	uint mask;                    /* mask on opcode */
   1.173 +	uint match;                   /* what to match after masking */
   1.174 +	uint ea_mask;                 /* what ea modes are allowed */
   1.175 +} opcode_struct;
   1.176 +
   1.177 +
   1.178 +
   1.179 +/* ======================================================================== */
   1.180 +/* ================================= DATA ================================= */
   1.181 +/* ======================================================================== */
   1.182 +
   1.183 +/* Opcode handler jump table */
   1.184 +static void (*g_instruction_table[0x10000])(void);
   1.185 +/* Flag if disassembler initialized */
   1.186 +static int  g_initialized = 0;
   1.187 +
   1.188 +/* Address mask to simulate address lines */
   1.189 +static unsigned int g_address_mask = 0xffffffff;
   1.190 +
   1.191 +static char g_dasm_str[100]; /* string to hold disassembly */
   1.192 +static char g_helper_str[100]; /* string to hold helpful info */
   1.193 +static uint g_cpu_pc;        /* program counter */
   1.194 +static uint g_cpu_ir;        /* instruction register */
   1.195 +static uint g_cpu_type;
   1.196 +
   1.197 +/* used by ops like asr, ror, addq, etc */
   1.198 +static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
   1.199 +
   1.200 +static uint g_5bit_data_table[32] =
   1.201 +{
   1.202 +	32,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
   1.203 +	16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
   1.204 +};
   1.205 +
   1.206 +static char* g_cc[16] =
   1.207 +{"t", "f", "hi", "ls", "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi", "ge", "lt", "gt", "le"};
   1.208 +
   1.209 +static char* g_cpcc[64] =
   1.210 +{/* 000    001    010    011    100    101    110    111 */
   1.211 +	  "f",  "eq", "ogt", "oge", "olt", "ole", "ogl",  "or", /* 000 */
   1.212 +	 "un", "ueq", "ugt", "uge", "ult", "ule",  "ne",   "t", /* 001 */
   1.213 +	 "sf", "seq",  "gt",  "ge",  "lt",  "le",  "gl"  "gle", /* 010 */
   1.214 +  "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne",  "st", /* 011 */
   1.215 +	  "?",   "?",   "?",   "?",   "?",   "?",   "?",   "?", /* 100 */
   1.216 +	  "?",   "?",   "?",   "?",   "?",   "?",   "?",   "?", /* 101 */
   1.217 +	  "?",   "?",   "?",   "?",   "?",   "?",   "?",   "?", /* 110 */
   1.218 +	  "?",   "?",   "?",   "?",   "?",   "?",   "?",   "?"  /* 111 */
   1.219 +};
   1.220 +
   1.221 +
   1.222 +/* ======================================================================== */
   1.223 +/* =========================== UTILITY FUNCTIONS ========================== */
   1.224 +/* ======================================================================== */
   1.225 +
   1.226 +#define LIMIT_CPU_TYPES(ALLOWED_CPU_TYPES)	\
   1.227 +	if(!(g_cpu_type & ALLOWED_CPU_TYPES))	\
   1.228 +	{										\
   1.229 +		d68000_illegal();					\
   1.230 +		return;								\
   1.231 +	}
   1.232 +
   1.233 +#define read_imm_8()  (m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)&0xff)
   1.234 +#define read_imm_16() m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)
   1.235 +#define read_imm_32() m68k_read_disassembler_32(((g_cpu_pc+=4)-4)&g_address_mask)
   1.236 +
   1.237 +#define peek_imm_8()  (m68k_read_disassembler_16(g_cpu_pc & g_address_mask)&0xff)
   1.238 +#define peek_imm_16() m68k_read_disassembler_16(g_cpu_pc & g_address_mask)
   1.239 +#define peek_imm_32() m68k_read_disassembler_32(g_cpu_pc & g_address_mask)
   1.240 +
   1.241 +/* Fake a split interface */
   1.242 +#define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0)
   1.243 +#define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1)
   1.244 +#define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2)
   1.245 +
   1.246 +#define get_imm_str_s8() get_imm_str_s(0)
   1.247 +#define get_imm_str_s16() get_imm_str_s(1)
   1.248 +#define get_imm_str_s32() get_imm_str_s(2)
   1.249 +
   1.250 +#define get_imm_str_u8() get_imm_str_u(0)
   1.251 +#define get_imm_str_u16() get_imm_str_u(1)
   1.252 +#define get_imm_str_u32() get_imm_str_u(2)
   1.253 +
   1.254 +
   1.255 +/* 100% portable signed int generators */
   1.256 +static int make_int_8(int value)
   1.257 +{
   1.258 +	return (value & 0x80) ? value | ~0xff : value & 0xff;
   1.259 +}
   1.260 +
   1.261 +static int make_int_16(int value)
   1.262 +{
   1.263 +	return (value & 0x8000) ? value | ~0xffff : value & 0xffff;
   1.264 +}
   1.265 +
   1.266 +
   1.267 +/* Get string representation of hex values */
   1.268 +static char* make_signed_hex_str_8(uint val)
   1.269 +{
   1.270 +	static char str[20];
   1.271 +
   1.272 +	val &= 0xff;
   1.273 +
   1.274 +	if(val == 0x80)
   1.275 +		sprintf(str, "-$80");
   1.276 +	else if(val & 0x80)
   1.277 +		sprintf(str, "-$%x", (0-val) & 0x7f);
   1.278 +	else
   1.279 +		sprintf(str, "$%x", val & 0x7f);
   1.280 +
   1.281 +	return str;
   1.282 +}
   1.283 +
   1.284 +static char* make_signed_hex_str_16(uint val)
   1.285 +{
   1.286 +	static char str[20];
   1.287 +
   1.288 +	val &= 0xffff;
   1.289 +
   1.290 +	if(val == 0x8000)
   1.291 +		sprintf(str, "-$8000");
   1.292 +	else if(val & 0x8000)
   1.293 +		sprintf(str, "-$%x", (0-val) & 0x7fff);
   1.294 +	else
   1.295 +		sprintf(str, "$%x", val & 0x7fff);
   1.296 +
   1.297 +	return str;
   1.298 +}
   1.299 +
   1.300 +static char* make_signed_hex_str_32(uint val)
   1.301 +{
   1.302 +	static char str[20];
   1.303 +
   1.304 +	val &= 0xffffffff;
   1.305 +
   1.306 +	if(val == 0x80000000)
   1.307 +		sprintf(str, "-$80000000");
   1.308 +	else if(val & 0x80000000)
   1.309 +		sprintf(str, "-$%x", (0-val) & 0x7fffffff);
   1.310 +	else
   1.311 +		sprintf(str, "$%x", val & 0x7fffffff);
   1.312 +
   1.313 +	return str;
   1.314 +}
   1.315 +
   1.316 +
   1.317 +/* make string of immediate value */
   1.318 +static char* get_imm_str_s(uint size)
   1.319 +{
   1.320 +	static char str[15];
   1.321 +	if(size == 0)
   1.322 +		sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8()));
   1.323 +	else if(size == 1)
   1.324 +		sprintf(str, "#%s", make_signed_hex_str_16(read_imm_16()));
   1.325 +	else
   1.326 +		sprintf(str, "#%s", make_signed_hex_str_32(read_imm_32()));
   1.327 +	return str;
   1.328 +}
   1.329 +
   1.330 +static char* get_imm_str_u(uint size)
   1.331 +{
   1.332 +	static char str[15];
   1.333 +	if(size == 0)
   1.334 +		sprintf(str, "#$%x", read_imm_8() & 0xff);
   1.335 +	else if(size == 1)
   1.336 +		sprintf(str, "#$%x", read_imm_16() & 0xffff);
   1.337 +	else
   1.338 +		sprintf(str, "#$%x", read_imm_32() & 0xffffffff);
   1.339 +	return str;
   1.340 +}
   1.341 +
   1.342 +/* Make string of effective address mode */
   1.343 +static char* get_ea_mode_str(uint instruction, uint size)
   1.344 +{
   1.345 +	static char b1[64];
   1.346 +	static char b2[64];
   1.347 +	static char* mode = b2;
   1.348 +	uint extension;
   1.349 +	uint base;
   1.350 +	uint outer;
   1.351 +	char base_reg[4];
   1.352 +	char index_reg[8];
   1.353 +	uint preindex;
   1.354 +	uint postindex;
   1.355 +	uint comma = 0;
   1.356 +	uint temp_value;
   1.357 +
   1.358 +	/* Switch buffers so we don't clobber on a double-call to this function */
   1.359 +	mode = mode == b1 ? b2 : b1;
   1.360 +
   1.361 +	switch(instruction & 0x3f)
   1.362 +	{
   1.363 +		case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
   1.364 +		/* data register direct */
   1.365 +			sprintf(mode, "D%d", instruction&7);
   1.366 +			break;
   1.367 +		case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
   1.368 +		/* address register direct */
   1.369 +			sprintf(mode, "A%d", instruction&7);
   1.370 +			break;
   1.371 +		case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
   1.372 +		/* address register indirect */
   1.373 +			sprintf(mode, "(A%d)", instruction&7);
   1.374 +			break;
   1.375 +		case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
   1.376 +		/* address register indirect with postincrement */
   1.377 +			sprintf(mode, "(A%d)+", instruction&7);
   1.378 +			break;
   1.379 +		case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
   1.380 +		/* address register indirect with predecrement */
   1.381 +			sprintf(mode, "-(A%d)", instruction&7);
   1.382 +			break;
   1.383 +		case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
   1.384 +		/* address register indirect with displacement*/
   1.385 +			sprintf(mode, "(%s,A%d)", make_signed_hex_str_16(read_imm_16()), instruction&7);
   1.386 +			break;
   1.387 +		case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
   1.388 +		/* address register indirect with index */
   1.389 +			extension = read_imm_16();
   1.390 +
   1.391 +			if(EXT_FULL(extension))
   1.392 +			{
   1.393 +				if(EXT_EFFECTIVE_ZERO(extension))
   1.394 +				{
   1.395 +					strcpy(mode, "0");
   1.396 +					break;
   1.397 +				}
   1.398 +				base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
   1.399 +				outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
   1.400 +				if(EXT_BASE_REGISTER_PRESENT(extension))
   1.401 +					sprintf(base_reg, "A%d", instruction&7);
   1.402 +				else
   1.403 +					*base_reg = 0;
   1.404 +				if(EXT_INDEX_REGISTER_PRESENT(extension))
   1.405 +				{
   1.406 +					sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
   1.407 +					if(EXT_INDEX_SCALE(extension))
   1.408 +						sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
   1.409 +				}
   1.410 +				else
   1.411 +					*index_reg = 0;
   1.412 +				preindex = (extension&7) > 0 && (extension&7) < 4;
   1.413 +				postindex = (extension&7) > 4;
   1.414 +
   1.415 +				strcpy(mode, "(");
   1.416 +				if(preindex || postindex)
   1.417 +					strcat(mode, "[");
   1.418 +				if(base)
   1.419 +				{
   1.420 +					strcat(mode, make_signed_hex_str_16(base));
   1.421 +					comma = 1;
   1.422 +				}
   1.423 +				if(*base_reg)
   1.424 +				{
   1.425 +					if(comma)
   1.426 +						strcat(mode, ",");
   1.427 +					strcat(mode, base_reg);
   1.428 +					comma = 1;
   1.429 +				}
   1.430 +				if(postindex)
   1.431 +				{
   1.432 +					strcat(mode, "]");
   1.433 +					comma = 1;
   1.434 +				}
   1.435 +				if(*index_reg)
   1.436 +				{
   1.437 +					if(comma)
   1.438 +						strcat(mode, ",");
   1.439 +					strcat(mode, index_reg);
   1.440 +					comma = 1;
   1.441 +				}
   1.442 +				if(preindex)
   1.443 +				{
   1.444 +					strcat(mode, "]");
   1.445 +					comma = 1;
   1.446 +				}
   1.447 +				if(outer)
   1.448 +				{
   1.449 +					if(comma)
   1.450 +						strcat(mode, ",");
   1.451 +					strcat(mode, make_signed_hex_str_16(outer));
   1.452 +				}
   1.453 +				strcat(mode, ")");
   1.454 +				break;
   1.455 +			}
   1.456 +
   1.457 +			if(EXT_8BIT_DISPLACEMENT(extension) == 0)
   1.458 +				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');
   1.459 +			else
   1.460 +				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');
   1.461 +			if(EXT_INDEX_SCALE(extension))
   1.462 +				sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
   1.463 +			strcat(mode, ")");
   1.464 +			break;
   1.465 +		case 0x38:
   1.466 +		/* absolute short address */
   1.467 +			sprintf(mode, "$%x.w", read_imm_16());
   1.468 +			break;
   1.469 +		case 0x39:
   1.470 +		/* absolute long address */
   1.471 +			sprintf(mode, "$%x.l", read_imm_32());
   1.472 +			break;
   1.473 +		case 0x3a:
   1.474 +		/* program counter with displacement */
   1.475 +			temp_value = read_imm_16();
   1.476 +			sprintf(mode, "(%s,PC)", make_signed_hex_str_16(temp_value));
   1.477 +			sprintf(g_helper_str, "; ($%x)", (make_int_16(temp_value) + g_cpu_pc-2) & 0xffffffff);
   1.478 +			break;
   1.479 +		case 0x3b:
   1.480 +		/* program counter with index */
   1.481 +			extension = read_imm_16();
   1.482 +
   1.483 +			if(EXT_FULL(extension))
   1.484 +			{
   1.485 +				if(EXT_EFFECTIVE_ZERO(extension))
   1.486 +				{
   1.487 +					strcpy(mode, "0");
   1.488 +					break;
   1.489 +				}
   1.490 +				base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
   1.491 +				outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0;
   1.492 +				if(EXT_BASE_REGISTER_PRESENT(extension))
   1.493 +					strcpy(base_reg, "PC");
   1.494 +				else
   1.495 +					*base_reg = 0;
   1.496 +				if(EXT_INDEX_REGISTER_PRESENT(extension))
   1.497 +				{
   1.498 +					sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
   1.499 +					if(EXT_INDEX_SCALE(extension))
   1.500 +						sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension));
   1.501 +				}
   1.502 +				else
   1.503 +					*index_reg = 0;
   1.504 +				preindex = (extension&7) > 0 && (extension&7) < 4;
   1.505 +				postindex = (extension&7) > 4;
   1.506 +
   1.507 +				strcpy(mode, "(");
   1.508 +				if(preindex || postindex)
   1.509 +					strcat(mode, "[");
   1.510 +				if(base)
   1.511 +				{
   1.512 +					strcat(mode, make_signed_hex_str_16(base));
   1.513 +					comma = 1;
   1.514 +				}
   1.515 +				if(*base_reg)
   1.516 +				{
   1.517 +					if(comma)
   1.518 +						strcat(mode, ",");
   1.519 +					strcat(mode, base_reg);
   1.520 +					comma = 1;
   1.521 +				}
   1.522 +				if(postindex)
   1.523 +				{
   1.524 +					strcat(mode, "]");
   1.525 +					comma = 1;
   1.526 +				}
   1.527 +				if(*index_reg)
   1.528 +				{
   1.529 +					if(comma)
   1.530 +						strcat(mode, ",");
   1.531 +					strcat(mode, index_reg);
   1.532 +					comma = 1;
   1.533 +				}
   1.534 +				if(preindex)
   1.535 +				{
   1.536 +					strcat(mode, "]");
   1.537 +					comma = 1;
   1.538 +				}
   1.539 +				if(outer)
   1.540 +				{
   1.541 +					if(comma)
   1.542 +						strcat(mode, ",");
   1.543 +					strcat(mode, make_signed_hex_str_16(outer));
   1.544 +				}
   1.545 +				strcat(mode, ")");
   1.546 +				break;
   1.547 +			}
   1.548 +
   1.549 +			if(EXT_8BIT_DISPLACEMENT(extension) == 0)
   1.550 +				sprintf(mode, "(PC,%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w');
   1.551 +			else
   1.552 +				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');
   1.553 +			if(EXT_INDEX_SCALE(extension))
   1.554 +				sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension));
   1.555 +			strcat(mode, ")");
   1.556 +			break;
   1.557 +		case 0x3c:
   1.558 +		/* Immediate */
   1.559 +			sprintf(mode, "%s", get_imm_str_u(size));
   1.560 +			break;
   1.561 +		default:
   1.562 +			sprintf(mode, "INVALID %x", instruction & 0x3f);
   1.563 +	}
   1.564 +	return mode;
   1.565 +}
   1.566 +
   1.567 +
   1.568 +
   1.569 +/* ======================================================================== */
   1.570 +/* ========================= INSTRUCTION HANDLERS ========================= */
   1.571 +/* ======================================================================== */
   1.572 +/* Instruction handler function names follow this convention:
   1.573 + *
   1.574 + * d68000_NAME_EXTENSIONS(void)
   1.575 + * where NAME is the name of the opcode it handles and EXTENSIONS are any
   1.576 + * extensions for special instances of that opcode.
   1.577 + *
   1.578 + * Examples:
   1.579 + *   d68000_add_er_8(): add opcode, from effective address to register,
   1.580 + *                      size = byte
   1.581 + *
   1.582 + *   d68000_asr_s_8(): arithmetic shift right, static count, size = byte
   1.583 + *
   1.584 + *
   1.585 + * Common extensions:
   1.586 + * 8   : size = byte
   1.587 + * 16  : size = word
   1.588 + * 32  : size = long
   1.589 + * rr  : register to register
   1.590 + * mm  : memory to memory
   1.591 + * r   : register
   1.592 + * s   : static
   1.593 + * er  : effective address -> register
   1.594 + * re  : register -> effective address
   1.595 + * ea  : using effective address mode of operation
   1.596 + * d   : data register direct
   1.597 + * a   : address register direct
   1.598 + * ai  : address register indirect
   1.599 + * pi  : address register indirect with postincrement
   1.600 + * pd  : address register indirect with predecrement
   1.601 + * di  : address register indirect with displacement
   1.602 + * ix  : address register indirect with index
   1.603 + * aw  : absolute word
   1.604 + * al  : absolute long
   1.605 + */
   1.606 +
   1.607 +static void d68000_illegal(void)
   1.608 +{
   1.609 +	sprintf(g_dasm_str, "dc.w $%04x; ILLEGAL", g_cpu_ir);
   1.610 +}
   1.611 +
   1.612 +static void d68000_1010(void)
   1.613 +{
   1.614 +	sprintf(g_dasm_str, "dc.w    $%04x; opcode 1010", g_cpu_ir);
   1.615 +}
   1.616 +
   1.617 +
   1.618 +static void d68000_1111(void)
   1.619 +{
   1.620 +	sprintf(g_dasm_str, "dc.w    $%04x; opcode 1111", g_cpu_ir);
   1.621 +}
   1.622 +
   1.623 +
   1.624 +static void d68000_abcd_rr(void)
   1.625 +{
   1.626 +	sprintf(g_dasm_str, "abcd    D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.627 +}
   1.628 +
   1.629 +
   1.630 +static void d68000_abcd_mm(void)
   1.631 +{
   1.632 +	sprintf(g_dasm_str, "abcd    -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.633 +}
   1.634 +
   1.635 +static void d68000_add_er_8(void)
   1.636 +{
   1.637 +	sprintf(g_dasm_str, "add.b   %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.638 +}
   1.639 +
   1.640 +
   1.641 +static void d68000_add_er_16(void)
   1.642 +{
   1.643 +	sprintf(g_dasm_str, "add.w   %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.644 +}
   1.645 +
   1.646 +static void d68000_add_er_32(void)
   1.647 +{
   1.648 +	sprintf(g_dasm_str, "add.l   %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.649 +}
   1.650 +
   1.651 +static void d68000_add_re_8(void)
   1.652 +{
   1.653 +	sprintf(g_dasm_str, "add.b   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
   1.654 +}
   1.655 +
   1.656 +static void d68000_add_re_16(void)
   1.657 +{
   1.658 +	sprintf(g_dasm_str, "add.w   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
   1.659 +}
   1.660 +
   1.661 +static void d68000_add_re_32(void)
   1.662 +{
   1.663 +	sprintf(g_dasm_str, "add.l   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
   1.664 +}
   1.665 +
   1.666 +static void d68000_adda_16(void)
   1.667 +{
   1.668 +	sprintf(g_dasm_str, "adda.w  %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.669 +}
   1.670 +
   1.671 +static void d68000_adda_32(void)
   1.672 +{
   1.673 +	sprintf(g_dasm_str, "adda.l  %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.674 +}
   1.675 +
   1.676 +static void d68000_addi_8(void)
   1.677 +{
   1.678 +	char* str = get_imm_str_s8();
   1.679 +	sprintf(g_dasm_str, "addi.b  %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
   1.680 +}
   1.681 +
   1.682 +static void d68000_addi_16(void)
   1.683 +{
   1.684 +	char* str = get_imm_str_s16();
   1.685 +	sprintf(g_dasm_str, "addi.w  %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
   1.686 +}
   1.687 +
   1.688 +static void d68000_addi_32(void)
   1.689 +{
   1.690 +	char* str = get_imm_str_s32();
   1.691 +	sprintf(g_dasm_str, "addi.l  %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
   1.692 +}
   1.693 +
   1.694 +static void d68000_addq_8(void)
   1.695 +{
   1.696 +	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));
   1.697 +}
   1.698 +
   1.699 +static void d68000_addq_16(void)
   1.700 +{
   1.701 +	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));
   1.702 +}
   1.703 +
   1.704 +static void d68000_addq_32(void)
   1.705 +{
   1.706 +	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));
   1.707 +}
   1.708 +
   1.709 +static void d68000_addx_rr_8(void)
   1.710 +{
   1.711 +	sprintf(g_dasm_str, "addx.b  D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.712 +}
   1.713 +
   1.714 +static void d68000_addx_rr_16(void)
   1.715 +{
   1.716 +	sprintf(g_dasm_str, "addx.w  D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.717 +}
   1.718 +
   1.719 +static void d68000_addx_rr_32(void)
   1.720 +{
   1.721 +	sprintf(g_dasm_str, "addx.l  D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.722 +}
   1.723 +
   1.724 +static void d68000_addx_mm_8(void)
   1.725 +{
   1.726 +	sprintf(g_dasm_str, "addx.b  -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.727 +}
   1.728 +
   1.729 +static void d68000_addx_mm_16(void)
   1.730 +{
   1.731 +	sprintf(g_dasm_str, "addx.w  -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.732 +}
   1.733 +
   1.734 +static void d68000_addx_mm_32(void)
   1.735 +{
   1.736 +	sprintf(g_dasm_str, "addx.l  -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
   1.737 +}
   1.738 +
   1.739 +static void d68000_and_er_8(void)
   1.740 +{
   1.741 +	sprintf(g_dasm_str, "and.b   %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.742 +}
   1.743 +
   1.744 +static void d68000_and_er_16(void)
   1.745 +{
   1.746 +	sprintf(g_dasm_str, "and.w   %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.747 +}
   1.748 +
   1.749 +static void d68000_and_er_32(void)
   1.750 +{
   1.751 +	sprintf(g_dasm_str, "and.l   %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
   1.752 +}
   1.753 +
   1.754 +static void d68000_and_re_8(void)
   1.755 +{
   1.756 +	sprintf(g_dasm_str, "and.b   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
   1.757 +}
   1.758 +
   1.759 +static void d68000_and_re_16(void)
   1.760 +{
   1.761 +	sprintf(g_dasm_str, "and.w   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
   1.762 +}
   1.763 +
   1.764 +static void d68000_and_re_32(void)
   1.765 +{
   1.766 +	sprintf(g_dasm_str, "and.l   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
   1.767 +}
   1.768 +
   1.769 +static void d68000_andi_8(void)
   1.770 +{
   1.771 +	char* str = get_imm_str_u8();
   1.772 +	sprintf(g_dasm_str, "andi.b  %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
   1.773 +}
   1.774 +
   1.775 +static void d68000_andi_16(void)
   1.776 +{
   1.777 +	char* str = get_imm_str_u16();
   1.778 +	sprintf(g_dasm_str, "andi.w  %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
   1.779 +}
   1.780 +
   1.781 +static void d68000_andi_32(void)
   1.782 +{
   1.783 +	char* str = get_imm_str_u32();
   1.784 +	sprintf(g_dasm_str, "andi.l  %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
   1.785 +}
   1.786 +
   1.787 +static void d68000_andi_to_ccr(void)
   1.788 +{
   1.789 +	sprintf(g_dasm_str, "andi    %s, CCR", get_imm_str_u8());
   1.790 +}
   1.791 +
   1.792 +static void d68000_andi_to_sr(void)
   1.793 +{
   1.794 +	sprintf(g_dasm_str, "andi    %s, SR", get_imm_str_u16());
   1.795 +}
   1.796 +
   1.797 +static void d68000_asr_s_8(void)
   1.798 +{
   1.799 +	sprintf(g_dasm_str, "asr.b   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
   1.800 +}
   1.801 +
   1.802 +static void d68000_asr_s_16(void)
   1.803 +{
   1.804 +	sprintf(g_dasm_str, "asr.w   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
   1.805 +}
   1.806 +
   1.807 +static void d68000_asr_s_32(void)
   1.808 +{
   1.809 +	sprintf(g_dasm_str, "asr.l   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
   1.810 +}
   1.811 +
   1.812 +static void d68000_asr_r_8(void)
   1.813 +{
   1.814 +	sprintf(g_dasm_str, "asr.b   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
   1.815 +}
   1.816 +
   1.817 +static void d68000_asr_r_16(void)
   1.818 +{
   1.819 +	sprintf(g_dasm_str, "asr.w   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
   1.820 +}
   1.821 +
   1.822 +static void d68000_asr_r_32(void)
   1.823 +{
   1.824 +	sprintf(g_dasm_str, "asr.l   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
   1.825 +}
   1.826 +
   1.827 +static void d68000_asr_ea(void)
   1.828 +{
   1.829 +	sprintf(g_dasm_str, "asr.w   %s", get_ea_mode_str_16(g_cpu_ir));
   1.830 +}
   1.831 +
   1.832 +static void d68000_asl_s_8(void)
   1.833 +{
   1.834 +	sprintf(g_dasm_str, "asl.b   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
   1.835 +}
   1.836 +
   1.837 +static void d68000_asl_s_16(void)
   1.838 +{
   1.839 +	sprintf(g_dasm_str, "asl.w   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
   1.840 +}
   1.841 +
   1.842 +static void d68000_asl_s_32(void)
   1.843 +{
   1.844 +	sprintf(g_dasm_str, "asl.l   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
   1.845 +}
   1.846 +
   1.847 +static void d68000_asl_r_8(void)
   1.848 +{
   1.849 +	sprintf(g_dasm_str, "asl.b   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
   1.850 +}
   1.851 +
   1.852 +static void d68000_asl_r_16(void)
   1.853 +{
   1.854 +	sprintf(g_dasm_str, "asl.w   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
   1.855 +}
   1.856 +
   1.857 +static void d68000_asl_r_32(void)
   1.858 +{
   1.859 +	sprintf(g_dasm_str, "asl.l   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
   1.860 +}
   1.861 +
   1.862 +static void d68000_asl_ea(void)
   1.863 +{
   1.864 +	sprintf(g_dasm_str, "asl.w   %s", get_ea_mode_str_16(g_cpu_ir));
   1.865 +}
   1.866 +
   1.867 +static void d68000_bcc_8(void)
   1.868 +{
   1.869 +	uint temp_pc = g_cpu_pc;
   1.870 +	sprintf(g_dasm_str, "b%-2s     %x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_8(g_cpu_ir));
   1.871 +}
   1.872 +
   1.873 +static void d68000_bcc_16(void)
   1.874 +{
   1.875 +	uint temp_pc = g_cpu_pc;
   1.876 +	sprintf(g_dasm_str, "b%-2s     %x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_16(read_imm_16()));
   1.877 +}
   1.878 +
   1.879 +static void d68020_bcc_32(void)
   1.880 +{
   1.881 +	uint temp_pc = g_cpu_pc;
   1.882 +	LIMIT_CPU_TYPES(M68020_PLUS);
   1.883 +	sprintf(g_dasm_str, "b%-2s     %x; (2+)", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + read_imm_32());
   1.884 +}
   1.885 +
   1.886 +static void d68000_bchg_r(void)
   1.887 +{
   1.888 +	sprintf(g_dasm_str, "bchg    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
   1.889 +}
   1.890 +
   1.891 +static void d68000_bchg_s(void)
   1.892 +{
   1.893 +	char* str = get_imm_str_u8();
   1.894 +	sprintf(g_dasm_str, "bchg    %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
   1.895 +}
   1.896 +
   1.897 +static void d68000_bclr_r(void)
   1.898 +{
   1.899 +	sprintf(g_dasm_str, "bclr    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
   1.900 +}
   1.901 +
   1.902 +static void d68000_bclr_s(void)
   1.903 +{
   1.904 +	char* str = get_imm_str_u8();
   1.905 +	sprintf(g_dasm_str, "bclr    %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
   1.906 +}
   1.907 +
   1.908 +static void d68010_bkpt(void)
   1.909 +{
   1.910 +	LIMIT_CPU_TYPES(M68010_PLUS);
   1.911 +	sprintf(g_dasm_str, "bkpt #%d; (1+)", g_cpu_ir&7);
   1.912 +}
   1.913 +
   1.914 +static void d68020_bfchg(void)
   1.915 +{
   1.916 +	uint extension;
   1.917 +	char offset[3];
   1.918 +	char width[3];
   1.919 +
   1.920 +	LIMIT_CPU_TYPES(M68020_PLUS);
   1.921 +
   1.922 +	extension = read_imm_16();
   1.923 +
   1.924 +	if(BIT_B(extension))
   1.925 +		sprintf(offset, "D%d", (extension>>6)&7);
   1.926 +	else
   1.927 +		sprintf(offset, "%d", (extension>>6)&31);
   1.928 +	if(BIT_5(extension))
   1.929 +		sprintf(width, "D%d", extension&7);
   1.930 +	else
   1.931 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
   1.932 +	sprintf(g_dasm_str, "bfchg   %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
   1.933 +}
   1.934 +
   1.935 +static void d68020_bfclr(void)
   1.936 +{
   1.937 +	uint extension;
   1.938 +	char offset[3];
   1.939 +	char width[3];
   1.940 +
   1.941 +	LIMIT_CPU_TYPES(M68020_PLUS);
   1.942 +
   1.943 +	extension = read_imm_16();
   1.944 +
   1.945 +	if(BIT_B(extension))
   1.946 +		sprintf(offset, "D%d", (extension>>6)&7);
   1.947 +	else
   1.948 +		sprintf(offset, "%d", (extension>>6)&31);
   1.949 +	if(BIT_5(extension))
   1.950 +		sprintf(width, "D%d", extension&7);
   1.951 +	else
   1.952 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
   1.953 +	sprintf(g_dasm_str, "bfclr   %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
   1.954 +}
   1.955 +
   1.956 +static void d68020_bfexts(void)
   1.957 +{
   1.958 +	uint extension;
   1.959 +	char offset[3];
   1.960 +	char width[3];
   1.961 +
   1.962 +	LIMIT_CPU_TYPES(M68020_PLUS);
   1.963 +
   1.964 +	extension = read_imm_16();
   1.965 +
   1.966 +	if(BIT_B(extension))
   1.967 +		sprintf(offset, "D%d", (extension>>6)&7);
   1.968 +	else
   1.969 +		sprintf(offset, "%d", (extension>>6)&31);
   1.970 +	if(BIT_5(extension))
   1.971 +		sprintf(width, "D%d", extension&7);
   1.972 +	else
   1.973 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
   1.974 +	sprintf(g_dasm_str, "bfexts  D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
   1.975 +}
   1.976 +
   1.977 +static void d68020_bfextu(void)
   1.978 +{
   1.979 +	uint extension;
   1.980 +	char offset[3];
   1.981 +	char width[3];
   1.982 +
   1.983 +	LIMIT_CPU_TYPES(M68020_PLUS);
   1.984 +
   1.985 +	extension = read_imm_16();
   1.986 +
   1.987 +	if(BIT_B(extension))
   1.988 +		sprintf(offset, "D%d", (extension>>6)&7);
   1.989 +	else
   1.990 +		sprintf(offset, "%d", (extension>>6)&31);
   1.991 +	if(BIT_5(extension))
   1.992 +		sprintf(width, "D%d", extension&7);
   1.993 +	else
   1.994 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
   1.995 +	sprintf(g_dasm_str, "bfextu  D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
   1.996 +}
   1.997 +
   1.998 +static void d68020_bfffo(void)
   1.999 +{
  1.1000 +	uint extension;
  1.1001 +	char offset[3];
  1.1002 +	char width[3];
  1.1003 +
  1.1004 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1005 +
  1.1006 +	extension = read_imm_16();
  1.1007 +
  1.1008 +	if(BIT_B(extension))
  1.1009 +		sprintf(offset, "D%d", (extension>>6)&7);
  1.1010 +	else
  1.1011 +		sprintf(offset, "%d", (extension>>6)&31);
  1.1012 +	if(BIT_5(extension))
  1.1013 +		sprintf(width, "D%d", extension&7);
  1.1014 +	else
  1.1015 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
  1.1016 +	sprintf(g_dasm_str, "bfffo   D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
  1.1017 +}
  1.1018 +
  1.1019 +static void d68020_bfins(void)
  1.1020 +{
  1.1021 +	uint extension;
  1.1022 +	char offset[3];
  1.1023 +	char width[3];
  1.1024 +
  1.1025 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1026 +
  1.1027 +	extension = read_imm_16();
  1.1028 +
  1.1029 +	if(BIT_B(extension))
  1.1030 +		sprintf(offset, "D%d", (extension>>6)&7);
  1.1031 +	else
  1.1032 +		sprintf(offset, "%d", (extension>>6)&31);
  1.1033 +	if(BIT_5(extension))
  1.1034 +		sprintf(width, "D%d", extension&7);
  1.1035 +	else
  1.1036 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
  1.1037 +	sprintf(g_dasm_str, "bfins   D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width);
  1.1038 +}
  1.1039 +
  1.1040 +static void d68020_bfset(void)
  1.1041 +{
  1.1042 +	uint extension;
  1.1043 +	char offset[3];
  1.1044 +	char width[3];
  1.1045 +
  1.1046 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1047 +
  1.1048 +	extension = read_imm_16();
  1.1049 +
  1.1050 +	if(BIT_B(extension))
  1.1051 +		sprintf(offset, "D%d", (extension>>6)&7);
  1.1052 +	else
  1.1053 +		sprintf(offset, "%d", (extension>>6)&31);
  1.1054 +	if(BIT_5(extension))
  1.1055 +		sprintf(width, "D%d", extension&7);
  1.1056 +	else
  1.1057 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
  1.1058 +	sprintf(g_dasm_str, "bfset   %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
  1.1059 +}
  1.1060 +
  1.1061 +static void d68020_bftst(void)
  1.1062 +{
  1.1063 +	uint extension;
  1.1064 +	char offset[3];
  1.1065 +	char width[3];
  1.1066 +
  1.1067 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1068 +
  1.1069 +	extension = read_imm_16();
  1.1070 +
  1.1071 +	if(BIT_B(extension))
  1.1072 +		sprintf(offset, "D%d", (extension>>6)&7);
  1.1073 +	else
  1.1074 +		sprintf(offset, "%d", (extension>>6)&31);
  1.1075 +	if(BIT_5(extension))
  1.1076 +		sprintf(width, "D%d", extension&7);
  1.1077 +	else
  1.1078 +		sprintf(width, "%d", g_5bit_data_table[extension&31]);
  1.1079 +	sprintf(g_dasm_str, "bftst   %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width);
  1.1080 +}
  1.1081 +
  1.1082 +static void d68000_bra_8(void)
  1.1083 +{
  1.1084 +	uint temp_pc = g_cpu_pc;
  1.1085 +	sprintf(g_dasm_str, "bra     %x", temp_pc + make_int_8(g_cpu_ir));
  1.1086 +}
  1.1087 +
  1.1088 +static void d68000_bra_16(void)
  1.1089 +{
  1.1090 +	uint temp_pc = g_cpu_pc;
  1.1091 +	sprintf(g_dasm_str, "bra     %x", temp_pc + make_int_16(read_imm_16()));
  1.1092 +}
  1.1093 +
  1.1094 +static void d68020_bra_32(void)
  1.1095 +{
  1.1096 +	uint temp_pc = g_cpu_pc;
  1.1097 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1098 +	sprintf(g_dasm_str, "bra     %x; (2+)", temp_pc + read_imm_32());
  1.1099 +}
  1.1100 +
  1.1101 +static void d68000_bset_r(void)
  1.1102 +{
  1.1103 +	sprintf(g_dasm_str, "bset    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.1104 +}
  1.1105 +
  1.1106 +static void d68000_bset_s(void)
  1.1107 +{
  1.1108 +	char* str = get_imm_str_u8();
  1.1109 +	sprintf(g_dasm_str, "bset    %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
  1.1110 +}
  1.1111 +
  1.1112 +static void d68000_bsr_8(void)
  1.1113 +{
  1.1114 +	uint temp_pc = g_cpu_pc;
  1.1115 +	sprintf(g_dasm_str, "bsr     %x", temp_pc + make_int_8(g_cpu_ir));
  1.1116 +}
  1.1117 +
  1.1118 +static void d68000_bsr_16(void)
  1.1119 +{
  1.1120 +	uint temp_pc = g_cpu_pc;
  1.1121 +	sprintf(g_dasm_str, "bsr     %x", temp_pc + make_int_16(read_imm_16()));
  1.1122 +}
  1.1123 +
  1.1124 +static void d68020_bsr_32(void)
  1.1125 +{
  1.1126 +	uint temp_pc = g_cpu_pc;
  1.1127 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1128 +	sprintf(g_dasm_str, "bsr     %x; (2+)", temp_pc + peek_imm_32());
  1.1129 +}
  1.1130 +
  1.1131 +static void d68000_btst_r(void)
  1.1132 +{
  1.1133 +	sprintf(g_dasm_str, "btst    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.1134 +}
  1.1135 +
  1.1136 +static void d68000_btst_s(void)
  1.1137 +{
  1.1138 +	char* str = get_imm_str_u8();
  1.1139 +	sprintf(g_dasm_str, "btst    %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
  1.1140 +}
  1.1141 +
  1.1142 +static void d68020_callm(void)
  1.1143 +{
  1.1144 +	char* str;
  1.1145 +	LIMIT_CPU_TYPES(M68020_ONLY);
  1.1146 +	str = get_imm_str_u8();
  1.1147 +
  1.1148 +	sprintf(g_dasm_str, "callm   %s, %s; (2)", str, get_ea_mode_str_8(g_cpu_ir));
  1.1149 +}
  1.1150 +
  1.1151 +static void d68020_cas_8(void)
  1.1152 +{
  1.1153 +	uint extension;
  1.1154 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1155 +	extension = read_imm_16();
  1.1156 +	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));
  1.1157 +}
  1.1158 +
  1.1159 +static void d68020_cas_16(void)
  1.1160 +{
  1.1161 +	uint extension;
  1.1162 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1163 +	extension = read_imm_16();
  1.1164 +	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));
  1.1165 +}
  1.1166 +
  1.1167 +static void d68020_cas_32(void)
  1.1168 +{
  1.1169 +	uint extension;
  1.1170 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1171 +	extension = read_imm_16();
  1.1172 +	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));
  1.1173 +}
  1.1174 +
  1.1175 +static void d68020_cas2_16(void)
  1.1176 +{
  1.1177 +/* CAS2 Dc1:Dc2,Du1:Dc2:(Rn1):(Rn2)
  1.1178 +f e d c b a 9 8 7 6 5 4 3 2 1 0
  1.1179 + DARn1  0 0 0  Du1  0 0 0  Dc1
  1.1180 + DARn2  0 0 0  Du2  0 0 0  Dc2
  1.1181 +*/
  1.1182 +
  1.1183 +	uint extension;
  1.1184 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1185 +	extension = read_imm_32();
  1.1186 +	sprintf(g_dasm_str, "cas2.w  D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)",
  1.1187 +		(extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
  1.1188 +		BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
  1.1189 +		BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
  1.1190 +}
  1.1191 +
  1.1192 +static void d68020_cas2_32(void)
  1.1193 +{
  1.1194 +	uint extension;
  1.1195 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1196 +	extension = read_imm_32();
  1.1197 +	sprintf(g_dasm_str, "cas2.l  D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)",
  1.1198 +		(extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7,
  1.1199 +		BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7,
  1.1200 +		BIT_F(extension) ? 'A' : 'D', (extension>>12)&7);
  1.1201 +}
  1.1202 +
  1.1203 +static void d68000_chk_16(void)
  1.1204 +{
  1.1205 +	sprintf(g_dasm_str, "chk.w   %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1206 +}
  1.1207 +
  1.1208 +static void d68020_chk_32(void)
  1.1209 +{
  1.1210 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1211 +	sprintf(g_dasm_str, "chk.l   %s, D%d; (2+)", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1212 +}
  1.1213 +
  1.1214 +static void d68020_chk2_cmp2_8(void)
  1.1215 +{
  1.1216 +	uint extension;
  1.1217 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1218 +	extension = read_imm_16();
  1.1219 +	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);
  1.1220 +}
  1.1221 +
  1.1222 +static void d68020_chk2_cmp2_16(void)
  1.1223 +{
  1.1224 +	uint extension;
  1.1225 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1226 +	extension = read_imm_16();
  1.1227 +	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);
  1.1228 +}
  1.1229 +
  1.1230 +static void d68020_chk2_cmp2_32(void)
  1.1231 +{
  1.1232 +	uint extension;
  1.1233 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1234 +	extension = read_imm_16();
  1.1235 +	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);
  1.1236 +}
  1.1237 +
  1.1238 +static void d68040_cinv(void)
  1.1239 +{
  1.1240 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.1241 +	switch((g_cpu_ir>>3)&3)
  1.1242 +	{
  1.1243 +		case 0:
  1.1244 +			sprintf(g_dasm_str, "cinv (illegal scope); (4)");
  1.1245 +			break;
  1.1246 +		case 1:
  1.1247 +			sprintf(g_dasm_str, "cinvl   %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
  1.1248 +			break;
  1.1249 +		case 2:
  1.1250 +			sprintf(g_dasm_str, "cinvp   %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
  1.1251 +			break;
  1.1252 +		case 3:
  1.1253 +			sprintf(g_dasm_str, "cinva   %d; (4)", (g_cpu_ir>>6)&3);
  1.1254 +			break;
  1.1255 +	}
  1.1256 +}
  1.1257 +
  1.1258 +static void d68000_clr_8(void)
  1.1259 +{
  1.1260 +	sprintf(g_dasm_str, "clr.b   %s", get_ea_mode_str_8(g_cpu_ir));
  1.1261 +}
  1.1262 +
  1.1263 +static void d68000_clr_16(void)
  1.1264 +{
  1.1265 +	sprintf(g_dasm_str, "clr.w   %s", get_ea_mode_str_16(g_cpu_ir));
  1.1266 +}
  1.1267 +
  1.1268 +static void d68000_clr_32(void)
  1.1269 +{
  1.1270 +	sprintf(g_dasm_str, "clr.l   %s", get_ea_mode_str_32(g_cpu_ir));
  1.1271 +}
  1.1272 +
  1.1273 +static void d68000_cmp_8(void)
  1.1274 +{
  1.1275 +	sprintf(g_dasm_str, "cmp.b   %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1276 +}
  1.1277 +
  1.1278 +static void d68000_cmp_16(void)
  1.1279 +{
  1.1280 +	sprintf(g_dasm_str, "cmp.w   %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1281 +}
  1.1282 +
  1.1283 +static void d68000_cmp_32(void)
  1.1284 +{
  1.1285 +	sprintf(g_dasm_str, "cmp.l   %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1286 +}
  1.1287 +
  1.1288 +static void d68000_cmpa_16(void)
  1.1289 +{
  1.1290 +	sprintf(g_dasm_str, "cmpa.w  %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1291 +}
  1.1292 +
  1.1293 +static void d68000_cmpa_32(void)
  1.1294 +{
  1.1295 +	sprintf(g_dasm_str, "cmpa.l  %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1296 +}
  1.1297 +
  1.1298 +static void d68000_cmpi_8(void)
  1.1299 +{
  1.1300 +	char* str = get_imm_str_s8();
  1.1301 +	sprintf(g_dasm_str, "cmpi.b  %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
  1.1302 +}
  1.1303 +
  1.1304 +static void d68020_cmpi_pcdi_8(void)
  1.1305 +{
  1.1306 +	char* str;
  1.1307 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1308 +	str = get_imm_str_s8();
  1.1309 +	sprintf(g_dasm_str, "cmpi.b  %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
  1.1310 +}
  1.1311 +
  1.1312 +static void d68020_cmpi_pcix_8(void)
  1.1313 +{
  1.1314 +	char* str;
  1.1315 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1316 +	str = get_imm_str_s8();
  1.1317 +	sprintf(g_dasm_str, "cmpi.b  %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir));
  1.1318 +}
  1.1319 +
  1.1320 +static void d68000_cmpi_16(void)
  1.1321 +{
  1.1322 +	char* str;
  1.1323 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1324 +	str = get_imm_str_s16();
  1.1325 +	sprintf(g_dasm_str, "cmpi.w  %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
  1.1326 +}
  1.1327 +
  1.1328 +static void d68020_cmpi_pcdi_16(void)
  1.1329 +{
  1.1330 +	char* str;
  1.1331 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1332 +	str = get_imm_str_s16();
  1.1333 +	sprintf(g_dasm_str, "cmpi.w  %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
  1.1334 +}
  1.1335 +
  1.1336 +static void d68020_cmpi_pcix_16(void)
  1.1337 +{
  1.1338 +	char* str;
  1.1339 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1340 +	str = get_imm_str_s16();
  1.1341 +	sprintf(g_dasm_str, "cmpi.w  %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir));
  1.1342 +}
  1.1343 +
  1.1344 +static void d68000_cmpi_32(void)
  1.1345 +{
  1.1346 +	char* str;
  1.1347 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1348 +	str = get_imm_str_s32();
  1.1349 +	sprintf(g_dasm_str, "cmpi.l  %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
  1.1350 +}
  1.1351 +
  1.1352 +static void d68020_cmpi_pcdi_32(void)
  1.1353 +{
  1.1354 +	char* str;
  1.1355 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1356 +	str = get_imm_str_s32();
  1.1357 +	sprintf(g_dasm_str, "cmpi.l  %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
  1.1358 +}
  1.1359 +
  1.1360 +static void d68020_cmpi_pcix_32(void)
  1.1361 +{
  1.1362 +	char* str;
  1.1363 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1364 +	str = get_imm_str_s32();
  1.1365 +	sprintf(g_dasm_str, "cmpi.l  %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir));
  1.1366 +}
  1.1367 +
  1.1368 +static void d68000_cmpm_8(void)
  1.1369 +{
  1.1370 +	sprintf(g_dasm_str, "cmpm.b  (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.1371 +}
  1.1372 +
  1.1373 +static void d68000_cmpm_16(void)
  1.1374 +{
  1.1375 +	sprintf(g_dasm_str, "cmpm.w  (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.1376 +}
  1.1377 +
  1.1378 +static void d68000_cmpm_32(void)
  1.1379 +{
  1.1380 +	sprintf(g_dasm_str, "cmpm.l  (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.1381 +}
  1.1382 +
  1.1383 +static void d68020_cpbcc_16(void)
  1.1384 +{
  1.1385 +	uint extension;
  1.1386 +	uint new_pc = g_cpu_pc;
  1.1387 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1388 +	extension = read_imm_16();
  1.1389 +	new_pc += make_int_16(peek_imm_16());
  1.1390 +	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);
  1.1391 +}
  1.1392 +
  1.1393 +static void d68020_cpbcc_32(void)
  1.1394 +{
  1.1395 +	uint extension;
  1.1396 +	uint new_pc = g_cpu_pc;
  1.1397 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1398 +	extension = read_imm_16();
  1.1399 +	new_pc += peek_imm_32();
  1.1400 +	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);
  1.1401 +}
  1.1402 +
  1.1403 +static void d68020_cpdbcc(void)
  1.1404 +{
  1.1405 +	uint extension1;
  1.1406 +	uint extension2;
  1.1407 +	uint new_pc = g_cpu_pc;
  1.1408 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1409 +	extension1 = read_imm_16();
  1.1410 +	extension2 = read_imm_16();
  1.1411 +	new_pc += make_int_16(peek_imm_16());
  1.1412 +	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);
  1.1413 +}
  1.1414 +
  1.1415 +static void d68020_cpgen(void)
  1.1416 +{
  1.1417 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1418 +	sprintf(g_dasm_str, "%dgen    %s; (2-3)", (g_cpu_ir>>9)&7, get_imm_str_u32());
  1.1419 +}
  1.1420 +
  1.1421 +static void d68020_cprestore(void)
  1.1422 +{
  1.1423 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1424 +	sprintf(g_dasm_str, "%drestore %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.1425 +}
  1.1426 +
  1.1427 +static void d68020_cpsave(void)
  1.1428 +{
  1.1429 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1430 +	sprintf(g_dasm_str, "%dsave   %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.1431 +}
  1.1432 +
  1.1433 +static void d68020_cpscc(void)
  1.1434 +{
  1.1435 +	uint extension1;
  1.1436 +	uint extension2;
  1.1437 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1438 +	extension1 = read_imm_16();
  1.1439 +	extension2 = read_imm_16();
  1.1440 +	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);
  1.1441 +}
  1.1442 +
  1.1443 +static void d68020_cptrapcc_0(void)
  1.1444 +{
  1.1445 +	uint extension1;
  1.1446 +	uint extension2;
  1.1447 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1448 +	extension1 = read_imm_16();
  1.1449 +	extension2 = read_imm_16();
  1.1450 +	sprintf(g_dasm_str, "%dtrap%-4s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], extension2);
  1.1451 +}
  1.1452 +
  1.1453 +static void d68020_cptrapcc_16(void)
  1.1454 +{
  1.1455 +	uint extension1;
  1.1456 +	uint extension2;
  1.1457 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1458 +	extension1 = read_imm_16();
  1.1459 +	extension2 = read_imm_16();
  1.1460 +	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);
  1.1461 +}
  1.1462 +
  1.1463 +static void d68020_cptrapcc_32(void)
  1.1464 +{
  1.1465 +	uint extension1;
  1.1466 +	uint extension2;
  1.1467 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1468 +	extension1 = read_imm_16();
  1.1469 +	extension2 = read_imm_16();
  1.1470 +	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);
  1.1471 +}
  1.1472 +
  1.1473 +static void d68040_cpush(void)
  1.1474 +{
  1.1475 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.1476 +	switch((g_cpu_ir>>3)&3)
  1.1477 +	{
  1.1478 +		case 0:
  1.1479 +			sprintf(g_dasm_str, "cpush (illegal scope); (4)");
  1.1480 +			break;
  1.1481 +		case 1:
  1.1482 +			sprintf(g_dasm_str, "cpushl  %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
  1.1483 +			break;
  1.1484 +		case 2:
  1.1485 +			sprintf(g_dasm_str, "cpushp  %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7);
  1.1486 +			break;
  1.1487 +		case 3:
  1.1488 +			sprintf(g_dasm_str, "cpusha  %d; (4)", (g_cpu_ir>>6)&3);
  1.1489 +			break;
  1.1490 +	}
  1.1491 +}
  1.1492 +
  1.1493 +static void d68000_dbra(void)
  1.1494 +{
  1.1495 +	uint temp_pc = g_cpu_pc;
  1.1496 +	sprintf(g_dasm_str, "dbra    D%d, %x", g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16()));
  1.1497 +}
  1.1498 +
  1.1499 +static void d68000_dbcc(void)
  1.1500 +{
  1.1501 +	uint temp_pc = g_cpu_pc;
  1.1502 +	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()));
  1.1503 +}
  1.1504 +
  1.1505 +static void d68000_divs(void)
  1.1506 +{
  1.1507 +	sprintf(g_dasm_str, "divs.w  %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1508 +}
  1.1509 +
  1.1510 +static void d68000_divu(void)
  1.1511 +{
  1.1512 +	sprintf(g_dasm_str, "divu.w  %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1513 +}
  1.1514 +
  1.1515 +static void d68020_divl(void)
  1.1516 +{
  1.1517 +	uint extension;
  1.1518 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1519 +	extension = read_imm_16();
  1.1520 +
  1.1521 +	if(BIT_A(extension))
  1.1522 +		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);
  1.1523 +	else if((extension&7) == ((extension>>12)&7))
  1.1524 +		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);
  1.1525 +	else
  1.1526 +		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);
  1.1527 +}
  1.1528 +
  1.1529 +static void d68000_eor_8(void)
  1.1530 +{
  1.1531 +	sprintf(g_dasm_str, "eor.b   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.1532 +}
  1.1533 +
  1.1534 +static void d68000_eor_16(void)
  1.1535 +{
  1.1536 +	sprintf(g_dasm_str, "eor.w   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
  1.1537 +}
  1.1538 +
  1.1539 +static void d68000_eor_32(void)
  1.1540 +{
  1.1541 +	sprintf(g_dasm_str, "eor.l   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
  1.1542 +}
  1.1543 +
  1.1544 +static void d68000_eori_8(void)
  1.1545 +{
  1.1546 +	char* str = get_imm_str_u8();
  1.1547 +	sprintf(g_dasm_str, "eori.b  %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
  1.1548 +}
  1.1549 +
  1.1550 +static void d68000_eori_16(void)
  1.1551 +{
  1.1552 +	char* str = get_imm_str_u16();
  1.1553 +	sprintf(g_dasm_str, "eori.w  %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
  1.1554 +}
  1.1555 +
  1.1556 +static void d68000_eori_32(void)
  1.1557 +{
  1.1558 +	char* str = get_imm_str_u32();
  1.1559 +	sprintf(g_dasm_str, "eori.l  %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
  1.1560 +}
  1.1561 +
  1.1562 +static void d68000_eori_to_ccr(void)
  1.1563 +{
  1.1564 +	sprintf(g_dasm_str, "eori    %s, CCR", get_imm_str_u8());
  1.1565 +}
  1.1566 +
  1.1567 +static void d68000_eori_to_sr(void)
  1.1568 +{
  1.1569 +	sprintf(g_dasm_str, "eori    %s, SR", get_imm_str_u16());
  1.1570 +}
  1.1571 +
  1.1572 +static void d68000_exg_dd(void)
  1.1573 +{
  1.1574 +	sprintf(g_dasm_str, "exg     D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1575 +}
  1.1576 +
  1.1577 +static void d68000_exg_aa(void)
  1.1578 +{
  1.1579 +	sprintf(g_dasm_str, "exg     A%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1580 +}
  1.1581 +
  1.1582 +static void d68000_exg_da(void)
  1.1583 +{
  1.1584 +	sprintf(g_dasm_str, "exg     D%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1585 +}
  1.1586 +
  1.1587 +static void d68000_ext_16(void)
  1.1588 +{
  1.1589 +	sprintf(g_dasm_str, "ext.w   D%d", g_cpu_ir&7);
  1.1590 +}
  1.1591 +
  1.1592 +static void d68000_ext_32(void)
  1.1593 +{
  1.1594 +	sprintf(g_dasm_str, "ext.l   D%d", g_cpu_ir&7);
  1.1595 +}
  1.1596 +
  1.1597 +static void d68020_extb_32(void)
  1.1598 +{
  1.1599 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1600 +	sprintf(g_dasm_str, "extb.l  D%d; (2+)", g_cpu_ir&7);
  1.1601 +}
  1.1602 +
  1.1603 +static void d68000_jmp(void)
  1.1604 +{
  1.1605 +	sprintf(g_dasm_str, "jmp     %s", get_ea_mode_str_32(g_cpu_ir));
  1.1606 +}
  1.1607 +
  1.1608 +static void d68000_jsr(void)
  1.1609 +{
  1.1610 +	sprintf(g_dasm_str, "jsr     %s", get_ea_mode_str_32(g_cpu_ir));
  1.1611 +}
  1.1612 +
  1.1613 +static void d68000_lea(void)
  1.1614 +{
  1.1615 +	sprintf(g_dasm_str, "lea     %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1616 +}
  1.1617 +
  1.1618 +static void d68000_link_16(void)
  1.1619 +{
  1.1620 +	sprintf(g_dasm_str, "link    A%d, %s", g_cpu_ir&7, get_imm_str_s16());
  1.1621 +}
  1.1622 +
  1.1623 +static void d68020_link_32(void)
  1.1624 +{
  1.1625 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.1626 +	sprintf(g_dasm_str, "link    A%d, %s; (2+)", g_cpu_ir&7, get_imm_str_s32());
  1.1627 +}
  1.1628 +
  1.1629 +static void d68000_lsr_s_8(void)
  1.1630 +{
  1.1631 +	sprintf(g_dasm_str, "lsr.b   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.1632 +}
  1.1633 +
  1.1634 +static void d68000_lsr_s_16(void)
  1.1635 +{
  1.1636 +	sprintf(g_dasm_str, "lsr.w   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.1637 +}
  1.1638 +
  1.1639 +static void d68000_lsr_s_32(void)
  1.1640 +{
  1.1641 +	sprintf(g_dasm_str, "lsr.l   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.1642 +}
  1.1643 +
  1.1644 +static void d68000_lsr_r_8(void)
  1.1645 +{
  1.1646 +	sprintf(g_dasm_str, "lsr.b   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1647 +}
  1.1648 +
  1.1649 +static void d68000_lsr_r_16(void)
  1.1650 +{
  1.1651 +	sprintf(g_dasm_str, "lsr.w   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1652 +}
  1.1653 +
  1.1654 +static void d68000_lsr_r_32(void)
  1.1655 +{
  1.1656 +	sprintf(g_dasm_str, "lsr.l   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1657 +}
  1.1658 +
  1.1659 +static void d68000_lsr_ea(void)
  1.1660 +{
  1.1661 +	sprintf(g_dasm_str, "lsr.w   %s", get_ea_mode_str_32(g_cpu_ir));
  1.1662 +}
  1.1663 +
  1.1664 +static void d68000_lsl_s_8(void)
  1.1665 +{
  1.1666 +	sprintf(g_dasm_str, "lsl.b   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.1667 +}
  1.1668 +
  1.1669 +static void d68000_lsl_s_16(void)
  1.1670 +{
  1.1671 +	sprintf(g_dasm_str, "lsl.w   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.1672 +}
  1.1673 +
  1.1674 +static void d68000_lsl_s_32(void)
  1.1675 +{
  1.1676 +	sprintf(g_dasm_str, "lsl.l   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.1677 +}
  1.1678 +
  1.1679 +static void d68000_lsl_r_8(void)
  1.1680 +{
  1.1681 +	sprintf(g_dasm_str, "lsl.b   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1682 +}
  1.1683 +
  1.1684 +static void d68000_lsl_r_16(void)
  1.1685 +{
  1.1686 +	sprintf(g_dasm_str, "lsl.w   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1687 +}
  1.1688 +
  1.1689 +static void d68000_lsl_r_32(void)
  1.1690 +{
  1.1691 +	sprintf(g_dasm_str, "lsl.l   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.1692 +}
  1.1693 +
  1.1694 +static void d68000_lsl_ea(void)
  1.1695 +{
  1.1696 +	sprintf(g_dasm_str, "lsl.w   %s", get_ea_mode_str_32(g_cpu_ir));
  1.1697 +}
  1.1698 +
  1.1699 +static void d68000_move_8(void)
  1.1700 +{
  1.1701 +	char* str = get_ea_mode_str_8(g_cpu_ir);
  1.1702 +	sprintf(g_dasm_str, "move.b  %s, %s", str, get_ea_mode_str_8(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
  1.1703 +}
  1.1704 +
  1.1705 +static void d68000_move_16(void)
  1.1706 +{
  1.1707 +	char* str = get_ea_mode_str_16(g_cpu_ir);
  1.1708 +	sprintf(g_dasm_str, "move.w  %s, %s", str, get_ea_mode_str_16(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
  1.1709 +}
  1.1710 +
  1.1711 +static void d68000_move_32(void)
  1.1712 +{
  1.1713 +	char* str = get_ea_mode_str_32(g_cpu_ir);
  1.1714 +	sprintf(g_dasm_str, "move.l  %s, %s", str, get_ea_mode_str_32(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38)));
  1.1715 +}
  1.1716 +
  1.1717 +static void d68000_movea_16(void)
  1.1718 +{
  1.1719 +	sprintf(g_dasm_str, "movea.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1720 +}
  1.1721 +
  1.1722 +static void d68000_movea_32(void)
  1.1723 +{
  1.1724 +	sprintf(g_dasm_str, "movea.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.1725 +}
  1.1726 +
  1.1727 +static void d68000_move_to_ccr(void)
  1.1728 +{
  1.1729 +	sprintf(g_dasm_str, "move    %s, CCR", get_ea_mode_str_8(g_cpu_ir));
  1.1730 +}
  1.1731 +
  1.1732 +static void d68010_move_fr_ccr(void)
  1.1733 +{
  1.1734 +	LIMIT_CPU_TYPES(M68010_PLUS);
  1.1735 +	sprintf(g_dasm_str, "move    CCR, %s; (1+)", get_ea_mode_str_8(g_cpu_ir));
  1.1736 +}
  1.1737 +
  1.1738 +static void d68000_move_fr_sr(void)
  1.1739 +{
  1.1740 +	sprintf(g_dasm_str, "move    SR, %s", get_ea_mode_str_16(g_cpu_ir));
  1.1741 +}
  1.1742 +
  1.1743 +static void d68000_move_to_sr(void)
  1.1744 +{
  1.1745 +	sprintf(g_dasm_str, "move    %s, SR", get_ea_mode_str_16(g_cpu_ir));
  1.1746 +}
  1.1747 +
  1.1748 +static void d68000_move_fr_usp(void)
  1.1749 +{
  1.1750 +	sprintf(g_dasm_str, "move    USP, A%d", g_cpu_ir&7);
  1.1751 +}
  1.1752 +
  1.1753 +static void d68000_move_to_usp(void)
  1.1754 +{
  1.1755 +	sprintf(g_dasm_str, "move    A%d, USP", g_cpu_ir&7);
  1.1756 +}
  1.1757 +
  1.1758 +static void d68010_movec(void)
  1.1759 +{
  1.1760 +	uint extension;
  1.1761 +	char* reg_name;
  1.1762 +	char* processor;
  1.1763 +	LIMIT_CPU_TYPES(M68010_PLUS);
  1.1764 +	extension = read_imm_16();
  1.1765 +
  1.1766 +	switch(extension & 0xfff)
  1.1767 +	{
  1.1768 +		case 0x000:
  1.1769 +			reg_name = "SFC";
  1.1770 +			processor = "1+";
  1.1771 +			break;
  1.1772 +		case 0x001:
  1.1773 +			reg_name = "DFC";
  1.1774 +			processor = "1+";
  1.1775 +			break;
  1.1776 +		case 0x800:
  1.1777 +			reg_name = "USP";
  1.1778 +			processor = "1+";
  1.1779 +			break;
  1.1780 +		case 0x801:
  1.1781 +			reg_name = "VBR";
  1.1782 +			processor = "1+";
  1.1783 +			break;
  1.1784 +		case 0x002:
  1.1785 +			reg_name = "CACR";
  1.1786 +			processor = "2+";
  1.1787 +			break;
  1.1788 +		case 0x802:
  1.1789 +			reg_name = "CAAR";
  1.1790 +			processor = "2,3";
  1.1791 +			break;
  1.1792 +		case 0x803:
  1.1793 +			reg_name = "MSP";
  1.1794 +			processor = "2+";
  1.1795 +			break;
  1.1796 +		case 0x804:
  1.1797 +			reg_name = "ISP";
  1.1798 +			processor = "2+";
  1.1799 +			break;
  1.1800 +		case 0x003:
  1.1801 +			reg_name = "TC";
  1.1802 +			processor = "4+";
  1.1803 +			break;
  1.1804 +		case 0x004:
  1.1805 +			reg_name = "ITT0";
  1.1806 +			processor = "4+";
  1.1807 +			break;
  1.1808 +		case 0x005:
  1.1809 +			reg_name = "ITT1";
  1.1810 +			processor = "4+";
  1.1811 +			break;
  1.1812 +		case 0x006:
  1.1813 +			reg_name = "DTT0";
  1.1814 +			processor = "4+";
  1.1815 +			break;
  1.1816 +		case 0x007:
  1.1817 +			reg_name = "DTT1";
  1.1818 +			processor = "4+";
  1.1819 +			break;
  1.1820 +		case 0x805:
  1.1821 +			reg_name = "MMUSR";
  1.1822 +			processor = "4+";
  1.1823 +			break;
  1.1824 +		case 0x806:
  1.1825 +			reg_name = "URP";
  1.1826 +			processor = "4+";
  1.1827 +			break;
  1.1828 +		case 0x807:
  1.1829 +			reg_name = "SRP";
  1.1830 +			processor = "4+";
  1.1831 +			break;
  1.1832 +		default:
  1.1833 +			reg_name = make_signed_hex_str_16(extension & 0xfff);
  1.1834 +			processor = "?";
  1.1835 +	}
  1.1836 +
  1.1837 +	if(BIT_1(g_cpu_ir))
  1.1838 +		sprintf(g_dasm_str, "movec %c%d, %s; (%s)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, reg_name, processor);
  1.1839 +	else
  1.1840 +		sprintf(g_dasm_str, "movec %s, %c%d; (%s)", reg_name, BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, processor);
  1.1841 +}
  1.1842 +
  1.1843 +static void d68000_movem_pd_16(void)
  1.1844 +{
  1.1845 +	uint data = read_imm_16();
  1.1846 +	char buffer[40];
  1.1847 +	uint first;
  1.1848 +	uint run_length;
  1.1849 +	uint i;
  1.1850 +
  1.1851 +	buffer[0] = 0;
  1.1852 +	for(i=0;i<8;i++)
  1.1853 +	{
  1.1854 +		if(data&(1<<(15-i)))
  1.1855 +		{
  1.1856 +			first = i;
  1.1857 +			run_length = 0;
  1.1858 +			for(i++;i<8;i++)
  1.1859 +				if(data&(1<<(15-i)))
  1.1860 +					run_length++;
  1.1861 +			if(buffer[0] != 0)
  1.1862 +				strcat(buffer, "/");
  1.1863 +			sprintf(buffer+strlen(buffer), "D%d", first);
  1.1864 +			if(run_length > 0)
  1.1865 +				sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
  1.1866 +		}
  1.1867 +	}
  1.1868 +	for(i=0;i<8;i++)
  1.1869 +	{
  1.1870 +		if(data&(1<<(7-i)))
  1.1871 +		{
  1.1872 +			first = i;
  1.1873 +			run_length = 0;
  1.1874 +			for(i++;i<8;i++)
  1.1875 +				if(data&(1<<(7-i)))
  1.1876 +					run_length++;
  1.1877 +			if(buffer[0] != 0)
  1.1878 +				strcat(buffer, "/");
  1.1879 +			sprintf(buffer+strlen(buffer), "A%d", first);
  1.1880 +			if(run_length > 0)
  1.1881 +				sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
  1.1882 +		}
  1.1883 +	}
  1.1884 +	sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
  1.1885 +}
  1.1886 +
  1.1887 +static void d68000_movem_pd_32(void)
  1.1888 +{
  1.1889 +	uint data = read_imm_16();
  1.1890 +	char buffer[40];
  1.1891 +	uint first;
  1.1892 +	uint run_length;
  1.1893 +	uint i;
  1.1894 +
  1.1895 +	buffer[0] = 0;
  1.1896 +	for(i=0;i<8;i++)
  1.1897 +	{
  1.1898 +		if(data&(1<<(15-i)))
  1.1899 +		{
  1.1900 +			first = i;
  1.1901 +			run_length = 0;
  1.1902 +			for(i++;i<8;i++)
  1.1903 +				if(data&(1<<(15-i)))
  1.1904 +					run_length++;
  1.1905 +			if(buffer[0] != 0)
  1.1906 +				strcat(buffer, "/");
  1.1907 +			sprintf(buffer+strlen(buffer), "D%d", first);
  1.1908 +			if(run_length > 0)
  1.1909 +				sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
  1.1910 +		}
  1.1911 +	}
  1.1912 +	for(i=0;i<8;i++)
  1.1913 +	{
  1.1914 +		if(data&(1<<(7-i)))
  1.1915 +		{
  1.1916 +			first = i;
  1.1917 +			run_length = 0;
  1.1918 +			for(i++;i<8;i++)
  1.1919 +				if(data&(1<<(7-i)))
  1.1920 +					run_length++;
  1.1921 +			if(buffer[0] != 0)
  1.1922 +				strcat(buffer, "/");
  1.1923 +			sprintf(buffer+strlen(buffer), "A%d", first);
  1.1924 +			if(run_length > 0)
  1.1925 +				sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
  1.1926 +		}
  1.1927 +	}
  1.1928 +	sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
  1.1929 +}
  1.1930 +
  1.1931 +static void d68000_movem_er_16(void)
  1.1932 +{
  1.1933 +	uint data = read_imm_16();
  1.1934 +	char buffer[40];
  1.1935 +	uint first;
  1.1936 +	uint run_length;
  1.1937 +	uint i;
  1.1938 +
  1.1939 +	buffer[0] = 0;
  1.1940 +	for(i=0;i<8;i++)
  1.1941 +	{
  1.1942 +		if(data&(1<<i))
  1.1943 +		{
  1.1944 +			first = i;
  1.1945 +			run_length = 0;
  1.1946 +			for(i++;i<8;i++)
  1.1947 +				if(data&(1<<i))
  1.1948 +					run_length++;
  1.1949 +			if(buffer[0] != 0)
  1.1950 +				strcat(buffer, "/");
  1.1951 +			sprintf(buffer+strlen(buffer), "D%d", first);
  1.1952 +			if(run_length > 0)
  1.1953 +				sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
  1.1954 +		}
  1.1955 +	}
  1.1956 +	for(i=0;i<8;i++)
  1.1957 +	{
  1.1958 +		if(data&(1<<(i+8)))
  1.1959 +		{
  1.1960 +			first = i;
  1.1961 +			run_length = 0;
  1.1962 +			for(i++;i<8;i++)
  1.1963 +				if(data&(1<<(i+8)))
  1.1964 +					run_length++;
  1.1965 +			if(buffer[0] != 0)
  1.1966 +				strcat(buffer, "/");
  1.1967 +			sprintf(buffer+strlen(buffer), "A%d", first);
  1.1968 +			if(run_length > 0)
  1.1969 +				sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
  1.1970 +		}
  1.1971 +	}
  1.1972 +	sprintf(g_dasm_str, "movem.w %s, %s", get_ea_mode_str_16(g_cpu_ir), buffer);
  1.1973 +}
  1.1974 +
  1.1975 +static void d68000_movem_er_32(void)
  1.1976 +{
  1.1977 +	uint data = read_imm_16();
  1.1978 +	char buffer[40];
  1.1979 +	uint first;
  1.1980 +	uint run_length;
  1.1981 +	uint i;
  1.1982 +
  1.1983 +	buffer[0] = 0;
  1.1984 +	for(i=0;i<8;i++)
  1.1985 +	{
  1.1986 +		if(data&(1<<i))
  1.1987 +		{
  1.1988 +			first = i;
  1.1989 +			run_length = 0;
  1.1990 +			for(i++;i<8;i++)
  1.1991 +				if(data&(1<<i))
  1.1992 +					run_length++;
  1.1993 +			if(buffer[0] != 0)
  1.1994 +				strcat(buffer, "/");
  1.1995 +			sprintf(buffer+strlen(buffer), "D%d", first);
  1.1996 +			if(run_length > 0)
  1.1997 +				sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
  1.1998 +		}
  1.1999 +	}
  1.2000 +	for(i=0;i<8;i++)
  1.2001 +	{
  1.2002 +		if(data&(1<<(i+8)))
  1.2003 +		{
  1.2004 +			first = i;
  1.2005 +			run_length = 0;
  1.2006 +			for(i++;i<8;i++)
  1.2007 +				if(data&(1<<(i+8)))
  1.2008 +					run_length++;
  1.2009 +			if(buffer[0] != 0)
  1.2010 +				strcat(buffer, "/");
  1.2011 +			sprintf(buffer+strlen(buffer), "A%d", first);
  1.2012 +			if(run_length > 0)
  1.2013 +				sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
  1.2014 +		}
  1.2015 +	}
  1.2016 +	sprintf(g_dasm_str, "movem.l %s, %s", get_ea_mode_str_32(g_cpu_ir), buffer);
  1.2017 +}
  1.2018 +
  1.2019 +static void d68000_movem_re_16(void)
  1.2020 +{
  1.2021 +	uint data = read_imm_16();
  1.2022 +	char buffer[40];
  1.2023 +	uint first;
  1.2024 +	uint run_length;
  1.2025 +	uint i;
  1.2026 +
  1.2027 +	buffer[0] = 0;
  1.2028 +	for(i=0;i<8;i++)
  1.2029 +	{
  1.2030 +		if(data&(1<<i))
  1.2031 +		{
  1.2032 +			first = i;
  1.2033 +			run_length = 0;
  1.2034 +			for(i++;i<8;i++)
  1.2035 +				if(data&(1<<i))
  1.2036 +					run_length++;
  1.2037 +			if(buffer[0] != 0)
  1.2038 +				strcat(buffer, "/");
  1.2039 +			sprintf(buffer+strlen(buffer), "D%d", first);
  1.2040 +			if(run_length > 0)
  1.2041 +				sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
  1.2042 +		}
  1.2043 +	}
  1.2044 +	for(i=0;i<8;i++)
  1.2045 +	{
  1.2046 +		if(data&(1<<(i+8)))
  1.2047 +		{
  1.2048 +			first = i;
  1.2049 +			run_length = 0;
  1.2050 +			for(i++;i<8;i++)
  1.2051 +				if(data&(1<<(i+8)))
  1.2052 +					run_length++;
  1.2053 +			if(buffer[0] != 0)
  1.2054 +				strcat(buffer, "/");
  1.2055 +			sprintf(buffer+strlen(buffer), "A%d", first);
  1.2056 +			if(run_length > 0)
  1.2057 +				sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
  1.2058 +		}
  1.2059 +	}
  1.2060 +	sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir));
  1.2061 +}
  1.2062 +
  1.2063 +static void d68000_movem_re_32(void)
  1.2064 +{
  1.2065 +	uint data = read_imm_16();
  1.2066 +	char buffer[40];
  1.2067 +	uint first;
  1.2068 +	uint run_length;
  1.2069 +	uint i;
  1.2070 +
  1.2071 +	buffer[0] = 0;
  1.2072 +	for(i=0;i<8;i++)
  1.2073 +	{
  1.2074 +		if(data&(1<<i))
  1.2075 +		{
  1.2076 +			first = i;
  1.2077 +			run_length = 0;
  1.2078 +			for(i++;i<8;i++)
  1.2079 +				if(data&(1<<i))
  1.2080 +					run_length++;
  1.2081 +			if(buffer[0] != 0)
  1.2082 +				strcat(buffer, "/");
  1.2083 +			sprintf(buffer+strlen(buffer), "D%d", first);
  1.2084 +			if(run_length > 0)
  1.2085 +				sprintf(buffer+strlen(buffer), "-D%d", first + run_length);
  1.2086 +		}
  1.2087 +	}
  1.2088 +	for(i=0;i<8;i++)
  1.2089 +	{
  1.2090 +		if(data&(1<<(i+8)))
  1.2091 +		{
  1.2092 +			first = i;
  1.2093 +			run_length = 0;
  1.2094 +			for(i++;i<8;i++)
  1.2095 +				if(data&(1<<(i+8)))
  1.2096 +					run_length++;
  1.2097 +			if(buffer[0] != 0)
  1.2098 +				strcat(buffer, "/");
  1.2099 +			sprintf(buffer+strlen(buffer), "A%d", first);
  1.2100 +			if(run_length > 0)
  1.2101 +				sprintf(buffer+strlen(buffer), "-A%d", first + run_length);
  1.2102 +		}
  1.2103 +	}
  1.2104 +	sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir));
  1.2105 +}
  1.2106 +
  1.2107 +static void d68000_movep_re_16(void)
  1.2108 +{
  1.2109 +	sprintf(g_dasm_str, "movep.w D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
  1.2110 +}
  1.2111 +
  1.2112 +static void d68000_movep_re_32(void)
  1.2113 +{
  1.2114 +	sprintf(g_dasm_str, "movep.l D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7);
  1.2115 +}
  1.2116 +
  1.2117 +static void d68000_movep_er_16(void)
  1.2118 +{
  1.2119 +	sprintf(g_dasm_str, "movep.w ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2120 +}
  1.2121 +
  1.2122 +static void d68000_movep_er_32(void)
  1.2123 +{
  1.2124 +	sprintf(g_dasm_str, "movep.l ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2125 +}
  1.2126 +
  1.2127 +static void d68010_moves_8(void)
  1.2128 +{
  1.2129 +	uint extension;
  1.2130 +	LIMIT_CPU_TYPES(M68010_PLUS);
  1.2131 +	extension = read_imm_16();
  1.2132 +	if(BIT_B(extension))
  1.2133 +		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));
  1.2134 +	else
  1.2135 +		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);
  1.2136 +}
  1.2137 +
  1.2138 +static void d68010_moves_16(void)
  1.2139 +{
  1.2140 +	uint extension;
  1.2141 +	LIMIT_CPU_TYPES(M68010_PLUS);
  1.2142 +	extension = read_imm_16();
  1.2143 +	if(BIT_B(extension))
  1.2144 +		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));
  1.2145 +	else
  1.2146 +		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);
  1.2147 +}
  1.2148 +
  1.2149 +static void d68010_moves_32(void)
  1.2150 +{
  1.2151 +	uint extension;
  1.2152 +	LIMIT_CPU_TYPES(M68010_PLUS);
  1.2153 +	extension = read_imm_16();
  1.2154 +	if(BIT_B(extension))
  1.2155 +		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));
  1.2156 +	else
  1.2157 +		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);
  1.2158 +}
  1.2159 +
  1.2160 +static void d68000_moveq(void)
  1.2161 +{
  1.2162 +	sprintf(g_dasm_str, "moveq   #%s, D%d", make_signed_hex_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2163 +}
  1.2164 +
  1.2165 +static void d68040_move16_pi_pi(void)
  1.2166 +{
  1.2167 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.2168 +	sprintf(g_dasm_str, "move16  (A%d)+, (A%d)+; (4)", g_cpu_ir&7, (read_imm_16()>>12)&7);
  1.2169 +}
  1.2170 +
  1.2171 +static void d68040_move16_pi_al(void)
  1.2172 +{
  1.2173 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.2174 +	sprintf(g_dasm_str, "move16  (A%d)+, %s; (4)", g_cpu_ir&7, get_imm_str_u32());
  1.2175 +}
  1.2176 +
  1.2177 +static void d68040_move16_al_pi(void)
  1.2178 +{
  1.2179 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.2180 +	sprintf(g_dasm_str, "move16  %s, (A%d)+; (4)", get_imm_str_u32(), g_cpu_ir&7);
  1.2181 +}
  1.2182 +
  1.2183 +static void d68040_move16_ai_al(void)
  1.2184 +{
  1.2185 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.2186 +	sprintf(g_dasm_str, "move16  (A%d), %s; (4)", g_cpu_ir&7, get_imm_str_u32());
  1.2187 +}
  1.2188 +
  1.2189 +static void d68040_move16_al_ai(void)
  1.2190 +{
  1.2191 +	LIMIT_CPU_TYPES(M68040_PLUS);
  1.2192 +	sprintf(g_dasm_str, "move16  %s, (A%d); (4)", get_imm_str_u32(), g_cpu_ir&7);
  1.2193 +}
  1.2194 +
  1.2195 +static void d68000_muls(void)
  1.2196 +{
  1.2197 +	sprintf(g_dasm_str, "muls.w  %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2198 +}
  1.2199 +
  1.2200 +static void d68000_mulu(void)
  1.2201 +{
  1.2202 +	sprintf(g_dasm_str, "mulu.w  %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2203 +}
  1.2204 +
  1.2205 +static void d68020_mull(void)
  1.2206 +{
  1.2207 +	uint extension;
  1.2208 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2209 +	extension = read_imm_16();
  1.2210 +
  1.2211 +	if(BIT_A(extension))
  1.2212 +		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);
  1.2213 +	else
  1.2214 +		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);
  1.2215 +}
  1.2216 +
  1.2217 +static void d68000_nbcd(void)
  1.2218 +{
  1.2219 +	sprintf(g_dasm_str, "nbcd    %s", get_ea_mode_str_8(g_cpu_ir));
  1.2220 +}
  1.2221 +
  1.2222 +static void d68000_neg_8(void)
  1.2223 +{
  1.2224 +	sprintf(g_dasm_str, "neg.b   %s", get_ea_mode_str_8(g_cpu_ir));
  1.2225 +}
  1.2226 +
  1.2227 +static void d68000_neg_16(void)
  1.2228 +{
  1.2229 +	sprintf(g_dasm_str, "neg.w   %s", get_ea_mode_str_16(g_cpu_ir));
  1.2230 +}
  1.2231 +
  1.2232 +static void d68000_neg_32(void)
  1.2233 +{
  1.2234 +	sprintf(g_dasm_str, "neg.l   %s", get_ea_mode_str_32(g_cpu_ir));
  1.2235 +}
  1.2236 +
  1.2237 +static void d68000_negx_8(void)
  1.2238 +{
  1.2239 +	sprintf(g_dasm_str, "negx.b  %s", get_ea_mode_str_8(g_cpu_ir));
  1.2240 +}
  1.2241 +
  1.2242 +static void d68000_negx_16(void)
  1.2243 +{
  1.2244 +	sprintf(g_dasm_str, "negx.w  %s", get_ea_mode_str_16(g_cpu_ir));
  1.2245 +}
  1.2246 +
  1.2247 +static void d68000_negx_32(void)
  1.2248 +{
  1.2249 +	sprintf(g_dasm_str, "negx.l  %s", get_ea_mode_str_32(g_cpu_ir));
  1.2250 +}
  1.2251 +
  1.2252 +static void d68000_nop(void)
  1.2253 +{
  1.2254 +	sprintf(g_dasm_str, "nop");
  1.2255 +}
  1.2256 +
  1.2257 +static void d68000_not_8(void)
  1.2258 +{
  1.2259 +	sprintf(g_dasm_str, "not.b   %s", get_ea_mode_str_8(g_cpu_ir));
  1.2260 +}
  1.2261 +
  1.2262 +static void d68000_not_16(void)
  1.2263 +{
  1.2264 +	sprintf(g_dasm_str, "not.w   %s", get_ea_mode_str_16(g_cpu_ir));
  1.2265 +}
  1.2266 +
  1.2267 +static void d68000_not_32(void)
  1.2268 +{
  1.2269 +	sprintf(g_dasm_str, "not.l   %s", get_ea_mode_str_32(g_cpu_ir));
  1.2270 +}
  1.2271 +
  1.2272 +static void d68000_or_er_8(void)
  1.2273 +{
  1.2274 +	sprintf(g_dasm_str, "or.b    %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2275 +}
  1.2276 +
  1.2277 +static void d68000_or_er_16(void)
  1.2278 +{
  1.2279 +	sprintf(g_dasm_str, "or.w    %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2280 +}
  1.2281 +
  1.2282 +static void d68000_or_er_32(void)
  1.2283 +{
  1.2284 +	sprintf(g_dasm_str, "or.l    %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2285 +}
  1.2286 +
  1.2287 +static void d68000_or_re_8(void)
  1.2288 +{
  1.2289 +	sprintf(g_dasm_str, "or.b    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.2290 +}
  1.2291 +
  1.2292 +static void d68000_or_re_16(void)
  1.2293 +{
  1.2294 +	sprintf(g_dasm_str, "or.w    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
  1.2295 +}
  1.2296 +
  1.2297 +static void d68000_or_re_32(void)
  1.2298 +{
  1.2299 +	sprintf(g_dasm_str, "or.l    D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
  1.2300 +}
  1.2301 +
  1.2302 +static void d68000_ori_8(void)
  1.2303 +{
  1.2304 +	char* str = get_imm_str_u8();
  1.2305 +	sprintf(g_dasm_str, "ori.b   %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
  1.2306 +}
  1.2307 +
  1.2308 +static void d68000_ori_16(void)
  1.2309 +{
  1.2310 +	char* str = get_imm_str_u16();
  1.2311 +	sprintf(g_dasm_str, "ori.w   %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
  1.2312 +}
  1.2313 +
  1.2314 +static void d68000_ori_32(void)
  1.2315 +{
  1.2316 +	char* str = get_imm_str_u32();
  1.2317 +	sprintf(g_dasm_str, "ori.l   %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
  1.2318 +}
  1.2319 +
  1.2320 +static void d68000_ori_to_ccr(void)
  1.2321 +{
  1.2322 +	sprintf(g_dasm_str, "ori     %s, CCR", get_imm_str_u8());
  1.2323 +}
  1.2324 +
  1.2325 +static void d68000_ori_to_sr(void)
  1.2326 +{
  1.2327 +	sprintf(g_dasm_str, "ori     %s, SR", get_imm_str_u16());
  1.2328 +}
  1.2329 +
  1.2330 +static void d68020_pack_rr(void)
  1.2331 +{
  1.2332 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2333 +	sprintf(g_dasm_str, "pack    D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
  1.2334 +}
  1.2335 +
  1.2336 +static void d68020_pack_mm(void)
  1.2337 +{
  1.2338 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2339 +	sprintf(g_dasm_str, "pack    -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
  1.2340 +}
  1.2341 +
  1.2342 +static void d68000_pea(void)
  1.2343 +{
  1.2344 +	sprintf(g_dasm_str, "pea     %s", get_ea_mode_str_32(g_cpu_ir));
  1.2345 +}
  1.2346 +
  1.2347 +static void d68000_reset(void)
  1.2348 +{
  1.2349 +	sprintf(g_dasm_str, "reset");
  1.2350 +}
  1.2351 +
  1.2352 +static void d68000_ror_s_8(void)
  1.2353 +{
  1.2354 +	sprintf(g_dasm_str, "ror.b   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2355 +}
  1.2356 +
  1.2357 +static void d68000_ror_s_16(void)
  1.2358 +{
  1.2359 +	sprintf(g_dasm_str, "ror.w   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7],g_cpu_ir&7);
  1.2360 +}
  1.2361 +
  1.2362 +static void d68000_ror_s_32(void)
  1.2363 +{
  1.2364 +	sprintf(g_dasm_str, "ror.l   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2365 +}
  1.2366 +
  1.2367 +static void d68000_ror_r_8(void)
  1.2368 +{
  1.2369 +	sprintf(g_dasm_str, "ror.b   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2370 +}
  1.2371 +
  1.2372 +static void d68000_ror_r_16(void)
  1.2373 +{
  1.2374 +	sprintf(g_dasm_str, "ror.w   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2375 +}
  1.2376 +
  1.2377 +static void d68000_ror_r_32(void)
  1.2378 +{
  1.2379 +	sprintf(g_dasm_str, "ror.l   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2380 +}
  1.2381 +
  1.2382 +static void d68000_ror_ea(void)
  1.2383 +{
  1.2384 +	sprintf(g_dasm_str, "ror.w   %s", get_ea_mode_str_32(g_cpu_ir));
  1.2385 +}
  1.2386 +
  1.2387 +static void d68000_rol_s_8(void)
  1.2388 +{
  1.2389 +	sprintf(g_dasm_str, "rol.b   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2390 +}
  1.2391 +
  1.2392 +static void d68000_rol_s_16(void)
  1.2393 +{
  1.2394 +	sprintf(g_dasm_str, "rol.w   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2395 +}
  1.2396 +
  1.2397 +static void d68000_rol_s_32(void)
  1.2398 +{
  1.2399 +	sprintf(g_dasm_str, "rol.l   #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2400 +}
  1.2401 +
  1.2402 +static void d68000_rol_r_8(void)
  1.2403 +{
  1.2404 +	sprintf(g_dasm_str, "rol.b   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2405 +}
  1.2406 +
  1.2407 +static void d68000_rol_r_16(void)
  1.2408 +{
  1.2409 +	sprintf(g_dasm_str, "rol.w   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2410 +}
  1.2411 +
  1.2412 +static void d68000_rol_r_32(void)
  1.2413 +{
  1.2414 +	sprintf(g_dasm_str, "rol.l   D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2415 +}
  1.2416 +
  1.2417 +static void d68000_rol_ea(void)
  1.2418 +{
  1.2419 +	sprintf(g_dasm_str, "rol.w   %s", get_ea_mode_str_32(g_cpu_ir));
  1.2420 +}
  1.2421 +
  1.2422 +static void d68000_roxr_s_8(void)
  1.2423 +{
  1.2424 +	sprintf(g_dasm_str, "roxr.b  #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2425 +}
  1.2426 +
  1.2427 +static void d68000_roxr_s_16(void)
  1.2428 +{
  1.2429 +	sprintf(g_dasm_str, "roxr.w  #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2430 +}
  1.2431 +
  1.2432 +
  1.2433 +static void d68000_roxr_s_32(void)
  1.2434 +{
  1.2435 +	sprintf(g_dasm_str, "roxr.l  #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2436 +}
  1.2437 +
  1.2438 +static void d68000_roxr_r_8(void)
  1.2439 +{
  1.2440 +	sprintf(g_dasm_str, "roxr.b  D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2441 +}
  1.2442 +
  1.2443 +static void d68000_roxr_r_16(void)
  1.2444 +{
  1.2445 +	sprintf(g_dasm_str, "roxr.w  D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2446 +}
  1.2447 +
  1.2448 +static void d68000_roxr_r_32(void)
  1.2449 +{
  1.2450 +	sprintf(g_dasm_str, "roxr.l  D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2451 +}
  1.2452 +
  1.2453 +static void d68000_roxr_ea(void)
  1.2454 +{
  1.2455 +	sprintf(g_dasm_str, "roxr.w  %s", get_ea_mode_str_32(g_cpu_ir));
  1.2456 +}
  1.2457 +
  1.2458 +static void d68000_roxl_s_8(void)
  1.2459 +{
  1.2460 +	sprintf(g_dasm_str, "roxl.b  #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2461 +}
  1.2462 +
  1.2463 +static void d68000_roxl_s_16(void)
  1.2464 +{
  1.2465 +	sprintf(g_dasm_str, "roxl.w  #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2466 +}
  1.2467 +
  1.2468 +static void d68000_roxl_s_32(void)
  1.2469 +{
  1.2470 +	sprintf(g_dasm_str, "roxl.l  #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7);
  1.2471 +}
  1.2472 +
  1.2473 +static void d68000_roxl_r_8(void)
  1.2474 +{
  1.2475 +	sprintf(g_dasm_str, "roxl.b  D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2476 +}
  1.2477 +
  1.2478 +static void d68000_roxl_r_16(void)
  1.2479 +{
  1.2480 +	sprintf(g_dasm_str, "roxl.w  D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2481 +}
  1.2482 +
  1.2483 +static void d68000_roxl_r_32(void)
  1.2484 +{
  1.2485 +	sprintf(g_dasm_str, "roxl.l  D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7);
  1.2486 +}
  1.2487 +
  1.2488 +static void d68000_roxl_ea(void)
  1.2489 +{
  1.2490 +	sprintf(g_dasm_str, "roxl.w  %s", get_ea_mode_str_32(g_cpu_ir));
  1.2491 +}
  1.2492 +
  1.2493 +static void d68010_rtd(void)
  1.2494 +{
  1.2495 +	LIMIT_CPU_TYPES(M68010_PLUS);
  1.2496 +	sprintf(g_dasm_str, "rtd     %s; (1+)", get_imm_str_s16());
  1.2497 +}
  1.2498 +
  1.2499 +static void d68000_rte(void)
  1.2500 +{
  1.2501 +	sprintf(g_dasm_str, "rte");
  1.2502 +}
  1.2503 +
  1.2504 +static void d68020_rtm(void)
  1.2505 +{
  1.2506 +	LIMIT_CPU_TYPES(M68020_ONLY);
  1.2507 +	sprintf(g_dasm_str, "rtm     %c%d; (2+)", BIT_3(g_cpu_ir) ? 'A' : 'D', g_cpu_ir&7);
  1.2508 +}
  1.2509 +
  1.2510 +static void d68000_rtr(void)
  1.2511 +{
  1.2512 +	sprintf(g_dasm_str, "rtr");
  1.2513 +}
  1.2514 +
  1.2515 +static void d68000_rts(void)
  1.2516 +{
  1.2517 +	sprintf(g_dasm_str, "rts");
  1.2518 +}
  1.2519 +
  1.2520 +static void d68000_sbcd_rr(void)
  1.2521 +{
  1.2522 +	sprintf(g_dasm_str, "sbcd    D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2523 +}
  1.2524 +
  1.2525 +static void d68000_sbcd_mm(void)
  1.2526 +{
  1.2527 +	sprintf(g_dasm_str, "sbcd    -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2528 +}
  1.2529 +
  1.2530 +static void d68000_scc(void)
  1.2531 +{
  1.2532 +	sprintf(g_dasm_str, "s%-2s     %s", g_cc[(g_cpu_ir>>8)&0xf], get_ea_mode_str_8(g_cpu_ir));
  1.2533 +}
  1.2534 +
  1.2535 +static void d68000_stop(void)
  1.2536 +{
  1.2537 +	sprintf(g_dasm_str, "stop    %s", get_imm_str_s16());
  1.2538 +}
  1.2539 +
  1.2540 +static void d68000_sub_er_8(void)
  1.2541 +{
  1.2542 +	sprintf(g_dasm_str, "sub.b   %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2543 +}
  1.2544 +
  1.2545 +static void d68000_sub_er_16(void)
  1.2546 +{
  1.2547 +	sprintf(g_dasm_str, "sub.w   %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2548 +}
  1.2549 +
  1.2550 +static void d68000_sub_er_32(void)
  1.2551 +{
  1.2552 +	sprintf(g_dasm_str, "sub.l   %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2553 +}
  1.2554 +
  1.2555 +static void d68000_sub_re_8(void)
  1.2556 +{
  1.2557 +	sprintf(g_dasm_str, "sub.b   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir));
  1.2558 +}
  1.2559 +
  1.2560 +static void d68000_sub_re_16(void)
  1.2561 +{
  1.2562 +	sprintf(g_dasm_str, "sub.w   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir));
  1.2563 +}
  1.2564 +
  1.2565 +static void d68000_sub_re_32(void)
  1.2566 +{
  1.2567 +	sprintf(g_dasm_str, "sub.l   D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir));
  1.2568 +}
  1.2569 +
  1.2570 +static void d68000_suba_16(void)
  1.2571 +{
  1.2572 +	sprintf(g_dasm_str, "suba.w  %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2573 +}
  1.2574 +
  1.2575 +static void d68000_suba_32(void)
  1.2576 +{
  1.2577 +	sprintf(g_dasm_str, "suba.l  %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7);
  1.2578 +}
  1.2579 +
  1.2580 +static void d68000_subi_8(void)
  1.2581 +{
  1.2582 +	char* str = get_imm_str_s8();
  1.2583 +	sprintf(g_dasm_str, "subi.b  %s, %s", str, get_ea_mode_str_8(g_cpu_ir));
  1.2584 +}
  1.2585 +
  1.2586 +static void d68000_subi_16(void)
  1.2587 +{
  1.2588 +	char* str = get_imm_str_s16();
  1.2589 +	sprintf(g_dasm_str, "subi.w  %s, %s", str, get_ea_mode_str_16(g_cpu_ir));
  1.2590 +}
  1.2591 +
  1.2592 +static void d68000_subi_32(void)
  1.2593 +{
  1.2594 +	char* str = get_imm_str_s32();
  1.2595 +	sprintf(g_dasm_str, "subi.l  %s, %s", str, get_ea_mode_str_32(g_cpu_ir));
  1.2596 +}
  1.2597 +
  1.2598 +static void d68000_subq_8(void)
  1.2599 +{
  1.2600 +	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));
  1.2601 +}
  1.2602 +
  1.2603 +static void d68000_subq_16(void)
  1.2604 +{
  1.2605 +	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));
  1.2606 +}
  1.2607 +
  1.2608 +static void d68000_subq_32(void)
  1.2609 +{
  1.2610 +	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));
  1.2611 +}
  1.2612 +
  1.2613 +static void d68000_subx_rr_8(void)
  1.2614 +{
  1.2615 +	sprintf(g_dasm_str, "subx.b  D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2616 +}
  1.2617 +
  1.2618 +static void d68000_subx_rr_16(void)
  1.2619 +{
  1.2620 +	sprintf(g_dasm_str, "subx.w  D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2621 +}
  1.2622 +
  1.2623 +static void d68000_subx_rr_32(void)
  1.2624 +{
  1.2625 +	sprintf(g_dasm_str, "subx.l  D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2626 +}
  1.2627 +
  1.2628 +static void d68000_subx_mm_8(void)
  1.2629 +{
  1.2630 +	sprintf(g_dasm_str, "subx.b  -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2631 +}
  1.2632 +
  1.2633 +static void d68000_subx_mm_16(void)
  1.2634 +{
  1.2635 +	sprintf(g_dasm_str, "subx.w  -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2636 +}
  1.2637 +
  1.2638 +static void d68000_subx_mm_32(void)
  1.2639 +{
  1.2640 +	sprintf(g_dasm_str, "subx.l  -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7);
  1.2641 +}
  1.2642 +
  1.2643 +static void d68000_swap(void)
  1.2644 +{
  1.2645 +	sprintf(g_dasm_str, "swap    D%d", g_cpu_ir&7);
  1.2646 +}
  1.2647 +
  1.2648 +static void d68000_tas(void)
  1.2649 +{
  1.2650 +	sprintf(g_dasm_str, "tas     %s", get_ea_mode_str_8(g_cpu_ir));
  1.2651 +}
  1.2652 +
  1.2653 +static void d68000_trap(void)
  1.2654 +{
  1.2655 +	sprintf(g_dasm_str, "trap    #$%x", g_cpu_ir&0xf);
  1.2656 +}
  1.2657 +
  1.2658 +static void d68020_trapcc_0(void)
  1.2659 +{
  1.2660 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2661 +	sprintf(g_dasm_str, "trap%-2s; (2+)", g_cc[(g_cpu_ir>>8)&0xf]);
  1.2662 +}
  1.2663 +
  1.2664 +static void d68020_trapcc_16(void)
  1.2665 +{
  1.2666 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2667 +	sprintf(g_dasm_str, "trap%-2s  %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u16());
  1.2668 +}
  1.2669 +
  1.2670 +static void d68020_trapcc_32(void)
  1.2671 +{
  1.2672 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2673 +	sprintf(g_dasm_str, "trap%-2s  %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u32());
  1.2674 +}
  1.2675 +
  1.2676 +static void d68000_trapv(void)
  1.2677 +{
  1.2678 +	sprintf(g_dasm_str, "trapv");
  1.2679 +}
  1.2680 +
  1.2681 +static void d68000_tst_8(void)
  1.2682 +{
  1.2683 +	sprintf(g_dasm_str, "tst.b   %s", get_ea_mode_str_8(g_cpu_ir));
  1.2684 +}
  1.2685 +
  1.2686 +static void d68020_tst_pcdi_8(void)
  1.2687 +{
  1.2688 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2689 +	sprintf(g_dasm_str, "tst.b   %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
  1.2690 +}
  1.2691 +
  1.2692 +static void d68020_tst_pcix_8(void)
  1.2693 +{
  1.2694 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2695 +	sprintf(g_dasm_str, "tst.b   %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
  1.2696 +}
  1.2697 +
  1.2698 +static void d68020_tst_i_8(void)
  1.2699 +{
  1.2700 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2701 +	sprintf(g_dasm_str, "tst.b   %s; (2+)", get_ea_mode_str_8(g_cpu_ir));
  1.2702 +}
  1.2703 +
  1.2704 +static void d68000_tst_16(void)
  1.2705 +{
  1.2706 +	sprintf(g_dasm_str, "tst.w   %s", get_ea_mode_str_16(g_cpu_ir));
  1.2707 +}
  1.2708 +
  1.2709 +static void d68020_tst_a_16(void)
  1.2710 +{
  1.2711 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2712 +	sprintf(g_dasm_str, "tst.w   %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
  1.2713 +}
  1.2714 +
  1.2715 +static void d68020_tst_pcdi_16(void)
  1.2716 +{
  1.2717 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2718 +	sprintf(g_dasm_str, "tst.w   %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
  1.2719 +}
  1.2720 +
  1.2721 +static void d68020_tst_pcix_16(void)
  1.2722 +{
  1.2723 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2724 +	sprintf(g_dasm_str, "tst.w   %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
  1.2725 +}
  1.2726 +
  1.2727 +static void d68020_tst_i_16(void)
  1.2728 +{
  1.2729 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2730 +	sprintf(g_dasm_str, "tst.w   %s; (2+)", get_ea_mode_str_16(g_cpu_ir));
  1.2731 +}
  1.2732 +
  1.2733 +static void d68000_tst_32(void)
  1.2734 +{
  1.2735 +	sprintf(g_dasm_str, "tst.l   %s", get_ea_mode_str_32(g_cpu_ir));
  1.2736 +}
  1.2737 +
  1.2738 +static void d68020_tst_a_32(void)
  1.2739 +{
  1.2740 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2741 +	sprintf(g_dasm_str, "tst.l   %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
  1.2742 +}
  1.2743 +
  1.2744 +static void d68020_tst_pcdi_32(void)
  1.2745 +{
  1.2746 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2747 +	sprintf(g_dasm_str, "tst.l   %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
  1.2748 +}
  1.2749 +
  1.2750 +static void d68020_tst_pcix_32(void)
  1.2751 +{
  1.2752 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2753 +	sprintf(g_dasm_str, "tst.l   %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
  1.2754 +}
  1.2755 +
  1.2756 +static void d68020_tst_i_32(void)
  1.2757 +{
  1.2758 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2759 +	sprintf(g_dasm_str, "tst.l   %s; (2+)", get_ea_mode_str_32(g_cpu_ir));
  1.2760 +}
  1.2761 +
  1.2762 +static void d68000_unlk(void)
  1.2763 +{
  1.2764 +	sprintf(g_dasm_str, "unlk    A%d", g_cpu_ir&7);
  1.2765 +}
  1.2766 +
  1.2767 +static void d68020_unpk_rr(void)
  1.2768 +{
  1.2769 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2770 +	sprintf(g_dasm_str, "unpk    D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
  1.2771 +}
  1.2772 +
  1.2773 +static void d68020_unpk_mm(void)
  1.2774 +{
  1.2775 +	LIMIT_CPU_TYPES(M68020_PLUS);
  1.2776 +	sprintf(g_dasm_str, "unpk    -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16());
  1.2777 +}
  1.2778 +
  1.2779 +
  1.2780 +
  1.2781 +/* ======================================================================== */
  1.2782 +/* ======================= INSTRUCTION TABLE BUILDER ====================== */
  1.2783 +/* ======================================================================== */
  1.2784 +
  1.2785 +/* EA Masks:
  1.2786 +800 = data register direct
  1.2787 +400 = address register direct
  1.2788 +200 = address register indirect
  1.2789 +100 = ARI postincrement
  1.2790 + 80 = ARI pre-decrement
  1.2791 + 40 = ARI displacement
  1.2792 + 20 = ARI index
  1.2793 + 10 = absolute short
  1.2794 +  8 = absolute long
  1.2795 +  4 = immediate / sr
  1.2796 +  2 = pc displacement
  1.2797 +  1 = pc idx
  1.2798 +*/
  1.2799 +
  1.2800 +static opcode_struct g_opcode_info[] =
  1.2801 +{
  1.2802 +/*  opcode handler    mask    match   ea mask */
  1.2803 +	{d68000_1010         , 0xf000, 0xa000, 0x000},
  1.2804 +	{d68000_1111         , 0xf000, 0xf000, 0x000},
  1.2805 +	{d68000_abcd_rr      , 0xf1f8, 0xc100, 0x000},
  1.2806 +	{d68000_abcd_mm      , 0xf1f8, 0xc108, 0x000},
  1.2807 +	{d68000_add_er_8     , 0xf1c0, 0xd000, 0xbff},
  1.2808 +	{d68000_add_er_16    , 0xf1c0, 0xd040, 0xfff},
  1.2809 +	{d68000_add_er_32    , 0xf1c0, 0xd080, 0xfff},
  1.2810 +	{d68000_add_re_8     , 0xf1c0, 0xd100, 0x3f8},
  1.2811 +	{d68000_add_re_16    , 0xf1c0, 0xd140, 0x3f8},
  1.2812 +	{d68000_add_re_32    , 0xf1c0, 0xd180, 0x3f8},
  1.2813 +	{d68000_adda_16      , 0xf1c0, 0xd0c0, 0xfff},
  1.2814 +	{d68000_adda_32      , 0xf1c0, 0xd1c0, 0xfff},
  1.2815 +	{d68000_addi_8       , 0xffc0, 0x0600, 0xbf8},
  1.2816 +	{d68000_addi_16      , 0xffc0, 0x0640, 0xbf8},
  1.2817 +	{d68000_addi_32      , 0xffc0, 0x0680, 0xbf8},
  1.2818 +	{d68000_addq_8       , 0xf1c0, 0x5000, 0xbf8},
  1.2819 +	{d68000_addq_16      , 0xf1c0, 0x5040, 0xff8},
  1.2820 +	{d68000_addq_32      , 0xf1c0, 0x5080, 0xff8},
  1.2821 +	{d68000_addx_rr_8    , 0xf1f8, 0xd100, 0x000},
  1.2822 +	{d68000_addx_rr_16   , 0xf1f8, 0xd140, 0x000},
  1.2823 +	{d68000_addx_rr_32   , 0xf1f8, 0xd180, 0x000},
  1.2824 +	{d68000_addx_mm_8    , 0xf1f8, 0xd108, 0x000},
  1.2825 +	{d68000_addx_mm_16   , 0xf1f8, 0xd148, 0x000},
  1.2826 +	{d68000_addx_mm_32   , 0xf1f8, 0xd188, 0x000},
  1.2827 +	{d68000_and_er_8     , 0xf1c0, 0xc000, 0xbff},
  1.2828 +	{d68000_and_er_16    , 0xf1c0, 0xc040, 0xbff},
  1.2829 +	{d68000_and_er_32    , 0xf1c0, 0xc080, 0xbff},
  1.2830 +	{d68000_and_re_8     , 0xf1c0, 0xc100, 0x3f8},
  1.2831 +	{d68000_and_re_16    , 0xf1c0, 0xc140, 0x3f8},
  1.2832 +	{d68000_and_re_32    , 0xf1c0, 0xc180, 0x3f8},
  1.2833 +	{d68000_andi_to_ccr  , 0xffff, 0x023c, 0x000},
  1.2834 +	{d68000_andi_to_sr   , 0xffff, 0x027c, 0x000},
  1.2835 +	{d68000_andi_8       , 0xffc0, 0x0200, 0xbf8},
  1.2836 +	{d68000_andi_16      , 0xffc0, 0x0240, 0xbf8},
  1.2837 +	{d68000_andi_32      , 0xffc0, 0x0280, 0xbf8},
  1.2838 +	{d68000_asr_s_8      , 0xf1f8, 0xe000, 0x000},
  1.2839 +	{d68000_asr_s_16     , 0xf1f8, 0xe040, 0x000},
  1.2840 +	{d68000_asr_s_32     , 0xf1f8, 0xe080, 0x000},
  1.2841 +	{d68000_asr_r_8      , 0xf1f8, 0xe020, 0x000},
  1.2842 +	{d68000_asr_r_16     , 0xf1f8, 0xe060, 0x000},
  1.2843 +	{d68000_asr_r_32     , 0xf1f8, 0xe0a0, 0x000},
  1.2844 +	{d68000_asr_ea       , 0xffc0, 0xe0c0, 0x3f8},
  1.2845 +	{d68000_asl_s_8      , 0xf1f8, 0xe100, 0x000},
  1.2846 +	{d68000_asl_s_16     , 0xf1f8, 0xe140, 0x000},
  1.2847 +	{d68000_asl_s_32     , 0xf1f8, 0xe180, 0x000},
  1.2848 +	{d68000_asl_r_8      , 0xf1f8, 0xe120, 0x000},
  1.2849 +	{d68000_asl_r_16     , 0xf1f8, 0xe160, 0x000},
  1.2850 +	{d68000_asl_r_32     , 0xf1f8, 0xe1a0, 0x000},
  1.2851 +	{d68000_asl_ea       , 0xffc0, 0xe1c0, 0x3f8},
  1.2852 +	{d68000_bcc_8        , 0xf000, 0x6000, 0x000},
  1.2853 +	{d68000_bcc_16       , 0xf0ff, 0x6000, 0x000},
  1.2854 +	{d68020_bcc_32       , 0xf0ff, 0x60ff, 0x000},
  1.2855 +	{d68000_bchg_r       , 0xf1c0, 0x0140, 0xbf8},
  1.2856 +	{d68000_bchg_s       , 0xffc0, 0x0840, 0xbf8},
  1.2857 +	{d68000_bclr_r       , 0xf1c0, 0x0180, 0xbf8},
  1.2858 +	{d68000_bclr_s       , 0xffc0, 0x0880, 0xbf8},
  1.2859 +	{d68020_bfchg        , 0xffc0, 0xeac0, 0xa78},
  1.2860 +	{d68020_bfclr        , 0xffc0, 0xecc0, 0xa78},
  1.2861 +	{d68020_bfexts       , 0xffc0, 0xebc0, 0xa7b},
  1.2862 +	{d68020_bfextu       , 0xffc0, 0xe9c0, 0xa7b},
  1.2863 +	{d68020_bfffo        , 0xffc0, 0xedc0, 0xa7b},
  1.2864 +	{d68020_bfins        , 0xffc0, 0xefc0, 0xa78},
  1.2865 +	{d68020_bfset        , 0xffc0, 0xeec0, 0xa78},
  1.2866 +	{d68020_bftst        , 0xffc0, 0xe8c0, 0xa7b},
  1.2867 +	{d68010_bkpt         , 0xfff8, 0x4848, 0x000},
  1.2868 +	{d68000_bra_8        , 0xff00, 0x6000, 0x000},
  1.2869 +	{d68000_bra_16       , 0xffff, 0x6000, 0x000},
  1.2870 +	{d68020_bra_32       , 0xffff, 0x60ff, 0x000},
  1.2871 +	{d68000_bset_r       , 0xf1c0, 0x01c0, 0xbf8},
  1.2872 +	{d68000_bset_s       , 0xffc0, 0x08c0, 0xbf8},
  1.2873 +	{d68000_bsr_8        , 0xff00, 0x6100, 0x000},
  1.2874 +	{d68000_bsr_16       , 0xffff, 0x6100, 0x000},
  1.2875 +	{d68020_bsr_32       , 0xffff, 0x61ff, 0x000},
  1.2876 +	{d68000_btst_r       , 0xf1c0, 0x0100, 0xbff},
  1.2877 +	{d68000_btst_s       , 0xffc0, 0x0800, 0xbfb},
  1.2878 +	{d68020_callm        , 0xffc0, 0x06c0, 0x27b},
  1.2879 +	{d68020_cas_8        , 0xffc0, 0x0ac0, 0x3f8},
  1.2880 +	{d68020_cas_16       , 0xffc0, 0x0cc0, 0x3f8},
  1.2881 +	{d68020_cas_32       , 0xffc0, 0x0ec0, 0x3f8},
  1.2882 +	{d68020_cas2_16      , 0xffff, 0x0cfc, 0x000},
  1.2883 +	{d68020_cas2_32      , 0xffff, 0x0efc, 0x000},
  1.2884 +	{d68000_chk_16       , 0xf1c0, 0x4180, 0xbff},
  1.2885 +	{d68020_chk_32       , 0xf1c0, 0x4100, 0xbff},
  1.2886 +	{d68020_chk2_cmp2_8  , 0xffc0, 0x00c0, 0x27b},
  1.2887 +	{d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b},
  1.2888 +	{d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b},
  1.2889 +	{d68040_cinv         , 0xff20, 0xf400, 0x000},
  1.2890 +	{d68000_clr_8        , 0xffc0, 0x4200, 0xbf8},
  1.2891 +	{d68000_clr_16       , 0xffc0, 0x4240, 0xbf8},
  1.2892 +	{d68000_clr_32       , 0xffc0, 0x4280, 0xbf8},
  1.2893 +	{d68000_cmp_8        , 0xf1c0, 0xb000, 0xbff},
  1.2894 +	{d68000_cmp_16       , 0xf1c0, 0xb040, 0xfff},
  1.2895 +	{d68000_cmp_32       , 0xf1c0, 0xb080, 0xfff},
  1.2896 +	{d68000_cmpa_16      , 0xf1c0, 0xb0c0, 0xfff},
  1.2897 +	{d68000_cmpa_32      , 0xf1c0, 0xb1c0, 0xfff},
  1.2898 +	{d68000_cmpi_8       , 0xffc0, 0x0c00, 0xbf8},
  1.2899 +	{d68020_cmpi_pcdi_8  , 0xffff, 0x0c3a, 0x000},
  1.2900 +	{d68020_cmpi_pcix_8  , 0xffff, 0x0c3b, 0x000},
  1.2901 +	{d68000_cmpi_16      , 0xffc0, 0x0c40, 0xbf8},
  1.2902 +	{d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000},
  1.2903 +	{d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000},
  1.2904 +	{d68000_cmpi_32      , 0xffc0, 0x0c80, 0xbf8},
  1.2905 +	{d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000},
  1.2906 +	{d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000},
  1.2907 +	{d68000_cmpm_8       , 0xf1f8, 0xb108, 0x000},
  1.2908 +	{d68000_cmpm_16      , 0xf1f8, 0xb148, 0x000},
  1.2909 +	{d68000_cmpm_32      , 0xf1f8, 0xb188, 0x000},
  1.2910 +	{d68020_cpbcc_16     , 0xf1c0, 0xf080, 0x000},
  1.2911 +	{d68020_cpbcc_32     , 0xf1c0, 0xf0c0, 0x000},
  1.2912 +	{d68020_cpdbcc       , 0xf1f8, 0xf048, 0x000},
  1.2913 +	{d68020_cpgen        , 0xf1c0, 0xf000, 0x000},
  1.2914 +	{d68020_cprestore    , 0xf1c0, 0xf140, 0x37f},
  1.2915 +	{d68020_cpsave       , 0xf1c0, 0xf100, 0x2f8},
  1.2916 +	{d68020_cpscc        , 0xf1c0, 0xf040, 0xbf8},
  1.2917 +	{d68020_cptrapcc_0   , 0xf1ff, 0xf07c, 0x000},
  1.2918 +	{d68020_cptrapcc_16  , 0xf1ff, 0xf07a, 0x000},
  1.2919 +	{d68020_cptrapcc_32  , 0xf1ff, 0xf07b, 0x000},
  1.2920 +	{d68040_cpush        , 0xff20, 0xf420, 0x000},
  1.2921 +	{d68000_dbcc         , 0xf0f8, 0x50c8, 0x000},
  1.2922 +	{d68000_dbra         , 0xfff8, 0x51c8, 0x000},
  1.2923 +	{d68000_divs         , 0xf1c0, 0x81c0, 0xbff},
  1.2924 +	{d68000_divu         , 0xf1c0, 0x80c0, 0xbff},
  1.2925 +	{d68020_divl         , 0xffc0, 0x4c40, 0xbff},
  1.2926 +	{d68000_eor_8        , 0xf1c0, 0xb100, 0xbf8},
  1.2927 +	{d68000_eor_16       , 0xf1c0, 0xb140, 0xbf8},
  1.2928 +	{d68000_eor_32       , 0xf1c0, 0xb180, 0xbf8},
  1.2929 +	{d68000_eori_to_ccr  , 0xffff, 0x0a3c, 0x000},
  1.2930 +	{d68000_eori_to_sr   , 0xffff, 0x0a7c, 0x000},
  1.2931 +	{d68000_eori_8       , 0xffc0, 0x0a00, 0xbf8},
  1.2932 +	{d68000_eori_16      , 0xffc0, 0x0a40, 0xbf8},
  1.2933 +	{d68000_eori_32      , 0xffc0, 0x0a80, 0xbf8},
  1.2934 +	{d68000_exg_dd       , 0xf1f8, 0xc140, 0x000},
  1.2935 +	{d68000_exg_aa       , 0xf1f8, 0xc148, 0x000},
  1.2936 +	{d68000_exg_da       , 0xf1f8, 0xc188, 0x000},
  1.2937 +	{d68020_extb_32      , 0xfff8, 0x49c0, 0x000},
  1.2938 +	{d68000_ext_16       , 0xfff8, 0x4880, 0x000},
  1.2939 +	{d68000_ext_32       , 0xfff8, 0x48c0, 0x000},
  1.2940 +	{d68000_illegal      , 0xffff, 0x4afc, 0x000},
  1.2941 +	{d68000_jmp          , 0xffc0, 0x4ec0, 0x27b},
  1.2942 +	{d68000_jsr          , 0xffc0, 0x4e80, 0x27b},
  1.2943 +	{d68000_lea          , 0xf1c0, 0x41c0, 0x27b},
  1.2944 +	{d68000_link_16      , 0xfff8, 0x4e50, 0x000},
  1.2945 +	{d68020_link_32      , 0xfff8, 0x4808, 0x000},
  1.2946 +	{d68000_lsr_s_8      , 0xf1f8, 0xe008, 0x000},
  1.2947 +	{d68000_lsr_s_16     , 0xf1f8, 0xe048, 0x000},
  1.2948 +	{d68000_lsr_s_32     , 0xf1f8, 0xe088, 0x000},
  1.2949 +	{d68000_lsr_r_8      , 0xf1f8, 0xe028, 0x000},
  1.2950 +	{d68000_lsr_r_16     , 0xf1f8, 0xe068, 0x000},
  1.2951 +	{d68000_lsr_r_32     , 0xf1f8, 0xe0a8, 0x000},
  1.2952 +	{d68000_lsr_ea       , 0xffc0, 0xe2c0, 0x3f8},
  1.2953 +	{d68000_lsl_s_8      , 0xf1f8, 0xe108, 0x000},
  1.2954 +	{d68000_lsl_s_16     , 0xf1f8, 0xe148, 0x000},
  1.2955 +	{d68000_lsl_s_32     , 0xf1f8, 0xe188, 0x000},
  1.2956 +	{d68000_lsl_r_8      , 0xf1f8, 0xe128, 0x000},
  1.2957 +	{d68000_lsl_r_16     , 0xf1f8, 0xe168, 0x000},
  1.2958 +	{d68000_lsl_r_32     , 0xf1f8, 0xe1a8, 0x000},
  1.2959 +	{d68000_lsl_ea       , 0xffc0, 0xe3c0, 0x3f8},
  1.2960 +	{d68000_move_8       , 0xf000, 0x1000, 0xbff},
  1.2961 +	{d68000_move_16      , 0xf000, 0x3000, 0xfff},
  1.2962 +	{d68000_move_32      , 0xf000, 0x2000, 0xfff},
  1.2963 +	{d68000_movea_16     , 0xf1c0, 0x3040, 0xfff},
  1.2964 +	{d68000_movea_32     , 0xf1c0, 0x2040, 0xfff},
  1.2965 +	{d68000_move_to_ccr  , 0xffc0, 0x44c0, 0xbff},
  1.2966 +	{d68010_move_fr_ccr  , 0xffc0, 0x42c0, 0xbf8},
  1.2967 +	{d68000_move_to_sr   , 0xffc0, 0x46c0, 0xbff},
  1.2968 +	{d68000_move_fr_sr   , 0xffc0, 0x40c0, 0xbf8},
  1.2969 +	{d68000_move_to_usp  , 0xfff8, 0x4e60, 0x000},
  1.2970 +	{d68000_move_fr_usp  , 0xfff8, 0x4e68, 0x000},
  1.2971 +	{d68010_movec        , 0xfffe, 0x4e7a, 0x000},
  1.2972 +	{d68000_movem_pd_16  , 0xfff8, 0x48a0, 0x000},
  1.2973 +	{d68000_movem_pd_32  , 0xfff8, 0x48e0, 0x000},
  1.2974 +	{d68000_movem_re_16  , 0xffc0, 0x4880, 0x2f8},
  1.2975 +	{d68000_movem_re_32  , 0xffc0, 0x48c0, 0x2f8},
  1.2976 +	{d68000_movem_er_16  , 0xffc0, 0x4c80, 0x37b},
  1.2977 +	{d68000_movem_er_32  , 0xffc0, 0x4cc0, 0x37b},
  1.2978 +	{d68000_movep_er_16  , 0xf1f8, 0x0108, 0x000},
  1.2979 +	{d68000_movep_er_32  , 0xf1f8, 0x0148, 0x000},
  1.2980 +	{d68000_movep_re_16  , 0xf1f8, 0x0188, 0x000},
  1.2981 +	{d68000_movep_re_32  , 0xf1f8, 0x01c8, 0x000},
  1.2982 +	{d68010_moves_8      , 0xffc0, 0x0e00, 0x3f8},
  1.2983 +	{d68010_moves_16     , 0xffc0, 0x0e40, 0x3f8},
  1.2984 +	{d68010_moves_32     , 0xffc0, 0x0e80, 0x3f8},
  1.2985 +	{d68000_moveq        , 0xf100, 0x7000, 0x000},
  1.2986 +	{d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000},
  1.2987 +	{d68040_move16_pi_al , 0xfff8, 0xf600, 0x000},
  1.2988 +	{d68040_move16_al_pi , 0xfff8, 0xf608, 0x000},
  1.2989 +	{d68040_move16_ai_al , 0xfff8, 0xf610, 0x000},
  1.2990 +	{d68040_move16_al_ai , 0xfff8, 0xf618, 0x000},
  1.2991 +	{d68000_muls         , 0xf1c0, 0xc1c0, 0xbff},
  1.2992 +	{d68000_mulu         , 0xf1c0, 0xc0c0, 0xbff},
  1.2993 +	{d68020_mull         , 0xffc0, 0x4c00, 0xbff},
  1.2994 +	{d68000_nbcd         , 0xffc0, 0x4800, 0xbf8},
  1.2995 +	{d68000_neg_8        , 0xffc0, 0x4400, 0xbf8},
  1.2996 +	{d68000_neg_16       , 0xffc0, 0x4440, 0xbf8},
  1.2997 +	{d68000_neg_32       , 0xffc0, 0x4480, 0xbf8},
  1.2998 +	{d68000_negx_8       , 0xffc0, 0x4000, 0xbf8},
  1.2999 +	{d68000_negx_16      , 0xffc0, 0x4040, 0xbf8},
  1.3000 +	{d68000_negx_32      , 0xffc0, 0x4080, 0xbf8},
  1.3001 +	{d68000_nop          , 0xffff, 0x4e71, 0x000},
  1.3002 +	{d68000_not_8        , 0xffc0, 0x4600, 0xbf8},
  1.3003 +	{d68000_not_16       , 0xffc0, 0x4640, 0xbf8},
  1.3004 +	{d68000_not_32       , 0xffc0, 0x4680, 0xbf8},
  1.3005 +	{d68000_or_er_8      , 0xf1c0, 0x8000, 0xbff},
  1.3006 +	{d68000_or_er_16     , 0xf1c0, 0x8040, 0xbff},
  1.3007 +	{d68000_or_er_32     , 0xf1c0, 0x8080, 0xbff},
  1.3008 +	{d68000_or_re_8      , 0xf1c0, 0x8100, 0x3f8},
  1.3009 +	{d68000_or_re_16     , 0xf1c0, 0x8140, 0x3f8},
  1.3010 +	{d68000_or_re_32     , 0xf1c0, 0x8180, 0x3f8},
  1.3011 +	{d68000_ori_to_ccr   , 0xffff, 0x003c, 0x000},
  1.3012 +	{d68000_ori_to_sr    , 0xffff, 0x007c, 0x000},
  1.3013 +	{d68000_ori_8        , 0xffc0, 0x0000, 0xbf8},
  1.3014 +	{d68000_ori_16       , 0xffc0, 0x0040, 0xbf8},
  1.3015 +	{d68000_ori_32       , 0xffc0, 0x0080, 0xbf8},
  1.3016 +	{d68020_pack_rr      , 0xf1f8, 0x8140, 0x000},
  1.3017 +	{d68020_pack_mm      , 0xf1f8, 0x8148, 0x000},
  1.3018 +	{d68000_pea          , 0xffc0, 0x4840, 0x27b},
  1.3019 +	{d68000_reset        , 0xffff, 0x4e70, 0x000},
  1.3020 +	{d68000_ror_s_8      , 0xf1f8, 0xe018, 0x000},
  1.3021 +	{d68000_ror_s_16     , 0xf1f8, 0xe058, 0x000},
  1.3022 +	{d68000_ror_s_32     , 0xf1f8, 0xe098, 0x000},
  1.3023 +	{d68000_ror_r_8      , 0xf1f8, 0xe038, 0x000},
  1.3024 +	{d68000_ror_r_16     , 0xf1f8, 0xe078, 0x000},
  1.3025 +	{d68000_ror_r_32     , 0xf1f8, 0xe0b8, 0x000},
  1.3026 +	{d68000_ror_ea       , 0xffc0, 0xe6c0, 0x3f8},
  1.3027 +	{d68000_rol_s_8      , 0xf1f8, 0xe118, 0x000},
  1.3028 +	{d68000_rol_s_16     , 0xf1f8, 0xe158, 0x000},
  1.3029 +	{d68000_rol_s_32     , 0xf1f8, 0xe198, 0x000},
  1.3030 +	{d68000_rol_r_8      , 0xf1f8, 0xe138, 0x000},
  1.3031 +	{d68000_rol_r_16     , 0xf1f8, 0xe178, 0x000},
  1.3032 +	{d68000_rol_r_32     , 0xf1f8, 0xe1b8, 0x000},
  1.3033 +	{d68000_rol_ea       , 0xffc0, 0xe7c0, 0x3f8},
  1.3034 +	{d68000_roxr_s_8     , 0xf1f8, 0xe010, 0x000},
  1.3035 +	{d68000_roxr_s_16    , 0xf1f8, 0xe050, 0x000},
  1.3036 +	{d68000_roxr_s_32    , 0xf1f8, 0xe090, 0x000},
  1.3037 +	{d68000_roxr_r_8     , 0xf1f8, 0xe030, 0x000},
  1.3038 +	{d68000_roxr_r_16    , 0xf1f8, 0xe070, 0x000},
  1.3039 +	{d68000_roxr_r_32    , 0xf1f8, 0xe0b0, 0x000},
  1.3040 +	{d68000_roxr_ea      , 0xffc0, 0xe4c0, 0x3f8},
  1.3041 +	{d68000_roxl_s_8     , 0xf1f8, 0xe110, 0x000},
  1.3042 +	{d68000_roxl_s_16    , 0xf1f8, 0xe150, 0x000},
  1.3043 +	{d68000_roxl_s_32    , 0xf1f8, 0xe190, 0x000},
  1.3044 +	{d68000_roxl_r_8     , 0xf1f8, 0xe130, 0x000},
  1.3045 +	{d68000_roxl_r_16    , 0xf1f8, 0xe170, 0x000},
  1.3046 +	{d68000_roxl_r_32    , 0xf1f8, 0xe1b0, 0x000},
  1.3047 +	{d68000_roxl_ea      , 0xffc0, 0xe5c0, 0x3f8},
  1.3048 +	{d68010_rtd          , 0xffff, 0x4e74, 0x000},
  1.3049 +	{d68000_rte          , 0xffff, 0x4e73, 0x000},
  1.3050 +	{d68020_rtm          , 0xfff0, 0x06c0, 0x000},
  1.3051 +	{d68000_rtr          , 0xffff, 0x4e77, 0x000},
  1.3052 +	{d68000_rts          , 0xffff, 0x4e75, 0x000},
  1.3053 +	{d68000_sbcd_rr      , 0xf1f8, 0x8100, 0x000},
  1.3054 +	{d68000_sbcd_mm      , 0xf1f8, 0x8108, 0x000},
  1.3055 +	{d68000_scc          , 0xf0c0, 0x50c0, 0xbf8},
  1.3056 +	{d68000_stop         , 0xffff, 0x4e72, 0x000},
  1.3057 +	{d68000_sub_er_8     , 0xf1c0, 0x9000, 0xbff},
  1.3058 +	{d68000_sub_er_16    , 0xf1c0, 0x9040, 0xfff},
  1.3059 +	{d68000_sub_er_32    , 0xf1c0, 0x9080, 0xfff},
  1.3060 +	{d68000_sub_re_8     , 0xf1c0, 0x9100, 0x3f8},
  1.3061 +	{d68000_sub_re_16    , 0xf1c0, 0x9140, 0x3f8},
  1.3062 +	{d68000_sub_re_32    , 0xf1c0, 0x9180, 0x3f8},
  1.3063 +	{d68000_suba_16      , 0xf1c0, 0x90c0, 0xfff},
  1.3064 +	{d68000_suba_32      , 0xf1c0, 0x91c0, 0xfff},
  1.3065 +	{d68000_subi_8       , 0xffc0, 0x0400, 0xbf8},
  1.3066 +	{d68000_subi_16      , 0xffc0, 0x0440, 0xbf8},
  1.3067 +	{d68000_subi_32      , 0xffc0, 0x0480, 0xbf8},
  1.3068 +	{d68000_subq_8       , 0xf1c0, 0x5100, 0xbf8},
  1.3069 +	{d68000_subq_16      , 0xf1c0, 0x5140, 0xff8},
  1.3070 +	{d68000_subq_32      , 0xf1c0, 0x5180, 0xff8},
  1.3071 +	{d68000_subx_rr_8    , 0xf1f8, 0x9100, 0x000},
  1.3072 +	{d68000_subx_rr_16   , 0xf1f8, 0x9140, 0x000},
  1.3073 +	{d68000_subx_rr_32   , 0xf1f8, 0x9180, 0x000},
  1.3074 +	{d68000_subx_mm_8    , 0xf1f8, 0x9108, 0x000},
  1.3075 +	{d68000_subx_mm_16   , 0xf1f8, 0x9148, 0x000},
  1.3076 +	{d68000_subx_mm_32   , 0xf1f8, 0x9188, 0x000},
  1.3077 +	{d68000_swap         , 0xfff8, 0x4840, 0x000},
  1.3078 +	{d68000_tas          , 0xffc0, 0x4ac0, 0xbf8},
  1.3079 +	{d68000_trap         , 0xfff0, 0x4e40, 0x000},
  1.3080 +	{d68020_trapcc_0     , 0xf0ff, 0x50fc, 0x000},
  1.3081 +	{d68020_trapcc_16    , 0xf0ff, 0x50fa, 0x000},
  1.3082 +	{d68020_trapcc_32    , 0xf0ff, 0x50fb, 0x000},
  1.3083 +	{d68000_trapv        , 0xffff, 0x4e76, 0x000},
  1.3084 +	{d68000_tst_8        , 0xffc0, 0x4a00, 0xbf8},
  1.3085 +	{d68020_tst_pcdi_8   , 0xffff, 0x4a3a, 0x000},
  1.3086 +	{d68020_tst_pcix_8   , 0xffff, 0x4a3b, 0x000},
  1.3087 +	{d68020_tst_i_8      , 0xffff, 0x4a3c, 0x000},
  1.3088 +	{d68000_tst_16       , 0xffc0, 0x4a40, 0xbf8},
  1.3089 +	{d68020_tst_a_16     , 0xfff8, 0x4a48, 0x000},
  1.3090 +	{d68020_tst_pcdi_16  , 0xffff, 0x4a7a, 0x000},
  1.3091 +	{d68020_tst_pcix_16  , 0xffff, 0x4a7b, 0x000},
  1.3092 +	{d68020_tst_i_16     , 0xffff, 0x4a7c, 0x000},
  1.3093 +	{d68000_tst_32       , 0xffc0, 0x4a80, 0xbf8},
  1.3094 +	{d68020_tst_a_32     , 0xfff8, 0x4a88, 0x000},
  1.3095 +	{d68020_tst_pcdi_32  , 0xffff, 0x4aba, 0x000},
  1.3096 +	{d68020_tst_pcix_32  , 0xffff, 0x4abb, 0x000},
  1.3097 +	{d68020_tst_i_32     , 0xffff, 0x4abc, 0x000},
  1.3098 +	{d68000_unlk         , 0xfff8, 0x4e58, 0x000},
  1.3099 +	{d68020_unpk_rr      , 0xf1f8, 0x8180, 0x000},
  1.3100 +	{d68020_unpk_mm      , 0xf1f8, 0x8188, 0x000},
  1.3101 +	{0, 0, 0, 0}
  1.3102 +};
  1.3103 +
  1.3104 +/* Check if opcode is using a valid ea mode */
  1.3105 +static int valid_ea(uint opcode, uint mask)
  1.3106 +{
  1.3107 +	if(mask == 0)
  1.3108 +		return 1;
  1.3109 +
  1.3110 +	switch(opcode & 0x3f)
  1.3111 +	{
  1.3112 +		case 0x00: case 0x01: case 0x02: case 0x03:
  1.3113 +		case 0x04: case 0x05: case 0x06: case 0x07:
  1.3114 +			return (mask & 0x800) != 0;
  1.3115 +		case 0x08: case 0x09: case 0x0a: case 0x0b:
  1.3116 +		case 0x0c: case 0x0d: case 0x0e: case 0x0f:
  1.3117 +			return (mask & 0x400) != 0;
  1.3118 +		case 0x10: case 0x11: case 0x12: case 0x13:
  1.3119 +		case 0x14: case 0x15: case 0x16: case 0x17:
  1.3120 +			return (mask & 0x200) != 0;
  1.3121 +		case 0x18: case 0x19: case 0x1a: case 0x1b:
  1.3122 +		case 0x1c: case 0x1d: case 0x1e: case 0x1f:
  1.3123 +			return (mask & 0x100) != 0;
  1.3124 +		case 0x20: case 0x21: case 0x22: case 0x23:
  1.3125 +		case 0x24: case 0x25: case 0x26: case 0x27:
  1.3126 +			return (mask & 0x080) != 0;
  1.3127 +		case 0x28: case 0x29: case 0x2a: case 0x2b:
  1.3128 +		case 0x2c: case 0x2d: case 0x2e: case 0x2f:
  1.3129 +			return (mask & 0x040) != 0;
  1.3130 +		case 0x30: case 0x31: case 0x32: case 0x33:
  1.3131 +		case 0x34: case 0x35: case 0x36: case 0x37:
  1.3132 +			return (mask & 0x020) != 0;
  1.3133 +		case 0x38:
  1.3134 +			return (mask & 0x010) != 0;
  1.3135 +		case 0x39:
  1.3136 +			return (mask & 0x008) != 0;
  1.3137 +		case 0x3a:
  1.3138 +			return (mask & 0x002) != 0;
  1.3139 +		case 0x3b:
  1.3140 +			return (mask & 0x001) != 0;
  1.3141 +		case 0x3c:
  1.3142 +			return (mask & 0x004) != 0;
  1.3143 +	}
  1.3144 +	return 0;
  1.3145 +
  1.3146 +}
  1.3147 +
  1.3148 +/* Used by qsort */
  1.3149 +static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr)
  1.3150 +{
  1.3151 +	uint a = ((const opcode_struct*)aptr)->mask;
  1.3152 +	uint b = ((const opcode_struct*)bptr)->mask;
  1.3153 +
  1.3154 +	a = ((a & 0xAAAA) >> 1) + (a & 0x5555);
  1.3155 +	a = ((a & 0xCCCC) >> 2) + (a & 0x3333);
  1.3156 +	a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F);
  1.3157 +	a = ((a & 0xFF00) >> 8) + (a & 0x00FF);
  1.3158 +
  1.3159 +	b = ((b & 0xAAAA) >> 1) + (b & 0x5555);
  1.3160 +	b = ((b & 0xCCCC) >> 2) + (b & 0x3333);
  1.3161 +	b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F);
  1.3162 +	b = ((b & 0xFF00) >> 8) + (b & 0x00FF);
  1.3163 +
  1.3164 +	return b - a; /* reversed to get greatest to least sorting */
  1.3165 +}
  1.3166 +
  1.3167 +/* build the opcode handler jump table */
  1.3168 +static void build_opcode_table(void)
  1.3169 +{
  1.3170 +	uint i;
  1.3171 +	uint opcode;
  1.3172 +	opcode_struct* ostruct;
  1.3173 +	uint opcode_info_length = 0;
  1.3174 +
  1.3175 +	for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
  1.3176 +		opcode_info_length++;
  1.3177 +
  1.3178 +	qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits);
  1.3179 +
  1.3180 +	for(i=0;i<0x10000;i++)
  1.3181 +	{
  1.3182 +		g_instruction_table[i] = d68000_illegal; /* default to illegal */
  1.3183 +		opcode = i;
  1.3184 +		/* search through opcode info for a match */
  1.3185 +		for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
  1.3186 +		{
  1.3187 +			/* match opcode mask and allowed ea modes */
  1.3188 +			if((opcode & ostruct->mask) == ostruct->match)
  1.3189 +			{
  1.3190 +				/* Handle destination ea for move instructions */
  1.3191 +				if((ostruct->opcode_handler == d68000_move_8 ||
  1.3192 +					 ostruct->opcode_handler == d68000_move_16 ||
  1.3193 +					 ostruct->opcode_handler == d68000_move_32) &&
  1.3194 +					 !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8))
  1.3195 +						continue;
  1.3196 +				if(valid_ea(opcode, ostruct->ea_mask))
  1.3197 +				{
  1.3198 +					g_instruction_table[i] = ostruct->opcode_handler;
  1.3199 +					break;
  1.3200 +				}
  1.3201 +			}
  1.3202 +		}
  1.3203 +	}
  1.3204 +}
  1.3205 +
  1.3206 +
  1.3207 +
  1.3208 +/* ======================================================================== */
  1.3209 +/* ================================= API ================================== */
  1.3210 +/* ======================================================================== */
  1.3211 +
  1.3212 +/* Disasemble one instruction at pc and store in str_buff */
  1.3213 +unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type)
  1.3214 +{
  1.3215 +	if(!g_initialized)
  1.3216 +	{
  1.3217 +		build_opcode_table();
  1.3218 +		g_initialized = 1;
  1.3219 +	}
  1.3220 +	switch(cpu_type)
  1.3221 +	{
  1.3222 +		case M68K_CPU_TYPE_68000:
  1.3223 +			g_cpu_type = TYPE_68000;
  1.3224 +			g_address_mask = 0x00ffffff;
  1.3225 +			break;
  1.3226 +		case M68K_CPU_TYPE_68010:
  1.3227 +			g_cpu_type = TYPE_68010;
  1.3228 +			g_address_mask = 0x00ffffff;
  1.3229 +			break;
  1.3230 +		case M68K_CPU_TYPE_68EC020:
  1.3231 +			g_cpu_type = TYPE_68020;
  1.3232 +			g_address_mask = 0x00ffffff;
  1.3233 +			break;
  1.3234 +		case M68K_CPU_TYPE_68020:
  1.3235 +			g_cpu_type = TYPE_68020;
  1.3236 +			g_address_mask = 0xffffffff;
  1.3237 +			break;
  1.3238 +		case M68K_CPU_TYPE_68030:
  1.3239 +			g_cpu_type = TYPE_68030;
  1.3240 +			g_address_mask = 0xffffffff;
  1.3241 +			break;
  1.3242 +		case M68K_CPU_TYPE_68040:
  1.3243 +			g_cpu_type = TYPE_68040;
  1.3244 +			g_address_mask = 0xffffffff;
  1.3245 +			break;
  1.3246 +		default:
  1.3247 +			return 0;
  1.3248 +	}
  1.3249 +
  1.3250 +	g_cpu_pc = pc;
  1.3251 +	g_helper_str[0] = 0;
  1.3252 +	g_cpu_ir = read_imm_16();
  1.3253 +	g_instruction_table[g_cpu_ir]();
  1.3254 +	sprintf(str_buff, "%s%s", g_dasm_str, g_helper_str);
  1.3255 +	return g_cpu_pc - pc;
  1.3256 +}
  1.3257 +
  1.3258 +char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type)
  1.3259 +{
  1.3260 +	static char buff[100];
  1.3261 +	buff[0] = 0;
  1.3262 +	m68k_disassemble(buff, pc, cpu_type);
  1.3263 +	return buff;
  1.3264 +}
  1.3265 +
  1.3266 +/* Check if the instruction is a valid one */
  1.3267 +unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type)
  1.3268 +{
  1.3269 +	if(!g_initialized)
  1.3270 +	{
  1.3271 +		build_opcode_table();
  1.3272 +		g_initialized = 1;
  1.3273 +	}
  1.3274 +
  1.3275 +	instruction &= 0xffff;
  1.3276 +	if(g_instruction_table[instruction] == d68000_illegal)
  1.3277 +		return 0;
  1.3278 +
  1.3279 +	switch(cpu_type)
  1.3280 +	{
  1.3281 +		case M68K_CPU_TYPE_68000:
  1.3282 +			if(g_instruction_table[instruction] == d68010_bkpt)
  1.3283 +				return 0;
  1.3284 +			if(g_instruction_table[instruction] == d68010_move_fr_ccr)
  1.3285 +				return 0;
  1.3286 +			if(g_instruction_table[instruction] == d68010_movec)
  1.3287 +				return 0;
  1.3288 +			if(g_instruction_table[instruction] == d68010_moves_8)
  1.3289 +				return 0;
  1.3290 +			if(g_instruction_table[instruction] == d68010_moves_16)
  1.3291 +				return 0;
  1.3292 +			if(g_instruction_table[instruction] == d68010_moves_32)
  1.3293 +				return 0;
  1.3294 +			if(g_instruction_table[instruction] == d68010_rtd)
  1.3295 +				return 0;
  1.3296 +		case M68K_CPU_TYPE_68010:
  1.3297 +			if(g_instruction_table[instruction] == d68020_bcc_32)
  1.3298 +				return 0;
  1.3299 +			if(g_instruction_table[instruction] == d68020_bfchg)
  1.3300 +				return 0;
  1.3301 +			if(g_instruction_table[instruction] == d68020_bfclr)
  1.3302 +				return 0;
  1.3303 +			if(g_instruction_table[instruction] == d68020_bfexts)
  1.3304 +				return 0;
  1.3305 +			if(g_instruction_table[instruction] == d68020_bfextu)
  1.3306 +				return 0;
  1.3307 +			if(g_instruction_table[instruction] == d68020_bfffo)
  1.3308 +				return 0;
  1.3309 +			if(g_instruction_table[instruction] == d68020_bfins)
  1.3310 +				return 0;
  1.3311 +			if(g_instruction_table[instruction] == d68020_bfset)
  1.3312 +				return 0;
  1.3313 +			if(g_instruction_table[instruction] == d68020_bftst)
  1.3314 +				return 0;
  1.3315 +			if(g_instruction_table[instruction] == d68020_bra_32)
  1.3316 +				return 0;
  1.3317 +			if(g_instruction_table[instruction] == d68020_bsr_32)
  1.3318 +				return 0;
  1.3319 +			if(g_instruction_table[instruction] == d68020_callm)
  1.3320 +				return 0;
  1.3321 +			if(g_instruction_table[instruction] == d68020_cas_8)
  1.3322 +				return 0;
  1.3323 +			if(g_instruction_table[instruction] == d68020_cas_16)
  1.3324 +				return 0;
  1.3325 +			if(g_instruction_table[instruction] == d68020_cas_32)
  1.3326 +				return 0;
  1.3327 +			if(g_instruction_table[instruction] == d68020_cas2_16)
  1.3328 +				return 0;
  1.3329 +			if(g_instruction_table[instruction] == d68020_cas2_32)
  1.3330 +				return 0;
  1.3331 +			if(g_instruction_table[instruction] == d68020_chk_32)
  1.3332 +				return 0;
  1.3333 +			if(g_instruction_table[instruction] == d68020_chk2_cmp2_8)
  1.3334 +				return 0;
  1.3335 +			if(g_instruction_table[instruction] == d68020_chk2_cmp2_16)
  1.3336 +				return 0;
  1.3337 +			if(g_instruction_table[instruction] == d68020_chk2_cmp2_32)
  1.3338 +				return 0;
  1.3339 +			if(g_instruction_table[instruction] == d68020_cmpi_pcdi_8)
  1.3340 +				return 0;
  1.3341 +			if(g_instruction_table[instruction] == d68020_cmpi_pcix_8)
  1.3342 +				return 0;
  1.3343 +			if(g_instruction_table[instruction] == d68020_cmpi_pcdi_16)
  1.3344 +				return 0;
  1.3345 +			if(g_instruction_table[instruction] == d68020_cmpi_pcix_16)
  1.3346 +				return 0;
  1.3347 +			if(g_instruction_table[instruction] == d68020_cmpi_pcdi_32)
  1.3348 +				return 0;
  1.3349 +			if(g_instruction_table[instruction] == d68020_cmpi_pcix_32)
  1.3350 +				return 0;
  1.3351 +			if(g_instruction_table[instruction] == d68020_cpbcc_16)
  1.3352 +				return 0;
  1.3353 +			if(g_instruction_table[instruction] == d68020_cpbcc_32)
  1.3354 +				return 0;
  1.3355 +			if(g_instruction_table[instruction] == d68020_cpdbcc)
  1.3356 +				return 0;
  1.3357 +			if(g_instruction_table[instruction] == d68020_cpgen)
  1.3358 +				return 0;
  1.3359 +			if(g_instruction_table[instruction] == d68020_cprestore)
  1.3360 +				return 0;
  1.3361 +			if(g_instruction_table[instruction] == d68020_cpsave)
  1.3362 +				return 0;
  1.3363 +			if(g_instruction_table[instruction] == d68020_cpscc)
  1.3364 +				return 0;
  1.3365 +			if(g_instruction_table[instruction] == d68020_cptrapcc_0)
  1.3366 +				return 0;
  1.3367 +			if(g_instruction_table[instruction] == d68020_cptrapcc_16)
  1.3368 +				return 0;
  1.3369 +			if(g_instruction_table[instruction] == d68020_cptrapcc_32)
  1.3370 +				return 0;
  1.3371 +			if(g_instruction_table[instruction] == d68020_divl)
  1.3372 +				return 0;
  1.3373 +			if(g_instruction_table[instruction] == d68020_extb_32)
  1.3374 +				return 0;
  1.3375 +			if(g_instruction_table[instruction] == d68020_link_32)
  1.3376 +				return 0;
  1.3377 +			if(g_instruction_table[instruction] == d68020_mull)
  1.3378 +				return 0;
  1.3379 +			if(g_instruction_table[instruction] == d68020_pack_rr)
  1.3380 +				return 0;
  1.3381 +			if(g_instruction_table[instruction] == d68020_pack_mm)
  1.3382 +				return 0;
  1.3383 +			if(g_instruction_table[instruction] == d68020_rtm)
  1.3384 +				return 0;
  1.3385 +			if(g_instruction_table[instruction] == d68020_trapcc_0)
  1.3386 +				return 0;
  1.3387 +			if(g_instruction_table[instruction] == d68020_trapcc_16)
  1.3388 +				return 0;
  1.3389 +			if(g_instruction_table[instruction] == d68020_trapcc_32)
  1.3390 +				return 0;
  1.3391 +			if(g_instruction_table[instruction] == d68020_tst_pcdi_8)
  1.3392 +				return 0;
  1.3393 +			if(g_instruction_table[instruction] == d68020_tst_pcix_8)
  1.3394 +				return 0;
  1.3395 +			if(g_instruction_table[instruction] == d68020_tst_i_8)
  1.3396 +				return 0;
  1.3397 +			if(g_instruction_table[instruction] == d68020_tst_a_16)
  1.3398 +				return 0;
  1.3399 +			if(g_instruction_table[instruction] == d68020_tst_pcdi_16)
  1.3400 +				return 0;
  1.3401 +			if(g_instruction_table[instruction] == d68020_tst_pcix_16)
  1.3402 +				return 0;
  1.3403 +			if(g_instruction_table[instruction] == d68020_tst_i_16)
  1.3404 +				return 0;
  1.3405 +			if(g_instruction_table[instruction] == d68020_tst_a_32)
  1.3406 +				return 0;
  1.3407 +			if(g_instruction_table[instruction] == d68020_tst_pcdi_32)
  1.3408 +				return 0;
  1.3409 +			if(g_instruction_table[instruction] == d68020_tst_pcix_32)
  1.3410 +				return 0;
  1.3411 +			if(g_instruction_table[instruction] == d68020_tst_i_32)
  1.3412 +				return 0;
  1.3413 +			if(g_instruction_table[instruction] == d68020_unpk_rr)
  1.3414 +				return 0;
  1.3415 +			if(g_instruction_table[instruction] == d68020_unpk_mm)
  1.3416 +				return 0;
  1.3417 +		case M68K_CPU_TYPE_68EC020:
  1.3418 +		case M68K_CPU_TYPE_68020:
  1.3419 +		case M68K_CPU_TYPE_68030:
  1.3420 +			if(g_instruction_table[instruction] == d68040_cinv)
  1.3421 +				return 0;
  1.3422 +			if(g_instruction_table[instruction] == d68040_cpush)
  1.3423 +				return 0;
  1.3424 +			if(g_instruction_table[instruction] == d68040_move16_pi_pi)
  1.3425 +				return 0;
  1.3426 +			if(g_instruction_table[instruction] == d68040_move16_pi_al)
  1.3427 +				return 0;
  1.3428 +			if(g_instruction_table[instruction] == d68040_move16_al_pi)
  1.3429 +				return 0;
  1.3430 +			if(g_instruction_table[instruction] == d68040_move16_ai_al)
  1.3431 +				return 0;
  1.3432 +			if(g_instruction_table[instruction] == d68040_move16_al_ai)
  1.3433 +				return 0;
  1.3434 +	}
  1.3435 +	if(cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 &&
  1.3436 +	  (g_instruction_table[instruction] == d68020_callm ||
  1.3437 +	  g_instruction_table[instruction] == d68020_rtm))
  1.3438 +		return 0;
  1.3439 +
  1.3440 +	return 1;
  1.3441 +}
  1.3442 +
  1.3443 +
  1.3444 +
  1.3445 +/* ======================================================================== */
  1.3446 +/* ============================== END OF FILE ============================= */
  1.3447 +/* ======================================================================== */