Rizin
unix-like reverse engineering framework and cli tools
M68KDisassembler.h File Reference
#include "../../MCInst.h"

Go to the source code of this file.

Classes

struct  m68k_info
 

Typedefs

typedef struct m68k_info m68k_info
 

Functions

bool M68K_getInstruction (csh ud, const uint8_t *code, size_t code_len, MCInst *instr, uint16_t *size, uint64_t address, void *info)
 

Typedef Documentation

◆ m68k_info

typedef struct m68k_info m68k_info

Function Documentation

◆ M68K_getInstruction()

bool M68K_getInstruction ( csh  ud,
const uint8_t code,
size_t  code_len,
MCInst instr,
uint16_t size,
uint64_t  address,
void *  info 
)

Definition at line 3601 of file M68KDisassembler.c.

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 }
@ M68K_CPU_TYPE_68030
@ M68K_CPU_TYPE_68010
@ M68K_CPU_TYPE_68020
@ M68K_CPU_TYPE_68000
@ M68K_CPU_TYPE_68040
static void build_regs_read_write_counts(m68k_info *info)
static void m68k_setup_internals(m68k_info *info, MCInst *inst, unsigned int pc, unsigned int cpu_type)
static unsigned int m68k_disassemble(m68k_info *info, uint64_t pc)
void M68K_printInst(MCInst *MI, SStream *O, void *PrinterInfo)
void SStream_Init(SStream *ss)
Definition: SStream.c:25
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
@ 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
voidpf void uLong size
Definition: ioapi.h:138
#define offsetof(type, member)
return memset(p, 0, total)
const char * code
Definition: pal.c:98
static RzSocket * s
Definition: rtr.c:28
unsigned short uint16_t
Definition: sftypes.h:30
cs_insn * flat_insn
Definition: MCInst.h:95
cs_struct * csh
Definition: MCInst.h:97
Definition: SStream.h:9
The M68K instruction and it's operands.
Definition: m68k.h:210
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4

References build_regs_read_write_counts(), code, cpu_type, CS_MODE_M68K_010, CS_MODE_M68K_020, CS_MODE_M68K_030, CS_MODE_M68K_040, CS_MODE_M68K_060, MCInst::csh, MCInst::flat_insn, handle, if(), info(), M68K_CPU_TYPE_68000, M68K_CPU_TYPE_68010, M68K_CPU_TYPE_68020, M68K_CPU_TYPE_68030, M68K_CPU_TYPE_68040, m68k_disassemble(), M68K_printInst(), m68k_setup_internals(), memset(), offsetof, s, and SStream_Init().