Rizin
unix-like reverse engineering framework and cli tools
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 below is based on MUSASHI but has been heavily modified for Capstone by
31  * Daniel Collin <daniel@collin.com> 2015-2019 */
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 /* ======================================================================== */
51 /* ============================ GENERAL DEFINES =========================== */
52 /* ======================================================================== */
53 
54 /* Bit Isolation Functions */
55 #define BIT_0(A) ((A) & 0x00000001)
56 #define BIT_1(A) ((A) & 0x00000002)
57 #define BIT_2(A) ((A) & 0x00000004)
58 #define BIT_3(A) ((A) & 0x00000008)
59 #define BIT_4(A) ((A) & 0x00000010)
60 #define BIT_5(A) ((A) & 0x00000020)
61 #define BIT_6(A) ((A) & 0x00000040)
62 #define BIT_7(A) ((A) & 0x00000080)
63 #define BIT_8(A) ((A) & 0x00000100)
64 #define BIT_9(A) ((A) & 0x00000200)
65 #define BIT_A(A) ((A) & 0x00000400)
66 #define BIT_B(A) ((A) & 0x00000800)
67 #define BIT_C(A) ((A) & 0x00001000)
68 #define BIT_D(A) ((A) & 0x00002000)
69 #define BIT_E(A) ((A) & 0x00004000)
70 #define BIT_F(A) ((A) & 0x00008000)
71 #define BIT_10(A) ((A) & 0x00010000)
72 #define BIT_11(A) ((A) & 0x00020000)
73 #define BIT_12(A) ((A) & 0x00040000)
74 #define BIT_13(A) ((A) & 0x00080000)
75 #define BIT_14(A) ((A) & 0x00100000)
76 #define BIT_15(A) ((A) & 0x00200000)
77 #define BIT_16(A) ((A) & 0x00400000)
78 #define BIT_17(A) ((A) & 0x00800000)
79 #define BIT_18(A) ((A) & 0x01000000)
80 #define BIT_19(A) ((A) & 0x02000000)
81 #define BIT_1A(A) ((A) & 0x04000000)
82 #define BIT_1B(A) ((A) & 0x08000000)
83 #define BIT_1C(A) ((A) & 0x10000000)
84 #define BIT_1D(A) ((A) & 0x20000000)
85 #define BIT_1E(A) ((A) & 0x40000000)
86 #define BIT_1F(A) ((A) & 0x80000000)
87 
88 /* These are the CPU types understood by this disassembler */
89 #define TYPE_68000 1
90 #define TYPE_68010 2
91 #define TYPE_68020 4
92 #define TYPE_68030 8
93 #define TYPE_68040 16
94 
95 #define M68000_ONLY TYPE_68000
96 
97 #define M68010_ONLY TYPE_68010
98 #define M68010_LESS (TYPE_68000 | TYPE_68010)
99 #define M68010_PLUS (TYPE_68010 | TYPE_68020 | TYPE_68030 | TYPE_68040)
100 
101 #define M68020_ONLY TYPE_68020
102 #define M68020_LESS (TYPE_68010 | TYPE_68020)
103 #define M68020_PLUS (TYPE_68020 | TYPE_68030 | TYPE_68040)
104 
105 #define M68030_ONLY TYPE_68030
106 #define M68030_LESS (TYPE_68010 | TYPE_68020 | TYPE_68030)
107 #define M68030_PLUS (TYPE_68030 | TYPE_68040)
108 
109 #define M68040_PLUS TYPE_68040
110 
111 enum {
117  M68K_CPU_TYPE_68030, /* Supported by disassembler ONLY */
118  M68K_CPU_TYPE_68040 /* Supported by disassembler ONLY */
119 };
120 
121 /* Extension word formats */
122 #define EXT_8BIT_DISPLACEMENT(A) ((A)&0xff)
123 #define EXT_FULL(A) BIT_8(A)
124 #define EXT_EFFECTIVE_ZERO(A) (((A)&0xe4) == 0xc4 || ((A)&0xe2) == 0xc0)
125 #define EXT_BASE_REGISTER_PRESENT(A) (!BIT_7(A))
126 #define EXT_INDEX_REGISTER_PRESENT(A) (!BIT_6(A))
127 #define EXT_INDEX_REGISTER(A) (((A)>>12)&7)
128 #define EXT_INDEX_PRE_POST(A) (EXT_INDEX_PRESENT(A) && (A)&3)
129 #define EXT_INDEX_PRE(A) (EXT_INDEX_PRESENT(A) && ((A)&7) < 4 && ((A)&7) != 0)
130 #define EXT_INDEX_POST(A) (EXT_INDEX_PRESENT(A) && ((A)&7) > 4)
131 #define EXT_INDEX_SCALE(A) (((A)>>9)&3)
132 #define EXT_INDEX_LONG(A) BIT_B(A)
133 #define EXT_INDEX_AR(A) BIT_F(A)
134 #define EXT_BASE_DISPLACEMENT_PRESENT(A) (((A)&0x30) > 0x10)
135 #define EXT_BASE_DISPLACEMENT_WORD(A) (((A)&0x30) == 0x20)
136 #define EXT_BASE_DISPLACEMENT_LONG(A) (((A)&0x30) == 0x30)
137 #define EXT_OUTER_DISPLACEMENT_PRESENT(A) (((A)&3) > 1 && ((A)&0x47) < 0x44)
138 #define EXT_OUTER_DISPLACEMENT_WORD(A) (((A)&3) == 2 && ((A)&0x47) < 0x44)
139 #define EXT_OUTER_DISPLACEMENT_LONG(A) (((A)&3) == 3 && ((A)&0x47) < 0x44)
140 
141 #define IS_BITSET(val,b) ((val) & (1 << (b)))
142 #define BITFIELD_MASK(sb,eb) (((1 << ((sb) + 1))-1) & (~((1 << (eb))-1)))
143 #define BITFIELD(val,sb,eb) ((BITFIELD_MASK(sb,eb) & (val)) >> (eb))
144 
146 
147 static unsigned int m68k_read_disassembler_16(const m68k_info *info, const uint64_t addr)
148 {
149  const uint16_t v0 = info->code[addr + 0];
150  const uint16_t v1 = info->code[addr + 1];
151  return (v0 << 8) | v1;
152 }
153 
154 static unsigned int m68k_read_disassembler_32(const m68k_info *info, const uint64_t addr)
155 {
156  const uint32_t v0 = info->code[addr + 0];
157  const uint32_t v1 = info->code[addr + 1];
158  const uint32_t v2 = info->code[addr + 2];
159  const uint32_t v3 = info->code[addr + 3];
160  return (v0 << 24) | (v1 << 16) | (v2 << 8) | v3;
161 }
162 
164 {
165  const uint64_t v0 = info->code[addr + 0];
166  const uint64_t v1 = info->code[addr + 1];
167  const uint64_t v2 = info->code[addr + 2];
168  const uint64_t v3 = info->code[addr + 3];
169  const uint64_t v4 = info->code[addr + 4];
170  const uint64_t v5 = info->code[addr + 5];
171  const uint64_t v6 = info->code[addr + 6];
172  const uint64_t v7 = info->code[addr + 7];
173  return (v0 << 56) | (v1 << 48) | (v2 << 40) | (v3 << 32) | (v4 << 24) | (v5 << 16) | (v6 << 8) | v7;
174 }
175 
176 static unsigned int m68k_read_safe_16(const m68k_info *info, const uint64_t address)
177 {
178  const uint64_t addr = (address - info->baseAddress) & info->address_mask;
179  if (info->code_len < addr + 2) {
180  return 0xaaaa;
181  }
183 }
184 
185 static unsigned int m68k_read_safe_32(const m68k_info *info, const uint64_t address)
186 {
187  const uint64_t addr = (address - info->baseAddress) & info->address_mask;
188  if (info->code_len < addr + 4) {
189  return 0xaaaaaaaa;
190  }
192 }
193 
194 static uint64_t m68k_read_safe_64(const m68k_info *info, const uint64_t address)
195 {
196  const uint64_t addr = (address - info->baseAddress) & info->address_mask;
197  if (info->code_len < addr + 8) {
198  return 0xaaaaaaaaaaaaaaaaLL;
199  }
201 }
202 
203 /* ======================================================================== */
204 /* =============================== PROTOTYPES ============================= */
205 /* ======================================================================== */
206 
207 /* make signed integers 100% portably */
208 static int make_int_8(int value);
209 static int make_int_16(int value);
210 
211 /* Stuff to build the opcode handler jump table */
212 static void d68000_invalid(m68k_info *info);
213 static int instruction_is_valid(m68k_info *info, const unsigned int word_check);
214 
215 typedef struct {
216  void (*instruction)(m68k_info *info); /* handler function */
217  uint16_t word2_mask; /* mask the 2nd word */
218  uint16_t word2_match; /* what to match after masking */
220 
221 /* ======================================================================== */
222 /* ================================= DATA ================================= */
223 /* ======================================================================== */
224 
226 
227 /* used by ops like asr, ror, addq, etc */
228 static uint32_t g_3bit_qdata_table[8] = {8, 1, 2, 3, 4, 5, 6, 7};
229 
231  32, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
232  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
233 };
234 
240 };
241 
242 static m68k_insn s_dbcc_lut[] = {
247 };
248 
249 static m68k_insn s_scc_lut[] = {
254 };
255 
256 static m68k_insn s_trap_lut[] = {
261 };
262 
263 /* ======================================================================== */
264 /* =========================== UTILITY FUNCTIONS ========================== */
265 /* ======================================================================== */
266 
267 #define LIMIT_CPU_TYPES(info, ALLOWED_CPU_TYPES) \
268  do { \
269  if (!(info->type & ALLOWED_CPU_TYPES)) { \
270  d68000_invalid(info); \
271  return; \
272  } \
273  } while (0)
274 
275 static unsigned int peek_imm_8(const m68k_info *info) { return (m68k_read_safe_16((info), (info)->pc)&0xff); }
276 static unsigned int peek_imm_16(const m68k_info *info) { return m68k_read_safe_16((info), (info)->pc); }
277 static unsigned int peek_imm_32(const m68k_info *info) { return m68k_read_safe_32((info), (info)->pc); }
278 static unsigned long long peek_imm_64(const m68k_info *info) { return m68k_read_safe_64((info), (info)->pc); }
279 
280 static unsigned int read_imm_8(m68k_info *info) { const unsigned int value = peek_imm_8(info); (info)->pc+=2; return value; }
281 static unsigned int read_imm_16(m68k_info *info) { const unsigned int value = peek_imm_16(info); (info)->pc+=2; return value; }
282 static unsigned int read_imm_32(m68k_info *info) { const unsigned int value = peek_imm_32(info); (info)->pc+=4; return value; }
283 static unsigned long long read_imm_64(m68k_info *info) { const unsigned long long value = peek_imm_64(info); (info)->pc+=8; return value; }
284 
285 /* Fake a split interface */
286 #define get_ea_mode_str_8(instruction) get_ea_mode_str(instruction, 0)
287 #define get_ea_mode_str_16(instruction) get_ea_mode_str(instruction, 1)
288 #define get_ea_mode_str_32(instruction) get_ea_mode_str(instruction, 2)
289 
290 #define get_imm_str_s8() get_imm_str_s(0)
291 #define get_imm_str_s16() get_imm_str_s(1)
292 #define get_imm_str_s32() get_imm_str_s(2)
293 
294 #define get_imm_str_u8() get_imm_str_u(0)
295 #define get_imm_str_u16() get_imm_str_u(1)
296 #define get_imm_str_u32() get_imm_str_u(2)
297 
298 
299 /* 100% portable signed int generators */
300 static int make_int_8(int value)
301 {
302  return (value & 0x80) ? value | ~0xff : value & 0xff;
303 }
304 
305 static int make_int_16(int value)
306 {
307  return (value & 0x8000) ? value | ~0xffff : value & 0xffff;
308 }
309 
311 {
312  uint32_t extension = read_imm_16(info);
313 
314  op->address_mode = M68K_AM_AREGI_INDEX_BASE_DISP;
315 
316  if (EXT_FULL(extension)) {
317  uint32_t preindex;
318  uint32_t postindex;
319 
320  op->mem.base_reg = M68K_REG_INVALID;
321  op->mem.index_reg = M68K_REG_INVALID;
322 
323  /* Not sure how to deal with this?
324  if (EXT_EFFECTIVE_ZERO(extension)) {
325  strcpy(mode, "0");
326  break;
327  }
328  */
329 
330  op->mem.in_disp = EXT_BASE_DISPLACEMENT_PRESENT(extension) ? (EXT_BASE_DISPLACEMENT_LONG(extension) ? read_imm_32(info) : read_imm_16(info)) : 0;
331  op->mem.out_disp = EXT_OUTER_DISPLACEMENT_PRESENT(extension) ? (EXT_OUTER_DISPLACEMENT_LONG(extension) ? read_imm_32(info) : read_imm_16(info)) : 0;
332 
333  if (EXT_BASE_REGISTER_PRESENT(extension)) {
334  if (is_pc) {
335  op->mem.base_reg = M68K_REG_PC;
336  } else {
337  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
338  }
339  }
340 
341  if (EXT_INDEX_REGISTER_PRESENT(extension)) {
342  if (EXT_INDEX_AR(extension)) {
343  op->mem.index_reg = M68K_REG_A0 + EXT_INDEX_REGISTER(extension);
344  } else {
345  op->mem.index_reg = M68K_REG_D0 + EXT_INDEX_REGISTER(extension);
346  }
347 
348  op->mem.index_size = EXT_INDEX_LONG(extension) ? 1 : 0;
349 
350  if (EXT_INDEX_SCALE(extension)) {
351  op->mem.scale = 1 << EXT_INDEX_SCALE(extension);
352  }
353  }
354 
355  preindex = (extension & 7) > 0 && (extension & 7) < 4;
356  postindex = (extension & 7) > 4;
357 
358  if (preindex) {
359  op->address_mode = is_pc ? M68K_AM_PC_MEMI_PRE_INDEX : M68K_AM_MEMI_PRE_INDEX;
360  } else if (postindex) {
361  op->address_mode = is_pc ? M68K_AM_PC_MEMI_POST_INDEX : M68K_AM_MEMI_POST_INDEX;
362  }
363 
364  return;
365  }
366 
367  op->mem.index_reg = (EXT_INDEX_AR(extension) ? M68K_REG_A0 : M68K_REG_D0) + EXT_INDEX_REGISTER(extension);
368  op->mem.index_size = EXT_INDEX_LONG(extension) ? 1 : 0;
369 
370  if (EXT_8BIT_DISPLACEMENT(extension) == 0) {
371  if (is_pc) {
372  op->mem.base_reg = M68K_REG_PC;
373  op->address_mode = M68K_AM_PCI_INDEX_BASE_DISP;
374  } else {
375  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
376  }
377  } else {
378  if (is_pc) {
379  op->mem.base_reg = M68K_REG_PC;
380  op->address_mode = M68K_AM_PCI_INDEX_8_BIT_DISP;
381  } else {
382  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
383  op->address_mode = M68K_AM_AREGI_INDEX_8_BIT_DISP;
384  }
385 
386  op->mem.disp = (int8_t)(extension & 0xff);
387  }
388 
389  if (EXT_INDEX_SCALE(extension)) {
390  op->mem.scale = 1 << EXT_INDEX_SCALE(extension);
391  }
392 }
393 
394 /* Make string of effective address mode */
396 {
397  // default to memory
398 
399  op->type = M68K_OP_MEM;
400 
401  switch (instruction & 0x3f) {
402  case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
403  /* data register direct */
404  op->address_mode = M68K_AM_REG_DIRECT_DATA;
405  op->reg = M68K_REG_D0 + (instruction & 7);
406  op->type = M68K_OP_REG;
407  break;
408 
409  case 0x08: case 0x09: case 0x0a: case 0x0b: case 0x0c: case 0x0d: case 0x0e: case 0x0f:
410  /* address register direct */
411  op->address_mode = M68K_AM_REG_DIRECT_ADDR;
412  op->reg = M68K_REG_A0 + (instruction & 7);
413  op->type = M68K_OP_REG;
414  break;
415 
416  case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17:
417  /* address register indirect */
418  op->address_mode = M68K_AM_REGI_ADDR;
419  op->reg = M68K_REG_A0 + (instruction & 7);
420  break;
421 
422  case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f:
423  /* address register indirect with postincrement */
424  op->address_mode = M68K_AM_REGI_ADDR_POST_INC;
425  op->reg = M68K_REG_A0 + (instruction & 7);
426  break;
427 
428  case 0x20: case 0x21: case 0x22: case 0x23: case 0x24: case 0x25: case 0x26: case 0x27:
429  /* address register indirect with predecrement */
430  op->address_mode = M68K_AM_REGI_ADDR_PRE_DEC;
431  op->reg = M68K_REG_A0 + (instruction & 7);
432  break;
433 
434  case 0x28: case 0x29: case 0x2a: case 0x2b: case 0x2c: case 0x2d: case 0x2e: case 0x2f:
435  /* address register indirect with displacement*/
436  op->address_mode = M68K_AM_REGI_ADDR_DISP;
437  op->mem.base_reg = M68K_REG_A0 + (instruction & 7);
438  op->mem.disp = (int16_t)read_imm_16(info);
439  break;
440 
441  case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: case 0x35: case 0x36: case 0x37:
442  /* address register indirect with index */
444  break;
445 
446  case 0x38:
447  /* absolute short address */
448  op->address_mode = M68K_AM_ABSOLUTE_DATA_SHORT;
449  op->imm = read_imm_16(info);
450  break;
451 
452  case 0x39:
453  /* absolute long address */
454  op->address_mode = M68K_AM_ABSOLUTE_DATA_LONG;
455  op->imm = read_imm_32(info);
456  break;
457 
458  case 0x3a:
459  /* program counter with displacement */
460  op->address_mode = M68K_AM_PCI_DISP;
461  op->mem.disp = (int16_t)read_imm_16(info);
462  break;
463 
464  case 0x3b:
465  /* program counter with index */
467  break;
468 
469  case 0x3c:
470  op->address_mode = M68K_AM_IMMEDIATE;
471  op->type = M68K_OP_IMM;
472 
473  if (size == 1)
474  op->imm = read_imm_8(info) & 0xff;
475  else if (size == 2)
476  op->imm = read_imm_16(info) & 0xffff;
477  else if (size == 4)
478  op->imm = read_imm_32(info);
479  else
480  op->imm = read_imm_64(info);
481 
482  break;
483 
484  default:
485  break;
486  }
487 }
488 
490 {
491  info->groups[info->groups_count++] = (uint8_t)group;
492 }
493 
494 static cs_m68k* build_init_op(m68k_info *info, int opcode, int count, int size)
495 {
496  cs_m68k* ext;
497 
498  MCInst_setOpcode(info->inst, opcode);
499 
500  ext = &info->extension;
501 
502  ext->op_count = (uint8_t)count;
503  ext->op_size.type = M68K_SIZE_TYPE_CPU;
504  ext->op_size.cpu_size = size;
505 
506  return ext;
507 }
508 
509 static void build_re_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
510 {
511  cs_m68k_op* op0;
512  cs_m68k_op* op1;
513  cs_m68k* ext = build_init_op(info, opcode, 2, size);
514 
515  op0 = &ext->operands[0];
516  op1 = &ext->operands[1];
517 
518  if (isDreg) {
520  op0->reg = M68K_REG_D0 + ((info->ir >> 9 ) & 7);
521  } else {
523  op0->reg = M68K_REG_A0 + ((info->ir >> 9 ) & 7);
524  }
525 
526  get_ea_mode_op(info, op1, info->ir, size);
527 }
528 
529 static void build_re_1(m68k_info *info, int opcode, uint8_t size)
530 {
531  build_re_gen_1(info, true, opcode, size);
532 }
533 
534 static void build_er_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
535 {
536  cs_m68k_op* op0;
537  cs_m68k_op* op1;
538  cs_m68k* ext = build_init_op(info, opcode, 2, size);
539 
540  op0 = &ext->operands[0];
541  op1 = &ext->operands[1];
542 
543  get_ea_mode_op(info, op0, info->ir, size);
544 
545  if (isDreg) {
547  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
548  } else {
550  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
551  }
552 }
553 
554 static void build_rr(m68k_info *info, int opcode, uint8_t size, int imm)
555 {
556  cs_m68k_op* op0;
557  cs_m68k_op* op1;
558  cs_m68k_op* op2;
559  cs_m68k* ext = build_init_op(info, opcode, 2, size);
560 
561  op0 = &ext->operands[0];
562  op1 = &ext->operands[1];
563  op2 = &ext->operands[2];
564 
566  op0->reg = M68K_REG_D0 + (info->ir & 7);
567 
569  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
570 
571  if (imm > 0) {
572  ext->op_count = 3;
573  op2->type = M68K_OP_IMM;
575  op2->imm = imm;
576  }
577 }
578 
579 static void build_r(m68k_info *info, int opcode, uint8_t size)
580 {
581  cs_m68k_op* op0;
582  cs_m68k_op* op1;
583  cs_m68k* ext = build_init_op(info, opcode, 2, size);
584 
585  op0 = &ext->operands[0];
586  op1 = &ext->operands[1];
587 
589  op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
590 
592  op1->reg = M68K_REG_D0 + (info->ir & 7);
593 }
594 
595 static void build_imm_ea(m68k_info *info, int opcode, uint8_t size, int imm)
596 {
597  cs_m68k_op* op0;
598  cs_m68k_op* op1;
599  cs_m68k* ext = build_init_op(info, opcode, 2, size);
600 
601  op0 = &ext->operands[0];
602  op1 = &ext->operands[1];
603 
604  op0->type = M68K_OP_IMM;
606  op0->imm = imm;
607 
608  get_ea_mode_op(info, op1, info->ir, size);
609 }
610 
611 static void build_3bit_d(m68k_info *info, int opcode, int size)
612 {
613  cs_m68k_op* op0;
614  cs_m68k_op* op1;
615  cs_m68k* ext = build_init_op(info, opcode, 2, size);
616 
617  op0 = &ext->operands[0];
618  op1 = &ext->operands[1];
619 
620  op0->type = M68K_OP_IMM;
622  op0->imm = g_3bit_qdata_table[(info->ir >> 9) & 7];
623 
625  op1->reg = M68K_REG_D0 + (info->ir & 7);
626 }
627 
628 static void build_3bit_ea(m68k_info *info, int opcode, int size)
629 {
630  cs_m68k_op* op0;
631  cs_m68k_op* op1;
632  cs_m68k* ext = build_init_op(info, opcode, 2, size);
633 
634  op0 = &ext->operands[0];
635  op1 = &ext->operands[1];
636 
637  op0->type = M68K_OP_IMM;
639  op0->imm = g_3bit_qdata_table[(info->ir >> 9) & 7];
640 
641  get_ea_mode_op(info, op1, info->ir, size);
642 }
643 
644 static void build_mm(m68k_info *info, int opcode, uint8_t size, int imm)
645 {
646  cs_m68k_op* op0;
647  cs_m68k_op* op1;
648  cs_m68k_op* op2;
649  cs_m68k* ext = build_init_op(info, opcode, 2, size);
650 
651  op0 = &ext->operands[0];
652  op1 = &ext->operands[1];
653  op2 = &ext->operands[2];
654 
656  op0->reg = M68K_REG_A0 + (info->ir & 7);
657 
659  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
660 
661  if (imm > 0) {
662  ext->op_count = 3;
663  op2->type = M68K_OP_IMM;
665  op2->imm = imm;
666  }
667 }
668 
669 static void build_ea(m68k_info *info, int opcode, uint8_t size)
670 {
671  cs_m68k* ext = build_init_op(info, opcode, 1, size);
672  get_ea_mode_op(info, &ext->operands[0], info->ir, size);
673 }
674 
675 static void build_ea_a(m68k_info *info, int opcode, uint8_t size)
676 {
677  cs_m68k_op* op0;
678  cs_m68k_op* op1;
679  cs_m68k* ext = build_init_op(info, opcode, 2, size);
680 
681  op0 = &ext->operands[0];
682  op1 = &ext->operands[1];
683 
684  get_ea_mode_op(info, op0, info->ir, size);
685 
687  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
688 }
689 
690 static void build_ea_ea(m68k_info *info, int opcode, int size)
691 {
692  cs_m68k_op* op0;
693  cs_m68k_op* op1;
694  cs_m68k* ext = build_init_op(info, opcode, 2, size);
695 
696  op0 = &ext->operands[0];
697  op1 = &ext->operands[1];
698 
699  get_ea_mode_op(info, op0, info->ir, size);
700  get_ea_mode_op(info, op1, (((info->ir>>9) & 7) | ((info->ir>>3) & 0x38)), size);
701 }
702 
703 static void build_pi_pi(m68k_info *info, int opcode, int size)
704 {
705  cs_m68k_op* op0;
706  cs_m68k_op* op1;
707  cs_m68k* ext = build_init_op(info, opcode, 2, size);
708 
709  op0 = &ext->operands[0];
710  op1 = &ext->operands[1];
711 
713  op0->reg = M68K_REG_A0 + (info->ir & 7);
714 
716  op1->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
717 }
718 
719 static void build_imm_special_reg(m68k_info *info, int opcode, int imm, int size, m68k_reg reg)
720 {
721  cs_m68k_op* op0;
722  cs_m68k_op* op1;
723  cs_m68k* ext = build_init_op(info, opcode, 2, size);
724 
725  op0 = &ext->operands[0];
726  op1 = &ext->operands[1];
727 
728  op0->type = M68K_OP_IMM;
730  op0->imm = imm;
731 
732  op1->address_mode = M68K_AM_NONE;
733  op1->reg = reg;
734 }
735 
736 static void build_relative_branch(m68k_info *info, int opcode, int size, int displacement)
737 {
738  cs_m68k_op* op;
739  cs_m68k* ext = build_init_op(info, opcode, 1, size);
740 
741  op = &ext->operands[0];
742 
743  op->type = M68K_OP_BR_DISP;
744  op->address_mode = M68K_AM_BRANCH_DISPLACEMENT;
745  op->br_disp.disp = displacement;
746  op->br_disp.disp_size = size;
747 
750 }
751 
752 static void build_absolute_jump_with_immediate(m68k_info *info, int opcode, int size, int immediate)
753 {
754  cs_m68k_op* op;
755  cs_m68k* ext = build_init_op(info, opcode, 1, size);
756 
757  op = &ext->operands[0];
758 
759  op->type = M68K_OP_IMM;
760  op->address_mode = M68K_AM_IMMEDIATE;
761  op->imm = immediate;
762 
764 }
765 
766 static void build_bcc(m68k_info *info, int size, int displacement)
767 {
768  build_relative_branch(info, s_branch_lut[(info->ir >> 8) & 0xf], size, displacement);
769 }
770 
771 static void build_trap(m68k_info *info, int size, int immediate)
772 {
773  build_absolute_jump_with_immediate(info, s_trap_lut[(info->ir >> 8) & 0xf], size, immediate);
774 }
775 
776 static void build_dbxx(m68k_info *info, int opcode, int size, int displacement)
777 {
778  cs_m68k_op* op0;
779  cs_m68k_op* op1;
780  cs_m68k* ext = build_init_op(info, opcode, 2, size);
781 
782  op0 = &ext->operands[0];
783  op1 = &ext->operands[1];
784 
786  op0->reg = M68K_REG_D0 + (info->ir & 7);
787 
788  op1->type = M68K_OP_BR_DISP;
790  op1->br_disp.disp = displacement;
792 
795 }
796 
797 static void build_dbcc(m68k_info *info, int size, int displacement)
798 {
799  build_dbxx(info, s_dbcc_lut[(info->ir >> 8) & 0xf], size, displacement);
800 }
801 
802 static void build_d_d_ea(m68k_info *info, int opcode, int size)
803 {
804  cs_m68k_op* op0;
805  cs_m68k_op* op1;
806  cs_m68k_op* op2;
807  uint32_t extension = read_imm_16(info);
808  cs_m68k* ext = build_init_op(info, opcode, 3, size);
809 
810  op0 = &ext->operands[0];
811  op1 = &ext->operands[1];
812  op2 = &ext->operands[2];
813 
815  op0->reg = M68K_REG_D0 + (extension & 7);
816 
818  op1->reg = M68K_REG_D0 + ((extension >> 6) & 7);
819 
820  get_ea_mode_op(info, op2, info->ir, size);
821 }
822 
823 static void build_bitfield_ins(m68k_info *info, int opcode, int has_d_arg)
824 {
825  uint8_t offset;
826  uint8_t width;
827  cs_m68k_op* op_ea;
828  cs_m68k_op* op1;
829  cs_m68k* ext = build_init_op(info, opcode, 1, 0);
830  uint32_t extension = read_imm_16(info);
831 
832  op_ea = &ext->operands[0];
833  op1 = &ext->operands[1];
834 
835  if (BIT_B(extension))
836  offset = (extension >> 6) & 7;
837  else
838  offset = (extension >> 6) & 31;
839 
840  if (BIT_5(extension))
841  width = extension & 7;
842  else
843  width = (uint8_t)g_5bit_data_table[extension & 31];
844 
845  if (has_d_arg) {
846  ext->op_count = 2;
848  op1->reg = M68K_REG_D0 + ((extension >> 12) & 7);
849  }
850 
851  get_ea_mode_op(info, op_ea, info->ir, 1);
852 
853  op_ea->mem.bitfield = 1;
854  op_ea->mem.width = width;
855  op_ea->mem.offset = offset;
856 }
857 
858 static void build_d(m68k_info *info, int opcode, int size)
859 {
860  cs_m68k* ext = build_init_op(info, opcode, 1, size);
861  cs_m68k_op* op;
862 
863  op = &ext->operands[0];
864 
865  op->address_mode = M68K_AM_REG_DIRECT_DATA;
866  op->reg = M68K_REG_D0 + (info->ir & 7);
867 }
868 
870 {
871  uint32_t r = v; // r will be reversed bits of v; first get LSB of v
872  uint32_t s = 16 - 1; // extra shift needed at end
873 
874  for (v >>= 1; v; v >>= 1) {
875  r <<= 1;
876  r |= v & 1;
877  s--;
878  }
879 
880  return r <<= s; // shift when v's highest bits are zero
881 }
882 
884 {
885  uint32_t r = v; // r will be reversed bits of v; first get LSB of v
886  uint32_t s = 8 - 1; // extra shift needed at end
887 
888  for (v >>= 1; v; v >>= 1) {
889  r <<= 1;
890  r |= v & 1;
891  s--;
892  }
893 
894  return r <<= s; // shift when v's highest bits are zero
895 }
896 
897 
898 static void build_movem_re(m68k_info *info, int opcode, int size)
899 {
900  cs_m68k_op* op0;
901  cs_m68k_op* op1;
902  cs_m68k* ext = build_init_op(info, opcode, 2, size);
903 
904  op0 = &ext->operands[0];
905  op1 = &ext->operands[1];
906 
907  op0->type = M68K_OP_REG_BITS;
909 
910  get_ea_mode_op(info, op1, info->ir, size);
911 
914 }
915 
916 static void build_movem_er(m68k_info *info, int opcode, int size)
917 {
918  cs_m68k_op* op0;
919  cs_m68k_op* op1;
920  cs_m68k* ext = build_init_op(info, opcode, 2, size);
921 
922  op0 = &ext->operands[0];
923  op1 = &ext->operands[1];
924 
925  op1->type = M68K_OP_REG_BITS;
927 
928  get_ea_mode_op(info, op0, info->ir, size);
929 }
930 
931 static void build_imm(m68k_info *info, int opcode, int data)
932 {
933  cs_m68k_op* op;
934  cs_m68k* ext = build_init_op(info, opcode, 1, 0);
935 
936  MCInst_setOpcode(info->inst, opcode);
937 
938  op = &ext->operands[0];
939 
940  op->type = M68K_OP_IMM;
941  op->address_mode = M68K_AM_IMMEDIATE;
942  op->imm = data;
943 }
944 
945 static void build_illegal(m68k_info *info, int data)
946 {
948 }
949 
950 static void build_invalid(m68k_info *info, int data)
951 {
953 }
954 
955 static void build_cas2(m68k_info *info, int size)
956 {
957  uint32_t word3;
958  uint32_t extension;
959  cs_m68k_op* op0;
960  cs_m68k_op* op1;
961  cs_m68k_op* op2;
963  int reg_0, reg_1;
964 
965  /* cas2 is the only 3 words instruction, word2 and word3 have the same motif bits to check */
966  word3 = peek_imm_32(info) & 0xffff;
967  if (!instruction_is_valid(info, word3))
968  return;
969 
970  op0 = &ext->operands[0];
971  op1 = &ext->operands[1];
972  op2 = &ext->operands[2];
973 
974  extension = read_imm_32(info);
975 
976  op0->address_mode = M68K_AM_NONE;
977  op0->type = M68K_OP_REG_PAIR;
978  op0->reg_pair.reg_0 = ((extension >> 16) & 7) + M68K_REG_D0;
979  op0->reg_pair.reg_1 = (extension & 7) + M68K_REG_D0;
980 
981  op1->address_mode = M68K_AM_NONE;
982  op1->type = M68K_OP_REG_PAIR;
983  op1->reg_pair.reg_0 = ((extension >> 22) & 7) + M68K_REG_D0;
984  op1->reg_pair.reg_1 = ((extension >> 6) & 7) + M68K_REG_D0;
985 
986  reg_0 = (extension >> 28) & 7;
987  reg_1 = (extension >> 12) & 7;
988 
989  op2->address_mode = M68K_AM_NONE;
990  op2->type = M68K_OP_REG_PAIR;
991  op2->reg_pair.reg_0 = reg_0 + (BIT_1F(extension) ? 8 : 0) + M68K_REG_D0;
992  op2->reg_pair.reg_1 = reg_1 + (BIT_F(extension) ? 8 : 0) + M68K_REG_D0;
993 }
994 
995 static void build_chk2_cmp2(m68k_info *info, int size)
996 {
997  cs_m68k_op* op0;
998  cs_m68k_op* op1;
1000 
1001  uint32_t extension = read_imm_16(info);
1002 
1003  if (BIT_B(extension))
1005  else
1007 
1008  op0 = &ext->operands[0];
1009  op1 = &ext->operands[1];
1010 
1011  get_ea_mode_op(info, op0, info->ir, size);
1012 
1013  op1->address_mode = M68K_AM_NONE;
1014  op1->type = M68K_OP_REG;
1015  op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
1016 }
1017 
1018 static void build_move16(m68k_info *info, int data[2], int modes[2])
1019 {
1021  int i;
1022 
1023  for (i = 0; i < 2; ++i) {
1024  cs_m68k_op* op = &ext->operands[i];
1025  const int d = data[i];
1026  const int m = modes[i];
1027 
1028  op->type = M68K_OP_MEM;
1029 
1031  op->address_mode = m;
1032  op->reg = M68K_REG_A0 + d;
1033  } else {
1034  op->address_mode = m;
1035  op->imm = d;
1036  }
1037  }
1038 }
1039 
1040 static void build_link(m68k_info *info, int disp, int size)
1041 {
1042  cs_m68k_op* op0;
1043  cs_m68k_op* op1;
1045 
1046  op0 = &ext->operands[0];
1047  op1 = &ext->operands[1];
1048 
1049  op0->address_mode = M68K_AM_NONE;
1050  op0->reg = M68K_REG_A0 + (info->ir & 7);
1051 
1053  op1->type = M68K_OP_IMM;
1054  op1->imm = disp;
1055 }
1056 
1057 static void build_cpush_cinv(m68k_info *info, int op_offset)
1058 {
1059  cs_m68k_op* op0;
1060  cs_m68k_op* op1;
1062 
1063  switch ((info->ir >> 3) & 3) { // scope
1064  // Invalid
1065  case 0:
1067  return;
1068  // Line
1069  case 1:
1070  MCInst_setOpcode(info->inst, op_offset + 0);
1071  break;
1072  // Page
1073  case 2:
1074  MCInst_setOpcode(info->inst, op_offset + 1);
1075  break;
1076  // All
1077  case 3:
1078  ext->op_count = 1;
1079  MCInst_setOpcode(info->inst, op_offset + 2);
1080  break;
1081  }
1082 
1083  op0 = &ext->operands[0];
1084  op1 = &ext->operands[1];
1085 
1087  op0->type = M68K_OP_IMM;
1088  op0->imm = (info->ir >> 6) & 3;
1089 
1090  op1->type = M68K_OP_MEM;
1092  op1->imm = M68K_REG_A0 + (info->ir & 7);
1093 }
1094 
1095 static void build_movep_re(m68k_info *info, int size)
1096 {
1097  cs_m68k_op* op0;
1098  cs_m68k_op* op1;
1100 
1101  op0 = &ext->operands[0];
1102  op1 = &ext->operands[1];
1103 
1104  op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
1105 
1107  op1->type = M68K_OP_MEM;
1108  op1->mem.base_reg = M68K_REG_A0 + (info->ir & 7);
1109  op1->mem.disp = (int16_t)read_imm_16(info);
1110 }
1111 
1112 static void build_movep_er(m68k_info *info, int size)
1113 {
1114  cs_m68k_op* op0;
1115  cs_m68k_op* op1;
1117 
1118  op0 = &ext->operands[0];
1119  op1 = &ext->operands[1];
1120 
1122  op0->type = M68K_OP_MEM;
1123  op0->mem.base_reg = M68K_REG_A0 + (info->ir & 7);
1124  op0->mem.disp = (int16_t)read_imm_16(info);
1125 
1126  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
1127 }
1128 
1129 static void build_moves(m68k_info *info, int size)
1130 {
1131  cs_m68k_op* op0;
1132  cs_m68k_op* op1;
1134  uint32_t extension = read_imm_16(info);
1135 
1136  op0 = &ext->operands[0];
1137  op1 = &ext->operands[1];
1138 
1139  if (BIT_B(extension)) {
1140  op0->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
1141  get_ea_mode_op(info, op1, info->ir, size);
1142  } else {
1143  get_ea_mode_op(info, op0, info->ir, size);
1144  op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
1145  }
1146 }
1147 
1148 static void build_er_1(m68k_info *info, int opcode, uint8_t size)
1149 {
1150  build_er_gen_1(info, true, opcode, size);
1151 }
1152 
1153 /* ======================================================================== */
1154 /* ========================= INSTRUCTION HANDLERS ========================= */
1155 /* ======================================================================== */
1156 /* Instruction handler function names follow this convention:
1157  *
1158  * d68000_NAME_EXTENSIONS(void)
1159  * where NAME is the name of the opcode it handles and EXTENSIONS are any
1160  * extensions for special instances of that opcode.
1161  *
1162  * Examples:
1163  * d68000_add_er_8(): add opcode, from effective address to register,
1164  * size = byte
1165  *
1166  * d68000_asr_s_8(): arithmetic shift right, static count, size = byte
1167  *
1168  *
1169  * Common extensions:
1170  * 8 : size = byte
1171  * 16 : size = word
1172  * 32 : size = long
1173  * rr : register to register
1174  * mm : memory to memory
1175  * r : register
1176  * s : static
1177  * er : effective address -> register
1178  * re : register -> effective address
1179  * ea : using effective address mode of operation
1180  * d : data register direct
1181  * a : address register direct
1182  * ai : address register indirect
1183  * pi : address register indirect with postincrement
1184  * pd : address register indirect with predecrement
1185  * di : address register indirect with displacement
1186  * ix : address register indirect with index
1187  * aw : absolute word
1188  * al : absolute long
1189  */
1190 
1191 
1193 {
1194  build_invalid(info, info->ir);
1195 }
1196 
1198 {
1199  build_illegal(info, info->ir);
1200 }
1201 
1203 {
1204  build_invalid(info, info->ir);
1205 }
1206 
1208 {
1209  build_invalid(info, info->ir);
1210 }
1211 
1213 {
1214  build_rr(info, M68K_INS_ABCD, 1, 0);
1215 }
1216 
1218 {
1219  build_mm(info, M68K_INS_ABCD, 1, 0);
1220 }
1221 
1223 {
1225 }
1226 
1228 {
1230 }
1231 
1233 {
1235 }
1236 
1238 {
1240 }
1241 
1243 {
1245 }
1246 
1248 {
1250 }
1251 
1253 {
1255 }
1256 
1258 {
1260 }
1261 
1263 {
1265 }
1266 
1268 {
1270 }
1271 
1273 {
1275 }
1276 
1278 {
1280 }
1281 
1283 {
1285 }
1286 
1288 {
1290 }
1291 
1293 {
1294  build_rr(info, M68K_INS_ADDX, 1, 0);
1295 }
1296 
1298 {
1299  build_rr(info, M68K_INS_ADDX, 2, 0);
1300 }
1301 
1303 {
1304  build_rr(info, M68K_INS_ADDX, 4, 0);
1305 }
1306 
1308 {
1309  build_mm(info, M68K_INS_ADDX, 1, 0);
1310 }
1311 
1313 {
1314  build_mm(info, M68K_INS_ADDX, 2, 0);
1315 }
1316 
1318 {
1319  build_mm(info, M68K_INS_ADDX, 4, 0);
1320 }
1321 
1323 {
1325 }
1326 
1328 {
1330 }
1331 
1333 {
1335 }
1336 
1338 {
1340 }
1341 
1343 {
1345 }
1346 
1348 {
1350 }
1351 
1353 {
1355 }
1356 
1358 {
1360 }
1361 
1363 {
1365 }
1366 
1368 {
1370 }
1371 
1373 {
1375 }
1376 
1378 {
1380 }
1381 
1383 {
1385 }
1386 
1388 {
1390 }
1391 
1393 {
1394  build_r(info, M68K_INS_ASR, 1);
1395 }
1396 
1398 {
1399  build_r(info, M68K_INS_ASR, 2);
1400 }
1401 
1403 {
1404  build_r(info, M68K_INS_ASR, 4);
1405 }
1406 
1408 {
1409  build_ea(info, M68K_INS_ASR, 2);
1410 }
1411 
1413 {
1415 }
1416 
1418 {
1420 }
1421 
1423 {
1425 }
1426 
1428 {
1429  build_r(info, M68K_INS_ASL, 1);
1430 }
1431 
1433 {
1434  build_r(info, M68K_INS_ASL, 2);
1435 }
1436 
1438 {
1439  build_r(info, M68K_INS_ASL, 4);
1440 }
1441 
1443 {
1444  build_ea(info, M68K_INS_ASL, 2);
1445 }
1446 
1448 {
1449  build_bcc(info, 1, make_int_8(info->ir));
1450 }
1451 
1453 {
1455 }
1456 
1458 {
1461 }
1462 
1464 {
1466 }
1467 
1469 {
1471 }
1472 
1474 {
1476 }
1477 
1479 {
1481 }
1482 
1484 {
1487 }
1488 
1490 {
1493 }
1494 
1495 
1497 {
1500 }
1501 
1503 {
1506 }
1507 
1509 {
1512 }
1513 
1515 {
1518 }
1519 
1521 {
1522  cs_m68k* ext = &info->extension;
1523  cs_m68k_op temp;
1524 
1527 
1528  // a bit hacky but we need to flip the args on only this instruction
1529 
1530  temp = ext->operands[0];
1531  ext->operands[0] = ext->operands[1];
1532  ext->operands[1] = temp;
1533 }
1534 
1536 {
1539 }
1540 
1542 {
1544 }
1545 
1547 {
1549 }
1550 
1552 {
1554 }
1555 
1557 {
1560 }
1561 
1563 {
1565 }
1566 
1568 {
1570 }
1571 
1573 {
1575 }
1576 
1578 {
1580 }
1581 
1583 {
1586 }
1587 
1589 {
1591 }
1592 
1594 {
1596 }
1597 
1599 {
1602 }
1603 
1605 {
1608 }
1609 
1611 {
1614 }
1615 
1617 {
1620 }
1621 
1623 {
1624  build_cas2(info, 2);
1625 }
1626 
1628 {
1629  build_cas2(info, 4);
1630 }
1631 
1633 {
1635 }
1636 
1638 {
1641 }
1642 
1644 {
1646  build_chk2_cmp2(info, 1);
1647 }
1648 
1650 {
1652  build_chk2_cmp2(info, 2);
1653 }
1654 
1656 {
1658  build_chk2_cmp2(info, 4);
1659 }
1660 
1662 {
1665 }
1666 
1668 {
1669  build_ea(info, M68K_INS_CLR, 1);
1670 }
1671 
1673 {
1674  build_ea(info, M68K_INS_CLR, 2);
1675 }
1676 
1678 {
1679  build_ea(info, M68K_INS_CLR, 4);
1680 }
1681 
1683 {
1685 }
1686 
1688 {
1690 }
1691 
1693 {
1695 }
1696 
1698 {
1700 }
1701 
1703 {
1705 }
1706 
1708 {
1710 }
1711 
1713 {
1716 }
1717 
1719 {
1722 }
1723 
1725 {
1727 }
1728 
1730 {
1733 }
1734 
1736 {
1739 }
1740 
1742 {
1744 }
1745 
1747 {
1750 }
1751 
1753 {
1756 }
1757 
1759 {
1761 }
1762 
1764 {
1766 }
1767 
1769 {
1771 }
1772 
1773 static void make_cpbcc_operand(cs_m68k_op* op, int size, int displacement)
1774 {
1775  op->address_mode = M68K_AM_BRANCH_DISPLACEMENT;
1776  op->type = M68K_OP_BR_DISP;
1777  op->br_disp.disp = displacement;
1778  op->br_disp.disp_size = size;
1779 }
1780 
1782 {
1783  cs_m68k_op* op0;
1784  cs_m68k* ext;
1786 
1787  // these are all in row with the extension so just doing a add here is fine
1788  info->inst->Opcode += (info->ir & 0x2f);
1789 
1790  ext = build_init_op(info, M68K_INS_FBF, 1, 2);
1791  op0 = &ext->operands[0];
1792 
1794 
1797 }
1798 
1800 {
1801  cs_m68k* ext;
1802  cs_m68k_op* op0;
1803 
1805 
1807 
1808  // these are all in row with the extension so just doing a add here is fine
1809  info->inst->Opcode += (info->ir & 0x2f);
1810 
1811  ext = build_init_op(info, M68K_INS_FBF, 1, 4);
1812  op0 = &ext->operands[0];
1813 
1815 
1818 }
1819 
1821 {
1822  cs_m68k* ext;
1823  cs_m68k_op* op0;
1824  cs_m68k_op* op1;
1825  uint32_t ext1, ext2;
1826 
1828 
1829  ext1 = read_imm_16(info);
1830  ext2 = read_imm_16(info);
1831 
1832  // these are all in row with the extension so just doing a add here is fine
1833  info->inst->Opcode += (ext1 & 0x2f);
1834 
1835  ext = build_init_op(info, M68K_INS_FDBF, 2, 0);
1836  op0 = &ext->operands[0];
1837  op1 = &ext->operands[1];
1838 
1839  op0->reg = M68K_REG_D0 + (info->ir & 7);
1840 
1842 
1845 }
1846 
1847 static void fmove_fpcr(m68k_info *info, uint32_t extension)
1848 {
1850  cs_m68k_op* op_ea;
1851 
1852  int regsel = (extension >> 10) & 0x7;
1853  int dir = (extension >> 13) & 0x1;
1854 
1856 
1857  special = &ext->operands[0];
1858  op_ea = &ext->operands[1];
1859 
1860  if (!dir) {
1861  cs_m68k_op* t = special;
1862  special = op_ea;
1863  op_ea = t;
1864  }
1865 
1866  get_ea_mode_op(info, op_ea, info->ir, 4);
1867 
1868  if (regsel & 4)
1869  special->reg = M68K_REG_FPCR;
1870  else if (regsel & 2)
1871  special->reg = M68K_REG_FPSR;
1872  else if (regsel & 1)
1873  special->reg = M68K_REG_FPIAR;
1874 }
1875 
1876 static void fmovem(m68k_info *info, uint32_t extension)
1877 {
1878  cs_m68k_op* op_reglist;
1879  cs_m68k_op* op_ea;
1880  int dir = (extension >> 13) & 0x1;
1881  int mode = (extension >> 11) & 0x3;
1882  uint32_t reglist = extension & 0xff;
1884 
1885  op_reglist = &ext->operands[0];
1886  op_ea = &ext->operands[1];
1887 
1888  // flip args around
1889 
1890  if (!dir) {
1891  cs_m68k_op* t = op_reglist;
1892  op_reglist = op_ea;
1893  op_ea = t;
1894  }
1895 
1896  get_ea_mode_op(info, op_ea, info->ir, 0);
1897 
1898  switch (mode) {
1899  case 1 : // Dynamic list in dn register
1900  op_reglist->reg = M68K_REG_D0 + ((reglist >> 4) & 7);
1901  break;
1902 
1903  case 0 :
1904  op_reglist->address_mode = M68K_AM_NONE;
1905  op_reglist->type = M68K_OP_REG_BITS;
1906  op_reglist->register_bits = reglist << 16;
1907  break;
1908 
1909  case 2 : // Static list
1910  op_reglist->address_mode = M68K_AM_NONE;
1911  op_reglist->type = M68K_OP_REG_BITS;
1912  op_reglist->register_bits = ((uint32_t)reverse_bits_8(reglist)) << 16;
1913  break;
1914  }
1915 }
1916 
1918 {
1919  cs_m68k *ext;
1920  cs_m68k_op* op0;
1921  cs_m68k_op* op1;
1922  bool supports_single_op;
1923  uint32_t next;
1924  int rm, src, dst, opmode;
1925 
1926 
1928 
1929  supports_single_op = true;
1930 
1931  next = read_imm_16(info);
1932 
1933  rm = (next >> 14) & 0x1;
1934  src = (next >> 10) & 0x7;
1935  dst = (next >> 7) & 0x7;
1936  opmode = next & 0x3f;
1937 
1938  // special handling for fmovecr
1939 
1940  if (BITFIELD(info->ir, 5, 0) == 0 && BITFIELD(next, 15, 10) == 0x17) {
1941  cs_m68k_op* op0;
1942  cs_m68k_op* op1;
1944 
1945  op0 = &ext->operands[0];
1946  op1 = &ext->operands[1];
1947 
1949  op0->type = M68K_OP_IMM;
1950  op0->imm = next & 0x3f;
1951 
1952  op1->reg = M68K_REG_FP0 + ((next >> 7) & 7);
1953 
1954  return;
1955  }
1956 
1957  // deal with extended move stuff
1958 
1959  switch ((next >> 13) & 0x7) {
1960  // fmovem fpcr
1961  case 0x4: // FMOVEM ea, FPCR
1962  case 0x5: // FMOVEM FPCR, ea
1963  fmove_fpcr(info, next);
1964  return;
1965 
1966  // fmovem list
1967  case 0x6:
1968  case 0x7:
1969  fmovem(info, next);
1970  return;
1971  }
1972 
1973  // See comment bellow on why this is being done
1974 
1975  if ((next >> 6) & 1)
1976  opmode &= ~4;
1977 
1978  // special handling of some instructions here
1979 
1980  switch (opmode) {
1981  case 0x00: MCInst_setOpcode(info->inst, M68K_INS_FMOVE); supports_single_op = false; break;
1982  case 0x01: MCInst_setOpcode(info->inst, M68K_INS_FINT); break;
1983  case 0x02: MCInst_setOpcode(info->inst, M68K_INS_FSINH); break;
1984  case 0x03: MCInst_setOpcode(info->inst, M68K_INS_FINTRZ); break;
1985  case 0x04: MCInst_setOpcode(info->inst, M68K_INS_FSQRT); break;
1986  case 0x06: MCInst_setOpcode(info->inst, M68K_INS_FLOGNP1); break;
1987  case 0x08: MCInst_setOpcode(info->inst, M68K_INS_FETOXM1); break;
1988  case 0x09: MCInst_setOpcode(info->inst, M68K_INS_FATANH); break;
1989  case 0x0a: MCInst_setOpcode(info->inst, M68K_INS_FATAN); break;
1990  case 0x0c: MCInst_setOpcode(info->inst, M68K_INS_FASIN); break;
1991  case 0x0d: MCInst_setOpcode(info->inst, M68K_INS_FATANH); break;
1992  case 0x0e: MCInst_setOpcode(info->inst, M68K_INS_FSIN); break;
1993  case 0x0f: MCInst_setOpcode(info->inst, M68K_INS_FTAN); break;
1994  case 0x10: MCInst_setOpcode(info->inst, M68K_INS_FETOX); break;
1995  case 0x11: MCInst_setOpcode(info->inst, M68K_INS_FTWOTOX); break;
1996  case 0x12: MCInst_setOpcode(info->inst, M68K_INS_FTENTOX); break;
1997  case 0x14: MCInst_setOpcode(info->inst, M68K_INS_FLOGN); break;
1998  case 0x15: MCInst_setOpcode(info->inst, M68K_INS_FLOG10); break;
1999  case 0x16: MCInst_setOpcode(info->inst, M68K_INS_FLOG2); break;
2000  case 0x18: MCInst_setOpcode(info->inst, M68K_INS_FABS); break;
2001  case 0x19: MCInst_setOpcode(info->inst, M68K_INS_FCOSH); break;
2002  case 0x1a: MCInst_setOpcode(info->inst, M68K_INS_FNEG); break;
2003  case 0x1c: MCInst_setOpcode(info->inst, M68K_INS_FACOS); break;
2004  case 0x1d: MCInst_setOpcode(info->inst, M68K_INS_FCOS); break;
2005  case 0x1e: MCInst_setOpcode(info->inst, M68K_INS_FGETEXP); break;
2006  case 0x1f: MCInst_setOpcode(info->inst, M68K_INS_FGETMAN); break;
2007  case 0x20: MCInst_setOpcode(info->inst, M68K_INS_FDIV); supports_single_op = false; break;
2008  case 0x21: MCInst_setOpcode(info->inst, M68K_INS_FMOD); supports_single_op = false; break;
2009  case 0x22: MCInst_setOpcode(info->inst, M68K_INS_FADD); supports_single_op = false; break;
2010  case 0x23: MCInst_setOpcode(info->inst, M68K_INS_FMUL); supports_single_op = false; break;
2011  case 0x24: MCInst_setOpcode(info->inst, M68K_INS_FSGLDIV); supports_single_op = false; break;
2012  case 0x25: MCInst_setOpcode(info->inst, M68K_INS_FREM); break;
2013  case 0x26: MCInst_setOpcode(info->inst, M68K_INS_FSCALE); break;
2014  case 0x27: MCInst_setOpcode(info->inst, M68K_INS_FSGLMUL); break;
2015  case 0x28: MCInst_setOpcode(info->inst, M68K_INS_FSUB); supports_single_op = false; break;
2016  case 0x38: MCInst_setOpcode(info->inst, M68K_INS_FCMP); supports_single_op = false; break;
2017  case 0x3a: MCInst_setOpcode(info->inst, M68K_INS_FTST); break;
2018  default:
2019  break;
2020  }
2021 
2022  // Some trickery here! It's not documented but if bit 6 is set this is a s/d opcode and then
2023  // if bit 2 is set it's a d. As we already have set our opcode in the code above we can just
2024  // offset it as the following 2 op codes (if s/d is supported) will always be directly after it
2025 
2026  if ((next >> 6) & 1) {
2027  if ((next >> 2) & 1)
2028  info->inst->Opcode += 2;
2029  else
2030  info->inst->Opcode += 1;
2031  }
2032 
2033  ext = &info->extension;
2034 
2035  ext->op_count = 2;
2036  ext->op_size.type = M68K_SIZE_TYPE_CPU;
2037  ext->op_size.cpu_size = 0;
2038 
2039  // Special case - adjust direction of fmove
2040  if ((opmode == 0x00) && ((next >> 13) & 0x1) != 0) {
2041  op0 = &ext->operands[1];
2042  op1 = &ext->operands[0];
2043  } else {
2044  op0 = &ext->operands[0];
2045  op1 = &ext->operands[1];
2046  }
2047 
2048  if (rm == 0 && supports_single_op && src == dst) {
2049  ext->op_count = 1;
2050  op0->reg = M68K_REG_FP0 + dst;
2051  return;
2052  }
2053 
2054  if (rm == 1) {
2055  switch (src) {
2056  case 0x00 :
2057  ext->op_size.cpu_size = M68K_CPU_SIZE_LONG;
2058  get_ea_mode_op(info, op0, info->ir, 4);
2059  break;
2060 
2061  case 0x06 :
2062  ext->op_size.cpu_size = M68K_CPU_SIZE_BYTE;
2063  get_ea_mode_op(info, op0, info->ir, 1);
2064  break;
2065 
2066  case 0x04 :
2067  ext->op_size.cpu_size = M68K_CPU_SIZE_WORD;
2068  get_ea_mode_op(info, op0, info->ir, 2);
2069  break;
2070 
2071  case 0x01 :
2072  ext->op_size.type = M68K_SIZE_TYPE_FPU;
2073  ext->op_size.fpu_size = M68K_FPU_SIZE_SINGLE;
2074  get_ea_mode_op(info, op0, info->ir, 4);
2075  op0->type = M68K_OP_FP_SINGLE;
2076  break;
2077 
2078  case 0x05:
2079  ext->op_size.type = M68K_SIZE_TYPE_FPU;
2080  ext->op_size.fpu_size = M68K_FPU_SIZE_DOUBLE;
2081  get_ea_mode_op(info, op0, info->ir, 8);
2082  op0->type = M68K_OP_FP_DOUBLE;
2083  break;
2084 
2085  default :
2086  ext->op_size.type = M68K_SIZE_TYPE_FPU;
2087  ext->op_size.fpu_size = M68K_FPU_SIZE_EXTENDED;
2088  break;
2089  }
2090  } else {
2091  op0->reg = M68K_REG_FP0 + src;
2092  }
2093 
2094  op1->reg = M68K_REG_FP0 + dst;
2095 }
2096 
2098 {
2099  cs_m68k* ext;
2101 
2103  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
2104 }
2105 
2107 {
2108  cs_m68k* ext;
2109 
2111 
2113  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
2114 }
2115 
2117 {
2118  cs_m68k* ext;
2119 
2121  ext = build_init_op(info, M68K_INS_FSF, 1, 1);
2122 
2123  // these are all in row with the extension so just doing a add here is fine
2124  info->inst->Opcode += (read_imm_16(info) & 0x2f);
2125 
2126  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
2127 }
2128 
2130 {
2131  uint32_t extension1;
2133 
2134  extension1 = read_imm_16(info);
2135 
2137 
2138  // these are all in row with the extension so just doing a add here is fine
2139  info->inst->Opcode += (extension1 & 0x2f);
2140 }
2141 
2143 {
2144  uint32_t extension1, extension2;
2145  cs_m68k_op* op0;
2146  cs_m68k* ext;
2147 
2149 
2150  extension1 = read_imm_16(info);
2151  extension2 = read_imm_16(info);
2152 
2154 
2155  // these are all in row with the extension so just doing a add here is fine
2156  info->inst->Opcode += (extension1 & 0x2f);
2157 
2158  op0 = &ext->operands[0];
2159 
2161  op0->type = M68K_OP_IMM;
2162  op0->imm = extension2;
2163 }
2164 
2166 {
2167  uint32_t extension1, extension2;
2168  cs_m68k* ext;
2169  cs_m68k_op* op0;
2170 
2172 
2173  extension1 = read_imm_16(info);
2174  extension2 = read_imm_32(info);
2175 
2177 
2178  // these are all in row with the extension so just doing a add here is fine
2179  info->inst->Opcode += (extension1 & 0x2f);
2180 
2181  op0 = &ext->operands[0];
2182 
2184  op0->type = M68K_OP_IMM;
2185  op0->imm = extension2;
2186 }
2187 
2189 {
2192 }
2193 
2195 {
2197 }
2198 
2200 {
2202 }
2203 
2205 {
2207 }
2208 
2210 {
2212 }
2213 
2215 {
2216  uint32_t extension, insn_signed;
2217  cs_m68k* ext;
2218  cs_m68k_op* op0;
2219  cs_m68k_op* op1;
2220  uint32_t reg_0, reg_1;
2221 
2223 
2224  extension = read_imm_16(info);
2225  insn_signed = 0;
2226 
2227  if (BIT_B((extension)))
2228  insn_signed = 1;
2229 
2230  ext = build_init_op(info, insn_signed ? M68K_INS_DIVS : M68K_INS_DIVU, 2, 4);
2231 
2232  op0 = &ext->operands[0];
2233  op1 = &ext->operands[1];
2234 
2235  get_ea_mode_op(info, op0, info->ir, 4);
2236 
2237  reg_0 = extension & 7;
2238  reg_1 = (extension >> 12) & 7;
2239 
2240  op1->address_mode = M68K_AM_NONE;
2241  op1->type = M68K_OP_REG_PAIR;
2242  op1->reg_pair.reg_0 = reg_0 + M68K_REG_D0;
2243  op1->reg_pair.reg_1 = reg_1 + M68K_REG_D0;
2244 
2245  if ((reg_0 == reg_1) || !BIT_A(extension)) {
2246  op1->type = M68K_OP_REG;
2247  op1->reg = M68K_REG_D0 + reg_1;
2248  }
2249 }
2250 
2252 {
2254 }
2255 
2257 {
2259 }
2260 
2262 {
2264 }
2265 
2267 {
2269 }
2270 
2272 {
2274 }
2275 
2277 {
2279 }
2280 
2282 {
2284 }
2285 
2287 {
2289 }
2290 
2292 {
2293  build_r(info, M68K_INS_EXG, 4);
2294 }
2295 
2297 {
2298  cs_m68k_op* op0;
2299  cs_m68k_op* op1;
2301 
2302  op0 = &ext->operands[0];
2303  op1 = &ext->operands[1];
2304 
2305  op0->address_mode = M68K_AM_NONE;
2306  op0->reg = M68K_REG_A0 + ((info->ir >> 9) & 7);
2307 
2308  op1->address_mode = M68K_AM_NONE;
2309  op1->reg = M68K_REG_A0 + (info->ir & 7);
2310 }
2311 
2313 {
2314  cs_m68k_op* op0;
2315  cs_m68k_op* op1;
2317 
2318  op0 = &ext->operands[0];
2319  op1 = &ext->operands[1];
2320 
2321  op0->address_mode = M68K_AM_NONE;
2322  op0->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
2323 
2324  op1->address_mode = M68K_AM_NONE;
2325  op1->reg = M68K_REG_A0 + (info->ir & 7);
2326 }
2327 
2329 {
2330  build_d(info, M68K_INS_EXT, 2);
2331 }
2332 
2334 {
2335  build_d(info, M68K_INS_EXT, 4);
2336 }
2337 
2339 {
2341  build_d(info, M68K_INS_EXTB, 4);
2342 }
2343 
2345 {
2348  get_ea_mode_op(info, &ext->operands[0], info->ir, 4);
2349 }
2350 
2352 {
2355  get_ea_mode_op(info, &ext->operands[0], info->ir, 4);
2356 }
2357 
2359 {
2361 }
2362 
2364 {
2366 }
2367 
2369 {
2372 }
2373 
2375 {
2377 }
2378 
2380 {
2382 }
2383 
2385 {
2387 }
2388 
2390 {
2391  build_r(info, M68K_INS_LSR, 1);
2392 }
2393 
2395 {
2396  build_r(info, M68K_INS_LSR, 2);
2397 }
2398 
2400 {
2401  build_r(info, M68K_INS_LSR, 4);
2402 }
2403 
2405 {
2406  build_ea(info, M68K_INS_LSR, 2);
2407 }
2408 
2410 {
2412 }
2413 
2415 {
2417 }
2418 
2420 {
2422 }
2423 
2425 {
2426  build_r(info, M68K_INS_LSL, 1);
2427 }
2428 
2430 {
2431  build_r(info, M68K_INS_LSL, 2);
2432 }
2433 
2435 {
2436  build_r(info, M68K_INS_LSL, 4);
2437 }
2438 
2440 {
2441  build_ea(info, M68K_INS_LSL, 2);
2442 }
2443 
2445 {
2447 }
2448 
2450 {
2452 }
2453 
2455 {
2457 }
2458 
2460 {
2462 }
2463 
2465 {
2467 }
2468 
2470 {
2471  cs_m68k_op* op0;
2472  cs_m68k_op* op1;
2474 
2475  op0 = &ext->operands[0];
2476  op1 = &ext->operands[1];
2477 
2478  get_ea_mode_op(info, op0, info->ir, 1);
2479 
2480  op1->address_mode = M68K_AM_NONE;
2481  op1->reg = M68K_REG_CCR;
2482 }
2483 
2485 {
2486  cs_m68k_op* op0;
2487  cs_m68k_op* op1;
2488  cs_m68k* ext;
2489 
2491 
2492  ext = build_init_op(info, M68K_INS_MOVE, 2, 2);
2493 
2494  op0 = &ext->operands[0];
2495  op1 = &ext->operands[1];
2496 
2497  op0->address_mode = M68K_AM_NONE;
2498  op0->reg = M68K_REG_CCR;
2499 
2500  get_ea_mode_op(info, op1, info->ir, 1);
2501 }
2502 
2504 {
2505  cs_m68k_op* op0;
2506  cs_m68k_op* op1;
2508 
2509  op0 = &ext->operands[0];
2510  op1 = &ext->operands[1];
2511 
2512  op0->address_mode = M68K_AM_NONE;
2513  op0->reg = M68K_REG_SR;
2514 
2515  get_ea_mode_op(info, op1, info->ir, 2);
2516 }
2517 
2519 {
2520  cs_m68k_op* op0;
2521  cs_m68k_op* op1;
2523 
2524  op0 = &ext->operands[0];
2525  op1 = &ext->operands[1];
2526 
2527  get_ea_mode_op(info, op0, info->ir, 2);
2528 
2529  op1->address_mode = M68K_AM_NONE;
2530  op1->reg = M68K_REG_SR;
2531 }
2532 
2534 {
2535  cs_m68k_op* op0;
2536  cs_m68k_op* op1;
2538 
2539  op0 = &ext->operands[0];
2540  op1 = &ext->operands[1];
2541 
2542  op0->address_mode = M68K_AM_NONE;
2543  op0->reg = M68K_REG_USP;
2544 
2545  op1->address_mode = M68K_AM_NONE;
2546  op1->reg = M68K_REG_A0 + (info->ir & 7);
2547 }
2548 
2550 {
2551  cs_m68k_op* op0;
2552  cs_m68k_op* op1;
2554 
2555  op0 = &ext->operands[0];
2556  op1 = &ext->operands[1];
2557 
2558  op0->address_mode = M68K_AM_NONE;
2559  op0->reg = M68K_REG_A0 + (info->ir & 7);
2560 
2561  op1->address_mode = M68K_AM_NONE;
2562  op1->reg = M68K_REG_USP;
2563 }
2564 
2566 {
2567  uint32_t extension;
2568  m68k_reg reg;
2569  cs_m68k* ext;
2570  cs_m68k_op* op0;
2571  cs_m68k_op* op1;
2572 
2573 
2575 
2576  extension = read_imm_16(info);
2578 
2580 
2581  op0 = &ext->operands[0];
2582  op1 = &ext->operands[1];
2583 
2584  switch (extension & 0xfff) {
2585  case 0x000: reg = M68K_REG_SFC; break;
2586  case 0x001: reg = M68K_REG_DFC; break;
2587  case 0x800: reg = M68K_REG_USP; break;
2588  case 0x801: reg = M68K_REG_VBR; break;
2589  case 0x002: reg = M68K_REG_CACR; break;
2590  case 0x802: reg = M68K_REG_CAAR; break;
2591  case 0x803: reg = M68K_REG_MSP; break;
2592  case 0x804: reg = M68K_REG_ISP; break;
2593  case 0x003: reg = M68K_REG_TC; break;
2594  case 0x004: reg = M68K_REG_ITT0; break;
2595  case 0x005: reg = M68K_REG_ITT1; break;
2596  case 0x006: reg = M68K_REG_DTT0; break;
2597  case 0x007: reg = M68K_REG_DTT1; break;
2598  case 0x805: reg = M68K_REG_MMUSR; break;
2599  case 0x806: reg = M68K_REG_URP; break;
2600  case 0x807: reg = M68K_REG_SRP; break;
2601  }
2602 
2603  if (BIT_1(info->ir)) {
2604  op0->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
2605  op1->reg = reg;
2606  } else {
2607  op0->reg = reg;
2608  op1->reg = (BIT_F(extension) ? M68K_REG_A0 : M68K_REG_D0) + ((extension >> 12) & 7);
2609  }
2610 }
2611 
2613 {
2615 }
2616 
2618 {
2620 }
2621 
2623 {
2625 }
2626 
2628 {
2630 }
2631 
2633 {
2635 }
2636 
2638 {
2640 }
2641 
2643 {
2644  build_movep_re(info, 2);
2645 }
2646 
2648 {
2649  build_movep_re(info, 4);
2650 }
2651 
2653 {
2654  build_movep_er(info, 2);
2655 }
2656 
2658 {
2659  build_movep_er(info, 4);
2660 }
2661 
2663 {
2665  build_moves(info, 1);
2666 }
2667 
2669 {
2670  //uint32_t extension;
2672  build_moves(info, 2);
2673 }
2674 
2676 {
2678  build_moves(info, 4);
2679 }
2680 
2682 {
2683  cs_m68k_op* op0;
2684  cs_m68k_op* op1;
2685 
2687 
2688  op0 = &ext->operands[0];
2689  op1 = &ext->operands[1];
2690 
2691  op0->type = M68K_OP_IMM;
2693  op0->imm = (info->ir & 0xff);
2694 
2696  op1->reg = M68K_REG_D0 + ((info->ir >> 9) & 7);
2697 }
2698 
2700 {
2701  int data[] = { info->ir & 7, (read_imm_16(info) >> 12) & 7 };
2703 
2705 
2706  build_move16(info, data, modes);
2707 }
2708 
2710 {
2711  int data[] = { info->ir & 7, read_imm_32(info) };
2713 
2715 
2716  build_move16(info, data, modes);
2717 }
2718 
2720 {
2721  int data[] = { read_imm_32(info), info->ir & 7 };
2723 
2725 
2726  build_move16(info, data, modes);
2727 }
2728 
2730 {
2731  int data[] = { info->ir & 7, read_imm_32(info) };
2733 
2735 
2736  build_move16(info, data, modes);
2737 }
2738 
2740 {
2741  int data[] = { read_imm_32(info), info->ir & 7 };
2743 
2745 
2746  build_move16(info, data, modes);
2747 }
2748 
2750 {
2752 }
2753 
2755 {
2757 }
2758 
2760 {
2761  uint32_t extension, insn_signed;
2762  cs_m68k* ext;
2763  cs_m68k_op* op0;
2764  cs_m68k_op* op1;
2765  uint32_t reg_0, reg_1;
2766 
2768 
2769  extension = read_imm_16(info);
2770  insn_signed = 0;
2771 
2772  if (BIT_B((extension)))
2773  insn_signed = 1;
2774 
2775  ext = build_init_op(info, insn_signed ? M68K_INS_MULS : M68K_INS_MULU, 2, 4);
2776 
2777  op0 = &ext->operands[0];
2778  op1 = &ext->operands[1];
2779 
2780  get_ea_mode_op(info, op0, info->ir, 4);
2781 
2782  reg_0 = extension & 7;
2783  reg_1 = (extension >> 12) & 7;
2784 
2785  op1->address_mode = M68K_AM_NONE;
2786  op1->type = M68K_OP_REG_PAIR;
2787  op1->reg_pair.reg_0 = reg_0 + M68K_REG_D0;
2788  op1->reg_pair.reg_1 = reg_1 + M68K_REG_D0;
2789 
2790  if (!BIT_A(extension)) {
2791  op1->type = M68K_OP_REG;
2792  op1->reg = M68K_REG_D0 + reg_1;
2793  }
2794 }
2795 
2797 {
2799 }
2800 
2802 {
2803  build_ea(info, M68K_INS_NEG, 1);
2804 }
2805 
2807 {
2808  build_ea(info, M68K_INS_NEG, 2);
2809 }
2810 
2812 {
2813  build_ea(info, M68K_INS_NEG, 4);
2814 }
2815 
2817 {
2819 }
2820 
2822 {
2824 }
2825 
2827 {
2829 }
2830 
2832 {
2834 }
2835 
2837 {
2838  build_ea(info, M68K_INS_NOT, 1);
2839 }
2840 
2842 {
2843  build_ea(info, M68K_INS_NOT, 2);
2844 }
2845 
2847 {
2848  build_ea(info, M68K_INS_NOT, 4);
2849 }
2850 
2852 {
2854 }
2855 
2857 {
2859 }
2860 
2862 {
2864 }
2865 
2867 {
2869 }
2870 
2872 {
2874 }
2875 
2877 {
2879 }
2880 
2882 {
2884 }
2885 
2887 {
2889 }
2890 
2892 {
2894 }
2895 
2897 {
2899 }
2900 
2902 {
2904 }
2905 
2907 {
2910 }
2911 
2913 {
2916 }
2917 
2919 {
2920  build_ea(info, M68K_INS_PEA, 4);
2921 }
2922 
2924 {
2926 }
2927 
2929 {
2931 }
2932 
2934 {
2936 }
2937 
2939 {
2941 }
2942 
2944 {
2945  build_r(info, M68K_INS_ROR, 1);
2946 }
2947 
2949 {
2950  build_r(info, M68K_INS_ROR, 2);
2951 }
2952 
2954 {
2955  build_r(info, M68K_INS_ROR, 4);
2956 }
2957 
2959 {
2960  build_ea(info, M68K_INS_ROR, 2);
2961 }
2962 
2964 {
2966 }
2967 
2969 {
2971 }
2972 
2974 {
2976 }
2977 
2979 {
2980  build_r(info, M68K_INS_ROL, 1);
2981 }
2982 
2984 {
2985  build_r(info, M68K_INS_ROL, 2);
2986 }
2987 
2989 {
2990  build_r(info, M68K_INS_ROL, 4);
2991 }
2992 
2994 {
2995  build_ea(info, M68K_INS_ROL, 2);
2996 }
2997 
2999 {
3001 }
3002 
3004 {
3006 }
3007 
3009 {
3011 }
3012 
3014 {
3016 }
3017 
3019 {
3020  build_r(info, M68K_INS_ROXR, 2);
3021 }
3022 
3024 {
3025  build_r(info, M68K_INS_ROXR, 4);
3026 }
3027 
3029 {
3031 }
3032 
3034 {
3036 }
3037 
3039 {
3041 }
3042 
3044 {
3046 }
3047 
3049 {
3050  build_r(info, M68K_INS_ROXL, 1);
3051 }
3052 
3054 {
3055  build_r(info, M68K_INS_ROXL, 2);
3056 }
3057 
3059 {
3060  build_r(info, M68K_INS_ROXL, 4);
3061 }
3062 
3064 {
3066 }
3067 
3069 {
3073 }
3074 
3076 {
3079 }
3080 
3082 {
3083  cs_m68k* ext;
3084  cs_m68k_op* op;
3085 
3087 
3089 
3091 
3092  ext = &info->extension;
3093  op = &ext->operands[0];
3094 
3095  op->address_mode = M68K_AM_NONE;
3096  op->type = M68K_OP_REG;
3097 
3098  if (BIT_3(info->ir)) {
3099  op->reg = M68K_REG_A0 + (info->ir & 7);
3100  } else {
3101  op->reg = M68K_REG_D0 + (info->ir & 7);
3102  }
3103 }
3104 
3106 {
3109 }
3110 
3112 {
3115 }
3116 
3118 {
3119  build_rr(info, M68K_INS_SBCD, 1, 0);
3120 }
3121 
3123 {
3125 }
3126 
3128 {
3129  cs_m68k* ext = build_init_op(info, s_scc_lut[(info->ir >> 8) & 0xf], 1, 1);
3130  get_ea_mode_op(info, &ext->operands[0], info->ir, 1);
3131 }
3132 
3134 {
3136 }
3137 
3139 {
3141 }
3142 
3144 {
3146 }
3147 
3149 {
3151 }
3152 
3154 {
3156 }
3157 
3159 {
3161 }
3162 
3164 {
3166 }
3167 
3169 {
3171 }
3172 
3174 {
3176 }
3177 
3179 {
3181 }
3182 
3184 {
3186 }
3187 
3189 {
3191 }
3192 
3194 {
3196 }
3197 
3199 {
3201 }
3202 
3204 {
3206 }
3207 
3209 {
3210  build_rr(info, M68K_INS_SUBX, 1, 0);
3211 }
3212 
3214 {
3215  build_rr(info, M68K_INS_SUBX, 2, 0);
3216 }
3217 
3219 {
3220  build_rr(info, M68K_INS_SUBX, 4, 0);
3221 }
3222 
3224 {
3225  build_mm(info, M68K_INS_SUBX, 1, 0);
3226 }
3227 
3229 {
3230  build_mm(info, M68K_INS_SUBX, 2, 0);
3231 }
3232 
3234 {
3235  build_mm(info, M68K_INS_SUBX, 4, 0);
3236 }
3237 
3239 {
3240  build_d(info, M68K_INS_SWAP, 0);
3241 }
3242 
3244 {
3245  build_ea(info, M68K_INS_TAS, 1);
3246 }
3247 
3249 {
3251 }
3252 
3254 {
3256  build_trap(info, 0, 0);
3257 
3258  info->extension.op_count = 0;
3259 }
3260 
3262 {
3265 }
3266 
3268 {
3271 }
3272 
3274 {
3276 }
3277 
3279 {
3280  build_ea(info, M68K_INS_TST, 1);
3281 }
3282 
3284 {
3286  build_ea(info, M68K_INS_TST, 1);
3287 }
3288 
3290 {
3292  build_ea(info, M68K_INS_TST, 1);
3293 }
3294 
3296 {
3298  build_ea(info, M68K_INS_TST, 1);
3299 }
3300 
3302 {
3303  build_ea(info, M68K_INS_TST, 2);
3304 }
3305 
3307 {
3309  build_ea(info, M68K_INS_TST, 2);
3310 }
3311 
3313 {
3315  build_ea(info, M68K_INS_TST, 2);
3316 }
3317 
3319 {
3321  build_ea(info, M68K_INS_TST, 2);
3322 }
3323 
3325 {
3327  build_ea(info, M68K_INS_TST, 2);
3328 }
3329 
3331 {
3332  build_ea(info, M68K_INS_TST, 4);
3333 }
3334 
3336 {
3338  build_ea(info, M68K_INS_TST, 4);
3339 }
3340 
3342 {
3344  build_ea(info, M68K_INS_TST, 4);
3345 }
3346 
3348 {
3350  build_ea(info, M68K_INS_TST, 4);
3351 }
3352 
3354 {
3356  build_ea(info, M68K_INS_TST, 4);
3357 }
3358 
3360 {
3361  cs_m68k_op* op;
3363 
3364  op = &ext->operands[0];
3365 
3366  op->address_mode = M68K_AM_REG_DIRECT_ADDR;
3367  op->reg = M68K_REG_A0 + (info->ir & 7);
3368 }
3369 
3371 {
3374 }
3375 
3377 {
3380 }
3381 
3382 /* This table is auto-generated. Look in contrib/m68k_instruction_tbl_gen for more info */
3383 #include "M68KInstructionTable.inc"
3384 
3385 static int instruction_is_valid(m68k_info *info, const unsigned int word_check)
3386 {
3387  const unsigned int instruction = info->ir;
3389 
3390  if ( (i->word2_mask && ((word_check & i->word2_mask) != i->word2_match)) ||
3391  (i->instruction == d68000_invalid) ) {
3393  return 0;
3394  }
3395 
3396  return 1;
3397 }
3398 
3400 {
3401  uint8_t i;
3402 
3403  for (i = 0; i < count; ++i) {
3404  if (regs[i] == (uint16_t)reg)
3405  return 1;
3406  }
3407 
3408  return 0;
3409 }
3410 
3412 {
3413  if (reg == M68K_REG_INVALID)
3414  return;
3415 
3416  if (write)
3417  {
3418  if (exists_reg_list(info->regs_write, info->regs_write_count, reg))
3419  return;
3420 
3421  info->regs_write[info->regs_write_count] = (uint16_t)reg;
3422  info->regs_write_count++;
3423  }
3424  else
3425  {
3426  if (exists_reg_list(info->regs_read, info->regs_read_count, reg))
3427  return;
3428 
3429  info->regs_read[info->regs_read_count] = (uint16_t)reg;
3430  info->regs_read_count++;
3431  }
3432 }
3433 
3435 {
3436  switch (op->address_mode) {
3439  add_reg_to_rw_list(info, op->reg, write);
3440  break;
3441 
3444  add_reg_to_rw_list(info, op->reg, 1);
3445  break;
3446 
3447  case M68K_AM_REGI_ADDR:
3449  add_reg_to_rw_list(info, op->reg, 0);
3450  break;
3451 
3460  add_reg_to_rw_list(info, op->mem.index_reg, 0);
3461  add_reg_to_rw_list(info, op->mem.base_reg, 0);
3462  break;
3463 
3464  // no register(s) in the other addressing modes
3465  default:
3466  break;
3467  }
3468 }
3469 
3471 {
3472  int i;
3473 
3474  for (i = 0; i < 8; ++i) {
3475  if (bits & (1 << i)) {
3476  add_reg_to_rw_list(info, reg_start + i, write);
3477  }
3478  }
3479 }
3480 
3482 {
3483  uint32_t bits = op->register_bits;
3485  update_bits_range(info, M68K_REG_A0, (bits >> 8) & 0xff, write);
3486  update_bits_range(info, M68K_REG_FP0, (bits >> 16) & 0xff, write);
3487 }
3488 
3490 {
3491  switch ((int)op->type) {
3492  case M68K_OP_REG:
3493  add_reg_to_rw_list(info, op->reg, write);
3494  break;
3495 
3496  case M68K_OP_MEM:
3498  break;
3499 
3500  case M68K_OP_REG_BITS:
3502  break;
3503 
3504  case M68K_OP_REG_PAIR:
3505  add_reg_to_rw_list(info, op->reg_pair.reg_0, write);
3506  add_reg_to_rw_list(info, op->reg_pair.reg_1, write);
3507  break;
3508  }
3509 }
3510 
3512 {
3513  int i;
3514 
3515  if (!info->extension.op_count)
3516  return;
3517 
3518  if (info->extension.op_count == 1) {
3519  update_op_reg_list(info, &info->extension.operands[0], 1);
3520  } else {
3521  // first operand is always read
3522  update_op_reg_list(info, &info->extension.operands[0], 0);
3523 
3524  // remaning write
3525  for (i = 1; i < info->extension.op_count; ++i)
3526  update_op_reg_list(info, &info->extension.operands[i], 1);
3527  }
3528 }
3529 
3530 static void m68k_setup_internals(m68k_info* info, MCInst* inst, unsigned int pc, unsigned int cpu_type)
3531 {
3532  info->inst = inst;
3533  info->pc = pc;
3534  info->ir = 0;
3535  info->type = cpu_type;
3536  info->address_mask = 0xffffffff;
3537 
3538  switch(info->type) {
3539  case M68K_CPU_TYPE_68000:
3540  info->type = TYPE_68000;
3541  info->address_mask = 0x00ffffff;
3542  break;
3543  case M68K_CPU_TYPE_68010:
3544  info->type = TYPE_68010;
3545  info->address_mask = 0x00ffffff;
3546  break;
3547  case M68K_CPU_TYPE_68EC020:
3548  info->type = TYPE_68020;
3549  info->address_mask = 0x00ffffff;
3550  break;
3551  case M68K_CPU_TYPE_68020:
3552  info->type = TYPE_68020;
3553  info->address_mask = 0xffffffff;
3554  break;
3555  case M68K_CPU_TYPE_68030:
3556  info->type = TYPE_68030;
3557  info->address_mask = 0xffffffff;
3558  break;
3559  case M68K_CPU_TYPE_68040:
3560  info->type = TYPE_68040;
3561  info->address_mask = 0xffffffff;
3562  break;
3563  default:
3564  info->address_mask = 0;
3565  return;
3566  }
3567 }
3568 
3569 /* ======================================================================== */
3570 /* ================================= API ================================== */
3571 /* ======================================================================== */
3572 
3573 /* Disasemble one instruction at pc and store in str_buff */
3575 {
3576  MCInst *inst = info->inst;
3577  cs_m68k* ext = &info->extension;
3578  int i;
3579  unsigned int size;
3580 
3581  inst->Opcode = M68K_INS_INVALID;
3582 
3583  memset(ext, 0, sizeof(cs_m68k));
3584  ext->op_size.type = M68K_SIZE_TYPE_CPU;
3585 
3586  for (i = 0; i < M68K_OPERAND_COUNT; ++i)
3587  ext->operands[i].type = M68K_OP_REG;
3588 
3589  info->ir = peek_imm_16(info);
3590  if (instruction_is_valid(info, peek_imm_32(info) & 0xffff)) {
3591  info->ir = read_imm_16(info);
3593  }
3594 
3595  size = info->pc - (unsigned int)pc;
3596  info->pc = (unsigned int)pc;
3597 
3598  return size;
3599 }
3600 
3601 bool M68K_getInstruction(csh ud, const uint8_t* code, size_t code_len, MCInst* instr, uint16_t* size, uint64_t address, void* inst_info)
3602 {
3603 #ifdef M68K_DEBUG
3604  SStream ss;
3605 #endif
3606  int s;
3608  cs_struct* handle = instr->csh;
3609  m68k_info *info = (m68k_info*)handle->printer_info;
3610 
3611  // code len has to be at least 2 bytes to be valid m68k
3612 
3613  if (code_len < 2) {
3614  *size = 0;
3615  return false;
3616  }
3617 
3618  if (instr->flat_insn->detail) {
3619  memset(instr->flat_insn->detail, 0, offsetof(cs_detail, m68k)+sizeof(cs_m68k));
3620  }
3621 
3622  info->groups_count = 0;
3623  info->regs_read_count = 0;
3624  info->regs_write_count = 0;
3625  info->code = code;
3626  info->code_len = code_len;
3627  info->baseAddress = address;
3628 
3629  if (handle->mode & CS_MODE_M68K_010)
3631  if (handle->mode & CS_MODE_M68K_020)
3633  if (handle->mode & CS_MODE_M68K_030)
3635  if (handle->mode & CS_MODE_M68K_040)
3637  if (handle->mode & CS_MODE_M68K_060)
3638  cpu_type = M68K_CPU_TYPE_68040; // 060 = 040 for now
3639 
3640  m68k_setup_internals(info, instr, (unsigned int)address, cpu_type);
3641  s = m68k_disassemble(info, address);
3642 
3643  if (s == 0) {
3644  *size = 2;
3645  return false;
3646  }
3647 
3649 
3650 #ifdef M68K_DEBUG
3651  SStream_Init(&ss);
3652  M68K_printInst(instr, &ss, info);
3653 #endif
3654 
3655  // Make sure we always stay within range
3656  if (s > (int)code_len)
3657  *size = (uint16_t)code_len;
3658  else
3659  *size = (uint16_t)s;
3660 
3661  return true;
3662 }
3663 
ut8 op
Definition: 6502dis.c:13
#define TYPE_68000
static void d68020_cmpi_pcdi_32(m68k_info *info)
static uint32_t g_5bit_data_table[32]
static void d68000_cmpi_8(m68k_info *info)
#define EXT_INDEX_REGISTER_PRESENT(A)
static void d68020_bfclr(m68k_info *info)
static void d68000_lsl_ea(m68k_info *info)
static void update_bits_range(m68k_info *info, m68k_reg reg_start, uint8_t bits, int write)
static void d68000_rts(m68k_info *info)
static void d68000_asr_r_32(m68k_info *info)
#define M68040_PLUS
static int exists_reg_list(uint16_t *regs, uint8_t count, m68k_reg reg)
static void build_dbcc(m68k_info *info, int size, int displacement)
static void d68020_bfset(m68k_info *info)
static void d68000_bchg_s(m68k_info *info)
static void d68020_cas_8(m68k_info *info)
static void d68000_lsl_s_8(m68k_info *info)
static void d68000_subi_32(m68k_info *info)
static void d68000_btst_r(m68k_info *info)
static void d68000_roxl_r_16(m68k_info *info)
static void d68000_sub_re_32(m68k_info *info)
static void get_ea_mode_op(m68k_info *info, cs_m68k_op *op, uint32_t instruction, uint32_t size)
static void d68000_or_re_16(m68k_info *info)
static uint8_t reverse_bits_8(uint32_t v)
static void d68000_roxl_s_32(m68k_info *info)
static void d68000_addi_8(m68k_info *info)
static void d68000_movem_er_16(m68k_info *info)
static void d68000_ror_ea(m68k_info *info)
static void build_imm_special_reg(m68k_info *info, int opcode, int imm, int size, m68k_reg reg)
static void d68000_bset_s(m68k_info *info)
static void d68020_chk_32(m68k_info *info)
static void update_op_reg_list(m68k_info *info, cs_m68k_op *op, int write)
static void d68000_roxl_s_16(m68k_info *info)
static void d68040_move16_al_pi(m68k_info *info)
static void d68020_tst_i_16(m68k_info *info)
static void d68000_subi_16(m68k_info *info)
static void d68000_bra_16(m68k_info *info)
static void d68000_rol_r_8(m68k_info *info)
static void d68000_and_re_8(m68k_info *info)
static void make_cpbcc_operand(cs_m68k_op *op, int size, int displacement)
static void build_relative_branch(m68k_info *info, int opcode, int size, int displacement)
static void d68000_move_16(m68k_info *info)
static void d68000_subx_mm_16(m68k_info *info)
static void d68000_adda_32(m68k_info *info)
static void d68000_ror_r_8(m68k_info *info)
static void d68000_asr_ea(m68k_info *info)
static void d68020_cmpi_pcix_32(m68k_info *info)
static void d68000_eori_to_ccr(m68k_info *info)
static void d68000_add_re_16(m68k_info *info)
static void d68000_andi_32(m68k_info *info)
static void d68000_roxr_ea(m68k_info *info)
static void d68020_rtm(m68k_info *info)
static void d68000_ext_16(m68k_info *info)
@ M68K_CPU_TYPE_68EC020
@ M68K_CPU_TYPE_INVALID
@ M68K_CPU_TYPE_68030
@ M68K_CPU_TYPE_68010
@ M68K_CPU_TYPE_68020
@ M68K_CPU_TYPE_68000
@ M68K_CPU_TYPE_68040
static void d68000_roxr_s_8(m68k_info *info)
static void d68000_rol_s_8(m68k_info *info)
static void d68000_asl_r_16(m68k_info *info)
static void d68000_rol_r_32(m68k_info *info)
static void d68000_bset_r(m68k_info *info)
static void d68000_abcd_mm(m68k_info *info)
static void build_re_1(m68k_info *info, int opcode, uint8_t size)
static void d68000_lsl_r_8(m68k_info *info)
static void build_illegal(m68k_info *info, int data)
static void d68020_trapcc_16(m68k_info *info)
static void d68010_rtd(m68k_info *info)
static void build_ea_a(m68k_info *info, int opcode, uint8_t size)
static void d68020_tst_pcdi_32(m68k_info *info)
static void d68020_chk2_cmp2_16(m68k_info *info)
static void d68000_clr_16(m68k_info *info)
static void build_chk2_cmp2(m68k_info *info, int size)
static void d68000_addx_rr_8(m68k_info *info)
static void build_trap(m68k_info *info, int size, int immediate)
static void d68000_move_to_sr(m68k_info *info)
static void d68000_sub_er_32(m68k_info *info)
static void d68020_cpdbcc(m68k_info *info)
static void build_regs_read_write_counts(m68k_info *info)
static void d68000_cmpm_16(m68k_info *info)
static void build_movep_re(m68k_info *info, int size)
static void build_movep_er(m68k_info *info, int size)
static void d68000_sbcd_mm(m68k_info *info)
static void d68000_ext_32(m68k_info *info)
static void d68000_rtr(m68k_info *info)
static void d68000_move_fr_usp(m68k_info *info)
static void d68000_tst_8(m68k_info *info)
static void d68000_bsr_16(m68k_info *info)
static void build_r(m68k_info *info, int opcode, uint8_t size)
static unsigned int peek_imm_8(const m68k_info *info)
static void d68000_or_re_8(m68k_info *info)
static void build_movem_re(m68k_info *info, int opcode, int size)
static void m68k_setup_internals(m68k_info *info, MCInst *inst, unsigned int pc, unsigned int cpu_type)
bool M68K_getInstruction(csh ud, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *inst_info)
static void d68000_ror_r_16(m68k_info *info)
static void d68000_illegal(m68k_info *info)
static void d68020_tst_i_8(m68k_info *info)
static void d68000_roxr_s_32(m68k_info *info)
static void d68000_movem_pd_32(m68k_info *info)
#define EXT_BASE_DISPLACEMENT_LONG(A)
static void d68000_roxr_s_16(m68k_info *info)
static void d68000_stop(m68k_info *info)
static void d68020_cas_32(m68k_info *info)
static void d68000_andi_to_ccr(m68k_info *info)
#define M68020_ONLY
static void d68010_move_fr_ccr(m68k_info *info)
static void d68010_movec(m68k_info *info)
static void d68020_cpsave(m68k_info *info)
static void d68000_roxl_r_8(m68k_info *info)
static void d68000_eor_8(m68k_info *info)
static void d68000_lsr_s_32(m68k_info *info)
static void d68020_bcc_32(m68k_info *info)
static void d68000_lsr_r_8(m68k_info *info)
static void d68020_trapcc_0(m68k_info *info)
static void d68000_ror_r_32(m68k_info *info)
static void d68000_roxr_r_16(m68k_info *info)
static void d68000_asr_s_32(m68k_info *info)
static void d68000_move_to_usp(m68k_info *info)
static void d68000_cmpa_32(m68k_info *info)
static void d68000_eori_16(m68k_info *info)
static void d68000_or_er_8(m68k_info *info)
static void d68000_sub_er_16(m68k_info *info)
static void d68000_cmp_32(m68k_info *info)
#define BIT_1F(A)
#define BIT_3(A)
static void build_d_d_ea(m68k_info *info, int opcode, int size)
static void fmove_fpcr(m68k_info *info, uint32_t extension)
static void d68000_abcd_rr(m68k_info *info)
static void d68000_moveq(m68k_info *info)
static void set_insn_group(m68k_info *info, m68k_group_type group)
static void d68000_divu(m68k_info *info)
static void d68000_bsr_8(m68k_info *info)
static void build_3bit_ea(m68k_info *info, int opcode, int size)
#define EXT_8BIT_DISPLACEMENT(A)
static void build_re_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
static void d68000_addx_rr_32(m68k_info *info)
static void build_cas2(m68k_info *info, int size)
static void d68020_cptrapcc_0(m68k_info *info)
static void d68000_add_er_8(m68k_info *info)
static void d68000_or_er_32(m68k_info *info)
static void d68010_moves_32(m68k_info *info)
static void d68000_mulu(m68k_info *info)
static void d68020_chk2_cmp2_8(m68k_info *info)
static void d68000_eori_8(m68k_info *info)
static void d68000_eori_32(m68k_info *info)
static void get_with_index_address_mode(m68k_info *info, cs_m68k_op *op, uint32_t instruction, uint32_t size, bool is_pc)
static void d68000_add_re_8(m68k_info *info)
static void d68000_lsr_s_16(m68k_info *info)
static void d68000_addq_8(m68k_info *info)
static uint16_t reverse_bits(uint32_t v)
static void d68020_extb_32(m68k_info *info)
static void d68000_lsr_ea(m68k_info *info)
#define M68010_PLUS
static void d68000_cmpa_16(m68k_info *info)
static void d68000_lsl_s_32(m68k_info *info)
static void build_bitfield_ins(m68k_info *info, int opcode, int has_d_arg)
static void d68000_dbcc(m68k_info *info)
static void d68000_rte(m68k_info *info)
static void d68000_scc(m68k_info *info)
static void d68000_invalid(m68k_info *info)
static void d68000_negx_32(m68k_info *info)
static void d68020_link_32(m68k_info *info)
static void d68000_suba_16(m68k_info *info)
static void d68000_nop(m68k_info *info)
static void d68000_bclr_r(m68k_info *info)
static void d68000_asr_s_8(m68k_info *info)
static void d68020_cpbcc_32(m68k_info *info)
static unsigned int m68k_disassemble(m68k_info *info, uint64_t pc)
static void d68000_ror_s_8(m68k_info *info)
#define EXT_INDEX_LONG(A)
static void d68040_move16_pi_pi(m68k_info *info)
static void d68000_jsr(m68k_info *info)
static void d68000_rol_s_16(m68k_info *info)
static void d68020_bra_32(m68k_info *info)
static void d68000_exg_aa(m68k_info *info)
static void d68000_andi_to_sr(m68k_info *info)
static void d68000_subq_16(m68k_info *info)
static void d68000_negx_8(m68k_info *info)
static m68k_insn s_trap_lut[]
static int make_int_16(int value)
static void d68020_chk2_cmp2_32(m68k_info *info)
static void d68020_cas2_32(m68k_info *info)
static void d68020_tst_a_32(m68k_info *info)
static void update_reg_list_regbits(m68k_info *info, cs_m68k_op *op, int write)
#define M68020_PLUS
static void d68020_callm(m68k_info *info)
static void d68000_ori_to_sr(m68k_info *info)
static void d68000_clr_32(m68k_info *info)
static void d68010_moves_8(m68k_info *info)
static void d68020_tst_i_32(m68k_info *info)
static void d68000_neg_32(m68k_info *info)
static void d68000_adda_16(m68k_info *info)
static void d68000_lsr_s_8(m68k_info *info)
static void d68000_ror_s_16(m68k_info *info)
static void build_dbxx(m68k_info *info, int opcode, int size, int displacement)
static void d68000_exg_da(m68k_info *info)
static void d68000_link_16(m68k_info *info)
static void d68000_cmpi_32(m68k_info *info)
static void d68020_bsr_32(m68k_info *info)
static void d68000_bclr_s(m68k_info *info)
static void d68000_chk_16(m68k_info *info)
static int instruction_is_valid(m68k_info *info, const unsigned int word_check)
static void d68000_tst_32(m68k_info *info)
static void d68010_moves_16(m68k_info *info)
static void d68000_ori_8(m68k_info *info)
static void d68000_bra_8(m68k_info *info)
static void d68000_movem_er_32(m68k_info *info)
static void d68000_eor_32(m68k_info *info)
static void d68000_or_re_32(m68k_info *info)
static void d68000_tas(m68k_info *info)
static void build_3bit_d(m68k_info *info, int opcode, int size)
static void d68020_tst_pcix_16(m68k_info *info)
static void build_moves(m68k_info *info, int size)
static cs_m68k * build_init_op(m68k_info *info, int opcode, int count, int size)
static void d68000_asl_ea(m68k_info *info)
static void d68020_trapcc_32(m68k_info *info)
static void d68020_mull(m68k_info *info)
static void d68000_bcc_16(m68k_info *info)
static void d68000_cmpi_16(m68k_info *info)
static void d68020_bfins(m68k_info *info)
static void d68000_lsr_r_16(m68k_info *info)
static void build_bcc(m68k_info *info, int size, int displacement)
static void fmovem(m68k_info *info, uint32_t extension)
static void d68000_addi_16(m68k_info *info)
static void d68020_divl(m68k_info *info)
static void build_ea_ea(m68k_info *info, int opcode, int size)
static void d68020_bftst(m68k_info *info)
static void d68000_subi_8(m68k_info *info)
static void d68020_cprestore(m68k_info *info)
static void d68000_addi_32(m68k_info *info)
static void d68000_neg_8(m68k_info *info)
static void d68000_asl_s_32(m68k_info *info)
static unsigned long long read_imm_64(m68k_info *info)
static void d68000_subx_rr_8(m68k_info *info)
static void d68000_addx_rr_16(m68k_info *info)
static void d68000_add_er_16(m68k_info *info)
static void d68020_tst_a_16(m68k_info *info)
static m68k_insn s_dbcc_lut[]
static void d68000_ori_32(m68k_info *info)
static void d68020_pack_rr(m68k_info *info)
static unsigned int read_imm_8(m68k_info *info)
static void d68020_cmpi_pcdi_16(m68k_info *info)
static unsigned int m68k_read_safe_32(const m68k_info *info, const uint64_t address)
#define EXT_OUTER_DISPLACEMENT_PRESENT(A)
static unsigned int read_imm_32(m68k_info *info)
static void d68000_movep_er_16(m68k_info *info)
static void d68000_1010(m68k_info *info)
static void d68000_reset(m68k_info *info)
static void d68000_cmp_8(m68k_info *info)
static void d68000_not_8(m68k_info *info)
static void d68000_add_re_32(m68k_info *info)
static void d68020_cpscc(m68k_info *info)
#define TYPE_68010
static void d68040_move16_pi_al(m68k_info *info)
static void d68000_and_re_32(m68k_info *info)
static void update_am_reg_list(m68k_info *info, cs_m68k_op *op, int write)
static void d68000_bchg_r(m68k_info *info)
static void d68020_bfchg(m68k_info *info)
static void d68000_lsl_r_32(m68k_info *info)
static void d68000_andi_16(m68k_info *info)
static void add_reg_to_rw_list(m68k_info *info, m68k_reg reg, int write)
#define EXT_BASE_REGISTER_PRESENT(A)
static void d68000_and_er_16(m68k_info *info)
static int make_int_8(int value)
static unsigned long long peek_imm_64(const m68k_info *info)
static void d68020_cptrapcc_16(m68k_info *info)
static void d68000_roxl_ea(m68k_info *info)
static void d68000_not_32(m68k_info *info)
static void d68000_eori_to_sr(m68k_info *info)
static void d68000_roxr_r_32(m68k_info *info)
static void d68000_cmpm_8(m68k_info *info)
static void d68000_asl_s_8(m68k_info *info)
static void d68000_negx_16(m68k_info *info)
static unsigned int read_imm_16(m68k_info *info)
#define TYPE_68020
#define TYPE_68040
static void d68000_lsl_r_16(m68k_info *info)
static void d68020_bfextu(m68k_info *info)
static void build_mm(m68k_info *info, int opcode, uint8_t size, int imm)
static void d68000_bcc_8(m68k_info *info)
static void d68000_addq_32(m68k_info *info)
static unsigned int m68k_read_safe_16(const m68k_info *info, const uint64_t address)
static void d68010_bkpt(m68k_info *info)
static void d68000_subx_rr_32(m68k_info *info)
static void build_pi_pi(m68k_info *info, int opcode, int size)
#define BITFIELD(val, sb, eb)
static void d68000_unlk(m68k_info *info)
static void d68000_lsr_r_32(m68k_info *info)
static void d68000_pea(m68k_info *info)
static void d68000_nbcd(m68k_info *info)
static void d68000_roxl_r_32(m68k_info *info)
static void d68000_movem_re_16(m68k_info *info)
static void d68020_bfexts(m68k_info *info)
static void build_d(m68k_info *info, int opcode, int size)
static void build_ea(m68k_info *info, int opcode, uint8_t size)
static void d68000_rol_r_16(m68k_info *info)
static void d68000_addx_mm_16(m68k_info *info)
static void d68000_ror_s_32(m68k_info *info)
static void d68040_move16_al_ai(m68k_info *info)
static void build_rr(m68k_info *info, int opcode, uint8_t size, int imm)
static void d68000_dbra(m68k_info *info)
static void d68000_movem_re_32(m68k_info *info)
static void d68000_andi_8(m68k_info *info)
static void d68040_cinv(m68k_info *info)
static void d68000_swap(m68k_info *info)
static void d68000_clr_8(m68k_info *info)
static instruction_struct g_instruction_table[0x10000]
static void d68000_1111(m68k_info *info)
static void d68000_muls(m68k_info *info)
static void build_imm_ea(m68k_info *info, int opcode, uint8_t size, int imm)
static void d68000_addx_mm_32(m68k_info *info)
static void d68000_movep_re_16(m68k_info *info)
#define EXT_BASE_DISPLACEMENT_PRESENT(A)
static void d68000_move_8(m68k_info *info)
static void d68000_subx_mm_32(m68k_info *info)
static void d68000_add_er_32(m68k_info *info)
#define BIT_F(A)
static void d68000_asl_s_16(m68k_info *info)
static void d68020_cmpi_pcdi_8(m68k_info *info)
#define EXT_INDEX_REGISTER(A)
static void d68000_rol_s_32(m68k_info *info)
static void d68000_roxr_r_8(m68k_info *info)
static void d68000_rol_ea(m68k_info *info)
static void d68000_lsl_s_16(m68k_info *info)
static void build_invalid(m68k_info *info, int data)
static void d68020_tst_pcdi_16(m68k_info *info)
static void d68000_sbcd_rr(m68k_info *info)
static void d68000_subx_mm_8(m68k_info *info)
static void d68000_jmp(m68k_info *info)
static void d68000_and_er_32(m68k_info *info)
static void d68000_suba_32(m68k_info *info)
static void d68000_asl_r_8(m68k_info *info)
#define EXT_INDEX_SCALE(A)
static void d68000_and_er_8(m68k_info *info)
#define LIMIT_CPU_TYPES(info, ALLOWED_CPU_TYPES)
static void d68040_move16_ai_al(m68k_info *info)
static void d68020_cmpi_pcix_8(m68k_info *info)
static void d68000_asl_r_32(m68k_info *info)
static void d68000_movem_pd_16(m68k_info *info)
static void build_er_1(m68k_info *info, int opcode, uint8_t size)
static void d68020_cpgen(m68k_info *info)
static void d68000_subq_32(m68k_info *info)
static void d68000_btst_s(m68k_info *info)
static uint32_t g_3bit_qdata_table[8]
static void d68000_exg_dd(m68k_info *info)
static unsigned int m68k_read_disassembler_32(const m68k_info *info, const uint64_t addr)
static void d68000_cmp_16(m68k_info *info)
static void d68000_addx_mm_8(m68k_info *info)
static void d68000_sub_er_8(m68k_info *info)
static void d68000_addq_16(m68k_info *info)
static m68k_insn s_scc_lut[]
#define BIT_5(A)
static void d68000_asr_s_16(m68k_info *info)
static void d68020_tst_pcix_8(m68k_info *info)
static void d68000_asr_r_16(m68k_info *info)
#define EXT_INDEX_AR(A)
static void build_imm(m68k_info *info, int opcode, int data)
static void d68020_cas_16(m68k_info *info)
static uint64_t m68k_read_disassembler_64(const m68k_info *info, const uint64_t addr)
static void d68000_movea_16(m68k_info *info)
static void d68000_asr_r_8(m68k_info *info)
static void d68000_move_32(m68k_info *info)
static void build_movem_er(m68k_info *info, int opcode, int size)
static void d68000_move_to_ccr(m68k_info *info)
static void d68000_or_er_16(m68k_info *info)
static unsigned int peek_imm_16(const m68k_info *info)
static void d68000_movea_32(m68k_info *info)
static void d68000_trapv(m68k_info *info)
static void d68020_bfffo(m68k_info *info)
#define BIT_A(A)
static void d68000_subq_8(m68k_info *info)
static void d68020_pack_mm(m68k_info *info)
static void d68000_not_16(m68k_info *info)
static void build_cpush_cinv(m68k_info *info, int op_offset)
static void d68000_and_re_16(m68k_info *info)
static void d68000_ori_16(m68k_info *info)
static void d68020_unpk_mm(m68k_info *info)
static void d68020_unpk_rr(m68k_info *info)
static void build_er_gen_1(m68k_info *info, bool isDreg, int opcode, uint8_t size)
static void d68000_eor_16(m68k_info *info)
static void d68020_cas2_16(m68k_info *info)
static m68k_insn s_branch_lut[]
static void d68020_cpbcc_16(m68k_info *info)
static void build_link(m68k_info *info, int disp, int size)
static void d68000_move_fr_sr(m68k_info *info)
static void d68000_neg_16(m68k_info *info)
static void d68000_tst_16(m68k_info *info)
static void d68000_movep_re_32(m68k_info *info)
static void d68000_divs(m68k_info *info)
#define EXT_FULL(A)
static void d68020_cptrapcc_32(m68k_info *info)
#define TYPE_68030
static void d68000_trap(m68k_info *info)
static unsigned int m68k_read_disassembler_16(const m68k_info *info, const uint64_t addr)
static void d68000_ori_to_ccr(m68k_info *info)
static void d68040_cpush(m68k_info *info)
#define BIT_B(A)
#define BIT_1(A)
static void d68020_tst_pcix_32(m68k_info *info)
static void d68000_sub_re_16(m68k_info *info)
static uint64_t m68k_read_safe_64(const m68k_info *info, const uint64_t address)
static void d68000_movep_er_32(m68k_info *info)
#define EXT_OUTER_DISPLACEMENT_LONG(A)
static void d68000_lea(m68k_info *info)
static void d68000_subx_rr_16(m68k_info *info)
static void d68020_tst_pcdi_8(m68k_info *info)
static unsigned int peek_imm_32(const m68k_info *info)
static void build_absolute_jump_with_immediate(m68k_info *info, int opcode, int size, int immediate)
static void d68000_sub_re_8(m68k_info *info)
static void d68020_cmpi_pcix_16(m68k_info *info)
static void build_move16(m68k_info *info, int data[2], int modes[2])
static void d68000_roxl_s_8(m68k_info *info)
static void d68000_cmpm_32(m68k_info *info)
void M68K_printInst(MCInst *MI, SStream *O, void *PrinterInfo)
void MCInst_setOpcode(MCInst *inst, unsigned Op)
Definition: MCInst.c:58
void SStream_Init(SStream *ss)
Definition: SStream.c:25
#define imm
static char * regs[]
Definition: analysis_sh.c:203
lzma_index ** i
Definition: index.h:629
lzma_index * src
Definition: index.h:567
static const char ext[]
Definition: apprentice.c:1981
static int cpu_type
Definition: arc-opc.c:143
static mcore_handle handle
Definition: asm_mcore.c:8
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
int bits(struct state *s, int need)
Definition: blast.c:72
@ CS_MODE_M68K_040
M68K 68040 mode.
Definition: capstone.h:121
@ CS_MODE_M68K_060
M68K 68060 mode.
Definition: capstone.h:122
@ CS_MODE_M68K_010
M68K 68010 mode.
Definition: capstone.h:118
@ CS_MODE_M68K_020
M68K 68020 mode.
Definition: capstone.h:119
@ CS_MODE_M68K_030
M68K 68030 mode.
Definition: capstone.h:120
size_t csh
Definition: capstone.h:71
static int value
Definition: cmd_api.c:93
#define r
Definition: crypto_rc6.c:12
static static fork write
Definition: sflib.h:33
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
const char * v
Definition: dsignal.c:12
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
const char int mode
Definition: ioapi.h:137
#define offsetof(type, member)
#define reg(n)
@ v0
Definition: lanai.h:84
@ v1
Definition: lanai.h:85
return memset(p, 0, total)
char * dst
Definition: lz4.h:724
#define M68K_OPERAND_COUNT
Definition: m68k.h:17
@ M68K_CPU_SIZE_LONG
4 bytes in size
Definition: m68k.h:181
@ M68K_CPU_SIZE_WORD
2 bytes in size
Definition: m68k.h:180
@ M68K_CPU_SIZE_BYTE
1 byte in size
Definition: m68k.h:179
@ M68K_AM_NONE
No address mode.
Definition: m68k.h:80
@ M68K_AM_MEMI_POST_INDEX
Memory indirect - Postindex.
Definition: m68k.h:93
@ M68K_AM_PC_MEMI_PRE_INDEX
Program Counter Memory Indirect - Preindexed.
Definition: m68k.h:102
@ M68K_AM_REG_DIRECT_ADDR
Register Direct - Address.
Definition: m68k.h:83
@ M68K_AM_REGI_ADDR
Register Indirect - Address.
Definition: m68k.h:85
@ M68K_AM_IMMEDIATE
Immediate value.
Definition: m68k.h:106
@ M68K_AM_REGI_ADDR_POST_INC
Register Indirect - Address with Postincrement.
Definition: m68k.h:86
@ M68K_AM_ABSOLUTE_DATA_SHORT
Absolute Data Addressing - Short.
Definition: m68k.h:104
@ M68K_AM_AREGI_INDEX_8_BIT_DISP
Address Register Indirect With Index- 8-bit displacement.
Definition: m68k.h:90
@ M68K_AM_PCI_INDEX_BASE_DISP
Program Counter Indirect with Index - with Base Displacement.
Definition: m68k.h:99
@ M68K_AM_PCI_DISP
Program Counter Indirect - with Displacement.
Definition: m68k.h:96
@ M68K_AM_REGI_ADDR_PRE_DEC
Register Indirect - Address with Predecrement.
Definition: m68k.h:87
@ M68K_AM_MEMI_PRE_INDEX
Memory indirect - Preindex.
Definition: m68k.h:94
@ M68K_AM_ABSOLUTE_DATA_LONG
Absolute Data Addressing - Long.
Definition: m68k.h:105
@ M68K_AM_PC_MEMI_POST_INDEX
Program Counter Memory Indirect - Postindexed.
Definition: m68k.h:101
@ M68K_AM_REG_DIRECT_DATA
Register Direct - Data.
Definition: m68k.h:82
@ M68K_AM_AREGI_INDEX_BASE_DISP
Address Register Indirect With Index- Base displacement.
Definition: m68k.h:91
@ M68K_AM_BRANCH_DISPLACEMENT
Address as displacement from (PC+2) used by branches.
Definition: m68k.h:108
@ M68K_AM_PCI_INDEX_8_BIT_DISP
Program Counter Indirect with Index - with 8-Bit Displacement.
Definition: m68k.h:98
@ M68K_AM_REGI_ADDR_DISP
Register Indirect - Address with Displacement.
Definition: m68k.h:88
@ M68K_SIZE_TYPE_CPU
Definition: m68k.h:196
@ M68K_SIZE_TYPE_FPU
Definition: m68k.h:197
m68k_group_type
Group of M68K instructions.
Definition: m68k.h:599
@ M68K_GRP_RET
= CS_GRP_RET
Definition: m68k.h:602
@ M68K_GRP_IRET
= CS_GRP_IRET
Definition: m68k.h:603
@ M68K_GRP_JUMP
= CS_GRP_JUMP
Definition: m68k.h:601
@ M68K_GRP_BRANCH_RELATIVE
= CS_GRP_BRANCH_RELATIVE
Definition: m68k.h:604
@ M68K_OP_REG_PAIR
Register pair in the same op (upper 4 bits for first reg, lower for second)
Definition: m68k.h:120
@ M68K_OP_BR_DISP
Branch displacement.
Definition: m68k.h:121
@ M68K_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: m68k.h:115
@ M68K_OP_FP_SINGLE
single precision Floating-Point operand
Definition: m68k.h:117
@ M68K_OP_FP_DOUBLE
double precision Floating-Point operand
Definition: m68k.h:118
@ M68K_OP_REG_BITS
Register bits move.
Definition: m68k.h:119
@ M68K_OP_REG
= CS_OP_REG (Register operand).
Definition: m68k.h:114
@ M68K_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: m68k.h:116
@ M68K_FPU_SIZE_SINGLE
4 byte in size (single float)
Definition: m68k.h:187
@ M68K_FPU_SIZE_DOUBLE
8 byte in size (double)
Definition: m68k.h:188
@ M68K_FPU_SIZE_EXTENDED
12 byte in size (extended real format)
Definition: m68k.h:189
m68k_insn
M68K instruction.
Definition: m68k.h:218
@ M68K_INS_SUBQ
Definition: m68k.h:568
@ M68K_INS_BFSET
Definition: m68k.h:259
@ M68K_INS_NOP
Definition: m68k.h:514
@ M68K_INS_FGETMAN
Definition: m68k.h:388
@ M68K_INS_FCOS
Definition: m68k.h:348
@ M68K_INS_DBLS
Definition: m68k.h:282
@ M68K_INS_BGE
Definition: m68k.h:243
@ M68K_INS_BFEXTU
Definition: m68k.h:256
@ M68K_INS_ADDQ
Definition: m68k.h:225
@ M68K_INS_RTR
Definition: m68k.h:543
@ M68K_INS_SUBX
Definition: m68k.h:569
@ M68K_INS_CINVL
Definition: m68k.h:273
@ M68K_INS_ORI
Definition: m68k.h:517
@ M68K_INS_BFCHG
Definition: m68k.h:253
@ M68K_INS_OR
Definition: m68k.h:516
@ M68K_INS_TRAPNE
Definition: m68k.h:582
@ M68K_INS_ROXL
Definition: m68k.h:538
@ M68K_INS_BLE
Definition: m68k.h:246
@ M68K_INS_INVALID
Definition: m68k.h:219
@ M68K_INS_FLOGN
Definition: m68k.h:393
@ M68K_INS_SVS
Definition: m68k.h:557
@ M68K_INS_TRAPMI
Definition: m68k.h:587
@ M68K_INS_FATAN
Definition: m68k.h:313
@ M68K_INS_LEA
Definition: m68k.h:496
@ M68K_INS_FINTRZ
Definition: m68k.h:390
@ M68K_INS_SPL
Definition: m68k.h:558
@ M68K_INS_FETOX
Definition: m68k.h:385
@ M68K_INS_RTM
Definition: m68k.h:542
@ M68K_INS_FTAN
Definition: m68k.h:455
@ M68K_INS_CMPI
Definition: m68k.h:270
@ M68K_INS_JSR
Definition: m68k.h:495
@ M68K_INS_MULS
Definition: m68k.h:509
@ M68K_INS_FLOGNP1
Definition: m68k.h:394
@ M68K_INS_DBGT
Definition: m68k.h:293
@ M68K_INS_BSET
Definition: m68k.h:251
@ M68K_INS_SVC
Definition: m68k.h:556
@ M68K_INS_MOVEQ
Definition: m68k.h:506
@ M68K_INS_EXG
Definition: m68k.h:302
@ M68K_INS_TRAPCC
Definition: m68k.h:578
@ M68K_INS_DBF
Definition: m68k.h:280
@ M68K_INS_BPL
Definition: m68k.h:241
@ M68K_INS_DBEQ
Definition: m68k.h:286
@ M68K_INS_BSR
Definition: m68k.h:248
@ M68K_INS_PACK
Definition: m68k.h:518
@ M68K_INS_FINT
Definition: m68k.h:389
@ M68K_INS_LSL
Definition: m68k.h:499
@ M68K_INS_BCLR
Definition: m68k.h:250
@ M68K_INS_RTS
Definition: m68k.h:544
@ M68K_INS_FMOD
Definition: m68k.h:395
@ M68K_INS_TRAPGT
Definition: m68k.h:590
@ M68K_INS_TRAPEQ
Definition: m68k.h:583
@ M68K_INS_FCOSH
Definition: m68k.h:349
@ M68K_INS_MOVES
Definition: m68k.h:507
@ M68K_INS_BMI
Definition: m68k.h:242
@ M68K_INS_SUB
Definition: m68k.h:565
@ M68K_INS_FCMP
Definition: m68k.h:347
@ M68K_INS_FTST
Definition: m68k.h:490
@ M68K_INS_TST
Definition: m68k.h:592
@ M68K_INS_LSR
Definition: m68k.h:500
@ M68K_INS_ADDI
Definition: m68k.h:224
@ M68K_INS_FSUB
Definition: m68k.h:452
@ M68K_INS_FSF
Definition: m68k.h:420
@ M68K_INS_SUBI
Definition: m68k.h:567
@ M68K_INS_BFEXTS
Definition: m68k.h:255
@ M68K_INS_TRAPF
Definition: m68k.h:575
@ M68K_INS_SGT
Definition: m68k.h:562
@ M68K_INS_FSINH
Definition: m68k.h:416
@ M68K_INS_FABS
Definition: m68k.h:305
@ M68K_INS_BNE
Definition: m68k.h:237
@ M68K_INS_BFFFO
Definition: m68k.h:257
@ M68K_INS_BTST
Definition: m68k.h:252
@ M68K_INS_FADD
Definition: m68k.h:309
@ M68K_INS_DBGE
Definition: m68k.h:291
@ M68K_INS_FETOXM1
Definition: m68k.h:386
@ M68K_INS_FMOVECR
Definition: m68k.h:399
@ M68K_INS_ROXR
Definition: m68k.h:539
@ M68K_INS_TRAPLT
Definition: m68k.h:589
@ M68K_INS_TRAPLS
Definition: m68k.h:577
@ M68K_INS_RESET
Definition: m68k.h:535
@ M68K_INS_DIVU
Definition: m68k.h:298
@ M68K_INS_FMUL
Definition: m68k.h:401
@ M68K_INS_SF
Definition: m68k.h:547
@ M68K_INS_BFCLR
Definition: m68k.h:254
@ M68K_INS_TAS
Definition: m68k.h:571
@ M68K_INS_CAS2
Definition: m68k.h:264
@ M68K_INS_DBVC
Definition: m68k.h:287
@ M68K_INS_STOP
Definition: m68k.h:564
@ M68K_INS_FMOVEM
Definition: m68k.h:400
@ M68K_INS_MOVE
Definition: m68k.h:501
@ M68K_INS_FSCALE
Definition: m68k.h:411
@ M68K_INS_DBNE
Definition: m68k.h:285
@ M68K_INS_LINK
Definition: m68k.h:497
@ M68K_INS_ASR
Definition: m68k.h:230
@ M68K_INS_PEA
Definition: m68k.h:519
@ M68K_INS_DBCC
Definition: m68k.h:283
@ M68K_INS_SHI
Definition: m68k.h:548
@ M68K_INS_BFINS
Definition: m68k.h:258
@ M68K_INS_FSQRT
Definition: m68k.h:417
@ M68K_INS_SLT
Definition: m68k.h:561
@ M68K_INS_ANDI
Definition: m68k.h:228
@ M68K_INS_CMP2
Definition: m68k.h:272
@ M68K_INS_FMOVE
Definition: m68k.h:396
@ M68K_INS_FLOG10
Definition: m68k.h:391
@ M68K_INS_FSGLMUL
Definition: m68k.h:413
@ M68K_INS_DBCS
Definition: m68k.h:284
@ M68K_INS_BEQ
Definition: m68k.h:238
@ M68K_INS_BCS
Definition: m68k.h:236
@ M68K_INS_CAS
Definition: m68k.h:263
@ M68K_INS_TRAP
Definition: m68k.h:572
@ M68K_INS_ST
Definition: m68k.h:546
@ M68K_INS_CMPM
Definition: m68k.h:271
@ M68K_INS_FREM
Definition: m68k.h:408
@ M68K_INS_BCC
Definition: m68k.h:235
@ M68K_INS_CHK2
Definition: m68k.h:266
@ M68K_INS_FATANH
Definition: m68k.h:314
@ M68K_INS_FGETEXP
Definition: m68k.h:387
@ M68K_INS_EOR
Definition: m68k.h:300
@ M68K_INS_FTENTOX
Definition: m68k.h:457
@ M68K_INS_DBMI
Definition: m68k.h:290
@ M68K_INS_EXT
Definition: m68k.h:303
@ M68K_INS_ROR
Definition: m68k.h:537
@ M68K_INS_FTRAPF
Definition: m68k.h:458
@ M68K_INS_CPUSHL
Definition: m68k.h:276
@ M68K_INS_JMP
Definition: m68k.h:494
@ M68K_INS_FACOS
Definition: m68k.h:308
@ M68K_INS_ROL
Definition: m68k.h:536
@ M68K_INS_TRAPHI
Definition: m68k.h:576
@ M68K_INS_RTE
Definition: m68k.h:541
@ M68K_INS_CLR
Definition: m68k.h:267
@ M68K_INS_BVC
Definition: m68k.h:239
@ M68K_INS_ADDA
Definition: m68k.h:223
@ M68K_INS_CMP
Definition: m68k.h:268
@ M68K_INS_SBCD
Definition: m68k.h:545
@ M68K_INS_BHI
Definition: m68k.h:233
@ M68K_INS_DBVS
Definition: m68k.h:288
@ M68K_INS_MOVEC
Definition: m68k.h:503
@ M68K_INS_FLOG2
Definition: m68k.h:392
@ M68K_INS_SCC
Definition: m68k.h:550
@ M68K_INS_FSGLDIV
Definition: m68k.h:412
@ M68K_INS_SNE
Definition: m68k.h:554
@ M68K_INS_MOVEP
Definition: m68k.h:505
@ M68K_INS_TRAPGE
Definition: m68k.h:588
@ M68K_INS_TRAPPL
Definition: m68k.h:586
@ M68K_INS_BVS
Definition: m68k.h:240
@ M68K_INS_ADDX
Definition: m68k.h:226
@ M68K_INS_FSIN
Definition: m68k.h:414
@ M68K_INS_FRESTORE
Definition: m68k.h:409
@ M68K_INS_UNLK
Definition: m68k.h:593
@ M68K_INS_TRAPV
Definition: m68k.h:573
@ M68K_INS_SLE
Definition: m68k.h:563
@ M68K_INS_ASL
Definition: m68k.h:229
@ M68K_INS_BLT
Definition: m68k.h:244
@ M68K_INS_BCHG
Definition: m68k.h:249
@ M68K_INS_CMPA
Definition: m68k.h:269
@ M68K_INS_SGE
Definition: m68k.h:560
@ M68K_INS_SWAP
Definition: m68k.h:570
@ M68K_INS_DBLT
Definition: m68k.h:292
@ M68K_INS_NEG
Definition: m68k.h:512
@ M68K_INS_TRAPVC
Definition: m68k.h:584
@ M68K_INS_ABCD
Definition: m68k.h:221
@ M68K_INS_DBT
Definition: m68k.h:279
@ M68K_INS_ILLEGAL
Definition: m68k.h:493
@ M68K_INS_NEGX
Definition: m68k.h:513
@ M68K_INS_SLS
Definition: m68k.h:549
@ M68K_INS_MOVE16
Definition: m68k.h:508
@ M68K_INS_SMI
Definition: m68k.h:559
@ M68K_INS_EXTB
Definition: m68k.h:304
@ M68K_INS_DBLE
Definition: m68k.h:294
@ M68K_INS_EORI
Definition: m68k.h:301
@ M68K_INS_DBPL
Definition: m68k.h:289
@ M68K_INS_MOVEA
Definition: m68k.h:502
@ M68K_INS_FBF
Definition: m68k.h:315
@ M68K_INS_MULU
Definition: m68k.h:510
@ M68K_INS_BGT
Definition: m68k.h:245
@ M68K_INS_BRA
Definition: m68k.h:247
@ M68K_INS_FDIV
Definition: m68k.h:382
@ M68K_INS_BKPT
Definition: m68k.h:261
@ M68K_INS_ADD
Definition: m68k.h:222
@ M68K_INS_NBCD
Definition: m68k.h:511
@ M68K_INS_TRAPT
Definition: m68k.h:574
@ M68K_INS_SEQ
Definition: m68k.h:555
@ M68K_INS_CHK
Definition: m68k.h:265
@ M68K_INS_NOT
Definition: m68k.h:515
@ M68K_INS_TRAPVS
Definition: m68k.h:585
@ M68K_INS_FNEG
Definition: m68k.h:404
@ M68K_INS_SCS
Definition: m68k.h:552
@ M68K_INS_FSAVE
Definition: m68k.h:410
@ M68K_INS_TRAPCS
Definition: m68k.h:580
@ M68K_INS_SUBA
Definition: m68k.h:566
@ M68K_INS_AND
Definition: m68k.h:227
@ M68K_INS_CALLM
Definition: m68k.h:262
@ M68K_INS_FTWOTOX
Definition: m68k.h:491
@ M68K_INS_BFTST
Definition: m68k.h:260
@ M68K_INS_TRAPLE
Definition: m68k.h:591
@ M68K_INS_FDBF
Definition: m68k.h:350
@ M68K_INS_MOVEM
Definition: m68k.h:504
@ M68K_INS_BLS
Definition: m68k.h:234
@ M68K_INS_FASIN
Definition: m68k.h:312
@ M68K_INS_UNPK
Definition: m68k.h:594
@ M68K_INS_RTD
Definition: m68k.h:540
@ M68K_INS_DBRA
Definition: m68k.h:295
@ M68K_INS_DIVS
Definition: m68k.h:296
@ M68K_INS_DBHI
Definition: m68k.h:281
m68k_reg
M68K registers and special registers.
Definition: m68k.h:20
@ M68K_REG_ITT1
Definition: m68k.h:64
@ M68K_REG_URP
Definition: m68k.h:68
@ M68K_REG_D0
Definition: m68k.h:23
@ M68K_REG_CCR
Definition: m68k.h:53
@ M68K_REG_INVALID
Definition: m68k.h:21
@ M68K_REG_MMUSR
Definition: m68k.h:67
@ M68K_REG_FPIAR
Definition: m68k.h:73
@ M68K_REG_CAAR
Definition: m68k.h:59
@ M68K_REG_ITT0
Definition: m68k.h:63
@ M68K_REG_SR
Definition: m68k.h:52
@ M68K_REG_DTT1
Definition: m68k.h:66
@ M68K_REG_A0
Definition: m68k.h:32
@ M68K_REG_SFC
Definition: m68k.h:54
@ M68K_REG_DFC
Definition: m68k.h:55
@ M68K_REG_DTT0
Definition: m68k.h:65
@ M68K_REG_FPCR
Definition: m68k.h:71
@ M68K_REG_FP0
Definition: m68k.h:41
@ M68K_REG_VBR
Definition: m68k.h:57
@ M68K_REG_TC
Definition: m68k.h:62
@ M68K_REG_PC
Definition: m68k.h:50
@ M68K_REG_MSP
Definition: m68k.h:60
@ M68K_REG_USP
Definition: m68k.h:56
@ M68K_REG_FPSR
Definition: m68k.h:72
@ M68K_REG_ISP
Definition: m68k.h:61
@ M68K_REG_SRP
Definition: m68k.h:69
@ M68K_REG_CACR
Definition: m68k.h:58
@ M68K_OP_BR_DISP_SIZE_LONG
signed 32-bit displacement
Definition: m68k.h:145
@ M68K_OP_BR_DISP_SIZE_WORD
signed 16-bit displacement
Definition: m68k.h:144
const char * code
Definition: pal.c:98
static void special(struct parse *, int)
Definition: regcomp.c:1076
static RzSocket * s
Definition: rtr.c:28
static int
Definition: sfsocketcall.h:114
unsigned short uint16_t
Definition: sftypes.h:30
unsigned int uint32_t
Definition: sftypes.h:29
unsigned long uint64_t
Definition: sftypes.h:28
short int16_t
Definition: sftypes.h:34
unsigned char uint8_t
Definition: sftypes.h:31
char int8_t
Definition: sftypes.h:35
#define d(i)
Definition: sha256.c:44
#define v6
Definition: sparc-opc.c:45
#define v7
Definition: sparc-opc.c:50
Definition: MCInst.h:88
cs_insn * flat_insn
Definition: MCInst.h:95
cs_struct * csh
Definition: MCInst.h:97
unsigned Opcode
Definition: MCInst.h:93
Definition: SStream.h:9
Definition: inftree9.h:24
m68k_reg reg_1
Definition: m68k.h:156
m68k_reg reg_0
Definition: m68k.h:155
Instruction operand.
Definition: m68k.h:160
m68k_op_br_disp br_disp
data when operand is a branch displacement
Definition: m68k.h:170
uint32_t register_bits
register bits for movem etc. (always in d0-d7, a0-a7, fp0 - fp7 order)
Definition: m68k.h:171
m68k_op_mem mem
data when operand is targeting memory
Definition: m68k.h:169
m68k_reg reg
register value for REG operand
Definition: m68k.h:165
m68k_op_type type
Definition: m68k.h:172
m68k_address_mode address_mode
M68K addressing mode for this op.
Definition: m68k.h:173
uint64_t imm
immediate value for IMM operand
Definition: m68k.h:162
cs_m68k_op_reg_pair reg_pair
register pair in one operand
Definition: m68k.h:166
The M68K instruction and it's operands.
Definition: m68k.h:210
void(* instruction)(m68k_info *info)
int32_t disp
displacement value
Definition: m68k.h:149
uint8_t disp_size
Size from m68k_op_br_disp_size type above.
Definition: m68k.h:150
uint8_t width
used for bf* instructions
Definition: m68k.h:135
uint8_t offset
used for bf* instructions
Definition: m68k.h:136
uint8_t bitfield
set to true if the two values below should be used
Definition: m68k.h:134
int16_t disp
displacement value
Definition: m68k.h:132
m68k_reg base_reg
base register (or M68K_REG_INVALID if irrelevant)
Definition: m68k.h:127
char * type
Definition: rz_bin.h:211
int width
Definition: main.c:10
Definition: dis.c:32
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4
static int addr
Definition: z80asm.c:58