18 #define get_bits(av, af, an) (((av) >> (af)) & ((2 << (an - 1)) - 1))
23 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
25 value = (pv[0] << 8) | pv[1];
32 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
34 value = (pv[0] << 16) | (pv[1] << 8) | pv[2];
283 printf(
"TODO: unknown opcode flag %02x\n", flag->
v);
308 int vreplace(
char *
string,
const char *token,
const char *fmt, va_list
args) {
312 pos = strstr(
string, token);
319 memmove(
pos + strlen(data),
pos + strlen(token), strlen(
pos + strlen(token)) + 1);
320 memmove(
pos, data, strlen(data));
325 int replace(
char *
string,
const char *token,
const char *fmt, ...) {
336 void substitute(
char *
string,
const char *token,
const char *fmt, ...) {
348 static const char *table[16] = {
367 return table[
key & 15];
371 static const char *table[16] = {
390 return table[
key & 15];
395 case 0:
return "swap ac0, ac2";
396 case 1:
return "swap ac1, ac3";
397 case 4:
return "swap t0, t2";
398 case 5:
return "swap t1, t3";
399 case 8:
return "swap ar0, ar2";
400 case 9:
return "swap ar1, ar3";
401 case 12:
return "swap ar4, t0";
402 case 13:
return "swap ar5, t1";
403 case 14:
return "swap ar6, t2";
404 case 15:
return "swap ar7, t3";
405 case 16:
return "swapp ac0, ac2";
406 case 20:
return "swapp t0, t2";
407 case 24:
return "swapp ar0, ar2";
408 case 28:
return "swapp ar4, t0";
409 case 30:
return "swapp ar6, t2";
410 case 44:
return "swap4 ar4, t0";
411 case 56:
return "swap ar0, ar1";
418 static const char *table[] = {
419 "==",
"<",
">=",
"!="
422 return table[
key & 3];
427 if ((
key >> 4) <= 5) {
428 static const char *
op[6] = {
"==",
"!=",
"<",
"<=",
">",
">=" };
434 if ((
key >> 2) == 0x18) {
440 if ((
key >> 2) == 0x1C) {
446 case 0x64:
return "tc1";
447 case 0x65:
return "tc2";
448 case 0x66:
return "carry";
449 case 0x74:
return "!tc1";
450 case 0x75:
return "!tc2";
454 case 0x68:
return "tc1 & tc2";
455 case 0x69:
return "tc1 & !tc2";
456 case 0x6A:
return "!tc1 & tc2";
458 return "!tc1 & !tc2";
460 case 0x78:
return "tc1 | tc2";
461 case 0x79:
return "tc1 | !tc2";
462 case 0x7A:
return "!tc1 | tc2";
464 return "!tc1 | !tc2";
466 case 0x7C:
return "tc1 ^ tc2";
467 case 0x7D:
return "tc1 ^ !tc2";
468 case 0x7E:
return "!tc1 ^ tc2";
469 case 0x7F:
return "!tc1 ^ !tc2";
476 static const char *table[2] = {
481 return table[
key & 1];
485 static const char *table[2] = {
490 return table[
key & 1];
494 static const char *table[4] = {
501 return table[
key & 3];
507 if ((
key & 0x01) == 0) {
508 #ifdef IDA_COMPATIBLE_MODE
519 case 0x11:
return "abs16(k16)";
520 case 0x31:
return "*(k23)";
521 case 0x51:
return "port(k16)";
522 case 0x71:
return "*cdp";
523 case 0x91:
return "*cdp+";
524 case 0xB1:
return "*cdp-";
525 case 0xD1:
return "*cdp(K16)";
526 case 0xF1:
return "*+cdp(K16)";
529 switch (
key & 0x1F) {
530 case 0x01:
return "*ARn";
531 case 0x03:
return "*ARn+";
538 return "*(ARn + t0)";
543 return "*(ARn - t0)";
547 case 0x0B:
return "*ARn(t0)";
548 case 0x0D:
return "*ARn(k16)";
555 return "*(ARn + t1)";
560 return "*(ARn - t1)";
580 return "*(ARn + t0b)";
584 case 0x1F:
return "*(ARn - t0b)";
593 case 0x00:
return "*ARn";
594 case 0x01:
return "*ARn+";
600 case 0x03:
return "*(ARn + t0)";
602 return "*(ARn + t1)";
606 case 0x05:
return "*(ARn - t0)";
608 return "*(ARn - t1)";
612 case 0x07:
return "*ARn(t0)";
645 pos = strstr(dasm->
syntax,
"[(saturate]");
668 bool parallel = !!strstr(dasm->
syntax,
"::");
982 if (strstr(
tmp,
"k16")) {
985 }
else if (strstr(
tmp,
"k23")) {
988 }
else if (strstr(
tmp,
"K16")) {
1107 while (e_list && (e_list[0] && e_list[1])) {
1108 if ((dasm->
opcode & e_list[0]) == e_list[1]) {
1109 dasm->
head = ht_up_find(dasm->
map, e_list[1],
NULL);
1125 strcpy(dasm->
syntax,
"invalid");
1131 memset(&dasm->
f, 0,
sizeof(dasm->
f));
1138 int qualifier_size = 0;
1147 return dasm->
length + qualifier_size;
1167 if (strstr(dasm->
syntax,
"invalid")) {
1189 dasm->
map = ht_up_new0();
1205 ht_up_free(dasm->
map);
int c55x_plus_disassemble(tms320_dasm_t *dasm, const ut8 *buf, int len)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
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 static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static ut32 rz_read_be24(const void *src)
static ut16 rz_read_be16(const void *src)
struct tms320_dasm_t::@115 f
static insn_head_t c55x_list[]
static void init_dasm(tms320_dasm_t *dasm, const ut8 *stream, int len)
int tms320_dasm_fini(tms320_dasm_t *dasm)
const char * get_swap_str(ut8 key, char *str)
const char * get_xreg_str(ut8 key, char *str)
int replace(char *string, const char *token, const char *fmt,...)
void decode_relop(tms320_dasm_t *dasm)
const char * get_cmem_str(ut8 key, char *str)
void decode_braces(tms320_dasm_t *dasm)
#define get_bits(av, af, an)
void decode_registers(tms320_dasm_t *dasm)
void decode_bits(tms320_dasm_t *dasm)
int run_m_list(tms320_dasm_t *dasm)
const char * get_smem_str(ut8 key, char *str)
int run_f_list(tms320_dasm_t *dasm)
static insn_item_t * finalize(tms320_dasm_t *dasm)
const char * get_relop_str(ut8 key, char *str)
int tms320_dasm_init(tms320_dasm_t *dasm)
int tms320_dasm(tms320_dasm_t *dasm, const ut8 *stream, int len)
void decode_constants(tms320_dasm_t *dasm)
void decode_swap(tms320_dasm_t *dasm)
insn_item_t * decode_insn_head(tms320_dasm_t *dasm)
const char * get_mmm_str(ut8 key, char *str)
const char * get_t_str(ut8 key, char *str)
void substitute(char *string, const char *token, const char *fmt,...)
const char * get_v_str(ut8 key, char *str)
void decode_addressing_modes(tms320_dasm_t *dasm)
void decode_qualifiers(tms320_dasm_t *dasm)
int vreplace(char *string, const char *token, const char *fmt, va_list args)
const char * get_freg_str(ut8 key, char *str)
void decode_cond(tms320_dasm_t *dasm)
insn_item_t * decode_insn(tms320_dasm_t *dasm)
void decode_addresses(tms320_dasm_t *dasm)
insn_head_t * lookup_insn_head(tms320_dasm_t *dasm)
static int full_insn_size(tms320_dasm_t *dasm)
const char * get_cond_str(ut8 key, char *str)
#define tms320_f_set_cpu(d, v)
#define TMS320_F_CPU_C55X_PLUS
#define field_valid(d, name)
#define set_field_value(d, name, value)
#define tms320_f_get_cpu(d)
#define TMS320_F_CPU_C55X
static const z80_opcode dd[]