Rizin
unix-like reverse engineering framework and cli tools
ins.c File Reference
#include "ins.h"

Go to the source code of this file.

Functions

ut32 get_ins_len (ut8 opcode)
 
ut32 get_ins_part (ut32 pos, ut32 len)
 

Variables

ut8ins_buff = (ut8 *)NULL
 
ut32 ins_buff_len = 0
 
static unsigned int has_failed = 0
 
char * ins_str []
 

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().

◆ get_ins_part()

ut32 get_ins_part ( ut32  pos,
ut32  len 
)

Definition at line 51 of file ins.c.

51  {
52  ut32 ret = 0;
53  has_failed = 0;
54  if (C55PLUS_DEBUG) {
55  printf("pos => 0x%x len => %d ins_buff_len => %d\n", pos, len, ins_buff_len);
56  }
57 
58  if ((st32)pos < 0 || pos >= ins_buff_len) {
59  has_failed = 1;
60  return ret;
61  }
62 
63  for (; len > 0; len--) {
64  ret <<= 8;
65  if (pos >= ins_buff_len) {
66  has_failed = 1;
67  } else {
68  ret |= ins_buff[pos++];
69  }
70  }
71 
72  return ret;
73 }
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
ut8 * ins_buff
Definition: ins.c:6
ut32 ins_buff_len
Definition: ins.c:7
static unsigned int has_failed
Definition: ins.c:9
#define C55PLUS_DEBUG
Definition: utils.h:8
#define st32
Definition: rz_types_base.h:12
int pos
Definition: main.c:11

References C55PLUS_DEBUG, has_failed, ins_buff, ins_buff_len, len, pos, printf(), and st32.

Referenced by c55plus_decode(), decode_ins(), do_decode(), get_AR_regs_class2(), get_hash_code(), and get_ins_bits().

Variable Documentation

◆ has_failed

unsigned int has_failed = 0
static

Definition at line 9 of file ins.c.

Referenced by get_ins_part().

◆ ins_buff

ut8* ins_buff = (ut8 *)NULL

Definition at line 6 of file ins.c.

Referenced by c55x_plus_disassemble(), and get_ins_part().

◆ ins_buff_len

ut32 ins_buff_len = 0

Definition at line 7 of file ins.c.

Referenced by c55plus_decode(), c55x_plus_disassemble(), and get_ins_part().

◆ ins_str

char* ins_str[]

Definition at line 76 of file ins.c.

Referenced by decode_ins(), and get_ins_bits().