Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1 | /* ======================================================================== */ |
| 2 | /* ========================= LICENSING & COPYRIGHT ======================== */ |
| 3 | /* ======================================================================== */ |
| 4 | /* |
| 5 | * MUSASHI |
| 6 | * Version 3.4 |
| 7 | * |
| 8 | * A portable Motorola M680x0 processor emulation engine. |
| 9 | * Copyright 1998-2001 Karl Stenerud. All rights reserved. |
| 10 | * |
| 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | * of this software and associated documentation files (the "Software"), to deal |
| 13 | * in the Software without restriction, including without limitation the rights |
| 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | * copies of the Software, and to permit persons to whom the Software is |
| 16 | * furnished to do so, subject to the following conditions: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice shall be included in |
| 19 | * all copies or substantial portions of the Software. |
| 20 | |
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 27 | * THE SOFTWARE. |
| 28 | */ |
| 29 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 30 | /* The code bellow is based on MUSASHI but has been heavily modified for capstore by |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 31 | * Daniel Collin <daniel@collin.com> 2015-2016 */ |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 32 | |
| 33 | /* ======================================================================== */ |
| 34 | /* ================================ INCLUDES ============================== */ |
| 35 | /* ======================================================================== */ |
| 36 | |
| 37 | #include <stdlib.h> |
| 38 | #include <stdio.h> |
| 39 | #include <string.h> |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 40 | |
| 41 | #include "../../cs_priv.h" |
| 42 | #include "../../utils.h" |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 43 | |
| 44 | #include "../../MCInst.h" |
| 45 | #include "../../MCInstrDesc.h" |
| 46 | #include "../../MCRegisterInfo.h" |
Daniel Collin | fc63aca | 2015-10-04 14:12:59 +0200 | [diff] [blame] | 47 | #include "M68KInstPrinter.h" |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 48 | #include "M68KDisassembler.h" |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 49 | |
| 50 | #ifndef DECL_SPEC |
| 51 | #define DECL_SPEC |
| 52 | #endif |
| 53 | |
| 54 | /* ======================================================================== */ |
| 55 | /* ============================ GENERAL DEFINES =========================== */ |
| 56 | /* ======================================================================== */ |
| 57 | |
| 58 | /* unsigned int and int must be at least 32 bits wide */ |
| 59 | #undef uint |
| 60 | #define uint unsigned int |
| 61 | |
| 62 | /* Bit Isolation Functions */ |
| 63 | #define BIT_0(A) ((A) & 0x00000001) |
| 64 | #define BIT_1(A) ((A) & 0x00000002) |
| 65 | #define BIT_2(A) ((A) & 0x00000004) |
| 66 | #define BIT_3(A) ((A) & 0x00000008) |
| 67 | #define BIT_4(A) ((A) & 0x00000010) |
| 68 | #define BIT_5(A) ((A) & 0x00000020) |
| 69 | #define BIT_6(A) ((A) & 0x00000040) |
| 70 | #define BIT_7(A) ((A) & 0x00000080) |
| 71 | #define BIT_8(A) ((A) & 0x00000100) |
| 72 | #define BIT_9(A) ((A) & 0x00000200) |
| 73 | #define BIT_A(A) ((A) & 0x00000400) |
| 74 | #define BIT_B(A) ((A) & 0x00000800) |
| 75 | #define BIT_C(A) ((A) & 0x00001000) |
| 76 | #define BIT_D(A) ((A) & 0x00002000) |
| 77 | #define BIT_E(A) ((A) & 0x00004000) |
| 78 | #define BIT_F(A) ((A) & 0x00008000) |
| 79 | #define BIT_10(A) ((A) & 0x00010000) |
| 80 | #define BIT_11(A) ((A) & 0x00020000) |
| 81 | #define BIT_12(A) ((A) & 0x00040000) |
| 82 | #define BIT_13(A) ((A) & 0x00080000) |
| 83 | #define BIT_14(A) ((A) & 0x00100000) |
| 84 | #define BIT_15(A) ((A) & 0x00200000) |
| 85 | #define BIT_16(A) ((A) & 0x00400000) |
| 86 | #define BIT_17(A) ((A) & 0x00800000) |
| 87 | #define BIT_18(A) ((A) & 0x01000000) |
| 88 | #define BIT_19(A) ((A) & 0x02000000) |
| 89 | #define BIT_1A(A) ((A) & 0x04000000) |
| 90 | #define BIT_1B(A) ((A) & 0x08000000) |
| 91 | #define BIT_1C(A) ((A) & 0x10000000) |
| 92 | #define BIT_1D(A) ((A) & 0x20000000) |
| 93 | #define BIT_1E(A) ((A) & 0x40000000) |
| 94 | #define BIT_1F(A) ((A) & 0x80000000) |
| 95 | |
| 96 | /* These are the CPU types understood by this disassembler */ |
| 97 | #define TYPE_68000 1 |
| 98 | #define TYPE_68010 2 |
| 99 | #define TYPE_68020 4 |
| 100 | #define TYPE_68030 8 |
| 101 | #define TYPE_68040 16 |
| 102 | |
| 103 | #define M68000_ONLY TYPE_68000 |
| 104 | |
| 105 | #define M68010_ONLY TYPE_68010 |
| 106 | #define M68010_LESS (TYPE_68000 | TYPE_68010) |
| 107 | #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040) |
| 108 | |
| 109 | #define M68020_ONLY TYPE_68020 |
| 110 | #define M68020_LESS (TYPE_68010 | TYPE_68020) |
| 111 | #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040) |
| 112 | |
| 113 | #define M68030_ONLY TYPE_68030 |
| 114 | #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030) |
| 115 | #define M68030_PLUS (TYPE_68030 | TYPE_68040) |
| 116 | |
| 117 | #define M68040_PLUS TYPE_68040 |
| 118 | |
Daniel Collin | 997112d | 2015-10-09 08:25:10 +0200 | [diff] [blame] | 119 | enum { |
| 120 | M68K_CPU_TYPE_INVALID, |
| 121 | M68K_CPU_TYPE_68000, |
| 122 | M68K_CPU_TYPE_68010, |
| 123 | M68K_CPU_TYPE_68EC020, |
| 124 | M68K_CPU_TYPE_68020, |
| 125 | M68K_CPU_TYPE_68030, /* Supported by disassembler ONLY */ |
| 126 | M68K_CPU_TYPE_68040 /* Supported by disassembler ONLY */ |
| 127 | }; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 128 | |
| 129 | /* Extension word formats */ |
| 130 | #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff) |
| 131 | #define EXT_FULL(A) BIT_8(A) |
| 132 | #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0) |
| 133 | #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A)) |
| 134 | #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A)) |
| 135 | #define EXT_INDEX_REGISTER(A) (((A)>>12)&7) |
| 136 | #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3) |
| 137 | #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0) |
| 138 | #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4) |
| 139 | #define EXT_INDEX_SCALE(A) (((A)>>9)&3) |
| 140 | #define EXT_INDEX_LONG(A) BIT_B(A) |
| 141 | #define EXT_INDEX_AR(A) BIT_F(A) |
| 142 | #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10) |
| 143 | #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20) |
| 144 | #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30) |
| 145 | #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44) |
| 146 | #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44) |
| 147 | #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44) |
| 148 | |
| 149 | #define IS_BITSET(val,b) ((val) & (1 << (b))) |
| 150 | #define BITFIELD_MASK(sb,eb) (((1 << ((sb) + 1))-1) & (~((1 << (eb))-1))) |
| 151 | #define BITFIELD(val,sb,eb) ((BITFIELD_MASK(sb,eb) & (val)) >> (eb)) |
| 152 | |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 153 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 154 | |
Nicolas PLANEL | 626510c | 2015-10-12 21:31:16 +1100 | [diff] [blame] | 155 | static unsigned int m68k_read_disassembler_16(const m68k_info *info, const uint64_t addr) |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 156 | { |
Nicolas PLANEL | 97aca80 | 2015-10-10 19:55:42 +1100 | [diff] [blame] | 157 | const uint16_t v0 = info->code[addr + 0]; |
| 158 | const uint16_t v1 = info->code[addr + 1]; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 159 | return (v0 << 8) | v1; |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 160 | } |
| 161 | |
Nicolas PLANEL | 626510c | 2015-10-12 21:31:16 +1100 | [diff] [blame] | 162 | static unsigned int m68k_read_disassembler_32(const m68k_info *info, const uint64_t addr) |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 163 | { |
Nicolas PLANEL | 97aca80 | 2015-10-10 19:55:42 +1100 | [diff] [blame] | 164 | const uint32_t v0 = info->code[addr + 0]; |
| 165 | const uint32_t v1 = info->code[addr + 1]; |
| 166 | const uint32_t v2 = info->code[addr + 2]; |
| 167 | const uint32_t v3 = info->code[addr + 3]; |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 168 | return (v0 << 24) | (v1 << 16) | (v2 << 8) | v3; |
| 169 | } |
| 170 | |
Nicolas PLANEL | 626510c | 2015-10-12 21:31:16 +1100 | [diff] [blame] | 171 | static uint64_t m68k_read_disassembler_64(const m68k_info *info, const uint64_t addr) |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 172 | { |
Nicolas PLANEL | 97aca80 | 2015-10-10 19:55:42 +1100 | [diff] [blame] | 173 | const uint64_t v0 = info->code[addr + 0]; |
| 174 | const uint64_t v1 = info->code[addr + 1]; |
| 175 | const uint64_t v2 = info->code[addr + 2]; |
| 176 | const uint64_t v3 = info->code[addr + 3]; |
| 177 | const uint64_t v4 = info->code[addr + 4]; |
| 178 | const uint64_t v5 = info->code[addr + 5]; |
| 179 | const uint64_t v6 = info->code[addr + 6]; |
| 180 | const uint64_t v7 = info->code[addr + 7]; |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 181 | return (v0 << 56) | (v1 << 48) | (v2 << 40) | (v3 << 32) | (v4 << 24) | (v5 << 16) | (v6 << 8) | v7; |
| 182 | } |
| 183 | |
Nicolas PLANEL | 626510c | 2015-10-12 21:31:16 +1100 | [diff] [blame] | 184 | static unsigned int m68k_read_safe_16(const m68k_info *info, const uint64_t address) |
| 185 | { |
| 186 | const uint64_t addr = (address - info->baseAddress) & info->address_mask; |
| 187 | if (addr > (info->code_len - 2)) { |
| 188 | return 0xaaaa; |
| 189 | } |
| 190 | return m68k_read_disassembler_16(info, addr); |
| 191 | } |
| 192 | |
| 193 | static unsigned int m68k_read_safe_32(const m68k_info *info, const uint64_t address) |
| 194 | { |
| 195 | const uint64_t addr = (address - info->baseAddress) & info->address_mask; |
| 196 | if (addr > (info->code_len - 4)) { |
| 197 | return 0xaaaaaaaa; |
| 198 | } |
| 199 | return m68k_read_disassembler_32(info, addr); |
| 200 | } |
| 201 | |
| 202 | static uint64_t m68k_read_safe_64(const m68k_info *info, const uint64_t address) |
| 203 | { |
| 204 | const uint64_t addr = (address - info->baseAddress) & info->address_mask; |
| 205 | if (addr > (info->code_len - 8)) { |
| 206 | return 0xaaaaaaaaaaaaaaaa; |
| 207 | } |
| 208 | return m68k_read_disassembler_64(info, addr); |
| 209 | } |
| 210 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 211 | /* ======================================================================== */ |
| 212 | /* =============================== PROTOTYPES ============================= */ |
| 213 | /* ======================================================================== */ |
| 214 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 215 | /* make signed integers 100% portably */ |
| 216 | static int make_int_8(int value); |
| 217 | static int make_int_16(int value); |
| 218 | |
| 219 | /* Stuff to build the opcode handler jump table */ |
| 220 | static void build_opcode_table(void); |
| 221 | static int valid_ea(uint opcode, uint mask); |
| 222 | static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 223 | static void d68000_invalid(m68k_info *info); |
| 224 | static int instruction_is_valid(m68k_info *info, const unsigned int word_check); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 225 | |
| 226 | /* used to build opcode handler jump table */ |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 227 | typedef struct { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 228 | void (*opcode_handler)(m68k_info *info); /* handler function */ |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 229 | uint mask; /* mask on opcode */ |
| 230 | uint match; /* what to match after masking */ |
| 231 | uint ea_mask; /* what ea modes are allowed */ |
| 232 | uint mask2; /* mask the 2nd word */ |
| 233 | uint match2; /* what to match after masking */ |
| 234 | } opcode_struct; |
| 235 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 236 | typedef struct { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 237 | void (*instruction)(m68k_info *info); /* handler function */ |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 238 | uint word2_mask; /* mask the 2nd word */ |
| 239 | uint word2_match; /* what to match after masking */ |
| 240 | } instruction_struct; |
| 241 | |
| 242 | /* ======================================================================== */ |
| 243 | /* ================================= DATA ================================= */ |
| 244 | /* ======================================================================== */ |
| 245 | |
| 246 | /* Opcode handler jump table */ |
| 247 | static instruction_struct g_instruction_table[0x10000]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 248 | |
| 249 | /* used by ops like asr, ror, addq, etc */ |
| 250 | static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7}; |
| 251 | |
Nguyen Anh Quynh | 4815704 | 2015-10-04 17:40:46 +0800 | [diff] [blame] | 252 | static uint g_5bit_data_table[32] = { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 253 | 32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, |
| 254 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 |
| 255 | }; |
| 256 | |
| 257 | static m68k_insn s_branch_lut[] = { |
| 258 | M68K_INS_INVALID, M68K_INS_INVALID, M68K_INS_BHI, M68K_INS_BLS, |
| 259 | M68K_INS_BCC, M68K_INS_BCS, M68K_INS_BNE, M68K_INS_BEQ, |
| 260 | M68K_INS_BVC, M68K_INS_BVS, M68K_INS_BPL, M68K_INS_BMI, |
| 261 | M68K_INS_BGE, M68K_INS_BLT, M68K_INS_BGT, M68K_INS_BLE, |
| 262 | }; |
| 263 | |
| 264 | static m68k_insn s_dbcc_lut[] = { |
| 265 | M68K_INS_DBT, M68K_INS_DBF, M68K_INS_DBHI, M68K_INS_DBLS, |
| 266 | M68K_INS_DBCC, M68K_INS_DBCS, M68K_INS_DBNE, M68K_INS_DBEQ, |
| 267 | M68K_INS_DBVC, M68K_INS_DBVS, M68K_INS_DBPL, M68K_INS_DBMI, |
| 268 | M68K_INS_DBGE, M68K_INS_DBLT, M68K_INS_DBGT, M68K_INS_DBLE, |
| 269 | }; |
| 270 | |
| 271 | static m68k_insn s_scc_lut[] = { |
| 272 | M68K_INS_ST, M68K_INS_SF, M68K_INS_SHI, M68K_INS_SLS, |
| 273 | M68K_INS_SCC, M68K_INS_SCS, M68K_INS_SNE, M68K_INS_SEQ, |
| 274 | M68K_INS_SVC, M68K_INS_SVS, M68K_INS_SPL, M68K_INS_SMI, |
| 275 | M68K_INS_SGE, M68K_INS_SLT, M68K_INS_SGT, M68K_INS_SLE, |
| 276 | }; |
| 277 | |
| 278 | static m68k_insn s_trap_lut[] = { |
| 279 | M68K_INS_TRAPT, M68K_INS_TRAPF, M68K_INS_TRAPHI, M68K_INS_TRAPLS, |
| 280 | M68K_INS_TRAPCC, M68K_INS_TRAPCS, M68K_INS_TRAPNE, M68K_INS_TRAPEQ, |
| 281 | M68K_INS_TRAPVC, M68K_INS_TRAPVS, M68K_INS_TRAPPL, M68K_INS_TRAPMI, |
| 282 | M68K_INS_TRAPGE, M68K_INS_TRAPLT, M68K_INS_TRAPGT, M68K_INS_TRAPLE, |
| 283 | }; |
| 284 | |
| 285 | /* ======================================================================== */ |
| 286 | /* =========================== UTILITY FUNCTIONS ========================== */ |
| 287 | /* ======================================================================== */ |
| 288 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 289 | #define LIMIT_CPU_TYPES(info, ALLOWED_CPU_TYPES) \ |
| 290 | do { \ |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 291 | if (!(info->type & ALLOWED_CPU_TYPES)) { \ |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 292 | d68000_invalid(info); \ |
| 293 | return; \ |
| 294 | } \ |
| 295 | } while (0) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 296 | |
Nicolas PLANEL | 626510c | 2015-10-12 21:31:16 +1100 | [diff] [blame] | 297 | static unsigned int peek_imm_8(const m68k_info *info) { return (m68k_read_safe_16((info), (info)->pc)&0xff); } |
| 298 | static unsigned int peek_imm_16(const m68k_info *info) { return m68k_read_safe_16((info), (info)->pc); } |
| 299 | static unsigned int peek_imm_32(const m68k_info *info) { return m68k_read_safe_32((info), (info)->pc); } |
Nguyen Anh Quynh | 586e439 | 2016-03-08 00:49:15 +0800 | [diff] [blame] | 300 | static unsigned int peek_imm_64(const m68k_info *info) { return (unsigned int)m68k_read_safe_64((info), (info)->pc); } |
Nicolas PLANEL | af1d39d | 2015-10-08 22:16:39 +1100 | [diff] [blame] | 301 | |
Nicolas PLANEL | 97aca80 | 2015-10-10 19:55:42 +1100 | [diff] [blame] | 302 | static unsigned int read_imm_8(m68k_info *info) { const unsigned int value = peek_imm_8(info); (info)->pc+=2; return value; } |
| 303 | static unsigned int read_imm_16(m68k_info *info) { const unsigned int value = peek_imm_16(info); (info)->pc+=2; return value; } |
| 304 | static unsigned int read_imm_32(m68k_info *info) { const unsigned int value = peek_imm_32(info); (info)->pc+=4; return value; } |
| 305 | static unsigned int read_imm_64(m68k_info *info) { const unsigned int value = peek_imm_64(info); (info)->pc+=8; return value; } |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 306 | |
| 307 | /* Fake a split interface */ |
| 308 | #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0) |
| 309 | #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1) |
| 310 | #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2) |
| 311 | |
| 312 | #define get_imm_str_s8() get_imm_str_s(0) |
| 313 | #define get_imm_str_s16() get_imm_str_s(1) |
| 314 | #define get_imm_str_s32() get_imm_str_s(2) |
| 315 | |
| 316 | #define get_imm_str_u8() get_imm_str_u(0) |
| 317 | #define get_imm_str_u16() get_imm_str_u(1) |
| 318 | #define get_imm_str_u32() get_imm_str_u(2) |
| 319 | |
| 320 | |
| 321 | /* 100% portable signed int generators */ |
| 322 | static int make_int_8(int value) |
| 323 | { |
| 324 | return (value & 0x80) ? value | ~0xff : value & 0xff; |
| 325 | } |
| 326 | |
| 327 | static int make_int_16(int value) |
| 328 | { |
| 329 | return (value & 0x8000) ? value | ~0xffff : value & 0xffff; |
| 330 | } |
| 331 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 332 | static void get_with_index_address_mode(m68k_info *info, cs_m68k_op* op, uint instruction, uint size, bool is_pc) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 333 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 334 | uint extension = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 335 | |
| 336 | op->address_mode = M68K_AM_AREGI_INDEX_BASE_DISP; |
| 337 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 338 | if (EXT_FULL(extension)) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 339 | uint preindex; |
| 340 | uint postindex; |
| 341 | |
| 342 | op->mem.base_reg = M68K_REG_INVALID; |
| 343 | op->mem.index_reg = M68K_REG_INVALID; |
| 344 | |
| 345 | /* Not sure how to deal with this? |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 346 | if (EXT_EFFECTIVE_ZERO(extension)) { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 347 | strcpy(mode, "0"); |
| 348 | break; |
| 349 | } |
| 350 | */ |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 351 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 352 | op->mem.in_disp = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32(info) : read_imm_16(info)) : 0; |
| 353 | op->mem.out_disp = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32(info) : read_imm_16(info)) : 0; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 354 | |
| 355 | if (EXT_BASE_REGISTER_PRESENT(extension)) { |
| 356 | if (is_pc) { |
| 357 | op->mem.base_reg = M68K_REG_PC; |
| 358 | } else { |
| 359 | op->mem.base_reg = M68K_REG_A0 + (instruction & 7); |
| 360 | } |
| 361 | } |
| 362 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 363 | if (EXT_INDEX_REGISTER_PRESENT(extension)) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 364 | if (EXT_INDEX_AR(extension)) { |
| 365 | op->mem.index_reg = M68K_REG_A0 + EXT_INDEX_REGISTER(extension); |
| 366 | } else { |
| 367 | op->mem.index_reg = M68K_REG_D0 + EXT_INDEX_REGISTER(extension); |
| 368 | } |
| 369 | |
| 370 | op->mem.index_size = EXT_INDEX_LONG(extension) ? 1 : 0; |
| 371 | |
| 372 | if (EXT_INDEX_SCALE(extension)) { |
| 373 | op->mem.scale = 1 << EXT_INDEX_SCALE(extension); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | preindex = (extension & 7) > 0 && (extension & 7) < 4; |
| 378 | postindex = (extension & 7) > 4; |
| 379 | |
| 380 | if (preindex) { |
| 381 | op->address_mode = is_pc ? M68K_AM_PC_MEMI_PRE_INDEX : M68K_AM_MEMI_PRE_INDEX; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 382 | } else if (postindex) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 383 | op->address_mode = is_pc ? M68K_AM_PC_MEMI_POST_INDEX : M68K_AM_MEMI_POST_INDEX; |
| 384 | } |
| 385 | |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | op->mem.index_reg = (EXT_INDEX_AR(extension) ? M68K_REG_A0 : M68K_REG_D0) + EXT_INDEX_REGISTER(extension); |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 390 | op->mem.index_size = EXT_INDEX_LONG(extension) ? 1 : 0; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 391 | |
| 392 | if (EXT_8BIT_DISPLACEMENT(extension) == 0) { |
| 393 | if (is_pc) { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 394 | op->mem.base_reg = M68K_REG_PC; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 395 | op->address_mode = M68K_AM_PCI_INDEX_BASE_DISP; |
| 396 | } else { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 397 | op->mem.base_reg = M68K_REG_A0 + (instruction & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 398 | } |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 399 | } else { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 400 | if (is_pc) { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 401 | op->mem.base_reg = M68K_REG_PC; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 402 | op->address_mode = M68K_AM_PCI_INDEX_8_BIT_DISP; |
| 403 | } else { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 404 | op->mem.base_reg = M68K_REG_A0 + (instruction & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 405 | op->address_mode = M68K_AM_AREGI_INDEX_8_BIT_DISP; |
| 406 | } |
| 407 | |
| 408 | op->mem.disp = extension & 0xff; |
| 409 | } |
| 410 | |
| 411 | if (EXT_INDEX_SCALE(extension)) { |
| 412 | op->mem.scale = 1 << EXT_INDEX_SCALE(extension); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | /* Make string of effective address mode */ |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 417 | void get_ea_mode_op(m68k_info *info, cs_m68k_op* op, uint instruction, uint size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 418 | { |
| 419 | // default to memory |
| 420 | |
| 421 | op->type = M68K_OP_MEM; |
| 422 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 423 | switch (instruction & 0x3f) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 424 | case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 425 | /* data register direct */ |
| 426 | op->address_mode = M68K_AM_REG_DIRECT_DATA; |
| 427 | op->reg = M68K_REG_D0 + (instruction & 7); |
| 428 | op->type = M68K_OP_REG; |
| 429 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 430 | |
| 431 | case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 432 | /* address register direct */ |
| 433 | op->address_mode = M68K_AM_REG_DIRECT_ADDR; |
| 434 | op->reg = M68K_REG_A0 + (instruction & 7); |
| 435 | op->type = M68K_OP_REG; |
| 436 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 437 | |
| 438 | case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 439 | /* address register indirect */ |
| 440 | op->address_mode = M68K_AM_REGI_ADDR; |
| 441 | op->reg = M68K_REG_A0 + (instruction & 7); |
| 442 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 443 | |
| 444 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 445 | /* address register indirect with postincrement */ |
| 446 | op->address_mode = M68K_AM_REGI_ADDR_POST_INC; |
| 447 | op->reg = M68K_REG_A0 + (instruction & 7); |
| 448 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 449 | |
| 450 | case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 451 | /* address register indirect with predecrement */ |
| 452 | op->address_mode = M68K_AM_REGI_ADDR_PRE_DEC; |
| 453 | op->reg = M68K_REG_A0 + (instruction & 7); |
| 454 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 455 | |
| 456 | case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 457 | /* address register indirect with displacement*/ |
| 458 | op->address_mode = M68K_AM_REGI_ADDR_DISP; |
| 459 | op->mem.base_reg = M68K_REG_A0 + (instruction & 7); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 460 | op->mem.disp = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 461 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 462 | |
| 463 | case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 464 | /* address register indirect with index */ |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 465 | get_with_index_address_mode(info, op, instruction, size, false); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 466 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 467 | |
| 468 | case 0x38: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 469 | /* absolute short address */ |
| 470 | op->address_mode = M68K_AM_ABSOLUTE_DATA_SHORT; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 471 | op->imm = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 472 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 473 | |
| 474 | case 0x39: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 475 | /* absolute long address */ |
| 476 | op->address_mode = M68K_AM_ABSOLUTE_DATA_LONG; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 477 | op->imm = read_imm_32(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 478 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 479 | |
| 480 | case 0x3a: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 481 | /* program counter with displacement */ |
| 482 | op->address_mode = M68K_AM_PCI_DISP; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 483 | op->mem.disp = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 484 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 485 | |
| 486 | case 0x3b: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 487 | /* program counter with index */ |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 488 | get_with_index_address_mode(info, op, instruction, size, true); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 489 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 490 | |
| 491 | case 0x3c: |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 492 | op->address_mode = M68K_AM_IMMIDIATE; |
| 493 | op->type = M68K_OP_IMM; |
| 494 | |
| 495 | if (size == 1) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 496 | op->imm = read_imm_8(info) & 0xff; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 497 | else if (size == 2) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 498 | op->imm = read_imm_16(info) & 0xffff; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 499 | else if (size == 4) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 500 | op->imm = read_imm_32(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 501 | else |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 502 | op->imm = read_imm_64(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 503 | |
| 504 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 505 | |
| 506 | default: |
| 507 | break; |
| 508 | } |
| 509 | } |
| 510 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 511 | static void set_insn_group(m68k_info *info, m68k_group_type group) |
| 512 | { |
| 513 | info->groups[info->groups_count++] = (uint8_t)group; |
| 514 | } |
| 515 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 516 | static cs_m68k* build_init_op(m68k_info *info, int opcode, int count, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 517 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 518 | cs_m68k* ext; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 519 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 520 | MCInst_setOpcode(info->inst, opcode); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 521 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 522 | ext = &info->extension; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 523 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 524 | ext->op_count = count; |
| 525 | ext->op_size.type = M68K_SIZE_TYPE_CPU; |
| 526 | ext->op_size.cpu_size = size; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 527 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 528 | return ext; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 529 | } |
| 530 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 531 | static void build_re_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 532 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 533 | cs_m68k_op* op0; |
| 534 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 535 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 536 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 537 | op0 = &ext->operands[0]; |
| 538 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 539 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 540 | if (isDreg) { |
| 541 | op0->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 542 | op0->reg = M68K_REG_D0 + ((info->ir >> 9 ) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 543 | } else { |
| 544 | op0->address_mode = M68K_AM_REG_DIRECT_ADDR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 545 | op0->reg = M68K_REG_A0 + ((info->ir >> 9 ) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 546 | } |
| 547 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 548 | get_ea_mode_op(info, op1, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 549 | } |
| 550 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 551 | static void build_re_1(m68k_info *info, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 552 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 553 | build_re_gen_1(info, true, opcode, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 554 | } |
| 555 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 556 | static void build_er_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 557 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 558 | cs_m68k_op* op0; |
| 559 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 560 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 561 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 562 | op0 = &ext->operands[0]; |
| 563 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 564 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 565 | get_ea_mode_op(info, op0, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 566 | |
| 567 | if (isDreg) { |
| 568 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 569 | op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 570 | } else { |
| 571 | op1->address_mode = M68K_AM_REG_DIRECT_ADDR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 572 | op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 573 | } |
| 574 | } |
| 575 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 576 | static void build_rr(m68k_info *info, int opcode, uint8_t size, int imm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 577 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 578 | cs_m68k_op* op0; |
| 579 | cs_m68k_op* op1; |
| 580 | cs_m68k_op* op2; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 581 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 582 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 583 | op0 = &ext->operands[0]; |
| 584 | op1 = &ext->operands[1]; |
| 585 | op2 = &ext->operands[2]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 586 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 587 | op0->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 588 | op0->reg = M68K_REG_D0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 589 | |
| 590 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 591 | op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 592 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 593 | if (imm > 0) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 594 | ext->op_count = 3; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 595 | op2->type = M68K_OP_IMM; |
| 596 | op2->address_mode = M68K_AM_IMMIDIATE; |
| 597 | op2->imm = imm; |
| 598 | } |
| 599 | } |
| 600 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 601 | static void build_r(m68k_info *info, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 602 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 603 | cs_m68k_op* op0; |
| 604 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 605 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 606 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 607 | op0 = &ext->operands[0]; |
| 608 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 609 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 610 | op0->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 611 | op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 612 | |
| 613 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 614 | op1->reg = M68K_REG_D0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 615 | } |
| 616 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 617 | static void build_imm_ea(m68k_info *info, int opcode, uint8_t size, int imm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 618 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 619 | cs_m68k_op* op0; |
| 620 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 621 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 622 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 623 | op0 = &ext->operands[0]; |
| 624 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 625 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 626 | op0->type = M68K_OP_IMM; |
| 627 | op0->address_mode = M68K_AM_IMMIDIATE; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 628 | op0->imm = imm; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 629 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 630 | get_ea_mode_op(info, op1, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 631 | } |
| 632 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 633 | static void build_3bit_d(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 634 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 635 | cs_m68k_op* op0; |
| 636 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 637 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 638 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 639 | op0 = &ext->operands[0]; |
| 640 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 641 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 642 | op0->type = M68K_OP_IMM; |
| 643 | op0->address_mode = M68K_AM_IMMIDIATE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 644 | op0->imm = g_3bit_qdata_table[(info->ir >> 9) & 7]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 645 | |
| 646 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 647 | op1->reg = M68K_REG_D0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 648 | } |
| 649 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 650 | static void build_3bit_ea(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 651 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 652 | cs_m68k_op* op0; |
| 653 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 654 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 655 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 656 | op0 = &ext->operands[0]; |
| 657 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 658 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 659 | op0->type = M68K_OP_IMM; |
| 660 | op0->address_mode = M68K_AM_IMMIDIATE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 661 | op0->imm = g_3bit_qdata_table[(info->ir >> 9) & 7]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 662 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 663 | get_ea_mode_op(info, op1, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 664 | } |
| 665 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 666 | static void build_mm(m68k_info *info, int opcode, uint8_t size, int imm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 667 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 668 | cs_m68k_op* op0; |
| 669 | cs_m68k_op* op1; |
| 670 | cs_m68k_op* op2; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 671 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 672 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 673 | op0 = &ext->operands[0]; |
| 674 | op1 = &ext->operands[1]; |
| 675 | op2 = &ext->operands[2]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 676 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 677 | op0->address_mode = M68K_AM_REGI_ADDR_PRE_DEC; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 678 | op0->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 679 | |
| 680 | op1->address_mode = M68K_AM_REGI_ADDR_PRE_DEC; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 681 | op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 682 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 683 | if (imm > 0) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 684 | ext->op_count = 3; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 685 | op2->type = M68K_OP_IMM; |
| 686 | op2->address_mode = M68K_AM_IMMIDIATE; |
| 687 | op2->imm = imm; |
| 688 | } |
| 689 | } |
| 690 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 691 | static void build_ea(m68k_info *info, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 692 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 693 | cs_m68k* ext = build_init_op(info, opcode, 1, size); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 694 | get_ea_mode_op(info, &ext->operands[0], info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 695 | } |
| 696 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 697 | static void build_ea_a(m68k_info *info, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 698 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 699 | cs_m68k_op* op0; |
| 700 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 701 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 702 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 703 | op0 = &ext->operands[0]; |
| 704 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 705 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 706 | get_ea_mode_op(info, op0, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 707 | |
| 708 | op1->address_mode = M68K_AM_REG_DIRECT_ADDR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 709 | op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 710 | } |
| 711 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 712 | static void build_ea_ea(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 713 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 714 | cs_m68k_op* op0; |
| 715 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 716 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 717 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 718 | op0 = &ext->operands[0]; |
| 719 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 720 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 721 | get_ea_mode_op(info, op0, info->ir, size); |
| 722 | get_ea_mode_op(info, op1, (((info->ir>>9) & 7) | ((info->ir>>3) & 0x38)), size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 723 | } |
| 724 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 725 | static void build_pi_pi(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 726 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 727 | cs_m68k_op* op0; |
| 728 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 729 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 730 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 731 | op0 = &ext->operands[0]; |
| 732 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 733 | |
| 734 | op0->address_mode = M68K_AM_REGI_ADDR_POST_INC; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 735 | op0->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 736 | |
| 737 | op1->address_mode = M68K_AM_REGI_ADDR_POST_INC; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 738 | op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 739 | } |
| 740 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 741 | static void build_imm_special_reg(m68k_info *info, int opcode, int imm, int size, m68k_reg reg) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 742 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 743 | cs_m68k_op* op0; |
| 744 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 745 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 746 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 747 | op0 = &ext->operands[0]; |
| 748 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 749 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 750 | op0->type = M68K_OP_IMM; |
| 751 | op0->address_mode = M68K_AM_IMMIDIATE; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 752 | op0->imm = imm; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 753 | |
| 754 | op1->address_mode = M68K_AM_NONE; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 755 | op1->reg = reg; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 756 | } |
| 757 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 758 | static void build_bxx(m68k_info *info, int opcode, int size, int jump_offset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 759 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 760 | cs_m68k_op* op; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 761 | cs_m68k* ext = build_init_op(info, opcode, 1, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 762 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 763 | op = &ext->operands[0]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 764 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 765 | op->type = M68K_OP_IMM; |
| 766 | op->address_mode = M68K_AM_IMMIDIATE; |
| 767 | op->imm = jump_offset; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 768 | |
| 769 | set_insn_group(info, M68K_GRP_JUMP); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 770 | } |
| 771 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 772 | static void build_bcc(m68k_info *info, int size, int jump_offset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 773 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 774 | build_bxx(info, s_branch_lut[(info->ir >> 8) & 0xf], size, jump_offset); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 775 | } |
| 776 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 777 | static void build_trap(m68k_info *info, int size, int jump_offset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 778 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 779 | build_bxx(info, s_trap_lut[(info->ir >> 8) & 0xf], size, jump_offset); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 780 | } |
| 781 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 782 | static void build_dbxx(m68k_info *info, int opcode, int size, int jump_offset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 783 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 784 | cs_m68k_op* op0; |
| 785 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 786 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 787 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 788 | op0 = &ext->operands[0]; |
| 789 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 790 | |
| 791 | op0->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 792 | op0->reg = M68K_REG_D0 + (info->ir & 7); |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 793 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 794 | op1->type = M68K_OP_IMM; |
| 795 | op1->address_mode = M68K_AM_IMMIDIATE; |
| 796 | op1->imm = jump_offset; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 797 | |
| 798 | set_insn_group(info, M68K_GRP_JUMP); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 799 | } |
| 800 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 801 | static void build_dbcc(m68k_info *info, int size, int jump_offset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 802 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 803 | build_dbxx(info, s_dbcc_lut[(info->ir >> 8) & 0xf], size, jump_offset); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 804 | } |
| 805 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 806 | static void build_d_d_ea(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 807 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 808 | cs_m68k_op* op0; |
| 809 | cs_m68k_op* op1; |
| 810 | cs_m68k_op* op2; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 811 | uint extension = read_imm_16(info); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 812 | cs_m68k* ext = build_init_op(info, opcode, 3, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 813 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 814 | op0 = &ext->operands[0]; |
| 815 | op1 = &ext->operands[1]; |
| 816 | op2 = &ext->operands[2]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 817 | |
| 818 | op0->address_mode = M68K_AM_REG_DIRECT_DATA; |
| 819 | op0->reg = M68K_REG_D0 + (extension & 7); |
| 820 | |
| 821 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
| 822 | op1->reg = M68K_REG_D0 + ((extension >> 6) & 7); |
| 823 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 824 | get_ea_mode_op(info, op2, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 825 | } |
| 826 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 827 | static void build_bitfield_ins(m68k_info *info, int opcode, int has_d_arg) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 828 | { |
| 829 | uint8_t offset; |
| 830 | uint8_t width; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 831 | cs_m68k_op* op_ea; |
| 832 | cs_m68k_op* op1; |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 833 | cs_m68k* ext = build_init_op(info, opcode, 1, 0); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 834 | uint extension = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 835 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 836 | op_ea = &ext->operands[0]; |
| 837 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 838 | |
| 839 | if (BIT_B(extension)) |
| 840 | offset = (extension >> 6) & 7; |
| 841 | else |
| 842 | offset = (extension >> 6) & 31; |
| 843 | |
| 844 | if (BIT_5(extension)) |
| 845 | width = extension & 7; |
| 846 | else |
| 847 | width = g_5bit_data_table[extension & 31]; |
| 848 | |
| 849 | if (has_d_arg) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 850 | ext->op_count = 2; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 851 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
| 852 | op1->reg = M68K_REG_D0 + ((extension >> 12) & 7); |
| 853 | } |
| 854 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 855 | get_ea_mode_op(info, op_ea, info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 856 | |
| 857 | op_ea->mem.bitfield = 1; |
| 858 | op_ea->mem.width = width; |
| 859 | op_ea->mem.offset = offset; |
| 860 | } |
| 861 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 862 | static void build_d(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 863 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 864 | cs_m68k* ext = build_init_op(info, opcode, 1, size); |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 865 | cs_m68k_op* op; |
| 866 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 867 | op = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 868 | |
| 869 | op->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 870 | op->reg = M68K_REG_D0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | static uint16_t reverse_bits(uint v) |
| 874 | { |
| 875 | uint r = v; // r will be reversed bits of v; first get LSB of v |
| 876 | uint s = 16 - 1; // extra shift needed at end |
| 877 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 878 | for (v >>= 1; v; v >>= 1) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 879 | r <<= 1; |
| 880 | r |= v & 1; |
| 881 | s--; |
| 882 | } |
| 883 | |
| 884 | return r <<= s; // shift when v's highest bits are zero |
| 885 | } |
| 886 | |
| 887 | static uint8_t reverse_bits_8(uint v) |
| 888 | { |
| 889 | uint r = v; // r will be reversed bits of v; first get LSB of v |
| 890 | uint s = 8 - 1; // extra shift needed at end |
| 891 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 892 | for (v >>= 1; v; v >>= 1) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 893 | r <<= 1; |
| 894 | r |= v & 1; |
| 895 | s--; |
| 896 | } |
| 897 | |
| 898 | return r <<= s; // shift when v's highest bits are zero |
| 899 | } |
| 900 | |
| 901 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 902 | static void build_movem_re(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 903 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 904 | cs_m68k_op* op0; |
| 905 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 906 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 907 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 908 | op0 = &ext->operands[0]; |
| 909 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 910 | |
| 911 | op0->type = M68K_OP_REG_BITS; |
jmechnich | 97ae4c3 | 2016-03-25 22:04:04 +0100 | [diff] [blame] | 912 | op0->register_bits = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 913 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 914 | get_ea_mode_op(info, op1, info->ir, size); |
jmechnich | 97ae4c3 | 2016-03-25 22:04:04 +0100 | [diff] [blame] | 915 | |
Nguyen Anh Quynh | 43b69a8 | 2016-03-30 09:39:24 +0800 | [diff] [blame] | 916 | if (op1->address_mode == M68K_AM_REGI_ADDR_PRE_DEC) |
| 917 | op0->register_bits = reverse_bits(op0->register_bits); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 918 | } |
| 919 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 920 | static void build_movem_er(m68k_info *info, int opcode, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 921 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 922 | cs_m68k_op* op0; |
| 923 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 924 | cs_m68k* ext = build_init_op(info, opcode, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 925 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 926 | op0 = &ext->operands[0]; |
| 927 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 928 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 929 | op1->type = M68K_OP_REG_BITS; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 930 | op1->register_bits = read_imm_16(info); |
jmechnich | 97ae4c3 | 2016-03-25 22:04:04 +0100 | [diff] [blame] | 931 | |
| 932 | get_ea_mode_op(info, op0, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 933 | } |
| 934 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 935 | static void build_imm(m68k_info *info, int opcode, int data) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 936 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 937 | cs_m68k_op* op; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 938 | cs_m68k* ext = build_init_op(info, opcode, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 939 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 940 | MCInst_setOpcode(info->inst, opcode); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 941 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 942 | op = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 943 | |
| 944 | op->type = M68K_OP_IMM; |
| 945 | op->address_mode = M68K_AM_IMMIDIATE; |
| 946 | op->imm = data; |
| 947 | } |
| 948 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 949 | static void build_illegal(m68k_info *info, int data) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 950 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 951 | build_imm(info, M68K_INS_ILLEGAL, data); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 952 | } |
| 953 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 954 | static void build_invalid(m68k_info *info, int data) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 955 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 956 | build_imm(info, M68K_INS_INVALID, data); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 957 | } |
| 958 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 959 | static void build_cas2(m68k_info *info, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 960 | { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 961 | uint word3; |
| 962 | uint extension; |
| 963 | cs_m68k_op* op0; |
| 964 | cs_m68k_op* op1; |
| 965 | cs_m68k_op* op2; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 966 | cs_m68k* ext = build_init_op(info, M68K_INS_CAS2, 3, size); |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 967 | int reg_0, reg_1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 968 | |
| 969 | /* cas2 is the only 3 words instruction, word2 and word3 have the same motif bits to check */ |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 970 | word3 = peek_imm_32(info) & 0xffff; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 971 | if (!instruction_is_valid(info, word3)) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 972 | return; |
| 973 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 974 | op0 = &ext->operands[0]; |
| 975 | op1 = &ext->operands[1]; |
| 976 | op2 = &ext->operands[2]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 977 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 978 | extension = read_imm_32(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 979 | |
| 980 | op0->address_mode = M68K_AM_NONE; |
| 981 | op0->type = M68K_OP_REG_PAIR; |
| 982 | op0->register_bits = (((extension >> 16) & 7) << 4) | (extension & 7); |
| 983 | |
| 984 | op1->address_mode = M68K_AM_NONE; |
| 985 | op1->type = M68K_OP_REG_PAIR; |
| 986 | op1->register_bits = (((extension >> 22) & 7) << 4) | ((extension >> 6) & 7); |
| 987 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 988 | reg_0 = (extension >> 28) & 7; |
| 989 | reg_1 = (extension >> 12) & 7; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 990 | |
| 991 | op2->address_mode = M68K_AM_NONE; |
| 992 | op2->type = M68K_OP_REG_PAIR; |
| 993 | op2->register_bits = ((reg_0 + (BIT_1F(extension) ? 8 : 0)) << 4) | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 994 | (reg_1 + (BIT_F(extension) ? 8 : 0)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 995 | } |
| 996 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 997 | static void build_chk2_cmp2(m68k_info *info, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 998 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 999 | cs_m68k_op* op0; |
| 1000 | cs_m68k_op* op1; |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1001 | cs_m68k* ext = build_init_op(info, M68K_INS_CHK2, 2, size); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1002 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1003 | uint extension = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1004 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1005 | if (BIT_B(extension)) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1006 | MCInst_setOpcode(info->inst, M68K_INS_CHK2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1007 | else |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1008 | MCInst_setOpcode(info->inst, M68K_INS_CMP2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1009 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1010 | op0 = &ext->operands[0]; |
| 1011 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1012 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1013 | get_ea_mode_op(info, op0, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1014 | |
| 1015 | op1->address_mode = M68K_AM_NONE; |
| 1016 | op1->type = M68K_OP_REG; |
| 1017 | op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7); |
| 1018 | } |
| 1019 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1020 | static void build_move16(m68k_info *info, int data[2], int modes[2]) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1021 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1022 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVE16, 2, 0); |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1023 | int i; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1024 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1025 | for (i = 0; i < 2; ++i) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1026 | cs_m68k_op* op = &ext->operands[i]; |
| 1027 | const int d = data[i]; |
| 1028 | const int m = modes[i]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1029 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1030 | op->type = M68K_OP_MEM; |
| 1031 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1032 | if (m == M68K_AM_REGI_ADDR_POST_INC || m == M68K_AM_REG_DIRECT_ADDR) { |
| 1033 | op->address_mode = m; |
| 1034 | op->reg = M68K_REG_A0 + d; |
| 1035 | } else { |
| 1036 | op->address_mode = m; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1037 | op->imm = d; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1038 | } |
| 1039 | } |
| 1040 | } |
| 1041 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1042 | static void build_link(m68k_info *info, int disp, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1043 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1044 | cs_m68k_op* op0; |
| 1045 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1046 | cs_m68k* ext = build_init_op(info, M68K_INS_LINK, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1047 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1048 | op0 = &ext->operands[0]; |
| 1049 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1050 | |
| 1051 | op0->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1052 | op0->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1053 | |
| 1054 | op1->address_mode = M68K_AM_IMMIDIATE; |
| 1055 | op1->type = M68K_OP_IMM; |
| 1056 | op1->imm = disp; |
| 1057 | } |
| 1058 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1059 | static void build_cpush_cinv(m68k_info *info, int op_offset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1060 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1061 | cs_m68k_op* op0; |
| 1062 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1063 | cs_m68k* ext = build_init_op(info, M68K_INS_INVALID, 2, 0); |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1064 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1065 | switch ((info->ir >> 3) & 3) { // scope |
Nicolas PLANEL | 858b8cb | 2015-10-03 21:36:18 +1000 | [diff] [blame] | 1066 | // Invalid |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 1067 | case 0: |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1068 | d68000_invalid(info); |
Nicolas PLANEL | 858b8cb | 2015-10-03 21:36:18 +1000 | [diff] [blame] | 1069 | return; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1070 | // Line |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1071 | case 1: |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1072 | MCInst_setOpcode(info->inst, op_offset + 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1073 | break; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1074 | // Page |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1075 | case 2: |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1076 | MCInst_setOpcode(info->inst, op_offset + 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1077 | break; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1078 | // All |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1079 | case 3: |
Nicolas PLANEL | e661bd0 | 2015-10-07 17:58:38 +1100 | [diff] [blame] | 1080 | ext->op_count = 1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1081 | MCInst_setOpcode(info->inst, op_offset + 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1082 | break; |
| 1083 | } |
| 1084 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1085 | op0 = &ext->operands[0]; |
| 1086 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1087 | |
| 1088 | op0->address_mode = M68K_AM_IMMIDIATE; |
| 1089 | op0->type = M68K_OP_IMM; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1090 | op0->imm = (info->ir >> 6) & 3; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1091 | |
| 1092 | op1->type = M68K_OP_MEM; |
| 1093 | op1->address_mode = M68K_AM_REG_DIRECT_ADDR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1094 | op1->imm = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1095 | } |
| 1096 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1097 | static void build_movep_re(m68k_info *info, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1098 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1099 | cs_m68k_op* op0; |
| 1100 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1101 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVEP, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1102 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1103 | op0 = &ext->operands[0]; |
| 1104 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1105 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1106 | op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1107 | |
| 1108 | op1->address_mode = M68K_AM_REGI_ADDR_DISP; |
| 1109 | op1->type = M68K_OP_MEM; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1110 | op1->mem.base_reg = M68K_REG_A0 + (info->ir & 7); |
| 1111 | op1->mem.disp = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1112 | } |
| 1113 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1114 | static void build_movep_er(m68k_info *info, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1115 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1116 | cs_m68k_op* op0; |
| 1117 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1118 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVEP, 2, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1119 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1120 | op0 = &ext->operands[0]; |
| 1121 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1122 | |
| 1123 | op0->address_mode = M68K_AM_REGI_ADDR_DISP; |
| 1124 | op0->type = M68K_OP_MEM; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1125 | op0->mem.base_reg = M68K_REG_A0 + (info->ir & 7); |
| 1126 | op0->mem.disp = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1127 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1128 | op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1129 | } |
| 1130 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1131 | static void build_moves(m68k_info *info, int size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1132 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1133 | cs_m68k_op* op0; |
| 1134 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1135 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVES, 2, size); |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1136 | uint extension = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1137 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1138 | op0 = &ext->operands[0]; |
| 1139 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1140 | |
| 1141 | if (BIT_B(extension)) { |
| 1142 | op0->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1143 | get_ea_mode_op(info, op1, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1144 | } else { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1145 | get_ea_mode_op(info, op0, info->ir, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1146 | op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7); |
| 1147 | } |
| 1148 | } |
| 1149 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1150 | static void build_er_1(m68k_info *info, int opcode, uint8_t size) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1151 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1152 | build_er_gen_1(info, true, opcode, size); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | /* ======================================================================== */ |
| 1156 | /* ========================= INSTRUCTION HANDLERS ========================= */ |
| 1157 | /* ======================================================================== */ |
| 1158 | /* Instruction handler function names follow this convention: |
| 1159 | * |
| 1160 | * d68000_NAME_EXTENSIONS(void) |
| 1161 | * where NAME is the name of the opcode it handles and EXTENSIONS are any |
| 1162 | * extensions for special instances of that opcode. |
| 1163 | * |
| 1164 | * Examples: |
| 1165 | * d68000_add_er_8(): add opcode, from effective address to register, |
| 1166 | * size = byte |
| 1167 | * |
| 1168 | * d68000_asr_s_8(): arithmetic shift right, static count, size = byte |
| 1169 | * |
| 1170 | * |
| 1171 | * Common extensions: |
| 1172 | * 8 : size = byte |
| 1173 | * 16 : size = word |
| 1174 | * 32 : size = long |
| 1175 | * rr : register to register |
| 1176 | * mm : memory to memory |
| 1177 | * r : register |
| 1178 | * s : static |
| 1179 | * er : effective address -> register |
| 1180 | * re : register -> effective address |
| 1181 | * ea : using effective address mode of operation |
| 1182 | * d : data register direct |
| 1183 | * a : address register direct |
| 1184 | * ai : address register indirect |
| 1185 | * pi : address register indirect with postincrement |
| 1186 | * pd : address register indirect with predecrement |
| 1187 | * di : address register indirect with displacement |
| 1188 | * ix : address register indirect with index |
| 1189 | * aw : absolute word |
| 1190 | * al : absolute long |
| 1191 | */ |
| 1192 | |
| 1193 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1194 | static void d68000_invalid(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1195 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1196 | build_invalid(info, info->ir); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1197 | } |
| 1198 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1199 | static void d68000_illegal(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1200 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1201 | build_illegal(info, info->ir); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1202 | } |
| 1203 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1204 | static void d68000_1010(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1205 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1206 | build_invalid(info, info->ir); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1207 | } |
| 1208 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1209 | static void d68000_1111(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1210 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1211 | build_invalid(info, info->ir); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1212 | } |
| 1213 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1214 | static void d68000_abcd_rr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1215 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1216 | build_rr(info, M68K_INS_ABCD, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1217 | } |
| 1218 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1219 | static void d68000_abcd_mm(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1220 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1221 | build_mm(info, M68K_INS_ABCD, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1222 | } |
| 1223 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1224 | static void d68000_add_er_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1225 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1226 | build_er_1(info, M68K_INS_ADD, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1227 | } |
| 1228 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1229 | static void d68000_add_er_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1230 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1231 | build_er_1(info, M68K_INS_ADD, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1232 | } |
| 1233 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1234 | static void d68000_add_er_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1235 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1236 | build_er_1(info, M68K_INS_ADD, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1237 | } |
| 1238 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1239 | static void d68000_add_re_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1240 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1241 | build_re_1(info, M68K_INS_ADD, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1242 | } |
| 1243 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1244 | static void d68000_add_re_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1245 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1246 | build_re_1(info, M68K_INS_ADD, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1247 | } |
| 1248 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1249 | static void d68000_add_re_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1250 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1251 | build_re_1(info, M68K_INS_ADD, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1252 | } |
| 1253 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1254 | static void d68000_adda_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1255 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1256 | build_ea_a(info, M68K_INS_ADDA, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1257 | } |
| 1258 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1259 | static void d68000_adda_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1260 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1261 | build_ea_a(info, M68K_INS_ADDA, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1262 | } |
| 1263 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1264 | static void d68000_addi_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1265 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1266 | build_imm_ea(info, M68K_INS_ADDI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1267 | } |
| 1268 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1269 | static void d68000_addi_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1270 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1271 | build_imm_ea(info, M68K_INS_ADDI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1272 | } |
| 1273 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1274 | static void d68000_addi_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1275 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1276 | build_imm_ea(info, M68K_INS_ADDI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1277 | } |
| 1278 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1279 | static void d68000_addq_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1280 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1281 | build_3bit_ea(info, M68K_INS_ADDQ, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1282 | } |
| 1283 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1284 | static void d68000_addq_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1285 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1286 | build_3bit_ea(info, M68K_INS_ADDQ, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1287 | } |
| 1288 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1289 | static void d68000_addq_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1290 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1291 | build_3bit_ea(info, M68K_INS_ADDQ, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1292 | } |
| 1293 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1294 | static void d68000_addx_rr_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1295 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1296 | build_rr(info, M68K_INS_ADDX, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1297 | } |
| 1298 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1299 | static void d68000_addx_rr_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1300 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1301 | build_rr(info, M68K_INS_ADDX, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1302 | } |
| 1303 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1304 | static void d68000_addx_rr_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1305 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1306 | build_rr(info, M68K_INS_ADDX, 4, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1307 | } |
| 1308 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1309 | static void d68000_addx_mm_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1310 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1311 | build_mm(info, M68K_INS_ADDX, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1312 | } |
| 1313 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1314 | static void d68000_addx_mm_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1315 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1316 | build_mm(info, M68K_INS_ADDX, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1317 | } |
| 1318 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1319 | static void d68000_addx_mm_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1320 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1321 | build_mm(info, M68K_INS_ADDX, 4, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1322 | } |
| 1323 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1324 | static void d68000_and_er_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1325 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1326 | build_er_1(info, M68K_INS_AND, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1327 | } |
| 1328 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1329 | static void d68000_and_er_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1330 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1331 | build_er_1(info, M68K_INS_AND, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1332 | } |
| 1333 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1334 | static void d68000_and_er_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1335 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1336 | build_er_1(info, M68K_INS_AND, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1337 | } |
| 1338 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1339 | static void d68000_and_re_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1340 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1341 | build_re_1(info, M68K_INS_AND, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1342 | } |
| 1343 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1344 | static void d68000_and_re_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1345 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1346 | build_re_1(info, M68K_INS_AND, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1347 | } |
| 1348 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1349 | static void d68000_and_re_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1350 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1351 | build_re_1(info, M68K_INS_AND, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1352 | } |
| 1353 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1354 | static void d68000_andi_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1355 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1356 | build_imm_ea(info, M68K_INS_ANDI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1357 | } |
| 1358 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1359 | static void d68000_andi_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1360 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1361 | build_imm_ea(info, M68K_INS_ANDI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1362 | } |
| 1363 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1364 | static void d68000_andi_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1365 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1366 | build_imm_ea(info, M68K_INS_ANDI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1367 | } |
| 1368 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1369 | static void d68000_andi_to_ccr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1370 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1371 | build_imm_special_reg(info, M68K_INS_ANDI, read_imm_8(info), 1, M68K_REG_CCR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1372 | } |
| 1373 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1374 | static void d68000_andi_to_sr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1375 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1376 | build_imm_special_reg(info, M68K_INS_ANDI, read_imm_16(info), 2, M68K_REG_SR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1377 | } |
| 1378 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1379 | static void d68000_asr_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1380 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1381 | build_3bit_d(info, M68K_INS_ASR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1382 | } |
| 1383 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1384 | static void d68000_asr_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1385 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1386 | build_3bit_d(info, M68K_INS_ASR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1387 | } |
| 1388 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1389 | static void d68000_asr_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1390 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1391 | build_3bit_d(info, M68K_INS_ASR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1392 | } |
| 1393 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1394 | static void d68000_asr_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1395 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1396 | build_r(info, M68K_INS_ASR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1397 | } |
| 1398 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1399 | static void d68000_asr_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1400 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1401 | build_r(info, M68K_INS_ASR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1402 | } |
| 1403 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1404 | static void d68000_asr_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1405 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1406 | build_r(info, M68K_INS_ASR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1407 | } |
| 1408 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1409 | static void d68000_asr_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1410 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1411 | build_ea(info, M68K_INS_ASR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1412 | } |
| 1413 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1414 | static void d68000_asl_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1415 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1416 | build_3bit_d(info, M68K_INS_ASL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1417 | } |
| 1418 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1419 | static void d68000_asl_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1420 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1421 | build_3bit_d(info, M68K_INS_ASL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1422 | } |
| 1423 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1424 | static void d68000_asl_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1425 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1426 | build_3bit_d(info, M68K_INS_ASL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1427 | } |
| 1428 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1429 | static void d68000_asl_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1430 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1431 | build_r(info, M68K_INS_ASL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1432 | } |
| 1433 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1434 | static void d68000_asl_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1435 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1436 | build_r(info, M68K_INS_ASL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1437 | } |
| 1438 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1439 | static void d68000_asl_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1440 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1441 | build_r(info, M68K_INS_ASL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1442 | } |
| 1443 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1444 | static void d68000_asl_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1445 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1446 | build_ea(info, M68K_INS_ASL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1447 | } |
| 1448 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1449 | static void d68000_bcc_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1450 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1451 | uint temp_pc = info->pc; |
| 1452 | build_bcc(info, 1, temp_pc + make_int_8(info->ir)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1453 | } |
| 1454 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1455 | static void d68000_bcc_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1456 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1457 | uint temp_pc = info->pc; |
| 1458 | build_bcc(info, 2, temp_pc + make_int_16(read_imm_16(info))); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1459 | } |
| 1460 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1461 | static void d68020_bcc_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1462 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1463 | uint temp_pc = info->pc; |
| 1464 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1465 | build_bcc(info, 4, temp_pc + read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1466 | } |
| 1467 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1468 | static void d68000_bchg_r(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1469 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1470 | build_re_1(info, M68K_INS_BCHG, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1471 | } |
| 1472 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1473 | static void d68000_bchg_s(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1474 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1475 | build_imm_ea(info, M68K_INS_BCHG, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1476 | } |
| 1477 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1478 | static void d68000_bclr_r(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1479 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1480 | build_re_1(info, M68K_INS_BCLR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1481 | } |
| 1482 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1483 | static void d68000_bclr_s(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1484 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1485 | build_imm_ea(info, M68K_INS_BCLR, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1486 | } |
| 1487 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1488 | static void d68010_bkpt(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1489 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1490 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1491 | build_bxx(info, M68K_INS_BKPT, 0, info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1492 | } |
| 1493 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1494 | static void d68020_bfchg(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1495 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1496 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1497 | build_bitfield_ins(info, M68K_INS_BFCHG, false); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1498 | } |
| 1499 | |
| 1500 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1501 | static void d68020_bfclr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1502 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1503 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1504 | build_bitfield_ins(info, M68K_INS_BFCLR, false); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1505 | } |
| 1506 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1507 | static void d68020_bfexts(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1508 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1509 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1510 | build_bitfield_ins(info, M68K_INS_BFEXTS, true); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1511 | } |
| 1512 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1513 | static void d68020_bfextu(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1514 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1515 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1516 | build_bitfield_ins(info, M68K_INS_BFEXTU, true); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1517 | } |
| 1518 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1519 | static void d68020_bfffo(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1520 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1521 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1522 | build_bitfield_ins(info, M68K_INS_BFFFO, true); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1523 | } |
| 1524 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1525 | static void d68020_bfins(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1526 | { |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1527 | cs_m68k* ext = &info->extension; |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1528 | cs_m68k_op temp; |
| 1529 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1530 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1531 | build_bitfield_ins(info, M68K_INS_BFINS, true); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1532 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1533 | // a bit hacky but we need to flip the args on only this instruction |
| 1534 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1535 | temp = ext->operands[0]; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1536 | ext->operands[0] = ext->operands[1]; |
| 1537 | ext->operands[1] = temp; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1538 | } |
| 1539 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1540 | static void d68020_bfset(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1541 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1542 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1543 | build_bitfield_ins(info, M68K_INS_BFSET, false); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1544 | } |
| 1545 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1546 | static void d68020_bftst(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1547 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1548 | build_bitfield_ins(info, M68K_INS_BFTST, false); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1549 | } |
| 1550 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1551 | static void d68000_bra_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1552 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1553 | uint temp_pc = info->pc; |
| 1554 | build_bxx(info, M68K_INS_BRA, 1, temp_pc + make_int_8(info->ir)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1555 | } |
| 1556 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1557 | static void d68000_bra_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1558 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1559 | uint temp_pc = info->pc; |
| 1560 | build_bxx(info, M68K_INS_BRA, 2, temp_pc + make_int_16(read_imm_16(info))); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1561 | } |
| 1562 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1563 | static void d68020_bra_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1564 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1565 | uint temp_pc = info->pc; |
| 1566 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1567 | build_bxx(info, M68K_INS_BRA, 4, temp_pc + read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1568 | } |
| 1569 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1570 | static void d68000_bset_r(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1571 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1572 | build_re_1(info, M68K_INS_BSET, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1573 | } |
| 1574 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1575 | static void d68000_bset_s(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1576 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1577 | build_imm_ea(info, M68K_INS_BSET, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1578 | } |
| 1579 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1580 | static void d68000_bsr_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1581 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1582 | uint temp_pc = info->pc; |
| 1583 | build_bxx(info, M68K_INS_BSR, 1, temp_pc + make_int_8(info->ir)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1584 | } |
| 1585 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1586 | static void d68000_bsr_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1587 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1588 | uint temp_pc = info->pc; |
| 1589 | build_bxx(info, M68K_INS_BSR, 2, temp_pc + make_int_16(read_imm_16(info))); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1590 | } |
| 1591 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1592 | static void d68020_bsr_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1593 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1594 | uint temp_pc = info->pc; |
| 1595 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1596 | build_bxx(info, M68K_INS_BSR, 4, temp_pc + peek_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1597 | } |
| 1598 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1599 | static void d68000_btst_r(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1600 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1601 | build_re_1(info, M68K_INS_BTST, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1602 | } |
| 1603 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1604 | static void d68000_btst_s(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1605 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1606 | build_imm_ea(info, M68K_INS_BTST, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1607 | } |
| 1608 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1609 | static void d68020_callm(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1610 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1611 | LIMIT_CPU_TYPES(info, M68020_ONLY); |
| 1612 | build_imm_ea(info, M68K_INS_CALLM, 0, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1613 | } |
| 1614 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1615 | static void d68020_cas_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1616 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1617 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1618 | build_d_d_ea(info, M68K_INS_CAS, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1619 | } |
| 1620 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1621 | static void d68020_cas_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1622 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1623 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1624 | build_d_d_ea(info, M68K_INS_CAS, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1625 | } |
| 1626 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1627 | static void d68020_cas_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1628 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1629 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1630 | build_d_d_ea(info, M68K_INS_CAS, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1631 | } |
| 1632 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1633 | static void d68020_cas2_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1634 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1635 | build_cas2(info, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1636 | } |
| 1637 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1638 | static void d68020_cas2_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1639 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1640 | build_cas2(info, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1641 | } |
| 1642 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1643 | static void d68000_chk_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1644 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1645 | build_er_1(info, M68K_INS_CHK, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1646 | } |
| 1647 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1648 | static void d68020_chk_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1649 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1650 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1651 | build_er_1(info, M68K_INS_CHK, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1652 | } |
| 1653 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1654 | static void d68020_chk2_cmp2_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1655 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1656 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1657 | build_chk2_cmp2(info, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1658 | } |
| 1659 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1660 | static void d68020_chk2_cmp2_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1661 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1662 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1663 | build_chk2_cmp2(info, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1664 | } |
| 1665 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1666 | static void d68020_chk2_cmp2_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1667 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1668 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 1669 | build_chk2_cmp2(info, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1670 | } |
| 1671 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1672 | static void d68040_cinv(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1673 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1674 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 1675 | build_cpush_cinv(info, M68K_INS_CINVL); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1676 | } |
| 1677 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1678 | static void d68000_clr_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1679 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1680 | build_ea(info, M68K_INS_CLR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1681 | } |
| 1682 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1683 | static void d68000_clr_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1684 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1685 | build_ea(info, M68K_INS_CLR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1686 | } |
| 1687 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1688 | static void d68000_clr_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1689 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1690 | build_ea(info, M68K_INS_CLR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1691 | } |
| 1692 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1693 | static void d68000_cmp_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1694 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1695 | build_er_1(info, M68K_INS_CMP, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1696 | } |
| 1697 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1698 | static void d68000_cmp_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1699 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1700 | build_er_1(info, M68K_INS_CMP, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1701 | } |
| 1702 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1703 | static void d68000_cmp_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1704 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1705 | build_er_1(info, M68K_INS_CMP, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1706 | } |
| 1707 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1708 | static void d68000_cmpa_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1709 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1710 | build_ea_a(info, M68K_INS_CMPA, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1711 | } |
| 1712 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1713 | static void d68000_cmpa_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1714 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1715 | build_ea_a(info, M68K_INS_CMPA, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1716 | } |
| 1717 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1718 | static void d68000_cmpi_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1719 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1720 | build_imm_ea(info, M68K_INS_CMPI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1721 | } |
| 1722 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1723 | static void d68020_cmpi_pcdi_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1724 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1725 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1726 | build_imm_ea(info, M68K_INS_CMPI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1727 | } |
| 1728 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1729 | static void d68020_cmpi_pcix_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1730 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1731 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1732 | build_imm_ea(info, M68K_INS_CMPI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1733 | } |
| 1734 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1735 | static void d68000_cmpi_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1736 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1737 | build_imm_ea(info, M68K_INS_CMPI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1738 | } |
| 1739 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1740 | static void d68020_cmpi_pcdi_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1741 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1742 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1743 | build_imm_ea(info, M68K_INS_CMPI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1744 | } |
| 1745 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1746 | static void d68020_cmpi_pcix_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1747 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1748 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1749 | build_imm_ea(info, M68K_INS_CMPI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1750 | } |
| 1751 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1752 | static void d68000_cmpi_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1753 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1754 | build_imm_ea(info, M68K_INS_CMPI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1755 | } |
| 1756 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1757 | static void d68020_cmpi_pcdi_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1758 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1759 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1760 | build_imm_ea(info, M68K_INS_CMPI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1761 | } |
| 1762 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1763 | static void d68020_cmpi_pcix_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1764 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1765 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 1766 | build_imm_ea(info, M68K_INS_CMPI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1767 | } |
| 1768 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1769 | static void d68000_cmpm_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1770 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1771 | build_pi_pi(info, M68K_INS_CMPM, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1772 | } |
| 1773 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1774 | static void d68000_cmpm_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1775 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1776 | build_pi_pi(info, M68K_INS_CMPM, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1777 | } |
| 1778 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1779 | static void d68000_cmpm_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1780 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1781 | build_pi_pi(info, M68K_INS_CMPM, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1782 | } |
| 1783 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1784 | static void d68020_cpbcc_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1785 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1786 | cs_m68k_op* op0; |
| 1787 | cs_m68k* ext; |
| 1788 | uint new_pc; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1789 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1790 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1791 | new_pc = info->pc; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1792 | new_pc += make_int_16(read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1793 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1794 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1795 | info->inst->Opcode += (info->ir & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1796 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1797 | ext = build_init_op(info, M68K_INS_FBF, 1, 2); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1798 | op0 = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1799 | |
| 1800 | op0->address_mode = M68K_AM_IMMIDIATE; |
| 1801 | op0->type = M68K_OP_IMM; |
| 1802 | op0->imm = new_pc; |
| 1803 | } |
| 1804 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1805 | static void d68020_cpbcc_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1806 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1807 | cs_m68k* ext; |
| 1808 | cs_m68k_op* op0; |
| 1809 | uint new_pc; |
| 1810 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1811 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1812 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1813 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1814 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1815 | new_pc = info->pc; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1816 | new_pc += read_imm_32(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1817 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1818 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1819 | info->inst->Opcode += (info->ir & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1820 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1821 | ext = build_init_op(info, M68K_INS_FBF, 1, 4); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1822 | op0 = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1823 | |
| 1824 | op0->type = M68K_OP_IMM; |
| 1825 | op0->address_mode = M68K_AM_IMMIDIATE; |
| 1826 | op0->imm = new_pc; |
| 1827 | } |
| 1828 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1829 | static void d68020_cpdbcc(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1830 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1831 | cs_m68k* ext; |
| 1832 | cs_m68k_op* op0; |
| 1833 | cs_m68k_op* op1; |
| 1834 | uint new_pc, ext1, ext2; |
| 1835 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1836 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1837 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1838 | new_pc = info->pc; |
| 1839 | ext1 = read_imm_16(info); |
| 1840 | ext2 = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1841 | new_pc += make_int_16(ext2) + 2; |
| 1842 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1843 | |
| 1844 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1845 | info->inst->Opcode += (ext1 & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1846 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 1847 | ext = build_init_op(info, M68K_INS_FDBF, 2, 0); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1848 | op0 = &ext->operands[0]; |
| 1849 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1850 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1851 | op0->reg = M68K_REG_D0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1852 | |
| 1853 | op1->address_mode = M68K_AM_IMMIDIATE; |
| 1854 | op1->type = M68K_OP_IMM; |
| 1855 | op1->imm = new_pc; |
| 1856 | } |
| 1857 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1858 | static void fmove_fpcr(m68k_info *info, uint extension) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1859 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1860 | cs_m68k_op* special; |
| 1861 | cs_m68k_op* op_ea; |
| 1862 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1863 | int regsel = (extension >> 10) & 0x7; |
| 1864 | int dir = (extension >> 13) & 0x1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1865 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1866 | cs_m68k* ext = build_init_op(info, M68K_INS_FMOVE, 2, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1867 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1868 | special = &ext->operands[0]; |
| 1869 | op_ea = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1870 | |
| 1871 | if (!dir) { |
| 1872 | cs_m68k_op* t = special; |
| 1873 | special = op_ea; |
| 1874 | op_ea = t; |
| 1875 | } |
| 1876 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1877 | get_ea_mode_op(info, op_ea, info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1878 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 1879 | if (regsel & 4) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1880 | special->reg = M68K_REG_FPCR; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 1881 | else if (regsel & 2) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1882 | special->reg = M68K_REG_FPSR; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 1883 | else if (regsel & 1) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1884 | special->reg = M68K_REG_FPIAR; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1885 | } |
| 1886 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1887 | static void fmovem(m68k_info *info, uint extension) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1888 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1889 | cs_m68k_op* op_reglist; |
| 1890 | cs_m68k_op* op_ea; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1891 | int dir = (extension >> 13) & 0x1; |
| 1892 | int mode = (extension >> 11) & 0x3; |
| 1893 | uint reglist = extension & 0xff; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1894 | cs_m68k* ext = build_init_op(info, M68K_INS_FMOVEM, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1895 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1896 | op_reglist = &ext->operands[0]; |
| 1897 | op_ea = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1898 | |
| 1899 | // flip args around |
| 1900 | |
| 1901 | if (!dir) { |
| 1902 | cs_m68k_op* t = op_reglist; |
| 1903 | op_reglist = op_ea; |
| 1904 | op_ea = t; |
| 1905 | } |
| 1906 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1907 | get_ea_mode_op(info, op_ea, info->ir, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1908 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1909 | switch (mode) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1910 | case 1 : // Dynamic list in dn register |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1911 | op_reglist->reg = M68K_REG_D0 + ((reglist >> 4) & 7); |
| 1912 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1913 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 1914 | case 0 : |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1915 | op_reglist->address_mode = M68K_AM_NONE; |
| 1916 | op_reglist->type = M68K_OP_REG_BITS; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1917 | op_reglist->register_bits = reglist << 16; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1918 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1919 | |
| 1920 | case 2 : // Static list |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1921 | op_reglist->address_mode = M68K_AM_NONE; |
| 1922 | op_reglist->type = M68K_OP_REG_BITS; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1923 | op_reglist->register_bits = ((uint32_t)reverse_bits_8(reglist)) << 16; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1924 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1925 | } |
| 1926 | } |
| 1927 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1928 | static void d68020_cpgen(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1929 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1930 | cs_m68k *ext; |
| 1931 | cs_m68k_op* op0; |
| 1932 | cs_m68k_op* op1; |
| 1933 | bool supports_single_op; |
| 1934 | uint next; |
| 1935 | int rm, src, dst, opmode; |
| 1936 | |
| 1937 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1938 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1939 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1940 | supports_single_op = true; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1941 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1942 | next = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1943 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1944 | rm = (next >> 14) & 0x1; |
| 1945 | src = (next >> 10) & 0x7; |
| 1946 | dst = (next >> 7) & 0x7; |
| 1947 | opmode = next & 0x3f; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1948 | |
| 1949 | // special handling for fmovecr |
| 1950 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1951 | if (BITFIELD(info->ir, 5, 0) == 0 && BITFIELD(next, 15, 10) == 0x17) { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1952 | cs_m68k_op* op0; |
| 1953 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1954 | cs_m68k* ext = build_init_op(info, M68K_INS_FMOVECR, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1955 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1956 | op0 = &ext->operands[0]; |
| 1957 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1958 | |
| 1959 | op0->address_mode = M68K_AM_IMMIDIATE; |
| 1960 | op0->type = M68K_OP_IMM; |
| 1961 | op0->imm = next & 0x3f; |
| 1962 | |
| 1963 | op1->reg = M68K_REG_FP0 + ((next >> 7) & 7); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1964 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1965 | return; |
| 1966 | } |
| 1967 | |
| 1968 | // deal with extended move stuff |
| 1969 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1970 | switch ((next >> 13) & 0x7) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1971 | // fmovem fpcr |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1972 | case 0x4: // FMOVEM ea, FPCR |
| 1973 | case 0x5: // FMOVEM FPCR, ea |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1974 | fmove_fpcr(info, next); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1975 | return; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1976 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1977 | // fmovem list |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1978 | case 0x6: |
| 1979 | case 0x7: |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1980 | fmovem(info, next); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1981 | return; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1982 | } |
| 1983 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 1984 | // See comment bellow on why this is being done |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1985 | |
| 1986 | if ((next >> 6) & 1) |
| 1987 | opmode &= ~4; |
| 1988 | |
| 1989 | // special handling of some instructions here |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 1990 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 1991 | switch (opmode) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 1992 | case 0x00: MCInst_setOpcode(info->inst, M68K_INS_FMOVE); supports_single_op = false; break; |
| 1993 | case 0x01: MCInst_setOpcode(info->inst, M68K_INS_FINT); break; |
| 1994 | case 0x02: MCInst_setOpcode(info->inst, M68K_INS_FSINH); break; |
| 1995 | case 0x03: MCInst_setOpcode(info->inst, M68K_INS_FINTRZ); break; |
| 1996 | case 0x04: MCInst_setOpcode(info->inst, M68K_INS_FSQRT); break; |
| 1997 | case 0x06: MCInst_setOpcode(info->inst, M68K_INS_FLOGNP1); break; |
| 1998 | case 0x08: MCInst_setOpcode(info->inst, M68K_INS_FETOXM1); break; |
| 1999 | case 0x09: MCInst_setOpcode(info->inst, M68K_INS_FATANH); break; |
| 2000 | case 0x0a: MCInst_setOpcode(info->inst, M68K_INS_FATAN); break; |
| 2001 | case 0x0c: MCInst_setOpcode(info->inst, M68K_INS_FASIN); break; |
| 2002 | case 0x0d: MCInst_setOpcode(info->inst, M68K_INS_FATANH); break; |
| 2003 | case 0x0e: MCInst_setOpcode(info->inst, M68K_INS_FSIN); break; |
| 2004 | case 0x0f: MCInst_setOpcode(info->inst, M68K_INS_FTAN); break; |
| 2005 | case 0x10: MCInst_setOpcode(info->inst, M68K_INS_FETOX); break; |
| 2006 | case 0x11: MCInst_setOpcode(info->inst, M68K_INS_FTWOTOX); break; |
| 2007 | case 0x12: MCInst_setOpcode(info->inst, M68K_INS_FTENTOX); break; |
| 2008 | case 0x14: MCInst_setOpcode(info->inst, M68K_INS_FLOGN); break; |
| 2009 | case 0x15: MCInst_setOpcode(info->inst, M68K_INS_FLOG10); break; |
| 2010 | case 0x16: MCInst_setOpcode(info->inst, M68K_INS_FLOG2); break; |
| 2011 | case 0x18: MCInst_setOpcode(info->inst, M68K_INS_FABS); break; |
| 2012 | case 0x19: MCInst_setOpcode(info->inst, M68K_INS_FCOSH); break; |
| 2013 | case 0x1a: MCInst_setOpcode(info->inst, M68K_INS_FNEG); break; |
| 2014 | case 0x1c: MCInst_setOpcode(info->inst, M68K_INS_FACOS); break; |
| 2015 | case 0x1d: MCInst_setOpcode(info->inst, M68K_INS_FCOS); break; |
| 2016 | case 0x1e: MCInst_setOpcode(info->inst, M68K_INS_FGETEXP); break; |
| 2017 | case 0x1f: MCInst_setOpcode(info->inst, M68K_INS_FGETMAN); break; |
| 2018 | case 0x20: MCInst_setOpcode(info->inst, M68K_INS_FDIV); supports_single_op = false; break; |
| 2019 | case 0x21: MCInst_setOpcode(info->inst, M68K_INS_FMOD); supports_single_op = false; break; |
| 2020 | case 0x22: MCInst_setOpcode(info->inst, M68K_INS_FADD); supports_single_op = false; break; |
| 2021 | case 0x23: MCInst_setOpcode(info->inst, M68K_INS_FMUL); supports_single_op = false; break; |
| 2022 | case 0x24: MCInst_setOpcode(info->inst, M68K_INS_FSGLDIV); supports_single_op = false; break; |
| 2023 | case 0x25: MCInst_setOpcode(info->inst, M68K_INS_FREM); break; |
| 2024 | case 0x26: MCInst_setOpcode(info->inst, M68K_INS_FSCALE); break; |
| 2025 | case 0x27: MCInst_setOpcode(info->inst, M68K_INS_FSGLMUL); break; |
| 2026 | case 0x28: MCInst_setOpcode(info->inst, M68K_INS_FSUB); supports_single_op = false; break; |
| 2027 | case 0x38: MCInst_setOpcode(info->inst, M68K_INS_FCMP); supports_single_op = false; break; |
| 2028 | case 0x3a: MCInst_setOpcode(info->inst, M68K_INS_FTST); break; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 2029 | default: |
Daniel Collin | 1bca054 | 2016-04-10 16:16:28 +0200 | [diff] [blame^] | 2030 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2031 | } |
| 2032 | |
| 2033 | // Some trickery here! It's not documented but if bit 6 is set this is a s/d opcode and then |
| 2034 | // if bit 2 is set it's a d. As we already have set our opcode in the code above we can just |
| 2035 | // offset it as the following 2 op codes (if s/d is supported) will always be directly after it |
| 2036 | |
| 2037 | if ((next >> 6) & 1) { |
| 2038 | if ((next >> 2) & 1) |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2039 | info->inst->Opcode += 2; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2040 | else |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2041 | info->inst->Opcode += 1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2042 | } |
| 2043 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 2044 | ext = &info->extension; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2045 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2046 | ext->op_count = 2; |
| 2047 | ext->op_size.type = M68K_SIZE_TYPE_CPU; |
| 2048 | ext->op_size.cpu_size = 0; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2049 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2050 | op0 = &ext->operands[0]; |
| 2051 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2052 | |
| 2053 | if (rm == 0 && supports_single_op && src == dst) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2054 | ext->op_count = 1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2055 | op0->reg = M68K_REG_FP0 + dst; |
| 2056 | return; |
| 2057 | } |
| 2058 | |
| 2059 | if (rm == 1) { |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 2060 | switch (src) { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 2061 | case 0x00 : |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2062 | ext->op_size.cpu_size = M68K_CPU_SIZE_LONG; |
| 2063 | get_ea_mode_op(info, op0, info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2064 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2065 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 2066 | case 0x06 : |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2067 | ext->op_size.cpu_size = M68K_CPU_SIZE_BYTE; |
| 2068 | get_ea_mode_op(info, op0, info->ir, 1); |
| 2069 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2070 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 2071 | case 0x04 : |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2072 | ext->op_size.cpu_size = M68K_CPU_SIZE_WORD; |
| 2073 | get_ea_mode_op(info, op0, info->ir, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2074 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2075 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 2076 | case 0x01 : |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2077 | ext->op_size.type = M68K_SIZE_TYPE_FPU; |
| 2078 | ext->op_size.fpu_size = M68K_FPU_SIZE_SINGLE; |
| 2079 | get_ea_mode_op(info, op0, info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2080 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2081 | |
| 2082 | case 0x05: |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2083 | ext->op_size.type = M68K_SIZE_TYPE_FPU; |
| 2084 | ext->op_size.fpu_size = M68K_FPU_SIZE_DOUBLE; |
| 2085 | get_ea_mode_op(info, op0, info->ir, 8); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2086 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2087 | |
| 2088 | default : |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2089 | ext->op_size.type = M68K_SIZE_TYPE_FPU; |
| 2090 | ext->op_size.fpu_size = M68K_FPU_SIZE_EXTENDED; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2091 | break; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2092 | } |
| 2093 | } else { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2094 | op0->reg = M68K_REG_FP0 + src; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2095 | } |
| 2096 | |
| 2097 | op1->reg = M68K_REG_FP0 + dst; |
| 2098 | } |
| 2099 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2100 | static void d68020_cprestore(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2101 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2102 | cs_m68k* ext; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2103 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2104 | |
| 2105 | ext = build_init_op(info, M68K_INS_FRESTORE, 1, 0); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2106 | get_ea_mode_op(info, &ext->operands[0], info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2107 | } |
| 2108 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2109 | static void d68020_cpsave(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2110 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2111 | cs_m68k* ext; |
| 2112 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2113 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2114 | |
| 2115 | ext = build_init_op(info, M68K_INS_FSAVE, 1, 0); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2116 | get_ea_mode_op(info, &ext->operands[0], info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2117 | } |
| 2118 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2119 | static void d68020_cpscc(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2120 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2121 | cs_m68k* ext; |
| 2122 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2123 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2124 | ext = build_init_op(info, M68K_INS_FSF, 1, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2125 | |
| 2126 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2127 | info->inst->Opcode += (read_imm_16(info) & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2128 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2129 | get_ea_mode_op(info, &ext->operands[0], info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2130 | } |
| 2131 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2132 | static void d68020_cptrapcc_0(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2133 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2134 | uint extension1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2135 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2136 | |
| 2137 | extension1 = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2138 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2139 | build_init_op(info, M68K_INS_FTRAPF, 0, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2140 | |
| 2141 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2142 | info->inst->Opcode += (extension1 & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2143 | } |
| 2144 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2145 | static void d68020_cptrapcc_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2146 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2147 | uint extension1, extension2; |
| 2148 | cs_m68k_op* op0; |
| 2149 | cs_m68k* ext; |
| 2150 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2151 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2152 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2153 | extension1 = read_imm_16(info); |
| 2154 | extension2 = read_imm_16(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2155 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2156 | ext = build_init_op(info, M68K_INS_FTRAPF, 1, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2157 | |
| 2158 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2159 | info->inst->Opcode += (extension1 & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2160 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2161 | op0 = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2162 | |
| 2163 | op0->address_mode = M68K_AM_IMMIDIATE; |
| 2164 | op0->type = M68K_OP_IMM; |
| 2165 | op0->imm = extension2; |
| 2166 | } |
| 2167 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2168 | static void d68020_cptrapcc_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2169 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2170 | uint extension1, extension2; |
| 2171 | cs_m68k* ext; |
| 2172 | cs_m68k_op* op0; |
| 2173 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2174 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2175 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2176 | extension1 = read_imm_16(info); |
| 2177 | extension2 = read_imm_32(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2178 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2179 | ext = build_init_op(info, M68K_INS_FTRAPF, 1, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2180 | |
| 2181 | // these are all in row with the extension so just doing a add here is fine |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2182 | info->inst->Opcode += (extension1 & 0x2f); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2183 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2184 | op0 = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2185 | |
| 2186 | op0->address_mode = M68K_AM_IMMIDIATE; |
| 2187 | op0->type = M68K_OP_IMM; |
| 2188 | op0->imm = extension2; |
| 2189 | } |
| 2190 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2191 | static void d68040_cpush(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2192 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2193 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 2194 | build_cpush_cinv(info, M68K_INS_CPUSHL); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2195 | } |
| 2196 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2197 | static void d68000_dbra(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2198 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2199 | uint temp_pc = info->pc; |
| 2200 | build_dbxx(info, M68K_INS_DBRA, 0, temp_pc + make_int_16(read_imm_16(info))); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2201 | } |
| 2202 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2203 | static void d68000_dbcc(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2204 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2205 | uint temp_pc = info->pc; |
| 2206 | build_dbcc(info, 0, temp_pc + make_int_16(read_imm_16(info))); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2207 | } |
| 2208 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2209 | static void d68000_divs(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2210 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2211 | build_er_1(info, M68K_INS_DIVS, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2212 | } |
| 2213 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2214 | static void d68000_divu(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2215 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2216 | build_er_1(info, M68K_INS_DIVU, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2217 | } |
| 2218 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2219 | static void d68020_divl(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2220 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2221 | uint extension, insn_signed; |
| 2222 | cs_m68k* ext; |
| 2223 | cs_m68k_op* op0; |
| 2224 | cs_m68k_op* op1; |
| 2225 | uint reg_0, reg_1; |
| 2226 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2227 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2228 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2229 | extension = read_imm_16(info); |
| 2230 | insn_signed = 0; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 2231 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2232 | if (BIT_B((extension))) |
| 2233 | insn_signed = 1; |
| 2234 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2235 | ext = build_init_op(info, insn_signed ? M68K_INS_DIVS : M68K_INS_DIVU, 2, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2236 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2237 | op0 = &ext->operands[0]; |
| 2238 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2239 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2240 | get_ea_mode_op(info, op0, info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2241 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2242 | reg_0 = extension & 7; |
| 2243 | reg_1 = (extension >> 12) & 7; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2244 | |
| 2245 | op1->address_mode = M68K_AM_NONE; |
| 2246 | op1->type = M68K_OP_REG_PAIR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2247 | op1->register_bits = (reg_0 << 4) | reg_1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2248 | |
| 2249 | if ((reg_0 == reg_1) || !BIT_A(extension)) { |
| 2250 | op1->type = M68K_OP_REG; |
| 2251 | op1->reg = M68K_REG_D0 + reg_1; |
| 2252 | } |
| 2253 | } |
| 2254 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2255 | static void d68000_eor_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2256 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2257 | build_re_1(info, M68K_INS_EOR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2258 | } |
| 2259 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2260 | static void d68000_eor_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2261 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2262 | build_re_1(info, M68K_INS_EOR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2263 | } |
| 2264 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2265 | static void d68000_eor_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2266 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2267 | build_re_1(info, M68K_INS_EOR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2268 | } |
| 2269 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2270 | static void d68000_eori_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2271 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2272 | build_imm_ea(info, M68K_INS_EORI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2273 | } |
| 2274 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2275 | static void d68000_eori_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2276 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2277 | build_imm_ea(info, M68K_INS_EORI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2278 | } |
| 2279 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2280 | static void d68000_eori_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2281 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2282 | build_imm_ea(info, M68K_INS_EORI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2283 | } |
| 2284 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2285 | static void d68000_eori_to_ccr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2286 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2287 | build_imm_special_reg(info, M68K_INS_EORI, read_imm_8(info), 1, M68K_REG_CCR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2288 | } |
| 2289 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2290 | static void d68000_eori_to_sr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2291 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2292 | build_imm_special_reg(info, M68K_INS_EORI, read_imm_16(info), 2, M68K_REG_SR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2293 | } |
| 2294 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2295 | static void d68000_exg_dd(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2296 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2297 | build_r(info, M68K_INS_EXG, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2298 | } |
| 2299 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2300 | static void d68000_exg_aa(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2301 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2302 | cs_m68k_op* op0; |
| 2303 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2304 | cs_m68k* ext = build_init_op(info, M68K_INS_EXG, 2, 4); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2305 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2306 | op0 = &ext->operands[0]; |
| 2307 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2308 | |
| 2309 | op0->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2310 | op0->reg = M68K_REG_A0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2311 | |
| 2312 | op1->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2313 | op1->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2314 | } |
| 2315 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2316 | static void d68000_exg_da(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2317 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2318 | cs_m68k_op* op0; |
| 2319 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2320 | cs_m68k* ext = build_init_op(info, M68K_INS_EXG, 2, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2321 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2322 | op0 = &ext->operands[0]; |
| 2323 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2324 | |
| 2325 | op0->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2326 | op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2327 | |
| 2328 | op1->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2329 | op1->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2330 | } |
| 2331 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2332 | static void d68000_ext_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2333 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2334 | build_d(info, M68K_INS_EXT, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2335 | } |
| 2336 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2337 | static void d68000_ext_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2338 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2339 | build_d(info, M68K_INS_EXT, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2340 | } |
| 2341 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2342 | static void d68020_extb_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2343 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2344 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 2345 | build_d(info, M68K_INS_EXTB, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2346 | } |
| 2347 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2348 | static void d68000_jmp(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2349 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2350 | cs_m68k* ext = build_init_op(info, M68K_INS_JMP, 1, 0); |
Daniel Collin | 1bca054 | 2016-04-10 16:16:28 +0200 | [diff] [blame^] | 2351 | set_insn_group(info, M68K_GRP_JUMP); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2352 | get_ea_mode_op(info, &ext->operands[0], info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2353 | } |
| 2354 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2355 | static void d68000_jsr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2356 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2357 | cs_m68k* ext = build_init_op(info, M68K_INS_JSR, 1, 0); |
Daniel Collin | 1bca054 | 2016-04-10 16:16:28 +0200 | [diff] [blame^] | 2358 | set_insn_group(info, M68K_GRP_JUMP); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2359 | get_ea_mode_op(info, &ext->operands[0], info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2360 | } |
| 2361 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2362 | static void d68000_lea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2363 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2364 | build_ea_a(info, M68K_INS_LEA, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2365 | } |
| 2366 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2367 | static void d68000_link_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2368 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2369 | build_link(info, read_imm_16(info), 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2370 | } |
| 2371 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2372 | static void d68020_link_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2373 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2374 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 2375 | build_link(info, read_imm_32(info), 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2376 | } |
| 2377 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2378 | static void d68000_lsr_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2379 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2380 | build_3bit_d(info, M68K_INS_LSR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2381 | } |
| 2382 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2383 | static void d68000_lsr_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2384 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2385 | build_3bit_d(info, M68K_INS_LSR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2386 | } |
| 2387 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2388 | static void d68000_lsr_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2389 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2390 | build_3bit_d(info, M68K_INS_LSR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2391 | } |
| 2392 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2393 | static void d68000_lsr_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2394 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2395 | build_r(info, M68K_INS_LSR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2396 | } |
| 2397 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2398 | static void d68000_lsr_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2399 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2400 | build_r(info, M68K_INS_LSR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2401 | } |
| 2402 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2403 | static void d68000_lsr_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2404 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2405 | build_r(info, M68K_INS_LSR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2406 | } |
| 2407 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2408 | static void d68000_lsr_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2409 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2410 | build_ea(info, M68K_INS_LSR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2411 | } |
| 2412 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2413 | static void d68000_lsl_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2414 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2415 | build_3bit_d(info, M68K_INS_LSL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2416 | } |
| 2417 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2418 | static void d68000_lsl_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2419 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2420 | build_3bit_d(info, M68K_INS_LSL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2421 | } |
| 2422 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2423 | static void d68000_lsl_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2424 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2425 | build_3bit_d(info, M68K_INS_LSL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2426 | } |
| 2427 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2428 | static void d68000_lsl_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2429 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2430 | build_r(info, M68K_INS_LSL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2431 | } |
| 2432 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2433 | static void d68000_lsl_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2434 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2435 | build_r(info, M68K_INS_LSL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2436 | } |
| 2437 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2438 | static void d68000_lsl_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2439 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2440 | build_r(info, M68K_INS_LSL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2441 | } |
| 2442 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2443 | static void d68000_lsl_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2444 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2445 | build_ea(info, M68K_INS_LSL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2446 | } |
| 2447 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2448 | static void d68000_move_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2449 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2450 | build_ea_ea(info, M68K_INS_MOVE, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2451 | } |
| 2452 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2453 | static void d68000_move_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2454 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2455 | build_ea_ea(info, M68K_INS_MOVE, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2456 | } |
| 2457 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2458 | static void d68000_move_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2459 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2460 | build_ea_ea(info, M68K_INS_MOVE, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2461 | } |
| 2462 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2463 | static void d68000_movea_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2464 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2465 | build_ea_a(info, M68K_INS_MOVEA, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2466 | } |
| 2467 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2468 | static void d68000_movea_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2469 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2470 | build_ea_a(info, M68K_INS_MOVEA, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2471 | } |
| 2472 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2473 | static void d68000_move_to_ccr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2474 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2475 | cs_m68k_op* op0; |
| 2476 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2477 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2478 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2479 | op0 = &ext->operands[0]; |
| 2480 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2481 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2482 | get_ea_mode_op(info, op0, info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2483 | |
| 2484 | op1->address_mode = M68K_AM_NONE; |
| 2485 | op1->reg = M68K_REG_CCR; |
| 2486 | } |
| 2487 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2488 | static void d68010_move_fr_ccr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2489 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2490 | cs_m68k_op* op0; |
| 2491 | cs_m68k_op* op1; |
| 2492 | cs_m68k* ext; |
| 2493 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2494 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2495 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2496 | ext = build_init_op(info, M68K_INS_MOVE, 2, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2497 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2498 | op0 = &ext->operands[0]; |
| 2499 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2500 | |
| 2501 | op0->address_mode = M68K_AM_NONE; |
| 2502 | op0->reg = M68K_REG_CCR; |
| 2503 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2504 | get_ea_mode_op(info, op1, info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2505 | } |
| 2506 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2507 | static void d68000_move_fr_sr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2508 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2509 | cs_m68k_op* op0; |
| 2510 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2511 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2512 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2513 | op0 = &ext->operands[0]; |
| 2514 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2515 | |
| 2516 | op0->address_mode = M68K_AM_NONE; |
| 2517 | op0->reg = M68K_REG_SR; |
| 2518 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2519 | get_ea_mode_op(info, op1, info->ir, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2520 | } |
| 2521 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2522 | static void d68000_move_to_sr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2523 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2524 | cs_m68k_op* op0; |
| 2525 | cs_m68k_op* op1; |
| 2526 | cs_m68k* ext; |
| 2527 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2528 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2529 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2530 | ext = build_init_op(info, M68K_INS_MOVE, 2, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2531 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2532 | op0 = &ext->operands[0]; |
| 2533 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2534 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2535 | get_ea_mode_op(info, op0, info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2536 | |
| 2537 | op1->address_mode = M68K_AM_NONE; |
| 2538 | op1->reg = M68K_REG_SR; |
| 2539 | } |
| 2540 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2541 | static void d68000_move_fr_usp(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2542 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2543 | cs_m68k_op* op0; |
| 2544 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2545 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2546 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2547 | op0 = &ext->operands[0]; |
| 2548 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2549 | |
| 2550 | op0->address_mode = M68K_AM_NONE; |
| 2551 | op0->reg = M68K_REG_USP; |
| 2552 | |
| 2553 | op1->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2554 | op1->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2555 | } |
| 2556 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2557 | static void d68000_move_to_usp(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2558 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2559 | cs_m68k_op* op0; |
| 2560 | cs_m68k_op* op1; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2561 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2562 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2563 | op0 = &ext->operands[0]; |
| 2564 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2565 | |
| 2566 | op0->address_mode = M68K_AM_NONE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2567 | op0->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2568 | |
| 2569 | op1->address_mode = M68K_AM_NONE; |
| 2570 | op1->reg = M68K_REG_USP; |
| 2571 | } |
| 2572 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2573 | static void d68010_movec(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2574 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2575 | uint extension; |
| 2576 | m68k_reg reg; |
| 2577 | cs_m68k* ext; |
| 2578 | cs_m68k_op* op0; |
| 2579 | cs_m68k_op* op1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2580 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2581 | |
| 2582 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 2583 | |
| 2584 | extension = read_imm_16(info); |
| 2585 | reg = M68K_REG_INVALID; |
| 2586 | |
| 2587 | ext = build_init_op(info, M68K_INS_MOVEC, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2588 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2589 | op0 = &ext->operands[0]; |
| 2590 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2591 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 2592 | switch (extension & 0xfff) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2593 | case 0x000: reg = M68K_REG_SFC; break; |
| 2594 | case 0x001: reg = M68K_REG_DFC; break; |
| 2595 | case 0x800: reg = M68K_REG_USP; break; |
| 2596 | case 0x801: reg = M68K_REG_VBR; break; |
| 2597 | case 0x002: reg = M68K_REG_CACR; break; |
| 2598 | case 0x802: reg = M68K_REG_CAAR; break; |
| 2599 | case 0x803: reg = M68K_REG_MSP; break; |
| 2600 | case 0x804: reg = M68K_REG_ISP; break; |
| 2601 | case 0x003: reg = M68K_REG_TC; break; |
| 2602 | case 0x004: reg = M68K_REG_ITT0; break; |
| 2603 | case 0x005: reg = M68K_REG_ITT1; break; |
| 2604 | case 0x006: reg = M68K_REG_DTT0; break; |
| 2605 | case 0x007: reg = M68K_REG_DTT1; break; |
| 2606 | case 0x805: reg = M68K_REG_MMUSR; break; |
| 2607 | case 0x806: reg = M68K_REG_URP; break; |
| 2608 | case 0x807: reg = M68K_REG_SRP; break; |
| 2609 | } |
| 2610 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2611 | if (BIT_1(info->ir)) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2612 | op0->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2613 | op1->reg = reg; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2614 | } else { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2615 | op0->reg = reg; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2616 | op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7); |
| 2617 | } |
| 2618 | } |
| 2619 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2620 | static void d68000_movem_pd_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2621 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2622 | build_movem_re(info, M68K_INS_MOVEM, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2623 | } |
| 2624 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2625 | static void d68000_movem_pd_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2626 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2627 | build_movem_re(info, M68K_INS_MOVEM, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2628 | } |
| 2629 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2630 | static void d68000_movem_er_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2631 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2632 | build_movem_er(info, M68K_INS_MOVEM, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2633 | } |
| 2634 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2635 | static void d68000_movem_er_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2636 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2637 | build_movem_er(info, M68K_INS_MOVEM, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2638 | } |
| 2639 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2640 | static void d68000_movem_re_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2641 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2642 | build_movem_re(info, M68K_INS_MOVEM, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2643 | } |
| 2644 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2645 | static void d68000_movem_re_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2646 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2647 | build_movem_re(info, M68K_INS_MOVEM, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2648 | } |
| 2649 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2650 | static void d68000_movep_re_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2651 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2652 | build_movep_re(info, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2653 | } |
| 2654 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2655 | static void d68000_movep_re_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2656 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2657 | build_movep_re(info, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2658 | } |
| 2659 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2660 | static void d68000_movep_er_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2661 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2662 | build_movep_er(info, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2663 | } |
| 2664 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2665 | static void d68000_movep_er_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2666 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2667 | build_movep_er(info, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2668 | } |
| 2669 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2670 | static void d68010_moves_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2671 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2672 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 2673 | build_moves(info, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2674 | } |
| 2675 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2676 | static void d68010_moves_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2677 | { |
| 2678 | //uint extension; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2679 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 2680 | build_moves(info, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2681 | } |
| 2682 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2683 | static void d68010_moves_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2684 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2685 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 2686 | build_moves(info, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2687 | } |
| 2688 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2689 | static void d68000_moveq(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2690 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2691 | cs_m68k_op* op0; |
| 2692 | cs_m68k_op* op1; |
| 2693 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2694 | cs_m68k* ext = build_init_op(info, M68K_INS_MOVEQ, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2695 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2696 | op0 = &ext->operands[0]; |
| 2697 | op1 = &ext->operands[1]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 2698 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2699 | op0->type = M68K_OP_IMM; |
| 2700 | op0->address_mode = M68K_AM_IMMIDIATE; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2701 | op0->imm = (info->ir & 0xff); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2702 | |
| 2703 | op1->address_mode = M68K_AM_REG_DIRECT_DATA; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2704 | op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2705 | } |
| 2706 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2707 | static void d68040_move16_pi_pi(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2708 | { |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 2709 | int data[] = { info->ir & 7, (read_imm_16(info) >> 12) & 7 }; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2710 | int modes[] = { M68K_AM_REGI_ADDR_POST_INC, M68K_AM_REGI_ADDR_POST_INC }; |
| 2711 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 2712 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 2713 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2714 | build_move16(info, data, modes); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2715 | } |
| 2716 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2717 | static void d68040_move16_pi_al(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2718 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2719 | int data[] = { info->ir & 7, read_imm_32(info) }; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2720 | int modes[] = { M68K_AM_REGI_ADDR_POST_INC, M68K_AM_ABSOLUTE_DATA_LONG }; |
| 2721 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 2722 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 2723 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2724 | build_move16(info, data, modes); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2725 | } |
| 2726 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2727 | static void d68040_move16_al_pi(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2728 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2729 | int data[] = { read_imm_32(info), info->ir & 7 }; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2730 | int modes[] = { M68K_AM_ABSOLUTE_DATA_LONG, M68K_AM_REGI_ADDR_POST_INC }; |
| 2731 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 2732 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 2733 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2734 | build_move16(info, data, modes); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2735 | } |
| 2736 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2737 | static void d68040_move16_ai_al(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2738 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2739 | int data[] = { info->ir & 7, read_imm_32(info) }; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2740 | int modes[] = { M68K_AM_REG_DIRECT_ADDR, M68K_AM_ABSOLUTE_DATA_LONG }; |
| 2741 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 2742 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 2743 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2744 | build_move16(info, data, modes); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2745 | } |
| 2746 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2747 | static void d68040_move16_al_ai(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2748 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2749 | int data[] = { read_imm_32(info), info->ir & 7 }; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2750 | int modes[] = { M68K_AM_ABSOLUTE_DATA_LONG, M68K_AM_REG_DIRECT_ADDR }; |
| 2751 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 2752 | LIMIT_CPU_TYPES(info, M68040_PLUS); |
| 2753 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2754 | build_move16(info, data, modes); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2755 | } |
| 2756 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2757 | static void d68000_muls(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2758 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2759 | build_er_1(info, M68K_INS_MULS, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2760 | } |
| 2761 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2762 | static void d68000_mulu(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2763 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2764 | build_er_1(info, M68K_INS_MULU, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2765 | } |
| 2766 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2767 | static void d68020_mull(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2768 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2769 | uint extension, insn_signed; |
| 2770 | cs_m68k* ext; |
| 2771 | cs_m68k_op* op0; |
| 2772 | cs_m68k_op* op1; |
| 2773 | uint reg_0, reg_1; |
| 2774 | |
| 2775 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2776 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2777 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2778 | extension = read_imm_16(info); |
| 2779 | insn_signed = 0; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 2780 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2781 | if (BIT_B((extension))) |
| 2782 | insn_signed = 1; |
| 2783 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2784 | ext = build_init_op(info, insn_signed ? M68K_INS_MULS : M68K_INS_MULU, 2, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2785 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2786 | op0 = &ext->operands[0]; |
| 2787 | op1 = &ext->operands[1]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2788 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2789 | get_ea_mode_op(info, op0, info->ir, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2790 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 2791 | reg_0 = extension & 7; |
| 2792 | reg_1 = (extension >> 12) & 7; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2793 | |
| 2794 | op1->address_mode = M68K_AM_NONE; |
| 2795 | op1->type = M68K_OP_REG_PAIR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2796 | op1->register_bits = (reg_0 << 4) | reg_1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2797 | |
| 2798 | if (!BIT_A(extension)) { |
| 2799 | op1->type = M68K_OP_REG; |
| 2800 | op1->reg = M68K_REG_D0 + reg_1; |
| 2801 | } |
| 2802 | } |
| 2803 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2804 | static void d68000_nbcd(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2805 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2806 | build_ea(info, M68K_INS_NBCD, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2807 | } |
| 2808 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2809 | static void d68000_neg_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2810 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2811 | build_ea(info, M68K_INS_NEG, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2812 | } |
| 2813 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2814 | static void d68000_neg_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2815 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2816 | build_ea(info, M68K_INS_NEG, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2817 | } |
| 2818 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2819 | static void d68000_neg_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2820 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2821 | build_ea(info, M68K_INS_NEG, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2822 | } |
| 2823 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2824 | static void d68000_negx_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2825 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2826 | build_ea(info, M68K_INS_NEGX, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2827 | } |
| 2828 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2829 | static void d68000_negx_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2830 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2831 | build_ea(info, M68K_INS_NEGX, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2832 | } |
| 2833 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2834 | static void d68000_negx_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2835 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2836 | build_ea(info, M68K_INS_NEGX, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2837 | } |
| 2838 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2839 | static void d68000_nop(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2840 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2841 | MCInst_setOpcode(info->inst, M68K_INS_NOP); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2842 | } |
| 2843 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2844 | static void d68000_not_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2845 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2846 | build_ea(info, M68K_INS_NOT, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2847 | } |
| 2848 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2849 | static void d68000_not_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2850 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2851 | build_ea(info, M68K_INS_NOT, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2852 | } |
| 2853 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2854 | static void d68000_not_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2855 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2856 | build_ea(info, M68K_INS_NOT, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2857 | } |
| 2858 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2859 | static void d68000_or_er_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2860 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2861 | build_er_1(info, M68K_INS_OR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2862 | } |
| 2863 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2864 | static void d68000_or_er_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2865 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2866 | build_er_1(info, M68K_INS_OR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2867 | } |
| 2868 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2869 | static void d68000_or_er_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2870 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2871 | build_er_1(info, M68K_INS_OR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2872 | } |
| 2873 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2874 | static void d68000_or_re_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2875 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2876 | build_re_1(info, M68K_INS_OR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2877 | } |
| 2878 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2879 | static void d68000_or_re_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2880 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2881 | build_re_1(info, M68K_INS_OR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2882 | } |
| 2883 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2884 | static void d68000_or_re_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2885 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2886 | build_re_1(info, M68K_INS_OR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2887 | } |
| 2888 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2889 | static void d68000_ori_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2890 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2891 | build_imm_ea(info, M68K_INS_ORI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2892 | } |
| 2893 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2894 | static void d68000_ori_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2895 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2896 | build_imm_ea(info, M68K_INS_ORI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2897 | } |
| 2898 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2899 | static void d68000_ori_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2900 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2901 | build_imm_ea(info, M68K_INS_ORI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2902 | } |
| 2903 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2904 | static void d68000_ori_to_ccr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2905 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2906 | build_imm_special_reg(info, M68K_INS_ORI, read_imm_8(info), 1, M68K_REG_CCR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2907 | } |
| 2908 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2909 | static void d68000_ori_to_sr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2910 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2911 | build_imm_special_reg(info, M68K_INS_ORI, read_imm_16(info), 2, M68K_REG_SR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2912 | } |
| 2913 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2914 | static void d68020_pack_rr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2915 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2916 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 2917 | build_rr(info, M68K_INS_PACK, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2918 | } |
| 2919 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2920 | static void d68020_pack_mm(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2921 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2922 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 2923 | build_mm(info, M68K_INS_PACK, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2924 | } |
| 2925 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2926 | static void d68000_pea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2927 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2928 | build_ea(info, M68K_INS_PEA, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2929 | } |
| 2930 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2931 | static void d68000_reset(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2932 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2933 | MCInst_setOpcode(info->inst, M68K_INS_RESET); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2934 | } |
| 2935 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2936 | static void d68000_ror_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2937 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2938 | build_3bit_d(info, M68K_INS_ROR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2939 | } |
| 2940 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2941 | static void d68000_ror_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2942 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2943 | build_3bit_d(info, M68K_INS_ROR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2944 | } |
| 2945 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2946 | static void d68000_ror_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2947 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2948 | build_3bit_d(info, M68K_INS_ROR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2949 | } |
| 2950 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2951 | static void d68000_ror_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2952 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2953 | build_r(info, M68K_INS_ROR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2954 | } |
| 2955 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2956 | static void d68000_ror_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2957 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2958 | build_r(info, M68K_INS_ROR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2959 | } |
| 2960 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2961 | static void d68000_ror_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2962 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2963 | build_r(info, M68K_INS_ROR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2964 | } |
| 2965 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2966 | static void d68000_ror_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2967 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2968 | build_ea(info, M68K_INS_ROR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2969 | } |
| 2970 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2971 | static void d68000_rol_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2972 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2973 | build_3bit_d(info, M68K_INS_ROL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2974 | } |
| 2975 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2976 | static void d68000_rol_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2977 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2978 | build_3bit_d(info, M68K_INS_ROL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2979 | } |
| 2980 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2981 | static void d68000_rol_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2982 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2983 | build_3bit_d(info, M68K_INS_ROL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2984 | } |
| 2985 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2986 | static void d68000_rol_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2987 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2988 | build_r(info, M68K_INS_ROL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2989 | } |
| 2990 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2991 | static void d68000_rol_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2992 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2993 | build_r(info, M68K_INS_ROL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2994 | } |
| 2995 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2996 | static void d68000_rol_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2997 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 2998 | build_r(info, M68K_INS_ROL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 2999 | } |
| 3000 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3001 | static void d68000_rol_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3002 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3003 | build_ea(info, M68K_INS_ROL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3004 | } |
| 3005 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3006 | static void d68000_roxr_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3007 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3008 | build_3bit_d(info, M68K_INS_ROXR, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3009 | } |
| 3010 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3011 | static void d68000_roxr_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3012 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3013 | build_3bit_d(info, M68K_INS_ROXR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3014 | } |
| 3015 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3016 | static void d68000_roxr_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3017 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3018 | build_3bit_d(info, M68K_INS_ROXR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3019 | } |
| 3020 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3021 | static void d68000_roxr_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3022 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3023 | build_3bit_d(info, M68K_INS_ROXR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3024 | } |
| 3025 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3026 | static void d68000_roxr_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3027 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3028 | build_r(info, M68K_INS_ROXR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3029 | } |
| 3030 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3031 | static void d68000_roxr_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3032 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3033 | build_r(info, M68K_INS_ROXR, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3034 | } |
| 3035 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3036 | static void d68000_roxr_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3037 | { |
jmechnich | ab10864 | 2016-04-03 13:50:28 +0200 | [diff] [blame] | 3038 | build_ea(info, M68K_INS_ROXR, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3039 | } |
| 3040 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3041 | static void d68000_roxl_s_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3042 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3043 | build_3bit_d(info, M68K_INS_ROXL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3044 | } |
| 3045 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3046 | static void d68000_roxl_s_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3047 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3048 | build_3bit_d(info, M68K_INS_ROXL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3049 | } |
| 3050 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3051 | static void d68000_roxl_s_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3052 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3053 | build_3bit_d(info, M68K_INS_ROXL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3054 | } |
| 3055 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3056 | static void d68000_roxl_r_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3057 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3058 | build_r(info, M68K_INS_ROXL, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3059 | } |
| 3060 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3061 | static void d68000_roxl_r_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3062 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3063 | build_r(info, M68K_INS_ROXL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3064 | } |
| 3065 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3066 | static void d68000_roxl_r_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3067 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3068 | build_r(info, M68K_INS_ROXL, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3069 | } |
| 3070 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3071 | static void d68000_roxl_ea(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3072 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3073 | build_ea(info, M68K_INS_ROXL, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3074 | } |
| 3075 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3076 | static void d68010_rtd(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3077 | { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3078 | set_insn_group(info, M68K_GRP_RET); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3079 | LIMIT_CPU_TYPES(info, M68010_PLUS); |
| 3080 | build_bxx(info, M68K_INS_RTD, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3081 | } |
| 3082 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3083 | static void d68000_rte(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3084 | { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3085 | set_insn_group(info, M68K_GRP_IRET); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3086 | MCInst_setOpcode(info->inst, M68K_INS_RTE); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3087 | } |
| 3088 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3089 | static void d68020_rtm(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3090 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3091 | cs_m68k* ext; |
| 3092 | cs_m68k_op* op; |
| 3093 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3094 | set_insn_group(info, M68K_GRP_RET); |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3095 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3096 | LIMIT_CPU_TYPES(info, M68020_ONLY); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3097 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3098 | build_bxx(info, M68K_INS_RTM, 0, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3099 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 3100 | ext = &info->extension; |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3101 | op = &ext->operands[0]; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3102 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3103 | op->address_mode = M68K_AM_NONE; |
| 3104 | op->type = M68K_OP_REG; |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3105 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3106 | if (BIT_3(info->ir)) { |
| 3107 | op->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3108 | } else { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3109 | op->reg = M68K_REG_D0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3110 | } |
| 3111 | } |
| 3112 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3113 | static void d68000_rtr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3114 | { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3115 | set_insn_group(info, M68K_GRP_RET); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3116 | MCInst_setOpcode(info->inst, M68K_INS_RTR); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3117 | } |
| 3118 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3119 | static void d68000_rts(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3120 | { |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3121 | set_insn_group(info, M68K_GRP_RET); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3122 | MCInst_setOpcode(info->inst, M68K_INS_RTS); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3123 | } |
| 3124 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3125 | static void d68000_sbcd_rr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3126 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3127 | build_rr(info, M68K_INS_SBCD, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3128 | } |
| 3129 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3130 | static void d68000_sbcd_mm(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3131 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3132 | build_mm(info, M68K_INS_SBCD, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3133 | } |
| 3134 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3135 | static void d68000_scc(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3136 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3137 | cs_m68k* ext = build_init_op(info, s_scc_lut[(info->ir >> 8) & 0xf], 1, 1); |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3138 | get_ea_mode_op(info, &ext->operands[0], info->ir, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3139 | } |
| 3140 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3141 | static void d68000_stop(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3142 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3143 | build_bxx(info, M68K_INS_STOP, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3144 | } |
| 3145 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3146 | static void d68000_sub_er_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3147 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3148 | build_er_1(info, M68K_INS_SUB, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3149 | } |
| 3150 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3151 | static void d68000_sub_er_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3152 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3153 | build_er_1(info, M68K_INS_SUB, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3154 | } |
| 3155 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3156 | static void d68000_sub_er_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3157 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3158 | build_er_1(info, M68K_INS_SUB, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3159 | } |
| 3160 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3161 | static void d68000_sub_re_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3162 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3163 | build_re_1(info, M68K_INS_SUB, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3164 | } |
| 3165 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3166 | static void d68000_sub_re_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3167 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3168 | build_re_1(info, M68K_INS_SUB, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3169 | } |
| 3170 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3171 | static void d68000_sub_re_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3172 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3173 | build_re_1(info, M68K_INS_SUB, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3174 | } |
| 3175 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3176 | static void d68000_suba_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3177 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3178 | build_ea_a(info, M68K_INS_SUBA, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3179 | } |
| 3180 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3181 | static void d68000_suba_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3182 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3183 | build_ea_a(info, M68K_INS_SUBA, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3184 | } |
| 3185 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3186 | static void d68000_subi_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3187 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3188 | build_imm_ea(info, M68K_INS_SUBI, 1, read_imm_8(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3189 | } |
| 3190 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3191 | static void d68000_subi_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3192 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3193 | build_imm_ea(info, M68K_INS_SUBI, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3194 | } |
| 3195 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3196 | static void d68000_subi_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3197 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3198 | build_imm_ea(info, M68K_INS_SUBI, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3199 | } |
| 3200 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3201 | static void d68000_subq_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3202 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3203 | build_3bit_ea(info, M68K_INS_SUBQ, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3204 | } |
| 3205 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3206 | static void d68000_subq_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3207 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3208 | build_3bit_ea(info, M68K_INS_SUBQ, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3209 | } |
| 3210 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3211 | static void d68000_subq_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3212 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3213 | build_3bit_ea(info, M68K_INS_SUBQ, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3214 | } |
| 3215 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3216 | static void d68000_subx_rr_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3217 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3218 | build_rr(info, M68K_INS_SUBX, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3219 | } |
| 3220 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3221 | static void d68000_subx_rr_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3222 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3223 | build_rr(info, M68K_INS_SUBX, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3224 | } |
| 3225 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3226 | static void d68000_subx_rr_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3227 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3228 | build_rr(info, M68K_INS_SUBX, 4, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3229 | } |
| 3230 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3231 | static void d68000_subx_mm_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3232 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3233 | build_mm(info, M68K_INS_SUBX, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3234 | } |
| 3235 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3236 | static void d68000_subx_mm_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3237 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3238 | build_mm(info, M68K_INS_SUBX, 2, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3239 | } |
| 3240 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3241 | static void d68000_subx_mm_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3242 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3243 | build_mm(info, M68K_INS_SUBX, 4, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3244 | } |
| 3245 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3246 | static void d68000_swap(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3247 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3248 | build_d(info, M68K_INS_SWAP, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3249 | } |
| 3250 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3251 | static void d68000_tas(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3252 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3253 | build_ea(info, M68K_INS_TAS, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3254 | } |
| 3255 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3256 | static void d68000_trap(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3257 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3258 | build_bxx(info, M68K_INS_TRAP, 0, info->ir&0xf); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3259 | } |
| 3260 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3261 | static void d68020_trapcc_0(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3262 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3263 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3264 | build_trap(info, 0, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3265 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 3266 | info->extension.op_count = 0; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3267 | } |
| 3268 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3269 | static void d68020_trapcc_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3270 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3271 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3272 | build_trap(info, 2, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3273 | } |
| 3274 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3275 | static void d68020_trapcc_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3276 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3277 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3278 | build_trap(info, 4, read_imm_32(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3279 | } |
| 3280 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3281 | static void d68000_trapv(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3282 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3283 | MCInst_setOpcode(info->inst, M68K_INS_TRAPV); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3284 | } |
| 3285 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3286 | static void d68000_tst_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3287 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3288 | build_ea(info, M68K_INS_TST, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3289 | } |
| 3290 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3291 | static void d68020_tst_pcdi_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3292 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3293 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3294 | build_ea(info, M68K_INS_TST, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3295 | } |
| 3296 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3297 | static void d68020_tst_pcix_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3298 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3299 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3300 | build_ea(info, M68K_INS_TST, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3301 | } |
| 3302 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3303 | static void d68020_tst_i_8(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3304 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3305 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3306 | build_ea(info, M68K_INS_TST, 1); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3307 | } |
| 3308 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3309 | static void d68000_tst_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3310 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3311 | build_ea(info, M68K_INS_TST, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3312 | } |
| 3313 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3314 | static void d68020_tst_a_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3315 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3316 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3317 | build_ea(info, M68K_INS_TST, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3318 | } |
| 3319 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3320 | static void d68020_tst_pcdi_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3321 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3322 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3323 | build_ea(info, M68K_INS_TST, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3324 | } |
| 3325 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3326 | static void d68020_tst_pcix_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3327 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3328 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3329 | build_ea(info, M68K_INS_TST, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3330 | } |
| 3331 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3332 | static void d68020_tst_i_16(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3333 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3334 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3335 | build_ea(info, M68K_INS_TST, 2); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3336 | } |
| 3337 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3338 | static void d68000_tst_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3339 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3340 | build_ea(info, M68K_INS_TST, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3341 | } |
| 3342 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3343 | static void d68020_tst_a_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3344 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3345 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3346 | build_ea(info, M68K_INS_TST, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3347 | } |
| 3348 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3349 | static void d68020_tst_pcdi_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3350 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3351 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3352 | build_ea(info, M68K_INS_TST, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3353 | } |
| 3354 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3355 | static void d68020_tst_pcix_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3356 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3357 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3358 | build_ea(info, M68K_INS_TST, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3359 | } |
| 3360 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3361 | static void d68020_tst_i_32(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3362 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3363 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3364 | build_ea(info, M68K_INS_TST, 4); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3365 | } |
| 3366 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3367 | static void d68000_unlk(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3368 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3369 | cs_m68k_op* op; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3370 | cs_m68k* ext = build_init_op(info, M68K_INS_UNLK, 1, 0); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3371 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3372 | op = &ext->operands[0]; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3373 | |
| 3374 | op->address_mode = M68K_AM_REG_DIRECT_ADDR; |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3375 | op->reg = M68K_REG_A0 + (info->ir & 7); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3376 | } |
| 3377 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3378 | static void d68020_unpk_rr(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3379 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3380 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3381 | build_rr(info, M68K_INS_UNPK, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3382 | } |
| 3383 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3384 | static void d68020_unpk_mm(m68k_info *info) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3385 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3386 | LIMIT_CPU_TYPES(info, M68020_PLUS); |
| 3387 | build_mm(info, M68K_INS_UNPK, 0, read_imm_16(info)); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3388 | } |
| 3389 | |
| 3390 | /* ======================================================================== */ |
| 3391 | /* ======================= INSTRUCTION TABLE BUILDER ====================== */ |
| 3392 | /* ======================================================================== */ |
| 3393 | |
| 3394 | /* EA Masks: |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3395 | 800 = data register direct |
| 3396 | 400 = address register direct |
| 3397 | 200 = address register indirect |
| 3398 | 100 = ARI postincrement |
| 3399 | 80 = ARI pre-decrement |
| 3400 | 40 = ARI displacement |
| 3401 | 20 = ARI index |
| 3402 | 10 = absolute short |
| 3403 | 8 = absolute long |
| 3404 | 4 = immediate / sr |
| 3405 | 2 = pc displacement |
| 3406 | 1 = pc idx |
| 3407 | */ |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3408 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3409 | static opcode_struct g_opcode_info[] = { |
| 3410 | /* opcode handler mask match ea_mask mask2 match2*/ |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3411 | {d68000_1010 , 0xf000, 0xa000, 0x000}, |
| 3412 | {d68000_1111 , 0xf000, 0xf000, 0x000}, |
| 3413 | {d68000_abcd_rr , 0xf1f8, 0xc100, 0x000}, |
| 3414 | {d68000_abcd_mm , 0xf1f8, 0xc108, 0x000}, |
| 3415 | {d68000_add_er_8 , 0xf1c0, 0xd000, 0xbff}, |
| 3416 | {d68000_add_er_16 , 0xf1c0, 0xd040, 0xfff}, |
| 3417 | {d68000_add_er_32 , 0xf1c0, 0xd080, 0xfff}, |
| 3418 | {d68000_add_re_8 , 0xf1c0, 0xd100, 0x3f8}, |
| 3419 | {d68000_add_re_16 , 0xf1c0, 0xd140, 0x3f8}, |
| 3420 | {d68000_add_re_32 , 0xf1c0, 0xd180, 0x3f8}, |
| 3421 | {d68000_adda_16 , 0xf1c0, 0xd0c0, 0xfff}, |
| 3422 | {d68000_adda_32 , 0xf1c0, 0xd1c0, 0xfff}, |
| 3423 | {d68000_addi_8 , 0xffc0, 0x0600, 0xbf8}, |
| 3424 | {d68000_addi_16 , 0xffc0, 0x0640, 0xbf8}, |
| 3425 | {d68000_addi_32 , 0xffc0, 0x0680, 0xbf8}, |
| 3426 | {d68000_addq_8 , 0xf1c0, 0x5000, 0xbf8}, |
| 3427 | {d68000_addq_16 , 0xf1c0, 0x5040, 0xff8}, |
| 3428 | {d68000_addq_32 , 0xf1c0, 0x5080, 0xff8}, |
| 3429 | {d68000_addx_rr_8 , 0xf1f8, 0xd100, 0x000}, |
| 3430 | {d68000_addx_rr_16 , 0xf1f8, 0xd140, 0x000}, |
| 3431 | {d68000_addx_rr_32 , 0xf1f8, 0xd180, 0x000}, |
| 3432 | {d68000_addx_mm_8 , 0xf1f8, 0xd108, 0x000}, |
| 3433 | {d68000_addx_mm_16 , 0xf1f8, 0xd148, 0x000}, |
| 3434 | {d68000_addx_mm_32 , 0xf1f8, 0xd188, 0x000}, |
| 3435 | {d68000_and_er_8 , 0xf1c0, 0xc000, 0xbff}, |
| 3436 | {d68000_and_er_16 , 0xf1c0, 0xc040, 0xbff}, |
| 3437 | {d68000_and_er_32 , 0xf1c0, 0xc080, 0xbff}, |
| 3438 | {d68000_and_re_8 , 0xf1c0, 0xc100, 0x3f8}, |
| 3439 | {d68000_and_re_16 , 0xf1c0, 0xc140, 0x3f8}, |
| 3440 | {d68000_and_re_32 , 0xf1c0, 0xc180, 0x3f8}, |
| 3441 | {d68000_andi_to_ccr , 0xffff, 0x023c, 0x000, 0xff00, 0x0000}, |
| 3442 | {d68000_andi_to_sr , 0xffff, 0x027c, 0x000}, |
| 3443 | {d68000_andi_8 , 0xffc0, 0x0200, 0xbf8}, |
| 3444 | {d68000_andi_16 , 0xffc0, 0x0240, 0xbf8}, |
| 3445 | {d68000_andi_32 , 0xffc0, 0x0280, 0xbf8}, |
| 3446 | {d68000_asr_s_8 , 0xf1f8, 0xe000, 0x000}, |
| 3447 | {d68000_asr_s_16 , 0xf1f8, 0xe040, 0x000}, |
| 3448 | {d68000_asr_s_32 , 0xf1f8, 0xe080, 0x000}, |
| 3449 | {d68000_asr_r_8 , 0xf1f8, 0xe020, 0x000}, |
| 3450 | {d68000_asr_r_16 , 0xf1f8, 0xe060, 0x000}, |
| 3451 | {d68000_asr_r_32 , 0xf1f8, 0xe0a0, 0x000}, |
| 3452 | {d68000_asr_ea , 0xffc0, 0xe0c0, 0x3f8}, |
| 3453 | {d68000_asl_s_8 , 0xf1f8, 0xe100, 0x000}, |
| 3454 | {d68000_asl_s_16 , 0xf1f8, 0xe140, 0x000}, |
| 3455 | {d68000_asl_s_32 , 0xf1f8, 0xe180, 0x000}, |
| 3456 | {d68000_asl_r_8 , 0xf1f8, 0xe120, 0x000}, |
| 3457 | {d68000_asl_r_16 , 0xf1f8, 0xe160, 0x000}, |
| 3458 | {d68000_asl_r_32 , 0xf1f8, 0xe1a0, 0x000}, |
| 3459 | {d68000_asl_ea , 0xffc0, 0xe1c0, 0x3f8}, |
| 3460 | {d68000_bcc_8 , 0xf000, 0x6000, 0x000}, |
| 3461 | {d68000_bcc_16 , 0xf0ff, 0x6000, 0x000}, |
| 3462 | {d68020_bcc_32 , 0xf0ff, 0x60ff, 0x000}, |
| 3463 | {d68000_bchg_r , 0xf1c0, 0x0140, 0xbf8}, |
| 3464 | {d68000_bchg_s , 0xffc0, 0x0840, 0xbf8, 0xff00, 0x0000}, |
| 3465 | {d68000_bclr_r , 0xf1c0, 0x0180, 0xbf8}, |
| 3466 | {d68000_bclr_s , 0xffc0, 0x0880, 0xbf8, 0xff00, 0x0000}, |
| 3467 | {d68020_bfchg , 0xffc0, 0xeac0, 0xa78, 0xf000, 0x0000}, |
| 3468 | {d68020_bfclr , 0xffc0, 0xecc0, 0xa78, 0xf000, 0x0000}, |
| 3469 | {d68020_bfexts , 0xffc0, 0xebc0, 0xa7b, 0x8000, 0x0000}, |
| 3470 | {d68020_bfextu , 0xffc0, 0xe9c0, 0xa7b, 0x8000, 0x0000}, |
| 3471 | {d68020_bfffo , 0xffc0, 0xedc0, 0xa7b, 0x8000, 0x0000}, |
| 3472 | {d68020_bfins , 0xffc0, 0xefc0, 0xa78, 0x8000, 0x0000}, |
| 3473 | {d68020_bfset , 0xffc0, 0xeec0, 0xa78, 0xf000, 0x0000}, |
| 3474 | {d68020_bftst , 0xffc0, 0xe8c0, 0xa7b, 0xf000, 0x0000}, |
| 3475 | {d68010_bkpt , 0xfff8, 0x4848, 0x000}, |
| 3476 | {d68000_bra_8 , 0xff00, 0x6000, 0x000}, |
| 3477 | {d68000_bra_16 , 0xffff, 0x6000, 0x000}, |
| 3478 | {d68020_bra_32 , 0xffff, 0x60ff, 0x000}, |
| 3479 | {d68000_bset_r , 0xf1c0, 0x01c0, 0xbf8}, |
| 3480 | {d68000_bset_s , 0xffc0, 0x08c0, 0xbf8, 0xfe00, 0x0000 }, |
| 3481 | {d68000_bsr_8 , 0xff00, 0x6100, 0x000}, |
| 3482 | {d68000_bsr_16 , 0xffff, 0x6100, 0x000}, |
| 3483 | {d68020_bsr_32 , 0xffff, 0x61ff, 0x000}, |
| 3484 | {d68000_btst_r , 0xf1c0, 0x0100, 0xbff}, |
| 3485 | {d68000_btst_s , 0xffc0, 0x0800, 0xbfb, 0xff00, 0x0000}, |
| 3486 | {d68020_callm , 0xffc0, 0x06c0, 0x27b, 0xff00, 0x0000}, |
| 3487 | {d68020_cas_8 , 0xffc0, 0x0ac0, 0x3f8, 0xfe38, 0x0000}, |
| 3488 | {d68020_cas_16 , 0xffc0, 0x0cc0, 0x3f8, 0xfe38, 0x0000}, |
| 3489 | {d68020_cas_32 , 0xffc0, 0x0ec0, 0x3f8, 0xfe38, 0x0000}, |
| 3490 | {d68020_cas2_16 , 0xffff, 0x0cfc, 0x000, 0x0e38, 0x0000/*, 0x0e38, 0x0000 */}, |
| 3491 | {d68020_cas2_32 , 0xffff, 0x0efc, 0x000, 0x0e38, 0x0000/*, 0x0e38, 0x0000 */}, |
| 3492 | {d68000_chk_16 , 0xf1c0, 0x4180, 0xbff}, |
| 3493 | {d68020_chk_32 , 0xf1c0, 0x4100, 0xbff}, |
| 3494 | {d68020_chk2_cmp2_8 , 0xffc0, 0x00c0, 0x27b, 0x07ff, 0x0000}, |
| 3495 | {d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b, 0x07ff, 0x0000}, |
| 3496 | {d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b, 0x07ff, 0x0000}, |
| 3497 | {d68040_cinv , 0xff20, 0xf400, 0x000}, |
| 3498 | {d68000_clr_8 , 0xffc0, 0x4200, 0xbf8}, |
| 3499 | {d68000_clr_16 , 0xffc0, 0x4240, 0xbf8}, |
| 3500 | {d68000_clr_32 , 0xffc0, 0x4280, 0xbf8}, |
| 3501 | {d68000_cmp_8 , 0xf1c0, 0xb000, 0xbff}, |
| 3502 | {d68000_cmp_16 , 0xf1c0, 0xb040, 0xfff}, |
| 3503 | {d68000_cmp_32 , 0xf1c0, 0xb080, 0xfff}, |
| 3504 | {d68000_cmpa_16 , 0xf1c0, 0xb0c0, 0xfff}, |
| 3505 | {d68000_cmpa_32 , 0xf1c0, 0xb1c0, 0xfff}, |
| 3506 | {d68000_cmpi_8 , 0xffc0, 0x0c00, 0xbf8}, |
| 3507 | {d68020_cmpi_pcdi_8 , 0xffff, 0x0c3a, 0x000}, |
| 3508 | {d68020_cmpi_pcix_8 , 0xffff, 0x0c3b, 0x000}, |
| 3509 | {d68000_cmpi_16 , 0xffc0, 0x0c40, 0xbf8}, |
| 3510 | {d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000}, |
| 3511 | {d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000}, |
| 3512 | {d68000_cmpi_32 , 0xffc0, 0x0c80, 0xbf8}, |
| 3513 | {d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000}, |
| 3514 | {d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000}, |
| 3515 | {d68000_cmpm_8 , 0xf1f8, 0xb108, 0x000}, |
| 3516 | {d68000_cmpm_16 , 0xf1f8, 0xb148, 0x000}, |
| 3517 | {d68000_cmpm_32 , 0xf1f8, 0xb188, 0x000}, |
| 3518 | {d68020_cpbcc_16 , 0xf1c0, 0xf080, 0x000}, |
| 3519 | {d68020_cpbcc_32 , 0xf1c0, 0xf0c0, 0x000}, |
| 3520 | {d68020_cpdbcc , 0xf1f8, 0xf048, 0x000}, |
| 3521 | {d68020_cpgen , 0xf1c0, 0xf000, 0x000}, |
| 3522 | {d68020_cprestore , 0xf1c0, 0xf140, 0x37f}, |
| 3523 | {d68020_cpsave , 0xf1c0, 0xf100, 0x2f8}, |
| 3524 | {d68020_cpscc , 0xf1c0, 0xf040, 0xbf8}, |
| 3525 | {d68020_cptrapcc_0 , 0xf1ff, 0xf07c, 0x000}, |
| 3526 | {d68020_cptrapcc_16 , 0xf1ff, 0xf07a, 0x000}, |
| 3527 | {d68020_cptrapcc_32 , 0xf1ff, 0xf07b, 0x000}, |
| 3528 | {d68040_cpush , 0xff20, 0xf420, 0x000}, |
| 3529 | {d68000_dbcc , 0xf0f8, 0x50c8, 0x000}, |
| 3530 | {d68000_dbra , 0xfff8, 0x51c8, 0x000}, |
| 3531 | {d68000_divs , 0xf1c0, 0x81c0, 0xbff}, |
| 3532 | {d68000_divu , 0xf1c0, 0x80c0, 0xbff}, |
| 3533 | {d68020_divl , 0xff80, 0x4c00, 0xbff, 0x83f8, 0x0000}, |
| 3534 | {d68000_eor_8 , 0xf1c0, 0xb100, 0xbf8}, |
| 3535 | {d68000_eor_16 , 0xf1c0, 0xb140, 0xbf8}, |
| 3536 | {d68000_eor_32 , 0xf1c0, 0xb180, 0xbf8}, |
| 3537 | {d68000_eori_to_ccr , 0xffff, 0x0a3c, 0x000, 0xff00, 0x0000}, |
| 3538 | {d68000_eori_to_sr , 0xffff, 0x0a7c, 0x000}, |
| 3539 | {d68000_eori_8 , 0xffc0, 0x0a00, 0xbf8}, |
| 3540 | {d68000_eori_16 , 0xffc0, 0x0a40, 0xbf8}, |
| 3541 | {d68000_eori_32 , 0xffc0, 0x0a80, 0xbf8}, |
| 3542 | {d68000_exg_dd , 0xf1f8, 0xc140, 0x000}, |
| 3543 | {d68000_exg_aa , 0xf1f8, 0xc148, 0x000}, |
| 3544 | {d68000_exg_da , 0xf1f8, 0xc188, 0x000}, |
| 3545 | {d68020_extb_32 , 0xfff8, 0x49c0, 0x000}, |
| 3546 | {d68000_ext_16 , 0xfff8, 0x4880, 0x000}, |
| 3547 | {d68000_ext_32 , 0xfff8, 0x48c0, 0x000}, |
| 3548 | {d68000_illegal , 0xffff, 0x4afc, 0x000}, |
| 3549 | {d68000_jmp , 0xffc0, 0x4ec0, 0x27b}, |
| 3550 | {d68000_jsr , 0xffc0, 0x4e80, 0x27b}, |
| 3551 | {d68000_lea , 0xf1c0, 0x41c0, 0x27b}, |
| 3552 | {d68000_link_16 , 0xfff8, 0x4e50, 0x000}, |
| 3553 | {d68020_link_32 , 0xfff8, 0x4808, 0x000}, |
| 3554 | {d68000_lsr_s_8 , 0xf1f8, 0xe008, 0x000}, |
| 3555 | {d68000_lsr_s_16 , 0xf1f8, 0xe048, 0x000}, |
| 3556 | {d68000_lsr_s_32 , 0xf1f8, 0xe088, 0x000}, |
| 3557 | {d68000_lsr_r_8 , 0xf1f8, 0xe028, 0x000}, |
| 3558 | {d68000_lsr_r_16 , 0xf1f8, 0xe068, 0x000}, |
| 3559 | {d68000_lsr_r_32 , 0xf1f8, 0xe0a8, 0x000}, |
| 3560 | {d68000_lsr_ea , 0xffc0, 0xe2c0, 0x3f8}, |
| 3561 | {d68000_lsl_s_8 , 0xf1f8, 0xe108, 0x000}, |
| 3562 | {d68000_lsl_s_16 , 0xf1f8, 0xe148, 0x000}, |
| 3563 | {d68000_lsl_s_32 , 0xf1f8, 0xe188, 0x000}, |
| 3564 | {d68000_lsl_r_8 , 0xf1f8, 0xe128, 0x000}, |
| 3565 | {d68000_lsl_r_16 , 0xf1f8, 0xe168, 0x000}, |
| 3566 | {d68000_lsl_r_32 , 0xf1f8, 0xe1a8, 0x000}, |
| 3567 | {d68000_lsl_ea , 0xffc0, 0xe3c0, 0x3f8}, |
| 3568 | {d68000_move_8 , 0xf000, 0x1000, 0xbff}, |
| 3569 | {d68000_move_16 , 0xf000, 0x3000, 0xfff}, |
| 3570 | {d68000_move_32 , 0xf000, 0x2000, 0xfff}, |
| 3571 | {d68000_movea_16 , 0xf1c0, 0x3040, 0xfff}, |
| 3572 | {d68000_movea_32 , 0xf1c0, 0x2040, 0xfff}, |
| 3573 | {d68000_move_to_ccr , 0xffc0, 0x44c0, 0xbff}, |
| 3574 | {d68010_move_fr_ccr , 0xffc0, 0x42c0, 0xbf8}, |
| 3575 | {d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff}, |
| 3576 | {d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8}, |
| 3577 | {d68000_move_to_usp , 0xfff8, 0x4e60, 0x000}, |
| 3578 | {d68000_move_fr_usp , 0xfff8, 0x4e68, 0x000}, |
| 3579 | {d68010_movec , 0xfffe, 0x4e7a, 0x000}, |
| 3580 | {d68000_movem_pd_16 , 0xfff8, 0x48a0, 0x000}, |
| 3581 | {d68000_movem_pd_32 , 0xfff8, 0x48e0, 0x000}, |
| 3582 | {d68000_movem_re_16 , 0xffc0, 0x4880, 0x2f8}, |
| 3583 | {d68000_movem_re_32 , 0xffc0, 0x48c0, 0x2f8}, |
| 3584 | {d68000_movem_er_16 , 0xffc0, 0x4c80, 0x37b}, |
| 3585 | {d68000_movem_er_32 , 0xffc0, 0x4cc0, 0x37b}, |
| 3586 | {d68000_movep_er_16 , 0xf1f8, 0x0108, 0x000}, |
| 3587 | {d68000_movep_er_32 , 0xf1f8, 0x0148, 0x000}, |
| 3588 | {d68000_movep_re_16 , 0xf1f8, 0x0188, 0x000}, |
| 3589 | {d68000_movep_re_32 , 0xf1f8, 0x01c8, 0x000}, |
| 3590 | {d68010_moves_8 , 0xffc0, 0x0e00, 0x3f8, 0x07ff, 0x0000}, |
| 3591 | {d68010_moves_16 , 0xffc0, 0x0e40, 0x3f8, 0x07ff, 0x0000}, |
| 3592 | {d68010_moves_32 , 0xffc0, 0x0e80, 0x3f8, 0x07ff, 0x0000}, |
| 3593 | {d68000_moveq , 0xf100, 0x7000, 0x000}, |
| 3594 | {d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000, 0x8fff, 0x8000}, |
| 3595 | {d68040_move16_pi_al , 0xfff8, 0xf600, 0x000}, |
| 3596 | {d68040_move16_al_pi , 0xfff8, 0xf608, 0x000}, |
| 3597 | {d68040_move16_ai_al , 0xfff8, 0xf610, 0x000}, |
| 3598 | {d68040_move16_al_ai , 0xfff8, 0xf618, 0x000}, |
| 3599 | {d68000_muls , 0xf1c0, 0xc1c0, 0xbff}, |
| 3600 | {d68000_mulu , 0xf1c0, 0xc0c0, 0xbff}, |
| 3601 | {d68020_mull , 0xffc0, 0x4c00, 0xbff, 0x83f8, 0x0000}, |
| 3602 | {d68000_nbcd , 0xffc0, 0x4800, 0xbf8}, |
| 3603 | {d68000_neg_8 , 0xffc0, 0x4400, 0xbf8}, |
| 3604 | {d68000_neg_16 , 0xffc0, 0x4440, 0xbf8}, |
| 3605 | {d68000_neg_32 , 0xffc0, 0x4480, 0xbf8}, |
| 3606 | {d68000_negx_8 , 0xffc0, 0x4000, 0xbf8}, |
| 3607 | {d68000_negx_16 , 0xffc0, 0x4040, 0xbf8}, |
| 3608 | {d68000_negx_32 , 0xffc0, 0x4080, 0xbf8}, |
| 3609 | {d68000_nop , 0xffff, 0x4e71, 0x000}, |
| 3610 | {d68000_not_8 , 0xffc0, 0x4600, 0xbf8}, |
| 3611 | {d68000_not_16 , 0xffc0, 0x4640, 0xbf8}, |
| 3612 | {d68000_not_32 , 0xffc0, 0x4680, 0xbf8}, |
| 3613 | {d68000_or_er_8 , 0xf1c0, 0x8000, 0xbff}, |
| 3614 | {d68000_or_er_16 , 0xf1c0, 0x8040, 0xbff}, |
| 3615 | {d68000_or_er_32 , 0xf1c0, 0x8080, 0xbff}, |
| 3616 | {d68000_or_re_8 , 0xf1c0, 0x8100, 0x3f8}, |
| 3617 | {d68000_or_re_16 , 0xf1c0, 0x8140, 0x3f8}, |
| 3618 | {d68000_or_re_32 , 0xf1c0, 0x8180, 0x3f8}, |
| 3619 | {d68000_ori_to_ccr , 0xffff, 0x003c, 0x000, 0xff00, 0x0000}, |
| 3620 | {d68000_ori_to_sr , 0xffff, 0x007c, 0x000}, |
| 3621 | {d68000_ori_8 , 0xffc0, 0x0000, 0xbf8}, |
| 3622 | {d68000_ori_16 , 0xffc0, 0x0040, 0xbf8}, |
| 3623 | {d68000_ori_32 , 0xffc0, 0x0080, 0xbf8}, |
| 3624 | {d68020_pack_rr , 0xf1f8, 0x8140, 0x000}, |
| 3625 | {d68020_pack_mm , 0xf1f8, 0x8148, 0x000}, |
| 3626 | {d68000_pea , 0xffc0, 0x4840, 0x27b}, |
| 3627 | {d68000_reset , 0xffff, 0x4e70, 0x000}, |
| 3628 | {d68000_ror_s_8 , 0xf1f8, 0xe018, 0x000}, |
| 3629 | {d68000_ror_s_16 , 0xf1f8, 0xe058, 0x000}, |
| 3630 | {d68000_ror_s_32 , 0xf1f8, 0xe098, 0x000}, |
| 3631 | {d68000_ror_r_8 , 0xf1f8, 0xe038, 0x000}, |
| 3632 | {d68000_ror_r_16 , 0xf1f8, 0xe078, 0x000}, |
| 3633 | {d68000_ror_r_32 , 0xf1f8, 0xe0b8, 0x000}, |
| 3634 | {d68000_ror_ea , 0xffc0, 0xe6c0, 0x3f8}, |
| 3635 | {d68000_rol_s_8 , 0xf1f8, 0xe118, 0x000}, |
| 3636 | {d68000_rol_s_16 , 0xf1f8, 0xe158, 0x000}, |
| 3637 | {d68000_rol_s_32 , 0xf1f8, 0xe198, 0x000}, |
| 3638 | {d68000_rol_r_8 , 0xf1f8, 0xe138, 0x000}, |
| 3639 | {d68000_rol_r_16 , 0xf1f8, 0xe178, 0x000}, |
| 3640 | {d68000_rol_r_32 , 0xf1f8, 0xe1b8, 0x000}, |
| 3641 | {d68000_rol_ea , 0xffc0, 0xe7c0, 0x3f8}, |
| 3642 | {d68000_roxr_s_8 , 0xf1f8, 0xe010, 0x000}, |
| 3643 | {d68000_roxr_s_16 , 0xf1f8, 0xe050, 0x000}, |
| 3644 | {d68000_roxr_s_32 , 0xf1f8, 0xe090, 0x000}, |
| 3645 | {d68000_roxr_r_8 , 0xf1f8, 0xe030, 0x000}, |
| 3646 | {d68000_roxr_r_16 , 0xf1f8, 0xe070, 0x000}, |
| 3647 | {d68000_roxr_r_32 , 0xf1f8, 0xe0b0, 0x000}, |
| 3648 | {d68000_roxr_ea , 0xffc0, 0xe4c0, 0x3f8}, |
| 3649 | {d68000_roxl_s_8 , 0xf1f8, 0xe110, 0x000}, |
| 3650 | {d68000_roxl_s_16 , 0xf1f8, 0xe150, 0x000}, |
| 3651 | {d68000_roxl_s_32 , 0xf1f8, 0xe190, 0x000}, |
| 3652 | {d68000_roxl_r_8 , 0xf1f8, 0xe130, 0x000}, |
| 3653 | {d68000_roxl_r_16 , 0xf1f8, 0xe170, 0x000}, |
| 3654 | {d68000_roxl_r_32 , 0xf1f8, 0xe1b0, 0x000}, |
| 3655 | {d68000_roxl_ea , 0xffc0, 0xe5c0, 0x3f8}, |
| 3656 | {d68010_rtd , 0xffff, 0x4e74, 0x000}, |
| 3657 | {d68000_rte , 0xffff, 0x4e73, 0x000}, |
| 3658 | {d68020_rtm , 0xfff0, 0x06c0, 0x000}, |
| 3659 | {d68000_rtr , 0xffff, 0x4e77, 0x000}, |
| 3660 | {d68000_rts , 0xffff, 0x4e75, 0x000}, |
| 3661 | {d68000_sbcd_rr , 0xf1f8, 0x8100, 0x000}, |
| 3662 | {d68000_sbcd_mm , 0xf1f8, 0x8108, 0x000}, |
| 3663 | {d68000_scc , 0xf0c0, 0x50c0, 0xbf8}, |
| 3664 | {d68000_stop , 0xffff, 0x4e72, 0x000}, |
| 3665 | {d68000_sub_er_8 , 0xf1c0, 0x9000, 0xbff}, |
| 3666 | {d68000_sub_er_16 , 0xf1c0, 0x9040, 0xfff}, |
| 3667 | {d68000_sub_er_32 , 0xf1c0, 0x9080, 0xfff}, |
| 3668 | {d68000_sub_re_8 , 0xf1c0, 0x9100, 0x3f8}, |
| 3669 | {d68000_sub_re_16 , 0xf1c0, 0x9140, 0x3f8}, |
| 3670 | {d68000_sub_re_32 , 0xf1c0, 0x9180, 0x3f8}, |
| 3671 | {d68000_suba_16 , 0xf1c0, 0x90c0, 0xfff}, |
| 3672 | {d68000_suba_32 , 0xf1c0, 0x91c0, 0xfff}, |
| 3673 | {d68000_subi_8 , 0xffc0, 0x0400, 0xbf8}, |
| 3674 | {d68000_subi_16 , 0xffc0, 0x0440, 0xbf8}, |
| 3675 | {d68000_subi_32 , 0xffc0, 0x0480, 0xbf8}, |
| 3676 | {d68000_subq_8 , 0xf1c0, 0x5100, 0xbf8}, |
| 3677 | {d68000_subq_16 , 0xf1c0, 0x5140, 0xff8}, |
| 3678 | {d68000_subq_32 , 0xf1c0, 0x5180, 0xff8}, |
| 3679 | {d68000_subx_rr_8 , 0xf1f8, 0x9100, 0x000}, |
| 3680 | {d68000_subx_rr_16 , 0xf1f8, 0x9140, 0x000}, |
| 3681 | {d68000_subx_rr_32 , 0xf1f8, 0x9180, 0x000}, |
| 3682 | {d68000_subx_mm_8 , 0xf1f8, 0x9108, 0x000}, |
| 3683 | {d68000_subx_mm_16 , 0xf1f8, 0x9148, 0x000}, |
| 3684 | {d68000_subx_mm_32 , 0xf1f8, 0x9188, 0x000}, |
| 3685 | {d68000_swap , 0xfff8, 0x4840, 0x000}, |
| 3686 | {d68000_tas , 0xffc0, 0x4ac0, 0xbf8}, |
| 3687 | {d68000_trap , 0xfff0, 0x4e40, 0x000}, |
| 3688 | {d68020_trapcc_0 , 0xf0ff, 0x50fc, 0x000}, |
| 3689 | {d68020_trapcc_16 , 0xf0ff, 0x50fa, 0x000}, |
| 3690 | {d68020_trapcc_32 , 0xf0ff, 0x50fb, 0x000}, |
| 3691 | {d68000_trapv , 0xffff, 0x4e76, 0x000}, |
| 3692 | {d68000_tst_8 , 0xffc0, 0x4a00, 0xbf8}, |
| 3693 | {d68020_tst_pcdi_8 , 0xffff, 0x4a3a, 0x000}, |
| 3694 | {d68020_tst_pcix_8 , 0xffff, 0x4a3b, 0x000}, |
| 3695 | {d68020_tst_i_8 , 0xffff, 0x4a3c, 0x000}, |
| 3696 | {d68000_tst_16 , 0xffc0, 0x4a40, 0xbf8}, |
| 3697 | {d68020_tst_a_16 , 0xfff8, 0x4a48, 0x000}, |
| 3698 | {d68020_tst_pcdi_16 , 0xffff, 0x4a7a, 0x000}, |
| 3699 | {d68020_tst_pcix_16 , 0xffff, 0x4a7b, 0x000}, |
| 3700 | {d68020_tst_i_16 , 0xffff, 0x4a7c, 0x000}, |
| 3701 | {d68000_tst_32 , 0xffc0, 0x4a80, 0xbf8}, |
| 3702 | {d68020_tst_a_32 , 0xfff8, 0x4a88, 0x000}, |
| 3703 | {d68020_tst_pcdi_32 , 0xffff, 0x4aba, 0x000}, |
| 3704 | {d68020_tst_pcix_32 , 0xffff, 0x4abb, 0x000}, |
| 3705 | {d68020_tst_i_32 , 0xffff, 0x4abc, 0x000}, |
| 3706 | {d68000_unlk , 0xfff8, 0x4e58, 0x000}, |
| 3707 | {d68020_unpk_rr , 0xf1f8, 0x8180, 0x000}, |
| 3708 | {d68020_unpk_mm , 0xf1f8, 0x8188, 0x000}, |
| 3709 | {0, 0, 0, 0} |
| 3710 | }; |
| 3711 | |
| 3712 | /* Check if opcode is using a valid ea mode */ |
| 3713 | static int valid_ea(uint opcode, uint mask) |
| 3714 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3715 | if (mask == 0) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3716 | return 1; |
| 3717 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3718 | switch(opcode & 0x3f) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3719 | case 0x00: case 0x01: case 0x02: case 0x03: |
| 3720 | case 0x04: case 0x05: case 0x06: case 0x07: |
| 3721 | return (mask & 0x800) != 0; |
| 3722 | case 0x08: case 0x09: case 0x0a: case 0x0b: |
| 3723 | case 0x0c: case 0x0d: case 0x0e: case 0x0f: |
| 3724 | return (mask & 0x400) != 0; |
| 3725 | case 0x10: case 0x11: case 0x12: case 0x13: |
| 3726 | case 0x14: case 0x15: case 0x16: case 0x17: |
| 3727 | return (mask & 0x200) != 0; |
| 3728 | case 0x18: case 0x19: case 0x1a: case 0x1b: |
| 3729 | case 0x1c: case 0x1d: case 0x1e: case 0x1f: |
| 3730 | return (mask & 0x100) != 0; |
| 3731 | case 0x20: case 0x21: case 0x22: case 0x23: |
| 3732 | case 0x24: case 0x25: case 0x26: case 0x27: |
| 3733 | return (mask & 0x080) != 0; |
| 3734 | case 0x28: case 0x29: case 0x2a: case 0x2b: |
| 3735 | case 0x2c: case 0x2d: case 0x2e: case 0x2f: |
| 3736 | return (mask & 0x040) != 0; |
| 3737 | case 0x30: case 0x31: case 0x32: case 0x33: |
| 3738 | case 0x34: case 0x35: case 0x36: case 0x37: |
| 3739 | return (mask & 0x020) != 0; |
| 3740 | case 0x38: |
| 3741 | return (mask & 0x010) != 0; |
| 3742 | case 0x39: |
| 3743 | return (mask & 0x008) != 0; |
| 3744 | case 0x3a: |
| 3745 | return (mask & 0x002) != 0; |
| 3746 | case 0x3b: |
| 3747 | return (mask & 0x001) != 0; |
| 3748 | case 0x3c: |
| 3749 | return (mask & 0x004) != 0; |
| 3750 | } |
| 3751 | return 0; |
| 3752 | |
| 3753 | } |
| 3754 | |
| 3755 | /* Used by qsort */ |
| 3756 | static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr) |
| 3757 | { |
| 3758 | uint a = ((const opcode_struct*)aptr)->mask; |
| 3759 | uint b = ((const opcode_struct*)bptr)->mask; |
| 3760 | |
| 3761 | a = ((a & 0xAAAA) >> 1) + (a & 0x5555); |
| 3762 | a = ((a & 0xCCCC) >> 2) + (a & 0x3333); |
| 3763 | a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F); |
| 3764 | a = ((a & 0xFF00) >> 8) + (a & 0x00FF); |
| 3765 | |
| 3766 | b = ((b & 0xAAAA) >> 1) + (b & 0x5555); |
| 3767 | b = ((b & 0xCCCC) >> 2) + (b & 0x3333); |
| 3768 | b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F); |
| 3769 | b = ((b & 0xFF00) >> 8) + (b & 0x00FF); |
| 3770 | |
| 3771 | return b - a; /* reversed to get greatest to least sorting */ |
| 3772 | } |
| 3773 | |
| 3774 | /* build the opcode handler jump table */ |
| 3775 | static void build_opcode_table(void) |
| 3776 | { |
| 3777 | uint i; |
| 3778 | uint opcode; |
| 3779 | opcode_struct* ostruct; |
| 3780 | uint opcode_info_length = 0; |
| 3781 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3782 | /* Already initialized ? */ |
| 3783 | if (g_instruction_table[0].instruction != NULL) { |
| 3784 | return; |
| 3785 | } |
| 3786 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3787 | for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++) |
| 3788 | opcode_info_length++; |
| 3789 | |
| 3790 | qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits); |
| 3791 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3792 | for(i=0;i<0x10000;i++) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3793 | g_instruction_table[i].instruction = d68000_invalid; /* default to invalid, undecoded opcode */ |
| 3794 | opcode = i; |
| 3795 | /* search through opcode info for a match */ |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3796 | for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3797 | /* match opcode mask and allowed ea modes */ |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3798 | if ((opcode & ostruct->mask) == ostruct->match) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3799 | /* Handle destination ea for move instructions */ |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3800 | if ((ostruct->opcode_handler == d68000_move_8 || |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3801 | ostruct->opcode_handler == d68000_move_16 || |
| 3802 | ostruct->opcode_handler == d68000_move_32) && |
| 3803 | !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8)) |
| 3804 | continue; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3805 | if (valid_ea(opcode, ostruct->ea_mask)) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3806 | g_instruction_table[i].instruction = ostruct->opcode_handler; |
| 3807 | g_instruction_table[i].word2_mask = ostruct->mask2; |
| 3808 | g_instruction_table[i].word2_match = ostruct->match2; |
| 3809 | break; |
| 3810 | } |
| 3811 | } |
| 3812 | } |
| 3813 | } |
| 3814 | } |
| 3815 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3816 | static int instruction_is_valid(m68k_info *info, const unsigned int word_check) |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3817 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3818 | const unsigned int instruction = info->ir; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3819 | instruction_struct *i = &g_instruction_table[instruction]; |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3820 | |
Nicolas PLANEL | b9f66d6 | 2015-10-08 15:35:39 +1100 | [diff] [blame] | 3821 | if ( (i->word2_mask && ((word_check & i->word2_mask) != i->word2_match)) || |
| 3822 | (i->instruction == d68000_invalid) ) { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3823 | d68000_invalid(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3824 | return 0; |
| 3825 | } |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3826 | |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 3827 | return 1; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3828 | } |
| 3829 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3830 | static void m68k_setup_internals(m68k_info* info, MCInst* inst, unsigned int pc, unsigned int cpu_type) |
| 3831 | { |
| 3832 | info->inst = inst; |
| 3833 | info->pc = pc; |
| 3834 | info->ir = 0; |
| 3835 | info->type = cpu_type; |
| 3836 | info->address_mask = 0xffffffff; |
| 3837 | |
| 3838 | switch(info->type) { |
| 3839 | case M68K_CPU_TYPE_68000: |
| 3840 | info->type = TYPE_68000; |
| 3841 | info->address_mask = 0x00ffffff; |
| 3842 | break; |
| 3843 | case M68K_CPU_TYPE_68010: |
| 3844 | info->type = TYPE_68010; |
| 3845 | info->address_mask = 0x00ffffff; |
| 3846 | break; |
| 3847 | case M68K_CPU_TYPE_68EC020: |
| 3848 | info->type = TYPE_68020; |
| 3849 | info->address_mask = 0x00ffffff; |
| 3850 | break; |
| 3851 | case M68K_CPU_TYPE_68020: |
| 3852 | info->type = TYPE_68020; |
| 3853 | info->address_mask = 0xffffffff; |
| 3854 | break; |
| 3855 | case M68K_CPU_TYPE_68030: |
| 3856 | info->type = TYPE_68030; |
| 3857 | info->address_mask = 0xffffffff; |
| 3858 | break; |
| 3859 | case M68K_CPU_TYPE_68040: |
| 3860 | info->type = TYPE_68040; |
| 3861 | info->address_mask = 0xffffffff; |
| 3862 | break; |
| 3863 | default: |
| 3864 | info->address_mask = 0; |
| 3865 | return; |
| 3866 | } |
| 3867 | } |
| 3868 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3869 | /* ======================================================================== */ |
| 3870 | /* ================================= API ================================== */ |
| 3871 | /* ======================================================================== */ |
| 3872 | |
| 3873 | /* Disasemble one instruction at pc and store in str_buff */ |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3874 | static unsigned int m68k_disassemble(m68k_info *info, uint64_t pc) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3875 | { |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3876 | MCInst *inst = info->inst; |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 3877 | cs_m68k* ext = &info->extension; |
| 3878 | int i; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3879 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3880 | inst->Opcode = M68K_INS_INVALID; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3881 | |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3882 | build_opcode_table(); |
| 3883 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 3884 | memset(ext, 0, sizeof(cs_m68k)); |
| 3885 | ext->op_size.type = M68K_SIZE_TYPE_CPU; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3886 | |
Nicolas PLANEL | d529ea0 | 2015-10-05 20:19:33 +1100 | [diff] [blame] | 3887 | for (i = 0; i < M68K_OPERAND_COUNT; ++i) |
| 3888 | ext->operands[i].type = M68K_OP_REG; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3889 | |
Nicolas PLANEL | b9f66d6 | 2015-10-08 15:35:39 +1100 | [diff] [blame] | 3890 | info->ir = peek_imm_16(info); |
| 3891 | if (instruction_is_valid(info, peek_imm_32(info) & 0xffff)) { |
| 3892 | info->ir = read_imm_16(info); |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3893 | g_instruction_table[info->ir].instruction(info); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3894 | } |
| 3895 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 3896 | return info->pc - (unsigned int)pc; |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3897 | } |
| 3898 | |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3899 | bool M68K_getInstruction(csh ud, const uint8_t* code, size_t code_len, MCInst* instr, uint16_t* size, uint64_t address, void* inst_info) |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 3900 | { |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3901 | #ifdef M68K_DEBUG |
| 3902 | SStream ss; |
| 3903 | #endif |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 3904 | int s; |
| 3905 | int cpu_type = M68K_CPU_TYPE_68000; |
Nicolas PLANEL | 44cc3d0 | 2015-10-05 21:56:39 +1100 | [diff] [blame] | 3906 | cs_struct* handle = instr->csh; |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3907 | m68k_info *info = (m68k_info*)handle->printer_info; |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3908 | |
Daniel Collin | 1bca054 | 2016-04-10 16:16:28 +0200 | [diff] [blame^] | 3909 | info->groups_count = 0; |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3910 | info->code = code; |
Nicolas PLANEL | 8daac3a | 2015-10-08 16:34:25 +1100 | [diff] [blame] | 3911 | info->code_len = code_len; |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3912 | info->baseAddress = address; |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 3913 | |
| 3914 | if (handle->mode & CS_MODE_M68K_010) |
| 3915 | cpu_type = M68K_CPU_TYPE_68010; |
| 3916 | if (handle->mode & CS_MODE_M68K_020) |
| 3917 | cpu_type = M68K_CPU_TYPE_68020; |
| 3918 | if (handle->mode & CS_MODE_M68K_030) |
| 3919 | cpu_type = M68K_CPU_TYPE_68030; |
| 3920 | if (handle->mode & CS_MODE_M68K_040) |
| 3921 | cpu_type = M68K_CPU_TYPE_68040; |
| 3922 | if (handle->mode & CS_MODE_M68K_060) |
| 3923 | cpu_type = M68K_CPU_TYPE_68040; // 060 = 040 for now |
| 3924 | |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 3925 | m68k_setup_internals(info, instr, (unsigned int)address, cpu_type); |
Nicolas PLANEL | ee75626 | 2015-10-05 19:26:30 +1100 | [diff] [blame] | 3926 | s = m68k_disassemble(info, address); |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 3927 | |
| 3928 | if (s == 0) { |
| 3929 | *size = 2; |
| 3930 | return false; |
| 3931 | } |
| 3932 | |
| 3933 | #ifdef M68K_DEBUG |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 3934 | SStream_Init(&ss); |
| 3935 | M68K_printInst(instr, &ss, info); |
| 3936 | #endif |
| 3937 | |
Daniel Collin | 988bb63 | 2016-04-10 10:55:21 +0200 | [diff] [blame] | 3938 | // Make sure we always stay within range |
Daniel Collin | 25d2ea6 | 2015-10-05 16:31:06 +0200 | [diff] [blame] | 3939 | if (s > (int)code_len) |
Nguyen Anh Quynh | 918215d | 2016-03-08 11:08:20 +0800 | [diff] [blame] | 3940 | *size = (uint16_t)code_len; |
Daniel Collin | e8a4e98 | 2015-10-04 14:22:58 +0200 | [diff] [blame] | 3941 | else |
| 3942 | *size = (uint16_t)s; |
| 3943 | |
| 3944 | return true; |
| 3945 | } |
| 3946 | |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3947 | #if 0 |
| 3948 | |
| 3949 | // Currently not used |
| 3950 | |
| 3951 | /* Check if the instruction is a valid one */ |
| 3952 | unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type) |
| 3953 | { |
Nicolas PLANEL | 3a64e58 | 2015-10-04 20:07:57 +1100 | [diff] [blame] | 3954 | build_opcode_table(); |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3955 | |
| 3956 | instruction &= 0xffff; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3957 | if (g_instruction_table[instruction] == d68000_invalid) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3958 | return 0; |
| 3959 | |
Nguyen Anh Quynh | 7d5badd | 2015-10-04 21:45:50 +0800 | [diff] [blame] | 3960 | switch(cpu_type) { |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3961 | case M68K_CPU_TYPE_68000: |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3962 | if (g_instruction_table[instruction] == d68010_bkpt) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3963 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3964 | if (g_instruction_table[instruction] == d68010_move_fr_ccr) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3965 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3966 | if (g_instruction_table[instruction] == d68010_movec) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3967 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3968 | if (g_instruction_table[instruction] == d68010_moves_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3969 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3970 | if (g_instruction_table[instruction] == d68010_moves_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3971 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3972 | if (g_instruction_table[instruction] == d68010_moves_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3973 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3974 | if (g_instruction_table[instruction] == d68010_rtd) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3975 | return 0; |
| 3976 | case M68K_CPU_TYPE_68010: |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3977 | if (g_instruction_table[instruction] == d68020_bcc_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3978 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3979 | if (g_instruction_table[instruction] == d68020_bfchg) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3980 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3981 | if (g_instruction_table[instruction] == d68020_bfclr) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3982 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3983 | if (g_instruction_table[instruction] == d68020_bfexts) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3984 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3985 | if (g_instruction_table[instruction] == d68020_bfextu) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3986 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3987 | if (g_instruction_table[instruction] == d68020_bfffo) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3988 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3989 | if (g_instruction_table[instruction] == d68020_bfins) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3990 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3991 | if (g_instruction_table[instruction] == d68020_bfset) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3992 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3993 | if (g_instruction_table[instruction] == d68020_bftst) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3994 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3995 | if (g_instruction_table[instruction] == d68020_bra_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3996 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3997 | if (g_instruction_table[instruction] == d68020_bsr_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 3998 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 3999 | if (g_instruction_table[instruction] == d68020_callm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4000 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4001 | if (g_instruction_table[instruction] == d68020_cas_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4002 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4003 | if (g_instruction_table[instruction] == d68020_cas_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4004 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4005 | if (g_instruction_table[instruction] == d68020_cas_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4006 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4007 | if (g_instruction_table[instruction] == d68020_cas2_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4008 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4009 | if (g_instruction_table[instruction] == d68020_cas2_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4010 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4011 | if (g_instruction_table[instruction] == d68020_chk_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4012 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4013 | if (g_instruction_table[instruction] == d68020_chk2_cmp2_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4014 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4015 | if (g_instruction_table[instruction] == d68020_chk2_cmp2_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4016 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4017 | if (g_instruction_table[instruction] == d68020_chk2_cmp2_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4018 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4019 | if (g_instruction_table[instruction] == d68020_cmpi_pcdi_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4020 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4021 | if (g_instruction_table[instruction] == d68020_cmpi_pcix_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4022 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4023 | if (g_instruction_table[instruction] == d68020_cmpi_pcdi_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4024 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4025 | if (g_instruction_table[instruction] == d68020_cmpi_pcix_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4026 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4027 | if (g_instruction_table[instruction] == d68020_cmpi_pcdi_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4028 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4029 | if (g_instruction_table[instruction] == d68020_cmpi_pcix_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4030 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4031 | if (g_instruction_table[instruction] == d68020_cpbcc_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4032 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4033 | if (g_instruction_table[instruction] == d68020_cpbcc_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4034 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4035 | if (g_instruction_table[instruction] == d68020_cpdbcc) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4036 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4037 | if (g_instruction_table[instruction] == d68020_cpgen) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4038 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4039 | if (g_instruction_table[instruction] == d68020_cprestore) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4040 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4041 | if (g_instruction_table[instruction] == d68020_cpsave) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4042 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4043 | if (g_instruction_table[instruction] == d68020_cpscc) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4044 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4045 | if (g_instruction_table[instruction] == d68020_cptrapcc_0) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4046 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4047 | if (g_instruction_table[instruction] == d68020_cptrapcc_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4048 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4049 | if (g_instruction_table[instruction] == d68020_cptrapcc_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4050 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4051 | if (g_instruction_table[instruction] == d68020_divl) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4052 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4053 | if (g_instruction_table[instruction] == d68020_extb_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4054 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4055 | if (g_instruction_table[instruction] == d68020_link_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4056 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4057 | if (g_instruction_table[instruction] == d68020_mull) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4058 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4059 | if (g_instruction_table[instruction] == d68020_pack_rr) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4060 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4061 | if (g_instruction_table[instruction] == d68020_pack_mm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4062 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4063 | if (g_instruction_table[instruction] == d68020_rtm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4064 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4065 | if (g_instruction_table[instruction] == d68020_trapcc_0) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4066 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4067 | if (g_instruction_table[instruction] == d68020_trapcc_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4068 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4069 | if (g_instruction_table[instruction] == d68020_trapcc_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4070 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4071 | if (g_instruction_table[instruction] == d68020_tst_pcdi_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4072 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4073 | if (g_instruction_table[instruction] == d68020_tst_pcix_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4074 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4075 | if (g_instruction_table[instruction] == d68020_tst_i_8) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4076 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4077 | if (g_instruction_table[instruction] == d68020_tst_a_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4078 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4079 | if (g_instruction_table[instruction] == d68020_tst_pcdi_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4080 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4081 | if (g_instruction_table[instruction] == d68020_tst_pcix_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4082 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4083 | if (g_instruction_table[instruction] == d68020_tst_i_16) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4084 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4085 | if (g_instruction_table[instruction] == d68020_tst_a_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4086 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4087 | if (g_instruction_table[instruction] == d68020_tst_pcdi_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4088 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4089 | if (g_instruction_table[instruction] == d68020_tst_pcix_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4090 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4091 | if (g_instruction_table[instruction] == d68020_tst_i_32) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4092 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4093 | if (g_instruction_table[instruction] == d68020_unpk_rr) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4094 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4095 | if (g_instruction_table[instruction] == d68020_unpk_mm) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4096 | return 0; |
| 4097 | case M68K_CPU_TYPE_68EC020: |
| 4098 | case M68K_CPU_TYPE_68020: |
| 4099 | case M68K_CPU_TYPE_68030: |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4100 | if (g_instruction_table[instruction] == d68040_cinv) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4101 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4102 | if (g_instruction_table[instruction] == d68040_cpush) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4103 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4104 | if (g_instruction_table[instruction] == d68040_move16_pi_pi) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4105 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4106 | if (g_instruction_table[instruction] == d68040_move16_pi_al) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4107 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4108 | if (g_instruction_table[instruction] == d68040_move16_al_pi) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4109 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4110 | if (g_instruction_table[instruction] == d68040_move16_ai_al) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4111 | return 0; |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4112 | if (g_instruction_table[instruction] == d68040_move16_al_ai) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4113 | return 0; |
| 4114 | } |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 4115 | |
Nguyen Anh Quynh | 58fe7cd | 2015-10-05 16:05:17 +0800 | [diff] [blame] | 4116 | if (cpu_type != M68K_CPU_TYPE_68020 && cpu_type != M68K_CPU_TYPE_68EC020 && |
Nguyen Anh Quynh | ac63d5b | 2015-10-04 14:34:51 +0800 | [diff] [blame] | 4117 | (g_instruction_table[instruction] == d68020_callm || |
| 4118 | g_instruction_table[instruction] == d68020_rtm)) |
Daniel Collin | 2ee675c | 2015-08-03 18:45:08 +0200 | [diff] [blame] | 4119 | return 0; |
| 4120 | |
| 4121 | return 1; |
| 4122 | } |
Daniel Collin | fc63aca | 2015-10-04 14:12:59 +0200 | [diff] [blame] | 4123 | #endif |
| 4124 | |