Rizin
unix-like reverse engineering framework and cli tools
asm_lh5801.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014-2015 jn
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "../../arch/lh5801/lh5801.c"
5 #include <rz_asm.h>
6 #include <rz_types.h>
7 #include <rz_lib.h>
8 
9 static int disassemble(RzAsm *as, RzAsmOp *op, const ut8 *buf, int len) {
10  struct lh5801_insn insn = { 0 };
11  if (!op) {
12  return 0;
13  }
14  int consumed = lh5801_decode(&insn, buf, len);
15  if (consumed == -1 || consumed == 0) {
16  rz_strbuf_set(&op->buf_asm, "invalid");
17  op->size = 1;
18  return 0;
19  }
20  char buf_asm[128] = { 0 };
21  lh5801_print_insn(buf_asm, sizeof(buf_asm), &insn);
22  rz_strbuf_set(&op->buf_asm, buf_asm);
23  op->size = consumed;
24  // op->payload = lh5801_insn_descs[insn.type].format & 3;
25  // ^ MAYBE?
26  return op->size;
27 }
28 
30  .name = "lh5801",
31  .arch = "LH5801",
32  .license = "LGPL3",
33  .bits = 8,
34  .endian = RZ_SYS_ENDIAN_NONE,
35  .desc = "SHARP LH5801 disassembler",
36  .disassemble = &disassemble
37 };
38 
39 #ifndef RZ_PLUGIN_INCORE
42  .data = &rz_asm_plugin_lh5801,
44 };
45 #endif
size_t len
Definition: 6502dis.c:15
static int disassemble(RzAsm *as, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_lh5801.c:9
RzAsmPlugin rz_asm_plugin_lh5801
Definition: asm_lh5801.c:29
RZ_API RzLibStruct rizin_plugin
Definition: asm_lh5801.c:40
#define RZ_API
voidpf void * buf
Definition: ioapi.h:138
void lh5801_print_insn(char *out, int size, const struct lh5801_insn *insn)
Definition: lh5801.c:792
int lh5801_decode(struct lh5801_insn *insn, const ut8 *buf, int len)
Definition: lh5801.c:674
uint8_t ut8
Definition: lh5801.h:11
@ 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
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32