Rizin
unix-like reverse engineering framework and cli tools
asm_rsp.c File Reference
#include <rz_types.h>
#include <rz_util.h>
#include <rz_asm.h>
#include <rz_lib.h>
#include <stdarg.h>
#include <stdio.h>
#include "rsp_idec.h"

Go to the source code of this file.

Functions

static int disassemble (RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
 

Variables

RzAsmPlugin rz_asm_plugin_rsp
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ disassemble()

static int disassemble ( RzAsm a,
RzAsmOp op,
const ut8 buf,
int  len 
)
static

Definition at line 15 of file asm_rsp.c.

15  {
16  rsp_instruction rz_instr;
17  int i;
18 
19  /* all instructions are 32bit words */
20  if (len < 4) {
21  op->size = 0;
22  return 0;
23  }
24  op->size = 4;
25 
26  ut32 iw = rz_read_ble32(buf, a->big_endian);
27  rz_instr = rsp_instruction_decode(a->pc, iw);
28 
29  rz_strbuf_append(&op->buf_asm, rz_instr.mnemonic);
30  for (i = 0; i < rz_instr.noperands; i++) {
31  rz_strbuf_append(&op->buf_asm, (i == 0) ? " " : ", ");
32 
33  switch (rz_instr.operands[i].type) {
34  case RSP_OPND_GP_REG:
35  rz_strbuf_append(&op->buf_asm, rsp_gp_reg_soft_names[rz_instr.operands[i].u]);
36  break;
37  case RSP_OPND_OFFSET:
38  case RSP_OPND_TARGET:
39  rz_strbuf_appendf(&op->buf_asm, "0x%08" PFMT64x, rz_instr.operands[i].u);
40  break;
41  case RSP_OPND_ZIMM: {
42  int shift = (rz_instr.operands[i].u & ~0xffff) ? 16 : 0;
43  rz_strbuf_appendf(&op->buf_asm, "0x%04" PFMT64x,
44  rz_instr.operands[i].u >> shift);
45  } break;
46  case RSP_OPND_SIMM:
47  rz_strbuf_appendf(&op->buf_asm, "%s0x%04" PFMT64x,
48  (rz_instr.operands[i].s < 0) ? "-" : "",
49  (rz_instr.operands[i].s < 0) ? -rz_instr.operands[i].s : rz_instr.operands[i].s);
50  break;
52  rz_strbuf_appendf(&op->buf_asm, "%" PFMT64u, rz_instr.operands[i].u);
53  break;
55  rz_strbuf_appendf(&op->buf_asm, "%s0x%04x(%s)",
56  (rz_instr.operands[i].s < 0) ? "-" : "",
57  (ut32)((rz_instr.operands[i].s < 0) ? -rz_instr.operands[i].s : rz_instr.operands[i].s),
58  rsp_gp_reg_soft_names[rz_instr.operands[i].u]);
59  break;
60  case RSP_OPND_C0_REG:
61  rz_strbuf_append(&op->buf_asm, rsp_c0_reg_soft_names[rz_instr.operands[i].u]);
62  break;
63  case RSP_OPND_C2_CREG:
64  rz_strbuf_append(&op->buf_asm, rsp_c2_creg_names[rz_instr.operands[i].u]);
65  break;
66  case RSP_OPND_C2_ACCU:
67  rz_strbuf_append(&op->buf_asm, rsp_c2_accu_names[rz_instr.operands[i].u]);
68  break;
69  case RSP_OPND_C2_VREG:
70  rz_strbuf_append(&op->buf_asm, rsp_c2_vreg_names[rz_instr.operands[i].u]);
71  break;
74  rz_strbuf_appendf(&op->buf_asm, "%s[%u]", rsp_c2_vreg_names[rz_instr.operands[i].u],
75  (ut32)rz_instr.operands[i].s);
76  break;
78  rz_strbuf_appendf(&op->buf_asm, "%s%s", rsp_c2_vreg_names[rz_instr.operands[i].u], rsp_c2_vreg_element_names[rz_instr.operands[i].s]);
79  break;
80  default: /* should not happend */
81  rz_strbuf_append(&op->buf_asm, "???");
82  break;
83  }
84  }
85 
86  return op->size;
87 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
Definition: arm_il32.c:190
uint32_t ut32
voidpf void * buf
Definition: ioapi.h:138
rsp_instruction rsp_instruction_decode(ut64 pc, ut32 iw)
Definition: rsp_idec.c:587
const char * rsp_c0_reg_soft_names[]
Definition: rsp_idec.c:13
const char * rsp_gp_reg_soft_names[]
Definition: rsp_idec.c:6
const char * rsp_c2_vreg_names[]
Definition: rsp_idec.c:68
const char * rsp_c2_accu_names[]
Definition: rsp_idec.c:64
const char * rsp_c2_creg_names[]
Definition: rsp_idec.c:60
const char * rsp_c2_vreg_element_names[]
Definition: rsp_idec.c:75
@ RSP_OPND_OFFSET
Definition: rsp_idec.h:150
@ RSP_OPND_BASE_OFFSET
Definition: rsp_idec.h:154
@ RSP_OPND_C2_ACCU
Definition: rsp_idec.h:157
@ RSP_OPND_C2_CREG
Definition: rsp_idec.h:156
@ RSP_OPND_SIMM
Definition: rsp_idec.h:152
@ RSP_OPND_C0_REG
Definition: rsp_idec.h:155
@ RSP_OPND_SHIFT_AMOUNT
Definition: rsp_idec.h:153
@ RSP_OPND_ZIMM
Definition: rsp_idec.h:151
@ RSP_OPND_C2_VREG_ELEMENT
Definition: rsp_idec.h:161
@ RSP_OPND_C2_VREG
Definition: rsp_idec.h:158
@ RSP_OPND_C2_VREG_BYTE
Definition: rsp_idec.h:159
@ RSP_OPND_C2_VREG_SCALAR
Definition: rsp_idec.h:160
@ RSP_OPND_TARGET
Definition: rsp_idec.h:149
@ RSP_OPND_GP_REG
Definition: rsp_idec.h:148
static ut32 rz_read_ble32(const void *src, bool big_endian)
Definition: rz_endian.h:497
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
Definition: strbuf.c:222
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
#define PFMT64u
Definition: rz_types.h:395
#define PFMT64x
Definition: rz_types.h:393
#define a(i)
Definition: sha256.c:41
rsp_operand operands[RSP_MAX_OPNDS]
Definition: rsp_idec.h:176
const char * mnemonic
Definition: rsp_idec.h:173
rsp_operand_type type
Definition: rsp_idec.h:165
Definition: dis.c:32

References a, i, len, rsp_instruction::mnemonic, rsp_instruction::noperands, rsp_instruction::operands, PFMT64u, PFMT64x, rsp_c0_reg_soft_names, rsp_c2_accu_names, rsp_c2_creg_names, rsp_c2_vreg_element_names, rsp_c2_vreg_names, rsp_gp_reg_soft_names, rsp_instruction_decode(), RSP_OPND_BASE_OFFSET, RSP_OPND_C0_REG, RSP_OPND_C2_ACCU, RSP_OPND_C2_CREG, RSP_OPND_C2_VREG, RSP_OPND_C2_VREG_BYTE, RSP_OPND_C2_VREG_ELEMENT, RSP_OPND_C2_VREG_SCALAR, RSP_OPND_GP_REG, RSP_OPND_OFFSET, RSP_OPND_SHIFT_AMOUNT, RSP_OPND_SIMM, RSP_OPND_TARGET, RSP_OPND_ZIMM, rz_read_ble32(), rz_strbuf_append(), rz_strbuf_appendf(), rsp_operand::s, shift(), rsp_operand::type, and rsp_operand::u.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_rsp
Definition: asm_rsp.c:89
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_asm.h:133

Definition at line 100 of file asm_rsp.c.

◆ rz_asm_plugin_rsp

RzAsmPlugin rz_asm_plugin_rsp
Initial value:
= {
.name = "rsp",
.desc = "Reality Signal Processor",
.arch = "rsp",
.bits = 32,
.endian = RZ_SYS_ENDIAN_BI,
.license = "LGPL3",
.disassemble = &disassemble
}
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_rsp.c:15
#define RZ_SYS_ENDIAN_BI
Definition: rz_types.h:528

Definition at line 89 of file asm_rsp.c.