Rizin
unix-like reverse engineering framework and cli tools
asm_avr.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/avr/assembler.h"
#include "../arch/avr/disassembler.h"

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 *ao, const char *str)
 

Variables

RzAsmPlugin rz_asm_plugin_avr
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ assemble()

static int assemble ( RzAsm a,
RzAsmOp ao,
const char *  str 
)
static

Definition at line 26 of file asm_avr.c.

26  {
27  st32 slen = strlen(str);
28 
29  ut8 buffer[16];
30  ut32 written = avr_assembler(str, slen, buffer, sizeof(buffer), a->pc, a->big_endian);
31 
32  if (written < 1) {
33  return -1;
34  }
35 
36  rz_strbuf_setbin(&ao->buf, (const ut8 *)&buffer, written);
37  return (int)written;
38 }
ut32 avr_assembler(const char *input, st32 input_size, ut8 *output, st32 output_size, ut64 pc, bool be)
Definition: assembler.c:1084
uint32_t ut32
uint8_t ut8
Definition: lh5801.h:11
RZ_API bool rz_strbuf_setbin(RzStrBuf *sb, const ut8 *s, size_t len)
Definition: strbuf.c:85
#define st32
Definition: rz_types_base.h:12
#define a(i)
Definition: sha256.c:41
Definition: buffer.h:15
RzStrBuf buf
Definition: rz_asm.h:71

References a, avr_assembler(), rz_asm_op_t::buf, rz_strbuf_setbin(), st32, and cmd_descs_generate::str.

◆ disassemble()

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

Definition at line 16 of file asm_avr.c.

16  {
17  AVROp aop = { 0 };
18  op->size = avr_disassembler(buf, len, a->pc, a->big_endian, &aop, &op->buf_asm);
19  if (!op->size) {
20  op->size = 2;
21  rz_strbuf_set(&op->buf_asm, "invalid");
22  }
23  return op->size;
24 }
size_t len
Definition: 6502dis.c:15
ut32 avr_disassembler(const ut8 *buffer, const ut32 size, ut64 pc, bool be, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:773
voidpf void * buf
Definition: ioapi.h:138
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153
Definition: dis.c:32

References a, avr_disassembler(), len, and rz_strbuf_set().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_avr
Definition: asm_avr.c:40
@ 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 68 of file asm_avr.c.

◆ rz_asm_plugin_avr

RzAsmPlugin rz_asm_plugin_avr
Initial value:
= {
.name = "avr",
.arch = "avr",
.license = "LGPL3",
.bits = 8 | 16,
.desc = "AVR Atmel",
.disassemble = &disassemble,
.assemble = &assemble,
.cpus =
"ATmega8,"
"ATmega1280,"
"ATmega1281,"
"ATmega16,"
"ATmega168,"
"ATmega2560,"
"ATmega2561,"
"ATmega328p,"
"ATmega32u4,"
"ATmega48,"
"ATmega640,"
"ATmega88,"
"ATxmega128a4u,"
"ATTiny48,"
"ATTiny88,"
}
static int assemble(RzAsm *a, RzAsmOp *ao, const char *str)
Definition: asm_avr.c:26
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_avr.c:16
#define RZ_SYS_ENDIAN_BIG
Definition: rz_types.h:527
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 40 of file asm_avr.c.