Rizin
unix-like reverse engineering framework and cli tools
asm_amd29k.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2019 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <stdio.h>
5 #include <string.h>
6 #include <rz_types.h>
7 #include <rz_lib.h>
8 #include <rz_asm.h>
9 #include "../arch/amd29k/amd29k.h"
10 
11 static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len) {
12  if (!a || !op || !buf || len < 4) {
13  return -1;
14  }
15  char buf_asm[64];
16  ut64 offset = a->pc;
18  op->size = 4;
19  if (amd29k_instr_decode(buf, len, &instruction, a->cpu)) {
20  amd29k_instr_print(buf_asm, sizeof(buf_asm), offset, &instruction);
21  rz_asm_op_set_asm(op, buf_asm);
22  return 4;
23  }
24  rz_asm_op_set_asm(op, "invalid");
25  return -1;
26 }
27 
29  .name = "amd29k",
30  .license = "LGPL3",
31  .desc = "AMD 29k RISC CPU",
32  .author = "deroad",
33  .arch = CPU_29000 "," CPU_29050,
34  .cpus = "amd29k",
35  .bits = 32,
36  .endian = RZ_SYS_ENDIAN_LITTLE,
37  .disassemble = &disassemble,
38 };
39 
40 #ifndef RZ_PLUGIN_INCORE
43  .data = &rz_asm_plugin_amd29k,
45 };
46 #endif
size_t len
Definition: 6502dis.c:15
bool amd29k_instr_decode(const ut8 *buffer, const ut32 buffer_size, amd29k_instr_t *instruction, const char *cpu)
Definition: amd29k.c:435
void amd29k_instr_print(char *string, int string_size, ut64 address, amd29k_instr_t *instruction)
Definition: amd29k.c:501
#define CPU_29050
Definition: amd29k.h:14
#define CPU_29000
Definition: amd29k.h:13
RZ_API void rz_asm_op_set_asm(RzAsmOp *op, const char *str)
Definition: aop.c:53
RZ_API RzLibStruct rizin_plugin
Definition: asm_amd29k.c:41
static int disassemble(RzAsm *a, RzAsmOp *op, const ut8 *buf, int len)
Definition: asm_amd29k.c:11
RzAsmPlugin rz_asm_plugin_amd29k
Definition: asm_amd29k.c:28
#define RZ_API
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
@ RZ_LIB_TYPE_ASM
Definition: rz_lib.h:72
#define RZ_SYS_ENDIAN_LITTLE
Definition: rz_types.h:526
#define RZ_VERSION
Definition: rz_version.h:8
#define a(i)
Definition: sha256.c:41
const char * name
Definition: rz_asm.h:130
const char * version
Definition: rz_asm.h:133
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()