Rizin
unix-like reverse engineering framework and cli tools
asm_xap.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2014 nibble <nibble.ds@gmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <stdio.h>
5 #include <rz_types.h>
6 #include <rz_lib.h>
7 #include <rz_util.h>
8 #include <rz_asm.h>
9 #include "xap/dis.c"
10 
11 static int arch_xap_disasm(char *str, const unsigned char *buf, ut64 seek) {
12  struct state *s = get_state();
13  struct directive *d;
14  memset(s, 0, sizeof(*s));
15  s->s_buf = buf;
16  s->s_off = seek;
17  s->s_out = NULL;
18  d = next_inst(s);
19  if (d != NULL) {
20  xap_decode(s, d);
21  strcpy(str, d->d_asm);
22  free(d);
23  } else {
24  *str = '\0';
25  }
26 #if 0
27  if (s->s_ff_quirk) {
28  sprintf(d->d_asm, "DC\t0x%x", i2u16(&d->d_inst));
29  s->s_ff_quirk = 0;
30  }
31 #endif
32  return 0;
33 }
34 static int disassemble(RzAsm *a, struct rz_asm_op_t *op, const ut8 *buf, int len) {
35  char *buf_asm = rz_strbuf_get(&op->buf_asm);
36  arch_xap_disasm(buf_asm, buf, a->pc);
37  return (op->size = 2);
38 }
39 
41  .name = "xap",
42  .arch = "xap",
43  .license = "PD",
44  .bits = 16,
45  .endian = RZ_SYS_ENDIAN_LITTLE,
46  .desc = "XAP4 RISC (CSR)",
47  .disassemble = &disassemble
48 };
49 
50 #ifndef RZ_PLUGIN_INCORE
53  .data = &rz_asm_plugin_xap,
55 };
56 #endif
size_t len
Definition: 6502dis.c:15
RzAsmPlugin rz_asm_plugin_xap
Definition: asm_xap.c:40
static int arch_xap_disasm(char *str, const unsigned char *buf, ut64 seek)
Definition: asm_xap.c:11
RZ_API RzLibStruct rizin_plugin
Definition: asm_xap.c:51
static int disassemble(RzAsm *a, struct rz_asm_op_t *op, const ut8 *buf, int len)
Definition: asm_xap.c:34
#define RZ_API
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
sprintf
Definition: kernel.h:365
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
static RzSocket * s
Definition: rtr.c:28
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
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 d(i)
Definition: sha256.c:44
#define a(i)
Definition: sha256.c:41
Definition: dis.h:26
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.h:43
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static void xap_decode(struct state *s, struct directive *d)
Definition: dis.c:448
static struct directive * next_inst(struct state *s)
Definition: dis.c:463
static struct state * get_state(void)
Definition: dis.c:18
static uint16_t i2u16(struct instruction *in)
Definition: dis.c:23
static int seek(char *argv[])