2010-02-22 02:42:29 +01:00
|
|
|
/* radare - GPL3 - Copyright 2009-2010 nibble<.ds@gmail.com> */
|
2009-02-18 03:47:40 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <r_types.h>
|
|
|
|
#include <r_lib.h>
|
|
|
|
#include <r_util.h>
|
|
|
|
#include <r_asm.h>
|
|
|
|
|
|
|
|
#include "ppc/ppc_disasm/ppc_disasm.h"
|
|
|
|
|
2010-02-22 02:42:29 +01:00
|
|
|
static int disassemble(struct r_asm_t *a, struct r_asm_aop_t *aop, ut8 *buf, ut64 len) {
|
2009-02-18 03:47:40 +01:00
|
|
|
ppc_word iaddr = (ppc_word)a->pc;
|
|
|
|
ppc_word bof[4];
|
|
|
|
char opcode[128];
|
|
|
|
char operands[128];
|
|
|
|
|
2009-02-26 15:15:19 +01:00
|
|
|
static struct DisasmPara_PPC dp;
|
2009-02-18 03:47:40 +01:00
|
|
|
/* initialize DisasmPara */
|
|
|
|
memcpy(bof, buf, 4);
|
|
|
|
dp.opcode = opcode;
|
|
|
|
dp.operands = operands;
|
|
|
|
dp.iaddr = &iaddr;
|
|
|
|
dp.instr = bof;
|
|
|
|
PPC_Disassemble(&dp, a->big_endian);
|
2009-04-16 19:20:03 +02:00
|
|
|
snprintf(aop->buf_asm, R_ASM_BUFSIZE, "%s %s", opcode, operands);
|
2009-02-18 03:47:40 +01:00
|
|
|
aop->inst_len = 4;
|
|
|
|
|
|
|
|
return aop->inst_len;
|
|
|
|
}
|
|
|
|
|
2009-03-10 01:49:24 +00:00
|
|
|
struct r_asm_handle_t r_asm_plugin_ppc = {
|
2009-09-24 12:29:05 +02:00
|
|
|
.name = "ppc",
|
2010-02-22 02:42:29 +01:00
|
|
|
.arch = "ppc",
|
2009-04-11 21:22:20 +00:00
|
|
|
.bits = (int[]){ 32, 0 },
|
2009-02-18 03:47:40 +01:00
|
|
|
.desc = "PPC disassembly plugin",
|
|
|
|
.init = NULL,
|
|
|
|
.fini = NULL,
|
|
|
|
.disassemble = &disassemble,
|
|
|
|
.assemble = NULL
|
|
|
|
};
|
|
|
|
|
2009-03-10 12:21:46 +01:00
|
|
|
#ifndef CORELIB
|
2009-02-18 03:47:40 +01:00
|
|
|
struct r_lib_struct_t radare_plugin = {
|
|
|
|
.type = R_LIB_TYPE_ASM,
|
|
|
|
.data = &r_asm_plugin_ppc
|
|
|
|
};
|
2009-03-10 12:21:46 +01:00
|
|
|
#endif
|