Rizin
unix-like reverse engineering framework and cli tools
asm_snes.c File Reference
#include <rz_types.h>
#include <rz_util.h>
#include <rz_asm.h>
#include <rz_lib.h>
#include "../arch/snes/snesdis.c"
#include "asm_snes.h"

Go to the source code of this file.

Functions

static int dis (RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
 
static bool snes_asm_init (void **user)
 
static bool snes_asm_fini (void *user)
 

Variables

RzAsmPlugin rz_asm_plugin_snes
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ dis()

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

Definition at line 12 of file asm_snes.c.

12  {
13  struct snes_asm_flags *snesflags = (struct snes_asm_flags *)a->plugin_data;
14  int dlen = snesDisass(snesflags->M, snesflags->X, a->pc, op, buf, len);
15  if (dlen < 0) {
16  dlen = 0;
17  }
18  op->size = dlen;
19  if (buf[0] == 0xc2) { // REP
20  if (buf[1] & 0x10) {
21  snesflags->X = 0;
22  }
23  if (buf[1] & 0x20) {
24  snesflags->M = 0;
25  }
26  } else if (buf[0] == 0xe2) { // SEP
27  if (buf[1] & 0x10) {
28  snesflags->X = 1;
29  }
30  if (buf[1] & 0x20) {
31  snesflags->M = 1;
32  }
33  }
34  return dlen;
35 }
size_t len
Definition: 6502dis.c:15
voidpf void * buf
Definition: ioapi.h:138
#define a(i)
Definition: sha256.c:41
static int snesDisass(int M_flag, int X_flag, ut64 pc, RzAsmOp *op, const ut8 *buf, int len)
Definition: snesdis.c:12
unsigned char M
Definition: asm_snes.h:9
unsigned char X
Definition: asm_snes.h:10
Definition: dis.c:32

References a, len, snes_asm_flags::M, snesDisass(), and snes_asm_flags::X.

Referenced by cmd_pCd(), cmd_pCD(), cmd_pCx(), rz_core_visual_xrefs(), and rz_main_rz_asm().

◆ snes_asm_fini()

static bool snes_asm_fini ( void *  user)
static

Definition at line 42 of file asm_snes.c.

42  {
43  rz_return_val_if_fail(user, false);
44  free(user);
45  return true;
46 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108

References free(), and rz_return_val_if_fail.

◆ snes_asm_init()

static bool snes_asm_init ( void **  user)
static

Definition at line 37 of file asm_snes.c.

37  {
38  *user = RZ_NEW0(struct snes_asm_flags);
39  return *user != NULL;
40 }
#define NULL
Definition: cris-opc.c:27
#define RZ_NEW0(x)
Definition: rz_types.h:284

References NULL, and RZ_NEW0.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_snes
Definition: asm_snes.c:48
@ 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 61 of file asm_snes.c.

◆ rz_asm_plugin_snes

RzAsmPlugin rz_asm_plugin_snes
Initial value:
= {
.name = "snes",
.desc = "SuperNES CPU",
.arch = "snes",
.bits = 8 | 16,
.init = snes_asm_init,
.fini = snes_asm_fini,
.license = "LGPL3",
.disassemble = &dis
}
static bool snes_asm_fini(void *user)
Definition: asm_snes.c:42
static int dis(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_snes.c:12
static bool snes_asm_init(void **user)
Definition: asm_snes.c:37
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 48 of file asm_snes.c.