mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-25 06:36:34 +00:00
55 lines
1.1 KiB
C
55 lines
1.1 KiB
C
/* radare2 - LGPL - Copyright 2013-2014 - pancake */
|
|
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
#include <r_types.h>
|
|
#include <r_util.h>
|
|
#include <r_lib.h>
|
|
#include <r_asm.h>
|
|
|
|
#include <8051_disas.h>
|
|
|
|
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
|
|
char *tmp = NULL;
|
|
|
|
r_8051_op o = r_8051_decode (buf, len);
|
|
memset(op->buf_asm, 0, sizeof (op->buf_asm));
|
|
if (!o.name) return 0; // invalid instruction
|
|
tmp = r_8051_disasm (o, a->pc, op->buf_asm, sizeof (op->buf_asm));
|
|
if (tmp) {
|
|
if (strlen(tmp) < sizeof (op->buf_asm)) {
|
|
strncpy (op->buf_asm, tmp, strlen (tmp));
|
|
} else {
|
|
eprintf ("8051 disassemble: too big opcode!\n");
|
|
free (tmp);
|
|
op->size = -1;
|
|
return -1;
|
|
}
|
|
free (tmp);
|
|
}
|
|
if (!*op->buf_asm) {
|
|
op->size = 1;
|
|
return -1;
|
|
}
|
|
return (op->size = o.length);
|
|
}
|
|
|
|
RAsmPlugin r_asm_plugin_8051 = {
|
|
.name = "8051",
|
|
.arch = "8051",
|
|
.bits = 8,
|
|
.endian = R_SYS_ENDIAN_NONE,
|
|
.desc = "8051 Intel CPU",
|
|
.disassemble = &disassemble,
|
|
.license = "PD"
|
|
};
|
|
|
|
#ifndef CORELIB
|
|
RLibStruct radare_plugin = {
|
|
.type = R_LIB_TYPE_ASM,
|
|
.data = &r_asm_plugin_8051,
|
|
.version = R2_VERSION
|
|
};
|
|
#endif
|