Rizin
unix-like reverse engineering framework and cli tools
c55plus.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2013 th0rpe <josediazfer@yahoo.es>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <ctype.h>
8 #include <rz_types.h>
9 #include <rz_lib.h>
10 #include <rz_asm.h>
11 
12 #define USE_DECODE
13 #include "decode.h"
14 
15 #include "../tms320_dasm.h"
16 
17 extern ut8 *ins_buff;
18 extern ut32 ins_buff_len;
19 extern char *c55plus_decode(ut32 ins_pos, ut32 *next_ins_pos);
20 
21 int c55x_plus_disassemble(tms320_dasm_t *dasm, const ut8 *buf, int len) {
22  unsigned int next_ins_pos;
23  char *ins_decoded;
24  size_t i, ins_decoded_len;
25 
26  ins_buff = (ut8 *)buf;
28 
29  next_ins_pos = 0;
30 
31  // decode instruction
32  ins_decoded = c55plus_decode(0, &next_ins_pos);
33  dasm->length = next_ins_pos;
34  if (!ins_decoded) {
35  return 0;
36  }
37 
38  // opcode length
39  dasm->length = next_ins_pos;
40  ins_decoded_len = strlen(ins_decoded);
41  for (i = 0; i < ins_decoded_len; i++) {
42  {
43  ins_decoded[i] = tolower((unsigned char)ins_decoded[i]);
44  }
45  }
46  snprintf(dasm->syntax, sizeof(dasm->syntax), "%s", ins_decoded);
47  free(ins_decoded);
48 
49  return next_ins_pos;
50 }
size_t len
Definition: 6502dis.c:15
lzma_index ** i
Definition: index.h:629
ut8 * ins_buff
Definition: ins.c:6
ut32 ins_buff_len
Definition: ins.c:7
char * c55plus_decode(ut32 ins_pos, ut32 *next_ins_pos)
int c55x_plus_disassemble(tms320_dasm_t *dasm, const ut8 *buf, int len)
Definition: c55plus.c:21
uint32_t ut32
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
uint8_t ut8
Definition: lh5801.h:11
#define tolower(c)
Definition: safe-ctype.h:149
char syntax[1024]
Definition: tms320_dasm.h:127