Rizin
unix-like reverse engineering framework and cli tools
asm_propeller.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014 fedor.sakharov <fedor.sakharov@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <stdio.h>
5 #include <string.h>
6 #include <rz_types.h>
7 #include <rz_lib.h>
8 #include <rz_asm.h>
9 
10 #include <propeller_disas.h>
11 
12 static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
13  rz_return_val_if_fail(a && op && buf && len >= 4, -1);
14  const char *buf_asm;
15  struct propeller_cmd cmd;
16  int ret = propeller_decode_command(buf, &cmd);
17  if (cmd.prefix[0] && cmd.operands[0]) {
18  buf_asm = sdb_fmt("%s %s %s", cmd.prefix, cmd.instr, cmd.operands);
19  } else if (cmd.operands[0]) {
20  buf_asm = sdb_fmt("%s %s", cmd.instr, cmd.operands);
21  } else {
22  buf_asm = sdb_fmt("%s", cmd.instr);
23  }
24  rz_asm_op_set_asm(op, buf_asm);
25  op->size = 4;
26  return ret;
27 }
28 
30  .name = "propeller",
31  .license = "LGPL3",
32  .desc = "propeller disassembly plugin",
33  .arch = "propeller",
34  .bits = 32,
35  .endian = RZ_SYS_ENDIAN_BIG,
36  .disassemble = &disassemble
37 };
38 
39 #ifndef RZ_PLUGIN_INCORE
42  .data = &rz_asm_plugin_propeller,
44 };
45 #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_propeller.c:40
RzAsmPlugin rz_asm_plugin_propeller
Definition: asm_propeller.c:29
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_propeller.c:12
#define RZ_API
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
RZ_API char * sdb_fmt(const char *fmt,...)
Definition: fmt.c:26
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
int propeller_decode_command(const ut8 *instr, struct propeller_cmd *cmd)
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
@ 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
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32