Rizin
unix-like reverse engineering framework and cli tools
analysis_cr16.c File Reference
#include <string.h>
#include <rz_types.h>
#include <rz_lib.h>
#include <rz_asm.h>
#include <rz_analysis.h>
#include <rz_util.h>
#include <cr16_disas.h>

Go to the source code of this file.

Functions

static int cr16_op (RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
 

Variables

RzAnalysisPlugin rz_analysis_plugin_cr16
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ cr16_op()

static int cr16_op ( RzAnalysis analysis,
RzAnalysisOp op,
ut64  addr,
const ut8 buf,
int  len,
RzAnalysisOpMask  mask 
)
static

Definition at line 14 of file analysis_cr16.c.

15  {
16  int ret;
17  struct cr16_cmd cmd;
18 
19  memset(&cmd, 0, sizeof(cmd));
20 
21  ret = op->size = cr16_decode_command(buf, &cmd, len);
22 
23  if (ret <= 0) {
24  return ret;
25  }
26 
27  op->addr = addr;
28 
29  switch (cmd.type) {
30  case CR16_TYPE_MOV:
32  break;
33  case CR16_TYPE_ADD:
35  break;
36  case CR16_TYPE_MUL:
38  break;
39  case CR16_TYPE_SUB:
41  break;
42  case CR16_TYPE_CMP:
44  break;
45  case CR16_TYPE_BE:
46  case CR16_TYPE_BNE:
48  break;
49  case CR16_TYPE_AND:
51  break;
52  case CR16_TYPE_OR:
53  op->type = RZ_ANALYSIS_OP_TYPE_OR;
54  break;
55  case CR16_TYPE_SCOND:
56  break;
57  case CR16_TYPE_XOR:
59  break;
60  case CR16_TYPE_SHIFT:
62  break;
63  case CR16_TYPE_BIT:
65  break;
66  case CR16_TYPE_SLPR:
68  break;
69  case CR16_TYPE_BCOND:
70  if (cmd.reladdr) {
71  op->jump = addr + cmd.reladdr;
72  op->fail = addr + 2;
73  }
75  break;
76  case CR16_TYPE_BR:
77  case CR16_TYPE_BAL:
79  break;
80  case CR16_TYPE_EXCP:
82  break;
83  case CR16_TYPE_JCOND:
84  case CR16_TYPE_JAL:
85  case CR16_TYPE_JUMP:
86  case CR16_TYPE_JUMP_UNK:
87  if (cmd.reladdr) {
88  op->jump = addr + cmd.reladdr;
89  op->fail = addr + 2;
90  }
92  break;
93  case CR16_TYPE_RETX:
95  break;
96  case CR16_TYPE_PUSH:
98  break;
99  case CR16_TYPE_POP:
100  op->type = RZ_ANALYSIS_OP_TYPE_POP;
101  break;
102  case CR16_TYPE_LOAD:
103  case CR16_TYPE_DI:
104  case CR16_TYPE_EI:
105  case CR16_TYPE_STOR:
106  op->type = RZ_ANALYSIS_OP_TYPE_MOV;
107  break;
108  case CR16_TYPE_NOP:
109  op->type = RZ_ANALYSIS_OP_TYPE_NOP;
110  break;
111  case CR16_TYPE_WAIT:
112  case CR16_TYPE_EWAIT:
113  op->type = RZ_ANALYSIS_OP_TYPE_SWI;
114  break;
115  default:
116  op->type = RZ_ANALYSIS_OP_TYPE_UNK;
117  }
118 
119  return ret;
120 }
size_t len
Definition: 6502dis.c:15
int cr16_decode_command(const ut8 *instr, struct cr16_cmd *cmd, int len)
Definition: cr16_disas.c:1184
@ CR16_TYPE_EI
Definition: cr16_disas.h:39
@ CR16_TYPE_DI
Definition: cr16_disas.h:38
@ CR16_TYPE_JAL
Definition: cr16_disas.h:30
@ CR16_TYPE_BE
Definition: cr16_disas.h:16
@ CR16_TYPE_EXCP
Definition: cr16_disas.h:28
@ CR16_TYPE_BNE
Definition: cr16_disas.h:17
@ CR16_TYPE_JUMP
Definition: cr16_disas.h:31
@ CR16_TYPE_STOR
Definition: cr16_disas.h:37
@ CR16_TYPE_BIT
Definition: cr16_disas.h:23
@ CR16_TYPE_RETX
Definition: cr16_disas.h:33
@ CR16_TYPE_BR
Definition: cr16_disas.h:27
@ CR16_TYPE_MOV
Definition: cr16_disas.h:11
@ CR16_TYPE_SLPR
Definition: cr16_disas.h:24
@ CR16_TYPE_MUL
Definition: cr16_disas.h:13
@ CR16_TYPE_SUB
Definition: cr16_disas.h:14
@ CR16_TYPE_PUSH
Definition: cr16_disas.h:34
@ CR16_TYPE_WAIT
Definition: cr16_disas.h:41
@ CR16_TYPE_POP
Definition: cr16_disas.h:35
@ CR16_TYPE_BAL
Definition: cr16_disas.h:26
@ CR16_TYPE_JUMP_UNK
Definition: cr16_disas.h:32
@ CR16_TYPE_SCOND
Definition: cr16_disas.h:20
@ CR16_TYPE_LOAD
Definition: cr16_disas.h:36
@ CR16_TYPE_OR
Definition: cr16_disas.h:19
@ CR16_TYPE_XOR
Definition: cr16_disas.h:21
@ CR16_TYPE_SHIFT
Definition: cr16_disas.h:22
@ CR16_TYPE_ADD
Definition: cr16_disas.h:12
@ CR16_TYPE_CMP
Definition: cr16_disas.h:15
@ CR16_TYPE_NOP
Definition: cr16_disas.h:40
@ CR16_TYPE_EWAIT
Definition: cr16_disas.h:42
@ CR16_TYPE_BCOND
Definition: cr16_disas.h:25
@ CR16_TYPE_AND
Definition: cr16_disas.h:18
@ CR16_TYPE_JCOND
Definition: cr16_disas.h:29
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 cmd
Definition: sflib.h:79
voidpf void * buf
Definition: ioapi.h:138
return memset(p, 0, total)
@ RZ_ANALYSIS_OP_TYPE_CMP
Definition: rz_analysis.h:399
@ RZ_ANALYSIS_OP_TYPE_SUB
Definition: rz_analysis.h:402
@ RZ_ANALYSIS_OP_TYPE_UNK
Definition: rz_analysis.h:388
@ RZ_ANALYSIS_OP_TYPE_MUL
Definition: rz_analysis.h:404
@ RZ_ANALYSIS_OP_TYPE_JMP
Definition: rz_analysis.h:368
@ RZ_ANALYSIS_OP_TYPE_AND
Definition: rz_analysis.h:411
@ RZ_ANALYSIS_OP_TYPE_UJMP
Definition: rz_analysis.h:369
@ RZ_ANALYSIS_OP_TYPE_SWI
Definition: rz_analysis.h:393
@ RZ_ANALYSIS_OP_TYPE_ADD
Definition: rz_analysis.h:401
@ RZ_ANALYSIS_OP_TYPE_OR
Definition: rz_analysis.h:410
@ RZ_ANALYSIS_OP_TYPE_PUSH
Definition: rz_analysis.h:397
@ RZ_ANALYSIS_OP_TYPE_SHR
Definition: rz_analysis.h:406
@ RZ_ANALYSIS_OP_TYPE_POP
Definition: rz_analysis.h:398
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_MOV
Definition: rz_analysis.h:390
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
@ RZ_ANALYSIS_OP_TYPE_NOP
Definition: rz_analysis.h:389
@ RZ_ANALYSIS_OP_TYPE_XOR
Definition: rz_analysis.h:412
Definition: dis.c:32
static int addr
Definition: z80asm.c:58

References addr, cmd, cr16_decode_command(), CR16_TYPE_ADD, CR16_TYPE_AND, CR16_TYPE_BAL, CR16_TYPE_BCOND, CR16_TYPE_BE, CR16_TYPE_BIT, CR16_TYPE_BNE, CR16_TYPE_BR, CR16_TYPE_CMP, CR16_TYPE_DI, CR16_TYPE_EI, CR16_TYPE_EWAIT, CR16_TYPE_EXCP, CR16_TYPE_JAL, CR16_TYPE_JCOND, CR16_TYPE_JUMP, CR16_TYPE_JUMP_UNK, CR16_TYPE_LOAD, CR16_TYPE_MOV, CR16_TYPE_MUL, CR16_TYPE_NOP, CR16_TYPE_OR, CR16_TYPE_POP, CR16_TYPE_PUSH, CR16_TYPE_RETX, CR16_TYPE_SCOND, CR16_TYPE_SHIFT, CR16_TYPE_SLPR, CR16_TYPE_STOR, CR16_TYPE_SUB, CR16_TYPE_WAIT, CR16_TYPE_XOR, len, memset(), RZ_ANALYSIS_OP_TYPE_ADD, RZ_ANALYSIS_OP_TYPE_AND, RZ_ANALYSIS_OP_TYPE_CJMP, RZ_ANALYSIS_OP_TYPE_CMP, RZ_ANALYSIS_OP_TYPE_JMP, RZ_ANALYSIS_OP_TYPE_MOV, RZ_ANALYSIS_OP_TYPE_MUL, RZ_ANALYSIS_OP_TYPE_NOP, RZ_ANALYSIS_OP_TYPE_OR, RZ_ANALYSIS_OP_TYPE_POP, RZ_ANALYSIS_OP_TYPE_PUSH, RZ_ANALYSIS_OP_TYPE_RET, RZ_ANALYSIS_OP_TYPE_SHR, RZ_ANALYSIS_OP_TYPE_SUB, RZ_ANALYSIS_OP_TYPE_SWI, RZ_ANALYSIS_OP_TYPE_UJMP, RZ_ANALYSIS_OP_TYPE_UNK, and RZ_ANALYSIS_OP_TYPE_XOR.

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
}
RzAnalysisPlugin rz_analysis_plugin_cr16
@ RZ_LIB_TYPE_ANALYSIS
Definition: rz_lib.h:73
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_analysis.h:1239

Definition at line 132 of file analysis_cr16.c.

◆ rz_analysis_plugin_cr16

RzAnalysisPlugin rz_analysis_plugin_cr16
Initial value:
= {
.name = "cr16",
.desc = "CR16 code analysis plugin",
.license = "LGPL3",
.arch = "cr16",
.bits = 16,
.op = cr16_op,
}
static int cr16_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len, RzAnalysisOpMask mask)
Definition: analysis_cr16.c:14

Definition at line 122 of file analysis_cr16.c.