static int disassemble(RAsm *a, RAsmOp *aop, const ut8 *buf, int len) { m68k_word bof[8] = {0}; int iaddr = (int)a->pc; char opcode[256], operands[256]; const unsigned char *buf2; int ilen ; static struct DisasmPara_68k dp; char *buf_asm; /* initialize DisasmPara */ *operands = *opcode = 0; memcpy (bof, buf, R_MIN(len, sizeof(bof))); dp.opcode = opcode; dp.operands = operands; dp.iaddr = (m68k_word *) (size_t)iaddr; dp.instr = bof; buf2 = (const ut8*)M68k_Disassemble (&dp); if (!buf2) { // invalid instruction return aop->size = 2; } ilen = (buf2-(const ut8*)bof); if (*operands) buf_asm = sdb_fmt ("%s %s", opcode, operands); else buf_asm = sdb_fmt ("%s", opcode); r_str_rmch (buf_asm, '#'); r_asm_op_set_asm (aop, buf_asm); aop->size = ilen; return aop->size; }
static int instlen(const ut8 *buf, int len) { m68k_word bof[8] = {0}; char opcode[256], operands[256]; const unsigned char *buf2; static struct DisasmPara_68k dp; /* initialize DisasmPara */ *operands = *opcode = 0; memcpy (bof, buf, R_MIN(len, sizeof(bof))); dp.opcode = opcode; dp.operands = operands; dp.iaddr = 0LL; dp.instr = bof; buf2 = (const ut8*)M68k_Disassemble (&dp); if (!buf2) { // invalid instruction return 2; } return (buf2-(const ut8*)bof); }
static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len) { m68k_word bof[4]; m68k_word iaddr = (m68k_word)a->pc; char opcode[256]; char operands[256]; static struct DisasmPara_68k dp; /* initialize DisasmPara */ memcpy(bof, buf, 4); dp.opcode = opcode; dp.operands = operands; dp.iaddr = &iaddr; dp.instr = bof; M68k_Disassemble(&dp); snprintf(aop->buf_asm, R_ASM_BUFSIZE, "%s %s", opcode, operands); aop->inst_len = 4; return aop->inst_len; }