M68KDisassembler.c
Go to the documentation of this file.
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 
30 /* The code bellow is based on MUSASHI but has been heavily modified for capstore by
31  * Daniel Collin <daniel@collin.com> 2015-2016 */
32 
33 /* ======================================================================== */
34 /* ================================ INCLUDES ============================== */
35 /* ======================================================================== */
36 
37 #include <stdlib.h>
38 #include <stdio.h>
39 #include <string.h>
40 
41 #include "../../cs_priv.h"
42 #include "../../utils.h"
43 
44 #include "../../MCInst.h"
45 #include "../../MCInstrDesc.h"
46 #include "../../MCRegisterInfo.h"
47 #include "M68KInstPrinter.h"
48 #include "M68KDisassembler.h"
49 
50 #ifndef DECL_SPEC
51 #ifdef _MSC_VER
52 #define DECL_SPEC __cdecl
53 #else
54 #define DECL_SPEC
55 #endif // _MSC_VER
56 #endif // DECL_SPEC
57 
58 /* ======================================================================== */
59 /* ============================ GENERAL DEFINES =========================== */
60 /* ======================================================================== */
61 
62 /* unsigned int and int must be at least 32 bits wide */
63 #undef uint
64 #define uint unsigned int
65 
66 /* Bit Isolation Functions */
67 #define BIT_0(A) ((A) & 0x00000001)
68 #define BIT_1(A) ((A) & 0x00000002)
69 #define BIT_2(A) ((A) & 0x00000004)
70 #define BIT_3(A) ((A) & 0x00000008)
71 #define BIT_4(A) ((A) & 0x00000010)
72 #define BIT_5(A) ((A) & 0x00000020)
73 #define BIT_6(A) ((A) & 0x00000040)
74 #define BIT_7(A) ((A) & 0x00000080)
75 #define BIT_8(A) ((A) & 0x00000100)
76 #define BIT_9(A) ((A) & 0x00000200)
77 #define BIT_A(A) ((A) & 0x00000400)
78 #define BIT_B(A) ((A) & 0x00000800)
79 #define BIT_C(A) ((A) & 0x00001000)
80 #define BIT_D(A) ((A) & 0x00002000)
81 #define BIT_E(A) ((A) & 0x00004000)
82 #define BIT_F(A) ((A) & 0x00008000)
83 #define BIT_10(A) ((A) & 0x00010000)
84 #define BIT_11(A) ((A) & 0x00020000)
85 #define BIT_12(A) ((A) & 0x00040000)
86 #define BIT_13(A) ((A) & 0x00080000)
87 #define BIT_14(A) ((A) & 0x00100000)
88 #define BIT_15(A) ((A) & 0x00200000)
89 #define BIT_16(A) ((A) & 0x00400000)
90 #define BIT_17(A) ((A) & 0x00800000)
91 #define BIT_18(A) ((A) & 0x01000000)
92 #define BIT_19(A) ((A) & 0x02000000)
93 #define BIT_1A(A) ((A) & 0x04000000)
94 #define BIT_1B(A) ((A) & 0x08000000)
95 #define BIT_1C(A) ((A) & 0x10000000)
96 #define BIT_1D(A) ((A) & 0x20000000)
97 #define BIT_1E(A) ((A) & 0x40000000)
98 #define BIT_1F(A) ((A) & 0x80000000)
99 
100 /* These are the CPU types understood by this disassembler */
101 #define TYPE_68000 1
102 #define TYPE_68010 2
103 #define TYPE_68020 4
104 #define TYPE_68030 8
105 #define TYPE_68040 16
106 
107 #define M68000_ONLY TYPE_68000
108 
109 #define M68010_ONLY TYPE_68010
110 #define M68010_LESS (TYPE_68000 | TYPE_68010)
111 #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040)
112 
113 #define M68020_ONLY TYPE_68020
114 #define M68020_LESS (TYPE_68010 | TYPE_68020)
115 #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040)
116 
117 #define M68030_ONLY TYPE_68030
118 #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030)
119 #define M68030_PLUS (TYPE_68030 | TYPE_68040)
120 
121 #define M68040_PLUS TYPE_68040
122 
123 enum {
129  M68K_CPU_TYPE_68030, /* Supported by disassembler ONLY */
130  M68K_CPU_TYPE_68040 /* Supported by disassembler ONLY */
131 };
132 
133 /* Extension word formats */
134 #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff)
135 #define EXT_FULL(A) BIT_8(A)
136 #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0)
137 #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A))
138 #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A))
139 #define EXT_INDEX_REGISTER(A) (((A)>>12)&7)
140 #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3)
141 #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0)
142 #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4)
143 #define EXT_INDEX_SCALE(A) (((A)>>9)&3)
144 #define EXT_INDEX_LONG(A) BIT_B(A)
145 #define EXT_INDEX_AR(A) BIT_F(A)
146 #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10)
147 #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20)
148 #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30)
149 #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44)
150 #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44)
151 #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44)
152 
153 #define IS_BITSET(val,b) ((val) & (1 << (b)))
154 #define BITFIELD_MASK(sb,eb) (((1 << ((sb) + 1))-1) & (~((1 << (eb))-1)))
155 #define BITFIELD(val,sb,eb) ((BITFIELD_MASK(sb,eb) & (val)) >> (eb))
156 
158 
159 static unsigned int m68k_read_disassembler_16(const m68k_info *info, const uint64_t addr)
160 {
161  const uint16_t v0 = info->code[addr + 0];
162  const uint16_t v1 = info->code[addr + 1];
163  return (v0 << 8) | v1;
164 }
165 
166 static unsigned int m68k_read_disassembler_32(const m68k_info *info, const uint64_t addr)
167 {
168  const uint32_t v0 = info->code[addr + 0];
169  const uint32_t v1 = info->code[addr + 1];
170  const uint32_t v2 = info->code[addr + 2];
171  const uint32_t v3 = info->code[addr + 3];
172  return (v0 << 24) | (v1 << 16) | (v2 << 8) | v3;
173 }
174 
176 {
177  const uint64_t v0 = info->code[addr + 0];
178  const uint64_t v1 = info->code[addr + 1];
179  const uint64_t v2 = info->code[addr + 2];
180  const uint64_t v3 = info->code[addr + 3];
181  const uint64_t v4 = info->code[addr + 4];
182  const uint64_t v5 = info->code[addr + 5];
183  const uint64_t v6 = info->code[addr + 6];
184  const uint64_t v7 = info->code[addr + 7];
185  return (v0 << 56) | (v1 << 48) | (v2 << 40) | (v3 << 32) | (v4 << 24) | (v5 << 16) | (v6 << 8) | v7;
186 }
187 
188 static unsigned int m68k_read_safe_16(const m68k_info *info, const uint64_t address)
189 {
190  const uint64_t addr = (address - info->baseAddress) & info->address_mask;
191  if (info->code_len < addr + 2) {
192  return 0xaaaa;
193  }
194  return m68k_read_disassembler_16(info, addr);
195 }
196 
197 static unsigned int m68k_read_safe_32(const m68k_info *info, const uint64_t address)
198 {
199  const uint64_t addr = (address - info->baseAddress) & info->address_mask;
200  if (info->code_len < addr + 4) {
201  return 0xaaaaaaaa;
202  }
203  return m68k_read_disassembler_32(info, addr);
204 }
205 
206 static uint64_t m68k_read_safe_64(const m68k_info *info, const uint64_t address)
207 {
208  const uint64_t addr = (address - info->baseAddress) & info->address_mask;
209  if (info->code_len < addr + 8) {
210  return 0xaaaaaaaaaaaaaaaaLL;
211  }
212  return m68k_read_disassembler_64(info, addr);
213 }
214 
215 /* ======================================================================== */
216 /* =============================== PROTOTYPES ============================= */
217 /* ======================================================================== */
218 
219 /* make signed integers 100% portably */
220 static int make_int_8(int value);
221 static int make_int_16(int value);
222 
223 /* Stuff to build the opcode handler jump table */
224 static void build_opcode_table(void);
225 static int valid_ea(uint opcode, uint mask);
226 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr);
227 static void d68000_invalid(m68k_info *info);
228 static int instruction_is_valid(m68k_info *info, const unsigned int word_check);
229 
230 /* used to build opcode handler jump table */
231 typedef struct {
232  void (*opcode_handler)(m68k_info *info); /* handler function */
233  uint mask; /* mask on opcode */
234  uint match; /* what to match after masking */
235  uint ea_mask; /* what ea modes are allowed */
236  uint mask2; /* mask the 2nd word */
237  uint match2; /* what to match after masking */
238 } opcode_struct;
239 
240 typedef struct {
241  void (*instruction)(m68k_info *info); /* handler function */
242  uint word2_mask; /* mask the 2nd word */
243  uint word2_match; /* what to match after masking */
245 
246 /* ======================================================================== */
247 /* ================================= DATA ================================= */
248 /* ======================================================================== */
249 
250 /* Opcode handler jump table */
252 
253 /* used by ops like asr, ror, addq, etc */
254 static uint g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
255 
256 static uint g_5bit_data_table[32] = {
257  32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
258  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
259 };
260 
266 };
267 
268 static m68k_insn s_dbcc_lut[] = {
273 };
274 
275 static m68k_insn s_scc_lut[] = {
280 };
281 
282 static m68k_insn s_trap_lut[] = {
287 };
288 
289 /* ======================================================================== */
290 /* =========================== UTILITY FUNCTIONS ========================== */
291 /* ======================================================================== */
292 
293 #define LIMIT_CPU_TYPES(info, ALLOWED_CPU_TYPES) \
294  do { \
295  if (!(info->type & ALLOWED_CPU_TYPES)) { \
296  d68000_invalid(info); \
297  return; \
298  } \
299  } while (0)
300 
301 static unsigned int peek_imm_8(const m68k_info *info) { return (m68k_read_safe_16((info), (info)->pc)&0xff); }
302 static unsigned int peek_imm_16(const m68k_info *info) { return m68k_read_safe_16((info), (info)->pc); }
303 static unsigned int peek_imm_32(const m68k_info *info) { return m68k_read_safe_32((info), (info)->pc); }
304 static unsigned long long peek_imm_64(const m68k_info *info) { return m68k_read_safe_64((info), (info)->pc); }
305 
306 static unsigned int read_imm_8(m68k_info *info) { const unsigned int value = peek_imm_8(info); (info)->pc+=2; return value; }
307 static unsigned int read_imm_16(m68k_info *info) { const unsigned int value = peek_imm_16(info); (info)->pc+=2; return value; }
308 static unsigned int read_imm_32(m68k_info *info) { const unsigned int value = peek_imm_32(info); (info)->pc+=4; return value; }
309 static unsigned long long read_imm_64(m68k_info *info) { const unsigned long long value = peek_imm_64(info); (info)->pc+=8; return value; }
310 
311 /* Fake a split interface */
312 #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0)
313 #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1)
314 #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2)
315 
316 #define get_imm_str_s8() get_imm_str_s(0)
317 #define get_imm_str_s16() get_imm_str_s(1)
318 #define get_imm_str_s32() get_imm_str_s(2)
319 
320 #define get_imm_str_u8() get_imm_str_u(0)
321 #define get_imm_str_u16() get_imm_str_u(1)
322 #define get_imm_str_u32() get_imm_str_u(2)
323 
324 
325 /* 100% portable signed int generators */
326 static int make_int_8(int value)
327 {
328  return (value & 0x80) ? value | ~0xff : value & 0xff;
329 }
330 
331 static int make_int_16(int value)
332 {
333  return (value & 0x8000) ? value | ~0xffff : value & 0xffff;
334 }
335 
336 static void get_with_index_address_mode(m68k_info *info, cs_m68k_op* op, uint instruction, uint size, bool is_pc)
337 {
338  uint extension = read_imm_16(info);
339 
340  op->address_mode = M68K_AM_AREGI_INDEX_BASE_DISP;
341 
342  if (EXT_FULL(extension)) {
343  uint preindex;
344  uint postindex;
345 
346  op->mem.base_reg = M68K_REG_INVALID;
347  op->mem.index_reg = M68K_REG_INVALID;
348 
349  /* Not sure how to deal with this?
350  if (EXT_EFFECTIVE_ZERO(extension)) {
351  strcpy(mode, "0");
352  break;
353  }
354  */
355 
358 
360  if (is_pc) {
361  op->mem.base_reg = M68K_REG_PC;
362  } else {
363  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
364  }
365  }
366 
368  if (EXT_INDEX_AR(extension)) {
369  op->mem.index_reg = M68K_REG_A0 + EXT_INDEX_REGISTER(extension);
370  } else {
371  op->mem.index_reg = M68K_REG_D0 + EXT_INDEX_REGISTER(extension);
372  }
373 
374  op->mem.index_size = EXT_INDEX_LONG(extension) ? 1 : 0;
375 
376  if (EXT_INDEX_SCALE(extension)) {
377  op->mem.scale = 1 << EXT_INDEX_SCALE(extension);
378  }
379  }
380 
381  preindex = (extension & 7) > 0 && (extension & 7) < 4;
382  postindex = (extension & 7) > 4;
383 
384  if (preindex) {
385  op->address_mode = is_pc ? M68K_AM_PC_MEMI_PRE_INDEX : M68K_AM_MEMI_PRE_INDEX;
386  } else if (postindex) {
387  op->address_mode = is_pc ? M68K_AM_PC_MEMI_POST_INDEX : M68K_AM_MEMI_POST_INDEX;
388  }
389 
390  return;
391  }
392 
394  op->mem.index_size = EXT_INDEX_LONG(extension) ? 1 : 0;
395 
396  if (EXT_8BIT_DISPLACEMENT(extension) == 0) {
397  if (is_pc) {
398  op->mem.base_reg = M68K_REG_PC;
399  op->address_mode = M68K_AM_PCI_INDEX_BASE_DISP;
400  } else {
401  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
402  }
403  } else {
404  if (is_pc) {
405  op->mem.base_reg = M68K_REG_PC;
406  op->address_mode = M68K_AM_PCI_INDEX_8_BIT_DISP;
407  } else {
408  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
409  op->address_mode = M68K_AM_AREGI_INDEX_8_BIT_DISP;
410  }
411 
412  op->mem.disp = (int8_t)(extension & 0xff);
413  }
414 
415  if (EXT_INDEX_SCALE(extension)) {
416  op->mem.scale = 1 << EXT_INDEX_SCALE(extension);
417  }
418 }
419 
420 /* Make string of effective address mode */
421 static void get_ea_mode_op(m68k_info *info, cs_m68k_op* op, uint instruction, uint size)
422 {
423  // default to memory
424 
425  op->type = M68K_OP_MEM;
426 
427  switch (instruction & 0x3f) {
428  case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
429  /* data register direct */
430  op->address_mode = M68K_AM_REG_DIRECT_DATA;
431  op->reg = M68K_REG_D0 + (instruction & 7);
432  op->type = M68K_OP_REG;
433  break;
434 
435  case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
436  /* address register direct */
437  op->address_mode = M68K_AM_REG_DIRECT_ADDR;
438  op->reg = M68K_REG_A0 + (instruction & 7);
439  op->type = M68K_OP_REG;
440  break;
441 
442  case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
443  /* address register indirect */
444  op->address_mode = M68K_AM_REGI_ADDR;
445  op->reg = M68K_REG_A0 + (instruction & 7);
446  break;
447 
448  case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
449  /* address register indirect with postincrement */
450  op->address_mode = M68K_AM_REGI_ADDR_POST_INC;
451  op->reg = M68K_REG_A0 + (instruction & 7);
452  break;
453 
454  case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
455  /* address register indirect with predecrement */
456  op->address_mode = M68K_AM_REGI_ADDR_PRE_DEC;
457  op->reg = M68K_REG_A0 + (instruction & 7);
458  break;
459 
460  case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
461  /* address register indirect with displacement*/
462  op->address_mode = M68K_AM_REGI_ADDR_DISP;
463  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
464  op->mem.disp = (int16_t)read_imm_16(info);
465  break;
466 
467  case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
468  /* address register indirect with index */
469  get_with_index_address_mode(info, op, instruction, size, false);
470  break;
471 
472  case 0x38:
473  /* absolute short address */
474  op->address_mode = M68K_AM_ABSOLUTE_DATA_SHORT;
475  op->imm = read_imm_16(info);
476  break;
477 
478  case 0x39:
479  /* absolute long address */
480  op->address_mode = M68K_AM_ABSOLUTE_DATA_LONG;
481  op->imm = read_imm_32(info);
482  break;
483 
484  case 0x3a:
485  /* program counter with displacement */
486  op->address_mode = M68K_AM_PCI_DISP;
487  op->mem.disp = (int16_t)read_imm_16(info);
488  break;
489 
490  case 0x3b:
491  /* program counter with index */
492  get_with_index_address_mode(info, op, instruction, size, true);
493  break;
494 
495  case 0x3c:
496  op->address_mode = M68K_AM_IMMEDIATE;
497  op->type = M68K_OP_IMM;
498 
499  if (size == 1)
500  op->imm = read_imm_8(info) & 0xff;
501  else if (size == 2)
502  op->imm = read_imm_16(info) & 0xffff;
503  else if (size == 4)
504  op->imm = read_imm_32(info);
505  else
506  op->imm = read_imm_64(info);
507 
508  break;
509 
510  default:
511  break;
512  }
513 }
514 
516 {
517  info->groups[info->groups_count++] = (uint8_t)group;
518 }
519 
520 static cs_m68k* build_init_op(m68k_info *info, int opcode, int count, int size)
521 {
522  cs_m68k* ext;
523 
524  MCInst_setOpcode(info->inst, opcode);
525 
526  ext = &info->extension;
527 
529  ext->op_size.type = M68K_SIZE_TYPE_CPU;
530  ext->op_size.cpu_size = size;
531 
532  return ext;
533 }
534 
535 static void build_re_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
536 {
537  cs_m68k_op* op0;
538  cs_m68k_op* op1;
539  cs_m68k* ext = build_init_op(info, opcode, 2, size);
540 
541  op0 = &ext->operands[0];
542  op1 = &ext->operands[1];
543 
544  if (isDreg) {
546  op0->reg = M68K_REG_D0 + ((info->ir >> 9 ) & 7);
547  } else {
549  op0->reg = M68K_REG_A0 + ((info->ir >> 9 ) & 7);
550  }
551 
552  get_ea_mode_op(info, op1, info->ir, size);
553 }
554 
555 static void build_re_1(m68k_info *info, int opcode, uint8_t size)
556 {
557  build_re_gen_1(info, true, opcode, size);
558 }
559 
560 static void build_er_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
561 {
562  cs_m68k_op* op0;
563  cs_m68k_op* op1;
564  cs_m68k* ext = build_init_op(info, opcode, 2, size);
565 
566  op0 = &ext->operands[0];
567  op1 = &ext->operands[1];
568 
569  get_ea_mode_op(info, op0, info->ir, size);
570 
571  if (isDreg) {
573  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
574  } else {
576  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
577  }
578 }
579 
580 static void build_rr(m68k_info *info, int opcode, uint8_t size, int imm)
581 {
582  cs_m68k_op* op0;
583  cs_m68k_op* op1;
584  cs_m68k_op* op2;
585  cs_m68k* ext = build_init_op(info, opcode, 2, size);
586 
587  op0 = &ext->operands[0];
588  op1 = &ext->operands[1];
589  op2 = &ext->operands[2];
590 
592  op0->reg = M68K_REG_D0 + (info->ir & 7);
593 
595  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
596 
597  if (imm > 0) {
598  ext->op_count = 3;
599  op2->type = M68K_OP_IMM;
601  op2->imm = imm;
602  }
603 }
604 
605 static void build_r(m68k_info *info, int opcode, uint8_t size)
606 {
607  cs_m68k_op* op0;
608  cs_m68k_op* op1;
609  cs_m68k* ext = build_init_op(info, opcode, 2, size);
610 
611  op0 = &ext->operands[0];
612  op1 = &ext->operands[1];
613 
615  op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
616 
618  op1->reg = M68K_REG_D0 + (info->ir & 7);
619 }
620 
621 static void build_imm_ea(m68k_info *info, int opcode, uint8_t size, int imm)
622 {
623  cs_m68k_op* op0;
624  cs_m68k_op* op1;
625  cs_m68k* ext = build_init_op(info, opcode, 2, size);
626 
627  op0 = &ext->operands[0];
628  op1 = &ext->operands[1];
629 
630  op0->type = M68K_OP_IMM;
632  op0->imm = imm;
633 
634  get_ea_mode_op(info, op1, info->ir, size);
635 }
636 
637 static void build_3bit_d(m68k_info *info, int opcode, int size)
638 {
639  cs_m68k_op* op0;
640  cs_m68k_op* op1;
641  cs_m68k* ext = build_init_op(info, opcode, 2, size);
642 
643  op0 = &ext->operands[0];
644  op1 = &ext->operands[1];
645 
646  op0->type = M68K_OP_IMM;
648  op0->imm = g_3bit_qdata_table[(info->ir >> 9) & 7];
649 
651  op1->reg = M68K_REG_D0 + (info->ir & 7);
652 }
653 
654 static void build_3bit_ea(m68k_info *info, int opcode, int size)
655 {
656  cs_m68k_op* op0;
657  cs_m68k_op* op1;
658  cs_m68k* ext = build_init_op(info, opcode, 2, size);
659 
660  op0 = &ext->operands[0];
661  op1 = &ext->operands[1];
662 
663  op0->type = M68K_OP_IMM;
665  op0->imm = g_3bit_qdata_table[(info->ir >> 9) & 7];
666 
667  get_ea_mode_op(info, op1, info->ir, size);
668 }
669 
670 static void build_mm(m68k_info *info, int opcode, uint8_t size, int imm)
671 {
672  cs_m68k_op* op0;
673  cs_m68k_op* op1;
674  cs_m68k_op* op2;
675  cs_m68k* ext = build_init_op(info, opcode, 2, size);
676 
677  op0 = &ext->operands[0];
678  op1 = &ext->operands[1];
679  op2 = &ext->operands[2];
680 
682  op0->reg = M68K_REG_A0 + (info->ir & 7);
683 
685  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
686 
687  if (imm > 0) {
688  ext->op_count = 3;
689  op2->type = M68K_OP_IMM;
691  op2->imm = imm;
692  }
693 }
694 
695 static void build_ea(m68k_info *info, int opcode, uint8_t size)
696 {
697  cs_m68k* ext = build_init_op(info, opcode, 1, size);
698  get_ea_mode_op(info, &ext->operands[0], info->ir, size);
699 }
700 
701 static void build_ea_a(m68k_info *info, int opcode, uint8_t size)
702 {
703  cs_m68k_op* op0;
704  cs_m68k_op* op1;
705  cs_m68k* ext = build_init_op(info, opcode, 2, size);
706 
707  op0 = &ext->operands[0];
708  op1 = &ext->operands[1];
709 
710  get_ea_mode_op(info, op0, info->ir, size);
711 
713  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
714 }
715 
716 static void build_ea_ea(m68k_info *info, int opcode, int size)
717 {
718  cs_m68k_op* op0;
719  cs_m68k_op* op1;
720  cs_m68k* ext = build_init_op(info, opcode, 2, size);
721 
722  op0 = &ext->operands[0];
723  op1 = &ext->operands[1];
724 
725  get_ea_mode_op(info, op0, info->ir, size);
726  get_ea_mode_op(info, op1, (((info->ir>>9) & 7) | ((info->ir>>3) & 0x38)), size);
727 }
728 
729 static void build_pi_pi(m68k_info *info, int opcode, int size)
730 {
731  cs_m68k_op* op0;
732  cs_m68k_op* op1;
733  cs_m68k* ext = build_init_op(info, opcode, 2, size);
734 
735  op0 = &ext->operands[0];
736  op1 = &ext->operands[1];
737 
739  op0->reg = M68K_REG_A0 + (info->ir & 7);
740 
742  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
743 }
744 
745 static void build_imm_special_reg(m68k_info *info, int opcode, int imm, int size, m68k_reg reg)
746 {
747  cs_m68k_op* op0;
748  cs_m68k_op* op1;
749  cs_m68k* ext = build_init_op(info, opcode, 2, size);
750 
751  op0 = &ext->operands[0];
752  op1 = &ext->operands[1];
753 
754  op0->type = M68K_OP_IMM;
756  op0->imm = imm;
757 
758  op1->address_mode = M68K_AM_NONE;
759  op1->reg = reg;
760 }
761 
762 static void build_relative_branch(m68k_info *info, int opcode, int size, int displacement)
763 {
764  cs_m68k_op* op;
765  cs_m68k* ext = build_init_op(info, opcode, 1, size);
766 
767  op = &ext->operands[0];
768 
769  op->type = M68K_OP_BR_DISP;
770  op->address_mode = M68K_AM_BRANCH_DISPLACEMENT;
771  op->br_disp.disp = displacement;
772  op->br_disp.disp_size = size;
773 
776 }
777 
778 static void build_absolute_jump_with_immediate(m68k_info *info, int opcode, int size, int immediate)
779 {
780  cs_m68k_op* op;
781  cs_m68k* ext = build_init_op(info, opcode, 1, size);
782 
783  op = &ext->operands[0];
784 
785  op->type = M68K_OP_IMM;
786  op->address_mode = M68K_AM_IMMEDIATE;
787  op->imm = immediate;
788 
790 }
791 
792 static void build_bcc(m68k_info *info, int size, int displacement)
793 {
794  build_relative_branch(info, s_branch_lut[(info->ir >> 8) & 0xf], size, displacement);
795 }
796 
797 static void build_trap(m68k_info *info, int size, int immediate)
798 {
799  build_absolute_jump_with_immediate(info, s_trap_lut[(info->ir >> 8) & 0xf], size, immediate);
800 }
801 
802 static void build_dbxx(m68k_info *info, int opcode, int size, int displacement)
803 {
804  cs_m68k_op* op0;
805  cs_m68k_op* op1;
806  cs_m68k* ext = build_init_op(info, opcode, 2, size);
807 
808  op0 = &ext->operands[0];
809  op1 = &ext->operands[1];
810 
812  op0->reg = M68K_REG_D0 + (info->ir & 7);
813 
814  op1->type = M68K_OP_BR_DISP;
816  op1->br_disp.disp = displacement;
818 
821 }
822 
823 static void build_dbcc(m68k_info *info, int size, int displacement)
824 {
825  build_dbxx(info, s_dbcc_lut[(info->ir >> 8) & 0xf], size, displacement);
826 }
827 
828 static void build_d_d_ea(m68k_info *info, int opcode, int size)
829 {
830  cs_m68k_op* op0;
831  cs_m68k_op* op1;
832  cs_m68k_op* op2;
833  uint extension = read_imm_16(info);
834  cs_m68k* ext = build_init_op(info, opcode, 3, size);
835 
836  op0 = &ext->operands[0];
837  op1 = &ext->operands[1];
838  op2 = &ext->operands[2];
839 
841  op0->reg = M68K_REG_D0 + (extension & 7);
842 
844  op1->reg = M68K_REG_D0 + ((extension >> 6) & 7);
845 
846  get_ea_mode_op(info, op2, info->ir, size);
847 }
848 
849 static void build_bitfield_ins(m68k_info *info, int opcode, int has_d_arg)
850 {
851  uint8_t offset;
852  uint8_t width;
853  cs_m68k_op* op_ea;
854  cs_m68k_op* op1;
855  cs_m68k* ext = build_init_op(info, opcode, 1, 0);
856  uint extension = read_imm_16(info);
857 
858  op_ea = &ext->operands[0];
859  op1 = &ext->operands[1];
860 
861  if (BIT_B(extension))
862  offset = (extension >> 6) & 7;
863  else
864  offset = (extension >> 6) & 31;
865 
866  if (BIT_5(extension))
867  width = extension & 7;
868  else
870 
871  if (has_d_arg) {
872  ext->op_count = 2;
874  op1->reg = M68K_REG_D0 + ((extension >> 12) & 7);
875  }
876 
877  get_ea_mode_op(info, op_ea, info->ir, 1);
878 
879  op_ea->mem.bitfield = 1;
880  op_ea->mem.width = width;
881  op_ea->mem.offset = offset;
882 }
883 
884 static void build_d(m68k_info *info, int opcode, int size)
885 {
886  cs_m68k* ext = build_init_op(info, opcode, 1, size);
887  cs_m68k_op* op;
888 
889  op = &ext->operands[0];
890 
891  op->address_mode = M68K_AM_REG_DIRECT_DATA;
892  op->reg = M68K_REG_D0 + (info->ir & 7);
893 }
894 
896 {
897  uint r = v; // r will be reversed bits of v; first get LSB of v
898  uint s = 16 - 1; // extra shift needed at end
899 
900  for (v >>= 1; v; v >>= 1) {
901  r <<= 1;
902  r |= v & 1;
903  s--;
904  }
905 
906  return r <<= s; // shift when v's highest bits are zero
907 }
908 
910 {
911  uint r = v; // r will be reversed bits of v; first get LSB of v
912  uint s = 8 - 1; // extra shift needed at end
913 
914  for (v >>= 1; v; v >>= 1) {
915  r <<= 1;
916  r |= v & 1;
917  s--;
918  }
919 
920  return r <<= s; // shift when v's highest bits are zero
921 }
922 
923 
924 static void build_movem_re(m68k_info *info, int opcode, int size)
925 {
926  cs_m68k_op* op0;
927  cs_m68k_op* op1;
928  cs_m68k* ext = build_init_op(info, opcode, 2, size);
929 
930  op0 = &ext->operands[0];
931  op1 = &ext->operands[1];
932 
933  op0->type = M68K_OP_REG_BITS;
934  op0->register_bits = read_imm_16(info);
935 
936  get_ea_mode_op(info, op1, info->ir, size);
937 
940 }
941 
942 static void build_movem_er(m68k_info *info, int opcode, int size)
943 {
944  cs_m68k_op* op0;
945  cs_m68k_op* op1;
946  cs_m68k* ext = build_init_op(info, opcode, 2, size);
947 
948  op0 = &ext->operands[0];
949  op1 = &ext->operands[1];
950 
951  op1->type = M68K_OP_REG_BITS;
952  op1->register_bits = read_imm_16(info);
953 
954  get_ea_mode_op(info, op0, info->ir, size);
955 }
956 
957 static void build_imm(m68k_info *info, int opcode, int data)
958 {
959  cs_m68k_op* op;
960  cs_m68k* ext = build_init_op(info, opcode, 1, 0);
961 
962  MCInst_setOpcode(info->inst, opcode);
963 
964  op = &ext->operands[0];
965 
966  op->type = M68K_OP_IMM;
967  op->address_mode = M68K_AM_IMMEDIATE;
968  op->imm = data;
969 }
970 
971 static void build_illegal(m68k_info *info, int data)
972 {
974 }
975 
976 static void build_invalid(m68k_info *info, int data)
977 {
979 }
980 
981 static void build_cas2(m68k_info *info, int size)
982 {
983  uint word3;
984  uint extension;
985  cs_m68k_op* op0;
986  cs_m68k_op* op1;
987  cs_m68k_op* op2;
989  int reg_0, reg_1;
990 
991  /* cas2 is the only 3 words instruction, word2 and word3 have the same motif bits to check */
992  word3 = peek_imm_32(info) & 0xffff;
993  if (!instruction_is_valid(info, word3))
994  return;
995 
996  op0 = &ext->operands[0];
997  op1 = &ext->operands[1];
998  op2 = &ext->operands[2];
999 
1000  extension = read_imm_32(info);
1001 
1002  op0->address_mode = M68K_AM_NONE;
1003  op0->type = M68K_OP_REG_PAIR;
1004  op0->reg_pair.reg_0 = (extension >> 16) & 7;
1005  op0->reg_pair.reg_1 = extension & 7;
1006 
1007  op1->address_mode = M68K_AM_NONE;
1008  op1->type = M68K_OP_REG_PAIR;
1009  op1->reg_pair.reg_0 = (extension >> 22) & 7;
1010  op1->reg_pair.reg_1 = (extension >> 6) & 7;
1011 
1012  reg_0 = (extension >> 28) & 7;
1013  reg_1 = (extension >> 12) & 7;
1014 
1015  op2->address_mode = M68K_AM_NONE;
1016  op2->type = M68K_OP_REG_PAIR;
1017  op2->reg_pair.reg_0 = reg_0 + (BIT_1F(extension) ? 8 : 0);
1018  op2->reg_pair.reg_1 = reg_1 + (BIT_F(extension) ? 8 : 0);
1019 }
1020 
1021 static void build_chk2_cmp2(m68k_info *info, int size)
1022 {
1023  cs_m68k_op* op0;
1024  cs_m68k_op* op1;
1025  cs_m68k* ext = build_init_op(info, M68K_INS_CHK2, 2, size);
1026 
1027  uint extension = read_imm_16(info);
1028 
1029  if (BIT_B(extension))
1031  else
1033 
1034  op0 = &ext->operands[0];
1035  op1 = &ext->operands[1];
1036 
1037  get_ea_mode_op(info, op0, info->ir, size);
1038 
1039  op1->address_mode = M68K_AM_NONE;
1040  op1->type = M68K_OP_REG;
1041  op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
1042 }
1043 
1044 static void build_move16(m68k_info *info, int data[2], int modes[2])
1045 {
1046  cs_m68k* ext = build_init_op(info, M68K_INS_MOVE16, 2, 0);
1047  int i;
1048 
1049  for (i = 0; i < 2; ++i) {
1050  cs_m68k_op* op = &ext->operands[i];
1051  const int d = data[i];
1052  const int m = modes[i];
1053 
1054  op->type = M68K_OP_MEM;
1055 
1057  op->address_mode = m;
1058  op->reg = M68K_REG_A0 + d;
1059  } else {
1060  op->address_mode = m;
1061  op->imm = d;
1062  }
1063  }
1064 }
1065 
1066 static void build_link(m68k_info *info, int disp, int size)
1067 {
1068  cs_m68k_op* op0;
1069  cs_m68k_op* op1;
1070  cs_m68k* ext = build_init_op(info, M68K_INS_LINK, 2, size);
1071 
1072  op0 = &ext->operands[0];
1073  op1 = &ext->operands[1];
1074 
1075  op0->address_mode = M68K_AM_NONE;
1076  op0->reg = M68K_REG_A0 + (info->ir & 7);
1077 
1079  op1->type = M68K_OP_IMM;
1080  op1->imm = disp;
1081 }
1082 
1083 static void build_cpush_cinv(m68k_info *info, int op_offset)
1084 {
1085  cs_m68k_op* op0;
1086  cs_m68k_op* op1;
1087  cs_m68k* ext = build_init_op(info, M68K_INS_INVALID, 2, 0);
1088 
1089  switch ((info->ir >> 3) & 3) { // scope
1090  // Invalid
1091  case 0:
1092  d68000_invalid(info);
1093  return;
1094  // Line
1095  case 1:
1096  MCInst_setOpcode(info->inst, op_offset + 0);
1097  break;
1098  // Page
1099  case 2:
1100  MCInst_setOpcode(info->inst, op_offset + 1);
1101  break;
1102  // All
1103  case 3:
1104  ext->op_count = 1;
1105  MCInst_setOpcode(info->inst, op_offset + 2);
1106  break;
1107  }
1108 
1109  op0 = &ext->operands[0];
1110  op1 = &ext->operands[1];
1111 
1113  op0->type = M68K_OP_IMM;
1114  op0->imm = (info->ir >> 6) & 3;
1115 
1116  op1->type = M68K_OP_MEM;
1118  op1->imm = M68K_REG_A0 + (info->ir & 7);
1119 }
1120 
1121 static void build_movep_re(m68k_info *info, int size)
1122 {
1123  cs_m68k_op* op0;
1124  cs_m68k_op* op1;
1126 
1127  op0 = &ext->operands[0];
1128  op1 = &ext->operands[1];
1129 
1130  op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
1131 
1133  op1->type = M68K_OP_MEM;
1134  op1->mem.base_reg = M68K_REG_A0 + (info->ir & 7);
1135  op1->mem.disp = (int16_t)read_imm_16(info);
1136 }
1137 
1138 static void build_movep_er(m68k_info *info, int size)
1139 {
1140  cs_m68k_op* op0;
1141  cs_m68k_op* op1;
1143 
1144  op0 = &ext->operands[0];
1145  op1 = &ext->operands[1];
1146 
1148  op0->type = M68K_OP_MEM;
1149  op0->mem.base_reg = M68K_REG_A0 + (info->ir & 7);
1150  op0->mem.disp = (int16_t)read_imm_16(info);
1151 
1152  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
1153 }
1154 
1155 static void build_moves(m68k_info *info, int size)
1156 {
1157  cs_m68k_op* op0;
1158  cs_m68k_op* op1;
1160  uint extension = read_imm_16(info);
1161 
1162  op0 = &ext->operands[0];
1163  op1 = &ext->operands[1];
1164 
1165  if (BIT_B(extension)) {
1166  op0->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
1167  get_ea_mode_op(info, op1, info->ir, size);
1168  } else {
1169  get_ea_mode_op(info, op0, info->ir, size);
1170  op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
1171  }
1172 }
1173 
1174 static void build_er_1(m68k_info *info, int opcode, uint8_t size)
1175 {
1176  build_er_gen_1(info, true, opcode, size);
1177 }
1178 
1179 /* ======================================================================== */
1180 /* ========================= INSTRUCTION HANDLERS ========================= */
1181 /* ======================================================================== */
1182 /* Instruction handler function names follow this convention:
1183  *
1184  * d68000_NAME_EXTENSIONS(void)
1185  * where NAME is the name of the opcode it handles and EXTENSIONS are any
1186  * extensions for special instances of that opcode.
1187  *
1188  * Examples:
1189  * d68000_add_er_8(): add opcode, from effective address to register,
1190  * size = byte
1191  *
1192  * d68000_asr_s_8(): arithmetic shift right, static count, size = byte
1193  *
1194  *
1195  * Common extensions:
1196  * 8 : size = byte
1197  * 16 : size = word
1198  * 32 : size = long
1199  * rr : register to register
1200  * mm : memory to memory
1201  * r : register
1202  * s : static
1203  * er : effective address -> register
1204  * re : register -> effective address
1205  * ea : using effective address mode of operation
1206  * d : data register direct
1207  * a : address register direct
1208  * ai : address register indirect
1209  * pi : address register indirect with postincrement
1210  * pd : address register indirect with predecrement
1211  * di : address register indirect with displacement
1212  * ix : address register indirect with index
1213  * aw : absolute word
1214  * al : absolute long
1215  */
1216 
1217 
1218 static void d68000_invalid(m68k_info *info)
1219 {
1220  build_invalid(info, info->ir);
1221 }
1222 
1223 static void d68000_illegal(m68k_info *info)
1224 {
1225  build_illegal(info, info->ir);
1226 }
1227 
1228 static void d68000_1010(m68k_info *info)
1229 {
1230  build_invalid(info, info->ir);
1231 }
1232 
1233 static void d68000_1111(m68k_info *info)
1234 {
1235  build_invalid(info, info->ir);
1236 }
1237 
1238 static void d68000_abcd_rr(m68k_info *info)
1239 {
1240  build_rr(info, M68K_INS_ABCD, 1, 0);
1241 }
1242 
1243 static void d68000_abcd_mm(m68k_info *info)
1244 {
1245  build_mm(info, M68K_INS_ABCD, 1, 0);
1246 }
1247 
1248 static void d68000_add_er_8(m68k_info *info)
1249 {
1250  build_er_1(info, M68K_INS_ADD, 1);
1251 }
1252 
1253 static void d68000_add_er_16(m68k_info *info)
1254 {
1255  build_er_1(info, M68K_INS_ADD, 2);
1256 }
1257 
1258 static void d68000_add_er_32(m68k_info *info)
1259 {
1260  build_er_1(info, M68K_INS_ADD, 4);
1261 }
1262 
1263 static void d68000_add_re_8(m68k_info *info)
1264 {
1265  build_re_1(info, M68K_INS_ADD, 1);
1266 }
1267 
1268 static void d68000_add_re_16(m68k_info *info)
1269 {
1270  build_re_1(info, M68K_INS_ADD, 2);
1271 }
1272 
1273 static void d68000_add_re_32(m68k_info *info)
1274 {
1275  build_re_1(info, M68K_INS_ADD, 4);
1276 }
1277 
1278 static void d68000_adda_16(m68k_info *info)
1279 {
1280  build_ea_a(info, M68K_INS_ADDA, 2);
1281 }
1282 
1283 static void d68000_adda_32(m68k_info *info)
1284 {
1285  build_ea_a(info, M68K_INS_ADDA, 4);
1286 }
1287 
1288 static void d68000_addi_8(m68k_info *info)
1289 {
1290  build_imm_ea(info, M68K_INS_ADDI, 1, read_imm_8(info));
1291 }
1292 
1293 static void d68000_addi_16(m68k_info *info)
1294 {
1295  build_imm_ea(info, M68K_INS_ADDI, 2, read_imm_16(info));
1296 }
1297 
1298 static void d68000_addi_32(m68k_info *info)
1299 {
1300  build_imm_ea(info, M68K_INS_ADDI, 4, read_imm_32(info));
1301 }
1302 
1303 static void d68000_addq_8(m68k_info *info)
1304 {
1305  build_3bit_ea(info, M68K_INS_ADDQ, 1);
1306 }
1307 
1308 static void d68000_addq_16(m68k_info *info)
1309 {
1310  build_3bit_ea(info, M68K_INS_ADDQ, 2);
1311 }
1312 
1313 static void d68000_addq_32(m68k_info *info)
1314 {
1315  build_3bit_ea(info, M68K_INS_ADDQ, 4);
1316 }
1317 
1318 static void d68000_addx_rr_8(m68k_info *info)
1319 {
1320  build_rr(info, M68K_INS_ADDX, 1, 0);
1321 }
1322 
1323 static void d68000_addx_rr_16(m68k_info *info)
1324 {
1325  build_rr(info, M68K_INS_ADDX, 2, 0);
1326 }
1327 
1328 static void d68000_addx_rr_32(m68k_info *info)
1329 {
1330  build_rr(info, M68K_INS_ADDX, 4, 0);
1331 }
1332 
1333 static void d68000_addx_mm_8(m68k_info *info)
1334 {
1335  build_mm(info, M68K_INS_ADDX, 1, 0);
1336 }
1337 
1338 static void d68000_addx_mm_16(m68k_info *info)
1339 {
1340  build_mm(info, M68K_INS_ADDX, 2, 0);
1341 }
1342 
1343 static void d68000_addx_mm_32(m68k_info *info)
1344 {
1345  build_mm(info, M68K_INS_ADDX, 4, 0);
1346 }
1347 
1348 static void d68000_and_er_8(m68k_info *info)
1349 {
1350  build_er_1(info, M68K_INS_AND, 1);
1351 }
1352 
1353 static void d68000_and_er_16(m68k_info *info)
1354 {
1355  build_er_1(info, M68K_INS_AND, 2);
1356 }
1357 
1358 static void d68000_and_er_32(m68k_info *info)
1359 {
1360  build_er_1(info, M68K_INS_AND, 4);
1361 }
1362 
1363 static void d68000_and_re_8(m68k_info *info)
1364 {
1365  build_re_1(info, M68K_INS_AND, 1);
1366 }
1367 
1368 static void d68000_and_re_16(m68k_info *info)
1369 {
1370  build_re_1(info, M68K_INS_AND, 2);
1371 }
1372 
1373 static void d68000_and_re_32(m68k_info *info)
1374 {
1375  build_re_1(info, M68K_INS_AND, 4);
1376 }
1377 
1378 static void d68000_andi_8(m68k_info *info)
1379 {
1380  build_imm_ea(info, M68K_INS_ANDI, 1, read_imm_8(info));
1381 }
1382 
1383 static void d68000_andi_16(m68k_info *info)
1384 {
1385  build_imm_ea(info, M68K_INS_ANDI, 2, read_imm_16(info));
1386 }
1387 
1388 static void d68000_andi_32(m68k_info *info)
1389 {
1390  build_imm_ea(info, M68K_INS_ANDI, 4, read_imm_32(info));
1391 }
1392 
1393 static void d68000_andi_to_ccr(m68k_info *info)
1394 {
1396 }
1397 
1398 static void d68000_andi_to_sr(m68k_info *info)
1399 {
1401 }
1402 
1403 static void d68000_asr_s_8(m68k_info *info)
1404 {
1405  build_3bit_d(info, M68K_INS_ASR, 1);
1406 }
1407 
1408 static void d68000_asr_s_16(m68k_info *info)
1409 {
1410  build_3bit_d(info, M68K_INS_ASR, 2);
1411 }
1412 
1413 static void d68000_asr_s_32(m68k_info *info)
1414 {
1415  build_3bit_d(info, M68K_INS_ASR, 4);
1416 }
1417 
1418 static void d68000_asr_r_8(m68k_info *info)
1419 {
1420  build_r(info, M68K_INS_ASR, 1);
1421 }
1422 
1423 static void d68000_asr_r_16(m68k_info *info)
1424 {
1425  build_r(info, M68K_INS_ASR, 2);
1426 }
1427 
1428 static void d68000_asr_r_32(m68k_info *info)
1429 {
1430  build_r(info, M68K_INS_ASR, 4);
1431 }
1432 
1433 static void d68000_asr_ea(m68k_info *info)
1434 {
1435  build_ea(info, M68K_INS_ASR, 2);
1436 }
1437 
1438 static void d68000_asl_s_8(m68k_info *info)
1439 {
1440  build_3bit_d(info, M68K_INS_ASL, 1);
1441 }
1442 
1443 static void d68000_asl_s_16(m68k_info *info)
1444 {
1445  build_3bit_d(info, M68K_INS_ASL, 2);
1446 }
1447 
1448 static void d68000_asl_s_32(m68k_info *info)
1449 {
1450  build_3bit_d(info, M68K_INS_ASL, 4);
1451 }
1452 
1453 static void d68000_asl_r_8(m68k_info *info)
1454 {
1455  build_r(info, M68K_INS_ASL, 1);
1456 }
1457 
1458 static void d68000_asl_r_16(m68k_info *info)
1459 {
1460  build_r(info, M68K_INS_ASL, 2);
1461 }
1462 
1463 static void d68000_asl_r_32(m68k_info *info)
1464 {
1465  build_r(info, M68K_INS_ASL, 4);
1466 }
1467 
1468 static void d68000_asl_ea(m68k_info *info)
1469 {
1470  build_ea(info, M68K_INS_ASL, 2);
1471 }
1472 
1473 static void d68000_bcc_8(m68k_info *info)
1474 {
1475  build_bcc(info, 1, make_int_8(info->ir));
1476 }
1477 
1478 static void d68000_bcc_16(m68k_info *info)
1479 {
1480  build_bcc(info, 2, make_int_16(read_imm_16(info)));
1481 }
1482 
1483 static void d68020_bcc_32(m68k_info *info)
1484 {
1486  build_bcc(info, 4, read_imm_32(info));
1487 }
1488 
1489 static void d68000_bchg_r(m68k_info *info)
1490 {
1491  build_re_1(info, M68K_INS_BCHG, 1);
1492 }
1493 
1494 static void d68000_bchg_s(m68k_info *info)
1495 {
1496  build_imm_ea(info, M68K_INS_BCHG, 1, read_imm_8(info));
1497 }
1498 
1499 static void d68000_bclr_r(m68k_info *info)
1500 {
1501  build_re_1(info, M68K_INS_BCLR, 1);
1502 }
1503 
1504 static void d68000_bclr_s(m68k_info *info)
1505 {
1506  build_imm_ea(info, M68K_INS_BCLR, 1, read_imm_8(info));
1507 }
1508 
1509 static void d68010_bkpt(m68k_info *info)
1510 {
1513 }
1514 
1515 static void d68020_bfchg(m68k_info *info)
1516 {
1518  build_bitfield_ins(info, M68K_INS_BFCHG, false);
1519 }
1520 
1521 
1522 static void d68020_bfclr(m68k_info *info)
1523 {
1525  build_bitfield_ins(info, M68K_INS_BFCLR, false);
1526 }
1527 
1528 static void d68020_bfexts(m68k_info *info)
1529 {
1531  build_bitfield_ins(info, M68K_INS_BFEXTS, true);
1532 }
1533 
1534 static void d68020_bfextu(m68k_info *info)
1535 {
1537  build_bitfield_ins(info, M68K_INS_BFEXTU, true);
1538 }
1539 
1540 static void d68020_bfffo(m68k_info *info)
1541 {
1543  build_bitfield_ins(info, M68K_INS_BFFFO, true);
1544 }
1545 
1546 static void d68020_bfins(m68k_info *info)
1547 {
1548  cs_m68k* ext = &info->extension;
1549  cs_m68k_op temp;
1550 
1552  build_bitfield_ins(info, M68K_INS_BFINS, true);
1553 
1554  // a bit hacky but we need to flip the args on only this instruction
1555 
1556  temp = ext->operands[0];
1557  ext->operands[0] = ext->operands[1];
1558  ext->operands[1] = temp;
1559 }
1560 
1561 static void d68020_bfset(m68k_info *info)
1562 {
1564  build_bitfield_ins(info, M68K_INS_BFSET, false);
1565 }
1566 
1567 static void d68020_bftst(m68k_info *info)
1568 {
1569  build_bitfield_ins(info, M68K_INS_BFTST, false);
1570 }
1571 
1572 static void d68000_bra_8(m68k_info *info)
1573 {
1574  build_relative_branch(info, M68K_INS_BRA, 1, make_int_8(info->ir));
1575 }
1576 
1577 static void d68000_bra_16(m68k_info *info)
1578 {
1580 }
1581 
1582 static void d68020_bra_32(m68k_info *info)
1583 {
1586 }
1587 
1588 static void d68000_bset_r(m68k_info *info)
1589 {
1590  build_re_1(info, M68K_INS_BSET, 1);
1591 }
1592 
1593 static void d68000_bset_s(m68k_info *info)
1594 {
1595  build_imm_ea(info, M68K_INS_BSET, 1, read_imm_8(info));
1596 }
1597 
1598 static void d68000_bsr_8(m68k_info *info)
1599 {
1600  build_relative_branch(info, M68K_INS_BSR, 1, make_int_8(info->ir));
1601 }
1602 
1603 static void d68000_bsr_16(m68k_info *info)
1604 {
1606 }
1607 
1608 static void d68020_bsr_32(m68k_info *info)
1609 {
1612 }
1613 
1614 static void d68000_btst_r(m68k_info *info)
1615 {
1616  build_re_1(info, M68K_INS_BTST, 4);
1617 }
1618 
1619 static void d68000_btst_s(m68k_info *info)
1620 {
1621  build_imm_ea(info, M68K_INS_BTST, 1, read_imm_8(info));
1622 }
1623 
1624 static void d68020_callm(m68k_info *info)
1625 {
1627  build_imm_ea(info, M68K_INS_CALLM, 0, read_imm_8(info));
1628 }
1629 
1630 static void d68020_cas_8(m68k_info *info)
1631 {
1633  build_d_d_ea(info, M68K_INS_CAS, 1);
1634 }
1635 
1636 static void d68020_cas_16(m68k_info *info)
1637 {
1639  build_d_d_ea(info, M68K_INS_CAS, 2);
1640 }
1641 
1642 static void d68020_cas_32(m68k_info *info)
1643 {
1645  build_d_d_ea(info, M68K_INS_CAS, 4);
1646 }
1647 
1648 static void d68020_cas2_16(m68k_info *info)
1649 {
1650  build_cas2(info, 2);
1651 }
1652 
1653 static void d68020_cas2_32(m68k_info *info)
1654 {
1655  build_cas2(info, 4);
1656 }
1657 
1658 static void d68000_chk_16(m68k_info *info)
1659 {
1660  build_er_1(info, M68K_INS_CHK, 2);
1661 }
1662 
1663 static void d68020_chk_32(m68k_info *info)
1664 {
1666  build_er_1(info, M68K_INS_CHK, 4);
1667 }
1668 
1669 static void d68020_chk2_cmp2_8(m68k_info *info)
1670 {
1672  build_chk2_cmp2(info, 1);
1673 }
1674 
1675 static void d68020_chk2_cmp2_16(m68k_info *info)
1676 {
1678  build_chk2_cmp2(info, 2);
1679 }
1680 
1681 static void d68020_chk2_cmp2_32(m68k_info *info)
1682 {
1684  build_chk2_cmp2(info, 4);
1685 }
1686 
1687 static void d68040_cinv(m68k_info *info)
1688 {
1691 }
1692 
1693 static void d68000_clr_8(m68k_info *info)
1694 {
1695  build_ea(info, M68K_INS_CLR, 1);
1696 }
1697 
1698 static void d68000_clr_16(m68k_info *info)
1699 {
1700  build_ea(info, M68K_INS_CLR, 2);
1701 }
1702 
1703 static void d68000_clr_32(m68k_info *info)
1704 {
1705  build_ea(info, M68K_INS_CLR, 4);
1706 }
1707 
1708 static void d68000_cmp_8(m68k_info *info)
1709 {
1710  build_er_1(info, M68K_INS_CMP, 1);
1711 }
1712 
1713 static void d68000_cmp_16(m68k_info *info)
1714 {
1715  build_er_1(info, M68K_INS_CMP, 2);
1716 }
1717 
1718 static void d68000_cmp_32(m68k_info *info)
1719 {
1720  build_er_1(info, M68K_INS_CMP, 4);
1721 }
1722 
1723 static void d68000_cmpa_16(m68k_info *info)
1724 {
1725  build_ea_a(info, M68K_INS_CMPA, 2);
1726 }
1727 
1728 static void d68000_cmpa_32(m68k_info *info)
1729 {
1730  build_ea_a(info, M68K_INS_CMPA, 4);
1731 }
1732 
1733 static void d68000_cmpi_8(m68k_info *info)
1734 {
1735  build_imm_ea(info, M68K_INS_CMPI, 1, read_imm_8(info));
1736 }
1737 
1738 static void d68020_cmpi_pcdi_8(m68k_info *info)
1739 {
1741  build_imm_ea(info, M68K_INS_CMPI, 1, read_imm_8(info));
1742 }
1743 
1744 static void d68020_cmpi_pcix_8(m68k_info *info)
1745 {
1747  build_imm_ea(info, M68K_INS_CMPI, 1, read_imm_8(info));
1748 }
1749 
1750 static void d68000_cmpi_16(m68k_info *info)
1751 {
1752  build_imm_ea(info, M68K_INS_CMPI, 2, read_imm_16(info));
1753 }
1754 
1755 static void d68020_cmpi_pcdi_16(m68k_info *info)
1756 {
1758  build_imm_ea(info, M68K_INS_CMPI, 2, read_imm_16(info));
1759 }
1760 
1761 static void d68020_cmpi_pcix_16(m68k_info *info)
1762 {
1764  build_imm_ea(info, M68K_INS_CMPI, 2, read_imm_16(info));
1765 }
1766 
1767 static void d68000_cmpi_32(m68k_info *info)
1768 {
1769  build_imm_ea(info, M68K_INS_CMPI, 4, read_imm_32(info));
1770 }
1771 
1772 static void d68020_cmpi_pcdi_32(m68k_info *info)
1773 {
1775  build_imm_ea(info, M68K_INS_CMPI, 4, read_imm_32(info));
1776 }
1777 
1778 static void d68020_cmpi_pcix_32(m68k_info *info)
1779 {
1781  build_imm_ea(info, M68K_INS_CMPI, 4, read_imm_32(info));
1782 }
1783 
1784 static void d68000_cmpm_8(m68k_info *info)
1785 {
1786  build_pi_pi(info, M68K_INS_CMPM, 1);
1787 }
1788 
1789 static void d68000_cmpm_16(m68k_info *info)
1790 {
1791  build_pi_pi(info, M68K_INS_CMPM, 2);
1792 }
1793 
1794 static void d68000_cmpm_32(m68k_info *info)
1795 {
1796  build_pi_pi(info, M68K_INS_CMPM, 4);
1797 }
1798 
1799 static void make_cpbcc_operand(cs_m68k_op* op, int size, int displacement)
1800 {
1801  op->address_mode = M68K_AM_BRANCH_DISPLACEMENT;
1802  op->type = M68K_OP_BR_DISP;
1803  op->br_disp.disp = displacement;
1804  op->br_disp.disp_size = size;
1805 }
1806 
1807 static void d68020_cpbcc_16(m68k_info *info)
1808 {
1809  cs_m68k_op* op0;
1810  cs_m68k* ext;
1812 
1813  // these are all in row with the extension so just doing a add here is fine
1814  info->inst->Opcode += (info->ir & 0x2f);
1815 
1816  ext = build_init_op(info, M68K_INS_FBF, 1, 2);
1817  op0 = &ext->operands[0];
1818 
1820 
1823 }
1824 
1825 static void d68020_cpbcc_32(m68k_info *info)
1826 {
1827  cs_m68k* ext;
1828  cs_m68k_op* op0;
1829 
1831 
1833 
1834  // these are all in row with the extension so just doing a add here is fine
1835  info->inst->Opcode += (info->ir & 0x2f);
1836 
1837  ext = build_init_op(info, M68K_INS_FBF, 1, 4);
1838  op0 = &ext->operands[0];
1839 
1841 
1844 }
1845 
1846 static void d68020_cpdbcc(m68k_info *info)
1847 {
1848  cs_m68k* ext;
1849  cs_m68k_op* op0;
1850  cs_m68k_op* op1;
1851  uint ext1, ext2;
1852 
1854 
1855  ext1 = read_imm_16(info);
1856  ext2 = read_imm_16(info);
1857 
1858  // these are all in row with the extension so just doing a add here is fine
1859  info->inst->Opcode += (ext1 & 0x2f);
1860 
1861  ext = build_init_op(info, M68K_INS_FDBF, 2, 0);
1862  op0 = &ext->operands[0];
1863  op1 = &ext->operands[1];
1864 
1865  op0->reg = M68K_REG_D0 + (info->ir & 7);
1866 
1868 
1871 }
1872 
1873 static void fmove_fpcr(m68k_info *info, uint extension)
1874 {
1875  cs_m68k_op* special;
1876  cs_m68k_op* op_ea;
1877 
1878  int regsel = (extension >> 10) & 0x7;
1879  int dir = (extension >> 13) & 0x1;
1880 
1881  cs_m68k* ext = build_init_op(info, M68K_INS_FMOVE, 2, 4);
1882 
1883  special = &ext->operands[0];
1884  op_ea = &ext->operands[1];
1885 
1886  if (!dir) {
1887  cs_m68k_op* t = special;
1888  special = op_ea;
1889  op_ea = t;
1890  }
1891 
1892  get_ea_mode_op(info, op_ea, info->ir, 4);
1893 
1894  if (regsel & 4)
1895  special->reg = M68K_REG_FPCR;
1896  else if (regsel & 2)
1897  special->reg = M68K_REG_FPSR;
1898  else if (regsel & 1)
1899  special->reg = M68K_REG_FPIAR;
1900 }
1901 
1902 static void fmovem(m68k_info *info, uint extension)
1903 {
1904  cs_m68k_op* op_reglist;
1905  cs_m68k_op* op_ea;
1906  int dir = (extension >> 13) & 0x1;
1907  int mode = (extension >> 11) & 0x3;
1908  uint reglist = extension & 0xff;
1909  cs_m68k* ext = build_init_op(info, M68K_INS_FMOVEM, 2, 0);
1910 
1911  op_reglist = &ext->operands[0];
1912  op_ea = &ext->operands[1];
1913 
1914  // flip args around
1915 
1916  if (!dir) {
1917  cs_m68k_op* t = op_reglist;
1918  op_reglist = op_ea;
1919  op_ea = t;
1920  }
1921 
1922  get_ea_mode_op(info, op_ea, info->ir, 0);
1923 
1924  switch (mode) {
1925  case 1 : // Dynamic list in dn register
1926  op_reglist->reg = M68K_REG_D0 + ((reglist >> 4) & 7);
1927  break;
1928 
1929  case 0 :
1930  op_reglist->address_mode = M68K_AM_NONE;
1931  op_reglist->type = M68K_OP_REG_BITS;
1932  op_reglist->register_bits = reglist << 16;
1933  break;
1934 
1935  case 2 : // Static list
1936  op_reglist->address_mode = M68K_AM_NONE;
1937  op_reglist->type = M68K_OP_REG_BITS;
1938  op_reglist->register_bits = ((uint32_t)reverse_bits_8(reglist)) << 16;
1939  break;
1940  }
1941 }
1942 
1943 static void d68020_cpgen(m68k_info *info)
1944 {
1945  cs_m68k *ext;
1946  cs_m68k_op* op0;
1947  cs_m68k_op* op1;
1948  bool supports_single_op;
1949  uint next;
1950  int rm, src, dst, opmode;
1951 
1952 
1954 
1955  supports_single_op = true;
1956 
1957  next = read_imm_16(info);
1958 
1959  rm = (next >> 14) & 0x1;
1960  src = (next >> 10) & 0x7;
1961  dst = (next >> 7) & 0x7;
1962  opmode = next & 0x3f;
1963 
1964  // special handling for fmovecr
1965 
1966  if (BITFIELD(info->ir, 5, 0) == 0 && BITFIELD(next, 15, 10) == 0x17) {
1967  cs_m68k_op* op0;
1968  cs_m68k_op* op1;
1969  cs_m68k* ext = build_init_op(info, M68K_INS_FMOVECR, 2, 0);
1970 
1971  op0 = &ext->operands[0];
1972  op1 = &ext->operands[1];
1973 
1975  op0->type = M68K_OP_IMM;
1976  op0->imm = next & 0x3f;
1977 
1978  op1->reg = M68K_REG_FP0 + ((next >> 7) & 7);
1979 
1980  return;
1981  }
1982 
1983  // deal with extended move stuff
1984 
1985  switch ((next >> 13) & 0x7) {
1986  // fmovem fpcr
1987  case 0x4: // FMOVEM ea, FPCR
1988  case 0x5: // FMOVEM FPCR, ea
1989  fmove_fpcr(info, next);
1990  return;
1991 
1992  // fmovem list
1993  case 0x6:
1994  case 0x7:
1995  fmovem(info, next);
1996  return;
1997  }
1998 
1999  // See comment bellow on why this is being done
2000 
2001  if ((next >> 6) & 1)
2002  opmode &= ~4;
2003 
2004  // special handling of some instructions here
2005 
2006  switch (opmode) {
2007  case 0x00: MCInst_setOpcode(info->inst, M68K_INS_FMOVE); supports_single_op = false; break;
2008  case 0x01: MCInst_setOpcode(info->inst, M68K_INS_FINT); break;
2009  case 0x02: MCInst_setOpcode(info->inst, M68K_INS_FSINH); break;
2010  case 0x03: MCInst_setOpcode(info->inst, M68K_INS_FINTRZ); break;
2011  case 0x04: MCInst_setOpcode(info->inst, M68K_INS_FSQRT); break;
2012  case 0x06: MCInst_setOpcode(info->inst, M68K_INS_FLOGNP1); break;
2013  case 0x08: MCInst_setOpcode(info->inst, M68K_INS_FETOXM1); break;
2014  case 0x09: MCInst_setOpcode(info->inst, M68K_INS_FATANH); break;
2015  case 0x0a: MCInst_setOpcode(info->inst, M68K_INS_FATAN); break;
2016  case 0x0c: MCInst_setOpcode(info->inst, M68K_INS_FASIN); break;
2017  case 0x0d: MCInst_setOpcode(info->inst, M68K_INS_FATANH); break;
2018  case 0x0e: MCInst_setOpcode(info->inst, M68K_INS_FSIN); break;
2019  case 0x0f: MCInst_setOpcode(info->inst, M68K_INS_FTAN); break;
2020  case 0x10: MCInst_setOpcode(info->inst, M68K_INS_FETOX); break;
2021  case 0x11: MCInst_setOpcode(info->inst, M68K_INS_FTWOTOX); break;
2022  case 0x12: MCInst_setOpcode(info->inst, M68K_INS_FTENTOX); break;
2023  case 0x14: MCInst_setOpcode(info->inst, M68K_INS_FLOGN); break;
2024  case 0x15: MCInst_setOpcode(info->inst, M68K_INS_FLOG10); break;
2025  case 0x16: MCInst_setOpcode(info->inst, M68K_INS_FLOG2); break;
2026  case 0x18: MCInst_setOpcode(info->inst, M68K_INS_FABS); break;
2027  case 0x19: MCInst_setOpcode(info->inst, M68K_INS_FCOSH); break;
2028  case 0x1a: MCInst_setOpcode(info->inst, M68K_INS_FNEG); break;
2029  case 0x1c: MCInst_setOpcode(info->inst, M68K_INS_FACOS); break;
2030  case 0x1d: MCInst_setOpcode(info->inst, M68K_INS_FCOS); break;
2031  case 0x1e: MCInst_setOpcode(info->inst, M68K_INS_FGETEXP); break;
2032  case 0x1f: MCInst_setOpcode(info->inst, M68K_INS_FGETMAN); break;
2033  case 0x20: MCInst_setOpcode(info->inst, M68K_INS_FDIV); supports_single_op = false; break;
2034  case 0x21: MCInst_setOpcode(info->inst, M68K_INS_FMOD); supports_single_op = false; break;
2035  case 0x22: MCInst_setOpcode(info->inst, M68K_INS_FADD); supports_single_op = false; break;
2036  case 0x23: MCInst_setOpcode(info->inst, M68K_INS_FMUL); supports_single_op = false; break;
2037  case 0x24: MCInst_setOpcode(info->inst, M68K_INS_FSGLDIV); supports_single_op = false; break;
2038  case 0x25: MCInst_setOpcode(info->inst, M68K_INS_FREM); break;
2039  case 0x26: MCInst_setOpcode(info->inst, M68K_INS_FSCALE); break;
2040  case 0x27: MCInst_setOpcode(info->inst, M68K_INS_FSGLMUL); break;
2041  case 0x28: MCInst_setOpcode(info->inst, M68K_INS_FSUB); supports_single_op = false; break;
2042  case 0x38: MCInst_setOpcode(info->inst, M68K_INS_FCMP); supports_single_op = false; break;
2043  case 0x3a: MCInst_setOpcode(info->inst, M68K_INS_FTST); break;
2044  default:
2045  break;
2046  }
2047 
2048  // Some trickery here! It's not documented but if bit 6 is set this is a s/d opcode and then
2049  // if bit 2 is set it's a d. As we already have set our opcode in the code above we can just
2050  // offset it as the following 2 op codes (if s/d is supported) will always be directly after it
2051 
2052  if ((next >> 6) & 1) {
2053  if ((next >> 2) & 1)
2054  info->inst->Opcode += 2;
2055  else
2056  info->inst->Opcode += 1;
2057  }
2058 
2059  ext = &info->extension;
2060 
2061  ext->op_count = 2;
2062  ext->op_size.type = M68K_SIZE_TYPE_CPU;
2063  ext->op_size.cpu_size = 0;
2064 
2065  op0 = &ext->operands[0];
2066  op1 = &ext->operands[1];
2067 
2068  if (rm == 0 && supports_single_op && src == dst) {
2069  ext->op_count = 1;
2070  op0->reg = M68K_REG_FP0 + dst;
2071  return;
2072  }
2073 
2074  if (rm == 1) {
2075  switch (src) {
2076  case 0x00 :
2077  ext->op_size.cpu_size = M68K_CPU_SIZE_LONG;
2078  get_ea_mode_op(info, op0, info->ir, 4);
2079  break;
2080 
2081  case 0x06 :
2082  ext->op_size.cpu_size = M68K_CPU_SIZE_BYTE;
2083  get_ea_mode_op(info, op0, info->ir, 1);
2084  break;
2085 
2086  case 0x04 :
2087  ext->op_size.cpu_size = M68K_CPU_SIZE_WORD;
2088  get_ea_mode_op(info, op0, info->ir, 2);
2089  break;
2090 
2091  case 0x01 :
2092  ext->op_size.type = M68K_SIZE_TYPE_FPU;
2093  ext->op_size.fpu_size = M68K_FPU_SIZE_SINGLE;
2094  get_ea_mode_op(info, op0, info->ir, 4);
2095  op0->type = M68K_OP_FP_SINGLE;
2096  break;
2097 
2098  case 0x05:
2099  ext->op_size.type = M68K_SIZE_TYPE_FPU;
2100  ext->op_size.fpu_size = M68K_FPU_SIZE_DOUBLE;
2101  get_ea_mode_op(info, op0, info->ir, 8);
2102  op0->type = M68K_OP_FP_DOUBLE;
2103  break;
2104 
2105  default :
2106  ext->op_size.type = M68K_SIZE_TYPE_FPU;
2107  ext->op_size.fpu_size = M68K_FPU_SIZE_EXTENDED;
2108  break;
2109  }
2110  } else {
2111  op0->reg = M68K_REG_FP0 + src;
2112  }
2113 
2114  op1->reg = M68K_REG_FP0 + dst;
2115 }
2116 
2117 static void d68020_cprestore(m68k_info *info)
2118 {
2119  cs_m68k* ext;
2121 
2122  ext = build_init_op(info, M68K_INS_FRESTORE, 1, 0);
2123  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
2124 }
2125 
2126 static void d68020_cpsave(m68k_info *info)
2127 {
2128  cs_m68k* ext;
2129 
2131 
2132  ext = build_init_op(info, M68K_INS_FSAVE, 1, 0);
2133  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
2134 }
2135 
2136 static void d68020_cpscc(m68k_info *info)
2137 {
2138  cs_m68k* ext;
2139 
2141  ext = build_init_op(info, M68K_INS_FSF, 1, 1);
2142 
2143  // these are all in row with the extension so just doing a add here is fine
2144  info->inst->Opcode += (read_imm_16(info) & 0x2f);
2145 
2146  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
2147 }
2148 
2149 static void d68020_cptrapcc_0(m68k_info *info)
2150 {
2151  uint extension1;
2153 
2154  extension1 = read_imm_16(info);
2155 
2156  build_init_op(info, M68K_INS_FTRAPF, 0, 0);
2157 
2158  // these are all in row with the extension so just doing a add here is fine
2159  info->inst->Opcode += (extension1 & 0x2f);
2160 }
2161 
2162 static void d68020_cptrapcc_16(m68k_info *info)
2163 {
2164  uint extension1, extension2;
2165  cs_m68k_op* op0;
2166  cs_m68k* ext;
2167 
2169 
2170  extension1 = read_imm_16(info);
2171  extension2 = read_imm_16(info);
2172 
2173  ext = build_init_op(info, M68K_INS_FTRAPF, 1, 2);
2174 
2175  // these are all in row with the extension so just doing a add here is fine
2176  info->inst->Opcode += (extension1 & 0x2f);
2177 
2178  op0 = &ext->operands[0];
2179 
2181  op0->type = M68K_OP_IMM;
2182  op0->imm = extension2;
2183 }
2184 
2185 static void d68020_cptrapcc_32(m68k_info *info)
2186 {
2187  uint extension1, extension2;
2188  cs_m68k* ext;
2189  cs_m68k_op* op0;
2190 
2192 
2193  extension1 = read_imm_16(info);
2194  extension2 = read_imm_32(info);
2195 
2196  ext = build_init_op(info, M68K_INS_FTRAPF, 1, 2);
2197 
2198  // these are all in row with the extension so just doing a add here is fine
2199  info->inst->Opcode += (extension1 & 0x2f);
2200 
2201  op0 = &ext->operands[0];
2202 
2204  op0->type = M68K_OP_IMM;
2205  op0->imm = extension2;
2206 }
2207 
2208 static void d68040_cpush(m68k_info *info)
2209 {
2212 }
2213 
2214 static void d68000_dbra(m68k_info *info)
2215 {
2216  build_dbxx(info, M68K_INS_DBRA, 0, make_int_16(read_imm_16(info)));
2217 }
2218 
2219 static void d68000_dbcc(m68k_info *info)
2220 {
2221  build_dbcc(info, 0, make_int_16(read_imm_16(info)));
2222 }
2223 
2224 static void d68000_divs(m68k_info *info)
2225 {
2226  build_er_1(info, M68K_INS_DIVS, 2);
2227 }
2228 
2229 static void d68000_divu(m68k_info *info)
2230 {
2231  build_er_1(info, M68K_INS_DIVU, 2);
2232 }
2233 
2234 static void d68020_divl(m68k_info *info)
2235 {
2236  uint extension, insn_signed;
2237  cs_m68k* ext;
2238  cs_m68k_op* op0;
2239  cs_m68k_op* op1;
2240  uint reg_0, reg_1;
2241 
2243 
2244  extension = read_imm_16(info);
2245  insn_signed = 0;
2246 
2247  if (BIT_B((extension)))
2248  insn_signed = 1;
2249 
2250  ext = build_init_op(info, insn_signed ? M68K_INS_DIVS : M68K_INS_DIVU, 2, 4);
2251 
2252  op0 = &ext->operands[0];
2253  op1 = &ext->operands[1];
2254 
2255  get_ea_mode_op(info, op0, info->ir, 4);
2256 
2257  reg_0 = extension & 7;
2258  reg_1 = (extension >> 12) & 7;
2259 
2260  op1->address_mode = M68K_AM_NONE;
2261  op1->type = M68K_OP_REG_PAIR;
2262  op1->reg_pair.reg_0 = reg_0;
2263  op1->reg_pair.reg_1 = reg_1;
2264 
2265  if ((reg_0 == reg_1) || !BIT_A(extension)) {
2266  op1->type = M68K_OP_REG;
2267  op1->reg = M68K_REG_D0 + reg_1;
2268  }
2269 }
2270 
2271 static void d68000_eor_8(m68k_info *info)
2272 {
2273  build_re_1(info, M68K_INS_EOR, 1);
2274 }
2275 
2276 static void d68000_eor_16(m68k_info *info)
2277 {
2278  build_re_1(info, M68K_INS_EOR, 2);
2279 }
2280 
2281 static void d68000_eor_32(m68k_info *info)
2282 {
2283  build_re_1(info, M68K_INS_EOR, 4);
2284 }
2285 
2286 static void d68000_eori_8(m68k_info *info)
2287 {
2288  build_imm_ea(info, M68K_INS_EORI, 1, read_imm_8(info));
2289 }
2290 
2291 static void d68000_eori_16(m68k_info *info)
2292 {
2293  build_imm_ea(info, M68K_INS_EORI, 2, read_imm_16(info));
2294 }
2295 
2296 static void d68000_eori_32(m68k_info *info)
2297 {
2298  build_imm_ea(info, M68K_INS_EORI, 4, read_imm_32(info));
2299 }
2300 
2301 static void d68000_eori_to_ccr(m68k_info *info)
2302 {
2304 }
2305 
2306 static void d68000_eori_to_sr(m68k_info *info)
2307 {
2309 }
2310 
2311 static void d68000_exg_dd(m68k_info *info)
2312 {
2313  build_r(info, M68K_INS_EXG, 4);
2314 }
2315 
2316 static void d68000_exg_aa(m68k_info *info)
2317 {
2318  cs_m68k_op* op0;
2319  cs_m68k_op* op1;
2320  cs_m68k* ext = build_init_op(info, M68K_INS_EXG, 2, 4);
2321 
2322  op0 = &ext->operands[0];
2323  op1 = &ext->operands[1];
2324 
2325  op0->address_mode = M68K_AM_NONE;
2326  op0->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
2327 
2328  op1->address_mode = M68K_AM_NONE;
2329  op1->reg = M68K_REG_A0 + (info->ir & 7);
2330 }
2331 
2332 static void d68000_exg_da(m68k_info *info)
2333 {
2334  cs_m68k_op* op0;
2335  cs_m68k_op* op1;
2336  cs_m68k* ext = build_init_op(info, M68K_INS_EXG, 2, 4);
2337 
2338  op0 = &ext->operands[0];
2339  op1 = &ext->operands[1];
2340 
2341  op0->address_mode = M68K_AM_NONE;
2342  op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
2343 
2344  op1->address_mode = M68K_AM_NONE;
2345  op1->reg = M68K_REG_A0 + (info->ir & 7);
2346 }
2347 
2348 static void d68000_ext_16(m68k_info *info)
2349 {
2350  build_d(info, M68K_INS_EXT, 2);
2351 }
2352 
2353 static void d68000_ext_32(m68k_info *info)
2354 {
2355  build_d(info, M68K_INS_EXT, 4);
2356 }
2357 
2358 static void d68020_extb_32(m68k_info *info)
2359 {
2361  build_d(info, M68K_INS_EXTB, 4);
2362 }
2363 
2364 static void d68000_jmp(m68k_info *info)
2365 {
2366  cs_m68k* ext = build_init_op(info, M68K_INS_JMP, 1, 0);
2368  get_ea_mode_op(info, &ext->operands[0], info->ir, 4);
2369 }
2370 
2371 static void d68000_jsr(m68k_info *info)
2372 {
2373  cs_m68k* ext = build_init_op(info, M68K_INS_JSR, 1, 0);
2375  get_ea_mode_op(info, &ext->operands[0], info->ir, 4);
2376 }
2377 
2378 static void d68000_lea(m68k_info *info)
2379 {
2380  build_ea_a(info, M68K_INS_LEA, 4);
2381 }
2382 
2383 static void d68000_link_16(m68k_info *info)
2384 {
2385  build_link(info, read_imm_16(info), 2);
2386 }
2387 
2388 static void d68020_link_32(m68k_info *info)
2389 {
2391  build_link(info, read_imm_32(info), 4);
2392 }
2393 
2394 static void d68000_lsr_s_8(m68k_info *info)
2395 {
2396  build_3bit_d(info, M68K_INS_LSR, 1);
2397 }
2398 
2399 static void d68000_lsr_s_16(m68k_info *info)
2400 {
2401  build_3bit_d(info, M68K_INS_LSR, 2);
2402 }
2403 
2404 static void d68000_lsr_s_32(m68k_info *info)
2405 {
2406  build_3bit_d(info, M68K_INS_LSR, 4);
2407 }
2408 
2409 static void d68000_lsr_r_8(m68k_info *info)
2410 {
2411  build_r(info, M68K_INS_LSR, 1);
2412 }
2413 
2414 static void d68000_lsr_r_16(m68k_info *info)
2415 {
2416  build_r(info, M68K_INS_LSR, 2);
2417 }
2418 
2419 static void d68000_lsr_r_32(m68k_info *info)
2420 {
2421  build_r(info, M68K_INS_LSR, 4);
2422 }
2423 
2424 static void d68000_lsr_ea(m68k_info *info)
2425 {
2426  build_ea(info, M68K_INS_LSR, 2);
2427 }
2428 
2429 static void d68000_lsl_s_8(m68k_info *info)
2430 {
2431  build_3bit_d(info, M68K_INS_LSL, 1);
2432 }
2433 
2434 static void d68000_lsl_s_16(m68k_info *info)
2435 {
2436  build_3bit_d(info, M68K_INS_LSL, 2);
2437 }
2438 
2439 static void d68000_lsl_s_32(m68k_info *info)
2440 {
2441  build_3bit_d(info, M68K_INS_LSL, 4);
2442 }
2443 
2444 static void d68000_lsl_r_8(m68k_info *info)
2445 {
2446  build_r(info, M68K_INS_LSL, 1);
2447 }
2448 
2449 static void d68000_lsl_r_16(m68k_info *info)
2450 {
2451  build_r(info, M68K_INS_LSL, 2);
2452 }
2453 
2454 static void d68000_lsl_r_32(m68k_info *info)
2455 {
2456  build_r(info, M68K_INS_LSL, 4);
2457 }
2458 
2459 static void d68000_lsl_ea(m68k_info *info)
2460 {
2461  build_ea(info, M68K_INS_LSL, 2);
2462 }
2463 
2464 static void d68000_move_8(m68k_info *info)
2465 {
2466  build_ea_ea(info, M68K_INS_MOVE, 1);
2467 }
2468 
2469 static void d68000_move_16(m68k_info *info)
2470 {
2471  build_ea_ea(info, M68K_INS_MOVE, 2);
2472 }
2473 
2474 static void d68000_move_32(m68k_info *info)
2475 {
2476  build_ea_ea(info, M68K_INS_MOVE, 4);
2477 }
2478 
2479 static void d68000_movea_16(m68k_info *info)
2480 {
2481  build_ea_a(info, M68K_INS_MOVEA, 2);
2482 }
2483 
2484 static void d68000_movea_32(m68k_info *info)
2485 {
2486  build_ea_a(info, M68K_INS_MOVEA, 4);
2487 }
2488 
2489 static void d68000_move_to_ccr(m68k_info *info)
2490 {
2491  cs_m68k_op* op0;
2492  cs_m68k_op* op1;
2493  cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 2);
2494 
2495  op0 = &ext->operands[0];
2496  op1 = &ext->operands[1];
2497 
2498  get_ea_mode_op(info, op0, info->ir, 1);
2499 
2500  op1->address_mode = M68K_AM_NONE;
2501  op1->reg = M68K_REG_CCR;
2502 }
2503 
2504 static void d68010_move_fr_ccr(m68k_info *info)
2505 {
2506  cs_m68k_op* op0;
2507  cs_m68k_op* op1;
2508  cs_m68k* ext;
2509 
2511 
2512  ext = build_init_op(info, M68K_INS_MOVE, 2, 2);
2513 
2514  op0 = &ext->operands[0];
2515  op1 = &ext->operands[1];
2516 
2517  op0->address_mode = M68K_AM_NONE;
2518  op0->reg = M68K_REG_CCR;
2519 
2520  get_ea_mode_op(info, op1, info->ir, 1);
2521 }
2522 
2523 static void d68000_move_fr_sr(m68k_info *info)
2524 {
2525  cs_m68k_op* op0;
2526  cs_m68k_op* op1;
2527  cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 2);
2528 
2529  op0 = &ext->operands[0];
2530  op1 = &ext->operands[1];
2531 
2532  op0->address_mode = M68K_AM_NONE;
2533  op0->reg = M68K_REG_SR;
2534 
2535  get_ea_mode_op(info, op1, info->ir, 2);
2536 }
2537 
2538 static void d68000_move_to_sr(m68k_info *info)
2539 {
2540  cs_m68k_op* op0;
2541  cs_m68k_op* op1;
2542  cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 2);
2543 
2544  op0 = &ext->operands[0];
2545  op1 = &ext->operands[1];
2546 
2547  get_ea_mode_op(info, op0, info->ir, 2);
2548 
2549  op1->address_mode = M68K_AM_NONE;
2550  op1->reg = M68K_REG_SR;
2551 }
2552 
2553 static void d68000_move_fr_usp(m68k_info *info)
2554 {
2555  cs_m68k_op* op0;
2556  cs_m68k_op* op1;
2557  cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 0);
2558 
2559  op0 = &ext->operands[0];
2560  op1 = &ext->operands[1];
2561 
2562  op0->address_mode = M68K_AM_NONE;
2563  op0->reg = M68K_REG_USP;
2564 
2565  op1->address_mode = M68K_AM_NONE;
2566  op1->reg = M68K_REG_A0 + (info->ir & 7);
2567 }
2568 
2569 static void d68000_move_to_usp(m68k_info *info)
2570 {
2571  cs_m68k_op* op0;
2572  cs_m68k_op* op1;
2573  cs_m68k* ext = build_init_op(info, M68K_INS_MOVE, 2, 0);
2574 
2575  op0 = &ext->operands[0];
2576  op1 = &ext->operands[1];
2577 
2578  op0->address_mode = M68K_AM_NONE;
2579  op0->reg = M68K_REG_A0 + (info->ir & 7);
2580 
2581  op1->address_mode = M68K_AM_NONE;
2582  op1->reg = M68K_REG_USP;
2583 }
2584 
2585 static void d68010_movec(m68k_info *info)
2586 {
2587  uint extension;
2588  m68k_reg reg;
2589  cs_m68k* ext;
2590  cs_m68k_op* op0;
2591  cs_m68k_op* op1;
2592 
2593 
2595 
2596  extension = read_imm_16(info);
2597  reg = M68K_REG_INVALID;
2598 
2599  ext = build_init_op(info, M68K_INS_MOVEC, 2, 0);
2600 
2601  op0 = &ext->operands[0];
2602  op1 = &ext->operands[1];
2603 
2604  switch (extension & 0xfff) {
2605  case 0x000: reg = M68K_REG_SFC; break;
2606  case 0x001: reg = M68K_REG_DFC; break;
2607  case 0x800: reg = M68K_REG_USP; break;
2608  case 0x801: reg = M68K_REG_VBR; break;
2609  case 0x002: reg = M68K_REG_CACR; break;
2610  case 0x802: reg = M68K_REG_CAAR; break;
2611  case 0x803: reg = M68K_REG_MSP; break;
2612  case 0x804: reg = M68K_REG_ISP; break;
2613  case 0x003: reg = M68K_REG_TC; break;
2614  case 0x004: reg = M68K_REG_ITT0; break;
2615  case 0x005: reg = M68K_REG_ITT1; break;
2616  case 0x006: reg = M68K_REG_DTT0; break;
2617  case 0x007: reg = M68K_REG_DTT1; break;
2618  case 0x805: reg = M68K_REG_MMUSR; break;
2619  case 0x806: reg = M68K_REG_URP; break;
2620  case 0x807: reg = M68K_REG_SRP; break;
2621  }
2622 
2623  if (BIT_1(info->ir)) {
2624  op0->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
2625  op1->reg = reg;
2626  } else {
2627  op0->reg = reg;
2628  op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
2629  }
2630 }
2631 
2632 static void d68000_movem_pd_16(m68k_info *info)
2633 {
2634  build_movem_re(info, M68K_INS_MOVEM, 2);
2635 }
2636 
2637 static void d68000_movem_pd_32(m68k_info *info)
2638 {
2639  build_movem_re(info, M68K_INS_MOVEM, 4);
2640 }
2641 
2642 static void d68000_movem_er_16(m68k_info *info)
2643 {
2644  build_movem_er(info, M68K_INS_MOVEM, 2);
2645 }
2646 
2647 static void d68000_movem_er_32(m68k_info *info)
2648 {
2649  build_movem_er(info, M68K_INS_MOVEM, 4);
2650 }
2651 
2652 static void d68000_movem_re_16(m68k_info *info)
2653 {
2654  build_movem_re(info, M68K_INS_MOVEM, 2);
2655 }
2656 
2657 static void d68000_movem_re_32(m68k_info *info)
2658 {
2659  build_movem_re(info, M68K_INS_MOVEM, 4);
2660 }
2661 
2662 static void d68000_movep_re_16(m68k_info *info)
2663 {
2664  build_movep_re(info, 2);
2665 }
2666 
2667 static void d68000_movep_re_32(m68k_info *info)
2668 {
2669  build_movep_re(info, 4);
2670 }
2671 
2672 static void d68000_movep_er_16(m68k_info *info)
2673 {
2674  build_movep_er(info, 2);
2675 }
2676 
2677 static void d68000_movep_er_32(m68k_info *info)
2678 {
2679  build_movep_er(info, 4);
2680 }
2681 
2682 static void d68010_moves_8(m68k_info *info)
2683 {
2685  build_moves(info, 1);
2686 }
2687 
2688 static void d68010_moves_16(m68k_info *info)
2689 {
2690  //uint extension;
2692  build_moves(info, 2);
2693 }
2694 
2695 static void d68010_moves_32(m68k_info *info)
2696 {
2698  build_moves(info, 4);
2699 }
2700 
2701 static void d68000_moveq(m68k_info *info)
2702 {
2703  cs_m68k_op* op0;
2704  cs_m68k_op* op1;
2705 
2706  cs_m68k* ext = build_init_op(info, M68K_INS_MOVEQ, 2, 0);
2707 
2708  op0 = &ext->operands[0];
2709  op1 = &ext->operands[1];
2710 
2711  op0->type = M68K_OP_IMM;
2713  op0->imm = (info->ir & 0xff);
2714 
2716  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
2717 }
2718 
2719 static void d68040_move16_pi_pi(m68k_info *info)
2720 {
2721  int data[] = { info->ir & 7, (read_imm_16(info) >> 12) & 7 };
2723 
2725 
2726  build_move16(info, data, modes);
2727 }
2728 
2729 static void d68040_move16_pi_al(m68k_info *info)
2730 {
2731  int data[] = { info->ir & 7, read_imm_32(info) };
2733 
2735 
2736  build_move16(info, data, modes);
2737 }
2738 
2739 static void d68040_move16_al_pi(m68k_info *info)
2740 {
2741  int data[] = { read_imm_32(info), info->ir & 7 };
2743 
2745 
2746  build_move16(info, data, modes);
2747 }
2748 
2749 static void d68040_move16_ai_al(m68k_info *info)
2750 {
2751  int data[] = { info->ir & 7, read_imm_32(info) };
2753 
2755 
2756  build_move16(info, data, modes);
2757 }
2758 
2759 static void d68040_move16_al_ai(m68k_info *info)
2760 {
2761  int data[] = { read_imm_32(info), info->ir & 7 };
2763 
2765 
2766  build_move16(info, data, modes);
2767 }
2768 
2769 static void d68000_muls(m68k_info *info)
2770 {
2771  build_er_1(info, M68K_INS_MULS, 2);
2772 }
2773 
2774 static void d68000_mulu(m68k_info *info)
2775 {
2776  build_er_1(info, M68K_INS_MULU, 2);
2777 }
2778 
2779 static void d68020_mull(m68k_info *info)
2780 {
2781  uint extension, insn_signed;
2782  cs_m68k* ext;
2783  cs_m68k_op* op0;
2784  cs_m68k_op* op1;
2785  uint reg_0, reg_1;
2786 
2787 
2789 
2790  extension = read_imm_16(info);
2791  insn_signed = 0;
2792 
2793  if (BIT_B((extension)))
2794  insn_signed = 1;
2795 
2796  ext = build_init_op(info, insn_signed ? M68K_INS_MULS : M68K_INS_MULU, 2, 4);
2797 
2798  op0 = &ext->operands[0];
2799  op1 = &ext->operands[1];
2800 
2801  get_ea_mode_op(info, op0, info->ir, 4);
2802 
2803  reg_0 = extension & 7;
2804  reg_1 = (extension >> 12) & 7;
2805 
2806  op1->address_mode = M68K_AM_NONE;
2807  op1->type = M68K_OP_REG_PAIR;
2808  op1->reg_pair.reg_0 = reg_0;
2809  op1->reg_pair.reg_1 = reg_1;
2810 
2811  if (!BIT_A(extension)) {
2812  op1->type = M68K_OP_REG;
2813  op1->reg = M68K_REG_D0 + reg_1;
2814  }
2815 }
2816 
2817 static void d68000_nbcd(m68k_info *info)
2818 {
2819  build_ea(info, M68K_INS_NBCD, 1);
2820 }
2821 
2822 static void d68000_neg_8(m68k_info *info)
2823 {
2824  build_ea(info, M68K_INS_NEG, 1);
2825 }
2826 
2827 static void d68000_neg_16(m68k_info *info)
2828 {
2829  build_ea(info, M68K_INS_NEG, 2);
2830 }
2831 
2832 static void d68000_neg_32(m68k_info *info)
2833 {
2834  build_ea(info, M68K_INS_NEG, 4);
2835 }
2836 
2837 static void d68000_negx_8(m68k_info *info)
2838 {
2839  build_ea(info, M68K_INS_NEGX, 1);
2840 }
2841 
2842 static void d68000_negx_16(m68k_info *info)
2843 {
2844  build_ea(info, M68K_INS_NEGX, 2);
2845 }
2846 
2847 static void d68000_negx_32(m68k_info *info)
2848 {
2849  build_ea(info, M68K_INS_NEGX, 4);
2850 }
2851 
2852 static void d68000_nop(m68k_info *info)
2853 {
2855 }
2856 
2857 static void d68000_not_8(m68k_info *info)
2858 {
2859  build_ea(info, M68K_INS_NOT, 1);
2860 }
2861 
2862 static void d68000_not_16(m68k_info *info)
2863 {
2864  build_ea(info, M68K_INS_NOT, 2);
2865 }
2866 
2867 static void d68000_not_32(m68k_info *info)
2868 {
2869  build_ea(info, M68K_INS_NOT, 4);
2870 }
2871 
2872 static void d68000_or_er_8(m68k_info *info)
2873 {
2874  build_er_1(info, M68K_INS_OR, 1);
2875 }
2876 
2877 static void d68000_or_er_16(m68k_info *info)
2878 {
2879  build_er_1(info, M68K_INS_OR, 2);
2880 }
2881 
2882 static void d68000_or_er_32(m68k_info *info)
2883 {
2884  build_er_1(info, M68K_INS_OR, 4);
2885 }
2886 
2887 static void d68000_or_re_8(m68k_info *info)
2888 {
2889  build_re_1(info, M68K_INS_OR, 1);
2890 }
2891 
2892 static void d68000_or_re_16(m68k_info *info)
2893 {
2894  build_re_1(info, M68K_INS_OR, 2);
2895 }
2896 
2897 static void d68000_or_re_32(m68k_info *info)
2898 {
2899  build_re_1(info, M68K_INS_OR, 4);
2900 }
2901 
2902 static void d68000_ori_8(m68k_info *info)
2903 {
2904  build_imm_ea(info, M68K_INS_ORI, 1, read_imm_8(info));
2905 }
2906 
2907 static void d68000_ori_16(m68k_info *info)
2908 {
2909  build_imm_ea(info, M68K_INS_ORI, 2, read_imm_16(info));
2910 }
2911 
2912 static void d68000_ori_32(m68k_info *info)
2913 {
2914  build_imm_ea(info, M68K_INS_ORI, 4, read_imm_32(info));
2915 }
2916 
2917 static void d68000_ori_to_ccr(m68k_info *info)
2918 {
2920 }
2921 
2922 static void d68000_ori_to_sr(m68k_info *info)
2923 {
2925 }
2926 
2927 static void d68020_pack_rr(m68k_info *info)
2928 {
2930  build_rr(info, M68K_INS_PACK, 0, read_imm_16(info));
2931 }
2932 
2933 static void d68020_pack_mm(m68k_info *info)
2934 {
2936  build_mm(info, M68K_INS_PACK, 0, read_imm_16(info));
2937 }
2938 
2939 static void d68000_pea(m68k_info *info)
2940 {
2941  build_ea(info, M68K_INS_PEA, 4);
2942 }
2943 
2944 static void d68000_reset(m68k_info *info)
2945 {
2947 }
2948 
2949 static void d68000_ror_s_8(m68k_info *info)
2950 {
2951  build_3bit_d(info, M68K_INS_ROR, 1);
2952 }
2953 
2954 static void d68000_ror_s_16(m68k_info *info)
2955 {
2956  build_3bit_d(info, M68K_INS_ROR, 2);
2957 }
2958 
2959 static void d68000_ror_s_32(m68k_info *info)
2960 {
2961  build_3bit_d(info, M68K_INS_ROR, 4);
2962 }
2963 
2964 static void d68000_ror_r_8(m68k_info *info)
2965 {
2966  build_r(info, M68K_INS_ROR, 1);
2967 }
2968 
2969 static void d68000_ror_r_16(m68k_info *info)
2970 {
2971  build_r(info, M68K_INS_ROR, 2);
2972 }
2973 
2974 static void d68000_ror_r_32(m68k_info *info)
2975 {
2976  build_r(info, M68K_INS_ROR, 4);
2977 }
2978 
2979 static void d68000_ror_ea(m68k_info *info)
2980 {
2981  build_ea(info, M68K_INS_ROR, 2);
2982 }
2983 
2984 static void d68000_rol_s_8(m68k_info *info)
2985 {
2986  build_3bit_d(info, M68K_INS_ROL, 1);
2987 }
2988 
2989 static void d68000_rol_s_16(m68k_info *info)
2990 {
2991  build_3bit_d(info, M68K_INS_ROL, 2);
2992 }
2993 
2994 static void d68000_rol_s_32(m68k_info *info)
2995 {
2996  build_3bit_d(info, M68K_INS_ROL, 4);
2997 }
2998 
2999 static void d68000_rol_r_8(m68k_info *info)
3000 {
3001  build_r(info, M68K_INS_ROL, 1);
3002 }
3003 
3004 static void d68000_rol_r_16(m68k_info *info)
3005 {
3006  build_r(info, M68K_INS_ROL, 2);
3007 }
3008 
3009 static void d68000_rol_r_32(m68k_info *info)
3010 {
3011  build_r(info, M68K_INS_ROL, 4);
3012 }
3013 
3014 static void d68000_rol_ea(m68k_info *info)
3015 {
3016  build_ea(info, M68K_INS_ROL, 2);
3017 }
3018 
3019 static void d68000_roxr_s_8(m68k_info *info)
3020 {
3021  build_3bit_d(info, M68K_INS_ROXR, 1);
3022 }
3023 
3024 static void d68000_roxr_s_16(m68k_info *info)
3025 {
3026  build_3bit_d(info, M68K_INS_ROXR, 2);
3027 }
3028 
3029 static void d68000_roxr_s_32(m68k_info *info)
3030 {
3031  build_3bit_d(info, M68K_INS_ROXR, 4);
3032 }
3033 
3034 static void d68000_roxr_r_8(m68k_info *info)
3035 {
3036  build_3bit_d(info, M68K_INS_ROXR, 4);
3037 }
3038 
3039 static void d68000_roxr_r_16(m68k_info *info)
3040 {
3041  build_r(info, M68K_INS_ROXR, 2);
3042 }
3043 
3044 static void d68000_roxr_r_32(m68k_info *info)
3045 {
3046  build_r(info, M68K_INS_ROXR, 4);
3047 }
3048 
3049 static void d68000_roxr_ea(m68k_info *info)
3050 {
3051  build_ea(info, M68K_INS_ROXR, 2);
3052 }
3053 
3054 static void d68000_roxl_s_8(m68k_info *info)
3055 {
3056  build_3bit_d(info, M68K_INS_ROXL, 1);
3057 }
3058 
3059 static void d68000_roxl_s_16(m68k_info *info)
3060 {
3061  build_3bit_d(info, M68K_INS_ROXL, 2);
3062 }
3063 
3064 static void d68000_roxl_s_32(m68k_info *info)
3065 {
3066  build_3bit_d(info, M68K_INS_ROXL, 4);
3067 }
3068 
3069 static void d68000_roxl_r_8(m68k_info *info)
3070 {
3071  build_r(info, M68K_INS_ROXL, 1);
3072 }
3073 
3074 static void d68000_roxl_r_16(m68k_info *info)
3075 {
3076  build_r(info, M68K_INS_ROXL, 2);
3077 }
3078 
3079 static void d68000_roxl_r_32(m68k_info *info)
3080 {
3081  build_r(info, M68K_INS_ROXL, 4);
3082 }
3083 
3084 static void d68000_roxl_ea(m68k_info *info)
3085 {
3086  build_ea(info, M68K_INS_ROXL, 2);
3087 }
3088 
3089 static void d68010_rtd(m68k_info *info)
3090 {
3094 }
3095 
3096 static void d68000_rte(m68k_info *info)
3097 {
3100 }
3101 
3102 static void d68020_rtm(m68k_info *info)
3103 {
3104  cs_m68k* ext;
3105  cs_m68k_op* op;
3106 
3108 
3110 
3112 
3113  ext = &info->extension;
3114  op = &ext->operands[0];
3115 
3116  op->address_mode = M68K_AM_NONE;
3117  op->type = M68K_OP_REG;
3118 
3119  if (BIT_3(info->ir)) {
3120  op->reg = M68K_REG_A0 + (info->ir & 7);
3121  } else {
3122  op->reg = M68K_REG_D0 + (info->ir & 7);
3123  }
3124 }
3125 
3126 static void d68000_rtr(m68k_info *info)
3127 {
3130 }
3131 
3132 static void d68000_rts(m68k_info *info)
3133 {
3136 }
3137 
3138 static void d68000_sbcd_rr(m68k_info *info)
3139 {
3140  build_rr(info, M68K_INS_SBCD, 1, 0);
3141 }
3142 
3143 static void d68000_sbcd_mm(m68k_info *info)
3144 {
3145  build_mm(info, M68K_INS_SBCD, 0, read_imm_16(info));
3146 }
3147 
3148 static void d68000_scc(m68k_info *info)
3149 {
3150  cs_m68k* ext = build_init_op(info, s_scc_lut[(info->ir >> 8) & 0xf], 1, 1);
3151  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
3152 }
3153 
3154 static void d68000_stop(m68k_info *info)
3155 {
3157 }
3158 
3159 static void d68000_sub_er_8(m68k_info *info)
3160 {
3161  build_er_1(info, M68K_INS_SUB, 1);
3162 }
3163 
3164 static void d68000_sub_er_16(m68k_info *info)
3165 {
3166  build_er_1(info, M68K_INS_SUB, 2);
3167 }
3168 
3169 static void d68000_sub_er_32(m68k_info *info)
3170 {
3171  build_er_1(info, M68K_INS_SUB, 4);
3172 }
3173 
3174 static void d68000_sub_re_8(m68k_info *info)
3175 {
3176  build_re_1(info, M68K_INS_SUB, 1);
3177 }
3178 
3179 static void d68000_sub_re_16(m68k_info *info)
3180 {
3181  build_re_1(info, M68K_INS_SUB, 2);
3182 }
3183 
3184 static void d68000_sub_re_32(m68k_info *info)
3185 {
3186  build_re_1(info, M68K_INS_SUB, 4);
3187 }
3188 
3189 static void d68000_suba_16(m68k_info *info)
3190 {
3191  build_ea_a(info, M68K_INS_SUBA, 2);
3192 }
3193 
3194 static void d68000_suba_32(m68k_info *info)
3195 {
3196  build_ea_a(info, M68K_INS_SUBA, 4);
3197 }
3198 
3199 static void d68000_subi_8(m68k_info *info)
3200 {
3201  build_imm_ea(info, M68K_INS_SUBI, 1, read_imm_8(info));
3202 }
3203 
3204 static void d68000_subi_16(m68k_info *info)
3205 {
3206  build_imm_ea(info, M68K_INS_SUBI, 2, read_imm_16(info));
3207 }
3208 
3209 static void d68000_subi_32(m68k_info *info)
3210 {
3211  build_imm_ea(info, M68K_INS_SUBI, 4, read_imm_32(info));
3212 }
3213 
3214 static void d68000_subq_8(m68k_info *info)
3215 {
3216  build_3bit_ea(info, M68K_INS_SUBQ, 1);
3217 }
3218 
3219 static void d68000_subq_16(m68k_info *info)
3220 {
3221  build_3bit_ea(info, M68K_INS_SUBQ, 2);
3222 }
3223 
3224 static void d68000_subq_32(m68k_info *info)
3225 {
3226  build_3bit_ea(info, M68K_INS_SUBQ, 4);
3227 }
3228 
3229 static void d68000_subx_rr_8(m68k_info *info)
3230 {
3231  build_rr(info, M68K_INS_SUBX, 1, 0);
3232 }
3233 
3234 static void d68000_subx_rr_16(m68k_info *info)
3235 {
3236  build_rr(info, M68K_INS_SUBX, 2, 0);
3237 }
3238 
3239 static void d68000_subx_rr_32(m68k_info *info)
3240 {
3241  build_rr(info, M68K_INS_SUBX, 4, 0);
3242 }
3243 
3244 static void d68000_subx_mm_8(m68k_info *info)
3245 {
3246  build_mm(info, M68K_INS_SUBX, 1, 0);
3247 }
3248 
3249 static void d68000_subx_mm_16(m68k_info *info)
3250 {
3251  build_mm(info, M68K_INS_SUBX, 2, 0);
3252 }
3253 
3254 static void d68000_subx_mm_32(m68k_info *info)
3255 {
3256  build_mm(info, M68K_INS_SUBX, 4, 0);
3257 }
3258 
3259 static void d68000_swap(m68k_info *info)
3260 {
3261  build_d(info, M68K_INS_SWAP, 0);
3262 }
3263 
3264 static void d68000_tas(m68k_info *info)
3265 {
3266  build_ea(info, M68K_INS_TAS, 1);
3267 }
3268 
3269 static void d68000_trap(m68k_info *info)
3270 {
3272 }
3273 
3274 static void d68020_trapcc_0(m68k_info *info)
3275 {
3277  build_trap(info, 0, 0);
3278 
3279  info->extension.op_count = 0;
3280 }
3281 
3282 static void d68020_trapcc_16(m68k_info *info)
3283 {
3285  build_trap(info, 2, read_imm_16(info));
3286 }
3287 
3288 static void d68020_trapcc_32(m68k_info *info)
3289 {
3291  build_trap(info, 4, read_imm_32(info));
3292 }
3293 
3294 static void d68000_trapv(m68k_info *info)
3295 {
3297 }
3298 
3299 static void d68000_tst_8(m68k_info *info)
3300 {
3301  build_ea(info, M68K_INS_TST, 1);
3302 }
3303 
3304 static void d68020_tst_pcdi_8(m68k_info *info)
3305 {
3307  build_ea(info, M68K_INS_TST, 1);
3308 }
3309 
3310 static void d68020_tst_pcix_8(m68k_info *info)
3311 {
3313  build_ea(info, M68K_INS_TST, 1);
3314 }
3315 
3316 static void d68020_tst_i_8(m68k_info *info)
3317 {
3319  build_ea(info, M68K_INS_TST, 1);
3320 }
3321 
3322 static void d68000_tst_16(m68k_info *info)
3323 {
3324  build_ea(info, M68K_INS_TST, 2);
3325 }
3326 
3327 static void d68020_tst_a_16(m68k_info *info)
3328 {
3330  build_ea(info, M68K_INS_TST, 2);
3331 }
3332 
3333 static void d68020_tst_pcdi_16(m68k_info *info)
3334 {
3336  build_ea(info, M68K_INS_TST, 2);
3337 }
3338 
3339 static void d68020_tst_pcix_16(m68k_info *info)
3340 {
3342  build_ea(info, M68K_INS_TST, 2);
3343 }
3344 
3345 static void d68020_tst_i_16(m68k_info *info)
3346 {
3348  build_ea(info, M68K_INS_TST, 2);
3349 }
3350 
3351 static void d68000_tst_32(m68k_info *info)
3352 {
3353  build_ea(info, M68K_INS_TST, 4);
3354 }
3355 
3356 static void d68020_tst_a_32(m68k_info *info)
3357 {
3359  build_ea(info, M68K_INS_TST, 4);
3360 }
3361 
3362 static void d68020_tst_pcdi_32(m68k_info *info)
3363 {
3365  build_ea(info, M68K_INS_TST, 4);
3366 }
3367 
3368 static void d68020_tst_pcix_32(m68k_info *info)
3369 {
3371  build_ea(info, M68K_INS_TST, 4);
3372 }
3373 
3374 static void d68020_tst_i_32(m68k_info *info)
3375 {
3377  build_ea(info, M68K_INS_TST, 4);
3378 }
3379 
3380 static void d68000_unlk(m68k_info *info)
3381 {
3382  cs_m68k_op* op;
3383  cs_m68k* ext = build_init_op(info, M68K_INS_UNLK, 1, 0);
3384 
3385  op = &ext->operands[0];
3386 
3387  op->address_mode = M68K_AM_REG_DIRECT_ADDR;
3388  op->reg = M68K_REG_A0 + (info->ir & 7);
3389 }
3390 
3391 static void d68020_unpk_rr(m68k_info *info)
3392 {
3394  build_rr(info, M68K_INS_UNPK, 0, read_imm_16(info));
3395 }
3396 
3397 static void d68020_unpk_mm(m68k_info *info)
3398 {
3400  build_mm(info, M68K_INS_UNPK, 0, read_imm_16(info));
3401 }
3402 
3403 /* ======================================================================== */
3404 /* ======================= INSTRUCTION TABLE BUILDER ====================== */
3405 /* ======================================================================== */
3406 
3407 /* EA Masks:
3408  800 = data register direct
3409  400 = address register direct
3410  200 = address register indirect
3411  100 = ARI postincrement
3412  80 = ARI pre-decrement
3413  40 = ARI displacement
3414  20 = ARI index
3415  10 = absolute short
3416  8 = absolute long
3417  4 = immediate / sr
3418  2 = pc displacement
3419  1 = pc idx
3420  */
3421 
3423  /* opcode handler mask match ea_mask mask2 match2*/
3424  {d68000_1010 , 0xf000, 0xa000, 0x000},
3425  {d68000_1111 , 0xf000, 0xf000, 0x000},
3426  {d68000_abcd_rr , 0xf1f8, 0xc100, 0x000},
3427  {d68000_abcd_mm , 0xf1f8, 0xc108, 0x000},
3428  {d68000_add_er_8 , 0xf1c0, 0xd000, 0xbff},
3429  {d68000_add_er_16 , 0xf1c0, 0xd040, 0xfff},
3430  {d68000_add_er_32 , 0xf1c0, 0xd080, 0xfff},
3431  {d68000_add_re_8 , 0xf1c0, 0xd100, 0x3f8},
3432  {d68000_add_re_16 , 0xf1c0, 0xd140, 0x3f8},
3433  {d68000_add_re_32 , 0xf1c0, 0xd180, 0x3f8},
3434  {d68000_adda_16 , 0xf1c0, 0xd0c0, 0xfff},
3435  {d68000_adda_32 , 0xf1c0, 0xd1c0, 0xfff},
3436  {d68000_addi_8 , 0xffc0, 0x0600, 0xbf8},
3437  {d68000_addi_16 , 0xffc0, 0x0640, 0xbf8},
3438  {d68000_addi_32 , 0xffc0, 0x0680, 0xbf8},
3439  {d68000_addq_8 , 0xf1c0, 0x5000, 0xbf8},
3440  {d68000_addq_16 , 0xf1c0, 0x5040, 0xff8},
3441  {d68000_addq_32 , 0xf1c0, 0x5080, 0xff8},
3442  {d68000_addx_rr_8 , 0xf1f8, 0xd100, 0x000},
3443  {d68000_addx_rr_16 , 0xf1f8, 0xd140, 0x000},
3444  {d68000_addx_rr_32 , 0xf1f8, 0xd180, 0x000},
3445  {d68000_addx_mm_8 , 0xf1f8, 0xd108, 0x000},
3446  {d68000_addx_mm_16 , 0xf1f8, 0xd148, 0x000},
3447  {d68000_addx_mm_32 , 0xf1f8, 0xd188, 0x000},
3448  {d68000_and_er_8 , 0xf1c0, 0xc000, 0xbff},
3449  {d68000_and_er_16 , 0xf1c0, 0xc040, 0xbff},
3450  {d68000_and_er_32 , 0xf1c0, 0xc080, 0xbff},
3451  {d68000_and_re_8 , 0xf1c0, 0xc100, 0x3f8},
3452  {d68000_and_re_16 , 0xf1c0, 0xc140, 0x3f8},
3453  {d68000_and_re_32 , 0xf1c0, 0xc180, 0x3f8},
3454  {d68000_andi_to_ccr , 0xffff, 0x023c, 0x000, 0xff00, 0x0000},
3455  {d68000_andi_to_sr , 0xffff, 0x027c, 0x000},
3456  {d68000_andi_8 , 0xffc0, 0x0200, 0xbf8},
3457  {d68000_andi_16 , 0xffc0, 0x0240, 0xbf8},
3458  {d68000_andi_32 , 0xffc0, 0x0280, 0xbf8},
3459  {d68000_asr_s_8 , 0xf1f8, 0xe000, 0x000},
3460  {d68000_asr_s_16 , 0xf1f8, 0xe040, 0x000},
3461  {d68000_asr_s_32 , 0xf1f8, 0xe080, 0x000},
3462  {d68000_asr_r_8 , 0xf1f8, 0xe020, 0x000},
3463  {d68000_asr_r_16 , 0xf1f8, 0xe060, 0x000},
3464  {d68000_asr_r_32 , 0xf1f8, 0xe0a0, 0x000},
3465  {d68000_asr_ea , 0xffc0, 0xe0c0, 0x3f8},
3466  {d68000_asl_s_8 , 0xf1f8, 0xe100, 0x000},
3467  {d68000_asl_s_16 , 0xf1f8, 0xe140, 0x000},
3468  {d68000_asl_s_32 , 0xf1f8, 0xe180, 0x000},
3469  {d68000_asl_r_8 , 0xf1f8, 0xe120, 0x000},
3470  {d68000_asl_r_16 , 0xf1f8, 0xe160, 0x000},
3471  {d68000_asl_r_32 , 0xf1f8, 0xe1a0, 0x000},
3472  {d68000_asl_ea , 0xffc0, 0xe1c0, 0x3f8},
3473  {d68000_bcc_8 , 0xf000, 0x6000, 0x000},
3474  {d68000_bcc_16 , 0xf0ff, 0x6000, 0x000},
3475  {d68020_bcc_32 , 0xf0ff, 0x60ff, 0x000},
3476  {d68000_bchg_r , 0xf1c0, 0x0140, 0xbf8},
3477  {d68000_bchg_s , 0xffc0, 0x0840, 0xbf8, 0xff00, 0x0000},
3478  {d68000_bclr_r , 0xf1c0, 0x0180, 0xbf8},
3479  {d68000_bclr_s , 0xffc0, 0x0880, 0xbf8, 0xff00, 0x0000},
3480  {d68020_bfchg , 0xffc0, 0xeac0, 0xa78, 0xf000, 0x0000},
3481  {d68020_bfclr , 0xffc0, 0xecc0, 0xa78, 0xf000, 0x0000},
3482  {d68020_bfexts , 0xffc0, 0xebc0, 0xa7b, 0x8000, 0x0000},
3483  {d68020_bfextu , 0xffc0, 0xe9c0, 0xa7b, 0x8000, 0x0000},
3484  {d68020_bfffo , 0xffc0, 0xedc0, 0xa7b, 0x8000, 0x0000},
3485  {d68020_bfins , 0xffc0, 0xefc0, 0xa78, 0x8000, 0x0000},
3486  {d68020_bfset , 0xffc0, 0xeec0, 0xa78, 0xf000, 0x0000},
3487  {d68020_bftst , 0xffc0, 0xe8c0, 0xa7b, 0xf000, 0x0000},
3488  {d68010_bkpt , 0xfff8, 0x4848, 0x000},
3489  {d68000_bra_8 , 0xff00, 0x6000, 0x000},
3490  {d68000_bra_16 , 0xffff, 0x6000, 0x000},
3491  {d68020_bra_32 , 0xffff, 0x60ff, 0x000},
3492  {d68000_bset_r , 0xf1c0, 0x01c0, 0xbf8},
3493  {d68000_bset_s , 0xffc0, 0x08c0, 0xbf8, 0xfe00, 0x0000 },
3494  {d68000_bsr_8 , 0xff00, 0x6100, 0x000},
3495  {d68000_bsr_16 , 0xffff, 0x6100, 0x000},
3496  {d68020_bsr_32 , 0xffff, 0x61ff, 0x000},
3497  {d68000_btst_r , 0xf1c0, 0x0100, 0xbff},
3498  {d68000_btst_s , 0xffc0, 0x0800, 0xbfb, 0xff00, 0x0000},
3499  {d68020_callm , 0xffc0, 0x06c0, 0x27b, 0xff00, 0x0000},
3500  {d68020_cas_8 , 0xffc0, 0x0ac0, 0x3f8, 0xfe38, 0x0000},
3501  {d68020_cas_16 , 0xffc0, 0x0cc0, 0x3f8, 0xfe38, 0x0000},
3502  {d68020_cas_32 , 0xffc0, 0x0ec0, 0x3f8, 0xfe38, 0x0000},
3503  {d68020_cas2_16 , 0xffff, 0x0cfc, 0x000, 0x0e38, 0x0000/*, 0x0e38, 0x0000 */},
3504  {d68020_cas2_32 , 0xffff, 0x0efc, 0x000, 0x0e38, 0x0000/*, 0x0e38, 0x0000 */},
3505  {d68000_chk_16 , 0xf1c0, 0x4180, 0xbff},
3506  {d68020_chk_32 , 0xf1c0, 0x4100, 0xbff},
3507  {d68020_chk2_cmp2_8 , 0xffc0, 0x00c0, 0x27b, 0x07ff, 0x0000},
3508  {d68020_chk2_cmp2_16 , 0xffc0, 0x02c0, 0x27b, 0x07ff, 0x0000},
3509  {d68020_chk2_cmp2_32 , 0xffc0, 0x04c0, 0x27b, 0x07ff, 0x0000},
3510  {d68040_cinv , 0xff20, 0xf400, 0x000},
3511  {d68000_clr_8 , 0xffc0, 0x4200, 0xbf8},
3512  {d68000_clr_16 , 0xffc0, 0x4240, 0xbf8},
3513  {d68000_clr_32 , 0xffc0, 0x4280, 0xbf8},
3514  {d68000_cmp_8 , 0xf1c0, 0xb000, 0xbff},
3515  {d68000_cmp_16 , 0xf1c0, 0xb040, 0xfff},
3516  {d68000_cmp_32 , 0xf1c0, 0xb080, 0xfff},
3517  {d68000_cmpa_16 , 0xf1c0, 0xb0c0, 0xfff},
3518  {d68000_cmpa_32 , 0xf1c0, 0xb1c0, 0xfff},
3519  {d68000_cmpi_8 , 0xffc0, 0x0c00, 0xbf8},
3520  {d68020_cmpi_pcdi_8 , 0xffff, 0x0c3a, 0x000},
3521  {d68020_cmpi_pcix_8 , 0xffff, 0x0c3b, 0x000},
3522  {d68000_cmpi_16 , 0xffc0, 0x0c40, 0xbf8},
3523  {d68020_cmpi_pcdi_16 , 0xffff, 0x0c7a, 0x000},
3524  {d68020_cmpi_pcix_16 , 0xffff, 0x0c7b, 0x000},
3525  {d68000_cmpi_32 , 0xffc0, 0x0c80, 0xbf8},
3526  {d68020_cmpi_pcdi_32 , 0xffff, 0x0cba, 0x000},
3527  {d68020_cmpi_pcix_32 , 0xffff, 0x0cbb, 0x000},
3528  {d68000_cmpm_8 , 0xf1f8, 0xb108, 0x000},
3529  {d68000_cmpm_16 , 0xf1f8, 0xb148, 0x000},
3530  {d68000_cmpm_32 , 0xf1f8, 0xb188, 0x000},
3531  {d68020_cpbcc_16 , 0xf1c0, 0xf080, 0x000},
3532  {d68020_cpbcc_32 , 0xf1c0, 0xf0c0, 0x000},
3533  {d68020_cpdbcc , 0xf1f8, 0xf048, 0x000},
3534  {d68020_cpgen , 0xf1c0, 0xf000, 0x000},
3535  {d68020_cprestore , 0xf1c0, 0xf140, 0x37f},
3536  {d68020_cpsave , 0xf1c0, 0xf100, 0x2f8},
3537  {d68020_cpscc , 0xf1c0, 0xf040, 0xbf8},
3538  {d68020_cptrapcc_0 , 0xf1ff, 0xf07c, 0x000},
3539  {d68020_cptrapcc_16 , 0xf1ff, 0xf07a, 0x000},
3540  {d68020_cptrapcc_32 , 0xf1ff, 0xf07b, 0x000},
3541  {d68040_cpush , 0xff20, 0xf420, 0x000},
3542  {d68000_dbcc , 0xf0f8, 0x50c8, 0x000},
3543  {d68000_dbra , 0xfff8, 0x51c8, 0x000},
3544  {d68000_divs , 0xf1c0, 0x81c0, 0xbff},
3545  {d68000_divu , 0xf1c0, 0x80c0, 0xbff},
3546  {d68020_divl , 0xff80, 0x4c00, 0xbff, 0x83f8, 0x0000},
3547  {d68000_eor_8 , 0xf1c0, 0xb100, 0xbf8},
3548  {d68000_eor_16 , 0xf1c0, 0xb140, 0xbf8},
3549  {d68000_eor_32 , 0xf1c0, 0xb180, 0xbf8},
3550  {d68000_eori_to_ccr , 0xffff, 0x0a3c, 0x000, 0xff00, 0x0000},
3551  {d68000_eori_to_sr , 0xffff, 0x0a7c, 0x000},
3552  {d68000_eori_8 , 0xffc0, 0x0a00, 0xbf8},
3553  {d68000_eori_16 , 0xffc0, 0x0a40, 0xbf8},
3554  {d68000_eori_32 , 0xffc0, 0x0a80, 0xbf8},
3555  {d68000_exg_dd , 0xf1f8, 0xc140, 0x000},
3556  {d68000_exg_aa , 0xf1f8, 0xc148, 0x000},
3557  {d68000_exg_da , 0xf1f8, 0xc188, 0x000},
3558  {d68020_extb_32 , 0xfff8, 0x49c0, 0x000},
3559  {d68000_ext_16 , 0xfff8, 0x4880, 0x000},
3560  {d68000_ext_32 , 0xfff8, 0x48c0, 0x000},
3561  {d68000_illegal , 0xffff, 0x4afc, 0x000},
3562  {d68000_jmp , 0xffc0, 0x4ec0, 0x27b},
3563  {d68000_jsr , 0xffc0, 0x4e80, 0x27b},
3564  {d68000_lea , 0xf1c0, 0x41c0, 0x27b},
3565  {d68000_link_16 , 0xfff8, 0x4e50, 0x000},
3566  {d68020_link_32 , 0xfff8, 0x4808, 0x000},
3567  {d68000_lsr_s_8 , 0xf1f8, 0xe008, 0x000},
3568  {d68000_lsr_s_16 , 0xf1f8, 0xe048, 0x000},
3569  {d68000_lsr_s_32 , 0xf1f8, 0xe088, 0x000},
3570  {d68000_lsr_r_8 , 0xf1f8, 0xe028, 0x000},
3571  {d68000_lsr_r_16 , 0xf1f8, 0xe068, 0x000},
3572  {d68000_lsr_r_32 , 0xf1f8, 0xe0a8, 0x000},
3573  {d68000_lsr_ea , 0xffc0, 0xe2c0, 0x3f8},
3574  {d68000_lsl_s_8 , 0xf1f8, 0xe108, 0x000},
3575  {d68000_lsl_s_16 , 0xf1f8, 0xe148, 0x000},
3576  {d68000_lsl_s_32 , 0xf1f8, 0xe188, 0x000},
3577  {d68000_lsl_r_8 , 0xf1f8, 0xe128, 0x000},
3578  {d68000_lsl_r_16 , 0xf1f8, 0xe168, 0x000},
3579  {d68000_lsl_r_32 , 0xf1f8, 0xe1a8, 0x000},
3580  {d68000_lsl_ea , 0xffc0, 0xe3c0, 0x3f8},
3581  {d68000_move_8 , 0xf000, 0x1000, 0xbff},
3582  {d68000_move_16 , 0xf000, 0x3000, 0xfff},
3583  {d68000_move_32 , 0xf000, 0x2000, 0xfff},
3584  {d68000_movea_16 , 0xf1c0, 0x3040, 0xfff},
3585  {d68000_movea_32 , 0xf1c0, 0x2040, 0xfff},
3586  {d68000_move_to_ccr , 0xffc0, 0x44c0, 0xbff},
3587  {d68010_move_fr_ccr , 0xffc0, 0x42c0, 0xbf8},
3588  {d68000_move_to_sr , 0xffc0, 0x46c0, 0xbff},
3589  {d68000_move_fr_sr , 0xffc0, 0x40c0, 0xbf8},
3590  {d68000_move_to_usp , 0xfff8, 0x4e60, 0x000},
3591  {d68000_move_fr_usp , 0xfff8, 0x4e68, 0x000},
3592  {d68010_movec , 0xfffe, 0x4e7a, 0x000},
3593  {d68000_movem_pd_16 , 0xfff8, 0x48a0, 0x000},
3594  {d68000_movem_pd_32 , 0xfff8, 0x48e0, 0x000},
3595  {d68000_movem_re_16 , 0xffc0, 0x4880, 0x2f8},
3596  {d68000_movem_re_32 , 0xffc0, 0x48c0, 0x2f8},
3597  {d68000_movem_er_16 , 0xffc0, 0x4c80, 0x37b},
3598  {d68000_movem_er_32 , 0xffc0, 0x4cc0, 0x37b},
3599  {d68000_movep_er_16 , 0xf1f8, 0x0108, 0x000},
3600  {d68000_movep_er_32 , 0xf1f8, 0x0148, 0x000},
3601  {d68000_movep_re_16 , 0xf1f8, 0x0188, 0x000},
3602  {d68000_movep_re_32 , 0xf1f8, 0x01c8, 0x000},
3603  {d68010_moves_8 , 0xffc0, 0x0e00, 0x3f8, 0x07ff, 0x0000},
3604  {d68010_moves_16 , 0xffc0, 0x0e40, 0x3f8, 0x07ff, 0x0000},
3605  {d68010_moves_32 , 0xffc0, 0x0e80, 0x3f8, 0x07ff, 0x0000},
3606  {d68000_moveq , 0xf100, 0x7000, 0x000},
3607  {d68040_move16_pi_pi , 0xfff8, 0xf620, 0x000, 0x8fff, 0x8000},
3608  {d68040_move16_pi_al , 0xfff8, 0xf600, 0x000},
3609  {d68040_move16_al_pi , 0xfff8, 0xf608, 0x000},
3610  {d68040_move16_ai_al , 0xfff8, 0xf610, 0x000},
3611  {d68040_move16_al_ai , 0xfff8, 0xf618, 0x000},
3612  {d68000_muls , 0xf1c0, 0xc1c0, 0xbff},
3613  {d68000_mulu , 0xf1c0, 0xc0c0, 0xbff},
3614  {d68020_mull , 0xffc0, 0x4c00, 0xbff, 0x83f8, 0x0000},
3615  {d68000_nbcd , 0xffc0, 0x4800, 0xbf8},
3616  {d68000_neg_8 , 0xffc0, 0x4400, 0xbf8},
3617  {d68000_neg_16 , 0xffc0, 0x4440, 0xbf8},
3618  {d68000_neg_32 , 0xffc0, 0x4480, 0xbf8},
3619  {d68000_negx_8 , 0xffc0, 0x4000, 0xbf8},
3620  {d68000_negx_16 , 0xffc0, 0x4040, 0xbf8},
3621  {d68000_negx_32 , 0xffc0, 0x4080, 0xbf8},
3622  {d68000_nop , 0xffff, 0x4e71, 0x000},
3623  {d68000_not_8 , 0xffc0, 0x4600, 0xbf8},
3624  {d68000_not_16 , 0xffc0, 0x4640, 0xbf8},
3625  {d68000_not_32 , 0xffc0, 0x4680, 0xbf8},
3626  {d68000_or_er_8 , 0xf1c0, 0x8000, 0xbff},
3627  {d68000_or_er_16 , 0xf1c0, 0x8040, 0xbff},
3628  {d68000_or_er_32 , 0xf1c0, 0x8080, 0xbff},
3629  {d68000_or_re_8 , 0xf1c0, 0x8100, 0x3f8},
3630  {d68000_or_re_16 , 0xf1c0, 0x8140, 0x3f8},
3631  {d68000_or_re_32 , 0xf1c0, 0x8180, 0x3f8},
3632  {d68000_ori_to_ccr , 0xffff, 0x003c, 0x000, 0xff00, 0x0000},
3633  {d68000_ori_to_sr , 0xffff, 0x007c, 0x000},
3634  {d68000_ori_8 , 0xffc0, 0x0000, 0xbf8},
3635  {d68000_ori_16 , 0xffc0, 0x0040, 0xbf8},
3636  {d68000_ori_32 , 0xffc0, 0x0080, 0xbf8},
3637  {d68020_pack_rr , 0xf1f8, 0x8140, 0x000},
3638  {d68020_pack_mm , 0xf1f8, 0x8148, 0x000},
3639  {d68000_pea , 0xffc0, 0x4840, 0x27b},
3640  {d68000_reset , 0xffff, 0x4e70, 0x000},
3641  {d68000_ror_s_8 , 0xf1f8, 0xe018, 0x000},
3642  {d68000_ror_s_16 , 0xf1f8, 0xe058, 0x000},
3643  {d68000_ror_s_32 , 0xf1f8, 0xe098, 0x000},
3644  {d68000_ror_r_8 , 0xf1f8, 0xe038, 0x000},
3645  {d68000_ror_r_16 , 0xf1f8, 0xe078, 0x000},
3646  {d68000_ror_r_32 , 0xf1f8, 0xe0b8, 0x000},
3647  {d68000_ror_ea , 0xffc0, 0xe6c0, 0x3f8},
3648  {d68000_rol_s_8 , 0xf1f8, 0xe118, 0x000},
3649  {d68000_rol_s_16 , 0xf1f8, 0xe158, 0x000},
3650  {d68000_rol_s_32 , 0xf1f8, 0xe198, 0x000},
3651  {d68000_rol_r_8 , 0xf1f8, 0xe138, 0x000},
3652  {d68000_rol_r_16 , 0xf1f8, 0xe178, 0x000},
3653  {d68000_rol_r_32 , 0xf1f8, 0xe1b8, 0x000},
3654  {d68000_rol_ea , 0xffc0, 0xe7c0, 0x3f8},
3655  {d68000_roxr_s_8 , 0xf1f8, 0xe010, 0x000},
3656  {d68000_roxr_s_16 , 0xf1f8, 0xe050, 0x000},
3657  {d68000_roxr_s_32 , 0xf1f8, 0xe090, 0x000},
3658  {d68000_roxr_r_8 , 0xf1f8, 0xe030, 0x000},
3659  {d68000_roxr_r_16 , 0xf1f8, 0xe070, 0x000},
3660  {d68000_roxr_r_32 , 0xf1f8, 0xe0b0, 0x000},
3661  {d68000_roxr_ea , 0xffc0, 0xe4c0, 0x3f8},
3662  {d68000_roxl_s_8 , 0xf1f8, 0xe110, 0x000},
3663  {d68000_roxl_s_16 , 0xf1f8, 0xe150, 0x000},
3664  {d68000_roxl_s_32 , 0xf1f8, 0xe190, 0x000},
3665  {d68000_roxl_r_8 , 0xf1f8, 0xe130, 0x000},
3666  {d68000_roxl_r_16 , 0xf1f8, 0xe170, 0x000},
3667  {d68000_roxl_r_32 , 0xf1f8, 0xe1b0, 0x000},
3668  {d68000_roxl_ea , 0xffc0, 0xe5c0, 0x3f8},
3669  {d68010_rtd , 0xffff, 0x4e74, 0x000},
3670  {d68000_rte , 0xffff, 0x4e73, 0x000},
3671  {d68020_rtm , 0xfff0, 0x06c0, 0x000},
3672  {d68000_rtr , 0xffff, 0x4e77, 0x000},
3673  {d68000_rts , 0xffff, 0x4e75, 0x000},
3674  {d68000_sbcd_rr , 0xf1f8, 0x8100, 0x000},
3675  {d68000_sbcd_mm , 0xf1f8, 0x8108, 0x000},
3676  {d68000_scc , 0xf0c0, 0x50c0, 0xbf8},
3677  {d68000_stop , 0xffff, 0x4e72, 0x000},
3678  {d68000_sub_er_8 , 0xf1c0, 0x9000, 0xbff},
3679  {d68000_sub_er_16 , 0xf1c0, 0x9040, 0xfff},
3680  {d68000_sub_er_32 , 0xf1c0, 0x9080, 0xfff},
3681  {d68000_sub_re_8 , 0xf1c0, 0x9100, 0x3f8},
3682  {d68000_sub_re_16 , 0xf1c0, 0x9140, 0x3f8},
3683  {d68000_sub_re_32 , 0xf1c0, 0x9180, 0x3f8},
3684  {d68000_suba_16 , 0xf1c0, 0x90c0, 0xfff},
3685  {d68000_suba_32 , 0xf1c0, 0x91c0, 0xfff},
3686  {d68000_subi_8 , 0xffc0, 0x0400, 0xbf8},
3687  {d68000_subi_16 , 0xffc0, 0x0440, 0xbf8},
3688  {d68000_subi_32 , 0xffc0, 0x0480, 0xbf8},
3689  {d68000_subq_8 , 0xf1c0, 0x5100, 0xbf8},
3690  {d68000_subq_16 , 0xf1c0, 0x5140, 0xff8},
3691  {d68000_subq_32 , 0xf1c0, 0x5180, 0xff8},
3692  {d68000_subx_rr_8 , 0xf1f8, 0x9100, 0x000},
3693  {d68000_subx_rr_16 , 0xf1f8, 0x9140, 0x000},
3694  {d68000_subx_rr_32 , 0xf1f8, 0x9180, 0x000},
3695  {d68000_subx_mm_8 , 0xf1f8, 0x9108, 0x000},
3696  {d68000_subx_mm_16 , 0xf1f8, 0x9148, 0x000},
3697  {d68000_subx_mm_32 , 0xf1f8, 0x9188, 0x000},
3698  {d68000_swap , 0xfff8, 0x4840, 0x000},
3699  {d68000_tas , 0xffc0, 0x4ac0, 0xbf8},
3700  {d68000_trap , 0xfff0, 0x4e40, 0x000},
3701  {d68020_trapcc_0 , 0xf0ff, 0x50fc, 0x000},
3702  {d68020_trapcc_16 , 0xf0ff, 0x50fa, 0x000},
3703  {d68020_trapcc_32 , 0xf0ff, 0x50fb, 0x000},
3704  {d68000_trapv , 0xffff, 0x4e76, 0x000},
3705  {d68000_tst_8 , 0xffc0, 0x4a00, 0xbf8},
3706  {d68020_tst_pcdi_8 , 0xffff, 0x4a3a, 0x000},
3707  {d68020_tst_pcix_8 , 0xffff, 0x4a3b, 0x000},
3708  {d68020_tst_i_8 , 0xffff, 0x4a3c, 0x000},
3709  {d68000_tst_16 , 0xffc0, 0x4a40, 0xbf8},
3710  {d68020_tst_a_16 , 0xfff8, 0x4a48, 0x000},
3711  {d68020_tst_pcdi_16 , 0xffff, 0x4a7a, 0x000},
3712  {d68020_tst_pcix_16 , 0xffff, 0x4a7b, 0x000},
3713  {d68020_tst_i_16 , 0xffff, 0x4a7c, 0x000},
3714  {d68000_tst_32 , 0xffc0, 0x4a80, 0xbf8},
3715  {d68020_tst_a_32 , 0xfff8, 0x4a88, 0x000},
3716  {d68020_tst_pcdi_32 , 0xffff, 0x4aba, 0x000},
3717  {d68020_tst_pcix_32 , 0xffff, 0x4abb, 0x000},
3718  {d68020_tst_i_32 , 0xffff, 0x4abc, 0x000},
3719  {d68000_unlk , 0xfff8, 0x4e58, 0x000},
3720  {d68020_unpk_rr , 0xf1f8, 0x8180, 0x000},
3721  {d68020_unpk_mm , 0xf1f8, 0x8188, 0x000},
3722  {0, 0, 0, 0}
3723 };
3724 
3725 /* Check if opcode is using a valid ea mode */
3726 static int valid_ea(uint opcode, uint mask)
3727 {
3728  if (mask == 0)
3729  return 1;
3730 
3731  switch(opcode & 0x3f) {
3732  case 0x00: case 0x01: case 0x02: case 0x03:
3733  case 0x04: case 0x05: case 0x06: case 0x07:
3734  return (mask & 0x800) != 0;
3735  case 0x08: case 0x09: case 0x0a: case 0x0b:
3736  case 0x0c: case 0x0d: case 0x0e: case 0x0f:
3737  return (mask & 0x400) != 0;
3738  case 0x10: case 0x11: case 0x12: case 0x13:
3739  case 0x14: case 0x15: case 0x16: case 0x17:
3740  return (mask & 0x200) != 0;
3741  case 0x18: case 0x19: case 0x1a: case 0x1b:
3742  case 0x1c: case 0x1d: case 0x1e: case 0x1f:
3743  return (mask & 0x100) != 0;
3744  case 0x20: case 0x21: case 0x22: case 0x23:
3745  case 0x24: case 0x25: case 0x26: case 0x27:
3746  return (mask & 0x080) != 0;
3747  case 0x28: case 0x29: case 0x2a: case 0x2b:
3748  case 0x2c: case 0x2d: case 0x2e: case 0x2f:
3749  return (mask & 0x040) != 0;
3750  case 0x30: case 0x31: case 0x32: case 0x33:
3751  case 0x34: case 0x35: case 0x36: case 0x37:
3752  return (mask & 0x020) != 0;
3753  case 0x38:
3754  return (mask & 0x010) != 0;
3755  case 0x39:
3756  return (mask & 0x008) != 0;
3757  case 0x3a:
3758  return (mask & 0x002) != 0;
3759  case 0x3b:
3760  return (mask & 0x001) != 0;
3761  case 0x3c:
3762  return (mask & 0x004) != 0;
3763  }
3764  return 0;
3765 
3766 }
3767 
3768 /* Used by qsort */
3769 static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr)
3770 {
3771  uint a = ((const opcode_struct*)aptr)->mask;
3772  uint b = ((const opcode_struct*)bptr)->mask;
3773 
3774  a = ((a & 0xAAAA) >> 1) + (a & 0x5555);
3775  a = ((a & 0xCCCC) >> 2) + (a & 0x3333);
3776  a = ((a & 0xF0F0) >> 4) + (a & 0x0F0F);
3777  a = ((a & 0xFF00) >> 8) + (a & 0x00FF);
3778 
3779  b = ((b & 0xAAAA) >> 1) + (b & 0x5555);
3780  b = ((b & 0xCCCC) >> 2) + (b & 0x3333);
3781  b = ((b & 0xF0F0) >> 4) + (b & 0x0F0F);
3782  b = ((b & 0xFF00) >> 8) + (b & 0x00FF);
3783 
3784  return b - a; /* reversed to get greatest to least sorting */
3785 }
3786 
3787 /* build the opcode handler jump table */
3788 static void build_opcode_table(void)
3789 {
3790  uint i;
3791  uint opcode;
3792  opcode_struct* ostruct;
3793  uint opcode_info_length = 0;
3794 
3795  /* Already initialized ? */
3796  if (g_instruction_table[0].instruction != NULL) {
3797  return;
3798  }
3799 
3800  for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++)
3801  opcode_info_length++;
3802 
3803  qsort((void *)g_opcode_info, opcode_info_length, sizeof(g_opcode_info[0]), compare_nof_true_bits);
3804 
3805  for(i=0;i<0x10000;i++) {
3806  g_instruction_table[i].instruction = d68000_invalid; /* default to invalid, undecoded opcode */
3807  opcode = i;
3808  /* search through opcode info for a match */
3809  for(ostruct = g_opcode_info;ostruct->opcode_handler != 0;ostruct++) {
3810  /* match opcode mask and allowed ea modes */
3811  if ((opcode & ostruct->mask) == ostruct->match) {
3812  /* Handle destination ea for move instructions */
3813  if ((ostruct->opcode_handler == d68000_move_8 ||
3814  ostruct->opcode_handler == d68000_move_16 ||
3815  ostruct->opcode_handler == d68000_move_32) &&
3816  !valid_ea(((opcode>>9)&7) | ((opcode>>3)&0x38), 0xbf8))
3817  continue;
3818  if (valid_ea(opcode, ostruct->ea_mask)) {
3820  g_instruction_table[i].word2_mask = ostruct->mask2;
3822  break;
3823  }
3824  }
3825  }
3826  }
3827 }
3828 
3829 static int instruction_is_valid(m68k_info *info, const unsigned int word_check)
3830 {
3831  const unsigned int instruction = info->ir;
3832  instruction_struct *i = &g_instruction_table[instruction];
3833 
3834  if ( (i->word2_mask && ((word_check & i->word2_mask) != i->word2_match)) ||
3835  (i->instruction == d68000_invalid) ) {
3836  d68000_invalid(info);
3837  return 0;
3838  }
3839 
3840  return 1;
3841 }
3842 
3844 {
3845  uint8_t i;
3846 
3847  for (i = 0; i < count; ++i) {
3848  if (regs[i] == (uint16_t)reg)
3849  return 1;
3850  }
3851 
3852  return 0;
3853 }
3854 
3855 static void add_reg_to_rw_list(m68k_info *info, m68k_reg reg, int write)
3856 {
3857  if (reg == M68K_REG_INVALID)
3858  return;
3859 
3860  if (write)
3861  {
3862  if (exists_reg_list(info->regs_write, info->regs_write_count, reg))
3863  return;
3864 
3865  info->regs_write[info->regs_write_count] = (uint16_t)reg;
3866  info->regs_write_count++;
3867  }
3868  else
3869  {
3870  if (exists_reg_list(info->regs_read, info->regs_read_count, reg))
3871  return;
3872 
3873  info->regs_read[info->regs_read_count] = (uint16_t)reg;
3874  info->regs_read_count++;
3875  }
3876 }
3877 
3879 {
3880  switch (op->address_mode) {
3883  add_reg_to_rw_list(info, op->reg, write);
3884  break;
3885 
3888  add_reg_to_rw_list(info, op->reg, 1);
3889  break;
3890 
3891  case M68K_AM_REGI_ADDR:
3893  add_reg_to_rw_list(info, op->reg, 0);
3894  break;
3895 
3904  add_reg_to_rw_list(info, op->mem.index_reg, 0);
3905  add_reg_to_rw_list(info, op->mem.base_reg, 0);
3906  break;
3907 
3908  // no register(s) in the other addressing modes
3909  default:
3910  break;
3911  }
3912 }
3913 
3914 static void update_bits_range(m68k_info *info, m68k_reg reg_start, uint8_t bits, int write)
3915 {
3916  int i;
3917 
3918  for (i = 0; i < 8; ++i) {
3919  if (bits & (1 << i)) {
3920  add_reg_to_rw_list(info, reg_start + i, write);
3921  }
3922  }
3923 }
3924 
3926 {
3927  uint32_t bits = op->register_bits;
3928  update_bits_range(info, M68K_REG_D0, bits & 0xff, write);
3929  update_bits_range(info, M68K_REG_A0, (bits >> 8) & 0xff, write);
3930  update_bits_range(info, M68K_REG_FP0, (bits >> 16) & 0xff, write);
3931 }
3932 
3934 {
3935  switch ((int)op->type) {
3936  case M68K_OP_REG:
3937  add_reg_to_rw_list(info, op->reg, write);
3938  break;
3939 
3940  case M68K_OP_MEM:
3941  update_am_reg_list(info, op, write);
3942  break;
3943 
3944  case M68K_OP_REG_BITS:
3946  break;
3947 
3948  case M68K_OP_REG_PAIR:
3949  add_reg_to_rw_list(info, M68K_REG_D0 + op->reg_pair.reg_0, write);
3950  add_reg_to_rw_list(info, M68K_REG_D0 + op->reg_pair.reg_1, write);
3951  break;
3952  }
3953 }
3954 
3956 {
3957  int i;
3958 
3959  if (!info->extension.op_count)
3960  return;
3961 
3962  if (info->extension.op_count == 1) {
3963  update_op_reg_list(info, &info->extension.operands[0], 1);
3964  } else {
3965  // first operand is always read
3966  update_op_reg_list(info, &info->extension.operands[0], 0);
3967 
3968  // remaning write
3969  for (i = 1; i < info->extension.op_count; ++i)
3970  update_op_reg_list(info, &info->extension.operands[i], 1);
3971  }
3972 }
3973 
3974 static void m68k_setup_internals(m68k_info* info, MCInst* inst, unsigned int pc, unsigned int cpu_type)
3975 {
3976  info->inst = inst;
3977  info->pc = pc;
3978  info->ir = 0;
3979  info->type = cpu_type;
3980  info->address_mask = 0xffffffff;
3981 
3982  switch(info->type) {
3983  case M68K_CPU_TYPE_68000:
3984  info->type = TYPE_68000;
3985  info->address_mask = 0x00ffffff;
3986  break;
3987  case M68K_CPU_TYPE_68010:
3988  info->type = TYPE_68010;
3989  info->address_mask = 0x00ffffff;
3990  break;
3991  case M68K_CPU_TYPE_68EC020:
3992  info->type = TYPE_68020;
3993  info->address_mask = 0x00ffffff;
3994  break;
3995  case M68K_CPU_TYPE_68020:
3996  info->type = TYPE_68020;
3997  info->address_mask = 0xffffffff;
3998  break;
3999  case M68K_CPU_TYPE_68030:
4000  info->type = TYPE_68030;
4001  info->address_mask = 0xffffffff;
4002  break;
4003  case M68K_CPU_TYPE_68040:
4004  info->type = TYPE_68040;
4005  info->address_mask = 0xffffffff;
4006  break;
4007  default:
4008  info->address_mask = 0;
4009  return;
4010  }
4011 }
4012 
4013 /* ======================================================================== */
4014 /* ================================= API ================================== */
4015 /* ======================================================================== */
4016 
4017 /* Disasemble one instruction at pc and store in str_buff */
4018 static unsigned int m68k_disassemble(m68k_info *info, uint64_t pc)
4019 {
4020  MCInst *inst = info->inst;
4021  cs_m68k* ext = &info->extension;
4022  int i;
4023  unsigned int size;
4024 
4025  inst->Opcode = M68K_INS_INVALID;
4026 
4028 
4029  memset(ext, 0, sizeof(cs_m68k));
4030  ext->op_size.type = M68K_SIZE_TYPE_CPU;
4031 
4032  for (i = 0; i < M68K_OPERAND_COUNT; ++i)
4033  ext->operands[i].type = M68K_OP_REG;
4034 
4035  info->ir = peek_imm_16(info);
4036  if (instruction_is_valid(info, peek_imm_32(info) & 0xffff)) {
4037  info->ir = read_imm_16(info);
4038  g_instruction_table[info->ir].instruction(info);
4039  }
4040 
4041  size = info->pc - (unsigned int)pc;
4042  info->pc = (unsigned int)pc;
4043 
4044  return size;
4045 }
4046 
4047 bool M68K_getInstruction(csh ud, const uint8_t* code, size_t code_len, MCInst* instr, uint16_t* size, uint64_t address, void* inst_info)
4048 {
4049 #ifdef M68K_DEBUG
4050  SStream ss;
4051 #endif
4052  int s;
4053  int cpu_type = M68K_CPU_TYPE_68000;
4054  cs_struct* handle = instr->csh;
4055  m68k_info *info = (m68k_info*)handle->printer_info;
4056 
4057  // code len has to be at least 2 bytes to be valid m68k
4058 
4059  if (code_len < 2) {
4060  *size = 0;
4061  return false;
4062  }
4063 
4064  if (instr->flat_insn->detail) {
4065  memset(instr->flat_insn->detail, 0, offsetof(cs_detail, m68k)+sizeof(cs_m68k));
4066  }
4067 
4068  info->groups_count = 0;
4069  info->regs_read_count = 0;
4070  info->regs_write_count = 0;
4071  info->code = code;
4072  info->code_len = code_len;
4073  info->baseAddress = address;
4074 
4075  if (handle->mode & CS_MODE_M68K_010)
4076  cpu_type = M68K_CPU_TYPE_68010;
4077  if (handle->mode & CS_MODE_M68K_020)
4078  cpu_type = M68K_CPU_TYPE_68020;
4079  if (handle->mode & CS_MODE_M68K_030)
4080  cpu_type = M68K_CPU_TYPE_68030;
4081  if (handle->mode & CS_MODE_M68K_040)
4082  cpu_type = M68K_CPU_TYPE_68040;
4083  if (handle->mode & CS_MODE_M68K_060)
4084  cpu_type = M68K_CPU_TYPE_68040; // 060 = 040 for now
4085 
4086  m68k_setup_internals(info, instr, (unsigned int)address, cpu_type);
4087  s = m68k_disassemble(info, address);
4088 
4089  if (s == 0) {
4090  *size = 2;
4091  return false;
4092  }
4093 
4095 
4096 #ifdef M68K_DEBUG
4097  SStream_Init(&ss);
4098  M68K_printInst(instr, &ss, info);
4099 #endif
4100 
4101  // Make sure we always stay within range
4102  if (s > (int)code_len)
4103  *size = (uint16_t)code_len;
4104  else
4105  *size = (uint16_t)s;
4106 
4107  return true;
4108 }
4109 
d68000_add_re_32
static void d68000_add_re_32(m68k_info *info)
Definition: M68KDisassembler.c:1273
build_moves
static void build_moves(m68k_info *info, int size)
Definition: M68KDisassembler.c:1155
d68020_link_32
static void d68020_link_32(m68k_info *info)
Definition: M68KDisassembler.c:2388
d68000_not_8
static void d68000_not_8(m68k_info *info)
Definition: M68KDisassembler.c:2857
M68K_OP_REG_BITS
@ M68K_OP_REG_BITS
Register bits move.
Definition: m68k.h:119
m68k_reg
m68k_reg
M68K registers and special registers.
Definition: m68k.h:20
M68K_SIZE_TYPE_FPU
@ M68K_SIZE_TYPE_FPU
Definition: m68k.h:194
m68k_info::groups
uint8_t groups[8]
Definition: M68KDisassembler.h:24
d68000_ror_s_32
static void d68000_ror_s_32(m68k_info *info)
Definition: M68KDisassembler.c:2959
M68K_AM_REGI_ADDR_POST_INC
@ M68K_AM_REGI_ADDR_POST_INC
Register Indirect - Address with Postincrement.
Definition: m68k.h:86
M68K_INS_ROXR
@ M68K_INS_ROXR
Definition: m68k.h:536
M68K_INS_BFINS
@ M68K_INS_BFINS
Definition: m68k.h:255
M68K_INS_SUBI
@ M68K_INS_SUBI
Definition: m68k.h:564
M68K_INS_SCC
@ M68K_INS_SCC
Definition: m68k.h:547
M68K_INS_DBCS
@ M68K_INS_DBCS
Definition: m68k.h:281
M68K_INS_RTE
@ M68K_INS_RTE
Definition: m68k.h:538
d68000_asr_s_32
static void d68000_asr_s_32(m68k_info *info)
Definition: M68KDisassembler.c:1413
d68020_bcc_32
static void d68020_bcc_32(m68k_info *info)
Definition: M68KDisassembler.c:1483
width
int width
Definition: libuv/docs/code/tty-gravity/main.c:10
build_ea
static void build_ea(m68k_info *info, int opcode, uint8_t size)
Definition: M68KDisassembler.c:695
M68K_REG_D0
@ M68K_REG_D0
Definition: m68k.h:23
d68000_nbcd
static void d68000_nbcd(m68k_info *info)
Definition: M68KDisassembler.c:2817
M68K_INS_FLOG2
@ M68K_INS_FLOG2
Definition: m68k.h:389
d68000_1010
static void d68000_1010(m68k_info *info)
Definition: M68KDisassembler.c:1228
build_bitfield_ins
static void build_bitfield_ins(m68k_info *info, int opcode, int has_d_arg)
Definition: M68KDisassembler.c:849
m68k_info::regs_write_count
uint8_t regs_write_count
Definition: M68KDisassembler.h:23
d68000_ori_8
static void d68000_ori_8(m68k_info *info)
Definition: M68KDisassembler.c:2902
build_regs_read_write_counts
static void build_regs_read_write_counts(m68k_info *info)
Definition: M68KDisassembler.c:3955
M68K_INS_RTS
@ M68K_INS_RTS
Definition: m68k.h:541
dst
static const char dst[]
Definition: test-fs-copyfile.c:37
M68K_REG_FPCR
@ M68K_REG_FPCR
Definition: m68k.h:71
m68k_op_br_disp::disp_size
uint8_t disp_size
Size from m68k_op_br_disp_size type above.
Definition: m68k.h:150
fmove_fpcr
static void fmove_fpcr(m68k_info *info, uint extension)
Definition: M68KDisassembler.c:1873
fix_build_deps.temp
temp
Definition: fix_build_deps.py:488
d68000_movem_pd_32
static void d68000_movem_pd_32(m68k_info *info)
Definition: M68KDisassembler.c:2637
m68k_info::type
unsigned int type
Definition: M68KDisassembler.h:17
M68020_ONLY
#define M68020_ONLY
Definition: M68KDisassembler.c:113
M68K_INS_CHK2
@ M68K_INS_CHK2
Definition: m68k.h:263
M68K_INS_TRAPPL
@ M68K_INS_TRAPPL
Definition: m68k.h:583
d68000_ext_32
static void d68000_ext_32(m68k_info *info)
Definition: M68KDisassembler.c:2353
d68000_negx_32
static void d68000_negx_32(m68k_info *info)
Definition: M68KDisassembler.c:2847
d68000_cmpi_16
static void d68000_cmpi_16(m68k_info *info)
Definition: M68KDisassembler.c:1750
M68K_AM_AREGI_INDEX_BASE_DISP
@ M68K_AM_AREGI_INDEX_BASE_DISP
Address Register Indirect With Index- Base displacement.
Definition: m68k.h:91
d68000_abcd_mm
static void d68000_abcd_mm(m68k_info *info)
Definition: M68KDisassembler.c:1243
M68K_INS_SUBA
@ M68K_INS_SUBA
Definition: m68k.h:563
M68K_printInst
void M68K_printInst(MCInst *MI, SStream *O, void *PrinterInfo)
Definition: M68KInstPrinter.c:262
M68K_INS_DIVU
@ M68K_INS_DIVU
Definition: m68k.h:295
d68000_sub_er_16
static void d68000_sub_er_16(m68k_info *info)
Definition: M68KDisassembler.c:3164
d68000_eori_8
static void d68000_eori_8(m68k_info *info)
Definition: M68KDisassembler.c:2286
M68K_INS_TRAPCC
@ M68K_INS_TRAPCC
Definition: m68k.h:575
BITFIELD
#define BITFIELD(val, sb, eb)
Definition: M68KDisassembler.c:155
read_imm_64
static unsigned long long read_imm_64(m68k_info *info)
Definition: M68KDisassembler.c:309
M68K_INS_RTD
@ M68K_INS_RTD
Definition: m68k.h:537
m68k_info::baseAddress
uint64_t baseAddress
Definition: M68KDisassembler.h:13
d68020_pack_mm
static void d68020_pack_mm(m68k_info *info)
Definition: M68KDisassembler.c:2933
build_invalid
static void build_invalid(m68k_info *info, int data)
Definition: M68KDisassembler.c:976
M68K_FPU_SIZE_DOUBLE
@ M68K_FPU_SIZE_DOUBLE
8 byte in size (double)
Definition: m68k.h:185
M68K_AM_IMMEDIATE
@ M68K_AM_IMMEDIATE
Immediate value.
Definition: m68k.h:106
d68020_cpscc
static void d68020_cpscc(m68k_info *info)
Definition: M68KDisassembler.c:2136
M68K_CPU_SIZE_LONG
@ M68K_CPU_SIZE_LONG
4 bytes in size
Definition: m68k.h:178
d68000_roxl_s_8
static void d68000_roxl_s_8(m68k_info *info)
Definition: M68KDisassembler.c:3054
d68020_cpgen
static void d68020_cpgen(m68k_info *info)
Definition: M68KDisassembler.c:1943
add_reg_to_rw_list
static void add_reg_to_rw_list(m68k_info *info, m68k_reg reg, int write)
Definition: M68KDisassembler.c:3855
memset
return memset(p, 0, total)
reverse_bits
static uint16_t reverse_bits(uint v)
Definition: M68KDisassembler.c:895
d68020_cpdbcc
static void d68020_cpdbcc(m68k_info *info)
Definition: M68KDisassembler.c:1846
d68020_divl
static void d68020_divl(m68k_info *info)
Definition: M68KDisassembler.c:2234
M68K_INS_FCMP
@ M68K_INS_FCMP
Definition: m68k.h:344
google::protobuf::extension
const Descriptor::ReservedRange const EnumValueDescriptor const MethodDescriptor extension
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2001
opcode_struct::mask2
uint mask2
Definition: M68KDisassembler.c:236
d68000_subi_32
static void d68000_subi_32(m68k_info *info)
Definition: M68KDisassembler.c:3209
M68K_AM_REG_DIRECT_ADDR
@ M68K_AM_REG_DIRECT_ADDR
Register Direct - Address.
Definition: m68k.h:83
M68K_REG_ITT0
@ M68K_REG_ITT0
Definition: m68k.h:63
MCInst::Opcode
unsigned Opcode
Definition: MCInst.h:93
d68000_tst_32
static void d68000_tst_32(m68k_info *info)
Definition: M68KDisassembler.c:3351
asyncio_get_stats.default
default
Definition: asyncio_get_stats.py:38
d68020_tst_a_32
static void d68020_tst_a_32(m68k_info *info)
Definition: M68KDisassembler.c:3356
M68K_INS_FMOVE
@ M68K_INS_FMOVE
Definition: m68k.h:393
d68000_jsr
static void d68000_jsr(m68k_info *info)
Definition: M68KDisassembler.c:2371
M68K_INS_ADDI
@ M68K_INS_ADDI
Definition: m68k.h:221
d68000_subi_8
static void d68000_subi_8(m68k_info *info)
Definition: M68KDisassembler.c:3199
d68020_chk_32
static void d68020_chk_32(m68k_info *info)
Definition: M68KDisassembler.c:1663
M68K_INS_EXTB
@ M68K_INS_EXTB
Definition: m68k.h:301
d68000_asl_ea
static void d68000_asl_ea(m68k_info *info)
Definition: M68KDisassembler.c:1468
d68000_roxr_r_32
static void d68000_roxr_r_32(m68k_info *info)
Definition: M68KDisassembler.c:3044
update_op_reg_list
static void update_op_reg_list(m68k_info *info, cs_m68k_op *op, int write)
Definition: M68KDisassembler.c:3933
M68K_INS_CAS
@ M68K_INS_CAS
Definition: m68k.h:260
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
M68K_INS_TRAPVC
@ M68K_INS_TRAPVC
Definition: m68k.h:581
d68000_cmpa_32
static void d68000_cmpa_32(m68k_info *info)
Definition: M68KDisassembler.c:1728
d68000_sub_re_32
static void d68000_sub_re_32(m68k_info *info)
Definition: M68KDisassembler.c:3184
d68040_move16_pi_pi
static void d68040_move16_pi_pi(m68k_info *info)
Definition: M68KDisassembler.c:2719
write
#define write
Definition: test-fs.c:47
d68020_cas_16
static void d68020_cas_16(m68k_info *info)
Definition: M68KDisassembler.c:1636
m68k_op_mem::width
uint8_t width
used for bf* instructions
Definition: m68k.h:135
M68K_INS_UNPK
@ M68K_INS_UNPK
Definition: m68k.h:591
M68K_INS_EXG
@ M68K_INS_EXG
Definition: m68k.h:299
M68K_INS_FSINH
@ M68K_INS_FSINH
Definition: m68k.h:413
M68K_INS_FSGLMUL
@ M68K_INS_FSGLMUL
Definition: m68k.h:410
M68K_INS_FSGLDIV
@ M68K_INS_FSGLDIV
Definition: m68k.h:409
opcode_struct::ea_mask
uint ea_mask
Definition: M68KDisassembler.c:235
d68000_subx_mm_8
static void d68000_subx_mm_8(m68k_info *info)
Definition: M68KDisassembler.c:3244
d68000_move_32
static void d68000_move_32(m68k_info *info)
Definition: M68KDisassembler.c:2474
M68K_INS_FTENTOX
@ M68K_INS_FTENTOX
Definition: m68k.h:454
M68K_INS_SVS
@ M68K_INS_SVS
Definition: m68k.h:554
M68K_INS_CPUSHL
@ M68K_INS_CPUSHL
Definition: m68k.h:273
d68000_add_er_16
static void d68000_add_er_16(m68k_info *info)
Definition: M68KDisassembler.c:1253
M68K_INS_BCC
@ M68K_INS_BCC
Definition: m68k.h:232
d68000_cmpi_8
static void d68000_cmpi_8(m68k_info *info)
Definition: M68KDisassembler.c:1733
M68K_INS_FSAVE
@ M68K_INS_FSAVE
Definition: m68k.h:407
d68020_tst_i_32
static void d68020_tst_i_32(m68k_info *info)
Definition: M68KDisassembler.c:3374
M68K_INS_FMUL
@ M68K_INS_FMUL
Definition: m68k.h:398
M68K_INS_CINVL
@ M68K_INS_CINVL
Definition: m68k.h:270
cs_m68k_op::type
m68k_op_type type
Definition: m68k.h:169
ext
void * ext
Definition: x509v3.h:87
M68K_INS_MOVEC
@ M68K_INS_MOVEC
Definition: m68k.h:500
d68000_subi_16
static void d68000_subi_16(m68k_info *info)
Definition: M68KDisassembler.c:3204
M68K_INS_ASR
@ M68K_INS_ASR
Definition: m68k.h:227
build_3bit_d
static void build_3bit_d(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:637
M68K_REG_SR
@ M68K_REG_SR
Definition: m68k.h:52
M68K_INS_TST
@ M68K_INS_TST
Definition: m68k.h:589
d68020_bfclr
static void d68020_bfclr(m68k_info *info)
Definition: M68KDisassembler.c:1522
string.h
d68000_movep_re_32
static void d68000_movep_re_32(m68k_info *info)
Definition: M68KDisassembler.c:2667
M68KDisassembler.h
d68000_divu
static void d68000_divu(m68k_info *info)
Definition: M68KDisassembler.c:2229
build_er_1
static void build_er_1(m68k_info *info, int opcode, uint8_t size)
Definition: M68KDisassembler.c:1174
d68000_move_16
static void d68000_move_16(m68k_info *info)
Definition: M68KDisassembler.c:2469
M68K_INS_FTST
@ M68K_INS_FTST
Definition: m68k.h:487
M68K_AM_NONE
@ M68K_AM_NONE
No address mode.
Definition: m68k.h:80
M68K_INS_TRAPVS
@ M68K_INS_TRAPVS
Definition: m68k.h:582
d68000_add_er_8
static void d68000_add_er_8(m68k_info *info)
Definition: M68KDisassembler.c:1248
d68000_neg_8
static void d68000_neg_8(m68k_info *info)
Definition: M68KDisassembler.c:2822
M68K_INS_TRAPT
@ M68K_INS_TRAPT
Definition: m68k.h:571
d68000_rol_s_16
static void d68000_rol_s_16(m68k_info *info)
Definition: M68KDisassembler.c:2989
M68K_INS_DBMI
@ M68K_INS_DBMI
Definition: m68k.h:287
d68000_sbcd_mm
static void d68000_sbcd_mm(m68k_info *info)
Definition: M68KDisassembler.c:3143
d68020_tst_pcdi_32
static void d68020_tst_pcdi_32(m68k_info *info)
Definition: M68KDisassembler.c:3362
d68000_lsr_r_8
static void d68000_lsr_r_8(m68k_info *info)
Definition: M68KDisassembler.c:2409
M68K_INS_FASIN
@ M68K_INS_FASIN
Definition: m68k.h:309
M68K_INS_SPL
@ M68K_INS_SPL
Definition: m68k.h:555
m68k_op_mem::disp
int16_t disp
displacement value
Definition: m68k.h:132
m68k_op_mem::offset
uint8_t offset
used for bf* instructions
Definition: m68k.h:136
M68K_INS_NEGX
@ M68K_INS_NEGX
Definition: m68k.h:510
d68020_bfset
static void d68020_bfset(m68k_info *info)
Definition: M68KDisassembler.c:1561
d68020_tst_pcix_16
static void d68020_tst_pcix_16(m68k_info *info)
Definition: M68KDisassembler.c:3339
d68000_andi_8
static void d68000_andi_8(m68k_info *info)
Definition: M68KDisassembler.c:1378
m68k_info::groups_count
uint8_t groups_count
Definition: M68KDisassembler.h:25
M68K_CPU_TYPE_68040
@ M68K_CPU_TYPE_68040
Definition: M68KDisassembler.c:130
d68020_cmpi_pcix_16
static void d68020_cmpi_pcix_16(m68k_info *info)
Definition: M68KDisassembler.c:1761
build_cas2
static void build_cas2(m68k_info *info, int size)
Definition: M68KDisassembler.c:981
d68000_pea
static void d68000_pea(m68k_info *info)
Definition: M68KDisassembler.c:2939
TYPE_68020
#define TYPE_68020
Definition: M68KDisassembler.c:103
LIMIT_CPU_TYPES
#define LIMIT_CPU_TYPES(info, ALLOWED_CPU_TYPES)
Definition: M68KDisassembler.c:293
opcode_struct::mask
uint mask
Definition: M68KDisassembler.c:233
M68K_AM_PCI_INDEX_8_BIT_DISP
@ M68K_AM_PCI_INDEX_8_BIT_DISP
Program Counter Indirect with Index - with 8-Bit Displacement.
Definition: m68k.h:98
d68020_cptrapcc_16
static void d68020_cptrapcc_16(m68k_info *info)
Definition: M68KDisassembler.c:2162
d68000_lsl_s_8
static void d68000_lsl_s_8(m68k_info *info)
Definition: M68KDisassembler.c:2429
M68K_INS_BFFFO
@ M68K_INS_BFFFO
Definition: m68k.h:254
M68010_PLUS
#define M68010_PLUS
Definition: M68KDisassembler.c:111
build_imm
static void build_imm(m68k_info *info, int opcode, int data)
Definition: M68KDisassembler.c:957
d68000_move_fr_usp
static void d68000_move_fr_usp(m68k_info *info)
Definition: M68KDisassembler.c:2553
d68000_bsr_8
static void d68000_bsr_8(m68k_info *info)
Definition: M68KDisassembler.c:1598
cs_m68k_op::register_bits
uint32_t register_bits
register bits for movem etc. (always in d0-d7, a0-a7, fp0 - fp7 order)
Definition: m68k.h:168
M68K_INS_TRAPEQ
@ M68K_INS_TRAPEQ
Definition: m68k.h:580
M68K_OP_FP_DOUBLE
@ M68K_OP_FP_DOUBLE
double precision Floating-Point operand
Definition: m68k.h:118
d68000_chk_16
static void d68000_chk_16(m68k_info *info)
Definition: M68KDisassembler.c:1658
mode
const char int mode
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:135
M68K_INS_BNE
@ M68K_INS_BNE
Definition: m68k.h:234
M68K_INS_SLE
@ M68K_INS_SLE
Definition: m68k.h:560
TYPE_68030
#define TYPE_68030
Definition: M68KDisassembler.c:104
M68K_INS_FSUB
@ M68K_INS_FSUB
Definition: m68k.h:449
instruction_struct
Definition: M68KDisassembler.c:240
d68000_jmp
static void d68000_jmp(m68k_info *info)
Definition: M68KDisassembler.c:2364
M68K_INS_FBF
@ M68K_INS_FBF
Definition: m68k.h:312
d68020_unpk_mm
static void d68020_unpk_mm(m68k_info *info)
Definition: M68KDisassembler.c:3397
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
M68K_INS_SUBX
@ M68K_INS_SUBX
Definition: m68k.h:566
d68000_asl_r_16
static void d68000_asl_r_16(m68k_info *info)
Definition: M68KDisassembler.c:1458
M68K_SIZE_TYPE_CPU
@ M68K_SIZE_TYPE_CPU
Definition: m68k.h:193
M68K_OP_FP_SINGLE
@ M68K_OP_FP_SINGLE
single precision Floating-Point operand
Definition: m68k.h:117
M68K_INS_BCLR
@ M68K_INS_BCLR
Definition: m68k.h:247
d68000_ext_16
static void d68000_ext_16(m68k_info *info)
Definition: M68KDisassembler.c:2348
build_chk2_cmp2
static void build_chk2_cmp2(m68k_info *info, int size)
Definition: M68KDisassembler.c:1021
M68K_INS_BSET
@ M68K_INS_BSET
Definition: m68k.h:248
d68000_lsr_s_32
static void d68000_lsr_s_32(m68k_info *info)
Definition: M68KDisassembler.c:2404
CS_MODE_M68K_060
@ CS_MODE_M68K_060
M68K 68060 mode.
Definition: capstone.h:123
read_imm_32
static unsigned int read_imm_32(m68k_info *info)
Definition: M68KDisassembler.c:308
M68K_INS_FTRAPF
@ M68K_INS_FTRAPF
Definition: m68k.h:455
M68K_INS_TRAPNE
@ M68K_INS_TRAPNE
Definition: m68k.h:579
M68K_INS_ASL
@ M68K_INS_ASL
Definition: m68k.h:226
d68000_rte
static void d68000_rte(m68k_info *info)
Definition: M68KDisassembler.c:3096
d68000_addx_mm_32
static void d68000_addx_mm_32(m68k_info *info)
Definition: M68KDisassembler.c:1343
set_insn_group
static void set_insn_group(m68k_info *info, m68k_group_type group)
Definition: M68KDisassembler.c:515
make_cpbcc_operand
static void make_cpbcc_operand(cs_m68k_op *op, int size, int displacement)
Definition: M68KDisassembler.c:1799
M68K_INS_AND
@ M68K_INS_AND
Definition: m68k.h:224
d68020_mull
static void d68020_mull(m68k_info *info)
Definition: M68KDisassembler.c:2779
d68040_move16_al_ai
static void d68040_move16_al_ai(m68k_info *info)
Definition: M68KDisassembler.c:2759
d68000_ror_ea
static void d68000_ror_ea(m68k_info *info)
Definition: M68KDisassembler.c:2979
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
d68000_movea_32
static void d68000_movea_32(m68k_info *info)
Definition: M68KDisassembler.c:2484
d68000_move_to_usp
static void d68000_move_to_usp(m68k_info *info)
Definition: M68KDisassembler.c:2569
d68020_cmpi_pcdi_8
static void d68020_cmpi_pcdi_8(m68k_info *info)
Definition: M68KDisassembler.c:1738
M68K_INS_EOR
@ M68K_INS_EOR
Definition: m68k.h:297
EXT_OUTER_DISPLACEMENT_LONG
#define EXT_OUTER_DISPLACEMENT_LONG(A)
Definition: M68KDisassembler.c:151
m68k_info::address_mask
unsigned int address_mask
Definition: M68KDisassembler.h:18
d68000_sbcd_rr
static void d68000_sbcd_rr(m68k_info *info)
Definition: M68KDisassembler.c:3138
d68000_eori_to_ccr
static void d68000_eori_to_ccr(m68k_info *info)
Definition: M68KDisassembler.c:2301
M68K_REG_CAAR
@ M68K_REG_CAAR
Definition: m68k.h:59
M68K_OP_BR_DISP
@ M68K_OP_BR_DISP
Branch displacement.
Definition: m68k.h:121
M68K_AM_REGI_ADDR_PRE_DEC
@ M68K_AM_REGI_ADDR_PRE_DEC
Register Indirect - Address with Predecrement.
Definition: m68k.h:87
M68K_INS_BLS
@ M68K_INS_BLS
Definition: m68k.h:231
d68000_cmpm_8
static void d68000_cmpm_8(m68k_info *info)
Definition: M68KDisassembler.c:1784
BIT_F
#define BIT_F(A)
Definition: M68KDisassembler.c:82
M68K_INS_CMP2
@ M68K_INS_CMP2
Definition: m68k.h:269
d68010_moves_16
static void d68010_moves_16(m68k_info *info)
Definition: M68KDisassembler.c:2688
MCInst::csh
cs_struct * csh
Definition: MCInst.h:97
M68K_INS_FLOGNP1
@ M68K_INS_FLOGNP1
Definition: m68k.h:391
d68000_swap
static void d68000_swap(m68k_info *info)
Definition: M68KDisassembler.c:3259
M68K_INS_FABS
@ M68K_INS_FABS
Definition: m68k.h:302
d68020_bfins
static void d68020_bfins(m68k_info *info)
Definition: M68KDisassembler.c:1546
M68K_CPU_TYPE_68000
@ M68K_CPU_TYPE_68000
Definition: M68KDisassembler.c:125
d68000_addx_rr_8
static void d68000_addx_rr_8(m68k_info *info)
Definition: M68KDisassembler.c:1318
d68000_subx_mm_16
static void d68000_subx_mm_16(m68k_info *info)
Definition: M68KDisassembler.c:3249
m68k_info::regs_read_count
uint8_t regs_read_count
Definition: M68KDisassembler.h:21
M68K_INS_FLOG10
@ M68K_INS_FLOG10
Definition: m68k.h:388
M68K_REG_USP
@ M68K_REG_USP
Definition: m68k.h:56
build_imm_ea
static void build_imm_ea(m68k_info *info, int opcode, uint8_t size, int imm)
Definition: M68KDisassembler.c:621
peek_imm_8
static unsigned int peek_imm_8(const m68k_info *info)
Definition: M68KDisassembler.c:301
d68000_ror_r_16
static void d68000_ror_r_16(m68k_info *info)
Definition: M68KDisassembler.c:2969
M68K_OP_BR_DISP_SIZE_LONG
@ M68K_OP_BR_DISP_SIZE_LONG
signed 32-bit displacement
Definition: m68k.h:145
grpc_status._async.code
code
Definition: grpcio_status/grpc_status/_async.py:34
d68000_ori_to_sr
static void d68000_ori_to_sr(m68k_info *info)
Definition: M68KDisassembler.c:2922
d68000_bcc_16
static void d68000_bcc_16(m68k_info *info)
Definition: M68KDisassembler.c:1478
M68K_AM_REGI_ADDR
@ M68K_AM_REGI_ADDR
Register Indirect - Address.
Definition: m68k.h:85
M68K_GRP_BRANCH_RELATIVE
@ M68K_GRP_BRANCH_RELATIVE
= CS_GRP_BRANCH_RELATIVE
Definition: m68k.h:601
M68K_AM_MEMI_POST_INDEX
@ M68K_AM_MEMI_POST_INDEX
Memory indirect - Postindex.
Definition: m68k.h:93
opcode_struct::match
uint match
Definition: M68KDisassembler.c:234
M68K_REG_PC
@ M68K_REG_PC
Definition: m68k.h:50
M68020_PLUS
#define M68020_PLUS
Definition: M68KDisassembler.c:115
M68K_INS_FLOGN
@ M68K_INS_FLOGN
Definition: m68k.h:390
make_int_16
static int make_int_16(int value)
Definition: M68KDisassembler.c:331
M68K_INS_BFSET
@ M68K_INS_BFSET
Definition: m68k.h:256
d68020_extb_32
static void d68020_extb_32(m68k_info *info)
Definition: M68KDisassembler.c:2358
M68K_INS_BHI
@ M68K_INS_BHI
Definition: m68k.h:230
m68k_read_disassembler_32
static unsigned int m68k_read_disassembler_32(const m68k_info *info, const uint64_t addr)
Definition: M68KDisassembler.c:166
d68000_sub_re_16
static void d68000_sub_re_16(m68k_info *info)
Definition: M68KDisassembler.c:3179
CS_MODE_M68K_010
@ CS_MODE_M68K_010
M68K 68010 mode.
Definition: capstone.h:119
DECL_SPEC
#define DECL_SPEC
Definition: M68KDisassembler.c:54
d68000_adda_16
static void d68000_adda_16(m68k_info *info)
Definition: M68KDisassembler.c:1278
build_imm_special_reg
static void build_imm_special_reg(m68k_info *info, int opcode, int imm, int size, m68k_reg reg)
Definition: M68KDisassembler.c:745
M68K_INS_BGT
@ M68K_INS_BGT
Definition: m68k.h:242
M68K_GRP_RET
@ M68K_GRP_RET
= CS_GRP_RET
Definition: m68k.h:599
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
M68K_INS_ILLEGAL
@ M68K_INS_ILLEGAL
Definition: m68k.h:490
d68000_addx_mm_16
static void d68000_addx_mm_16(m68k_info *info)
Definition: M68KDisassembler.c:1338
d68000_asr_r_16
static void d68000_asr_r_16(m68k_info *info)
Definition: M68KDisassembler.c:1423
M68K_INS_NOT
@ M68K_INS_NOT
Definition: m68k.h:512
m68k_info::regs_write
uint16_t regs_write[20]
Definition: M68KDisassembler.h:22
cs_struct
Definition: cs_priv.h:51
d68000_andi_to_ccr
static void d68000_andi_to_ccr(m68k_info *info)
Definition: M68KDisassembler.c:1393
d68020_cmpi_pcix_8
static void d68020_cmpi_pcix_8(m68k_info *info)
Definition: M68KDisassembler.c:1744
d68040_cpush
static void d68040_cpush(m68k_info *info)
Definition: M68KDisassembler.c:2208
d68000_or_er_8
static void d68000_or_er_8(m68k_info *info)
Definition: M68KDisassembler.c:2872
d68000_move_8
static void d68000_move_8(m68k_info *info)
Definition: M68KDisassembler.c:2464
d68000_bsr_16
static void d68000_bsr_16(m68k_info *info)
Definition: M68KDisassembler.c:1603
d68000_negx_8
static void d68000_negx_8(m68k_info *info)
Definition: M68KDisassembler.c:2837
EXT_FULL
#define EXT_FULL(A)
Definition: M68KDisassembler.c:135
d68000_asr_s_8
static void d68000_asr_s_8(m68k_info *info)
Definition: M68KDisassembler.c:1403
m68k_group_type
m68k_group_type
Group of M68K instructions.
Definition: m68k.h:596
d68000_eor_32
static void d68000_eor_32(m68k_info *info)
Definition: M68KDisassembler.c:2281
M68K_INS_PEA
@ M68K_INS_PEA
Definition: m68k.h:516
M68K_INS_FDBF
@ M68K_INS_FDBF
Definition: m68k.h:347
build_dbcc
static void build_dbcc(m68k_info *info, int size, int displacement)
Definition: M68KDisassembler.c:823
EXT_INDEX_LONG
#define EXT_INDEX_LONG(A)
Definition: M68KDisassembler.c:144
M68K_INS_SBCD
@ M68K_INS_SBCD
Definition: m68k.h:542
build_illegal
static void build_illegal(m68k_info *info, int data)
Definition: M68KDisassembler.c:971
M68K_INS_DBVC
@ M68K_INS_DBVC
Definition: m68k.h:284
d68000_subq_32
static void d68000_subq_32(m68k_info *info)
Definition: M68KDisassembler.c:3224
d68000_bra_16
static void d68000_bra_16(m68k_info *info)
Definition: M68KDisassembler.c:1577
d68000_movem_re_32
static void d68000_movem_re_32(m68k_info *info)
Definition: M68KDisassembler.c:2657
M68K_INS_MOVES
@ M68K_INS_MOVES
Definition: m68k.h:504
build_bcc
static void build_bcc(m68k_info *info, int size, int displacement)
Definition: M68KDisassembler.c:792
d68020_tst_pcix_8
static void d68020_tst_pcix_8(m68k_info *info)
Definition: M68KDisassembler.c:3310
cs_m68k
The M68K instruction and it's operands.
Definition: m68k.h:207
cs_m68k::op_count
uint8_t op_count
number of operands for the instruction
Definition: m68k.h:211
cs_m68k_op::mem
m68k_op_mem mem
data when operand is targeting memory
Definition: m68k.h:166
int16_t
signed short int16_t
Definition: stdint-msvc2008.h:76
TYPE_68040
#define TYPE_68040
Definition: M68KDisassembler.c:105
M68K_INS_DBVS
@ M68K_INS_DBVS
Definition: m68k.h:285
d68000_muls
static void d68000_muls(m68k_info *info)
Definition: M68KDisassembler.c:2769
d68000_ori_16
static void d68000_ori_16(m68k_info *info)
Definition: M68KDisassembler.c:2907
xds_interop_client.int
int
Definition: xds_interop_client.py:113
d68000_move_fr_sr
static void d68000_move_fr_sr(m68k_info *info)
Definition: M68KDisassembler.c:2523
s_trap_lut
static m68k_insn s_trap_lut[]
Definition: M68KDisassembler.c:282
fmovem
static void fmovem(m68k_info *info, uint extension)
Definition: M68KDisassembler.c:1902
M68K_INS_ROXL
@ M68K_INS_ROXL
Definition: m68k.h:535
d68000_cmpm_32
static void d68000_cmpm_32(m68k_info *info)
Definition: M68KDisassembler.c:1794
d68000_asl_s_8
static void d68000_asl_s_8(m68k_info *info)
Definition: M68KDisassembler.c:1438
M68K_INS_TRAPGT
@ M68K_INS_TRAPGT
Definition: m68k.h:587
M68K_INS_SEQ
@ M68K_INS_SEQ
Definition: m68k.h:552
M68K_CPU_SIZE_WORD
@ M68K_CPU_SIZE_WORD
2 bytes in size
Definition: m68k.h:177
d68000_roxr_s_8
static void d68000_roxr_s_8(m68k_info *info)
Definition: M68KDisassembler.c:3019
M68K_AM_REG_DIRECT_DATA
@ M68K_AM_REG_DIRECT_DATA
Register Direct - Data.
Definition: m68k.h:82
d68000_roxl_ea
static void d68000_roxl_ea(m68k_info *info)
Definition: M68KDisassembler.c:3084
d68000_unlk
static void d68000_unlk(m68k_info *info)
Definition: M68KDisassembler.c:3380
M68K_INS_BRA
@ M68K_INS_BRA
Definition: m68k.h:244
cs_m68k_op::reg_pair
struct cs_m68k_op::@152::@154 reg_pair
SStream
Definition: SStream.h:9
update_am_reg_list
static void update_am_reg_list(m68k_info *info, cs_m68k_op *op, int write)
Definition: M68KDisassembler.c:3878
d68000_ror_r_8
static void d68000_ror_r_8(m68k_info *info)
Definition: M68KDisassembler.c:2964
M68K_INS_FTWOTOX
@ M68K_INS_FTWOTOX
Definition: m68k.h:488
build_pi_pi
static void build_pi_pi(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:729
d68000_lea
static void d68000_lea(m68k_info *info)
Definition: M68KDisassembler.c:2378
M68K_INS_FSQRT
@ M68K_INS_FSQRT
Definition: m68k.h:414
d68020_cas_32
static void d68020_cas_32(m68k_info *info)
Definition: M68KDisassembler.c:1642
read_imm_8
static unsigned int read_imm_8(m68k_info *info)
Definition: M68KDisassembler.c:306
M68K_INS_SGT
@ M68K_INS_SGT
Definition: m68k.h:559
M68K_INS_BCS
@ M68K_INS_BCS
Definition: m68k.h:233
d68000_andi_32
static void d68000_andi_32(m68k_info *info)
Definition: M68KDisassembler.c:1388
m68k_info
Definition: M68KDisassembler.h:10
M68K_INS_SCS
@ M68K_INS_SCS
Definition: m68k.h:549
d68000_lsl_r_16
static void d68000_lsl_r_16(m68k_info *info)
Definition: M68KDisassembler.c:2449
d68000_roxl_r_8
static void d68000_roxl_r_8(m68k_info *info)
Definition: M68KDisassembler.c:3069
M68K_INS_ROL
@ M68K_INS_ROL
Definition: m68k.h:533
M68K_INS_CMPA
@ M68K_INS_CMPA
Definition: m68k.h:266
M68K_INS_TRAPF
@ M68K_INS_TRAPF
Definition: m68k.h:572
m68k_info::ir
unsigned int ir
Definition: M68KDisassembler.h:16
M68K_INS_MOVEP
@ M68K_INS_MOVEP
Definition: m68k.h:502
d68020_unpk_rr
static void d68020_unpk_rr(m68k_info *info)
Definition: M68KDisassembler.c:3391
m68k_op_mem::bitfield
uint8_t bitfield
set to true if the two values below should be used
Definition: m68k.h:134
d68000_asr_r_8
static void d68000_asr_r_8(m68k_info *info)
Definition: M68KDisassembler.c:1418
d68000_lsr_ea
static void d68000_lsr_ea(m68k_info *info)
Definition: M68KDisassembler.c:2424
instruction_struct::word2_mask
uint word2_mask
Definition: M68KDisassembler.c:242
s_dbcc_lut
static m68k_insn s_dbcc_lut[]
Definition: M68KDisassembler.c:268
d68000_rol_r_16
static void d68000_rol_r_16(m68k_info *info)
Definition: M68KDisassembler.c:3004
d68020_tst_pcdi_16
static void d68020_tst_pcdi_16(m68k_info *info)
Definition: M68KDisassembler.c:3333
build_re_gen_1
static void build_re_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
Definition: M68KDisassembler.c:535
d68000_addi_16
static void d68000_addi_16(m68k_info *info)
Definition: M68KDisassembler.c:1293
M68K_INS_BPL
@ M68K_INS_BPL
Definition: m68k.h:238
d68000_divs
static void d68000_divs(m68k_info *info)
Definition: M68KDisassembler.c:2224
M68040_PLUS
#define M68040_PLUS
Definition: M68KDisassembler.c:121
build_ea_a
static void build_ea_a(m68k_info *info, int opcode, uint8_t size)
Definition: M68KDisassembler.c:701
setup.v
v
Definition: third_party/bloaty/third_party/capstone/bindings/python/setup.py:42
M68K_REG_ISP
@ M68K_REG_ISP
Definition: m68k.h:61
d68000_rtr
static void d68000_rtr(m68k_info *info)
Definition: M68KDisassembler.c:3126
BIT_3
#define BIT_3(A)
Definition: M68KDisassembler.c:70
d68000_not_16
static void d68000_not_16(m68k_info *info)
Definition: M68KDisassembler.c:2862
M68K_CPU_TYPE_68EC020
@ M68K_CPU_TYPE_68EC020
Definition: M68KDisassembler.c:127
M68K_REG_CCR
@ M68K_REG_CCR
Definition: m68k.h:53
M68K_INS_FINTRZ
@ M68K_INS_FINTRZ
Definition: m68k.h:387
M68K_INS_FCOS
@ M68K_INS_FCOS
Definition: m68k.h:345
d68000_cmp_16
static void d68000_cmp_16(m68k_info *info)
Definition: M68KDisassembler.c:1713
M68K_INS_BCHG
@ M68K_INS_BCHG
Definition: m68k.h:246
d68000_asl_s_32
static void d68000_asl_s_32(m68k_info *info)
Definition: M68KDisassembler.c:1448
M68K_INS_DBGE
@ M68K_INS_DBGE
Definition: m68k.h:288
d68000_asr_s_16
static void d68000_asr_s_16(m68k_info *info)
Definition: M68KDisassembler.c:1408
d68020_chk2_cmp2_8
static void d68020_chk2_cmp2_8(m68k_info *info)
Definition: M68KDisassembler.c:1669
EXT_BASE_DISPLACEMENT_PRESENT
#define EXT_BASE_DISPLACEMENT_PRESENT(A)
Definition: M68KDisassembler.c:146
build_movem_re
static void build_movem_re(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:924
instruction_struct::instruction
void(* instruction)(m68k_info *info)
Definition: M68KDisassembler.c:241
M68K_INS_TRAPGE
@ M68K_INS_TRAPGE
Definition: m68k.h:585
TYPE_68000
#define TYPE_68000
Definition: M68KDisassembler.c:101
EXT_INDEX_SCALE
#define EXT_INDEX_SCALE(A)
Definition: M68KDisassembler.c:143
d68000_subx_rr_8
static void d68000_subx_rr_8(m68k_info *info)
Definition: M68KDisassembler.c:3229
d68000_tst_16
static void d68000_tst_16(m68k_info *info)
Definition: M68KDisassembler.c:3322
M68K_INS_BGE
@ M68K_INS_BGE
Definition: m68k.h:240
d68000_adda_32
static void d68000_adda_32(m68k_info *info)
Definition: M68KDisassembler.c:1283
M68K_INS_BLT
@ M68K_INS_BLT
Definition: m68k.h:241
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
d68000_ori_to_ccr
static void d68000_ori_to_ccr(m68k_info *info)
Definition: M68KDisassembler.c:2917
d68020_cpbcc_16
static void d68020_cpbcc_16(m68k_info *info)
Definition: M68KDisassembler.c:1807
d68020_cpsave
static void d68020_cpsave(m68k_info *info)
Definition: M68KDisassembler.c:2126
read_imm_16
static unsigned int read_imm_16(m68k_info *info)
Definition: M68KDisassembler.c:307
peek_imm_64
static unsigned long long peek_imm_64(const m68k_info *info)
Definition: M68KDisassembler.c:304
M68K_CPU_SIZE_BYTE
@ M68K_CPU_SIZE_BYTE
1 byte in size
Definition: m68k.h:176
M68K_REG_A0
@ M68K_REG_A0
Definition: m68k.h:32
bits
OPENSSL_EXPORT ASN1_BIT_STRING * bits
Definition: x509v3.h:482
d68000_or_er_16
static void d68000_or_er_16(m68k_info *info)
Definition: M68KDisassembler.c:2877
g_instruction_table
static instruction_struct g_instruction_table[0x10000]
Definition: M68KDisassembler.c:251
M68K_REG_TC
@ M68K_REG_TC
Definition: m68k.h:62
m68k_op_mem::base_reg
m68k_reg base_reg
base register (or M68K_REG_INVALID if irrelevant)
Definition: m68k.h:127
d68000_movem_er_16
static void d68000_movem_er_16(m68k_info *info)
Definition: M68KDisassembler.c:2642
d68000_exg_da
static void d68000_exg_da(m68k_info *info)
Definition: M68KDisassembler.c:2332
d68020_cmpi_pcdi_32
static void d68020_cmpi_pcdi_32(m68k_info *info)
Definition: M68KDisassembler.c:1772
d68000_abcd_rr
static void d68000_abcd_rr(m68k_info *info)
Definition: M68KDisassembler.c:1238
M68K_INS_FACOS
@ M68K_INS_FACOS
Definition: m68k.h:305
d68000_tas
static void d68000_tas(m68k_info *info)
Definition: M68KDisassembler.c:3264
M68K_OPERAND_COUNT
#define M68K_OPERAND_COUNT
Definition: m68k.h:17
M68K_REG_DTT1
@ M68K_REG_DTT1
Definition: m68k.h:66
d68000_bset_r
static void d68000_bset_r(m68k_info *info)
Definition: M68KDisassembler.c:1588
m68k_info::inst
MCInst * inst
Definition: M68KDisassembler.h:14
d68000_lsl_r_8
static void d68000_lsl_r_8(m68k_info *info)
Definition: M68KDisassembler.c:2444
d68000_link_16
static void d68000_link_16(m68k_info *info)
Definition: M68KDisassembler.c:2383
d68000_roxr_s_32
static void d68000_roxr_s_32(m68k_info *info)
Definition: M68KDisassembler.c:3029
M68K_INS_EXT
@ M68K_INS_EXT
Definition: m68k.h:300
d68000_and_re_8
static void d68000_and_re_8(m68k_info *info)
Definition: M68KDisassembler.c:1363
build_opcode_table
static void build_opcode_table(void)
Definition: M68KDisassembler.c:3788
M68K_INS_LSR
@ M68K_INS_LSR
Definition: m68k.h:497
d68000_bset_s
static void d68000_bset_s(m68k_info *info)
Definition: M68KDisassembler.c:1593
d68000_trapv
static void d68000_trapv(m68k_info *info)
Definition: M68KDisassembler.c:3294
d68000_ror_s_8
static void d68000_ror_s_8(m68k_info *info)
Definition: M68KDisassembler.c:2949
M68K_INS_RTR
@ M68K_INS_RTR
Definition: m68k.h:540
CS_MODE_M68K_020
@ CS_MODE_M68K_020
M68K 68020 mode.
Definition: capstone.h:120
CS_MODE_M68K_040
@ CS_MODE_M68K_040
M68K 68040 mode.
Definition: capstone.h:122
d68010_move_fr_ccr
static void d68010_move_fr_ccr(m68k_info *info)
Definition: M68KDisassembler.c:2504
make_int_8
static int make_int_8(int value)
Definition: M68KDisassembler.c:326
m68k
Definition: test_winkernel.cpp:67
d68000_addx_mm_8
static void d68000_addx_mm_8(m68k_info *info)
Definition: M68KDisassembler.c:1333
M68K_INS_FGETMAN
@ M68K_INS_FGETMAN
Definition: m68k.h:385
M68K_INS_TRAPV
@ M68K_INS_TRAPV
Definition: m68k.h:570
d68040_move16_ai_al
static void d68040_move16_ai_al(m68k_info *info)
Definition: M68KDisassembler.c:2749
d68000_addi_32
static void d68000_addi_32(m68k_info *info)
Definition: M68KDisassembler.c:1298
d68000_negx_16
static void d68000_negx_16(m68k_info *info)
Definition: M68KDisassembler.c:2842
M68K_INS_OR
@ M68K_INS_OR
Definition: m68k.h:513
d68000_rol_s_8
static void d68000_rol_s_8(m68k_info *info)
Definition: M68KDisassembler.c:2984
d68010_movec
static void d68010_movec(m68k_info *info)
Definition: M68KDisassembler.c:2585
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
d68000_cmp_32
static void d68000_cmp_32(m68k_info *info)
Definition: M68KDisassembler.c:1718
d68000_scc
static void d68000_scc(m68k_info *info)
Definition: M68KDisassembler.c:3148
d68000_addx_rr_32
static void d68000_addx_rr_32(m68k_info *info)
Definition: M68KDisassembler.c:1328
M68K_INS_ABCD
@ M68K_INS_ABCD
Definition: m68k.h:218
d68020_cas2_32
static void d68020_cas2_32(m68k_info *info)
Definition: M68KDisassembler.c:1653
d68010_moves_32
static void d68010_moves_32(m68k_info *info)
Definition: M68KDisassembler.c:2695
M68K_AM_BRANCH_DISPLACEMENT
@ M68K_AM_BRANCH_DISPLACEMENT
Address as displacement from (PC+2) used by branches.
Definition: m68k.h:108
M68K_REG_FP0
@ M68K_REG_FP0
Definition: m68k.h:41
cs_m68k::operands
cs_m68k_op operands[M68K_OPERAND_COUNT]
operands for this instruction.
Definition: m68k.h:209
M68K_INS_TRAP
@ M68K_INS_TRAP
Definition: m68k.h:569
M68K_INS_BEQ
@ M68K_INS_BEQ
Definition: m68k.h:235
cs_m68k_op::reg
m68k_reg reg
register value for REG operand
Definition: m68k.h:159
uint
unsigned int uint
Definition: bloaty/third_party/zlib/examples/gzlog.c:242
d68000_subx_rr_16
static void d68000_subx_rr_16(m68k_info *info)
Definition: M68KDisassembler.c:3234
CS_MODE_M68K_030
@ CS_MODE_M68K_030
M68K 68030 mode.
Definition: capstone.h:121
M68K_INS_DBLS
@ M68K_INS_DBLS
Definition: m68k.h:279
d68000_ror_s_16
static void d68000_ror_s_16(m68k_info *info)
Definition: M68KDisassembler.c:2954
d68000_and_er_8
static void d68000_and_er_8(m68k_info *info)
Definition: M68KDisassembler.c:1348
rm
static bool rm(upb_table *t, lookupkey_t key, upb_value *val, upb_tabkey *removed, uint32_t hash, eqlfunc_t *eql)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:1477
M68K_INS_SUBQ
@ M68K_INS_SUBQ
Definition: m68k.h:565
M68K_OP_REG_PAIR
@ M68K_OP_REG_PAIR
Register pair in the same op (upper 4 bits for first reg, lower for second)
Definition: m68k.h:120
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
d68000_eori_32
static void d68000_eori_32(m68k_info *info)
Definition: M68KDisassembler.c:2296
M68K_CPU_TYPE_68030
@ M68K_CPU_TYPE_68030
Definition: M68KDisassembler.c:129
m68k_insn
m68k_insn
M68K instruction.
Definition: m68k.h:215
M68K_INS_SUB
@ M68K_INS_SUB
Definition: m68k.h:562
d68000_bchg_r
static void d68000_bchg_r(m68k_info *info)
Definition: M68KDisassembler.c:1489
d68040_move16_pi_al
static void d68040_move16_pi_al(m68k_info *info)
Definition: M68KDisassembler.c:2729
M68K_INS_TRAPCS
@ M68K_INS_TRAPCS
Definition: m68k.h:577
d68000_bcc_8
static void d68000_bcc_8(m68k_info *info)
Definition: M68KDisassembler.c:1473
M68K_AM_ABSOLUTE_DATA_LONG
@ M68K_AM_ABSOLUTE_DATA_LONG
Absolute Data Addressing - Long.
Definition: m68k.h:105
M68K_REG_URP
@ M68K_REG_URP
Definition: m68k.h:68
M68K_INS_BKPT
@ M68K_INS_BKPT
Definition: m68k.h:258
d
static const fe d
Definition: curve25519_tables.h:19
qsort
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
Definition: qsort.h:130
d68020_chk2_cmp2_16
static void d68020_chk2_cmp2_16(m68k_info *info)
Definition: M68KDisassembler.c:1675
opcode_struct::opcode_handler
void(* opcode_handler)(m68k_info *info)
Definition: M68KDisassembler.c:232
M68K_INS_CMPI
@ M68K_INS_CMPI
Definition: m68k.h:267
M68K_INS_ROR
@ M68K_INS_ROR
Definition: m68k.h:534
d68000_subx_mm_32
static void d68000_subx_mm_32(m68k_info *info)
Definition: M68KDisassembler.c:3254
EXT_OUTER_DISPLACEMENT_PRESENT
#define EXT_OUTER_DISPLACEMENT_PRESENT(A)
Definition: M68KDisassembler.c:149
M68K_INS_CALLM
@ M68K_INS_CALLM
Definition: m68k.h:259
d68020_cmpi_pcdi_16
static void d68020_cmpi_pcdi_16(m68k_info *info)
Definition: M68KDisassembler.c:1755
d68000_bclr_s
static void d68000_bclr_s(m68k_info *info)
Definition: M68KDisassembler.c:1504
M68K_REG_DFC
@ M68K_REG_DFC
Definition: m68k.h:55
build_rr
static void build_rr(m68k_info *info, int opcode, uint8_t size, int imm)
Definition: M68KDisassembler.c:580
M68K_INS_DBCC
@ M68K_INS_DBCC
Definition: m68k.h:280
M68K_INS_TRAPLT
@ M68K_INS_TRAPLT
Definition: m68k.h:586
EXT_INDEX_REGISTER_PRESENT
#define EXT_INDEX_REGISTER_PRESENT(A)
Definition: M68KDisassembler.c:138
BIT_1
#define BIT_1(A)
Definition: M68KDisassembler.c:68
d68020_trapcc_16
static void d68020_trapcc_16(m68k_info *info)
Definition: M68KDisassembler.c:3282
d68000_btst_s
static void d68000_btst_s(m68k_info *info)
Definition: M68KDisassembler.c:1619
build_re_1
static void build_re_1(m68k_info *info, int opcode, uint8_t size)
Definition: M68KDisassembler.c:555
build_mm
static void build_mm(m68k_info *info, int opcode, uint8_t size, int imm)
Definition: M68KDisassembler.c:670
M68K_OP_IMM
@ M68K_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: m68k.h:115
M68K_INS_LEA
@ M68K_INS_LEA
Definition: m68k.h:493
d68020_tst_pcdi_8
static void d68020_tst_pcdi_8(m68k_info *info)
Definition: M68KDisassembler.c:3304
M68K_INS_BTST
@ M68K_INS_BTST
Definition: m68k.h:249
d68020_tst_i_8
static void d68020_tst_i_8(m68k_info *info)
Definition: M68KDisassembler.c:3316
d68000_sub_er_32
static void d68000_sub_er_32(m68k_info *info)
Definition: M68KDisassembler.c:3169
build_link
static void build_link(m68k_info *info, int disp, int size)
Definition: M68KDisassembler.c:1066
d68000_and_er_16
static void d68000_and_er_16(m68k_info *info)
Definition: M68KDisassembler.c:1353
d68000_lsr_s_8
static void d68000_lsr_s_8(m68k_info *info)
Definition: M68KDisassembler.c:2394
modes
single_dict modes[]
Definition: capstone_test.c:19
d68000_stop
static void d68000_stop(m68k_info *info)
Definition: M68KDisassembler.c:3154
d68000_addq_32
static void d68000_addq_32(m68k_info *info)
Definition: M68KDisassembler.c:1313
update_reg_list_regbits
static void update_reg_list_regbits(m68k_info *info, cs_m68k_op *op, int write)
Definition: M68KDisassembler.c:3925
d68040_move16_al_pi
static void d68040_move16_al_pi(m68k_info *info)
Definition: M68KDisassembler.c:2739
build_movem_er
static void build_movem_er(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:942
d68000_not_32
static void d68000_not_32(m68k_info *info)
Definition: M68KDisassembler.c:2867
build_trap
static void build_trap(m68k_info *info, int size, int immediate)
Definition: M68KDisassembler.c:797
d68020_cptrapcc_32
static void d68020_cptrapcc_32(m68k_info *info)
Definition: M68KDisassembler.c:2185
M68K_INS_FMOD
@ M68K_INS_FMOD
Definition: m68k.h:392
d68000_lsr_r_32
static void d68000_lsr_r_32(m68k_info *info)
Definition: M68KDisassembler.c:2419
d68000_trap
static void d68000_trap(m68k_info *info)
Definition: M68KDisassembler.c:3269
d68000_and_re_16
static void d68000_and_re_16(m68k_info *info)
Definition: M68KDisassembler.c:1368
d68000_eor_8
static void d68000_eor_8(m68k_info *info)
Definition: M68KDisassembler.c:2271
M68K_INS_TRAPLE
@ M68K_INS_TRAPLE
Definition: m68k.h:588
build_init_op
static cs_m68k * build_init_op(m68k_info *info, int opcode, int count, int size)
Definition: M68KDisassembler.c:520
M68K_REG_SFC
@ M68K_REG_SFC
Definition: m68k.h:54
M68K_INS_SLS
@ M68K_INS_SLS
Definition: m68k.h:546
M68K_INS_FATANH
@ M68K_INS_FATANH
Definition: m68k.h:311
d68010_bkpt
static void d68010_bkpt(m68k_info *info)
Definition: M68KDisassembler.c:1509
value
const char * value
Definition: hpack_parser_table.cc:165
M68K_INS_DBT
@ M68K_INS_DBT
Definition: m68k.h:276
peek_imm_32
static unsigned int peek_imm_32(const m68k_info *info)
Definition: M68KDisassembler.c:303
csh
size_t csh
Definition: capstone.h:71
M68K_INS_FNEG
@ M68K_INS_FNEG
Definition: m68k.h:401
opcode_struct::match2
uint match2
Definition: M68KDisassembler.c:237
d68020_callm
static void d68020_callm(m68k_info *info)
Definition: M68KDisassembler.c:1624
M68K_GRP_JUMP
@ M68K_GRP_JUMP
= CS_GRP_JUMP
Definition: m68k.h:598
instruction_struct::word2_match
uint word2_match
Definition: M68KDisassembler.c:243
peek_imm_16
static unsigned int peek_imm_16(const m68k_info *info)
Definition: M68KDisassembler.c:302
M68K_INS_FTAN
@ M68K_INS_FTAN
Definition: m68k.h:452
MCInst
Definition: MCInst.h:88
M68K_INS_INVALID
@ M68K_INS_INVALID
Definition: m68k.h:216
d68000_rol_r_32
static void d68000_rol_r_32(m68k_info *info)
Definition: M68KDisassembler.c:3009
M68K_CPU_TYPE_68010
@ M68K_CPU_TYPE_68010
Definition: M68KDisassembler.c:126
d68000_rts
static void d68000_rts(m68k_info *info)
Definition: M68KDisassembler.c:3132
d68000_cmpi_32
static void d68000_cmpi_32(m68k_info *info)
Definition: M68KDisassembler.c:1767
d68000_sub_er_8
static void d68000_sub_er_8(m68k_info *info)
Definition: M68KDisassembler.c:3159
M68K_REG_ITT1
@ M68K_REG_ITT1
Definition: m68k.h:64
d68000_or_er_32
static void d68000_or_er_32(m68k_info *info)
Definition: M68KDisassembler.c:2882
m68k_op_br_disp::disp
int32_t disp
displacement value
Definition: m68k.h:149
m68k_read_safe_64
static uint64_t m68k_read_safe_64(const m68k_info *info, const uint64_t address)
Definition: M68KDisassembler.c:206
M68K_INS_TRAPLS
@ M68K_INS_TRAPLS
Definition: m68k.h:574
valid_ea
static int valid_ea(uint opcode, uint mask)
Definition: M68KDisassembler.c:3726
d68000_addq_8
static void d68000_addq_8(m68k_info *info)
Definition: M68KDisassembler.c:1303
d68000_or_re_32
static void d68000_or_re_32(m68k_info *info)
Definition: M68KDisassembler.c:2897
M68K_INS_BLE
@ M68K_INS_BLE
Definition: m68k.h:243
EXT_BASE_DISPLACEMENT_LONG
#define EXT_BASE_DISPLACEMENT_LONG(A)
Definition: M68KDisassembler.c:148
build_3bit_ea
static void build_3bit_ea(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:654
d68000_invalid
static void d68000_invalid(m68k_info *info)
Definition: M68KDisassembler.c:1218
d68000_movem_re_16
static void d68000_movem_re_16(m68k_info *info)
Definition: M68KDisassembler.c:2652
d68000_lsr_s_16
static void d68000_lsr_s_16(m68k_info *info)
Definition: M68KDisassembler.c:2399
M68K_INS_BFCHG
@ M68K_INS_BFCHG
Definition: m68k.h:250
d68000_asl_r_32
static void d68000_asl_r_32(m68k_info *info)
Definition: M68KDisassembler.c:1463
d68000_movea_16
static void d68000_movea_16(m68k_info *info)
Definition: M68KDisassembler.c:2479
d68000_add_er_32
static void d68000_add_er_32(m68k_info *info)
Definition: M68KDisassembler.c:1258
M68K_AM_PCI_DISP
@ M68K_AM_PCI_DISP
Program Counter Indirect - with Displacement.
Definition: m68k.h:96
M68K_INS_FETOXM1
@ M68K_INS_FETOXM1
Definition: m68k.h:383
M68K_GRP_IRET
@ M68K_GRP_IRET
= CS_GRP_IRET
Definition: m68k.h:600
build_move16
static void build_move16(m68k_info *info, int data[2], int modes[2])
Definition: M68KDisassembler.c:1044
M68K_INS_FREM
@ M68K_INS_FREM
Definition: m68k.h:405
m68k_read_disassembler_16
static unsigned int m68k_read_disassembler_16(const m68k_info *info, const uint64_t addr)
Definition: M68KDisassembler.c:159
M68K_REG_FPSR
@ M68K_REG_FPSR
Definition: m68k.h:72
d68000_cmp_8
static void d68000_cmp_8(m68k_info *info)
Definition: M68KDisassembler.c:1708
d68000_movep_re_16
static void d68000_movep_re_16(m68k_info *info)
Definition: M68KDisassembler.c:2662
M68K_AM_AREGI_INDEX_8_BIT_DISP
@ M68K_AM_AREGI_INDEX_8_BIT_DISP
Address Register Indirect With Index- 8-bit displacement.
Definition: m68k.h:90
M68K_INS_SWAP
@ M68K_INS_SWAP
Definition: m68k.h:567
M68K_INS_LINK
@ M68K_INS_LINK
Definition: m68k.h:494
M68K_INS_FINT
@ M68K_INS_FINT
Definition: m68k.h:386
d68000_andi_to_sr
static void d68000_andi_to_sr(m68k_info *info)
Definition: M68KDisassembler.c:1398
d68000_clr_8
static void d68000_clr_8(m68k_info *info)
Definition: M68KDisassembler.c:1693
M68K_INS_SNE
@ M68K_INS_SNE
Definition: m68k.h:551
upload.group
group
Definition: bloaty/third_party/googletest/googlemock/scripts/upload.py:397
g_3bit_qdata_table
static uint g_3bit_qdata_table[8]
Definition: M68KDisassembler.c:254
d68000_exg_aa
static void d68000_exg_aa(m68k_info *info)
Definition: M68KDisassembler.c:2316
M68K_INS_FATAN
@ M68K_INS_FATAN
Definition: m68k.h:310
M68K_INS_ANDI
@ M68K_INS_ANDI
Definition: m68k.h:225
d68000_movem_er_32
static void d68000_movem_er_32(m68k_info *info)
Definition: M68KDisassembler.c:2647
d68000_eori_16
static void d68000_eori_16(m68k_info *info)
Definition: M68KDisassembler.c:2291
d68000_asl_r_8
static void d68000_asl_r_8(m68k_info *info)
Definition: M68KDisassembler.c:1453
build_movep_re
static void build_movep_re(m68k_info *info, int size)
Definition: M68KDisassembler.c:1121
d68000_illegal
static void d68000_illegal(m68k_info *info)
Definition: M68KDisassembler.c:1223
d68000_roxr_r_16
static void d68000_roxr_r_16(m68k_info *info)
Definition: M68KDisassembler.c:3039
M68K_INS_SVC
@ M68K_INS_SVC
Definition: m68k.h:553
d68000_bclr_r
static void d68000_bclr_r(m68k_info *info)
Definition: M68KDisassembler.c:1499
M68K_INS_STOP
@ M68K_INS_STOP
Definition: m68k.h:561
M68K_INS_DBLE
@ M68K_INS_DBLE
Definition: m68k.h:291
M68K_INS_ST
@ M68K_INS_ST
Definition: m68k.h:543
M68K_REG_DTT0
@ M68K_REG_DTT0
Definition: m68k.h:65
get_ea_mode_op
static void get_ea_mode_op(m68k_info *info, cs_m68k_op *op, uint instruction, uint size)
Definition: M68KDisassembler.c:421
M68K_INS_FRESTORE
@ M68K_INS_FRESTORE
Definition: m68k.h:406
d68000_roxl_s_16
static void d68000_roxl_s_16(m68k_info *info)
Definition: M68KDisassembler.c:3059
d68000_neg_32
static void d68000_neg_32(m68k_info *info)
Definition: M68KDisassembler.c:2832
count
int * count
Definition: bloaty/third_party/googletest/googlemock/test/gmock_stress_test.cc:96
d68000_add_re_8
static void d68000_add_re_8(m68k_info *info)
Definition: M68KDisassembler.c:1263
d68000_addi_8
static void d68000_addi_8(m68k_info *info)
Definition: M68KDisassembler.c:1288
M68K_INS_BFTST
@ M68K_INS_BFTST
Definition: m68k.h:257
build_d
static void build_d(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:884
BIT_B
#define BIT_B(A)
Definition: M68KDisassembler.c:78
build_relative_branch
static void build_relative_branch(m68k_info *info, int opcode, int size, int displacement)
Definition: M68KDisassembler.c:762
d68000_suba_16
static void d68000_suba_16(m68k_info *info)
Definition: M68KDisassembler.c:3189
d68010_moves_8
static void d68010_moves_8(m68k_info *info)
Definition: M68KDisassembler.c:2682
d68000_1111
static void d68000_1111(m68k_info *info)
Definition: M68KDisassembler.c:1233
d68000_roxr_s_16
static void d68000_roxr_s_16(m68k_info *info)
Definition: M68KDisassembler.c:3024
d68000_dbcc
static void d68000_dbcc(m68k_info *info)
Definition: M68KDisassembler.c:2219
g_opcode_info
static opcode_struct g_opcode_info[]
Definition: M68KDisassembler.c:3422
d68020_cpbcc_32
static void d68020_cpbcc_32(m68k_info *info)
Definition: M68KDisassembler.c:1825
m68k_setup_internals
static void m68k_setup_internals(m68k_info *info, MCInst *inst, unsigned int pc, unsigned int cpu_type)
Definition: M68KDisassembler.c:3974
EXT_8BIT_DISPLACEMENT
#define EXT_8BIT_DISPLACEMENT(A)
Definition: M68KDisassembler.c:134
d68000_exg_dd
static void d68000_exg_dd(m68k_info *info)
Definition: M68KDisassembler.c:2311
d68000_roxl_r_32
static void d68000_roxl_r_32(m68k_info *info)
Definition: M68KDisassembler.c:3079
m68k_info::regs_read
uint16_t regs_read[20]
Definition: M68KDisassembler.h:20
d68000_movem_pd_16
static void d68000_movem_pd_16(m68k_info *info)
Definition: M68KDisassembler.c:2632
M68K_INS_BVS
@ M68K_INS_BVS
Definition: m68k.h:237
BIT_5
#define BIT_5(A)
Definition: M68KDisassembler.c:72
M68K_FPU_SIZE_SINGLE
@ M68K_FPU_SIZE_SINGLE
4 byte in size (single float)
Definition: m68k.h:184
M68K_REG_INVALID
@ M68K_REG_INVALID
Definition: m68k.h:21
d68000_or_re_16
static void d68000_or_re_16(m68k_info *info)
Definition: M68KDisassembler.c:2892
d68000_mulu
static void d68000_mulu(m68k_info *info)
Definition: M68KDisassembler.c:2774
m68k_read_safe_16
static unsigned int m68k_read_safe_16(const m68k_info *info, const uint64_t address)
Definition: M68KDisassembler.c:188
next
AllocList * next[kMaxLevel]
Definition: abseil-cpp/absl/base/internal/low_level_alloc.cc:100
M68K_INS_SHI
@ M68K_INS_SHI
Definition: m68k.h:545
M68K_INS_EORI
@ M68K_INS_EORI
Definition: m68k.h:298
fix_build_deps.r
r
Definition: fix_build_deps.py:491
M68K_INS_MOVEQ
@ M68K_INS_MOVEQ
Definition: m68k.h:503
M68K_INS_ADDA
@ M68K_INS_ADDA
Definition: m68k.h:220
BIT_1F
#define BIT_1F(A)
Definition: M68KDisassembler.c:98
d68000_roxr_ea
static void d68000_roxr_ea(m68k_info *info)
Definition: M68KDisassembler.c:3049
M68K_INS_FSIN
@ M68K_INS_FSIN
Definition: m68k.h:411
d68000_move_to_ccr
static void d68000_move_to_ccr(m68k_info *info)
Definition: M68KDisassembler.c:2489
build_cpush_cinv
static void build_cpush_cinv(m68k_info *info, int op_offset)
Definition: M68KDisassembler.c:1083
d68000_asr_r_32
static void d68000_asr_r_32(m68k_info *info)
Definition: M68KDisassembler.c:1428
update_bits_range
static void update_bits_range(m68k_info *info, m68k_reg reg_start, uint8_t bits, int write)
Definition: M68KDisassembler.c:3914
d68000_cmpa_16
static void d68000_cmpa_16(m68k_info *info)
Definition: M68KDisassembler.c:1723
M68K_AM_PC_MEMI_PRE_INDEX
@ M68K_AM_PC_MEMI_PRE_INDEX
Program Counter Memory Indirect - Preindexed.
Definition: m68k.h:102
M68K_INS_BSR
@ M68K_INS_BSR
Definition: m68k.h:245
build_absolute_jump_with_immediate
static void build_absolute_jump_with_immediate(m68k_info *info, int opcode, int size, int immediate)
Definition: M68KDisassembler.c:778
d68000_clr_16
static void d68000_clr_16(m68k_info *info)
Definition: M68KDisassembler.c:1698
M68K_INS_FMOVECR
@ M68K_INS_FMOVECR
Definition: m68k.h:396
d68020_tst_pcix_32
static void d68020_tst_pcix_32(m68k_info *info)
Definition: M68KDisassembler.c:3368
M68K_INS_DBNE
@ M68K_INS_DBNE
Definition: m68k.h:282
M68K_INS_SLT
@ M68K_INS_SLT
Definition: m68k.h:558
M68K_INS_BMI
@ M68K_INS_BMI
Definition: m68k.h:239
d68000_add_re_16
static void d68000_add_re_16(m68k_info *info)
Definition: M68KDisassembler.c:1268
M68K_INS_MULS
@ M68K_INS_MULS
Definition: m68k.h:506
EXT_INDEX_REGISTER
#define EXT_INDEX_REGISTER(A)
Definition: M68KDisassembler.c:139
TYPE_68010
#define TYPE_68010
Definition: M68KDisassembler.c:102
d68000_cmpm_16
static void d68000_cmpm_16(m68k_info *info)
Definition: M68KDisassembler.c:1789
reverse_bits_8
static uint8_t reverse_bits_8(uint v)
Definition: M68KDisassembler.c:909
d68000_andi_16
static void d68000_andi_16(m68k_info *info)
Definition: M68KDisassembler.c:1383
d68020_bfexts
static void d68020_bfexts(m68k_info *info)
Definition: M68KDisassembler.c:1528
M68K_INS_JSR
@ M68K_INS_JSR
Definition: m68k.h:492
M68K_INS_SGE
@ M68K_INS_SGE
Definition: m68k.h:557
M68K_INS_MOVE
@ M68K_INS_MOVE
Definition: m68k.h:498
d68000_or_re_8
static void d68000_or_re_8(m68k_info *info)
Definition: M68KDisassembler.c:2887
M68K_INS_BFEXTU
@ M68K_INS_BFEXTU
Definition: m68k.h:253
M68K_INS_BFCLR
@ M68K_INS_BFCLR
Definition: m68k.h:251
M68K_AM_ABSOLUTE_DATA_SHORT
@ M68K_AM_ABSOLUTE_DATA_SHORT
Absolute Data Addressing - Short.
Definition: m68k.h:104
M68K_INS_MULU
@ M68K_INS_MULU
Definition: m68k.h:507
d68000_lsl_s_32
static void d68000_lsl_s_32(m68k_info *info)
Definition: M68KDisassembler.c:2439
M68K_OP_REG
@ M68K_OP_REG
= CS_OP_REG (Register operand).
Definition: m68k.h:114
M68K_INS_JMP
@ M68K_INS_JMP
Definition: m68k.h:491
M68K_CPU_TYPE_68020
@ M68K_CPU_TYPE_68020
Definition: M68KDisassembler.c:128
d68000_btst_r
static void d68000_btst_r(m68k_info *info)
Definition: M68KDisassembler.c:1614
g_5bit_data_table
static uint g_5bit_data_table[32]
Definition: M68KDisassembler.c:256
d68000_neg_16
static void d68000_neg_16(m68k_info *info)
Definition: M68KDisassembler.c:2827
cs_m68k_op::address_mode
m68k_address_mode address_mode
M68K addressing mode for this op.
Definition: m68k.h:170
M68K_INS_FETOX
@ M68K_INS_FETOX
Definition: m68k.h:382
d68000_subx_rr_32
static void d68000_subx_rr_32(m68k_info *info)
Definition: M68KDisassembler.c:3239
d68000_ori_32
static void d68000_ori_32(m68k_info *info)
Definition: M68KDisassembler.c:2912
d68000_move_to_sr
static void d68000_move_to_sr(m68k_info *info)
Definition: M68KDisassembler.c:2538
d68020_chk2_cmp2_32
static void d68020_chk2_cmp2_32(m68k_info *info)
Definition: M68KDisassembler.c:1681
d68000_roxl_r_16
static void d68000_roxl_r_16(m68k_info *info)
Definition: M68KDisassembler.c:3074
s_scc_lut
static m68k_insn s_scc_lut[]
Definition: M68KDisassembler.c:275
M68K_INS_FCOSH
@ M68K_INS_FCOSH
Definition: m68k.h:346
d68000_lsl_r_32
static void d68000_lsl_r_32(m68k_info *info)
Definition: M68KDisassembler.c:2454
M68K_INS_RESET
@ M68K_INS_RESET
Definition: m68k.h:532
M68K_INS_DBF
@ M68K_INS_DBF
Definition: m68k.h:277
M68K_AM_MEMI_PRE_INDEX
@ M68K_AM_MEMI_PRE_INDEX
Memory indirect - Preindex.
Definition: m68k.h:94
d68000_rol_ea
static void d68000_rol_ea(m68k_info *info)
Definition: M68KDisassembler.c:3014
d68000_and_er_32
static void d68000_and_er_32(m68k_info *info)
Definition: M68KDisassembler.c:1358
d68000_bra_8
static void d68000_bra_8(m68k_info *info)
Definition: M68KDisassembler.c:1572
d68000_lsl_ea
static void d68000_lsl_ea(m68k_info *info)
Definition: M68KDisassembler.c:2459
M68K_INS_NEG
@ M68K_INS_NEG
Definition: m68k.h:509
m68k_info::pc
unsigned int pc
Definition: M68KDisassembler.h:15
d68020_bsr_32
static void d68020_bsr_32(m68k_info *info)
Definition: M68KDisassembler.c:1608
instruction_is_valid
static int instruction_is_valid(m68k_info *info, const unsigned int word_check)
Definition: M68KDisassembler.c:3829
M68K_AM_REGI_ADDR_DISP
@ M68K_AM_REGI_ADDR_DISP
Register Indirect - Address with Displacement.
Definition: m68k.h:88
M68K_INS_NBCD
@ M68K_INS_NBCD
Definition: m68k.h:508
M68K_AM_PCI_INDEX_BASE_DISP
@ M68K_AM_PCI_INDEX_BASE_DISP
Program Counter Indirect with Index - with Base Displacement.
Definition: m68k.h:99
M68K_AM_PC_MEMI_POST_INDEX
@ M68K_AM_PC_MEMI_POST_INDEX
Program Counter Memory Indirect - Postindexed.
Definition: m68k.h:101
m68k_info::code
const uint8_t * code
Definition: M68KDisassembler.h:11
M68K_INS_FADD
@ M68K_INS_FADD
Definition: m68k.h:306
d68020_bfextu
static void d68020_bfextu(m68k_info *info)
Definition: M68KDisassembler.c:1534
d68020_cas2_16
static void d68020_cas2_16(m68k_info *info)
Definition: M68KDisassembler.c:1648
build_ea_ea
static void build_ea_ea(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:716
M68K_INS_DBGT
@ M68K_INS_DBGT
Definition: m68k.h:290
handle
static csh handle
Definition: test_arm_regression.c:16
get_with_index_address_mode
static void get_with_index_address_mode(m68k_info *info, cs_m68k_op *op, uint instruction, uint size, bool is_pc)
Definition: M68KDisassembler.c:336
build_movep_er
static void build_movep_er(m68k_info *info, int size)
Definition: M68KDisassembler.c:1138
EXT_BASE_REGISTER_PRESENT
#define EXT_BASE_REGISTER_PRESENT(A)
Definition: M68KDisassembler.c:137
d68020_pack_rr
static void d68020_pack_rr(m68k_info *info)
Definition: M68KDisassembler.c:2927
d68000_asr_ea
static void d68000_asr_ea(m68k_info *info)
Definition: M68KDisassembler.c:1433
d68000_dbra
static void d68000_dbra(m68k_info *info)
Definition: M68KDisassembler.c:2214
s_branch_lut
static m68k_insn s_branch_lut[]
Definition: M68KDisassembler.c:261
M68K_INS_FMOVEM
@ M68K_INS_FMOVEM
Definition: m68k.h:397
d68020_cprestore
static void d68020_cprestore(m68k_info *info)
Definition: M68KDisassembler.c:2117
M68K_INS_TAS
@ M68K_INS_TAS
Definition: m68k.h:568
d68020_cas_8
static void d68020_cas_8(m68k_info *info)
Definition: M68KDisassembler.c:1630
build_r
static void build_r(m68k_info *info, int opcode, uint8_t size)
Definition: M68KDisassembler.c:605
M68K_INS_DBLT
@ M68K_INS_DBLT
Definition: m68k.h:289
d68020_bra_32
static void d68020_bra_32(m68k_info *info)
Definition: M68KDisassembler.c:1582
d68000_clr_32
static void d68000_clr_32(m68k_info *info)
Definition: M68KDisassembler.c:1703
M68K_INS_BFEXTS
@ M68K_INS_BFEXTS
Definition: m68k.h:252
build_er_gen_1
static void build_er_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
Definition: M68KDisassembler.c:560
M68K_INS_CLR
@ M68K_INS_CLR
Definition: m68k.h:264
d68000_asl_s_16
static void d68000_asl_s_16(m68k_info *info)
Definition: M68KDisassembler.c:1443
d68000_subq_8
static void d68000_subq_8(m68k_info *info)
Definition: M68KDisassembler.c:3214
d68000_movep_er_32
static void d68000_movep_er_32(m68k_info *info)
Definition: M68KDisassembler.c:2677
M68K_INS_UNLK
@ M68K_INS_UNLK
Definition: m68k.h:590
int8_t
signed char int8_t
Definition: stdint-msvc2008.h:75
code
Definition: bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
SStream_Init
void SStream_Init(SStream *ss)
Definition: SStream.c:25
compare_nof_true_bits
static int DECL_SPEC compare_nof_true_bits(const void *aptr, const void *bptr)
Definition: M68KDisassembler.c:3769
M68K_INS_FGETEXP
@ M68K_INS_FGETEXP
Definition: m68k.h:384
build_dbxx
static void build_dbxx(m68k_info *info, int opcode, int size, int displacement)
Definition: M68KDisassembler.c:802
M68K_INS_SMI
@ M68K_INS_SMI
Definition: m68k.h:556
d68020_trapcc_0
static void d68020_trapcc_0(m68k_info *info)
Definition: M68KDisassembler.c:3274
M68K_INS_ADDQ
@ M68K_INS_ADDQ
Definition: m68k.h:222
cs_m68k_op
Instruction operand.
Definition: m68k.h:154
M68K_REG_CACR
@ M68K_REG_CACR
Definition: m68k.h:58
d68020_bfchg
static void d68020_bfchg(m68k_info *info)
Definition: M68KDisassembler.c:1515
d68000_nop
static void d68000_nop(m68k_info *info)
Definition: M68KDisassembler.c:2852
m68k_read_safe_32
static unsigned int m68k_read_safe_32(const m68k_info *info, const uint64_t address)
Definition: M68KDisassembler.c:197
d68000_sub_re_8
static void d68000_sub_re_8(m68k_info *info)
Definition: M68KDisassembler.c:3174
M68K_INS_MOVE16
@ M68K_INS_MOVE16
Definition: m68k.h:505
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
d68040_cinv
static void d68040_cinv(m68k_info *info)
Definition: M68KDisassembler.c:1687
M68K_INS_MOVEA
@ M68K_INS_MOVEA
Definition: m68k.h:499
M68K_OP_BR_DISP_SIZE_WORD
@ M68K_OP_BR_DISP_SIZE_WORD
signed 16-bit displacement
Definition: m68k.h:144
d68000_reset
static void d68000_reset(m68k_info *info)
Definition: M68KDisassembler.c:2944
d68000_lsr_r_16
static void d68000_lsr_r_16(m68k_info *info)
Definition: M68KDisassembler.c:2414
d68000_addx_rr_16
static void d68000_addx_rr_16(m68k_info *info)
Definition: M68KDisassembler.c:1323
M68K_INS_PACK
@ M68K_INS_PACK
Definition: m68k.h:515
BIT_A
#define BIT_A(A)
Definition: M68KDisassembler.c:77
M68K_REG_FPIAR
@ M68K_REG_FPIAR
Definition: m68k.h:73
M68K_INS_FSF
@ M68K_INS_FSF
Definition: m68k.h:417
d68020_bftst
static void d68020_bftst(m68k_info *info)
Definition: M68KDisassembler.c:1567
regress.m
m
Definition: regress/regress.py:25
MCInst_setOpcode
void MCInst_setOpcode(MCInst *inst, unsigned Op)
Definition: MCInst.c:55
M68K_INS_DIVS
@ M68K_INS_DIVS
Definition: m68k.h:293
M68K_INS_ADD
@ M68K_INS_ADD
Definition: m68k.h:219
d68000_suba_32
static void d68000_suba_32(m68k_info *info)
Definition: M68KDisassembler.c:3194
M68K_INS_NOP
@ M68K_INS_NOP
Definition: m68k.h:511
m68k_read_disassembler_64
static uint64_t m68k_read_disassembler_64(const m68k_info *info, const uint64_t addr)
Definition: M68KDisassembler.c:175
d68020_cptrapcc_0
static void d68020_cptrapcc_0(m68k_info *info)
Definition: M68KDisassembler.c:2149
d68000_and_re_32
static void d68000_and_re_32(m68k_info *info)
Definition: M68KDisassembler.c:1373
d68020_tst_a_16
static void d68020_tst_a_16(m68k_info *info)
Definition: M68KDisassembler.c:3327
M68K_FPU_SIZE_EXTENDED
@ M68K_FPU_SIZE_EXTENDED
12 byte in size (extended real format)
Definition: m68k.h:186
M68K_INS_CMP
@ M68K_INS_CMP
Definition: m68k.h:265
M68K_REG_MMUSR
@ M68K_REG_MMUSR
Definition: m68k.h:67
d68000_eori_to_sr
static void d68000_eori_to_sr(m68k_info *info)
Definition: M68KDisassembler.c:2306
m68k_disassemble
static unsigned int m68k_disassemble(m68k_info *info, uint64_t pc)
Definition: M68KDisassembler.c:4018
opcode
opcode
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.h:6290
M68K_INS_TRAPHI
@ M68K_INS_TRAPHI
Definition: m68k.h:573
M68K_OP_MEM
@ M68K_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: m68k.h:116
m68k_info::extension
cs_m68k extension
Definition: M68KDisassembler.h:19
opcode_struct
Definition: M68KDisassembler.c:231
op
static grpc_op * op
Definition: test/core/fling/client.cc:47
M68K_REG_VBR
@ M68K_REG_VBR
Definition: m68k.h:57
d68020_trapcc_32
static void d68020_trapcc_32(m68k_info *info)
Definition: M68KDisassembler.c:3288
M68K_REG_MSP
@ M68K_REG_MSP
Definition: m68k.h:60
d68000_roxr_r_8
static void d68000_roxr_r_8(m68k_info *info)
Definition: M68KDisassembler.c:3034
M68K_INS_MOVEM
@ M68K_INS_MOVEM
Definition: m68k.h:501
d68000_eor_16
static void d68000_eor_16(m68k_info *info)
Definition: M68KDisassembler.c:2276
M68K_INS_DBHI
@ M68K_INS_DBHI
Definition: m68k.h:278
d68000_ror_r_32
static void d68000_ror_r_32(m68k_info *info)
Definition: M68KDisassembler.c:2974
M68K_INS_DBRA
@ M68K_INS_DBRA
Definition: m68k.h:292
d68000_rol_s_32
static void d68000_rol_s_32(m68k_info *info)
Definition: M68KDisassembler.c:2994
M68K_getInstruction
bool M68K_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *inst_info)
Definition: M68KDisassembler.c:4047
d68000_moveq
static void d68000_moveq(m68k_info *info)
Definition: M68KDisassembler.c:2701
d68020_cmpi_pcix_32
static void d68020_cmpi_pcix_32(m68k_info *info)
Definition: M68KDisassembler.c:1778
EXT_INDEX_AR
#define EXT_INDEX_AR(A)
Definition: M68KDisassembler.c:145
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
cs_m68k_op::br_disp
m68k_op_br_disp br_disp
data when operand is a branch displacement
Definition: m68k.h:167
cs_m68k_op::imm
uint64_t imm
immediate value for IMM operand
Definition: m68k.h:156
if
if(p->owned &&p->wrapped !=NULL)
Definition: call.c:42
d68020_bfffo
static void d68020_bfffo(m68k_info *info)
Definition: M68KDisassembler.c:1540
d68010_rtd
static void d68010_rtd(m68k_info *info)
Definition: M68KDisassembler.c:3089
M68K_INS_SF
@ M68K_INS_SF
Definition: m68k.h:544
exists_reg_list
static int exists_reg_list(uint16_t *regs, uint8_t count, m68k_reg reg)
Definition: M68KDisassembler.c:3843
M68K_INS_ADDX
@ M68K_INS_ADDX
Definition: m68k.h:223
M68K_INS_DBEQ
@ M68K_INS_DBEQ
Definition: m68k.h:283
d68000_rol_r_8
static void d68000_rol_r_8(m68k_info *info)
Definition: M68KDisassembler.c:2999
MCInst::flat_insn
cs_insn * flat_insn
Definition: MCInst.h:95
M68K_INS_LSL
@ M68K_INS_LSL
Definition: m68k.h:496
M68K_INS_CMPM
@ M68K_INS_CMPM
Definition: m68k.h:268
d68000_roxl_s_32
static void d68000_roxl_s_32(m68k_info *info)
Definition: M68KDisassembler.c:3064
d68000_addq_16
static void d68000_addq_16(m68k_info *info)
Definition: M68KDisassembler.c:1308
d68020_tst_i_16
static void d68020_tst_i_16(m68k_info *info)
Definition: M68KDisassembler.c:3345
M68K_INS_DBPL
@ M68K_INS_DBPL
Definition: m68k.h:286
d68020_rtm
static void d68020_rtm(m68k_info *info)
Definition: M68KDisassembler.c:3102
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
d68000_lsl_s_16
static void d68000_lsl_s_16(m68k_info *info)
Definition: M68KDisassembler.c:2434
offset
voidpf uLong offset
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:142
M68K_INS_RTM
@ M68K_INS_RTM
Definition: m68k.h:539
d68000_subq_16
static void d68000_subq_16(m68k_info *info)
Definition: M68KDisassembler.c:3219
LL
#define LL(x)
M68K_INS_BVC
@ M68K_INS_BVC
Definition: m68k.h:236
M68K_INS_TRAPMI
@ M68K_INS_TRAPMI
Definition: m68k.h:584
M68K_INS_FDIV
@ M68K_INS_FDIV
Definition: m68k.h:379
M68K_INS_FSCALE
@ M68K_INS_FSCALE
Definition: m68k.h:408
build_d_d_ea
static void build_d_d_ea(m68k_info *info, int opcode, int size)
Definition: M68KDisassembler.c:828
m68k_info::code_len
size_t code_len
Definition: M68KDisassembler.h:12
M68K_CPU_TYPE_INVALID
@ M68K_CPU_TYPE_INVALID
Definition: M68KDisassembler.c:124
M68KInstPrinter.h
d68000_tst_8
static void d68000_tst_8(m68k_info *info)
Definition: M68KDisassembler.c:3299
M68K_INS_CAS2
@ M68K_INS_CAS2
Definition: m68k.h:261
d68000_bchg_s
static void d68000_bchg_s(m68k_info *info)
Definition: M68KDisassembler.c:1494
M68K_INS_ORI
@ M68K_INS_ORI
Definition: m68k.h:514
d68000_movep_er_16
static void d68000_movep_er_16(m68k_info *info)
Definition: M68KDisassembler.c:2672
M68K_INS_CHK
@ M68K_INS_CHK
Definition: m68k.h:262
M68K_REG_SRP
@ M68K_REG_SRP
Definition: m68k.h:69


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:30