Rizin
unix-like reverse engineering framework and cli tools
mcore.h File Reference
#include <stdint.h>
#include <rz_types.h>

Go to the source code of this file.

Classes

struct  mcore_handle
 
struct  mcore_field_t
 
struct  mcore_t
 

Macros

#define ARGS_SIZE   5
 
#define MCORE_CPU_DFLT   0
 
#define MCORE_CPU_510E   1
 
#define MCORE_CPU_610E   2
 
#define MCORE_CPU_620   3
 
#define TYPE_NONE   0
 
#define TYPE_REG   1
 
#define TYPE_IMM   2
 
#define TYPE_MEM   3
 
#define TYPE_JMP   4
 
#define TYPE_JMPI   5
 
#define TYPE_CTRL   6
 

Functions

int mcore_init (mcore_handle *handle, const ut8 *buffer, const ut32 size)
 
mcore_tmcore_next (mcore_handle *handle)
 
void mcore_free (mcore_t *instr)
 
void mcore_snprint (char *str, int size, ut64 addr, mcore_t *instr)
 

Macro Definition Documentation

◆ ARGS_SIZE

#define ARGS_SIZE   5

Definition at line 14 of file mcore.h.

◆ MCORE_CPU_510E

#define MCORE_CPU_510E   1

Definition at line 17 of file mcore.h.

◆ MCORE_CPU_610E

#define MCORE_CPU_610E   2

Definition at line 18 of file mcore.h.

◆ MCORE_CPU_620

#define MCORE_CPU_620   3

Definition at line 19 of file mcore.h.

◆ MCORE_CPU_DFLT

#define MCORE_CPU_DFLT   0

Definition at line 16 of file mcore.h.

◆ TYPE_CTRL

#define TYPE_CTRL   6

Definition at line 27 of file mcore.h.

◆ TYPE_IMM

#define TYPE_IMM   2

Definition at line 23 of file mcore.h.

◆ TYPE_JMP

#define TYPE_JMP   4

Definition at line 25 of file mcore.h.

◆ TYPE_JMPI

#define TYPE_JMPI   5

Definition at line 26 of file mcore.h.

◆ TYPE_MEM

#define TYPE_MEM   3

Definition at line 24 of file mcore.h.

◆ TYPE_NONE

#define TYPE_NONE   0

Definition at line 21 of file mcore.h.

◆ TYPE_REG

#define TYPE_REG   1

Definition at line 22 of file mcore.h.

Function Documentation

◆ mcore_free()

void mcore_free ( mcore_t instr)

Definition at line 432 of file mcore.c.

432  {
433  free(instr);
434 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130

References free().

Referenced by disassemble(), and mcore_analysis().

◆ mcore_init()

int mcore_init ( mcore_handle handle,
const ut8 buffer,
const ut32  size 
)

Definition at line 409 of file mcore.c.

409  {
410  if (!handle || !buffer || size < 2) {
411  return 1;
412  }
413  handle->pos = buffer;
414  handle->end = buffer + size;
415  return 0;
416 }
static mcore_handle handle
Definition: asm_mcore.c:8
struct buffer buffer
voidpf void uLong size
Definition: ioapi.h:138
Definition: buffer.h:15
const ut8 * pos
Definition: mcore.h:31
const ut8 * end
Definition: mcore.h:30

References mcore_handle::end, handle, and mcore_handle::pos.

Referenced by disassemble(), and mcore_analysis().

◆ mcore_next()

mcore_t* mcore_next ( mcore_handle handle)

Definition at line 418 of file mcore.c.

418  {
419  mcore_t *op = NULL;
420  if (!handle || handle->pos + MCORE_INSTR_ALIGN > handle->end) {
421  return NULL;
422  }
423 
424  if (!op && handle->pos + 2 <= handle->end) {
426  }
428 
429  return op;
430 }
ut8 op
Definition: 6502dis.c:13
#define NULL
Definition: cris-opc.c:27
#define MCORE_INSTR_ALIGN
Definition: mcore.c:14
static mcore_t * find_instruction(const ut8 *buffer)
Definition: mcore.c:363
Definition: mcore.h:40
Definition: dis.c:32

References mcore_handle::end, find_instruction(), handle, MCORE_INSTR_ALIGN, NULL, op, and mcore_handle::pos.

Referenced by disassemble(), and mcore_analysis().

◆ mcore_snprint()

void mcore_snprint ( char *  str,
int  size,
ut64  addr,
mcore_t instr 
)

Definition at line 469 of file mcore.c.

469  {
470  ut32 imm;
471  if (!instr || !str) {
472  return;
473  }
474  switch (instr->type) {
477  imm = instr->args[1].value << load_shift[instr->args[3].value];
478  snprintf(str, size, "%s r%u, (r%u, 0x%x)",
479  instr->name, instr->args[2].value, instr->args[0].value, imm);
480  break;
481  default:
482  print_loop(str, size, addr, instr);
483  break;
484  }
485 }
#define imm
uint32_t ut32
snprintf
Definition: kernel.h:364
void print_loop(char *str, int size, ut64 addr, mcore_t *instr)
Definition: mcore.c:436
ut16 load_shift[4]
Definition: mcore.c:93
@ RZ_ANALYSIS_OP_TYPE_LOAD
Definition: rz_analysis.h:416
@ RZ_ANALYSIS_OP_TYPE_STORE
Definition: rz_analysis.h:415
ut32 value
Definition: mcore.h:36
ut64 type
Definition: mcore.h:43
const char * name
Definition: mcore.h:41
mcore_field_t args[ARGS_SIZE]
Definition: mcore.h:42
static int addr
Definition: z80asm.c:58

References addr, mcore_t::args, imm, load_shift, mcore_t::name, print_loop(), RZ_ANALYSIS_OP_TYPE_LOAD, RZ_ANALYSIS_OP_TYPE_STORE, snprintf, cmd_descs_generate::str, mcore_t::type, and mcore_field_t::value.

Referenced by disassemble().