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