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

Go to the source code of this file.

Functions

ut32 get_ins_len (ut8 opcode)
 
int tms320_c55x_plus_op (RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *buf, int len)
 

Function Documentation

◆ get_ins_len()

ut32 get_ins_len ( ut8  opcode)

Definition at line 11 of file ins.c.

11  {
12  ut32 val = (opcode >> 4) & 0xF;
13  ut32 len = 0;
14 
15  switch (val) {
16  case 0:
17  case 1:
18  len = 2;
19  break;
20  case 2:
21  case 3:
22  len = 1;
23  break;
24  case 4:
25  case 5:
26  case 6:
27  case 7:
28  len = 3;
29  break;
30  case 8:
31  case 9:
32  case 10:
33  len = 4;
34  break;
35  case 11:
36  case 12:
37  case 13:
38  len = 5;
39  break;
40  case 14:
41  len = 6;
42  break;
43  case 15:
44  len = 7;
45  break;
46  }
47 
48  return len;
49 }
size_t len
Definition: 6502dis.c:15
ut16 val
Definition: armass64_const.h:6
uint32_t ut32

References len, and val.

Referenced by decode_ins(), get_hash_code(), and tms320_c55x_plus_op().

◆ tms320_c55x_plus_op()

int tms320_c55x_plus_op ( RzAnalysis analysis,
RzAnalysisOp op,
ut64  addr,
const ut8 buf,
int  len 
)

Definition at line 12 of file analysis_tms320_c55x_plus.c.

12  {
13  ut16 *ins = (ut16 *)buf;
14  ut32 ins_len;
15 
16  if (!buf || len <= 0) {
17  return 0;
18  }
19 
20  ins_len = get_ins_len(buf[0]);
21  if (ins_len == 0) {
22  return 0;
23  }
24 
25  op->addr = addr;
26  op->size = ins_len;
27 
28  if (ins_len == 1) {
29  if (*ins == 0x20) {
31  } else if (*ins == 0x21) {
33  }
34  } else if (ins_len >= 4 && buf[0] == 0xD8) {
35  // BCC conditional absolute jump
37  op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
38  } else if (ins_len >= 2 && buf[0] == 0x6A) {
39  // BCC conditional relative jump
41  op->jump = addr + ((st8)buf[1]) + ins_len;
42  } else if (ins_len >= 3 && buf[0] == 0x9A) {
43  // BCC conditional relative jump
45  op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
46  } else if (ins_len >= 4 && buf[0] == 0x9C) {
47  // B unconditional absolute jump
49  op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
50  } else if (ins_len >= 3 && buf[0] == 0x68) {
51  // B unconditional relative jump
53  op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
54  } else if (ins_len == 2 && buf[0] == 0x02) {
55  // CALL unconditional absolute call with acumulator register ACx
56 
58  op->fail = addr + ins_len;
59  } else if (ins_len >= 3 && buf[0] == 0x69) {
60  // CALL unconditional relative call
62  op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
63  } else if (ins_len >= 3 && buf[0] == 0x9D) {
64  // CALL unconditional absolute call
66  op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
67  } else if (ins_len >= 3 && buf[0] == 0x9B) {
68  // CALLCC conditional relative call
70  op->jump = addr + (st16)((buf[1] << 8) | buf[2]) + ins_len;
71  } else if (ins_len >= 4 && buf[0] == 0xD9) {
72  // CALLCC conditional absolute call
74  op->jump = (buf[1] << 16) | (buf[2] << 8) | buf[3];
75  } else {
77  }
78  return op->size;
79 }
ut32 get_ins_len(ut8 opcode)
Definition: ins.c:11
uint16_t ut16
voidpf void * buf
Definition: ioapi.h:138
@ RZ_ANALYSIS_OP_TYPE_UNK
Definition: rz_analysis.h:388
@ RZ_ANALYSIS_OP_TYPE_JMP
Definition: rz_analysis.h:368
@ RZ_ANALYSIS_OP_TYPE_CALL
Definition: rz_analysis.h:378
@ RZ_ANALYSIS_OP_TYPE_CJMP
Definition: rz_analysis.h:373
@ RZ_ANALYSIS_OP_TYPE_UCALL
Definition: rz_analysis.h:379
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
@ RZ_ANALYSIS_OP_TYPE_NOP
Definition: rz_analysis.h:389
#define st8
Definition: rz_types_base.h:16
#define st16
Definition: rz_types_base.h:14
Definition: dis.c:32
static int addr
Definition: z80asm.c:58

References addr, get_ins_len(), len, RZ_ANALYSIS_OP_TYPE_CALL, RZ_ANALYSIS_OP_TYPE_CJMP, RZ_ANALYSIS_OP_TYPE_JMP, RZ_ANALYSIS_OP_TYPE_NOP, RZ_ANALYSIS_OP_TYPE_RET, RZ_ANALYSIS_OP_TYPE_UCALL, RZ_ANALYSIS_OP_TYPE_UNK, st16, and st8.

Referenced by tms320_op().