Rizin
unix-like reverse engineering framework and cli tools
asm_vax.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 "disas-asm.h"
#include "../arch/vax/vax.h"

Go to the source code of this file.

Functions

static int vax_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info)
 
static int symbol_at_address (bfd_vma addr, struct disassemble_info *info)
 
static void memory_error_func (int status, bfd_vma memaddr, struct disassemble_info *info)
 
static int disassemble (RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
 

Variables

static unsigned long Offset = 0
 
static RzStrBufbuf_global = NULL
 
static const ut8bytes = NULL
 
static int bytes_size = 0
 
RzAsmPlugin rz_asm_plugin_vax
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ disassemble()

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

Definition at line 46 of file asm_vax.c.

46  {
47  struct disassemble_info disasm_obj;
48  if (len < 4) {
49  return -1;
50  }
51  buf_global = &op->buf_asm;
52  bytes = buf;
53  bytes_size = len;
54  Offset = a->pc;
55 
56  /* prepare disassembler */
57  memset(&disasm_obj, '\0', sizeof(struct disassemble_info));
58  disasm_obj.buffer = (ut8 *)bytes;
59  disasm_obj.read_memory_func = &vax_buffer_read_memory;
60  disasm_obj.symbol_at_address_func = &symbol_at_address;
61  disasm_obj.memory_error_func = &memory_error_func;
62  disasm_obj.print_address_func = &generic_print_address_func;
63  disasm_obj.endian = BFD_ENDIAN_LITTLE;
64  disasm_obj.fprintf_func = &generic_fprintf_func;
65  disasm_obj.stream = stdout;
66  op->size = print_insn_vax((bfd_vma)Offset, &disasm_obj);
67 
68  if (op->size == -1) {
69  rz_asm_op_set_asm(op, "(data)");
70  }
71  return op->size;
72 }
size_t len
Definition: 6502dis.c:15
RZ_API void rz_asm_op_set_asm(RzAsmOp *op, const char *str)
Definition: aop.c:53
static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_info *info)
Definition: asm_vax.c:39
static int bytes_size
Definition: asm_vax.c:21
static unsigned long Offset
Definition: asm_vax.c:18
static int vax_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info)
Definition: asm_vax.c:23
static int symbol_at_address(bfd_vma addr, struct disassemble_info *info)
Definition: asm_vax.c:35
static RzStrBuf * buf_global
Definition: asm_vax.c:19
static const ut8 * bytes
Definition: asm_vax.c:20
int print_insn_vax(bfd_vma, disassemble_info *)
Definition: vax-dis.c:290
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
BFD_HOST_U_64_BIT bfd_vma
Definition: mybfd.h:111
@ BFD_ENDIAN_LITTLE
Definition: mybfd.h:4618
#define a(i)
Definition: sha256.c:41
Definition: dis.c:32

References a, BFD_ENDIAN_LITTLE, buf_global, disassemble_info::buffer, bytes, bytes_size, disassemble_info::endian, disassemble_info::fprintf_func, len, memory_error_func(), disassemble_info::memory_error_func, memset(), Offset, disassemble_info::print_address_func, print_insn_vax(), disassemble_info::read_memory_func, rz_asm_op_set_asm(), disassemble_info::stream, symbol_at_address(), disassemble_info::symbol_at_address_func, and vax_buffer_read_memory().

◆ memory_error_func()

static void memory_error_func ( int  status,
bfd_vma  memaddr,
struct disassemble_info info 
)
static

Definition at line 39 of file asm_vax.c.

39  {
40  //--
41 }

Referenced by disassemble().

◆ symbol_at_address()

static int symbol_at_address ( bfd_vma  addr,
struct disassemble_info info 
)
static

Definition at line 35 of file asm_vax.c.

35  {
36  return 0;
37 }

Referenced by disassemble().

◆ vax_buffer_read_memory()

static int vax_buffer_read_memory ( bfd_vma  memaddr,
bfd_byte myaddr,
ut32  length,
struct disassemble_info info 
)
static

Definition at line 23 of file asm_vax.c.

23  {
24  int delta = (memaddr - Offset);
25  if (delta < 0) {
26  return -1; // disable backward reads
27  }
28  if (delta > length) {
29  return -1;
30  }
31  memcpy(myaddr, bytes + delta, RZ_MIN(length, bytes_size));
32  return 0;
33 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
Definition: sflib.h:133
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
#define RZ_MIN(x, y)
static st64 delta
Definition: vmenus.c:2425

References bytes, bytes_size, delta, length, memcpy(), Offset, and RZ_MIN.

Referenced by disassemble().

Variable Documentation

◆ buf_global

RzStrBuf* buf_global = NULL
static

Definition at line 19 of file asm_vax.c.

Referenced by disassemble().

◆ bytes

const ut8* bytes = NULL
static

Definition at line 20 of file asm_vax.c.

Referenced by disassemble(), and vax_buffer_read_memory().

◆ bytes_size

int bytes_size = 0
static

Definition at line 21 of file asm_vax.c.

Referenced by disassemble(), print_hex_from_base2(), and vax_buffer_read_memory().

◆ Offset

unsigned long Offset = 0
static

Definition at line 18 of file asm_vax.c.

Referenced by disassemble(), and vax_buffer_read_memory().

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_ASM,
}
RzAsmPlugin rz_asm_plugin_vax
Definition: asm_vax.c:74
@ 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 85 of file asm_vax.c.

◆ rz_asm_plugin_vax

RzAsmPlugin rz_asm_plugin_vax
Initial value:
= {
.name = "vax",
.arch = "vax",
.license = "GPL3",
.bits = 8 | 32,
.desc = "VAX",
.disassemble = &disassemble
}
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_vax.c:46
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526

Definition at line 74 of file asm_vax.c.