Rizin
unix-like reverse engineering framework and cli tools
asm_8051.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2013-2019 pancake <pancake@nopcode.org>
2 // SPDX-FileCopyrightText: 2013-2019 astuder <github@adrianstuder.com>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include <stdio.h>
6 #include <stdarg.h>
7 #include <string.h>
8 #include <rz_types.h>
9 #include <rz_util.h>
10 #include <rz_lib.h>
11 #include <rz_asm.h>
12 
13 #include <8051_ass.h>
14 #include "../arch/8051/8051_disas.c"
15 
16 static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
17  int dlen = 0;
18  char *s = rz_8051_disas(a->pc, buf, len, &dlen);
19  if (dlen < 0) {
20  dlen = 0;
21  }
22  if (s) {
23  rz_strbuf_set(&op->buf_asm, s);
24  free(s);
25  }
26  op->size = dlen;
27  return dlen;
28 }
29 
31  .name = "8051",
32  .arch = "8051",
33  .bits = 8,
34  .endian = RZ_SYS_ENDIAN_NONE,
35  .desc = "8051 Intel CPU",
36  .disassemble = &disassemble,
37  .assemble = &assemble_8051,
38  .license = "PD",
39  .cpus =
40  "8051-generic," // First one is default
41  "8051-shared-code-xdata"
42 };
43 
44 #ifndef RZ_PLUGIN_INCORE
47  .data = &rz_asm_plugin_8051,
49 };
50 #endif
size_t len
Definition: 6502dis.c:15
int assemble_8051(RzAsm *a, RzAsmOp *op, char const *user_asm)
Definition: 8051_ass.c:1183
static char * rz_8051_disas(ut64 pc, const ut8 *buf, int len, int *olen)
Definition: 8051_disas.c:69
RZ_API RzLibStruct rizin_plugin
Definition: asm_8051.c:45
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_8051.c:16
RzAsmPlugin rz_asm_plugin_8051
Definition: asm_8051.c:30
#define RZ_API
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
static RzSocket * s
Definition: rtr.c:28
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153
#define RZ_SYS_ENDIAN_NONE
Definition: rz_types.h:525
#define RZ_VERSION
Definition: rz_version.h:8
#define a(i)
Definition: sha256.c:41
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32