Rizin
unix-like reverse engineering framework and cli tools
asm_dcpu16.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <rz_types.h>
#include <rz_util.h>
#include <rz_lib.h>
#include <rz_asm.h>
#include "../arch/dcpu16/dcpu16.h"
#include "../arch/dcpu16/dis.c"
#include "../arch/dcpu16/asm.c"

Go to the source code of this file.

Functions

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

Variables

RzAsmPlugin rz_asm_plugin_dcpu16
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ assemble()

static int assemble ( RzAsm a,
RzAsmOp op,
const char *  buf 
)
static

Definition at line 25 of file asm_dcpu16.c.

25  {
26  int len = dcpu16_assemble((ut8 *)rz_strbuf_get(&op->buf), buf);
27  op->buf.len = len;
28  return len;
29 }
size_t len
Definition: 6502dis.c:15
int dcpu16_assemble(ut8 *out, const char *unoline)
Definition: asm.c:216
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
Definition: strbuf.c:321
Definition: dis.c:32

References dcpu16_assemble(), len, and rz_strbuf_get().

◆ disassemble()

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

Definition at line 15 of file asm_dcpu16.c.

15  {
16  char buf_asm[96];
17  if (len < 2) {
18  return -1; // at least 2 bytes!
19  }
20  op->size = dcpu16_disasm(buf_asm, sizeof(buf_asm), (const ut16 *)buf, len, NULL);
21  rz_strbuf_set(&op->buf_asm, (op->size > 0) ? buf_asm : "(data)");
22  return op->size;
23 }
#define NULL
Definition: cris-opc.c:27
int dcpu16_disasm(char *out, size_t size_out, const ut16 *inp, int len, int *cost)
Definition: dis.c:130
uint16_t ut16
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153

References dcpu16_disasm(), len, NULL, and rz_strbuf_set().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_dcpu16
Definition: asm_dcpu16.c:31
@ 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 43 of file asm_dcpu16.c.

◆ rz_asm_plugin_dcpu16

RzAsmPlugin rz_asm_plugin_dcpu16
Initial value:
= {
.name = "dcpu16",
.arch = "dpcu",
.bits = 16,
.desc = "Mojang's DCPU-16",
.license = "PD",
.disassemble = &disassemble,
.assemble = &assemble
}
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_dcpu16.c:15
static int assemble(RzAsm *a, RzAsmOp *op, const char *buf)
Definition: asm_dcpu16.c:25
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 31 of file asm_dcpu16.c.