Rizin
unix-like reverse engineering framework and cli tools
asm_msp430.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014-2015 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 <msp430_disas.h>
11 
12 static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
13  struct msp430_cmd cmd;
14  int ret = msp430_decode_command(buf, len, &cmd);
15  if (ret > 0) {
16  if (cmd.operands[0]) {
17  rz_strbuf_set(&op->buf_asm, sdb_fmt("%s %s", cmd.instr, cmd.operands));
18  } else {
19  rz_strbuf_set(&op->buf_asm, sdb_fmt("%s", cmd.instr));
20  }
21  }
22  if (a->syntax != RZ_ASM_SYNTAX_ATT) {
23  char *ba = (char *)rz_strbuf_get(&op->buf_asm);
24  rz_str_replace_ch(ba, '#', 0, 1);
25  // rz_str_replace_ch (ba, "$", "$$", 1);
26  rz_str_replace_ch(ba, '&', 0, 1);
27  rz_str_replace_ch(ba, '%', 0, 1);
28  }
29 
30  return op->size = ret;
31 }
32 
34  .name = "msp430",
35  .license = "LGPL3",
36  .desc = "msp430 disassembly plugin",
37  .arch = "msp430",
38  .bits = 16,
39  .endian = RZ_SYS_ENDIAN_LITTLE,
40  .disassemble = &disassemble,
41 };
42 
43 #ifndef RZ_PLUGIN_INCORE
46  .data = &rz_asm_plugin_msp430,
48 };
49 #endif
size_t len
Definition: 6502dis.c:15
RZ_API RzLibStruct rizin_plugin
Definition: asm_msp430.c:44
RzAsmPlugin rz_asm_plugin_msp430
Definition: asm_msp430.c:33
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_msp430.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 msp430_decode_command(const ut8 *in, int len, struct msp430_cmd *cmd)
Definition: msp430_disas.c:441
@ RZ_ASM_SYNTAX_ATT
Definition: rz_asm.h:51
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
RZ_API int rz_str_replace_ch(char *s, char a, char b, bool g)
Definition: str.c:139
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
Definition: strbuf.c:321
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526
#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