Rizin
unix-like reverse engineering framework and cli tools
asm_mcore.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2018 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_asm.h>
5 #include <rz_lib.h>
6 #include "../arch/mcore/mcore.h"
7 
8 static mcore_handle handle = { 0 };
9 
10 static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
11  mcore_t *instr = NULL;
12  char tmp[256];
13  if (!op || mcore_init(&handle, buf, len)) {
14  return -1;
15  }
16  op->size = 2;
17  if ((instr = mcore_next(&handle))) {
18  mcore_snprint(tmp, sizeof(tmp), a->pc, instr);
19  mcore_free(instr);
21  } else {
22  rz_asm_op_set_asm(op, "invalid");
23  }
24  return op->size;
25 }
26 
28  .name = "mcore",
29  .desc = "Motorola MCORE disassembler",
30  .license = "LGPL3",
31  .arch = "mcore",
32  .cpus = "mcore,c-sky",
33  .bits = 32,
34  .endian = RZ_SYS_ENDIAN_BIG,
35  .disassemble = &disassemble,
36 };
37 
38 #ifndef RZ_PLUGIN_INCORE
41  .data = &rz_asm_plugin_mcore,
43 };
44 #endif
size_t len
Definition: 6502dis.c:15
RZ_API void rz_asm_op_set_asm(RzAsmOp *op, const char *str)
Definition: aop.c:53
RZ_API RzLibStruct rizin_plugin
Definition: asm_mcore.c:39
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_mcore.c:10
static mcore_handle handle
Definition: asm_mcore.c:8
RzAsmPlugin rz_asm_plugin_mcore
Definition: asm_mcore.c:27
#define RZ_API
#define NULL
Definition: cris-opc.c:27
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
int mcore_init(mcore_handle *handle, const ut8 *buffer, const ut32 size)
Definition: mcore.c:409
void mcore_snprint(char *str, int size, ut64 addr, mcore_t *instr)
Definition: mcore.c:469
mcore_t * mcore_next(mcore_handle *handle)
Definition: mcore.c:418
void mcore_free(mcore_t *instr)
Definition: mcore.c:432
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_SYS_ENDIAN_BIG
Definition: rz_types.h:527
#define RZ_VERSION
Definition: rz_version.h:8
#define a(i)
Definition: sha256.c:41
Definition: mcore.h:40
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32