Wed, 16 Jan 2013 00:34:11 +0000
[wd2010] use size_t for init filesize, make disc init more verbose
philpem@0 | 1 | /* ======================================================================== */ |
philpem@0 | 2 | /* ========================= LICENSING & COPYRIGHT ======================== */ |
philpem@0 | 3 | /* ======================================================================== */ |
philpem@0 | 4 | /* |
philpem@0 | 5 | * MUSASHI |
philpem@0 | 6 | * Version 3.3 |
philpem@0 | 7 | * |
philpem@0 | 8 | * A portable Motorola M680x0 processor emulation engine. |
philpem@0 | 9 | * Copyright 1998-2001 Karl Stenerud. All rights reserved. |
philpem@0 | 10 | * |
philpem@0 | 11 | * This code may be freely used for non-commercial purposes as long as this |
philpem@0 | 12 | * copyright notice remains unaltered in the source code and any binary files |
philpem@0 | 13 | * containing this code in compiled form. |
philpem@0 | 14 | * |
philpem@0 | 15 | * All other lisencing terms must be negotiated with the author |
philpem@0 | 16 | * (Karl Stenerud). |
philpem@0 | 17 | * |
philpem@0 | 18 | * The latest version of this code can be obtained at: |
philpem@0 | 19 | * http://kstenerud.cjb.net |
philpem@0 | 20 | */ |
philpem@0 | 21 | |
philpem@0 | 22 | |
philpem@0 | 23 | |
philpem@0 | 24 | /* ======================================================================== */ |
philpem@0 | 25 | /* ================================ INCLUDES ============================== */ |
philpem@0 | 26 | /* ======================================================================== */ |
philpem@0 | 27 | |
philpem@0 | 28 | #include <stdlib.h> |
philpem@0 | 29 | #include <stdio.h> |
philpem@0 | 30 | #include <string.h> |
philpem@0 | 31 | #include "m68k.h" |
philpem@0 | 32 | |
philpem@0 | 33 | /* ======================================================================== */ |
philpem@0 | 34 | /* ============================ GENERAL DEFINES =========================== */ |
philpem@0 | 35 | /* ======================================================================== */ |
philpem@0 | 36 | |
philpem@0 | 37 | /* unsigned int and int must be at least 32 bits wide */ |
philpem@0 | 38 | #undef uint |
philpem@0 | 39 | #define uint unsigned int |
philpem@0 | 40 | |
philpem@0 | 41 | /* Bit Isolation Functions */ |
philpem@0 | 42 | #define BIT_0(A) ((A) & 0x00000001) |
philpem@0 | 43 | #define BIT_1(A) ((A) & 0x00000002) |
philpem@0 | 44 | #define BIT_2(A) ((A) & 0x00000004) |
philpem@0 | 45 | #define BIT_3(A) ((A) & 0x00000008) |
philpem@0 | 46 | #define BIT_4(A) ((A) & 0x00000010) |
philpem@0 | 47 | #define BIT_5(A) ((A) & 0x00000020) |
philpem@0 | 48 | #define BIT_6(A) ((A) & 0x00000040) |
philpem@0 | 49 | #define BIT_7(A) ((A) & 0x00000080) |
philpem@0 | 50 | #define BIT_8(A) ((A) & 0x00000100) |
philpem@0 | 51 | #define BIT_9(A) ((A) & 0x00000200) |
philpem@0 | 52 | #define BIT_A(A) ((A) & 0x00000400) |
philpem@0 | 53 | #define BIT_B(A) ((A) & 0x00000800) |
philpem@0 | 54 | #define BIT_C(A) ((A) & 0x00001000) |
philpem@0 | 55 | #define BIT_D(A) ((A) & 0x00002000) |
philpem@0 | 56 | #define BIT_E(A) ((A) & 0x00004000) |
philpem@0 | 57 | #define BIT_F(A) ((A) & 0x00008000) |
philpem@0 | 58 | #define BIT_10(A) ((A) & 0x00010000) |
philpem@0 | 59 | #define BIT_11(A) ((A) & 0x00020000) |
philpem@0 | 60 | #define BIT_12(A) ((A) & 0x00040000) |
philpem@0 | 61 | #define BIT_13(A) ((A) & 0x00080000) |
philpem@0 | 62 | #define BIT_14(A) ((A) & 0x00100000) |
philpem@0 | 63 | #define BIT_15(A) ((A) & 0x00200000) |
philpem@0 | 64 | #define BIT_16(A) ((A) & 0x00400000) |
philpem@0 | 65 | #define BIT_17(A) ((A) & 0x00800000) |
philpem@0 | 66 | #define BIT_18(A) ((A) & 0x01000000) |
philpem@0 | 67 | #define BIT_19(A) ((A) & 0x02000000) |
philpem@0 | 68 | #define BIT_1A(A) ((A) & 0x04000000) |
philpem@0 | 69 | #define BIT_1B(A) ((A) & 0x08000000) |
philpem@0 | 70 | #define BIT_1C(A) ((A) & 0x10000000) |
philpem@0 | 71 | #define BIT_1D(A) ((A) & 0x20000000) |
philpem@0 | 72 | #define BIT_1E(A) ((A) & 0x40000000) |
philpem@0 | 73 | #define BIT_1F(A) ((A) & 0x80000000) |
philpem@0 | 74 | |
philpem@0 | 75 | /* These are the CPU types understood by this disassembler */ |
philpem@0 | 76 | #define TYPE_68000 1 |
philpem@0 | 77 | #define TYPE_68010 2 |
philpem@0 | 78 | #define TYPE_68020 4 |
philpem@0 | 79 | #define TYPE_68030 8 |
philpem@0 | 80 | #define TYPE_68040 16 |
philpem@0 | 81 | |
philpem@0 | 82 | #define M68000_ONLY TYPE_68000 |
philpem@0 | 83 | |
philpem@0 | 84 | #define M68010_ONLY TYPE_68010 |
philpem@0 | 85 | #define M68010_LESS (TYPE_68000 | TYPE_68010) |
philpem@0 | 86 | #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040) |
philpem@0 | 87 | |
philpem@0 | 88 | #define M68020_ONLY TYPE_68020 |
philpem@0 | 89 | #define M68020_LESS (TYPE_68010 | TYPE_68020) |
philpem@0 | 90 | #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040) |
philpem@0 | 91 | |
philpem@0 | 92 | #define M68030_ONLY TYPE_68030 |
philpem@0 | 93 | #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030) |
philpem@0 | 94 | #define M68030_PLUS (TYPE_68030 | TYPE_68040) |
philpem@0 | 95 | |
philpem@0 | 96 | #define M68040_PLUS TYPE_68040 |
philpem@0 | 97 | |
philpem@0 | 98 | |
philpem@0 | 99 | /* Extension word formats */ |
philpem@0 | 100 | #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff) |
philpem@0 | 101 | #define EXT_FULL(A) BIT_8(A) |
philpem@0 | 102 | #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0) |
philpem@0 | 103 | #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A)) |
philpem@0 | 104 | #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A)) |
philpem@0 | 105 | #define EXT_INDEX_REGISTER(A) (((A)>>12)&7) |
philpem@0 | 106 | #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3) |
philpem@0 | 107 | #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0) |
philpem@0 | 108 | #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4) |
philpem@0 | 109 | #define EXT_INDEX_SCALE(A) (((A)>>9)&3) |
philpem@0 | 110 | #define EXT_INDEX_LONG(A) BIT_B(A) |
philpem@0 | 111 | #define EXT_INDEX_AR(A) BIT_F(A) |
philpem@0 | 112 | #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10) |
philpem@0 | 113 | #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20) |
philpem@0 | 114 | #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30) |
philpem@0 | 115 | #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44) |
philpem@0 | 116 | #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44) |
philpem@0 | 117 | #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44) |
philpem@0 | 118 | |
philpem@0 | 119 | |
philpem@0 | 120 | |
philpem@0 | 121 | /* ======================================================================== */ |
philpem@0 | 122 | /* =============================== PROTOTYPES ============================= */ |
philpem@0 | 123 | /* ======================================================================== */ |
philpem@0 | 124 | |
philpem@0 | 125 | /* Read data at the PC and increment PC */ |
philpem@0 | 126 | uint read_imm_8(void); |
philpem@0 | 127 | uint read_imm_16(void); |
philpem@0 | 128 | uint read_imm_32(void); |
philpem@0 | 129 | |
philpem@0 | 130 | /* Read data at the PC but don't imcrement the PC */ |
philpem@0 | 131 | uint peek_imm_8(void); |
philpem@0 | 132 | uint peek_imm_16(void); |
philpem@0 | 133 | uint peek_imm_32(void); |
philpem@0 | 134 | |
philpem@0 | 135 | /* make signed integers 100% portably */ |
philpem@0 | 136 | static int make_int_8(int value); |
philpem@0 | 137 | static int make_int_16(int value); |
philpem@0 | 138 | |
philpem@0 | 139 | /* make a string of a hex value */ |
philpem@0 | 140 | static char* make_signed_hex_str_8(uint val); |
philpem@0 | 141 | static char* make_signed_hex_str_16(uint val); |
philpem@0 | 142 | static char* make_signed_hex_str_32(uint val); |
philpem@0 | 143 | |
philpem@0 | 144 | /* make string of ea mode */ |
philpem@0 | 145 | static char* get_ea_mode_str(uint instruction, uint size); |
philpem@0 | 146 | |
philpem@0 | 147 | char* get_ea_mode_str_8(uint instruction); |
philpem@0 | 148 | char* get_ea_mode_str_16(uint instruction); |
philpem@0 | 149 | char* get_ea_mode_str_32(uint instruction); |
philpem@0 | 150 | |
philpem@0 | 151 | /* make string of immediate value */ |
philpem@0 | 152 | static char* get_imm_str_s(uint size); |
philpem@0 | 153 | static char* get_imm_str_u(uint size); |
philpem@0 | 154 | |
philpem@0 | 155 | char* get_imm_str_s8(void); |
philpem@0 | 156 | char* get_imm_str_s16(void); |
philpem@0 | 157 | char* get_imm_str_s32(void); |
philpem@0 | 158 | |
philpem@0 | 159 | /* Stuff to build the opcode handler jump table */ |
philpem@0 | 160 | static void build_opcode_table(void); |
philpem@0 | 161 | static int valid_ea(uint opcode, uint mask); |
philpem@0 | 162 | static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr); |
philpem@0 | 163 | |
philpem@0 | 164 | /* used to build opcode handler jump table */ |
philpem@0 | 165 | typedef struct |
philpem@0 | 166 | { |
philpem@0 | 167 | void (*opcode_handler)(void); /* handler function */ |
philpem@0 | 168 | uint mask; /* mask on opcode */ |
philpem@0 | 169 | uint match; /* what to match after masking */ |
philpem@0 | 170 | uint ea_mask; /* what ea modes are allowed */ |
philpem@0 | 171 | } opcode_struct; |
philpem@0 | 172 | |
philpem@0 | 173 | |
philpem@0 | 174 | |
philpem@0 | 175 | /* ======================================================================== */ |
philpem@0 | 176 | /* ================================= DATA ================================= */ |
philpem@0 | 177 | /* ======================================================================== */ |
philpem@0 | 178 | |
philpem@0 | 179 | /* Opcode handler jump table */ |
philpem@0 | 180 | static void (*g_instruction_table[0x10000])(void); |
philpem@0 | 181 | /* Flag if disassembler initialized */ |
philpem@0 | 182 | static int g_initialized = 0; |
philpem@0 | 183 | |
philpem@0 | 184 | /* Address mask to simulate address lines */ |
philpem@0 | 185 | static unsigned int g_address_mask = 0xffffffff; |
philpem@0 | 186 | |
philpem@0 | 187 | static char g_dasm_str[100]; /* string to hold disassembly */ |
philpem@0 | 188 | static char g_helper_str[100]; /* string to hold helpful info */ |
philpem@0 | 189 | static uint g_cpu_pc; /* program counter */ |
philpem@0 | 190 | static uint g_cpu_ir; /* instruction register */ |
philpem@0 | 191 | static uint g_cpu_type; |
philpem@0 | 192 | |
philpem@0 | 193 | /* used by ops like asr, ror, addq, etc */ |
philpem@0 | 194 | static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7}; |
philpem@0 | 195 | |
philpem@0 | 196 | static uint g_5bit_data_table[32] = |
philpem@0 | 197 | { |
philpem@0 | 198 | 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
philpem@0 | 199 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 |
philpem@0 | 200 | }; |
philpem@0 | 201 | |
philpem@0 | 202 | static char* g_cc[16] = |
philpem@0 | 203 | {"t", "f", "hi", "ls", "cc", "cs", "ne", "eq", "vc", "vs", "pl", "mi", "ge", "lt", "gt", "le"}; |
philpem@0 | 204 | |
philpem@0 | 205 | static char* g_cpcc[64] = |
philpem@0 | 206 | {/* 000 001 010 011 100 101 110 111 */ |
philpem@0 | 207 | "f", "eq", "ogt", "oge", "olt", "ole", "ogl", "or", /* 000 */ |
philpem@0 | 208 | "un", "ueq", "ugt", "uge", "ult", "ule", "ne", "t", /* 001 */ |
philpem@0 | 209 | "sf", "seq", "gt", "ge", "lt", "le", "gl" "gle", /* 010 */ |
philpem@0 | 210 | "ngle", "ngl", "nle", "nlt", "nge", "ngt", "sne", "st", /* 011 */ |
philpem@0 | 211 | "?", "?", "?", "?", "?", "?", "?", "?", /* 100 */ |
philpem@0 | 212 | "?", "?", "?", "?", "?", "?", "?", "?", /* 101 */ |
philpem@0 | 213 | "?", "?", "?", "?", "?", "?", "?", "?", /* 110 */ |
philpem@0 | 214 | "?", "?", "?", "?", "?", "?", "?", "?" /* 111 */ |
philpem@0 | 215 | }; |
philpem@0 | 216 | |
philpem@0 | 217 | |
philpem@0 | 218 | /* ======================================================================== */ |
philpem@0 | 219 | /* =========================== UTILITY FUNCTIONS ========================== */ |
philpem@0 | 220 | /* ======================================================================== */ |
philpem@0 | 221 | |
philpem@0 | 222 | #define LIMIT_CPU_TYPES(ALLOWED_CPU_TYPES) \ |
philpem@0 | 223 | if(!(g_cpu_type & ALLOWED_CPU_TYPES)) \ |
philpem@0 | 224 | { \ |
philpem@0 | 225 | d68000_illegal(); \ |
philpem@0 | 226 | return; \ |
philpem@0 | 227 | } |
philpem@0 | 228 | |
philpem@0 | 229 | #define read_imm_8() (m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask)&0xff) |
philpem@0 | 230 | #define read_imm_16() m68k_read_disassembler_16(((g_cpu_pc+=2)-2)&g_address_mask) |
philpem@0 | 231 | #define read_imm_32() m68k_read_disassembler_32(((g_cpu_pc+=4)-4)&g_address_mask) |
philpem@0 | 232 | |
philpem@0 | 233 | #define peek_imm_8() (m68k_read_disassembler_16(g_cpu_pc & g_address_mask)&0xff) |
philpem@0 | 234 | #define peek_imm_16() m68k_read_disassembler_16(g_cpu_pc & g_address_mask) |
philpem@0 | 235 | #define peek_imm_32() m68k_read_disassembler_32(g_cpu_pc & g_address_mask) |
philpem@0 | 236 | |
philpem@0 | 237 | /* Fake a split interface */ |
philpem@0 | 238 | #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0) |
philpem@0 | 239 | #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1) |
philpem@0 | 240 | #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2) |
philpem@0 | 241 | |
philpem@0 | 242 | #define get_imm_str_s8() get_imm_str_s(0) |
philpem@0 | 243 | #define get_imm_str_s16() get_imm_str_s(1) |
philpem@0 | 244 | #define get_imm_str_s32() get_imm_str_s(2) |
philpem@0 | 245 | |
philpem@0 | 246 | #define get_imm_str_u8() get_imm_str_u(0) |
philpem@0 | 247 | #define get_imm_str_u16() get_imm_str_u(1) |
philpem@0 | 248 | #define get_imm_str_u32() get_imm_str_u(2) |
philpem@0 | 249 | |
philpem@0 | 250 | |
philpem@0 | 251 | /* 100% portable signed int generators */ |
philpem@0 | 252 | static int make_int_8(int value) |
philpem@0 | 253 | { |
philpem@0 | 254 | return (value & 0x80) ? value | ~0xff : value & 0xff; |
philpem@0 | 255 | } |
philpem@0 | 256 | |
philpem@0 | 257 | static int make_int_16(int value) |
philpem@0 | 258 | { |
philpem@0 | 259 | return (value & 0x8000) ? value | ~0xffff : value & 0xffff; |
philpem@0 | 260 | } |
philpem@0 | 261 | |
philpem@0 | 262 | |
philpem@0 | 263 | /* Get string representation of hex values */ |
philpem@0 | 264 | static char* make_signed_hex_str_8(uint val) |
philpem@0 | 265 | { |
philpem@0 | 266 | static char str[20]; |
philpem@0 | 267 | |
philpem@0 | 268 | val &= 0xff; |
philpem@0 | 269 | |
philpem@0 | 270 | if(val == 0x80) |
philpem@0 | 271 | sprintf(str, "-$80"); |
philpem@0 | 272 | else if(val & 0x80) |
philpem@0 | 273 | sprintf(str, "-$%x", (0-val) & 0x7f); |
philpem@0 | 274 | else |
philpem@0 | 275 | sprintf(str, "$%x", val & 0x7f); |
philpem@0 | 276 | |
philpem@0 | 277 | return str; |
philpem@0 | 278 | } |
philpem@0 | 279 | |
philpem@0 | 280 | static char* make_signed_hex_str_16(uint val) |
philpem@0 | 281 | { |
philpem@0 | 282 | static char str[20]; |
philpem@0 | 283 | |
philpem@0 | 284 | val &= 0xffff; |
philpem@0 | 285 | |
philpem@0 | 286 | if(val == 0x8000) |
philpem@0 | 287 | sprintf(str, "-$8000"); |
philpem@0 | 288 | else if(val & 0x8000) |
philpem@0 | 289 | sprintf(str, "-$%x", (0-val) & 0x7fff); |
philpem@0 | 290 | else |
philpem@0 | 291 | sprintf(str, "$%x", val & 0x7fff); |
philpem@0 | 292 | |
philpem@0 | 293 | return str; |
philpem@0 | 294 | } |
philpem@0 | 295 | |
philpem@0 | 296 | static char* make_signed_hex_str_32(uint val) |
philpem@0 | 297 | { |
philpem@0 | 298 | static char str[20]; |
philpem@0 | 299 | |
philpem@0 | 300 | val &= 0xffffffff; |
philpem@0 | 301 | |
philpem@0 | 302 | if(val == 0x80000000) |
philpem@0 | 303 | sprintf(str, "-$80000000"); |
philpem@0 | 304 | else if(val & 0x80000000) |
philpem@0 | 305 | sprintf(str, "-$%x", (0-val) & 0x7fffffff); |
philpem@0 | 306 | else |
philpem@0 | 307 | sprintf(str, "$%x", val & 0x7fffffff); |
philpem@0 | 308 | |
philpem@0 | 309 | return str; |
philpem@0 | 310 | } |
philpem@0 | 311 | |
philpem@0 | 312 | |
philpem@0 | 313 | /* make string of immediate value */ |
philpem@0 | 314 | static char* get_imm_str_s(uint size) |
philpem@0 | 315 | { |
philpem@0 | 316 | static char str[15]; |
philpem@0 | 317 | if(size == 0) |
philpem@0 | 318 | sprintf(str, "#%s", make_signed_hex_str_8(read_imm_8())); |
philpem@0 | 319 | else if(size == 1) |
philpem@0 | 320 | sprintf(str, "#%s", make_signed_hex_str_16(read_imm_16())); |
philpem@0 | 321 | else |
philpem@0 | 322 | sprintf(str, "#%s", make_signed_hex_str_32(read_imm_32())); |
philpem@0 | 323 | return str; |
philpem@0 | 324 | } |
philpem@0 | 325 | |
philpem@0 | 326 | static char* get_imm_str_u(uint size) |
philpem@0 | 327 | { |
philpem@0 | 328 | static char str[15]; |
philpem@0 | 329 | if(size == 0) |
philpem@0 | 330 | sprintf(str, "#$%x", read_imm_8() & 0xff); |
philpem@0 | 331 | else if(size == 1) |
philpem@0 | 332 | sprintf(str, "#$%x", read_imm_16() & 0xffff); |
philpem@0 | 333 | else |
philpem@0 | 334 | sprintf(str, "#$%x", read_imm_32() & 0xffffffff); |
philpem@0 | 335 | return str; |
philpem@0 | 336 | } |
philpem@0 | 337 | |
philpem@0 | 338 | /* Make string of effective address mode */ |
philpem@0 | 339 | static char* get_ea_mode_str(uint instruction, uint size) |
philpem@0 | 340 | { |
philpem@0 | 341 | static char b1[64]; |
philpem@0 | 342 | static char b2[64]; |
philpem@0 | 343 | static char* mode = b2; |
philpem@0 | 344 | uint extension; |
philpem@0 | 345 | uint base; |
philpem@0 | 346 | uint outer; |
philpem@0 | 347 | char base_reg[4]; |
philpem@0 | 348 | char index_reg[8]; |
philpem@0 | 349 | uint preindex; |
philpem@0 | 350 | uint postindex; |
philpem@0 | 351 | uint comma = 0; |
philpem@0 | 352 | uint temp_value; |
philpem@0 | 353 | |
philpem@0 | 354 | /* Switch buffers so we don't clobber on a double-call to this function */ |
philpem@0 | 355 | mode = mode == b1 ? b2 : b1; |
philpem@0 | 356 | |
philpem@0 | 357 | switch(instruction & 0x3f) |
philpem@0 | 358 | { |
philpem@0 | 359 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: |
philpem@0 | 360 | /* data register direct */ |
philpem@0 | 361 | sprintf(mode, "D%d", instruction&7); |
philpem@0 | 362 | break; |
philpem@0 | 363 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: |
philpem@0 | 364 | /* address register direct */ |
philpem@0 | 365 | sprintf(mode, "A%d", instruction&7); |
philpem@0 | 366 | break; |
philpem@0 | 367 | case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: |
philpem@0 | 368 | /* address register indirect */ |
philpem@0 | 369 | sprintf(mode, "(A%d)", instruction&7); |
philpem@0 | 370 | break; |
philpem@0 | 371 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: |
philpem@0 | 372 | /* address register indirect with postincrement */ |
philpem@0 | 373 | sprintf(mode, "(A%d)+", instruction&7); |
philpem@0 | 374 | break; |
philpem@0 | 375 | case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: |
philpem@0 | 376 | /* address register indirect with predecrement */ |
philpem@0 | 377 | sprintf(mode, "-(A%d)", instruction&7); |
philpem@0 | 378 | break; |
philpem@0 | 379 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: |
philpem@0 | 380 | /* address register indirect with displacement*/ |
philpem@0 | 381 | sprintf(mode, "(%s,A%d)", make_signed_hex_str_16(read_imm_16()), instruction&7); |
philpem@0 | 382 | break; |
philpem@0 | 383 | case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: |
philpem@0 | 384 | /* address register indirect with index */ |
philpem@0 | 385 | extension = read_imm_16(); |
philpem@0 | 386 | |
philpem@0 | 387 | if(EXT_FULL(extension)) |
philpem@0 | 388 | { |
philpem@0 | 389 | if(EXT_EFFECTIVE_ZERO(extension)) |
philpem@0 | 390 | { |
philpem@0 | 391 | strcpy(mode, "0"); |
philpem@0 | 392 | break; |
philpem@0 | 393 | } |
philpem@0 | 394 | base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0; |
philpem@0 | 395 | outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0; |
philpem@0 | 396 | if(EXT_BASE_REGISTER_PRESENT(extension)) |
philpem@0 | 397 | sprintf(base_reg, "A%d", instruction&7); |
philpem@0 | 398 | else |
philpem@0 | 399 | *base_reg = 0; |
philpem@0 | 400 | if(EXT_INDEX_REGISTER_PRESENT(extension)) |
philpem@0 | 401 | { |
philpem@0 | 402 | sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w'); |
philpem@0 | 403 | if(EXT_INDEX_SCALE(extension)) |
philpem@0 | 404 | sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension)); |
philpem@0 | 405 | } |
philpem@0 | 406 | else |
philpem@0 | 407 | *index_reg = 0; |
philpem@0 | 408 | preindex = (extension&7) > 0 && (extension&7) < 4; |
philpem@0 | 409 | postindex = (extension&7) > 4; |
philpem@0 | 410 | |
philpem@0 | 411 | strcpy(mode, "("); |
philpem@0 | 412 | if(preindex || postindex) |
philpem@0 | 413 | strcat(mode, "["); |
philpem@0 | 414 | if(base) |
philpem@0 | 415 | { |
philpem@0 | 416 | strcat(mode, make_signed_hex_str_16(base)); |
philpem@0 | 417 | comma = 1; |
philpem@0 | 418 | } |
philpem@0 | 419 | if(*base_reg) |
philpem@0 | 420 | { |
philpem@0 | 421 | if(comma) |
philpem@0 | 422 | strcat(mode, ","); |
philpem@0 | 423 | strcat(mode, base_reg); |
philpem@0 | 424 | comma = 1; |
philpem@0 | 425 | } |
philpem@0 | 426 | if(postindex) |
philpem@0 | 427 | { |
philpem@0 | 428 | strcat(mode, "]"); |
philpem@0 | 429 | comma = 1; |
philpem@0 | 430 | } |
philpem@0 | 431 | if(*index_reg) |
philpem@0 | 432 | { |
philpem@0 | 433 | if(comma) |
philpem@0 | 434 | strcat(mode, ","); |
philpem@0 | 435 | strcat(mode, index_reg); |
philpem@0 | 436 | comma = 1; |
philpem@0 | 437 | } |
philpem@0 | 438 | if(preindex) |
philpem@0 | 439 | { |
philpem@0 | 440 | strcat(mode, "]"); |
philpem@0 | 441 | comma = 1; |
philpem@0 | 442 | } |
philpem@0 | 443 | if(outer) |
philpem@0 | 444 | { |
philpem@0 | 445 | if(comma) |
philpem@0 | 446 | strcat(mode, ","); |
philpem@0 | 447 | strcat(mode, make_signed_hex_str_16(outer)); |
philpem@0 | 448 | } |
philpem@0 | 449 | strcat(mode, ")"); |
philpem@0 | 450 | break; |
philpem@0 | 451 | } |
philpem@0 | 452 | |
philpem@0 | 453 | if(EXT_8BIT_DISPLACEMENT(extension) == 0) |
philpem@0 | 454 | sprintf(mode, "(A%d,%c%d.%c", instruction&7, EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w'); |
philpem@0 | 455 | else |
philpem@0 | 456 | sprintf(mode, "(%s,A%d,%c%d.%c", make_signed_hex_str_8(extension), instruction&7, EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w'); |
philpem@0 | 457 | if(EXT_INDEX_SCALE(extension)) |
philpem@0 | 458 | sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension)); |
philpem@0 | 459 | strcat(mode, ")"); |
philpem@0 | 460 | break; |
philpem@0 | 461 | case 0x38: |
philpem@0 | 462 | /* absolute short address */ |
philpem@0 | 463 | sprintf(mode, "$%x.w", read_imm_16()); |
philpem@0 | 464 | break; |
philpem@0 | 465 | case 0x39: |
philpem@0 | 466 | /* absolute long address */ |
philpem@0 | 467 | sprintf(mode, "$%x.l", read_imm_32()); |
philpem@0 | 468 | break; |
philpem@0 | 469 | case 0x3a: |
philpem@0 | 470 | /* program counter with displacement */ |
philpem@0 | 471 | temp_value = read_imm_16(); |
philpem@0 | 472 | sprintf(mode, "(%s,PC)", make_signed_hex_str_16(temp_value)); |
philpem@0 | 473 | sprintf(g_helper_str, "; ($%x)", (make_int_16(temp_value) + g_cpu_pc-2) & 0xffffffff); |
philpem@0 | 474 | break; |
philpem@0 | 475 | case 0x3b: |
philpem@0 | 476 | /* program counter with index */ |
philpem@0 | 477 | extension = read_imm_16(); |
philpem@0 | 478 | |
philpem@0 | 479 | if(EXT_FULL(extension)) |
philpem@0 | 480 | { |
philpem@0 | 481 | if(EXT_EFFECTIVE_ZERO(extension)) |
philpem@0 | 482 | { |
philpem@0 | 483 | strcpy(mode, "0"); |
philpem@0 | 484 | break; |
philpem@0 | 485 | } |
philpem@0 | 486 | base = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0; |
philpem@0 | 487 | outer = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32() : read_imm_16()) : 0; |
philpem@0 | 488 | if(EXT_BASE_REGISTER_PRESENT(extension)) |
philpem@0 | 489 | strcpy(base_reg, "PC"); |
philpem@0 | 490 | else |
philpem@0 | 491 | *base_reg = 0; |
philpem@0 | 492 | if(EXT_INDEX_REGISTER_PRESENT(extension)) |
philpem@0 | 493 | { |
philpem@0 | 494 | sprintf(index_reg, "%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w'); |
philpem@0 | 495 | if(EXT_INDEX_SCALE(extension)) |
philpem@0 | 496 | sprintf(index_reg+strlen(index_reg), "*%d", 1 << EXT_INDEX_SCALE(extension)); |
philpem@0 | 497 | } |
philpem@0 | 498 | else |
philpem@0 | 499 | *index_reg = 0; |
philpem@0 | 500 | preindex = (extension&7) > 0 && (extension&7) < 4; |
philpem@0 | 501 | postindex = (extension&7) > 4; |
philpem@0 | 502 | |
philpem@0 | 503 | strcpy(mode, "("); |
philpem@0 | 504 | if(preindex || postindex) |
philpem@0 | 505 | strcat(mode, "["); |
philpem@0 | 506 | if(base) |
philpem@0 | 507 | { |
philpem@0 | 508 | strcat(mode, make_signed_hex_str_16(base)); |
philpem@0 | 509 | comma = 1; |
philpem@0 | 510 | } |
philpem@0 | 511 | if(*base_reg) |
philpem@0 | 512 | { |
philpem@0 | 513 | if(comma) |
philpem@0 | 514 | strcat(mode, ","); |
philpem@0 | 515 | strcat(mode, base_reg); |
philpem@0 | 516 | comma = 1; |
philpem@0 | 517 | } |
philpem@0 | 518 | if(postindex) |
philpem@0 | 519 | { |
philpem@0 | 520 | strcat(mode, "]"); |
philpem@0 | 521 | comma = 1; |
philpem@0 | 522 | } |
philpem@0 | 523 | if(*index_reg) |
philpem@0 | 524 | { |
philpem@0 | 525 | if(comma) |
philpem@0 | 526 | strcat(mode, ","); |
philpem@0 | 527 | strcat(mode, index_reg); |
philpem@0 | 528 | comma = 1; |
philpem@0 | 529 | } |
philpem@0 | 530 | if(preindex) |
philpem@0 | 531 | { |
philpem@0 | 532 | strcat(mode, "]"); |
philpem@0 | 533 | comma = 1; |
philpem@0 | 534 | } |
philpem@0 | 535 | if(outer) |
philpem@0 | 536 | { |
philpem@0 | 537 | if(comma) |
philpem@0 | 538 | strcat(mode, ","); |
philpem@0 | 539 | strcat(mode, make_signed_hex_str_16(outer)); |
philpem@0 | 540 | } |
philpem@0 | 541 | strcat(mode, ")"); |
philpem@0 | 542 | break; |
philpem@0 | 543 | } |
philpem@0 | 544 | |
philpem@0 | 545 | if(EXT_8BIT_DISPLACEMENT(extension) == 0) |
philpem@0 | 546 | sprintf(mode, "(PC,%c%d.%c", EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w'); |
philpem@0 | 547 | else |
philpem@0 | 548 | sprintf(mode, "(%s,PC,%c%d.%c", make_signed_hex_str_8(extension), EXT_INDEX_AR(extension) ? 'A' : 'D', EXT_INDEX_REGISTER(extension), EXT_INDEX_LONG(extension) ? 'l' : 'w'); |
philpem@0 | 549 | if(EXT_INDEX_SCALE(extension)) |
philpem@0 | 550 | sprintf(mode+strlen(mode), "*%d", 1 << EXT_INDEX_SCALE(extension)); |
philpem@0 | 551 | strcat(mode, ")"); |
philpem@0 | 552 | break; |
philpem@0 | 553 | case 0x3c: |
philpem@0 | 554 | /* Immediate */ |
philpem@0 | 555 | sprintf(mode, "%s", get_imm_str_u(size)); |
philpem@0 | 556 | break; |
philpem@0 | 557 | default: |
philpem@0 | 558 | sprintf(mode, "INVALID %x", instruction & 0x3f); |
philpem@0 | 559 | } |
philpem@0 | 560 | return mode; |
philpem@0 | 561 | } |
philpem@0 | 562 | |
philpem@0 | 563 | |
philpem@0 | 564 | |
philpem@0 | 565 | /* ======================================================================== */ |
philpem@0 | 566 | /* ========================= INSTRUCTION HANDLERS ========================= */ |
philpem@0 | 567 | /* ======================================================================== */ |
philpem@0 | 568 | /* Instruction handler function names follow this convention: |
philpem@0 | 569 | * |
philpem@0 | 570 | * d68000_NAME_EXTENSIONS(void) |
philpem@0 | 571 | * where NAME is the name of the opcode it handles and EXTENSIONS are any |
philpem@0 | 572 | * extensions for special instances of that opcode. |
philpem@0 | 573 | * |
philpem@0 | 574 | * Examples: |
philpem@0 | 575 | * d68000_add_er_8(): add opcode, from effective address to register, |
philpem@0 | 576 | * size = byte |
philpem@0 | 577 | * |
philpem@0 | 578 | * d68000_asr_s_8(): arithmetic shift right, static count, size = byte |
philpem@0 | 579 | * |
philpem@0 | 580 | * |
philpem@0 | 581 | * Common extensions: |
philpem@0 | 582 | * 8 : size = byte |
philpem@0 | 583 | * 16 : size = word |
philpem@0 | 584 | * 32 : size = long |
philpem@0 | 585 | * rr : register to register |
philpem@0 | 586 | * mm : memory to memory |
philpem@0 | 587 | * r : register |
philpem@0 | 588 | * s : static |
philpem@0 | 589 | * er : effective address -> register |
philpem@0 | 590 | * re : register -> effective address |
philpem@0 | 591 | * ea : using effective address mode of operation |
philpem@0 | 592 | * d : data register direct |
philpem@0 | 593 | * a : address register direct |
philpem@0 | 594 | * ai : address register indirect |
philpem@0 | 595 | * pi : address register indirect with postincrement |
philpem@0 | 596 | * pd : address register indirect with predecrement |
philpem@0 | 597 | * di : address register indirect with displacement |
philpem@0 | 598 | * ix : address register indirect with index |
philpem@0 | 599 | * aw : absolute word |
philpem@0 | 600 | * al : absolute long |
philpem@0 | 601 | */ |
philpem@0 | 602 | |
philpem@0 | 603 | static void d68000_illegal(void) |
philpem@0 | 604 | { |
philpem@0 | 605 | sprintf(g_dasm_str, "dc.w $%04x; ILLEGAL", g_cpu_ir); |
philpem@0 | 606 | } |
philpem@0 | 607 | |
philpem@0 | 608 | static void d68000_1010(void) |
philpem@0 | 609 | { |
philpem@0 | 610 | sprintf(g_dasm_str, "dc.w $%04x; opcode 1010", g_cpu_ir); |
philpem@0 | 611 | } |
philpem@0 | 612 | |
philpem@0 | 613 | |
philpem@0 | 614 | static void d68000_1111(void) |
philpem@0 | 615 | { |
philpem@0 | 616 | sprintf(g_dasm_str, "dc.w $%04x; opcode 1111", g_cpu_ir); |
philpem@0 | 617 | } |
philpem@0 | 618 | |
philpem@0 | 619 | |
philpem@0 | 620 | static void d68000_abcd_rr(void) |
philpem@0 | 621 | { |
philpem@0 | 622 | sprintf(g_dasm_str, "abcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 623 | } |
philpem@0 | 624 | |
philpem@0 | 625 | |
philpem@0 | 626 | static void d68000_abcd_mm(void) |
philpem@0 | 627 | { |
philpem@0 | 628 | sprintf(g_dasm_str, "abcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 629 | } |
philpem@0 | 630 | |
philpem@0 | 631 | static void d68000_add_er_8(void) |
philpem@0 | 632 | { |
philpem@0 | 633 | sprintf(g_dasm_str, "add.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 634 | } |
philpem@0 | 635 | |
philpem@0 | 636 | |
philpem@0 | 637 | static void d68000_add_er_16(void) |
philpem@0 | 638 | { |
philpem@0 | 639 | sprintf(g_dasm_str, "add.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 640 | } |
philpem@0 | 641 | |
philpem@0 | 642 | static void d68000_add_er_32(void) |
philpem@0 | 643 | { |
philpem@0 | 644 | sprintf(g_dasm_str, "add.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 645 | } |
philpem@0 | 646 | |
philpem@0 | 647 | static void d68000_add_re_8(void) |
philpem@0 | 648 | { |
philpem@0 | 649 | sprintf(g_dasm_str, "add.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 650 | } |
philpem@0 | 651 | |
philpem@0 | 652 | static void d68000_add_re_16(void) |
philpem@0 | 653 | { |
philpem@0 | 654 | sprintf(g_dasm_str, "add.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 655 | } |
philpem@0 | 656 | |
philpem@0 | 657 | static void d68000_add_re_32(void) |
philpem@0 | 658 | { |
philpem@0 | 659 | sprintf(g_dasm_str, "add.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 660 | } |
philpem@0 | 661 | |
philpem@0 | 662 | static void d68000_adda_16(void) |
philpem@0 | 663 | { |
philpem@0 | 664 | sprintf(g_dasm_str, "adda.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 665 | } |
philpem@0 | 666 | |
philpem@0 | 667 | static void d68000_adda_32(void) |
philpem@0 | 668 | { |
philpem@0 | 669 | sprintf(g_dasm_str, "adda.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 670 | } |
philpem@0 | 671 | |
philpem@0 | 672 | static void d68000_addi_8(void) |
philpem@0 | 673 | { |
philpem@0 | 674 | char* str = get_imm_str_s8(); |
philpem@0 | 675 | sprintf(g_dasm_str, "addi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 676 | } |
philpem@0 | 677 | |
philpem@0 | 678 | static void d68000_addi_16(void) |
philpem@0 | 679 | { |
philpem@0 | 680 | char* str = get_imm_str_s16(); |
philpem@0 | 681 | sprintf(g_dasm_str, "addi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 682 | } |
philpem@0 | 683 | |
philpem@0 | 684 | static void d68000_addi_32(void) |
philpem@0 | 685 | { |
philpem@0 | 686 | char* str = get_imm_str_s32(); |
philpem@0 | 687 | sprintf(g_dasm_str, "addi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 688 | } |
philpem@0 | 689 | |
philpem@0 | 690 | static void d68000_addq_8(void) |
philpem@0 | 691 | { |
philpem@0 | 692 | sprintf(g_dasm_str, "addq.b #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 693 | } |
philpem@0 | 694 | |
philpem@0 | 695 | static void d68000_addq_16(void) |
philpem@0 | 696 | { |
philpem@0 | 697 | sprintf(g_dasm_str, "addq.w #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 698 | } |
philpem@0 | 699 | |
philpem@0 | 700 | static void d68000_addq_32(void) |
philpem@0 | 701 | { |
philpem@0 | 702 | sprintf(g_dasm_str, "addq.l #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 703 | } |
philpem@0 | 704 | |
philpem@0 | 705 | static void d68000_addx_rr_8(void) |
philpem@0 | 706 | { |
philpem@0 | 707 | sprintf(g_dasm_str, "addx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 708 | } |
philpem@0 | 709 | |
philpem@0 | 710 | static void d68000_addx_rr_16(void) |
philpem@0 | 711 | { |
philpem@0 | 712 | sprintf(g_dasm_str, "addx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 713 | } |
philpem@0 | 714 | |
philpem@0 | 715 | static void d68000_addx_rr_32(void) |
philpem@0 | 716 | { |
philpem@0 | 717 | sprintf(g_dasm_str, "addx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 718 | } |
philpem@0 | 719 | |
philpem@0 | 720 | static void d68000_addx_mm_8(void) |
philpem@0 | 721 | { |
philpem@0 | 722 | sprintf(g_dasm_str, "addx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 723 | } |
philpem@0 | 724 | |
philpem@0 | 725 | static void d68000_addx_mm_16(void) |
philpem@0 | 726 | { |
philpem@0 | 727 | sprintf(g_dasm_str, "addx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 728 | } |
philpem@0 | 729 | |
philpem@0 | 730 | static void d68000_addx_mm_32(void) |
philpem@0 | 731 | { |
philpem@0 | 732 | sprintf(g_dasm_str, "addx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 733 | } |
philpem@0 | 734 | |
philpem@0 | 735 | static void d68000_and_er_8(void) |
philpem@0 | 736 | { |
philpem@0 | 737 | sprintf(g_dasm_str, "and.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 738 | } |
philpem@0 | 739 | |
philpem@0 | 740 | static void d68000_and_er_16(void) |
philpem@0 | 741 | { |
philpem@0 | 742 | sprintf(g_dasm_str, "and.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 743 | } |
philpem@0 | 744 | |
philpem@0 | 745 | static void d68000_and_er_32(void) |
philpem@0 | 746 | { |
philpem@0 | 747 | sprintf(g_dasm_str, "and.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 748 | } |
philpem@0 | 749 | |
philpem@0 | 750 | static void d68000_and_re_8(void) |
philpem@0 | 751 | { |
philpem@0 | 752 | sprintf(g_dasm_str, "and.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 753 | } |
philpem@0 | 754 | |
philpem@0 | 755 | static void d68000_and_re_16(void) |
philpem@0 | 756 | { |
philpem@0 | 757 | sprintf(g_dasm_str, "and.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 758 | } |
philpem@0 | 759 | |
philpem@0 | 760 | static void d68000_and_re_32(void) |
philpem@0 | 761 | { |
philpem@0 | 762 | sprintf(g_dasm_str, "and.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 763 | } |
philpem@0 | 764 | |
philpem@0 | 765 | static void d68000_andi_8(void) |
philpem@0 | 766 | { |
philpem@0 | 767 | char* str = get_imm_str_u8(); |
philpem@0 | 768 | sprintf(g_dasm_str, "andi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 769 | } |
philpem@0 | 770 | |
philpem@0 | 771 | static void d68000_andi_16(void) |
philpem@0 | 772 | { |
philpem@0 | 773 | char* str = get_imm_str_u16(); |
philpem@0 | 774 | sprintf(g_dasm_str, "andi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 775 | } |
philpem@0 | 776 | |
philpem@0 | 777 | static void d68000_andi_32(void) |
philpem@0 | 778 | { |
philpem@0 | 779 | char* str = get_imm_str_u32(); |
philpem@0 | 780 | sprintf(g_dasm_str, "andi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 781 | } |
philpem@0 | 782 | |
philpem@0 | 783 | static void d68000_andi_to_ccr(void) |
philpem@0 | 784 | { |
philpem@0 | 785 | sprintf(g_dasm_str, "andi %s, CCR", get_imm_str_u8()); |
philpem@0 | 786 | } |
philpem@0 | 787 | |
philpem@0 | 788 | static void d68000_andi_to_sr(void) |
philpem@0 | 789 | { |
philpem@0 | 790 | sprintf(g_dasm_str, "andi %s, SR", get_imm_str_u16()); |
philpem@0 | 791 | } |
philpem@0 | 792 | |
philpem@0 | 793 | static void d68000_asr_s_8(void) |
philpem@0 | 794 | { |
philpem@0 | 795 | sprintf(g_dasm_str, "asr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 796 | } |
philpem@0 | 797 | |
philpem@0 | 798 | static void d68000_asr_s_16(void) |
philpem@0 | 799 | { |
philpem@0 | 800 | sprintf(g_dasm_str, "asr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 801 | } |
philpem@0 | 802 | |
philpem@0 | 803 | static void d68000_asr_s_32(void) |
philpem@0 | 804 | { |
philpem@0 | 805 | sprintf(g_dasm_str, "asr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 806 | } |
philpem@0 | 807 | |
philpem@0 | 808 | static void d68000_asr_r_8(void) |
philpem@0 | 809 | { |
philpem@0 | 810 | sprintf(g_dasm_str, "asr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 811 | } |
philpem@0 | 812 | |
philpem@0 | 813 | static void d68000_asr_r_16(void) |
philpem@0 | 814 | { |
philpem@0 | 815 | sprintf(g_dasm_str, "asr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 816 | } |
philpem@0 | 817 | |
philpem@0 | 818 | static void d68000_asr_r_32(void) |
philpem@0 | 819 | { |
philpem@0 | 820 | sprintf(g_dasm_str, "asr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 821 | } |
philpem@0 | 822 | |
philpem@0 | 823 | static void d68000_asr_ea(void) |
philpem@0 | 824 | { |
philpem@0 | 825 | sprintf(g_dasm_str, "asr.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 826 | } |
philpem@0 | 827 | |
philpem@0 | 828 | static void d68000_asl_s_8(void) |
philpem@0 | 829 | { |
philpem@0 | 830 | sprintf(g_dasm_str, "asl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 831 | } |
philpem@0 | 832 | |
philpem@0 | 833 | static void d68000_asl_s_16(void) |
philpem@0 | 834 | { |
philpem@0 | 835 | sprintf(g_dasm_str, "asl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 836 | } |
philpem@0 | 837 | |
philpem@0 | 838 | static void d68000_asl_s_32(void) |
philpem@0 | 839 | { |
philpem@0 | 840 | sprintf(g_dasm_str, "asl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 841 | } |
philpem@0 | 842 | |
philpem@0 | 843 | static void d68000_asl_r_8(void) |
philpem@0 | 844 | { |
philpem@0 | 845 | sprintf(g_dasm_str, "asl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 846 | } |
philpem@0 | 847 | |
philpem@0 | 848 | static void d68000_asl_r_16(void) |
philpem@0 | 849 | { |
philpem@0 | 850 | sprintf(g_dasm_str, "asl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 851 | } |
philpem@0 | 852 | |
philpem@0 | 853 | static void d68000_asl_r_32(void) |
philpem@0 | 854 | { |
philpem@0 | 855 | sprintf(g_dasm_str, "asl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 856 | } |
philpem@0 | 857 | |
philpem@0 | 858 | static void d68000_asl_ea(void) |
philpem@0 | 859 | { |
philpem@0 | 860 | sprintf(g_dasm_str, "asl.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 861 | } |
philpem@0 | 862 | |
philpem@0 | 863 | static void d68000_bcc_8(void) |
philpem@0 | 864 | { |
philpem@0 | 865 | uint temp_pc = g_cpu_pc; |
philpem@0 | 866 | sprintf(g_dasm_str, "b%-2s %x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_8(g_cpu_ir)); |
philpem@0 | 867 | } |
philpem@0 | 868 | |
philpem@0 | 869 | static void d68000_bcc_16(void) |
philpem@0 | 870 | { |
philpem@0 | 871 | uint temp_pc = g_cpu_pc; |
philpem@0 | 872 | sprintf(g_dasm_str, "b%-2s %x", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + make_int_16(read_imm_16())); |
philpem@0 | 873 | } |
philpem@0 | 874 | |
philpem@0 | 875 | static void d68020_bcc_32(void) |
philpem@0 | 876 | { |
philpem@0 | 877 | uint temp_pc = g_cpu_pc; |
philpem@0 | 878 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 879 | sprintf(g_dasm_str, "b%-2s %x; (2+)", g_cc[(g_cpu_ir>>8)&0xf], temp_pc + read_imm_32()); |
philpem@0 | 880 | } |
philpem@0 | 881 | |
philpem@0 | 882 | static void d68000_bchg_r(void) |
philpem@0 | 883 | { |
philpem@0 | 884 | sprintf(g_dasm_str, "bchg D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 885 | } |
philpem@0 | 886 | |
philpem@0 | 887 | static void d68000_bchg_s(void) |
philpem@0 | 888 | { |
philpem@0 | 889 | char* str = get_imm_str_u8(); |
philpem@0 | 890 | sprintf(g_dasm_str, "bchg %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 891 | } |
philpem@0 | 892 | |
philpem@0 | 893 | static void d68000_bclr_r(void) |
philpem@0 | 894 | { |
philpem@0 | 895 | sprintf(g_dasm_str, "bclr D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 896 | } |
philpem@0 | 897 | |
philpem@0 | 898 | static void d68000_bclr_s(void) |
philpem@0 | 899 | { |
philpem@0 | 900 | char* str = get_imm_str_u8(); |
philpem@0 | 901 | sprintf(g_dasm_str, "bclr %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 902 | } |
philpem@0 | 903 | |
philpem@0 | 904 | static void d68010_bkpt(void) |
philpem@0 | 905 | { |
philpem@0 | 906 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 907 | sprintf(g_dasm_str, "bkpt #%d; (1+)", g_cpu_ir&7); |
philpem@0 | 908 | } |
philpem@0 | 909 | |
philpem@0 | 910 | static void d68020_bfchg(void) |
philpem@0 | 911 | { |
philpem@0 | 912 | uint extension; |
philpem@0 | 913 | char offset[3]; |
philpem@0 | 914 | char width[3]; |
philpem@0 | 915 | |
philpem@0 | 916 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 917 | |
philpem@0 | 918 | extension = read_imm_16(); |
philpem@0 | 919 | |
philpem@0 | 920 | if(BIT_B(extension)) |
philpem@0 | 921 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 922 | else |
philpem@0 | 923 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 924 | if(BIT_5(extension)) |
philpem@0 | 925 | sprintf(width, "D%d", extension&7); |
philpem@0 | 926 | else |
philpem@0 | 927 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 928 | sprintf(g_dasm_str, "bfchg %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 929 | } |
philpem@0 | 930 | |
philpem@0 | 931 | static void d68020_bfclr(void) |
philpem@0 | 932 | { |
philpem@0 | 933 | uint extension; |
philpem@0 | 934 | char offset[3]; |
philpem@0 | 935 | char width[3]; |
philpem@0 | 936 | |
philpem@0 | 937 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 938 | |
philpem@0 | 939 | extension = read_imm_16(); |
philpem@0 | 940 | |
philpem@0 | 941 | if(BIT_B(extension)) |
philpem@0 | 942 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 943 | else |
philpem@0 | 944 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 945 | if(BIT_5(extension)) |
philpem@0 | 946 | sprintf(width, "D%d", extension&7); |
philpem@0 | 947 | else |
philpem@0 | 948 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 949 | sprintf(g_dasm_str, "bfclr %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 950 | } |
philpem@0 | 951 | |
philpem@0 | 952 | static void d68020_bfexts(void) |
philpem@0 | 953 | { |
philpem@0 | 954 | uint extension; |
philpem@0 | 955 | char offset[3]; |
philpem@0 | 956 | char width[3]; |
philpem@0 | 957 | |
philpem@0 | 958 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 959 | |
philpem@0 | 960 | extension = read_imm_16(); |
philpem@0 | 961 | |
philpem@0 | 962 | if(BIT_B(extension)) |
philpem@0 | 963 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 964 | else |
philpem@0 | 965 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 966 | if(BIT_5(extension)) |
philpem@0 | 967 | sprintf(width, "D%d", extension&7); |
philpem@0 | 968 | else |
philpem@0 | 969 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 970 | sprintf(g_dasm_str, "bfexts D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 971 | } |
philpem@0 | 972 | |
philpem@0 | 973 | static void d68020_bfextu(void) |
philpem@0 | 974 | { |
philpem@0 | 975 | uint extension; |
philpem@0 | 976 | char offset[3]; |
philpem@0 | 977 | char width[3]; |
philpem@0 | 978 | |
philpem@0 | 979 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 980 | |
philpem@0 | 981 | extension = read_imm_16(); |
philpem@0 | 982 | |
philpem@0 | 983 | if(BIT_B(extension)) |
philpem@0 | 984 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 985 | else |
philpem@0 | 986 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 987 | if(BIT_5(extension)) |
philpem@0 | 988 | sprintf(width, "D%d", extension&7); |
philpem@0 | 989 | else |
philpem@0 | 990 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 991 | sprintf(g_dasm_str, "bfextu D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 992 | } |
philpem@0 | 993 | |
philpem@0 | 994 | static void d68020_bfffo(void) |
philpem@0 | 995 | { |
philpem@0 | 996 | uint extension; |
philpem@0 | 997 | char offset[3]; |
philpem@0 | 998 | char width[3]; |
philpem@0 | 999 | |
philpem@0 | 1000 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1001 | |
philpem@0 | 1002 | extension = read_imm_16(); |
philpem@0 | 1003 | |
philpem@0 | 1004 | if(BIT_B(extension)) |
philpem@0 | 1005 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 1006 | else |
philpem@0 | 1007 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 1008 | if(BIT_5(extension)) |
philpem@0 | 1009 | sprintf(width, "D%d", extension&7); |
philpem@0 | 1010 | else |
philpem@0 | 1011 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 1012 | sprintf(g_dasm_str, "bfffo D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 1013 | } |
philpem@0 | 1014 | |
philpem@0 | 1015 | static void d68020_bfins(void) |
philpem@0 | 1016 | { |
philpem@0 | 1017 | uint extension; |
philpem@0 | 1018 | char offset[3]; |
philpem@0 | 1019 | char width[3]; |
philpem@0 | 1020 | |
philpem@0 | 1021 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1022 | |
philpem@0 | 1023 | extension = read_imm_16(); |
philpem@0 | 1024 | |
philpem@0 | 1025 | if(BIT_B(extension)) |
philpem@0 | 1026 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 1027 | else |
philpem@0 | 1028 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 1029 | if(BIT_5(extension)) |
philpem@0 | 1030 | sprintf(width, "D%d", extension&7); |
philpem@0 | 1031 | else |
philpem@0 | 1032 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 1033 | sprintf(g_dasm_str, "bfins D%d, %s {%s:%s}; (2+)", (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 1034 | } |
philpem@0 | 1035 | |
philpem@0 | 1036 | static void d68020_bfset(void) |
philpem@0 | 1037 | { |
philpem@0 | 1038 | uint extension; |
philpem@0 | 1039 | char offset[3]; |
philpem@0 | 1040 | char width[3]; |
philpem@0 | 1041 | |
philpem@0 | 1042 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1043 | |
philpem@0 | 1044 | extension = read_imm_16(); |
philpem@0 | 1045 | |
philpem@0 | 1046 | if(BIT_B(extension)) |
philpem@0 | 1047 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 1048 | else |
philpem@0 | 1049 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 1050 | if(BIT_5(extension)) |
philpem@0 | 1051 | sprintf(width, "D%d", extension&7); |
philpem@0 | 1052 | else |
philpem@0 | 1053 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 1054 | sprintf(g_dasm_str, "bfset %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 1055 | } |
philpem@0 | 1056 | |
philpem@0 | 1057 | static void d68020_bftst(void) |
philpem@0 | 1058 | { |
philpem@0 | 1059 | uint extension; |
philpem@0 | 1060 | char offset[3]; |
philpem@0 | 1061 | char width[3]; |
philpem@0 | 1062 | |
philpem@0 | 1063 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1064 | |
philpem@0 | 1065 | extension = read_imm_16(); |
philpem@0 | 1066 | |
philpem@0 | 1067 | if(BIT_B(extension)) |
philpem@0 | 1068 | sprintf(offset, "D%d", (extension>>6)&7); |
philpem@0 | 1069 | else |
philpem@0 | 1070 | sprintf(offset, "%d", (extension>>6)&31); |
philpem@0 | 1071 | if(BIT_5(extension)) |
philpem@0 | 1072 | sprintf(width, "D%d", extension&7); |
philpem@0 | 1073 | else |
philpem@0 | 1074 | sprintf(width, "%d", g_5bit_data_table[extension&31]); |
philpem@0 | 1075 | sprintf(g_dasm_str, "bftst %s {%s:%s}; (2+)", get_ea_mode_str_8(g_cpu_ir), offset, width); |
philpem@0 | 1076 | } |
philpem@0 | 1077 | |
philpem@0 | 1078 | static void d68000_bra_8(void) |
philpem@0 | 1079 | { |
philpem@0 | 1080 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1081 | sprintf(g_dasm_str, "bra %x", temp_pc + make_int_8(g_cpu_ir)); |
philpem@0 | 1082 | } |
philpem@0 | 1083 | |
philpem@0 | 1084 | static void d68000_bra_16(void) |
philpem@0 | 1085 | { |
philpem@0 | 1086 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1087 | sprintf(g_dasm_str, "bra %x", temp_pc + make_int_16(read_imm_16())); |
philpem@0 | 1088 | } |
philpem@0 | 1089 | |
philpem@0 | 1090 | static void d68020_bra_32(void) |
philpem@0 | 1091 | { |
philpem@0 | 1092 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1093 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1094 | sprintf(g_dasm_str, "bra %x; (2+)", temp_pc + read_imm_32()); |
philpem@0 | 1095 | } |
philpem@0 | 1096 | |
philpem@0 | 1097 | static void d68000_bset_r(void) |
philpem@0 | 1098 | { |
philpem@0 | 1099 | sprintf(g_dasm_str, "bset D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1100 | } |
philpem@0 | 1101 | |
philpem@0 | 1102 | static void d68000_bset_s(void) |
philpem@0 | 1103 | { |
philpem@0 | 1104 | char* str = get_imm_str_u8(); |
philpem@0 | 1105 | sprintf(g_dasm_str, "bset %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1106 | } |
philpem@0 | 1107 | |
philpem@0 | 1108 | static void d68000_bsr_8(void) |
philpem@0 | 1109 | { |
philpem@0 | 1110 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1111 | sprintf(g_dasm_str, "bsr %x", temp_pc + make_int_8(g_cpu_ir)); |
philpem@0 | 1112 | } |
philpem@0 | 1113 | |
philpem@0 | 1114 | static void d68000_bsr_16(void) |
philpem@0 | 1115 | { |
philpem@0 | 1116 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1117 | sprintf(g_dasm_str, "bsr %x", temp_pc + make_int_16(read_imm_16())); |
philpem@0 | 1118 | } |
philpem@0 | 1119 | |
philpem@0 | 1120 | static void d68020_bsr_32(void) |
philpem@0 | 1121 | { |
philpem@0 | 1122 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1123 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1124 | sprintf(g_dasm_str, "bsr %x; (2+)", temp_pc + peek_imm_32()); |
philpem@0 | 1125 | } |
philpem@0 | 1126 | |
philpem@0 | 1127 | static void d68000_btst_r(void) |
philpem@0 | 1128 | { |
philpem@0 | 1129 | sprintf(g_dasm_str, "btst D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1130 | } |
philpem@0 | 1131 | |
philpem@0 | 1132 | static void d68000_btst_s(void) |
philpem@0 | 1133 | { |
philpem@0 | 1134 | char* str = get_imm_str_u8(); |
philpem@0 | 1135 | sprintf(g_dasm_str, "btst %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1136 | } |
philpem@0 | 1137 | |
philpem@0 | 1138 | static void d68020_callm(void) |
philpem@0 | 1139 | { |
philpem@0 | 1140 | char* str; |
philpem@0 | 1141 | LIMIT_CPU_TYPES(M68020_ONLY); |
philpem@0 | 1142 | str = get_imm_str_u8(); |
philpem@0 | 1143 | |
philpem@0 | 1144 | sprintf(g_dasm_str, "callm %s, %s; (2)", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1145 | } |
philpem@0 | 1146 | |
philpem@0 | 1147 | static void d68020_cas_8(void) |
philpem@0 | 1148 | { |
philpem@0 | 1149 | uint extension; |
philpem@0 | 1150 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1151 | extension = read_imm_16(); |
philpem@0 | 1152 | sprintf(g_dasm_str, "cas.b D%d, D%d, %s; (2+)", extension&7, (extension>>8)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1153 | } |
philpem@0 | 1154 | |
philpem@0 | 1155 | static void d68020_cas_16(void) |
philpem@0 | 1156 | { |
philpem@0 | 1157 | uint extension; |
philpem@0 | 1158 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1159 | extension = read_imm_16(); |
philpem@0 | 1160 | sprintf(g_dasm_str, "cas.w D%d, D%d, %s; (2+)", extension&7, (extension>>8)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1161 | } |
philpem@0 | 1162 | |
philpem@0 | 1163 | static void d68020_cas_32(void) |
philpem@0 | 1164 | { |
philpem@0 | 1165 | uint extension; |
philpem@0 | 1166 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1167 | extension = read_imm_16(); |
philpem@0 | 1168 | sprintf(g_dasm_str, "cas.l D%d, D%d, %s; (2+)", extension&7, (extension>>8)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1169 | } |
philpem@0 | 1170 | |
philpem@0 | 1171 | static void d68020_cas2_16(void) |
philpem@0 | 1172 | { |
philpem@0 | 1173 | /* CAS2 Dc1:Dc2,Du1:Dc2:(Rn1):(Rn2) |
philpem@0 | 1174 | f e d c b a 9 8 7 6 5 4 3 2 1 0 |
philpem@0 | 1175 | DARn1 0 0 0 Du1 0 0 0 Dc1 |
philpem@0 | 1176 | DARn2 0 0 0 Du2 0 0 0 Dc2 |
philpem@0 | 1177 | */ |
philpem@0 | 1178 | |
philpem@0 | 1179 | uint extension; |
philpem@0 | 1180 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1181 | extension = read_imm_32(); |
philpem@0 | 1182 | sprintf(g_dasm_str, "cas2.w D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)", |
philpem@0 | 1183 | (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7, |
philpem@0 | 1184 | BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7, |
philpem@0 | 1185 | BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 1186 | } |
philpem@0 | 1187 | |
philpem@0 | 1188 | static void d68020_cas2_32(void) |
philpem@0 | 1189 | { |
philpem@0 | 1190 | uint extension; |
philpem@0 | 1191 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1192 | extension = read_imm_32(); |
philpem@0 | 1193 | sprintf(g_dasm_str, "cas2.l D%d:D%d:D%d:D%d, (%c%d):(%c%d); (2+)", |
philpem@0 | 1194 | (extension>>16)&7, extension&7, (extension>>22)&7, (extension>>6)&7, |
philpem@0 | 1195 | BIT_1F(extension) ? 'A' : 'D', (extension>>28)&7, |
philpem@0 | 1196 | BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 1197 | } |
philpem@0 | 1198 | |
philpem@0 | 1199 | static void d68000_chk_16(void) |
philpem@0 | 1200 | { |
philpem@0 | 1201 | sprintf(g_dasm_str, "chk.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1202 | } |
philpem@0 | 1203 | |
philpem@0 | 1204 | static void d68020_chk_32(void) |
philpem@0 | 1205 | { |
philpem@0 | 1206 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1207 | sprintf(g_dasm_str, "chk.l %s, D%d; (2+)", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1208 | } |
philpem@0 | 1209 | |
philpem@0 | 1210 | static void d68020_chk2_cmp2_8(void) |
philpem@0 | 1211 | { |
philpem@0 | 1212 | uint extension; |
philpem@0 | 1213 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1214 | extension = read_imm_16(); |
philpem@0 | 1215 | sprintf(g_dasm_str, "%s.b %s, %c%d; (2+)", BIT_B(extension) ? "chk2" : "cmp2", get_ea_mode_str_8(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 1216 | } |
philpem@0 | 1217 | |
philpem@0 | 1218 | static void d68020_chk2_cmp2_16(void) |
philpem@0 | 1219 | { |
philpem@0 | 1220 | uint extension; |
philpem@0 | 1221 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1222 | extension = read_imm_16(); |
philpem@0 | 1223 | sprintf(g_dasm_str, "%s.w %s, %c%d; (2+)", BIT_B(extension) ? "chk2" : "cmp2", get_ea_mode_str_16(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 1224 | } |
philpem@0 | 1225 | |
philpem@0 | 1226 | static void d68020_chk2_cmp2_32(void) |
philpem@0 | 1227 | { |
philpem@0 | 1228 | uint extension; |
philpem@0 | 1229 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1230 | extension = read_imm_16(); |
philpem@0 | 1231 | sprintf(g_dasm_str, "%s.l %s, %c%d; (2+)", BIT_B(extension) ? "chk2" : "cmp2", get_ea_mode_str_32(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 1232 | } |
philpem@0 | 1233 | |
philpem@0 | 1234 | static void d68040_cinv(void) |
philpem@0 | 1235 | { |
philpem@0 | 1236 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 1237 | switch((g_cpu_ir>>3)&3) |
philpem@0 | 1238 | { |
philpem@0 | 1239 | case 0: |
philpem@0 | 1240 | sprintf(g_dasm_str, "cinv (illegal scope); (4)"); |
philpem@0 | 1241 | break; |
philpem@0 | 1242 | case 1: |
philpem@0 | 1243 | sprintf(g_dasm_str, "cinvl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7); |
philpem@0 | 1244 | break; |
philpem@0 | 1245 | case 2: |
philpem@0 | 1246 | sprintf(g_dasm_str, "cinvp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7); |
philpem@0 | 1247 | break; |
philpem@0 | 1248 | case 3: |
philpem@0 | 1249 | sprintf(g_dasm_str, "cinva %d; (4)", (g_cpu_ir>>6)&3); |
philpem@0 | 1250 | break; |
philpem@0 | 1251 | } |
philpem@0 | 1252 | } |
philpem@0 | 1253 | |
philpem@0 | 1254 | static void d68000_clr_8(void) |
philpem@0 | 1255 | { |
philpem@0 | 1256 | sprintf(g_dasm_str, "clr.b %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1257 | } |
philpem@0 | 1258 | |
philpem@0 | 1259 | static void d68000_clr_16(void) |
philpem@0 | 1260 | { |
philpem@0 | 1261 | sprintf(g_dasm_str, "clr.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1262 | } |
philpem@0 | 1263 | |
philpem@0 | 1264 | static void d68000_clr_32(void) |
philpem@0 | 1265 | { |
philpem@0 | 1266 | sprintf(g_dasm_str, "clr.l %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1267 | } |
philpem@0 | 1268 | |
philpem@0 | 1269 | static void d68000_cmp_8(void) |
philpem@0 | 1270 | { |
philpem@0 | 1271 | sprintf(g_dasm_str, "cmp.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1272 | } |
philpem@0 | 1273 | |
philpem@0 | 1274 | static void d68000_cmp_16(void) |
philpem@0 | 1275 | { |
philpem@0 | 1276 | sprintf(g_dasm_str, "cmp.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1277 | } |
philpem@0 | 1278 | |
philpem@0 | 1279 | static void d68000_cmp_32(void) |
philpem@0 | 1280 | { |
philpem@0 | 1281 | sprintf(g_dasm_str, "cmp.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1282 | } |
philpem@0 | 1283 | |
philpem@0 | 1284 | static void d68000_cmpa_16(void) |
philpem@0 | 1285 | { |
philpem@0 | 1286 | sprintf(g_dasm_str, "cmpa.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1287 | } |
philpem@0 | 1288 | |
philpem@0 | 1289 | static void d68000_cmpa_32(void) |
philpem@0 | 1290 | { |
philpem@0 | 1291 | sprintf(g_dasm_str, "cmpa.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1292 | } |
philpem@0 | 1293 | |
philpem@0 | 1294 | static void d68000_cmpi_8(void) |
philpem@0 | 1295 | { |
philpem@0 | 1296 | char* str = get_imm_str_s8(); |
philpem@0 | 1297 | sprintf(g_dasm_str, "cmpi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1298 | } |
philpem@0 | 1299 | |
philpem@0 | 1300 | static void d68020_cmpi_pcdi_8(void) |
philpem@0 | 1301 | { |
philpem@0 | 1302 | char* str; |
philpem@0 | 1303 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1304 | str = get_imm_str_s8(); |
philpem@0 | 1305 | sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1306 | } |
philpem@0 | 1307 | |
philpem@0 | 1308 | static void d68020_cmpi_pcix_8(void) |
philpem@0 | 1309 | { |
philpem@0 | 1310 | char* str; |
philpem@0 | 1311 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1312 | str = get_imm_str_s8(); |
philpem@0 | 1313 | sprintf(g_dasm_str, "cmpi.b %s, %s; (2+)", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1314 | } |
philpem@0 | 1315 | |
philpem@0 | 1316 | static void d68000_cmpi_16(void) |
philpem@0 | 1317 | { |
philpem@0 | 1318 | char* str; |
philpem@0 | 1319 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1320 | str = get_imm_str_s16(); |
philpem@0 | 1321 | sprintf(g_dasm_str, "cmpi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1322 | } |
philpem@0 | 1323 | |
philpem@0 | 1324 | static void d68020_cmpi_pcdi_16(void) |
philpem@0 | 1325 | { |
philpem@0 | 1326 | char* str; |
philpem@0 | 1327 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1328 | str = get_imm_str_s16(); |
philpem@0 | 1329 | sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1330 | } |
philpem@0 | 1331 | |
philpem@0 | 1332 | static void d68020_cmpi_pcix_16(void) |
philpem@0 | 1333 | { |
philpem@0 | 1334 | char* str; |
philpem@0 | 1335 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1336 | str = get_imm_str_s16(); |
philpem@0 | 1337 | sprintf(g_dasm_str, "cmpi.w %s, %s; (2+)", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1338 | } |
philpem@0 | 1339 | |
philpem@0 | 1340 | static void d68000_cmpi_32(void) |
philpem@0 | 1341 | { |
philpem@0 | 1342 | char* str; |
philpem@0 | 1343 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1344 | str = get_imm_str_s32(); |
philpem@0 | 1345 | sprintf(g_dasm_str, "cmpi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1346 | } |
philpem@0 | 1347 | |
philpem@0 | 1348 | static void d68020_cmpi_pcdi_32(void) |
philpem@0 | 1349 | { |
philpem@0 | 1350 | char* str; |
philpem@0 | 1351 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1352 | str = get_imm_str_s32(); |
philpem@0 | 1353 | sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1354 | } |
philpem@0 | 1355 | |
philpem@0 | 1356 | static void d68020_cmpi_pcix_32(void) |
philpem@0 | 1357 | { |
philpem@0 | 1358 | char* str; |
philpem@0 | 1359 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1360 | str = get_imm_str_s32(); |
philpem@0 | 1361 | sprintf(g_dasm_str, "cmpi.l %s, %s; (2+)", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1362 | } |
philpem@0 | 1363 | |
philpem@0 | 1364 | static void d68000_cmpm_8(void) |
philpem@0 | 1365 | { |
philpem@0 | 1366 | sprintf(g_dasm_str, "cmpm.b (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 1367 | } |
philpem@0 | 1368 | |
philpem@0 | 1369 | static void d68000_cmpm_16(void) |
philpem@0 | 1370 | { |
philpem@0 | 1371 | sprintf(g_dasm_str, "cmpm.w (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 1372 | } |
philpem@0 | 1373 | |
philpem@0 | 1374 | static void d68000_cmpm_32(void) |
philpem@0 | 1375 | { |
philpem@0 | 1376 | sprintf(g_dasm_str, "cmpm.l (A%d)+, (A%d)+", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 1377 | } |
philpem@0 | 1378 | |
philpem@0 | 1379 | static void d68020_cpbcc_16(void) |
philpem@0 | 1380 | { |
philpem@0 | 1381 | uint extension; |
philpem@0 | 1382 | uint new_pc = g_cpu_pc; |
philpem@0 | 1383 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1384 | extension = read_imm_16(); |
philpem@0 | 1385 | new_pc += make_int_16(peek_imm_16()); |
philpem@0 | 1386 | sprintf(g_dasm_str, "%db%-4s %s; %x (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[g_cpu_ir&0x3f], get_imm_str_s16(), new_pc, extension); |
philpem@0 | 1387 | } |
philpem@0 | 1388 | |
philpem@0 | 1389 | static void d68020_cpbcc_32(void) |
philpem@0 | 1390 | { |
philpem@0 | 1391 | uint extension; |
philpem@0 | 1392 | uint new_pc = g_cpu_pc; |
philpem@0 | 1393 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1394 | extension = read_imm_16(); |
philpem@0 | 1395 | new_pc += peek_imm_32(); |
philpem@0 | 1396 | sprintf(g_dasm_str, "%db%-4s %s; %x (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[g_cpu_ir&0x3f], get_imm_str_s16(), new_pc, extension); |
philpem@0 | 1397 | } |
philpem@0 | 1398 | |
philpem@0 | 1399 | static void d68020_cpdbcc(void) |
philpem@0 | 1400 | { |
philpem@0 | 1401 | uint extension1; |
philpem@0 | 1402 | uint extension2; |
philpem@0 | 1403 | uint new_pc = g_cpu_pc; |
philpem@0 | 1404 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1405 | extension1 = read_imm_16(); |
philpem@0 | 1406 | extension2 = read_imm_16(); |
philpem@0 | 1407 | new_pc += make_int_16(peek_imm_16()); |
philpem@0 | 1408 | sprintf(g_dasm_str, "%ddb%-4s D%d,%s; %x (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], g_cpu_ir&7, get_imm_str_s16(), new_pc, extension2); |
philpem@0 | 1409 | } |
philpem@0 | 1410 | |
philpem@0 | 1411 | static void d68020_cpgen(void) |
philpem@0 | 1412 | { |
philpem@0 | 1413 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1414 | sprintf(g_dasm_str, "%dgen %s; (2-3)", (g_cpu_ir>>9)&7, get_imm_str_u32()); |
philpem@0 | 1415 | } |
philpem@0 | 1416 | |
philpem@0 | 1417 | static void d68020_cprestore(void) |
philpem@0 | 1418 | { |
philpem@0 | 1419 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1420 | sprintf(g_dasm_str, "%drestore %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1421 | } |
philpem@0 | 1422 | |
philpem@0 | 1423 | static void d68020_cpsave(void) |
philpem@0 | 1424 | { |
philpem@0 | 1425 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1426 | sprintf(g_dasm_str, "%dsave %s; (2-3)", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1427 | } |
philpem@0 | 1428 | |
philpem@0 | 1429 | static void d68020_cpscc(void) |
philpem@0 | 1430 | { |
philpem@0 | 1431 | uint extension1; |
philpem@0 | 1432 | uint extension2; |
philpem@0 | 1433 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1434 | extension1 = read_imm_16(); |
philpem@0 | 1435 | extension2 = read_imm_16(); |
philpem@0 | 1436 | sprintf(g_dasm_str, "%ds%-4s %s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], get_ea_mode_str_8(g_cpu_ir), extension2); |
philpem@0 | 1437 | } |
philpem@0 | 1438 | |
philpem@0 | 1439 | static void d68020_cptrapcc_0(void) |
philpem@0 | 1440 | { |
philpem@0 | 1441 | uint extension1; |
philpem@0 | 1442 | uint extension2; |
philpem@0 | 1443 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1444 | extension1 = read_imm_16(); |
philpem@0 | 1445 | extension2 = read_imm_16(); |
philpem@0 | 1446 | sprintf(g_dasm_str, "%dtrap%-4s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], extension2); |
philpem@0 | 1447 | } |
philpem@0 | 1448 | |
philpem@0 | 1449 | static void d68020_cptrapcc_16(void) |
philpem@0 | 1450 | { |
philpem@0 | 1451 | uint extension1; |
philpem@0 | 1452 | uint extension2; |
philpem@0 | 1453 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1454 | extension1 = read_imm_16(); |
philpem@0 | 1455 | extension2 = read_imm_16(); |
philpem@0 | 1456 | sprintf(g_dasm_str, "%dtrap%-4s %s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], get_imm_str_u16(), extension2); |
philpem@0 | 1457 | } |
philpem@0 | 1458 | |
philpem@0 | 1459 | static void d68020_cptrapcc_32(void) |
philpem@0 | 1460 | { |
philpem@0 | 1461 | uint extension1; |
philpem@0 | 1462 | uint extension2; |
philpem@0 | 1463 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1464 | extension1 = read_imm_16(); |
philpem@0 | 1465 | extension2 = read_imm_16(); |
philpem@0 | 1466 | sprintf(g_dasm_str, "%dtrap%-4s %s; (extension = %x) (2-3)", (g_cpu_ir>>9)&7, g_cpcc[extension1&0x3f], get_imm_str_u32(), extension2); |
philpem@0 | 1467 | } |
philpem@0 | 1468 | |
philpem@0 | 1469 | static void d68040_cpush(void) |
philpem@0 | 1470 | { |
philpem@0 | 1471 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 1472 | switch((g_cpu_ir>>3)&3) |
philpem@0 | 1473 | { |
philpem@0 | 1474 | case 0: |
philpem@0 | 1475 | sprintf(g_dasm_str, "cpush (illegal scope); (4)"); |
philpem@0 | 1476 | break; |
philpem@0 | 1477 | case 1: |
philpem@0 | 1478 | sprintf(g_dasm_str, "cpushl %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7); |
philpem@0 | 1479 | break; |
philpem@0 | 1480 | case 2: |
philpem@0 | 1481 | sprintf(g_dasm_str, "cpushp %d, (A%d); (4)", (g_cpu_ir>>6)&3, g_cpu_ir&7); |
philpem@0 | 1482 | break; |
philpem@0 | 1483 | case 3: |
philpem@0 | 1484 | sprintf(g_dasm_str, "cpusha %d; (4)", (g_cpu_ir>>6)&3); |
philpem@0 | 1485 | break; |
philpem@0 | 1486 | } |
philpem@0 | 1487 | } |
philpem@0 | 1488 | |
philpem@0 | 1489 | static void d68000_dbra(void) |
philpem@0 | 1490 | { |
philpem@0 | 1491 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1492 | sprintf(g_dasm_str, "dbra D%d, %x", g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16())); |
philpem@0 | 1493 | } |
philpem@0 | 1494 | |
philpem@0 | 1495 | static void d68000_dbcc(void) |
philpem@0 | 1496 | { |
philpem@0 | 1497 | uint temp_pc = g_cpu_pc; |
philpem@0 | 1498 | sprintf(g_dasm_str, "db%-2s D%d, %x", g_cc[(g_cpu_ir>>8)&0xf], g_cpu_ir & 7, temp_pc + make_int_16(read_imm_16())); |
philpem@0 | 1499 | } |
philpem@0 | 1500 | |
philpem@0 | 1501 | static void d68000_divs(void) |
philpem@0 | 1502 | { |
philpem@0 | 1503 | sprintf(g_dasm_str, "divs.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1504 | } |
philpem@0 | 1505 | |
philpem@0 | 1506 | static void d68000_divu(void) |
philpem@0 | 1507 | { |
philpem@0 | 1508 | sprintf(g_dasm_str, "divu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1509 | } |
philpem@0 | 1510 | |
philpem@0 | 1511 | static void d68020_divl(void) |
philpem@0 | 1512 | { |
philpem@0 | 1513 | uint extension; |
philpem@0 | 1514 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1515 | extension = read_imm_16(); |
philpem@0 | 1516 | |
philpem@0 | 1517 | if(BIT_A(extension)) |
philpem@0 | 1518 | sprintf(g_dasm_str, "div%c.l %s, D%d:D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), extension&7, (extension>>12)&7); |
philpem@0 | 1519 | else if((extension&7) == ((extension>>12)&7)) |
philpem@0 | 1520 | sprintf(g_dasm_str, "div%c.l %s, D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), (extension>>12)&7); |
philpem@0 | 1521 | else |
philpem@0 | 1522 | sprintf(g_dasm_str, "div%cl.l %s, D%d:D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), extension&7, (extension>>12)&7); |
philpem@0 | 1523 | } |
philpem@0 | 1524 | |
philpem@0 | 1525 | static void d68000_eor_8(void) |
philpem@0 | 1526 | { |
philpem@0 | 1527 | sprintf(g_dasm_str, "eor.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1528 | } |
philpem@0 | 1529 | |
philpem@0 | 1530 | static void d68000_eor_16(void) |
philpem@0 | 1531 | { |
philpem@0 | 1532 | sprintf(g_dasm_str, "eor.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1533 | } |
philpem@0 | 1534 | |
philpem@0 | 1535 | static void d68000_eor_32(void) |
philpem@0 | 1536 | { |
philpem@0 | 1537 | sprintf(g_dasm_str, "eor.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1538 | } |
philpem@0 | 1539 | |
philpem@0 | 1540 | static void d68000_eori_8(void) |
philpem@0 | 1541 | { |
philpem@0 | 1542 | char* str = get_imm_str_u8(); |
philpem@0 | 1543 | sprintf(g_dasm_str, "eori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1544 | } |
philpem@0 | 1545 | |
philpem@0 | 1546 | static void d68000_eori_16(void) |
philpem@0 | 1547 | { |
philpem@0 | 1548 | char* str = get_imm_str_u16(); |
philpem@0 | 1549 | sprintf(g_dasm_str, "eori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1550 | } |
philpem@0 | 1551 | |
philpem@0 | 1552 | static void d68000_eori_32(void) |
philpem@0 | 1553 | { |
philpem@0 | 1554 | char* str = get_imm_str_u32(); |
philpem@0 | 1555 | sprintf(g_dasm_str, "eori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1556 | } |
philpem@0 | 1557 | |
philpem@0 | 1558 | static void d68000_eori_to_ccr(void) |
philpem@0 | 1559 | { |
philpem@0 | 1560 | sprintf(g_dasm_str, "eori %s, CCR", get_imm_str_u8()); |
philpem@0 | 1561 | } |
philpem@0 | 1562 | |
philpem@0 | 1563 | static void d68000_eori_to_sr(void) |
philpem@0 | 1564 | { |
philpem@0 | 1565 | sprintf(g_dasm_str, "eori %s, SR", get_imm_str_u16()); |
philpem@0 | 1566 | } |
philpem@0 | 1567 | |
philpem@0 | 1568 | static void d68000_exg_dd(void) |
philpem@0 | 1569 | { |
philpem@0 | 1570 | sprintf(g_dasm_str, "exg D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1571 | } |
philpem@0 | 1572 | |
philpem@0 | 1573 | static void d68000_exg_aa(void) |
philpem@0 | 1574 | { |
philpem@0 | 1575 | sprintf(g_dasm_str, "exg A%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1576 | } |
philpem@0 | 1577 | |
philpem@0 | 1578 | static void d68000_exg_da(void) |
philpem@0 | 1579 | { |
philpem@0 | 1580 | sprintf(g_dasm_str, "exg D%d, A%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1581 | } |
philpem@0 | 1582 | |
philpem@0 | 1583 | static void d68000_ext_16(void) |
philpem@0 | 1584 | { |
philpem@0 | 1585 | sprintf(g_dasm_str, "ext.w D%d", g_cpu_ir&7); |
philpem@0 | 1586 | } |
philpem@0 | 1587 | |
philpem@0 | 1588 | static void d68000_ext_32(void) |
philpem@0 | 1589 | { |
philpem@0 | 1590 | sprintf(g_dasm_str, "ext.l D%d", g_cpu_ir&7); |
philpem@0 | 1591 | } |
philpem@0 | 1592 | |
philpem@0 | 1593 | static void d68020_extb_32(void) |
philpem@0 | 1594 | { |
philpem@0 | 1595 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1596 | sprintf(g_dasm_str, "extb.l D%d; (2+)", g_cpu_ir&7); |
philpem@0 | 1597 | } |
philpem@0 | 1598 | |
philpem@0 | 1599 | static void d68000_jmp(void) |
philpem@0 | 1600 | { |
philpem@0 | 1601 | sprintf(g_dasm_str, "jmp %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1602 | } |
philpem@0 | 1603 | |
philpem@0 | 1604 | static void d68000_jsr(void) |
philpem@0 | 1605 | { |
philpem@0 | 1606 | sprintf(g_dasm_str, "jsr %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1607 | } |
philpem@0 | 1608 | |
philpem@0 | 1609 | static void d68000_lea(void) |
philpem@0 | 1610 | { |
philpem@0 | 1611 | sprintf(g_dasm_str, "lea %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1612 | } |
philpem@0 | 1613 | |
philpem@0 | 1614 | static void d68000_link_16(void) |
philpem@0 | 1615 | { |
philpem@0 | 1616 | sprintf(g_dasm_str, "link A%d, %s", g_cpu_ir&7, get_imm_str_s16()); |
philpem@0 | 1617 | } |
philpem@0 | 1618 | |
philpem@0 | 1619 | static void d68020_link_32(void) |
philpem@0 | 1620 | { |
philpem@0 | 1621 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 1622 | sprintf(g_dasm_str, "link A%d, %s; (2+)", g_cpu_ir&7, get_imm_str_s32()); |
philpem@0 | 1623 | } |
philpem@0 | 1624 | |
philpem@0 | 1625 | static void d68000_lsr_s_8(void) |
philpem@0 | 1626 | { |
philpem@0 | 1627 | sprintf(g_dasm_str, "lsr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 1628 | } |
philpem@0 | 1629 | |
philpem@0 | 1630 | static void d68000_lsr_s_16(void) |
philpem@0 | 1631 | { |
philpem@0 | 1632 | sprintf(g_dasm_str, "lsr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 1633 | } |
philpem@0 | 1634 | |
philpem@0 | 1635 | static void d68000_lsr_s_32(void) |
philpem@0 | 1636 | { |
philpem@0 | 1637 | sprintf(g_dasm_str, "lsr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 1638 | } |
philpem@0 | 1639 | |
philpem@0 | 1640 | static void d68000_lsr_r_8(void) |
philpem@0 | 1641 | { |
philpem@0 | 1642 | sprintf(g_dasm_str, "lsr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1643 | } |
philpem@0 | 1644 | |
philpem@0 | 1645 | static void d68000_lsr_r_16(void) |
philpem@0 | 1646 | { |
philpem@0 | 1647 | sprintf(g_dasm_str, "lsr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1648 | } |
philpem@0 | 1649 | |
philpem@0 | 1650 | static void d68000_lsr_r_32(void) |
philpem@0 | 1651 | { |
philpem@0 | 1652 | sprintf(g_dasm_str, "lsr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1653 | } |
philpem@0 | 1654 | |
philpem@0 | 1655 | static void d68000_lsr_ea(void) |
philpem@0 | 1656 | { |
philpem@0 | 1657 | sprintf(g_dasm_str, "lsr.w %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1658 | } |
philpem@0 | 1659 | |
philpem@0 | 1660 | static void d68000_lsl_s_8(void) |
philpem@0 | 1661 | { |
philpem@0 | 1662 | sprintf(g_dasm_str, "lsl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 1663 | } |
philpem@0 | 1664 | |
philpem@0 | 1665 | static void d68000_lsl_s_16(void) |
philpem@0 | 1666 | { |
philpem@0 | 1667 | sprintf(g_dasm_str, "lsl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 1668 | } |
philpem@0 | 1669 | |
philpem@0 | 1670 | static void d68000_lsl_s_32(void) |
philpem@0 | 1671 | { |
philpem@0 | 1672 | sprintf(g_dasm_str, "lsl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 1673 | } |
philpem@0 | 1674 | |
philpem@0 | 1675 | static void d68000_lsl_r_8(void) |
philpem@0 | 1676 | { |
philpem@0 | 1677 | sprintf(g_dasm_str, "lsl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1678 | } |
philpem@0 | 1679 | |
philpem@0 | 1680 | static void d68000_lsl_r_16(void) |
philpem@0 | 1681 | { |
philpem@0 | 1682 | sprintf(g_dasm_str, "lsl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1683 | } |
philpem@0 | 1684 | |
philpem@0 | 1685 | static void d68000_lsl_r_32(void) |
philpem@0 | 1686 | { |
philpem@0 | 1687 | sprintf(g_dasm_str, "lsl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 1688 | } |
philpem@0 | 1689 | |
philpem@0 | 1690 | static void d68000_lsl_ea(void) |
philpem@0 | 1691 | { |
philpem@0 | 1692 | sprintf(g_dasm_str, "lsl.w %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1693 | } |
philpem@0 | 1694 | |
philpem@0 | 1695 | static void d68000_move_8(void) |
philpem@0 | 1696 | { |
philpem@0 | 1697 | char* str = get_ea_mode_str_8(g_cpu_ir); |
philpem@0 | 1698 | sprintf(g_dasm_str, "move.b %s, %s", str, get_ea_mode_str_8(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38))); |
philpem@0 | 1699 | } |
philpem@0 | 1700 | |
philpem@0 | 1701 | static void d68000_move_16(void) |
philpem@0 | 1702 | { |
philpem@0 | 1703 | char* str = get_ea_mode_str_16(g_cpu_ir); |
philpem@0 | 1704 | sprintf(g_dasm_str, "move.w %s, %s", str, get_ea_mode_str_16(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38))); |
philpem@0 | 1705 | } |
philpem@0 | 1706 | |
philpem@0 | 1707 | static void d68000_move_32(void) |
philpem@0 | 1708 | { |
philpem@0 | 1709 | char* str = get_ea_mode_str_32(g_cpu_ir); |
philpem@0 | 1710 | sprintf(g_dasm_str, "move.l %s, %s", str, get_ea_mode_str_32(((g_cpu_ir>>9) & 7) | ((g_cpu_ir>>3) & 0x38))); |
philpem@0 | 1711 | } |
philpem@0 | 1712 | |
philpem@0 | 1713 | static void d68000_movea_16(void) |
philpem@0 | 1714 | { |
philpem@0 | 1715 | sprintf(g_dasm_str, "movea.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1716 | } |
philpem@0 | 1717 | |
philpem@0 | 1718 | static void d68000_movea_32(void) |
philpem@0 | 1719 | { |
philpem@0 | 1720 | sprintf(g_dasm_str, "movea.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 1721 | } |
philpem@0 | 1722 | |
philpem@0 | 1723 | static void d68000_move_to_ccr(void) |
philpem@0 | 1724 | { |
philpem@0 | 1725 | sprintf(g_dasm_str, "move %s, CCR", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1726 | } |
philpem@0 | 1727 | |
philpem@0 | 1728 | static void d68010_move_fr_ccr(void) |
philpem@0 | 1729 | { |
philpem@0 | 1730 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 1731 | sprintf(g_dasm_str, "move CCR, %s; (1+)", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 1732 | } |
philpem@0 | 1733 | |
philpem@0 | 1734 | static void d68000_move_fr_sr(void) |
philpem@0 | 1735 | { |
philpem@0 | 1736 | sprintf(g_dasm_str, "move SR, %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1737 | } |
philpem@0 | 1738 | |
philpem@0 | 1739 | static void d68000_move_to_sr(void) |
philpem@0 | 1740 | { |
philpem@0 | 1741 | sprintf(g_dasm_str, "move %s, SR", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1742 | } |
philpem@0 | 1743 | |
philpem@0 | 1744 | static void d68000_move_fr_usp(void) |
philpem@0 | 1745 | { |
philpem@0 | 1746 | sprintf(g_dasm_str, "move USP, A%d", g_cpu_ir&7); |
philpem@0 | 1747 | } |
philpem@0 | 1748 | |
philpem@0 | 1749 | static void d68000_move_to_usp(void) |
philpem@0 | 1750 | { |
philpem@0 | 1751 | sprintf(g_dasm_str, "move A%d, USP", g_cpu_ir&7); |
philpem@0 | 1752 | } |
philpem@0 | 1753 | |
philpem@0 | 1754 | static void d68010_movec(void) |
philpem@0 | 1755 | { |
philpem@0 | 1756 | uint extension; |
philpem@0 | 1757 | char* reg_name; |
philpem@0 | 1758 | char* processor; |
philpem@0 | 1759 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 1760 | extension = read_imm_16(); |
philpem@0 | 1761 | |
philpem@0 | 1762 | switch(extension & 0xfff) |
philpem@0 | 1763 | { |
philpem@0 | 1764 | case 0x000: |
philpem@0 | 1765 | reg_name = "SFC"; |
philpem@0 | 1766 | processor = "1+"; |
philpem@0 | 1767 | break; |
philpem@0 | 1768 | case 0x001: |
philpem@0 | 1769 | reg_name = "DFC"; |
philpem@0 | 1770 | processor = "1+"; |
philpem@0 | 1771 | break; |
philpem@0 | 1772 | case 0x800: |
philpem@0 | 1773 | reg_name = "USP"; |
philpem@0 | 1774 | processor = "1+"; |
philpem@0 | 1775 | break; |
philpem@0 | 1776 | case 0x801: |
philpem@0 | 1777 | reg_name = "VBR"; |
philpem@0 | 1778 | processor = "1+"; |
philpem@0 | 1779 | break; |
philpem@0 | 1780 | case 0x002: |
philpem@0 | 1781 | reg_name = "CACR"; |
philpem@0 | 1782 | processor = "2+"; |
philpem@0 | 1783 | break; |
philpem@0 | 1784 | case 0x802: |
philpem@0 | 1785 | reg_name = "CAAR"; |
philpem@0 | 1786 | processor = "2,3"; |
philpem@0 | 1787 | break; |
philpem@0 | 1788 | case 0x803: |
philpem@0 | 1789 | reg_name = "MSP"; |
philpem@0 | 1790 | processor = "2+"; |
philpem@0 | 1791 | break; |
philpem@0 | 1792 | case 0x804: |
philpem@0 | 1793 | reg_name = "ISP"; |
philpem@0 | 1794 | processor = "2+"; |
philpem@0 | 1795 | break; |
philpem@0 | 1796 | case 0x003: |
philpem@0 | 1797 | reg_name = "TC"; |
philpem@0 | 1798 | processor = "4+"; |
philpem@0 | 1799 | break; |
philpem@0 | 1800 | case 0x004: |
philpem@0 | 1801 | reg_name = "ITT0"; |
philpem@0 | 1802 | processor = "4+"; |
philpem@0 | 1803 | break; |
philpem@0 | 1804 | case 0x005: |
philpem@0 | 1805 | reg_name = "ITT1"; |
philpem@0 | 1806 | processor = "4+"; |
philpem@0 | 1807 | break; |
philpem@0 | 1808 | case 0x006: |
philpem@0 | 1809 | reg_name = "DTT0"; |
philpem@0 | 1810 | processor = "4+"; |
philpem@0 | 1811 | break; |
philpem@0 | 1812 | case 0x007: |
philpem@0 | 1813 | reg_name = "DTT1"; |
philpem@0 | 1814 | processor = "4+"; |
philpem@0 | 1815 | break; |
philpem@0 | 1816 | case 0x805: |
philpem@0 | 1817 | reg_name = "MMUSR"; |
philpem@0 | 1818 | processor = "4+"; |
philpem@0 | 1819 | break; |
philpem@0 | 1820 | case 0x806: |
philpem@0 | 1821 | reg_name = "URP"; |
philpem@0 | 1822 | processor = "4+"; |
philpem@0 | 1823 | break; |
philpem@0 | 1824 | case 0x807: |
philpem@0 | 1825 | reg_name = "SRP"; |
philpem@0 | 1826 | processor = "4+"; |
philpem@0 | 1827 | break; |
philpem@0 | 1828 | default: |
philpem@0 | 1829 | reg_name = make_signed_hex_str_16(extension & 0xfff); |
philpem@0 | 1830 | processor = "?"; |
philpem@0 | 1831 | } |
philpem@0 | 1832 | |
philpem@0 | 1833 | if(BIT_1(g_cpu_ir)) |
philpem@0 | 1834 | sprintf(g_dasm_str, "movec %c%d, %s; (%s)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, reg_name, processor); |
philpem@0 | 1835 | else |
philpem@0 | 1836 | sprintf(g_dasm_str, "movec %s, %c%d; (%s)", reg_name, BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, processor); |
philpem@0 | 1837 | } |
philpem@0 | 1838 | |
philpem@0 | 1839 | static void d68000_movem_pd_16(void) |
philpem@0 | 1840 | { |
philpem@0 | 1841 | uint data = read_imm_16(); |
philpem@0 | 1842 | char buffer[40]; |
philpem@0 | 1843 | uint first; |
philpem@0 | 1844 | uint run_length; |
philpem@0 | 1845 | uint i; |
philpem@0 | 1846 | |
philpem@0 | 1847 | buffer[0] = 0; |
philpem@0 | 1848 | for(i=0;i<8;i++) |
philpem@0 | 1849 | { |
philpem@0 | 1850 | if(data&(1<<(15-i))) |
philpem@0 | 1851 | { |
philpem@0 | 1852 | first = i; |
philpem@0 | 1853 | run_length = 0; |
philpem@0 | 1854 | for(i++;i<8;i++) |
philpem@0 | 1855 | if(data&(1<<(15-i))) |
philpem@0 | 1856 | run_length++; |
philpem@0 | 1857 | if(buffer[0] != 0) |
philpem@0 | 1858 | strcat(buffer, "/"); |
philpem@0 | 1859 | sprintf(buffer+strlen(buffer), "D%d", first); |
philpem@0 | 1860 | if(run_length > 0) |
philpem@0 | 1861 | sprintf(buffer+strlen(buffer), "-D%d", first + run_length); |
philpem@0 | 1862 | } |
philpem@0 | 1863 | } |
philpem@0 | 1864 | for(i=0;i<8;i++) |
philpem@0 | 1865 | { |
philpem@0 | 1866 | if(data&(1<<(7-i))) |
philpem@0 | 1867 | { |
philpem@0 | 1868 | first = i; |
philpem@0 | 1869 | run_length = 0; |
philpem@0 | 1870 | for(i++;i<8;i++) |
philpem@0 | 1871 | if(data&(1<<(7-i))) |
philpem@0 | 1872 | run_length++; |
philpem@0 | 1873 | if(buffer[0] != 0) |
philpem@0 | 1874 | strcat(buffer, "/"); |
philpem@0 | 1875 | sprintf(buffer+strlen(buffer), "A%d", first); |
philpem@0 | 1876 | if(run_length > 0) |
philpem@0 | 1877 | sprintf(buffer+strlen(buffer), "-A%d", first + run_length); |
philpem@0 | 1878 | } |
philpem@0 | 1879 | } |
philpem@0 | 1880 | sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 1881 | } |
philpem@0 | 1882 | |
philpem@0 | 1883 | static void d68000_movem_pd_32(void) |
philpem@0 | 1884 | { |
philpem@0 | 1885 | uint data = read_imm_16(); |
philpem@0 | 1886 | char buffer[40]; |
philpem@0 | 1887 | uint first; |
philpem@0 | 1888 | uint run_length; |
philpem@0 | 1889 | uint i; |
philpem@0 | 1890 | |
philpem@0 | 1891 | buffer[0] = 0; |
philpem@0 | 1892 | for(i=0;i<8;i++) |
philpem@0 | 1893 | { |
philpem@0 | 1894 | if(data&(1<<(15-i))) |
philpem@0 | 1895 | { |
philpem@0 | 1896 | first = i; |
philpem@0 | 1897 | run_length = 0; |
philpem@0 | 1898 | for(i++;i<8;i++) |
philpem@0 | 1899 | if(data&(1<<(15-i))) |
philpem@0 | 1900 | run_length++; |
philpem@0 | 1901 | if(buffer[0] != 0) |
philpem@0 | 1902 | strcat(buffer, "/"); |
philpem@0 | 1903 | sprintf(buffer+strlen(buffer), "D%d", first); |
philpem@0 | 1904 | if(run_length > 0) |
philpem@0 | 1905 | sprintf(buffer+strlen(buffer), "-D%d", first + run_length); |
philpem@0 | 1906 | } |
philpem@0 | 1907 | } |
philpem@0 | 1908 | for(i=0;i<8;i++) |
philpem@0 | 1909 | { |
philpem@0 | 1910 | if(data&(1<<(7-i))) |
philpem@0 | 1911 | { |
philpem@0 | 1912 | first = i; |
philpem@0 | 1913 | run_length = 0; |
philpem@0 | 1914 | for(i++;i<8;i++) |
philpem@0 | 1915 | if(data&(1<<(7-i))) |
philpem@0 | 1916 | run_length++; |
philpem@0 | 1917 | if(buffer[0] != 0) |
philpem@0 | 1918 | strcat(buffer, "/"); |
philpem@0 | 1919 | sprintf(buffer+strlen(buffer), "A%d", first); |
philpem@0 | 1920 | if(run_length > 0) |
philpem@0 | 1921 | sprintf(buffer+strlen(buffer), "-A%d", first + run_length); |
philpem@0 | 1922 | } |
philpem@0 | 1923 | } |
philpem@0 | 1924 | sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 1925 | } |
philpem@0 | 1926 | |
philpem@0 | 1927 | static void d68000_movem_er_16(void) |
philpem@0 | 1928 | { |
philpem@0 | 1929 | uint data = read_imm_16(); |
philpem@0 | 1930 | char buffer[40]; |
philpem@0 | 1931 | uint first; |
philpem@0 | 1932 | uint run_length; |
philpem@0 | 1933 | uint i; |
philpem@0 | 1934 | |
philpem@0 | 1935 | buffer[0] = 0; |
philpem@0 | 1936 | for(i=0;i<8;i++) |
philpem@0 | 1937 | { |
philpem@0 | 1938 | if(data&(1<<i)) |
philpem@0 | 1939 | { |
philpem@0 | 1940 | first = i; |
philpem@0 | 1941 | run_length = 0; |
philpem@0 | 1942 | for(i++;i<8;i++) |
philpem@0 | 1943 | if(data&(1<<i)) |
philpem@0 | 1944 | run_length++; |
philpem@0 | 1945 | if(buffer[0] != 0) |
philpem@0 | 1946 | strcat(buffer, "/"); |
philpem@0 | 1947 | sprintf(buffer+strlen(buffer), "D%d", first); |
philpem@0 | 1948 | if(run_length > 0) |
philpem@0 | 1949 | sprintf(buffer+strlen(buffer), "-D%d", first + run_length); |
philpem@0 | 1950 | } |
philpem@0 | 1951 | } |
philpem@0 | 1952 | for(i=0;i<8;i++) |
philpem@0 | 1953 | { |
philpem@0 | 1954 | if(data&(1<<(i+8))) |
philpem@0 | 1955 | { |
philpem@0 | 1956 | first = i; |
philpem@0 | 1957 | run_length = 0; |
philpem@0 | 1958 | for(i++;i<8;i++) |
philpem@0 | 1959 | if(data&(1<<(i+8))) |
philpem@0 | 1960 | run_length++; |
philpem@0 | 1961 | if(buffer[0] != 0) |
philpem@0 | 1962 | strcat(buffer, "/"); |
philpem@0 | 1963 | sprintf(buffer+strlen(buffer), "A%d", first); |
philpem@0 | 1964 | if(run_length > 0) |
philpem@0 | 1965 | sprintf(buffer+strlen(buffer), "-A%d", first + run_length); |
philpem@0 | 1966 | } |
philpem@0 | 1967 | } |
philpem@0 | 1968 | sprintf(g_dasm_str, "movem.w %s, %s", get_ea_mode_str_16(g_cpu_ir), buffer); |
philpem@0 | 1969 | } |
philpem@0 | 1970 | |
philpem@0 | 1971 | static void d68000_movem_er_32(void) |
philpem@0 | 1972 | { |
philpem@0 | 1973 | uint data = read_imm_16(); |
philpem@0 | 1974 | char buffer[40]; |
philpem@0 | 1975 | uint first; |
philpem@0 | 1976 | uint run_length; |
philpem@0 | 1977 | uint i; |
philpem@0 | 1978 | |
philpem@0 | 1979 | buffer[0] = 0; |
philpem@0 | 1980 | for(i=0;i<8;i++) |
philpem@0 | 1981 | { |
philpem@0 | 1982 | if(data&(1<<i)) |
philpem@0 | 1983 | { |
philpem@0 | 1984 | first = i; |
philpem@0 | 1985 | run_length = 0; |
philpem@0 | 1986 | for(i++;i<8;i++) |
philpem@0 | 1987 | if(data&(1<<i)) |
philpem@0 | 1988 | run_length++; |
philpem@0 | 1989 | if(buffer[0] != 0) |
philpem@0 | 1990 | strcat(buffer, "/"); |
philpem@0 | 1991 | sprintf(buffer+strlen(buffer), "D%d", first); |
philpem@0 | 1992 | if(run_length > 0) |
philpem@0 | 1993 | sprintf(buffer+strlen(buffer), "-D%d", first + run_length); |
philpem@0 | 1994 | } |
philpem@0 | 1995 | } |
philpem@0 | 1996 | for(i=0;i<8;i++) |
philpem@0 | 1997 | { |
philpem@0 | 1998 | if(data&(1<<(i+8))) |
philpem@0 | 1999 | { |
philpem@0 | 2000 | first = i; |
philpem@0 | 2001 | run_length = 0; |
philpem@0 | 2002 | for(i++;i<8;i++) |
philpem@0 | 2003 | if(data&(1<<(i+8))) |
philpem@0 | 2004 | run_length++; |
philpem@0 | 2005 | if(buffer[0] != 0) |
philpem@0 | 2006 | strcat(buffer, "/"); |
philpem@0 | 2007 | sprintf(buffer+strlen(buffer), "A%d", first); |
philpem@0 | 2008 | if(run_length > 0) |
philpem@0 | 2009 | sprintf(buffer+strlen(buffer), "-A%d", first + run_length); |
philpem@0 | 2010 | } |
philpem@0 | 2011 | } |
philpem@0 | 2012 | sprintf(g_dasm_str, "movem.l %s, %s", get_ea_mode_str_32(g_cpu_ir), buffer); |
philpem@0 | 2013 | } |
philpem@0 | 2014 | |
philpem@0 | 2015 | static void d68000_movem_re_16(void) |
philpem@0 | 2016 | { |
philpem@0 | 2017 | uint data = read_imm_16(); |
philpem@0 | 2018 | char buffer[40]; |
philpem@0 | 2019 | uint first; |
philpem@0 | 2020 | uint run_length; |
philpem@0 | 2021 | uint i; |
philpem@0 | 2022 | |
philpem@0 | 2023 | buffer[0] = 0; |
philpem@0 | 2024 | for(i=0;i<8;i++) |
philpem@0 | 2025 | { |
philpem@0 | 2026 | if(data&(1<<i)) |
philpem@0 | 2027 | { |
philpem@0 | 2028 | first = i; |
philpem@0 | 2029 | run_length = 0; |
philpem@0 | 2030 | for(i++;i<8;i++) |
philpem@0 | 2031 | if(data&(1<<i)) |
philpem@0 | 2032 | run_length++; |
philpem@0 | 2033 | if(buffer[0] != 0) |
philpem@0 | 2034 | strcat(buffer, "/"); |
philpem@0 | 2035 | sprintf(buffer+strlen(buffer), "D%d", first); |
philpem@0 | 2036 | if(run_length > 0) |
philpem@0 | 2037 | sprintf(buffer+strlen(buffer), "-D%d", first + run_length); |
philpem@0 | 2038 | } |
philpem@0 | 2039 | } |
philpem@0 | 2040 | for(i=0;i<8;i++) |
philpem@0 | 2041 | { |
philpem@0 | 2042 | if(data&(1<<(i+8))) |
philpem@0 | 2043 | { |
philpem@0 | 2044 | first = i; |
philpem@0 | 2045 | run_length = 0; |
philpem@0 | 2046 | for(i++;i<8;i++) |
philpem@0 | 2047 | if(data&(1<<(i+8))) |
philpem@0 | 2048 | run_length++; |
philpem@0 | 2049 | if(buffer[0] != 0) |
philpem@0 | 2050 | strcat(buffer, "/"); |
philpem@0 | 2051 | sprintf(buffer+strlen(buffer), "A%d", first); |
philpem@0 | 2052 | if(run_length > 0) |
philpem@0 | 2053 | sprintf(buffer+strlen(buffer), "-A%d", first + run_length); |
philpem@0 | 2054 | } |
philpem@0 | 2055 | } |
philpem@0 | 2056 | sprintf(g_dasm_str, "movem.w %s, %s", buffer, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2057 | } |
philpem@0 | 2058 | |
philpem@0 | 2059 | static void d68000_movem_re_32(void) |
philpem@0 | 2060 | { |
philpem@0 | 2061 | uint data = read_imm_16(); |
philpem@0 | 2062 | char buffer[40]; |
philpem@0 | 2063 | uint first; |
philpem@0 | 2064 | uint run_length; |
philpem@0 | 2065 | uint i; |
philpem@0 | 2066 | |
philpem@0 | 2067 | buffer[0] = 0; |
philpem@0 | 2068 | for(i=0;i<8;i++) |
philpem@0 | 2069 | { |
philpem@0 | 2070 | if(data&(1<<i)) |
philpem@0 | 2071 | { |
philpem@0 | 2072 | first = i; |
philpem@0 | 2073 | run_length = 0; |
philpem@0 | 2074 | for(i++;i<8;i++) |
philpem@0 | 2075 | if(data&(1<<i)) |
philpem@0 | 2076 | run_length++; |
philpem@0 | 2077 | if(buffer[0] != 0) |
philpem@0 | 2078 | strcat(buffer, "/"); |
philpem@0 | 2079 | sprintf(buffer+strlen(buffer), "D%d", first); |
philpem@0 | 2080 | if(run_length > 0) |
philpem@0 | 2081 | sprintf(buffer+strlen(buffer), "-D%d", first + run_length); |
philpem@0 | 2082 | } |
philpem@0 | 2083 | } |
philpem@0 | 2084 | for(i=0;i<8;i++) |
philpem@0 | 2085 | { |
philpem@0 | 2086 | if(data&(1<<(i+8))) |
philpem@0 | 2087 | { |
philpem@0 | 2088 | first = i; |
philpem@0 | 2089 | run_length = 0; |
philpem@0 | 2090 | for(i++;i<8;i++) |
philpem@0 | 2091 | if(data&(1<<(i+8))) |
philpem@0 | 2092 | run_length++; |
philpem@0 | 2093 | if(buffer[0] != 0) |
philpem@0 | 2094 | strcat(buffer, "/"); |
philpem@0 | 2095 | sprintf(buffer+strlen(buffer), "A%d", first); |
philpem@0 | 2096 | if(run_length > 0) |
philpem@0 | 2097 | sprintf(buffer+strlen(buffer), "-A%d", first + run_length); |
philpem@0 | 2098 | } |
philpem@0 | 2099 | } |
philpem@0 | 2100 | sprintf(g_dasm_str, "movem.l %s, %s", buffer, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2101 | } |
philpem@0 | 2102 | |
philpem@0 | 2103 | static void d68000_movep_re_16(void) |
philpem@0 | 2104 | { |
philpem@0 | 2105 | sprintf(g_dasm_str, "movep.w D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7); |
philpem@0 | 2106 | } |
philpem@0 | 2107 | |
philpem@0 | 2108 | static void d68000_movep_re_32(void) |
philpem@0 | 2109 | { |
philpem@0 | 2110 | sprintf(g_dasm_str, "movep.l D%d, ($%x,A%d)", (g_cpu_ir>>9)&7, read_imm_16(), g_cpu_ir&7); |
philpem@0 | 2111 | } |
philpem@0 | 2112 | |
philpem@0 | 2113 | static void d68000_movep_er_16(void) |
philpem@0 | 2114 | { |
philpem@0 | 2115 | sprintf(g_dasm_str, "movep.w ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2116 | } |
philpem@0 | 2117 | |
philpem@0 | 2118 | static void d68000_movep_er_32(void) |
philpem@0 | 2119 | { |
philpem@0 | 2120 | sprintf(g_dasm_str, "movep.l ($%x,A%d), D%d", read_imm_16(), g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2121 | } |
philpem@0 | 2122 | |
philpem@0 | 2123 | static void d68010_moves_8(void) |
philpem@0 | 2124 | { |
philpem@0 | 2125 | uint extension; |
philpem@0 | 2126 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 2127 | extension = read_imm_16(); |
philpem@0 | 2128 | if(BIT_B(extension)) |
philpem@0 | 2129 | sprintf(g_dasm_str, "moves.b %c%d, %s; (1+)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2130 | else |
philpem@0 | 2131 | sprintf(g_dasm_str, "moves.b %s, %c%d; (1+)", get_ea_mode_str_8(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 2132 | } |
philpem@0 | 2133 | |
philpem@0 | 2134 | static void d68010_moves_16(void) |
philpem@0 | 2135 | { |
philpem@0 | 2136 | uint extension; |
philpem@0 | 2137 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 2138 | extension = read_imm_16(); |
philpem@0 | 2139 | if(BIT_B(extension)) |
philpem@0 | 2140 | sprintf(g_dasm_str, "moves.w %c%d, %s; (1+)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2141 | else |
philpem@0 | 2142 | sprintf(g_dasm_str, "moves.w %s, %c%d; (1+)", get_ea_mode_str_16(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 2143 | } |
philpem@0 | 2144 | |
philpem@0 | 2145 | static void d68010_moves_32(void) |
philpem@0 | 2146 | { |
philpem@0 | 2147 | uint extension; |
philpem@0 | 2148 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 2149 | extension = read_imm_16(); |
philpem@0 | 2150 | if(BIT_B(extension)) |
philpem@0 | 2151 | sprintf(g_dasm_str, "moves.l %c%d, %s; (1+)", BIT_F(extension) ? 'A' : 'D', (extension>>12)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2152 | else |
philpem@0 | 2153 | sprintf(g_dasm_str, "moves.l %s, %c%d; (1+)", get_ea_mode_str_32(g_cpu_ir), BIT_F(extension) ? 'A' : 'D', (extension>>12)&7); |
philpem@0 | 2154 | } |
philpem@0 | 2155 | |
philpem@0 | 2156 | static void d68000_moveq(void) |
philpem@0 | 2157 | { |
philpem@0 | 2158 | sprintf(g_dasm_str, "moveq #%s, D%d", make_signed_hex_str_8(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2159 | } |
philpem@0 | 2160 | |
philpem@0 | 2161 | static void d68040_move16_pi_pi(void) |
philpem@0 | 2162 | { |
philpem@0 | 2163 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 2164 | sprintf(g_dasm_str, "move16 (A%d)+, (A%d)+; (4)", g_cpu_ir&7, (read_imm_16()>>12)&7); |
philpem@0 | 2165 | } |
philpem@0 | 2166 | |
philpem@0 | 2167 | static void d68040_move16_pi_al(void) |
philpem@0 | 2168 | { |
philpem@0 | 2169 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 2170 | sprintf(g_dasm_str, "move16 (A%d)+, %s; (4)", g_cpu_ir&7, get_imm_str_u32()); |
philpem@0 | 2171 | } |
philpem@0 | 2172 | |
philpem@0 | 2173 | static void d68040_move16_al_pi(void) |
philpem@0 | 2174 | { |
philpem@0 | 2175 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 2176 | sprintf(g_dasm_str, "move16 %s, (A%d)+; (4)", get_imm_str_u32(), g_cpu_ir&7); |
philpem@0 | 2177 | } |
philpem@0 | 2178 | |
philpem@0 | 2179 | static void d68040_move16_ai_al(void) |
philpem@0 | 2180 | { |
philpem@0 | 2181 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 2182 | sprintf(g_dasm_str, "move16 (A%d), %s; (4)", g_cpu_ir&7, get_imm_str_u32()); |
philpem@0 | 2183 | } |
philpem@0 | 2184 | |
philpem@0 | 2185 | static void d68040_move16_al_ai(void) |
philpem@0 | 2186 | { |
philpem@0 | 2187 | LIMIT_CPU_TYPES(M68040_PLUS); |
philpem@0 | 2188 | sprintf(g_dasm_str, "move16 %s, (A%d); (4)", get_imm_str_u32(), g_cpu_ir&7); |
philpem@0 | 2189 | } |
philpem@0 | 2190 | |
philpem@0 | 2191 | static void d68000_muls(void) |
philpem@0 | 2192 | { |
philpem@0 | 2193 | sprintf(g_dasm_str, "muls.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2194 | } |
philpem@0 | 2195 | |
philpem@0 | 2196 | static void d68000_mulu(void) |
philpem@0 | 2197 | { |
philpem@0 | 2198 | sprintf(g_dasm_str, "mulu.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2199 | } |
philpem@0 | 2200 | |
philpem@0 | 2201 | static void d68020_mull(void) |
philpem@0 | 2202 | { |
philpem@0 | 2203 | uint extension; |
philpem@0 | 2204 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2205 | extension = read_imm_16(); |
philpem@0 | 2206 | |
philpem@0 | 2207 | if(BIT_A(extension)) |
philpem@0 | 2208 | sprintf(g_dasm_str, "mul%c.l %s, D%d-D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), extension&7, (extension>>12)&7); |
philpem@0 | 2209 | else |
philpem@0 | 2210 | sprintf(g_dasm_str, "mul%c.l %s, D%d; (2+)", BIT_B(extension) ? 's' : 'u', get_ea_mode_str_32(g_cpu_ir), (extension>>12)&7); |
philpem@0 | 2211 | } |
philpem@0 | 2212 | |
philpem@0 | 2213 | static void d68000_nbcd(void) |
philpem@0 | 2214 | { |
philpem@0 | 2215 | sprintf(g_dasm_str, "nbcd %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2216 | } |
philpem@0 | 2217 | |
philpem@0 | 2218 | static void d68000_neg_8(void) |
philpem@0 | 2219 | { |
philpem@0 | 2220 | sprintf(g_dasm_str, "neg.b %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2221 | } |
philpem@0 | 2222 | |
philpem@0 | 2223 | static void d68000_neg_16(void) |
philpem@0 | 2224 | { |
philpem@0 | 2225 | sprintf(g_dasm_str, "neg.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2226 | } |
philpem@0 | 2227 | |
philpem@0 | 2228 | static void d68000_neg_32(void) |
philpem@0 | 2229 | { |
philpem@0 | 2230 | sprintf(g_dasm_str, "neg.l %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2231 | } |
philpem@0 | 2232 | |
philpem@0 | 2233 | static void d68000_negx_8(void) |
philpem@0 | 2234 | { |
philpem@0 | 2235 | sprintf(g_dasm_str, "negx.b %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2236 | } |
philpem@0 | 2237 | |
philpem@0 | 2238 | static void d68000_negx_16(void) |
philpem@0 | 2239 | { |
philpem@0 | 2240 | sprintf(g_dasm_str, "negx.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2241 | } |
philpem@0 | 2242 | |
philpem@0 | 2243 | static void d68000_negx_32(void) |
philpem@0 | 2244 | { |
philpem@0 | 2245 | sprintf(g_dasm_str, "negx.l %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2246 | } |
philpem@0 | 2247 | |
philpem@0 | 2248 | static void d68000_nop(void) |
philpem@0 | 2249 | { |
philpem@0 | 2250 | sprintf(g_dasm_str, "nop"); |
philpem@0 | 2251 | } |
philpem@0 | 2252 | |
philpem@0 | 2253 | static void d68000_not_8(void) |
philpem@0 | 2254 | { |
philpem@0 | 2255 | sprintf(g_dasm_str, "not.b %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2256 | } |
philpem@0 | 2257 | |
philpem@0 | 2258 | static void d68000_not_16(void) |
philpem@0 | 2259 | { |
philpem@0 | 2260 | sprintf(g_dasm_str, "not.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2261 | } |
philpem@0 | 2262 | |
philpem@0 | 2263 | static void d68000_not_32(void) |
philpem@0 | 2264 | { |
philpem@0 | 2265 | sprintf(g_dasm_str, "not.l %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2266 | } |
philpem@0 | 2267 | |
philpem@0 | 2268 | static void d68000_or_er_8(void) |
philpem@0 | 2269 | { |
philpem@0 | 2270 | sprintf(g_dasm_str, "or.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2271 | } |
philpem@0 | 2272 | |
philpem@0 | 2273 | static void d68000_or_er_16(void) |
philpem@0 | 2274 | { |
philpem@0 | 2275 | sprintf(g_dasm_str, "or.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2276 | } |
philpem@0 | 2277 | |
philpem@0 | 2278 | static void d68000_or_er_32(void) |
philpem@0 | 2279 | { |
philpem@0 | 2280 | sprintf(g_dasm_str, "or.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2281 | } |
philpem@0 | 2282 | |
philpem@0 | 2283 | static void d68000_or_re_8(void) |
philpem@0 | 2284 | { |
philpem@0 | 2285 | sprintf(g_dasm_str, "or.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2286 | } |
philpem@0 | 2287 | |
philpem@0 | 2288 | static void d68000_or_re_16(void) |
philpem@0 | 2289 | { |
philpem@0 | 2290 | sprintf(g_dasm_str, "or.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2291 | } |
philpem@0 | 2292 | |
philpem@0 | 2293 | static void d68000_or_re_32(void) |
philpem@0 | 2294 | { |
philpem@0 | 2295 | sprintf(g_dasm_str, "or.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2296 | } |
philpem@0 | 2297 | |
philpem@0 | 2298 | static void d68000_ori_8(void) |
philpem@0 | 2299 | { |
philpem@0 | 2300 | char* str = get_imm_str_u8(); |
philpem@0 | 2301 | sprintf(g_dasm_str, "ori.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2302 | } |
philpem@0 | 2303 | |
philpem@0 | 2304 | static void d68000_ori_16(void) |
philpem@0 | 2305 | { |
philpem@0 | 2306 | char* str = get_imm_str_u16(); |
philpem@0 | 2307 | sprintf(g_dasm_str, "ori.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2308 | } |
philpem@0 | 2309 | |
philpem@0 | 2310 | static void d68000_ori_32(void) |
philpem@0 | 2311 | { |
philpem@0 | 2312 | char* str = get_imm_str_u32(); |
philpem@0 | 2313 | sprintf(g_dasm_str, "ori.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2314 | } |
philpem@0 | 2315 | |
philpem@0 | 2316 | static void d68000_ori_to_ccr(void) |
philpem@0 | 2317 | { |
philpem@0 | 2318 | sprintf(g_dasm_str, "ori %s, CCR", get_imm_str_u8()); |
philpem@0 | 2319 | } |
philpem@0 | 2320 | |
philpem@0 | 2321 | static void d68000_ori_to_sr(void) |
philpem@0 | 2322 | { |
philpem@0 | 2323 | sprintf(g_dasm_str, "ori %s, SR", get_imm_str_u16()); |
philpem@0 | 2324 | } |
philpem@0 | 2325 | |
philpem@0 | 2326 | static void d68020_pack_rr(void) |
philpem@0 | 2327 | { |
philpem@0 | 2328 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2329 | sprintf(g_dasm_str, "pack D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16()); |
philpem@0 | 2330 | } |
philpem@0 | 2331 | |
philpem@0 | 2332 | static void d68020_pack_mm(void) |
philpem@0 | 2333 | { |
philpem@0 | 2334 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2335 | sprintf(g_dasm_str, "pack -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16()); |
philpem@0 | 2336 | } |
philpem@0 | 2337 | |
philpem@0 | 2338 | static void d68000_pea(void) |
philpem@0 | 2339 | { |
philpem@0 | 2340 | sprintf(g_dasm_str, "pea %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2341 | } |
philpem@0 | 2342 | |
philpem@0 | 2343 | static void d68000_reset(void) |
philpem@0 | 2344 | { |
philpem@0 | 2345 | sprintf(g_dasm_str, "reset"); |
philpem@0 | 2346 | } |
philpem@0 | 2347 | |
philpem@0 | 2348 | static void d68000_ror_s_8(void) |
philpem@0 | 2349 | { |
philpem@0 | 2350 | sprintf(g_dasm_str, "ror.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2351 | } |
philpem@0 | 2352 | |
philpem@0 | 2353 | static void d68000_ror_s_16(void) |
philpem@0 | 2354 | { |
philpem@0 | 2355 | sprintf(g_dasm_str, "ror.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7],g_cpu_ir&7); |
philpem@0 | 2356 | } |
philpem@0 | 2357 | |
philpem@0 | 2358 | static void d68000_ror_s_32(void) |
philpem@0 | 2359 | { |
philpem@0 | 2360 | sprintf(g_dasm_str, "ror.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2361 | } |
philpem@0 | 2362 | |
philpem@0 | 2363 | static void d68000_ror_r_8(void) |
philpem@0 | 2364 | { |
philpem@0 | 2365 | sprintf(g_dasm_str, "ror.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2366 | } |
philpem@0 | 2367 | |
philpem@0 | 2368 | static void d68000_ror_r_16(void) |
philpem@0 | 2369 | { |
philpem@0 | 2370 | sprintf(g_dasm_str, "ror.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2371 | } |
philpem@0 | 2372 | |
philpem@0 | 2373 | static void d68000_ror_r_32(void) |
philpem@0 | 2374 | { |
philpem@0 | 2375 | sprintf(g_dasm_str, "ror.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2376 | } |
philpem@0 | 2377 | |
philpem@0 | 2378 | static void d68000_ror_ea(void) |
philpem@0 | 2379 | { |
philpem@0 | 2380 | sprintf(g_dasm_str, "ror.w %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2381 | } |
philpem@0 | 2382 | |
philpem@0 | 2383 | static void d68000_rol_s_8(void) |
philpem@0 | 2384 | { |
philpem@0 | 2385 | sprintf(g_dasm_str, "rol.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2386 | } |
philpem@0 | 2387 | |
philpem@0 | 2388 | static void d68000_rol_s_16(void) |
philpem@0 | 2389 | { |
philpem@0 | 2390 | sprintf(g_dasm_str, "rol.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2391 | } |
philpem@0 | 2392 | |
philpem@0 | 2393 | static void d68000_rol_s_32(void) |
philpem@0 | 2394 | { |
philpem@0 | 2395 | sprintf(g_dasm_str, "rol.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2396 | } |
philpem@0 | 2397 | |
philpem@0 | 2398 | static void d68000_rol_r_8(void) |
philpem@0 | 2399 | { |
philpem@0 | 2400 | sprintf(g_dasm_str, "rol.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2401 | } |
philpem@0 | 2402 | |
philpem@0 | 2403 | static void d68000_rol_r_16(void) |
philpem@0 | 2404 | { |
philpem@0 | 2405 | sprintf(g_dasm_str, "rol.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2406 | } |
philpem@0 | 2407 | |
philpem@0 | 2408 | static void d68000_rol_r_32(void) |
philpem@0 | 2409 | { |
philpem@0 | 2410 | sprintf(g_dasm_str, "rol.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2411 | } |
philpem@0 | 2412 | |
philpem@0 | 2413 | static void d68000_rol_ea(void) |
philpem@0 | 2414 | { |
philpem@0 | 2415 | sprintf(g_dasm_str, "rol.w %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2416 | } |
philpem@0 | 2417 | |
philpem@0 | 2418 | static void d68000_roxr_s_8(void) |
philpem@0 | 2419 | { |
philpem@0 | 2420 | sprintf(g_dasm_str, "roxr.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2421 | } |
philpem@0 | 2422 | |
philpem@0 | 2423 | static void d68000_roxr_s_16(void) |
philpem@0 | 2424 | { |
philpem@0 | 2425 | sprintf(g_dasm_str, "roxr.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2426 | } |
philpem@0 | 2427 | |
philpem@0 | 2428 | |
philpem@0 | 2429 | static void d68000_roxr_s_32(void) |
philpem@0 | 2430 | { |
philpem@0 | 2431 | sprintf(g_dasm_str, "roxr.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2432 | } |
philpem@0 | 2433 | |
philpem@0 | 2434 | static void d68000_roxr_r_8(void) |
philpem@0 | 2435 | { |
philpem@0 | 2436 | sprintf(g_dasm_str, "roxr.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2437 | } |
philpem@0 | 2438 | |
philpem@0 | 2439 | static void d68000_roxr_r_16(void) |
philpem@0 | 2440 | { |
philpem@0 | 2441 | sprintf(g_dasm_str, "roxr.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2442 | } |
philpem@0 | 2443 | |
philpem@0 | 2444 | static void d68000_roxr_r_32(void) |
philpem@0 | 2445 | { |
philpem@0 | 2446 | sprintf(g_dasm_str, "roxr.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2447 | } |
philpem@0 | 2448 | |
philpem@0 | 2449 | static void d68000_roxr_ea(void) |
philpem@0 | 2450 | { |
philpem@0 | 2451 | sprintf(g_dasm_str, "roxr.w %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2452 | } |
philpem@0 | 2453 | |
philpem@0 | 2454 | static void d68000_roxl_s_8(void) |
philpem@0 | 2455 | { |
philpem@0 | 2456 | sprintf(g_dasm_str, "roxl.b #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2457 | } |
philpem@0 | 2458 | |
philpem@0 | 2459 | static void d68000_roxl_s_16(void) |
philpem@0 | 2460 | { |
philpem@0 | 2461 | sprintf(g_dasm_str, "roxl.w #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2462 | } |
philpem@0 | 2463 | |
philpem@0 | 2464 | static void d68000_roxl_s_32(void) |
philpem@0 | 2465 | { |
philpem@0 | 2466 | sprintf(g_dasm_str, "roxl.l #%d, D%d", g_3bit_qdata_table[(g_cpu_ir>>9)&7], g_cpu_ir&7); |
philpem@0 | 2467 | } |
philpem@0 | 2468 | |
philpem@0 | 2469 | static void d68000_roxl_r_8(void) |
philpem@0 | 2470 | { |
philpem@0 | 2471 | sprintf(g_dasm_str, "roxl.b D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2472 | } |
philpem@0 | 2473 | |
philpem@0 | 2474 | static void d68000_roxl_r_16(void) |
philpem@0 | 2475 | { |
philpem@0 | 2476 | sprintf(g_dasm_str, "roxl.w D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2477 | } |
philpem@0 | 2478 | |
philpem@0 | 2479 | static void d68000_roxl_r_32(void) |
philpem@0 | 2480 | { |
philpem@0 | 2481 | sprintf(g_dasm_str, "roxl.l D%d, D%d", (g_cpu_ir>>9)&7, g_cpu_ir&7); |
philpem@0 | 2482 | } |
philpem@0 | 2483 | |
philpem@0 | 2484 | static void d68000_roxl_ea(void) |
philpem@0 | 2485 | { |
philpem@0 | 2486 | sprintf(g_dasm_str, "roxl.w %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2487 | } |
philpem@0 | 2488 | |
philpem@0 | 2489 | static void d68010_rtd(void) |
philpem@0 | 2490 | { |
philpem@0 | 2491 | LIMIT_CPU_TYPES(M68010_PLUS); |
philpem@0 | 2492 | sprintf(g_dasm_str, "rtd %s; (1+)", get_imm_str_s16()); |
philpem@0 | 2493 | } |
philpem@0 | 2494 | |
philpem@0 | 2495 | static void d68000_rte(void) |
philpem@0 | 2496 | { |
philpem@0 | 2497 | sprintf(g_dasm_str, "rte"); |
philpem@0 | 2498 | } |
philpem@0 | 2499 | |
philpem@0 | 2500 | static void d68020_rtm(void) |
philpem@0 | 2501 | { |
philpem@0 | 2502 | LIMIT_CPU_TYPES(M68020_ONLY); |
philpem@0 | 2503 | sprintf(g_dasm_str, "rtm %c%d; (2+)", BIT_3(g_cpu_ir) ? 'A' : 'D', g_cpu_ir&7); |
philpem@0 | 2504 | } |
philpem@0 | 2505 | |
philpem@0 | 2506 | static void d68000_rtr(void) |
philpem@0 | 2507 | { |
philpem@0 | 2508 | sprintf(g_dasm_str, "rtr"); |
philpem@0 | 2509 | } |
philpem@0 | 2510 | |
philpem@0 | 2511 | static void d68000_rts(void) |
philpem@0 | 2512 | { |
philpem@0 | 2513 | sprintf(g_dasm_str, "rts"); |
philpem@0 | 2514 | } |
philpem@0 | 2515 | |
philpem@0 | 2516 | static void d68000_sbcd_rr(void) |
philpem@0 | 2517 | { |
philpem@0 | 2518 | sprintf(g_dasm_str, "sbcd D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2519 | } |
philpem@0 | 2520 | |
philpem@0 | 2521 | static void d68000_sbcd_mm(void) |
philpem@0 | 2522 | { |
philpem@0 | 2523 | sprintf(g_dasm_str, "sbcd -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2524 | } |
philpem@0 | 2525 | |
philpem@0 | 2526 | static void d68000_scc(void) |
philpem@0 | 2527 | { |
philpem@0 | 2528 | sprintf(g_dasm_str, "s%-2s %s", g_cc[(g_cpu_ir>>8)&0xf], get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2529 | } |
philpem@0 | 2530 | |
philpem@0 | 2531 | static void d68000_stop(void) |
philpem@0 | 2532 | { |
philpem@0 | 2533 | sprintf(g_dasm_str, "stop %s", get_imm_str_s16()); |
philpem@0 | 2534 | } |
philpem@0 | 2535 | |
philpem@0 | 2536 | static void d68000_sub_er_8(void) |
philpem@0 | 2537 | { |
philpem@0 | 2538 | sprintf(g_dasm_str, "sub.b %s, D%d", get_ea_mode_str_8(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2539 | } |
philpem@0 | 2540 | |
philpem@0 | 2541 | static void d68000_sub_er_16(void) |
philpem@0 | 2542 | { |
philpem@0 | 2543 | sprintf(g_dasm_str, "sub.w %s, D%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2544 | } |
philpem@0 | 2545 | |
philpem@0 | 2546 | static void d68000_sub_er_32(void) |
philpem@0 | 2547 | { |
philpem@0 | 2548 | sprintf(g_dasm_str, "sub.l %s, D%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2549 | } |
philpem@0 | 2550 | |
philpem@0 | 2551 | static void d68000_sub_re_8(void) |
philpem@0 | 2552 | { |
philpem@0 | 2553 | sprintf(g_dasm_str, "sub.b D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2554 | } |
philpem@0 | 2555 | |
philpem@0 | 2556 | static void d68000_sub_re_16(void) |
philpem@0 | 2557 | { |
philpem@0 | 2558 | sprintf(g_dasm_str, "sub.w D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2559 | } |
philpem@0 | 2560 | |
philpem@0 | 2561 | static void d68000_sub_re_32(void) |
philpem@0 | 2562 | { |
philpem@0 | 2563 | sprintf(g_dasm_str, "sub.l D%d, %s", (g_cpu_ir>>9)&7, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2564 | } |
philpem@0 | 2565 | |
philpem@0 | 2566 | static void d68000_suba_16(void) |
philpem@0 | 2567 | { |
philpem@0 | 2568 | sprintf(g_dasm_str, "suba.w %s, A%d", get_ea_mode_str_16(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2569 | } |
philpem@0 | 2570 | |
philpem@0 | 2571 | static void d68000_suba_32(void) |
philpem@0 | 2572 | { |
philpem@0 | 2573 | sprintf(g_dasm_str, "suba.l %s, A%d", get_ea_mode_str_32(g_cpu_ir), (g_cpu_ir>>9)&7); |
philpem@0 | 2574 | } |
philpem@0 | 2575 | |
philpem@0 | 2576 | static void d68000_subi_8(void) |
philpem@0 | 2577 | { |
philpem@0 | 2578 | char* str = get_imm_str_s8(); |
philpem@0 | 2579 | sprintf(g_dasm_str, "subi.b %s, %s", str, get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2580 | } |
philpem@0 | 2581 | |
philpem@0 | 2582 | static void d68000_subi_16(void) |
philpem@0 | 2583 | { |
philpem@0 | 2584 | char* str = get_imm_str_s16(); |
philpem@0 | 2585 | sprintf(g_dasm_str, "subi.w %s, %s", str, get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2586 | } |
philpem@0 | 2587 | |
philpem@0 | 2588 | static void d68000_subi_32(void) |
philpem@0 | 2589 | { |
philpem@0 | 2590 | char* str = get_imm_str_s32(); |
philpem@0 | 2591 | sprintf(g_dasm_str, "subi.l %s, %s", str, get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2592 | } |
philpem@0 | 2593 | |
philpem@0 | 2594 | static void d68000_subq_8(void) |
philpem@0 | 2595 | { |
philpem@0 | 2596 | sprintf(g_dasm_str, "subq.b #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2597 | } |
philpem@0 | 2598 | |
philpem@0 | 2599 | static void d68000_subq_16(void) |
philpem@0 | 2600 | { |
philpem@0 | 2601 | sprintf(g_dasm_str, "subq.w #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2602 | } |
philpem@0 | 2603 | |
philpem@0 | 2604 | static void d68000_subq_32(void) |
philpem@0 | 2605 | { |
philpem@0 | 2606 | sprintf(g_dasm_str, "subq.l #%d, %s", g_3bit_qdata_table[(g_cpu_ir>>9)&7], get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2607 | } |
philpem@0 | 2608 | |
philpem@0 | 2609 | static void d68000_subx_rr_8(void) |
philpem@0 | 2610 | { |
philpem@0 | 2611 | sprintf(g_dasm_str, "subx.b D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2612 | } |
philpem@0 | 2613 | |
philpem@0 | 2614 | static void d68000_subx_rr_16(void) |
philpem@0 | 2615 | { |
philpem@0 | 2616 | sprintf(g_dasm_str, "subx.w D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2617 | } |
philpem@0 | 2618 | |
philpem@0 | 2619 | static void d68000_subx_rr_32(void) |
philpem@0 | 2620 | { |
philpem@0 | 2621 | sprintf(g_dasm_str, "subx.l D%d, D%d", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2622 | } |
philpem@0 | 2623 | |
philpem@0 | 2624 | static void d68000_subx_mm_8(void) |
philpem@0 | 2625 | { |
philpem@0 | 2626 | sprintf(g_dasm_str, "subx.b -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2627 | } |
philpem@0 | 2628 | |
philpem@0 | 2629 | static void d68000_subx_mm_16(void) |
philpem@0 | 2630 | { |
philpem@0 | 2631 | sprintf(g_dasm_str, "subx.w -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2632 | } |
philpem@0 | 2633 | |
philpem@0 | 2634 | static void d68000_subx_mm_32(void) |
philpem@0 | 2635 | { |
philpem@0 | 2636 | sprintf(g_dasm_str, "subx.l -(A%d), -(A%d)", g_cpu_ir&7, (g_cpu_ir>>9)&7); |
philpem@0 | 2637 | } |
philpem@0 | 2638 | |
philpem@0 | 2639 | static void d68000_swap(void) |
philpem@0 | 2640 | { |
philpem@0 | 2641 | sprintf(g_dasm_str, "swap D%d", g_cpu_ir&7); |
philpem@0 | 2642 | } |
philpem@0 | 2643 | |
philpem@0 | 2644 | static void d68000_tas(void) |
philpem@0 | 2645 | { |
philpem@0 | 2646 | sprintf(g_dasm_str, "tas %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2647 | } |
philpem@0 | 2648 | |
philpem@0 | 2649 | static void d68000_trap(void) |
philpem@0 | 2650 | { |
philpem@0 | 2651 | sprintf(g_dasm_str, "trap #$%x", g_cpu_ir&0xf); |
philpem@0 | 2652 | } |
philpem@0 | 2653 | |
philpem@0 | 2654 | static void d68020_trapcc_0(void) |
philpem@0 | 2655 | { |
philpem@0 | 2656 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2657 | sprintf(g_dasm_str, "trap%-2s; (2+)", g_cc[(g_cpu_ir>>8)&0xf]); |
philpem@0 | 2658 | } |
philpem@0 | 2659 | |
philpem@0 | 2660 | static void d68020_trapcc_16(void) |
philpem@0 | 2661 | { |
philpem@0 | 2662 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2663 | sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u16()); |
philpem@0 | 2664 | } |
philpem@0 | 2665 | |
philpem@0 | 2666 | static void d68020_trapcc_32(void) |
philpem@0 | 2667 | { |
philpem@0 | 2668 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2669 | sprintf(g_dasm_str, "trap%-2s %s; (2+)", g_cc[(g_cpu_ir>>8)&0xf], get_imm_str_u32()); |
philpem@0 | 2670 | } |
philpem@0 | 2671 | |
philpem@0 | 2672 | static void d68000_trapv(void) |
philpem@0 | 2673 | { |
philpem@0 | 2674 | sprintf(g_dasm_str, "trapv"); |
philpem@0 | 2675 | } |
philpem@0 | 2676 | |
philpem@0 | 2677 | static void d68000_tst_8(void) |
philpem@0 | 2678 | { |
philpem@0 | 2679 | sprintf(g_dasm_str, "tst.b %s", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2680 | } |
philpem@0 | 2681 | |
philpem@0 | 2682 | static void d68020_tst_pcdi_8(void) |
philpem@0 | 2683 | { |
philpem@0 | 2684 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2685 | sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2686 | } |
philpem@0 | 2687 | |
philpem@0 | 2688 | static void d68020_tst_pcix_8(void) |
philpem@0 | 2689 | { |
philpem@0 | 2690 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2691 | sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2692 | } |
philpem@0 | 2693 | |
philpem@0 | 2694 | static void d68020_tst_i_8(void) |
philpem@0 | 2695 | { |
philpem@0 | 2696 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2697 | sprintf(g_dasm_str, "tst.b %s; (2+)", get_ea_mode_str_8(g_cpu_ir)); |
philpem@0 | 2698 | } |
philpem@0 | 2699 | |
philpem@0 | 2700 | static void d68000_tst_16(void) |
philpem@0 | 2701 | { |
philpem@0 | 2702 | sprintf(g_dasm_str, "tst.w %s", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2703 | } |
philpem@0 | 2704 | |
philpem@0 | 2705 | static void d68020_tst_a_16(void) |
philpem@0 | 2706 | { |
philpem@0 | 2707 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2708 | sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2709 | } |
philpem@0 | 2710 | |
philpem@0 | 2711 | static void d68020_tst_pcdi_16(void) |
philpem@0 | 2712 | { |
philpem@0 | 2713 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2714 | sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2715 | } |
philpem@0 | 2716 | |
philpem@0 | 2717 | static void d68020_tst_pcix_16(void) |
philpem@0 | 2718 | { |
philpem@0 | 2719 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2720 | sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2721 | } |
philpem@0 | 2722 | |
philpem@0 | 2723 | static void d68020_tst_i_16(void) |
philpem@0 | 2724 | { |
philpem@0 | 2725 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2726 | sprintf(g_dasm_str, "tst.w %s; (2+)", get_ea_mode_str_16(g_cpu_ir)); |
philpem@0 | 2727 | } |
philpem@0 | 2728 | |
philpem@0 | 2729 | static void d68000_tst_32(void) |
philpem@0 | 2730 | { |
philpem@0 | 2731 | sprintf(g_dasm_str, "tst.l %s", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2732 | } |
philpem@0 | 2733 | |
philpem@0 | 2734 | static void d68020_tst_a_32(void) |
philpem@0 | 2735 | { |
philpem@0 | 2736 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2737 | sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2738 | } |
philpem@0 | 2739 | |
philpem@0 | 2740 | static void d68020_tst_pcdi_32(void) |
philpem@0 | 2741 | { |
philpem@0 | 2742 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2743 | sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2744 | } |
philpem@0 | 2745 | |
philpem@0 | 2746 | static void d68020_tst_pcix_32(void) |
philpem@0 | 2747 | { |
philpem@0 | 2748 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2749 | sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2750 | } |
philpem@0 | 2751 | |
philpem@0 | 2752 | static void d68020_tst_i_32(void) |
philpem@0 | 2753 | { |
philpem@0 | 2754 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2755 | sprintf(g_dasm_str, "tst.l %s; (2+)", get_ea_mode_str_32(g_cpu_ir)); |
philpem@0 | 2756 | } |
philpem@0 | 2757 | |
philpem@0 | 2758 | static void d68000_unlk(void) |
philpem@0 | 2759 | { |
philpem@0 | 2760 | sprintf(g_dasm_str, "unlk A%d", g_cpu_ir&7); |
philpem@0 | 2761 | } |
philpem@0 | 2762 | |
philpem@0 | 2763 | static void d68020_unpk_rr(void) |
philpem@0 | 2764 | { |
philpem@0 | 2765 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2766 | sprintf(g_dasm_str, "unpk D%d, D%d, %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16()); |
philpem@0 | 2767 | } |
philpem@0 | 2768 | |
philpem@0 | 2769 | static void d68020_unpk_mm(void) |
philpem@0 | 2770 | { |
philpem@0 | 2771 | LIMIT_CPU_TYPES(M68020_PLUS); |
philpem@0 | 2772 | sprintf(g_dasm_str, "unpk -(A%d), -(A%d), %s; (2+)", g_cpu_ir&7, (g_cpu_ir>>9)&7, get_imm_str_u16()); |
philpem@0 | 2773 | } |
philpem@0 | 2774 | |
philpem@0 | 2775 | |
philpem@0 | 2776 | |
philpem@0 | 2777 | /* ======================================================================== */ |
philpem@0 | 2778 | /* ======================= INSTRUCTION TABLE BUILDER ====================== */ |
philpem@0 | 2779 | /* ======================================================================== */ |
philpem@0 | 2780 | |
philpem@0 | 2781 | /* EA Masks: |
philpem@0 | 2782 | 800 = data register direct |
philpem@0 | 2783 | 400 = address register direct |
philpem@0 | 2784 | 200 = address register indirect |
philpem@0 | 2785 | 100 = ARI postincrement |
philpem@0 | 2786 | 80 = ARI pre-decrement |
philpem@0 | 2787 | 40 = ARI displacement |
philpem@0 | 2788 | 20 = ARI index |
philpem@0 | 2789 | 10 = absolute short |
philpem@0 | 2790 | 8 = absolute long |
philpem@0 | 2791 | 4 = immediate / sr |
philpem@0 | 2792 | 2 = pc displacement |
philpem@0 | 2793 | 1 = pc idx |
philpem@0 | 2794 | */ |
philpem@0 | 2795 | |
philpem@0 | 2796 | static opcode_struct g_opcode_info[] = |
philpem@0 | 2797 | { |
philpem@0 | 2798 | /* opcode handler mask match ea mask */ |
philpem@0 | 2799 | {d68000_1010 , 0xf000, 0xa000, 0x000}, |
philpem@0 | 2800 | {d68000_1111 , 0xf000, 0xf000, 0x000}, |
philpem@0 | 2801 | {d68000_abcd_rr , 0xf1f8, 0xc100, 0x000}, |
philpem@0 | 2802 | {d68000_abcd_mm , 0xf1f8, 0xc108, 0x000}, |
philpem@0 | 2803 | {d68000_add_er_8 , 0xf1c0, 0xd000, 0xbff}, |
philpem@0 | 2804 | {d68000_add_er_16 , 0xf1c0, 0xd040, 0xfff}, |
philpem@0 | 2805 | {d68000_add_er_32 , 0xf1c0, 0xd080, 0xfff}, |
philpem@0 | 2806 | {d68000_add_re_8 , 0xf1c0, 0xd100, 0x3f8}, |
philpem@0 | 2807 | {d68000_add_re_16 , 0xf1c0, 0xd140, 0x3f8}, |
philpem@0 | 2808 | {d68000_add_re_32 , 0xf1c0, 0xd180, 0x3f8}, |
philpem@0 | 2809 | {d68000_adda_16 , 0xf1c0, 0xd0c0, 0xfff}, |
philpem@0 | 2810 | {d68000_adda_32 , 0xf1c0, 0xd1c0, 0xfff}, |
philpem@0 | 2811 | {d68000_addi_8 , 0xffc0, 0x0600, 0xbf8}, |
philpem@0 | 2812 | {d68000_addi_16 , 0xffc0, 0x0640, 0xbf8}, |
philpem@0 | 2813 | {d68000_addi_32 , 0xffc0, 0x0680, 0xbf8}, |
philpem@0 | 2814 | {d68000_addq_8 , 0xf1c0, 0x5000, 0xbf8}, |
philpem@0 | 2815 | {d68000_addq_16 , 0xf1c0, 0x5040, 0xff8}, |
philpem@0 | 2816 | {d68000_addq_32 , 0xf1c0, 0x5080, 0xff8}, |
philpem@0 | 2817 | {d68000_addx_rr_8 , 0xf1f8, 0xd100, 0x000}, |
philpem@0 | 2818 | {d68000_addx_rr_16 , 0xf1f8, 0xd140, 0x000}, |
philpem@0 | 2819 | {d68000_addx_rr_32 , 0xf1f8, 0xd180, 0x000}, |
philpem@0 | 2820 | {d68000_addx_mm_8 , 0xf1f8, 0xd108, 0x000}, |
philpem@0 | 2821 | {d68000_addx_mm_16 , 0xf1f8, 0xd148, 0x000}, |
philpem@0 | 2822 | {d68000_addx_mm_32 , 0xf1f8, 0xd188, 0x000}, |
philpem@0 | 2823 | {d68000_and_er_8 , 0xf1c0, 0xc000, 0xbff}, |
philpem@0 | 2824 | {d68000_and_er_16 , 0xf1c0, 0xc040, 0xbff}, |
philpem@0 | 2825 | {d68000_and_er_32 , 0xf1c0, 0xc080, 0xbff}, |
philpem@0 | 2826 | {d68000_and_re_8 , 0xf1c0, 0xc100, 0x3f8}, |
philpem@0 | 2827 | {d68000_and_re_16 , 0xf1c0, 0xc140, 0x3f8}, |
philpem@0 | 2828 | {d68000_and_re_32 , 0xf1c0, 0xc180, 0x3f8}, |
philpem@0 | 2829 | {d68000_andi_to_ccr , 0xffff, 0x023c, 0x000}, |
philpem@0 | 2830 | {d68000_andi_to_sr , 0xffff, 0x027c, 0x000}, |
philpem@0 | 2831 | {d68000_andi_8 , 0xffc0, 0x0200, 0xbf8}, |
philpem@0 | 2832 | {d68000_andi_16 , 0xffc0, 0x0240, 0xbf8}, |
philpem@0 | 2833 | {d68000_andi_32 , 0xffc0, 0x0280, 0xbf8}, |
philpem@0 | 2834 | {d68000_asr_s_8 , 0xf1f8, 0xe000, 0x000}, |
philpem@0 | 2835 | {d68000_asr_s_16 , 0xf1f8, 0xe040, 0x000}, |
philpem@0 | 2836 | {d68000_asr_s_32 , 0xf1f8, 0xe080, 0x000}, |
philpem@0 | 2837 | {d68000_asr_r_8 , 0xf1f8, 0xe020, 0x000}, |
philpem@0 | 2838 | {d68000_asr_r_16 , 0xf1f8, 0xe060, 0x000}, |
philpem@0 | 2839 | {d68000_asr_r_32 , 0xf1f8, 0xe0a0, 0x000}, |
philpem@0 | 2840 | {d68000_asr_ea , 0xffc0, 0xe0c0, 0x3f8}, |
philpem@0 | 2841 | {d68000_asl_s_8 , 0xf1f8, 0xe100, 0x000}, |
philpem@0 | 2842 | {d68000_asl_s_16 , 0xf1f8, 0xe140, 0x000}, |
philpem@0 | 2843 | {d68000_asl_s_32 , 0xf1f8, 0xe180, 0x000}, |
philpem@0 | 2844 | {d68000_asl_r_8 , 0xf1f8, 0xe120, 0x000}, |
philpem@0 | 2845 | {d68000_asl_r_16 , 0xf1f8, 0xe160, 0x000}, |
philpem@0 | 2846 | {d68000_asl_r_32 , 0xf1f8, 0xe1a0, 0x000}, |
philpem@0 | 2847 | {d68000_asl_ea , 0xffc0, 0xe1c0, 0x3f8}, |
philpem@0 | 2848 | {d68000_bcc_8 , 0xf000, 0x6000, 0x000}, |
philpem@0 | 2849 | {d68000_bcc_16 , 0xf0ff, 0x6000, 0x000}, |
philpem@0 | 2850 | {d68020_bcc_32 , 0xf0ff, 0x60ff, 0x000}, |
philpem@0 | 2851 | {d68000_bchg_r , 0xf1c0, 0x0140, 0xbf8}, |
philpem@0 | 2852 | {d68000_bchg_s , 0xffc0, 0x0840, 0xbf8}, |
philpem@0 | 2853 | {d68000_bclr_r , 0xf1c0, 0x0180, 0xbf8}, |
philpem@0 | 2854 | {d68000_bclr_s , 0xffc0, 0x0880, 0xbf8}, |
philpem@0 | 2855 | {d68020_bfchg , 0xffc0, 0xeac0, 0xa78}, |
philpem@0 | 2856 | {d68020_bfclr , 0xffc0, 0xecc0, 0xa78}, |
philpem@0 | 2857 | {d68020_bfexts , 0xffc0, 0xebc0, 0xa7b}, |
philpem@0 | 2858 | {d68020_bfextu , 0xffc0, 0xe9c0, 0xa7b}, |
philpem@0 | 2859 | {d68020_bfffo , 0xffc0, 0xedc0, 0xa7b}, |
philpem@0 | 2860 | {d68020_bfins , 0xffc0, 0xefc0, 0xa78}, |
philpem@0 | 2861 | {d68020_bfset , 0xffc0, 0xeec0, 0xa78}, |
philpem@0 | 2862 | {d68020_bftst , 0xffc0, 0xe8c0, 0xa7b}, |
philpem@0 | 2863 | {d68010_bkpt , 0xfff8, 0x4848, 0x000}, |
philpem@0 | 2864 | {d68000_bra_8 , 0xff00, 0x6000, 0x000}, |
philpem@0 | 2865 | {d68000_bra_16 , 0xffff, 0x6000, 0x000}, |
philpem@0 | 2866 | {d68020_bra_32 , 0xffff, 0x60ff, 0x000}, |
philpem@0 | 2867 | {d68000_bset_r , 0xf1c0, 0x01c0, 0xbf8}, |
philpem@0 | 2868 | {d68000_bset_s , 0xffc0, 0x08c0, 0xbf8}, |
philpem@0 | 2869 | {d68000_bsr_8 , 0xff00, 0x6100, 0x000}, |
philpem@0 | 2870 | {d68000_bsr_16 , 0xffff, 0x6100, 0x000}, |
philpem@0 | 2871 | {d68020_bsr_32 , 0xffff, 0x61ff, 0x000}, |
philpem@0 | 2872 | {d68000_btst_r , 0xf1c0, 0x0100, 0xbff}, |
philpem@0 | 2873 | {d68000_btst_s , 0xffc0, 0x0800, 0xbfb}, |
philpem@0 | 2874 | {d68020_callm , 0xffc0, 0x06c0, 0x27b}, |
philpem@0 | 2875 | {d68020_cas_8 , 0xffc0, 0x0ac0, 0x3f8}, |
philpem@0 | 2876 | {d68020_cas_16 , 0xffc0, 0x0cc0, 0x3f8}, |
philpem@0 | 2877 | {d68020_cas_32 , 0xffc0, 0x0ec0, 0x3f8}, |
philpem@0 | 2878 | {d68020_cas2_16 , 0xffff, 0x0cfc, 0x000}, |
philpem@0 | 2879 | {d68020_cas2_32 , 0xffff, 0x0efc, 0x000}, |
philpem@0 | 2880 | {d68000_chk_16 , 0xf1c0, 0x4180, 0xbff}, |
philpem@0 | 2881 | {d68020_chk_32 , 0xf1c0, 0x4100, 0xbff}, |
philpem@0 | 2882 | {d68020_chk2_cmp2_8 , 0xffc0, 0x00c0, 0x27b}, |
philpem@0 | 2883 | {d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b}, |
philpem@0 | 2884 | {d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b}, |
philpem@0 | 2885 | {d68040_cinv , 0xff20, 0xf400, 0x000}, |
philpem@0 | 2886 | {d68000_clr_8 , 0xffc0, 0x4200, 0xbf8}, |
philpem@0 | 2887 | {d68000_clr_16 , 0xffc0, 0x4240, 0xbf8}, |
philpem@0 | 2888 | {d68000_clr_32 , 0xffc0, 0x4280, 0xbf8}, |
philpem@0 | 2889 | {d68000_cmp_8 , 0xf1c0, 0xb000, 0xbff}, |
philpem@0 | 2890 | {d68000_cmp_16 , 0xf1c0, 0xb040, 0xfff}, |
philpem@0 | 2891 | {d68000_cmp_32 , 0xf1c0, 0xb080, 0xfff}, |
philpem@0 | 2892 | {d68000_cmpa_16 , 0xf1c0, 0xb0c0, 0xfff}, |
philpem@0 | 2893 | {d68000_cmpa_32 , 0xf1c0, 0xb1c0, 0xfff}, |
philpem@0 | 2894 | {d68000_cmpi_8 , 0xffc0, 0x0c00, 0xbf8}, |
philpem@0 | 2895 | {d68020_cmpi_pcdi_8 , 0xffff, 0x0c3a, 0x000}, |
philpem@0 | 2896 | {d68020_cmpi_pcix_8 , 0xffff, 0x0c3b, 0x000}, |
philpem@0 | 2897 | {d68000_cmpi_16 , 0xffc0, 0x0c40, 0xbf8}, |
philpem@0 | 2898 | {d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000}, |
philpem@0 | 2899 | {d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000}, |
philpem@0 | 2900 | {d68000_cmpi_32 , 0xffc0, 0x0c80, 0xbf8}, |
philpem@0 | 2901 | {d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000}, |
philpem@0 | 2902 | {d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000}, |
philpem@0 | 2903 | {d68000_cmpm_8 , 0xf1f8, 0xb108, 0x000}, |
philpem@0 | 2904 | {d68000_cmpm_16 , 0xf1f8, 0xb148, 0x000}, |
philpem@0 | 2905 | {d68000_cmpm_32 , 0xf1f8, 0xb188, 0x000}, |
philpem@0 | 2906 | {d68020_cpbcc_16 , 0xf1c0, 0xf080, 0x000}, |
philpem@0 | 2907 | {d68020_cpbcc_32 , 0xf1c0, 0xf0c0, 0x000}, |
philpem@0 | 2908 | {d68020_cpdbcc , 0xf1f8, 0xf048, 0x000}, |
philpem@0 | 2909 | {d68020_cpgen , 0xf1c0, 0xf000, 0x000}, |
philpem@0 | 2910 | {d68020_cprestore , 0xf1c0, 0xf140, 0x37f}, |
philpem@0 | 2911 | {d68020_cpsave , 0xf1c0, 0xf100, 0x2f8}, |
philpem@0 | 2912 | {d68020_cpscc , 0xf1c0, 0xf040, 0xbf8}, |
philpem@0 | 2913 | {d68020_cptrapcc_0 , 0xf1ff, 0xf07c, 0x000}, |
philpem@0 | 2914 | {d68020_cptrapcc_16 , 0xf1ff, 0xf07a, 0x000}, |
philpem@0 | 2915 | {d68020_cptrapcc_32 , 0xf1ff, 0xf07b, 0x000}, |
philpem@0 | 2916 | {d68040_cpush , 0xff20, 0xf420, 0x000}, |
philpem@0 | 2917 | {d68000_dbcc , 0xf0f8, 0x50c8, 0x000}, |
philpem@0 | 2918 | {d68000_dbra , 0xfff8, 0x51c8, 0x000}, |
philpem@0 | 2919 | {d68000_divs , 0xf1c0, 0x81c0, 0xbff}, |
philpem@0 | 2920 | {d68000_divu , 0xf1c0, 0x80c0, 0xbff}, |
philpem@0 | 2921 | {d68020_divl , 0xffc0, 0x4c40, 0xbff}, |
philpem@0 | 2922 | {d68000_eor_8 , 0xf1c0, 0xb100, 0xbf8}, |
philpem@0 | 2923 | {d68000_eor_16 , 0xf1c0, 0xb140, 0xbf8}, |
philpem@0 | 2924 | {d68000_eor_32 , 0xf1c0, 0xb180, 0xbf8}, |
philpem@0 | 2925 | {d68000_eori_to_ccr , 0xffff, 0x0a3c, 0x000}, |
philpem@0 | 2926 | {d68000_eori_to_sr , 0xffff, 0x0a7c, 0x000}, |
philpem@0 | 2927 | {d68000_eori_8 , 0xffc0, 0x0a00, 0xbf8}, |
philpem@0 | 2928 | {d68000_eori_16 , 0xffc0, 0x0a40, 0xbf8}, |
philpem@0 | 2929 | {d68000_eori_32 , 0xffc0, 0x0a80, 0xbf8}, |
philpem@0 | 2930 | {d68000_exg_dd , 0xf1f8, 0xc140, 0x000}, |
philpem@0 | 2931 | {d68000_exg_aa , 0xf1f8, 0xc148, 0x000}, |
philpem@0 | 2932 | {d68000_exg_da , 0xf1f8, 0xc188, 0x000}, |
philpem@0 | 2933 | {d68020_extb_32 , 0xfff8, 0x49c0, 0x000}, |
philpem@0 | 2934 | {d68000_ext_16 , 0xfff8, 0x4880, 0x000}, |
philpem@0 | 2935 | {d68000_ext_32 , 0xfff8, 0x48c0, 0x000}, |
philpem@0 | 2936 | {d68000_illegal , 0xffff, 0x4afc, 0x000}, |
philpem@0 | 2937 | {d68000_jmp , 0xffc0, 0x4ec0, 0x27b}, |
philpem@0 | 2938 | {d68000_jsr , 0xffc0, 0x4e80, 0x27b}, |
philpem@0 | 2939 | {d68000_lea , 0xf1c0, 0x41c0, 0x27b}, |
philpem@0 | 2940 | {d68000_link_16 , 0xfff8, 0x4e50, 0x000}, |
philpem@0 | 2941 | {d68020_link_32 , 0xfff8, 0x4808, 0x000}, |
philpem@0 | 2942 | {d68000_lsr_s_8 , 0xf1f8, 0xe008, 0x000}, |
philpem@0 | 2943 | {d68000_lsr_s_16 , 0xf1f8, 0xe048, 0x000}, |
philpem@0 | 2944 | {d68000_lsr_s_32 , 0xf1f8, 0xe088, 0x000}, |
philpem@0 | 2945 | {d68000_lsr_r_8 , 0xf1f8, 0xe028, 0x000}, |
philpem@0 | 2946 | {d68000_lsr_r_16 , 0xf1f8, 0xe068, 0x000}, |
philpem@0 | 2947 | {d68000_lsr_r_32 , 0xf1f8, 0xe0a8, 0x000}, |
philpem@0 | 2948 | {d68000_lsr_ea , 0xffc0, 0xe2c0, 0x3f8}, |
philpem@0 | 2949 | {d68000_lsl_s_8 , 0xf1f8, 0xe108, 0x000}, |
philpem@0 | 2950 | {d68000_lsl_s_16 , 0xf1f8, 0xe148, 0x000}, |
philpem@0 | 2951 | {d68000_lsl_s_32 , 0xf1f8, 0xe188, 0x000}, |
philpem@0 | 2952 | {d68000_lsl_r_8 , 0xf1f8, 0xe128, 0x000}, |
philpem@0 | 2953 | {d68000_lsl_r_16 , 0xf1f8, 0xe168, 0x000}, |
philpem@0 | 2954 | {d68000_lsl_r_32 , 0xf1f8, 0xe1a8, 0x000}, |
philpem@0 | 2955 | {d68000_lsl_ea , 0xffc0, 0xe3c0, 0x3f8}, |
philpem@0 | 2956 | {d68000_move_8 , 0xf000, 0x1000, 0xbff}, |
philpem@0 | 2957 | {d68000_move_16 , 0xf000, 0x3000, 0xfff}, |
philpem@0 | 2958 | {d68000_move_32 , 0xf000, 0x2000, 0xfff}, |
philpem@0 | 2959 | {d68000_movea_16 , 0xf1c0, 0x3040, 0xfff}, |
philpem@0 | 2960 | {d68000_movea_32 , 0xf1c0, 0x2040, 0xfff}, |
philpem@0 | 2961 | {d68000_move_to_ccr , 0xffc0, 0x44c0, 0xbff}, |
philpem@0 | 2962 | {d68010_move_fr_ccr , 0xffc0, 0x42c0, 0xbf8}, |
philpem@0 | 2963 | {d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff}, |
philpem@0 | 2964 | {d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8}, |
philpem@0 | 2965 | {d68000_move_to_usp , 0xfff8, 0x4e60, 0x000}, |
philpem@0 | 2966 | {d68000_move_fr_usp , 0xfff8, 0x4e68, 0x000}, |
philpem@0 | 2967 | {d68010_movec , 0xfffe, 0x4e7a, 0x000}, |
philpem@0 | 2968 | {d68000_movem_pd_16 , 0xfff8, 0x48a0, 0x000}, |
philpem@0 | 2969 | {d68000_movem_pd_32 , 0xfff8, 0x48e0, 0x000}, |
philpem@0 | 2970 | {d68000_movem_re_16 , 0xffc0, 0x4880, 0x2f8}, |
philpem@0 | 2971 | {d68000_movem_re_32 , 0xffc0, 0x48c0, 0x2f8}, |
philpem@0 | 2972 | {d68000_movem_er_16 , 0xffc0, 0x4c80, 0x37b}, |
philpem@0 | 2973 | {d68000_movem_er_32 , 0xffc0, 0x4cc0, 0x37b}, |
philpem@0 | 2974 | {d68000_movep_er_16 , 0xf1f8, 0x0108, 0x000}, |
philpem@0 | 2975 | {d68000_movep_er_32 , 0xf1f8, 0x0148, 0x000}, |
philpem@0 | 2976 | {d68000_movep_re_16 , 0xf1f8, 0x0188, 0x000}, |
philpem@0 | 2977 | {d68000_movep_re_32 , 0xf1f8, 0x01c8, 0x000}, |
philpem@0 | 2978 | {d68010_moves_8 , 0xffc0, 0x0e00, 0x3f8}, |
philpem@0 | 2979 | {d68010_moves_16 , 0xffc0, 0x0e40, 0x3f8}, |
philpem@0 | 2980 | {d68010_moves_32 , 0xffc0, 0x0e80, 0x3f8}, |
philpem@0 | 2981 | {d68000_moveq , 0xf100, 0x7000, 0x000}, |
philpem@0 | 2982 | {d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000}, |
philpem@0 | 2983 | {d68040_move16_pi_al , 0xfff8, 0xf600, 0x000}, |
philpem@0 | 2984 | {d68040_move16_al_pi , 0xfff8, 0xf608, 0x000}, |
philpem@0 | 2985 | {d68040_move16_ai_al , 0xfff8, 0xf610, 0x000}, |
philpem@0 | 2986 | {d68040_move16_al_ai , 0xfff8, 0xf618, 0x000}, |
philpem@0 | 2987 | {d68000_muls , 0xf1c0, 0xc1c0, 0xbff}, |
philpem@0 | 2988 | {d68000_mulu , 0xf1c0, 0xc0c0, 0xbff}, |
philpem@0 | 2989 | {d68020_mull , 0xffc0, 0x4c00, 0xbff}, |
philpem@0 | 2990 | {d68000_nbcd , 0xffc0, 0x4800, 0xbf8}, |
philpem@0 | 2991 | {d68000_neg_8 , 0xffc0, 0x4400, 0xbf8}, |
philpem@0 | 2992 | {d68000_neg_16 , 0xffc0, 0x4440, 0xbf8}, |
philpem@0 | 2993 | {d68000_neg_32 , 0xffc0, 0x4480, 0xbf8}, |
philpem@0 | 2994 | {d68000_negx_8 , 0xffc0, 0x4000, 0xbf8}, |
philpem@0 | 2995 | {d68000_negx_16 , 0xffc0, 0x4040, 0xbf8}, |
philpem@0 | 2996 | {d68000_negx_32 , 0xffc0, 0x4080, 0xbf8}, |
philpem@0 | 2997 | {d68000_nop , 0xffff, 0x4e71, 0x000}, |
philpem@0 | 2998 | {d68000_not_8 , 0xffc0, 0x4600, 0xbf8}, |
philpem@0 | 2999 | {d68000_not_16 , 0xffc0, 0x4640, 0xbf8}, |
philpem@0 | 3000 | {d68000_not_32 , 0xffc0, 0x4680, 0xbf8}, |
philpem@0 | 3001 | {d68000_or_er_8 , 0xf1c0, 0x8000, 0xbff}, |
philpem@0 | 3002 | {d68000_or_er_16 , 0xf1c0, 0x8040, 0xbff}, |
philpem@0 | 3003 | {d68000_or_er_32 , 0xf1c0, 0x8080, 0xbff}, |
philpem@0 | 3004 | {d68000_or_re_8 , 0xf1c0, 0x8100, 0x3f8}, |
philpem@0 | 3005 | {d68000_or_re_16 , 0xf1c0, 0x8140, 0x3f8}, |
philpem@0 | 3006 | {d68000_or_re_32 , 0xf1c0, 0x8180, 0x3f8}, |
philpem@0 | 3007 | {d68000_ori_to_ccr , 0xffff, 0x003c, 0x000}, |
philpem@0 | 3008 | {d68000_ori_to_sr , 0xffff, 0x007c, 0x000}, |
philpem@0 | 3009 | {d68000_ori_8 , 0xffc0, 0x0000, 0xbf8}, |
philpem@0 | 3010 | {d68000_ori_16 , 0xffc0, 0x0040, 0xbf8}, |
philpem@0 | 3011 | {d68000_ori_32 , 0xffc0, 0x0080, 0xbf8}, |
philpem@0 | 3012 | {d68020_pack_rr , 0xf1f8, 0x8140, 0x000}, |
philpem@0 | 3013 | {d68020_pack_mm , 0xf1f8, 0x8148, 0x000}, |
philpem@0 | 3014 | {d68000_pea , 0xffc0, 0x4840, 0x27b}, |
philpem@0 | 3015 | {d68000_reset , 0xffff, 0x4e70, 0x000}, |
philpem@0 | 3016 | {d68000_ror_s_8 , 0xf1f8, 0xe018, 0x000}, |
philpem@0 | 3017 | {d68000_ror_s_16 , 0xf1f8, 0xe058, 0x000}, |
philpem@0 | 3018 | {d68000_ror_s_32 , 0xf1f8, 0xe098, 0x000}, |
philpem@0 | 3019 | {d68000_ror_r_8 , 0xf1f8, 0xe038, 0x000}, |
philpem@0 | 3020 | {d68000_ror_r_16 , 0xf1f8, 0xe078, 0x000}, |
philpem@0 | 3021 | {d68000_ror_r_32 , 0xf1f8, 0xe0b8, 0x000}, |
philpem@0 | 3022 | {d68000_ror_ea , 0xffc0, 0xe6c0, 0x3f8}, |
philpem@0 | 3023 | {d68000_rol_s_8 , 0xf1f8, 0xe118, 0x000}, |
philpem@0 | 3024 | {d68000_rol_s_16 , 0xf1f8, 0xe158, 0x000}, |
philpem@0 | 3025 | {d68000_rol_s_32 , 0xf1f8, 0xe198, 0x000}, |
philpem@0 | 3026 | {d68000_rol_r_8 , 0xf1f8, 0xe138, 0x000}, |
philpem@0 | 3027 | {d68000_rol_r_16 , 0xf1f8, 0xe178, 0x000}, |
philpem@0 | 3028 | {d68000_rol_r_32 , 0xf1f8, 0xe1b8, 0x000}, |
philpem@0 | 3029 | {d68000_rol_ea , 0xffc0, 0xe7c0, 0x3f8}, |
philpem@0 | 3030 | {d68000_roxr_s_8 , 0xf1f8, 0xe010, 0x000}, |
philpem@0 | 3031 | {d68000_roxr_s_16 , 0xf1f8, 0xe050, 0x000}, |
philpem@0 | 3032 | {d68000_roxr_s_32 , 0xf1f8, 0xe090, 0x000}, |
philpem@0 | 3033 | {d68000_roxr_r_8 , 0xf1f8, 0xe030, 0x000}, |
philpem@0 | 3034 | {d68000_roxr_r_16 , 0xf1f8, 0xe070, 0x000}, |
philpem@0 | 3035 | {d68000_roxr_r_32 , 0xf1f8, 0xe0b0, 0x000}, |
philpem@0 | 3036 | {d68000_roxr_ea , 0xffc0, 0xe4c0, 0x3f8}, |
philpem@0 | 3037 | {d68000_roxl_s_8 , 0xf1f8, 0xe110, 0x000}, |
philpem@0 | 3038 | {d68000_roxl_s_16 , 0xf1f8, 0xe150, 0x000}, |
philpem@0 | 3039 | {d68000_roxl_s_32 , 0xf1f8, 0xe190, 0x000}, |
philpem@0 | 3040 | {d68000_roxl_r_8 , 0xf1f8, 0xe130, 0x000}, |
philpem@0 | 3041 | {d68000_roxl_r_16 , 0xf1f8, 0xe170, 0x000}, |
philpem@0 | 3042 | {d68000_roxl_r_32 , 0xf1f8, 0xe1b0, 0x000}, |
philpem@0 | 3043 | {d68000_roxl_ea , 0xffc0, 0xe5c0, 0x3f8}, |
philpem@0 | 3044 | {d68010_rtd , 0xffff, 0x4e74, 0x000}, |
philpem@0 | 3045 | {d68000_rte , 0xffff, 0x4e73, 0x000}, |
philpem@0 | 3046 | {d68020_rtm , 0xfff0, 0x06c0, 0x000}, |
philpem@0 | 3047 | {d68000_rtr , 0xffff, 0x4e77, 0x000}, |
philpem@0 | 3048 | {d68000_rts , 0xffff, 0x4e75, 0x000}, |
philpem@0 | 3049 | {d68000_sbcd_rr , 0xf1f8, 0x8100, 0x000}, |
philpem@0 | 3050 | {d68000_sbcd_mm , 0xf1f8, 0x8108, 0x000}, |
philpem@0 | 3051 | {d68000_scc , 0xf0c0, 0x50c0, 0xbf8}, |
philpem@0 | 3052 | {d68000_stop , 0xffff, 0x4e72, 0x000}, |
philpem@0 | 3053 | {d68000_sub_er_8 , 0xf1c0, 0x9000, 0xbff}, |
philpem@0 | 3054 | {d68000_sub_er_16 , 0xf1c0, 0x9040, 0xfff}, |
philpem@0 | 3055 | {d68000_sub_er_32 , 0xf1c0, 0x9080, 0xfff}, |
philpem@0 | 3056 | {d68000_sub_re_8 , 0xf1c0, 0x9100, 0x3f8}, |
philpem@0 | 3057 | {d68000_sub_re_16 , 0xf1c0, 0x9140, 0x3f8}, |
philpem@0 | 3058 | {d68000_sub_re_32 , 0xf1c0, 0x9180, 0x3f8}, |
philpem@0 | 3059 | {d68000_suba_16 , 0xf1c0, 0x90c0, 0xfff}, |
philpem@0 | 3060 | {d68000_suba_32 , 0xf1c0, 0x91c0, 0xfff}, |
philpem@0 | 3061 | {d68000_subi_8 , 0xffc0, 0x0400, 0xbf8}, |
philpem@0 | 3062 | {d68000_subi_16 , 0xffc0, 0x0440, 0xbf8}, |
philpem@0 | 3063 | {d68000_subi_32 , 0xffc0, 0x0480, 0xbf8}, |
philpem@0 | 3064 | {d68000_subq_8 , 0xf1c0, 0x5100, 0xbf8}, |
philpem@0 | 3065 | {d68000_subq_16 , 0xf1c0, 0x5140, 0xff8}, |
philpem@0 | 3066 | {d68000_subq_32 , 0xf1c0, 0x5180, 0xff8}, |
philpem@0 | 3067 | {d68000_subx_rr_8 , 0xf1f8, 0x9100, 0x000}, |
philpem@0 | 3068 | {d68000_subx_rr_16 , 0xf1f8, 0x9140, 0x000}, |
philpem@0 | 3069 | {d68000_subx_rr_32 , 0xf1f8, 0x9180, 0x000}, |
philpem@0 | 3070 | {d68000_subx_mm_8 , 0xf1f8, 0x9108, 0x000}, |
philpem@0 | 3071 | {d68000_subx_mm_16 , 0xf1f8, 0x9148, 0x000}, |
philpem@0 | 3072 | {d68000_subx_mm_32 , 0xf1f8, 0x9188, 0x000}, |
philpem@0 | 3073 | {d68000_swap , 0xfff8, 0x4840, 0x000}, |
philpem@0 | 3074 | {d68000_tas , 0xffc0, 0x4ac0, 0xbf8}, |
philpem@0 | 3075 | {d68000_trap , 0xfff0, 0x4e40, 0x000}, |
philpem@0 | 3076 | {d68020_trapcc_0 , 0xf0ff, 0x50fc, 0x000}, |
philpem@0 | 3077 | {d68020_trapcc_16 , 0xf0ff, 0x50fa, 0x000}, |
philpem@0 | 3078 | {d68020_trapcc_32 , 0xf0ff, 0x50fb, 0x000}, |
philpem@0 | 3079 | {d68000_trapv , 0xffff, 0x4e76, 0x000}, |
philpem@0 | 3080 | {d68000_tst_8 , 0xffc0, 0x4a00, 0xbf8}, |
philpem@0 | 3081 | {d68020_tst_pcdi_8 , 0xffff, 0x4a3a, 0x000}, |
philpem@0 | 3082 | {d68020_tst_pcix_8 , 0xffff, 0x4a3b, 0x000}, |
philpem@0 | 3083 | {d68020_tst_i_8 , 0xffff, 0x4a3c, 0x000}, |
philpem@0 | 3084 | {d68000_tst_16 , 0xffc0, 0x4a40, 0xbf8}, |
philpem@0 | 3085 | {d68020_tst_a_16 , 0xfff8, 0x4a48, 0x000}, |
philpem@0 | 3086 | {d68020_tst_pcdi_16 , 0xffff, 0x4a7a, 0x000}, |
philpem@0 | 3087 | {d68020_tst_pcix_16 , 0xffff, 0x4a7b, 0x000}, |
philpem@0 | 3088 | {d68020_tst_i_16 , 0xffff, 0x4a7c, 0x000}, |
philpem@0 | 3089 | {d68000_tst_32 , 0xffc0, 0x4a80, 0xbf8}, |
philpem@0 | 3090 | {d68020_tst_a_32 , 0xfff8, 0x4a88, 0x000}, |
philpem@0 | 3091 | {d68020_tst_pcdi_32 , 0xffff, 0x4aba, 0x000}, |
philpem@0 | 3092 | {d68020_tst_pcix_32 , 0xffff, 0x4abb, 0x000}, |
philpem@0 | 3093 | {d68020_tst_i_32 , 0xffff, 0x4abc, 0x000}, |
philpem@0 | 3094 | {d68000_unlk , 0xfff8, 0x4e58, 0x000}, |
philpem@0 | 3095 | {d68020_unpk_rr , 0xf1f8, 0x8180, 0x000}, |
philpem@0 | 3096 | {d68020_unpk_mm , 0xf1f8, 0x8188, 0x000}, |
philpem@0 | 3097 | {0, 0, 0, 0} |
philpem@0 | 3098 | }; |
philpem@0 | 3099 | |
philpem@0 | 3100 | /* Check if opcode is using a valid ea mode */ |
philpem@0 | 3101 | static int valid_ea(uint opcode, uint mask) |
philpem@0 | 3102 | { |
philpem@0 | 3103 | if(mask == 0) |
philpem@0 | 3104 | return 1; |
philpem@0 | 3105 | |
philpem@0 | 3106 | switch(opcode & 0x3f) |
philpem@0 | 3107 | { |
philpem@0 | 3108 | case 0x00: case 0x01: case 0x02: case 0x03: |
philpem@0 | 3109 | case 0x04: case 0x05: case 0x06: case 0x07: |
philpem@0 | 3110 | return (mask & 0x800) != 0; |
philpem@0 | 3111 | case 0x08: case 0x09: case 0x0a: case 0x0b: |
philpem@0 | 3112 | case 0x0c: case 0x0d: case 0x0e: case 0x0f: |
philpem@0 | 3113 | return (mask & 0x400) != 0; |
philpem@0 | 3114 | case 0x10: case 0x11: case 0x12: case 0x13: |
philpem@0 | 3115 | case 0x14: case 0x15: case 0x16: case 0x17: |
philpem@0 | 3116 | return (mask & 0x200) != 0; |
philpem@0 | 3117 | case 0x18: case 0x19: case 0x1a: case 0x1b: |
philpem@0 | 3118 | case 0x1c: case 0x1d: case 0x1e: case 0x1f: |
philpem@0 | 3119 | return (mask & 0x100) != 0; |
philpem@0 | 3120 | case 0x20: case 0x21: case 0x22: case 0x23: |
philpem@0 | 3121 | case 0x24: case 0x25: case 0x26: case 0x27: |
philpem@0 | 3122 | return (mask & 0x080) != 0; |
philpem@0 | 3123 | case 0x28: case 0x29: case 0x2a: case 0x2b: |
philpem@0 | 3124 | case 0x2c: case 0x2d: case 0x2e: case 0x2f: |
philpem@0 | 3125 | return (mask & 0x040) != 0; |
philpem@0 | 3126 | case 0x30: case 0x31: case 0x32: case 0x33: |
philpem@0 | 3127 | case 0x34: case 0x35: case 0x36: case 0x37: |
philpem@0 | 3128 | return (mask & 0x020) != 0; |
philpem@0 | 3129 | case 0x38: |
philpem@0 | 3130 | return (mask & 0x010) != 0; |
philpem@0 | 3131 | case 0x39: |
philpem@0 | 3132 | return (mask & 0x008) != 0; |
philpem@0 | 3133 | case 0x3a: |
philpem@0 | 3134 | return (mask & 0x002) != 0; |
philpem@0 | 3135 | case 0x3b: |
philpem@0 | 3136 | return (mask & 0x001) != 0; |
philpem@0 | 3137 | case 0x3c: |
philpem@0 | 3138 | return (mask & 0x004) != 0; |
philpem@0 | 3139 | } |
philpem@0 | 3140 | return 0; |
philpem@0 | 3141 | |
philpem@0 | 3142 | } |
philpem@0 | 3143 | |
philpem@0 | 3144 | /* Used by qsort */ |
philpem@0 | 3145 | static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr) |
philpem@0 | 3146 | { |
philpem@0 | 3147 | uint a = ((const opcode_struct*)aptr)->mask; |
philpem@0 | 3148 | uint b = ((const opcode_struct*)bptr)->mask; |
philpem@0 | 3149 | |
philpem@0 | 3150 | a = ((a & 0xAAAA) >> 1) + (a & 0x5555); |
philpem@0 | 3151 | a = ((a & 0xCCCC) >> 2) + (a & 0x3333); |
philpem@0 | 3152 | a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F); |
philpem@0 | 3153 | a = ((a & 0xFF00) >> 8) + (a & 0x00FF); |
philpem@0 | 3154 | |
philpem@0 | 3155 | b = ((b & 0xAAAA) >> 1) + (b & 0x5555); |
philpem@0 | 3156 | b = ((b & 0xCCCC) >> 2) + (b & 0x3333); |
philpem@0 | 3157 | b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F); |
philpem@0 | 3158 | b = ((b & 0xFF00) >> 8) + (b & 0x00FF); |
philpem@0 | 3159 | |
philpem@0 | 3160 | return b - a; /* reversed to get greatest to least sorting */ |
philpem@0 | 3161 | } |
philpem@0 | 3162 | |
philpem@0 | 3163 | /* build the opcode handler jump table */ |
philpem@0 | 3164 | static void build_opcode_table(void) |
philpem@0 | 3165 | { |
philpem@0 | 3166 | uint i; |
philpem@0 | 3167 | uint opcode; |
philpem@0 | 3168 | opcode_struct* ostruct; |
philpem@0 | 3169 | uint opcode_info_length = 0; |
philpem@0 | 3170 | |
philpem@0 | 3171 | for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++) |
philpem@0 | 3172 | opcode_info_length++; |
philpem@0 | 3173 | |
philpem@0 | 3174 | qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits); |
philpem@0 | 3175 | |
philpem@0 | 3176 | for(i=0;i<0x10000;i++) |
philpem@0 | 3177 | { |
philpem@0 | 3178 | g_instruction_table[i] = d68000_illegal; /* default to illegal */ |
philpem@0 | 3179 | opcode = i; |
philpem@0 | 3180 | /* search through opcode info for a match */ |
philpem@0 | 3181 | for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++) |
philpem@0 | 3182 | { |
philpem@0 | 3183 | /* match opcode mask and allowed ea modes */ |
philpem@0 | 3184 | if((opcode & ostruct->mask) == ostruct->match) |
philpem@0 | 3185 | { |
philpem@0 | 3186 | /* Handle destination ea for move instructions */ |
philpem@0 | 3187 | if((ostruct->opcode_handler == d68000_move_8 || |
philpem@0 | 3188 | ostruct->opcode_handler == d68000_move_16 || |
philpem@0 | 3189 | ostruct->opcode_handler == d68000_move_32) && |
philpem@0 | 3190 | !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8)) |
philpem@0 | 3191 | continue; |
philpem@0 | 3192 | if(valid_ea(opcode, ostruct->ea_mask)) |
philpem@0 | 3193 | { |
philpem@0 | 3194 | g_instruction_table[i] = ostruct->opcode_handler; |
philpem@0 | 3195 | break; |
philpem@0 | 3196 | } |
philpem@0 | 3197 | } |
philpem@0 | 3198 | } |
philpem@0 | 3199 | } |
philpem@0 | 3200 | } |
philpem@0 | 3201 | |
philpem@0 | 3202 | |
philpem@0 | 3203 | |
philpem@0 | 3204 | /* ======================================================================== */ |
philpem@0 | 3205 | /* ================================= API ================================== */ |
philpem@0 | 3206 | /* ======================================================================== */ |
philpem@0 | 3207 | |
philpem@0 | 3208 | /* Disasemble one instruction at pc and store in str_buff */ |
philpem@0 | 3209 | unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type) |
philpem@0 | 3210 | { |
philpem@0 | 3211 | if(!g_initialized) |
philpem@0 | 3212 | { |
philpem@0 | 3213 | build_opcode_table(); |
philpem@0 | 3214 | g_initialized = 1; |
philpem@0 | 3215 | } |
philpem@0 | 3216 | switch(cpu_type) |
philpem@0 | 3217 | { |
philpem@0 | 3218 | case M68K_CPU_TYPE_68000: |
philpem@0 | 3219 | g_cpu_type = TYPE_68000; |
philpem@0 | 3220 | g_address_mask = 0x00ffffff; |
philpem@0 | 3221 | break; |
philpem@0 | 3222 | case M68K_CPU_TYPE_68010: |
philpem@0 | 3223 | g_cpu_type = TYPE_68010; |
philpem@0 | 3224 | g_address_mask = 0x00ffffff; |
philpem@0 | 3225 | break; |
philpem@0 | 3226 | case M68K_CPU_TYPE_68EC020: |
philpem@0 | 3227 | g_cpu_type = TYPE_68020; |
philpem@0 | 3228 | g_address_mask = 0x00ffffff; |
philpem@0 | 3229 | break; |
philpem@0 | 3230 | case M68K_CPU_TYPE_68020: |
philpem@0 | 3231 | g_cpu_type = TYPE_68020; |
philpem@0 | 3232 | g_address_mask = 0xffffffff; |
philpem@0 | 3233 | break; |
philpem@0 | 3234 | case M68K_CPU_TYPE_68030: |
philpem@0 | 3235 | g_cpu_type = TYPE_68030; |
philpem@0 | 3236 | g_address_mask = 0xffffffff; |
philpem@0 | 3237 | break; |
philpem@0 | 3238 | case M68K_CPU_TYPE_68040: |
philpem@0 | 3239 | g_cpu_type = TYPE_68040; |
philpem@0 | 3240 | g_address_mask = 0xffffffff; |
philpem@0 | 3241 | break; |
philpem@0 | 3242 | default: |
philpem@0 | 3243 | return 0; |
philpem@0 | 3244 | } |
philpem@0 | 3245 | |
philpem@0 | 3246 | g_cpu_pc = pc; |
philpem@0 | 3247 | g_helper_str[0] = 0; |
philpem@0 | 3248 | g_cpu_ir = read_imm_16(); |
philpem@0 | 3249 | g_instruction_table[g_cpu_ir](); |
philpem@0 | 3250 | sprintf(str_buff, "%s%s", g_dasm_str, g_helper_str); |
philpem@0 | 3251 | return g_cpu_pc - pc; |
philpem@0 | 3252 | } |
philpem@0 | 3253 | |
philpem@0 | 3254 | char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type) |
philpem@0 | 3255 | { |
philpem@0 | 3256 | static char buff[100]; |
philpem@0 | 3257 | buff[0] = 0; |
philpem@0 | 3258 | m68k_disassemble(buff, pc, cpu_type); |
philpem@0 | 3259 | return buff; |
philpem@0 | 3260 | } |
philpem@0 | 3261 | |
philpem@0 | 3262 | /* Check if the instruction is a valid one */ |
philpem@0 | 3263 | unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type) |
philpem@0 | 3264 | { |
philpem@0 | 3265 | if(!g_initialized) |
philpem@0 | 3266 | { |
philpem@0 | 3267 | build_opcode_table(); |
philpem@0 | 3268 | g_initialized = 1; |
philpem@0 | 3269 | } |
philpem@0 | 3270 | |
philpem@0 | 3271 | instruction &= 0xffff; |
philpem@0 | 3272 | if(g_instruction_table[instruction] == d68000_illegal) |
philpem@0 | 3273 | return 0; |
philpem@0 | 3274 | |
philpem@0 | 3275 | switch(cpu_type) |
philpem@0 | 3276 | { |
philpem@0 | 3277 | case M68K_CPU_TYPE_68000: |
philpem@0 | 3278 | if(g_instruction_table[instruction] == d68010_bkpt) |
philpem@0 | 3279 | return 0; |
philpem@0 | 3280 | if(g_instruction_table[instruction] == d68010_move_fr_ccr) |
philpem@0 | 3281 | return 0; |
philpem@0 | 3282 | if(g_instruction_table[instruction] == d68010_movec) |
philpem@0 | 3283 | return 0; |
philpem@0 | 3284 | if(g_instruction_table[instruction] == d68010_moves_8) |
philpem@0 | 3285 | return 0; |
philpem@0 | 3286 | if(g_instruction_table[instruction] == d68010_moves_16) |
philpem@0 | 3287 | return 0; |
philpem@0 | 3288 | if(g_instruction_table[instruction] == d68010_moves_32) |
philpem@0 | 3289 | return 0; |
philpem@0 | 3290 | if(g_instruction_table[instruction] == d68010_rtd) |
philpem@0 | 3291 | return 0; |
philpem@0 | 3292 | case M68K_CPU_TYPE_68010: |
philpem@0 | 3293 | if(g_instruction_table[instruction] == d68020_bcc_32) |
philpem@0 | 3294 | return 0; |
philpem@0 | 3295 | if(g_instruction_table[instruction] == d68020_bfchg) |
philpem@0 | 3296 | return 0; |
philpem@0 | 3297 | if(g_instruction_table[instruction] == d68020_bfclr) |
philpem@0 | 3298 | return 0; |
philpem@0 | 3299 | if(g_instruction_table[instruction] == d68020_bfexts) |
philpem@0 | 3300 | return 0; |
philpem@0 | 3301 | if(g_instruction_table[instruction] == d68020_bfextu) |
philpem@0 | 3302 | return 0; |
philpem@0 | 3303 | if(g_instruction_table[instruction] == d68020_bfffo) |
philpem@0 | 3304 | return 0; |
philpem@0 | 3305 | if(g_instruction_table[instruction] == d68020_bfins) |
philpem@0 | 3306 | return 0; |
philpem@0 | 3307 | if(g_instruction_table[instruction] == d68020_bfset) |
philpem@0 | 3308 | return 0; |
philpem@0 | 3309 | if(g_instruction_table[instruction] == d68020_bftst) |
philpem@0 | 3310 | return 0; |
philpem@0 | 3311 | if(g_instruction_table[instruction] == d68020_bra_32) |
philpem@0 | 3312 | return 0; |
philpem@0 | 3313 | if(g_instruction_table[instruction] == d68020_bsr_32) |
philpem@0 | 3314 | return 0; |
philpem@0 | 3315 | if(g_instruction_table[instruction] == d68020_callm) |
philpem@0 | 3316 | return 0; |
philpem@0 | 3317 | if(g_instruction_table[instruction] == d68020_cas_8) |
philpem@0 | 3318 | return 0; |
philpem@0 | 3319 | if(g_instruction_table[instruction] == d68020_cas_16) |
philpem@0 | 3320 | return 0; |
philpem@0 | 3321 | if(g_instruction_table[instruction] == d68020_cas_32) |
philpem@0 | 3322 | return 0; |
philpem@0 | 3323 | if(g_instruction_table[instruction] == d68020_cas2_16) |
philpem@0 | 3324 | return 0; |
philpem@0 | 3325 | if(g_instruction_table[instruction] == d68020_cas2_32) |
philpem@0 | 3326 | return 0; |
philpem@0 | 3327 | if(g_instruction_table[instruction] == d68020_chk_32) |
philpem@0 | 3328 | return 0; |
philpem@0 | 3329 | if(g_instruction_table[instruction] == d68020_chk2_cmp2_8) |
philpem@0 | 3330 | return 0; |
philpem@0 | 3331 | if(g_instruction_table[instruction] == d68020_chk2_cmp2_16) |
philpem@0 | 3332 | return 0; |
philpem@0 | 3333 | if(g_instruction_table[instruction] == d68020_chk2_cmp2_32) |
philpem@0 | 3334 | return 0; |
philpem@0 | 3335 | if(g_instruction_table[instruction] == d68020_cmpi_pcdi_8) |
philpem@0 | 3336 | return 0; |
philpem@0 | 3337 | if(g_instruction_table[instruction] == d68020_cmpi_pcix_8) |
philpem@0 | 3338 | return 0; |
philpem@0 | 3339 | if(g_instruction_table[instruction] == d68020_cmpi_pcdi_16) |
philpem@0 | 3340 | return 0; |
philpem@0 | 3341 | if(g_instruction_table[instruction] == d68020_cmpi_pcix_16) |
philpem@0 | 3342 | return 0; |
philpem@0 | 3343 | if(g_instruction_table[instruction] == d68020_cmpi_pcdi_32) |
philpem@0 | 3344 | return 0; |
philpem@0 | 3345 | if(g_instruction_table[instruction] == d68020_cmpi_pcix_32) |
philpem@0 | 3346 | return 0; |
philpem@0 | 3347 | if(g_instruction_table[instruction] == d68020_cpbcc_16) |
philpem@0 | 3348 | return 0; |
philpem@0 | 3349 | if(g_instruction_table[instruction] == d68020_cpbcc_32) |
philpem@0 | 3350 | return 0; |
philpem@0 | 3351 | if(g_instruction_table[instruction] == d68020_cpdbcc) |
philpem@0 | 3352 | return 0; |
philpem@0 | 3353 | if(g_instruction_table[instruction] == d68020_cpgen) |
philpem@0 | 3354 | return 0; |
philpem@0 | 3355 | if(g_instruction_table[instruction] == d68020_cprestore) |
philpem@0 | 3356 | return 0; |
philpem@0 | 3357 | if(g_instruction_table[instruction] == d68020_cpsave) |
philpem@0 | 3358 | return 0; |
philpem@0 | 3359 | if(g_instruction_table[instruction] == d68020_cpscc) |
philpem@0 | 3360 | return 0; |
philpem@0 | 3361 | if(g_instruction_table[instruction] == d68020_cptrapcc_0) |
philpem@0 | 3362 | return 0; |
philpem@0 | 3363 | if(g_instruction_table[instruction] == d68020_cptrapcc_16) |
philpem@0 | 3364 | return 0; |
philpem@0 | 3365 | if(g_instruction_table[instruction] == d68020_cptrapcc_32) |
philpem@0 | 3366 | return 0; |
philpem@0 | 3367 | if(g_instruction_table[instruction] == d68020_divl) |
philpem@0 | 3368 | return 0; |
philpem@0 | 3369 | if(g_instruction_table[instruction] == d68020_extb_32) |
philpem@0 | 3370 | return 0; |
philpem@0 | 3371 | if(g_instruction_table[instruction] == d68020_link_32) |
philpem@0 | 3372 | return 0; |
philpem@0 | 3373 | if(g_instruction_table[instruction] == d68020_mull) |
philpem@0 | 3374 | return 0; |
philpem@0 | 3375 | if(g_instruction_table[instruction] == d68020_pack_rr) |
philpem@0 | 3376 | return 0; |
philpem@0 | 3377 | if(g_instruction_table[instruction] == d68020_pack_mm) |
philpem@0 | 3378 | return 0; |
philpem@0 | 3379 | if(g_instruction_table[instruction] == d68020_rtm) |
philpem@0 | 3380 | return 0; |
philpem@0 | 3381 | if(g_instruction_table[instruction] == d68020_trapcc_0) |
philpem@0 | 3382 | return 0; |
philpem@0 | 3383 | if(g_instruction_table[instruction] == d68020_trapcc_16) |
philpem@0 | 3384 | return 0; |
philpem@0 | 3385 | if(g_instruction_table[instruction] == d68020_trapcc_32) |
philpem@0 | 3386 | return 0; |
philpem@0 | 3387 | if(g_instruction_table[instruction] == d68020_tst_pcdi_8) |
philpem@0 | 3388 | return 0; |
philpem@0 | 3389 | if(g_instruction_table[instruction] == d68020_tst_pcix_8) |
philpem@0 | 3390 | return 0; |
philpem@0 | 3391 | if(g_instruction_table[instruction] == d68020_tst_i_8) |
philpem@0 | 3392 | return 0; |
philpem@0 | 3393 | if(g_instruction_table[instruction] == d68020_tst_a_16) |
philpem@0 | 3394 | return 0; |
philpem@0 | 3395 | if(g_instruction_table[instruction] == d68020_tst_pcdi_16) |
philpem@0 | 3396 | return 0; |
philpem@0 | 3397 | if(g_instruction_table[instruction] == d68020_tst_pcix_16) |
philpem@0 | 3398 | return 0; |
philpem@0 | 3399 | if(g_instruction_table[instruction] == d68020_tst_i_16) |
philpem@0 | 3400 | return 0; |
philpem@0 | 3401 | if(g_instruction_table[instruction] == d68020_tst_a_32) |
philpem@0 | 3402 | return 0; |
philpem@0 | 3403 | if(g_instruction_table[instruction] == d68020_tst_pcdi_32) |
philpem@0 | 3404 | return 0; |
philpem@0 | 3405 | if(g_instruction_table[instruction] == d68020_tst_pcix_32) |
philpem@0 | 3406 | return 0; |
philpem@0 | 3407 | if(g_instruction_table[instruction] == d68020_tst_i_32) |
philpem@0 | 3408 | return 0; |
philpem@0 | 3409 | if(g_instruction_table[instruction] == d68020_unpk_rr) |
philpem@0 | 3410 | return 0; |
philpem@0 | 3411 | if(g_instruction_table[instruction] == d68020_unpk_mm) |
philpem@0 | 3412 | return 0; |
philpem@0 | 3413 | case M68K_CPU_TYPE_68EC020: |
philpem@0 | 3414 | case M68K_CPU_TYPE_68020: |
philpem@0 | 3415 | case M68K_CPU_TYPE_68030: |
philpem@0 | 3416 | if(g_instruction_table[instruction] == d68040_cinv) |
philpem@0 | 3417 | return 0; |
philpem@0 | 3418 | if(g_instruction_table[instruction] == d68040_cpush) |
philpem@0 | 3419 | return 0; |
philpem@0 | 3420 | if(g_instruction_table[instruction] == d68040_move16_pi_pi) |
philpem@0 | 3421 | return 0; |
philpem@0 | 3422 | if(g_instruction_table[instruction] == d68040_move16_pi_al) |
philpem@0 | 3423 | return 0; |
philpem@0 | 3424 | if(g_instruction_table[instruction] == d68040_move16_al_pi) |
philpem@0 | 3425 | return 0; |
philpem@0 | 3426 | if(g_instruction_table[instruction] == d68040_move16_ai_al) |
philpem@0 | 3427 | return 0; |
philpem@0 | 3428 | if(g_instruction_table[instruction] == d68040_move16_al_ai) |
philpem@0 | 3429 | return 0; |
philpem@0 | 3430 | } |
philpem@0 | 3431 | if(cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 && |
philpem@0 | 3432 | (g_instruction_table[instruction] == d68020_callm || |
philpem@0 | 3433 | g_instruction_table[instruction] == d68020_rtm)) |
philpem@0 | 3434 | return 0; |
philpem@0 | 3435 | |
philpem@0 | 3436 | return 1; |
philpem@0 | 3437 | } |
philpem@0 | 3438 | |
philpem@0 | 3439 | |
philpem@0 | 3440 | |
philpem@0 | 3441 | /* ======================================================================== */ |
philpem@0 | 3442 | /* ============================== END OF FILE ============================= */ |
philpem@0 | 3443 | /* ======================================================================== */ |