7 #define CHK_SNPRINTF(dst, sz, fmt, ...) \
9 int len_chk_snprintf_ = snprintf(dst, sz, fmt, __VA_ARGS__); \
10 if (len_chk_snprintf_ >= sz) { \
103 index->
type = EBC_INDEX16;
104 index->
sign =
tmp & 0x8000 ? EBC_INDEX_PLUS : EBC_INDEX_MINUS;
113 index->
type = EBC_INDEX32;
123 index->
type = EBC_INDEX64;
141 char op1[32] = { 0 };
155 if ((
bytes[1] & 0x7) != 0) {
157 snprintf(op1,
sizeof(op1),
"%sr%u ",
164 sign = idx32.
sign ?
'+' :
'-';
168 op1, sign, idx32.
n, sign, idx32.
c);
172 "%s0x%x", op1, immed32);
185 char suff[3] = { 0 };
214 sign = idx32.
sign ?
'+' :
'-';
218 op1, sign, idx32.
n, sign, idx32.
c);
230 "r%d(0x%x)", op1, i1);
254 cmd->operands[0] =
'\0';
265 op1 =
bytes[1] & 0x07;
266 op2 = (
bytes[1] >> 4) & 0x07;
272 sign =
idx.sign ?
'+' :
'-';
274 "r%d, @r%d (%c%d, %c%d)",
275 op1, op2, sign,
idx.n, sign,
idx.c);
279 "r%d, r%d %d", op1, op2, immed);
283 "r%d, r%d", op1, op2);
328 char index[32] = { 0 };
334 op1 =
bytes[1] & 0x07;
335 op2 = (
bytes[1] >> 4) & 0x07;
343 snprintf(index, 32,
" (%c%d, %c%d)",
344 idx.sign ?
'+' :
'-',
idx.n,
345 idx.sign ?
'+' :
'-',
idx.c);
370 char index[32] = { 0 };
376 op1 =
bytes[1] & 0x07;
377 op2 = (
bytes[1] >> 4) & 0x07;
384 sign =
idx.sign ?
'+' :
'-';
386 " (%c%d, %c%d)", sign,
idx.n, sign,
idx.c);
389 snprintf(index,
sizeof(index),
"(%u)", immed);
451 char op1c[32], op2c[32];
452 char ind1[32] = { 0 }, ind2[32] = { 0 };
456 op1 =
bytes[1] & 0x07;
457 op2 = (
bytes[1] >> 4) & 0x07;
469 sign =
idx.sign ?
'+' :
'-';
470 snprintf(ind1, 32,
"(%c%u, %c%u)", sign,
476 sign =
idx.sign ?
'+' :
'-';
477 snprintf(ind2, 32,
"(%c%u, %c%u)", sign,
488 sign =
idx.sign ?
'+' :
'-';
489 snprintf(ind1, 32,
"(%c%u, %c%u)", sign,
495 sign =
idx.sign ?
'+' :
'-';
496 snprintf(ind2, 32,
"(%c%u, %c%u)", sign,
504 sign =
idx.sign ?
'+' :
'-';
505 snprintf(ind1, 32,
"(%c%u, %c%u)", sign,
511 sign =
idx.sign ?
'+' :
'-';
512 snprintf(ind1, 32,
"(%c%u, %c%u)", sign,
520 op1c, ind1, op2c, ind2);
534 char op1c[32], op2c[32], sign;
535 char ind1[32] = { 0 }, ind2[32] = { 0 };
537 op1 =
bytes[1] & 0x07;
538 op2 = (
bytes[1] >> 4) & 0x07;
549 sign =
idx.sign ?
'+' :
'-';
551 sign,
idx.n, sign,
idx.c);
556 sign =
idx.sign ?
'+' :
'-';
558 sign,
idx.n, sign,
idx.c);
566 op1c, ind1, op2c, ind2);
582 (
bytes[1] >> 4) & 0x7);
588 unsigned op2 = (
bytes[1] >> 4) & 0x07;
593 op2 < 2 ?
dedic_regs[op2] :
"RESERVED_DEDICATED_REG");
599 unsigned op1 =
bytes[1] & 0x07;
606 snprintf(op1c,
sizeof(op1c),
"%sr%d",
616 sign =
idx.sign ?
'+' :
'-';
619 op1c, sign,
idx.n, sign,
idx.c);
635 unsigned op1 =
bytes[1] & 0x07;
637 char indx[32] = { 0 };
638 char immed[32] = { 0 };
639 char *suff[] = {
"eq",
"lte",
"gte",
"ulte",
"ugte" };
641 snprintf(op1c,
sizeof(op1c) - 1,
"%sr%u",
656 sign =
idx.sign ?
'+' :
'-';
665 snprintf(immed,
sizeof(immed),
"%u", im);
669 snprintf(immed,
sizeof(immed),
"%u", im);
679 unsigned op1 =
bytes[1] & 0x07;
680 unsigned op2 = (
bytes[1] >> 4) & 0x07;
681 char op1c[32], op2c[32];
682 char indx1[32] = { 0 };
683 char indx2[32] = { 0 };
696 sign =
idx.sign ?
'+' :
'-';
702 sign =
idx.sign ?
'+' :
'-';
709 sign =
idx.sign ?
'+' :
'-';
715 sign =
idx.sign ?
'+' :
'-';
728 char indx[32] = { 0 };
730 unsigned long immed = 0;
732 switch (
bytes[0] >> 6) {
733 case 0: ret = -1;
break;
734 case 1: p2 =
'w';
break;
735 case 2: p2 =
'd';
break;
736 case 3: p2 =
'q';
break;
743 switch ((
bytes[1] >> 4) & 0x3) {
744 case 0: p1 =
'b';
break;
745 case 1: p1 =
'w';
break;
746 case 2: p1 =
'd';
break;
747 case 3: p1 =
'q';
break;
758 sign =
idx.sign ?
'+' :
'-';
771 immed = (
unsigned long)i1;
776 immed = (
unsigned long)
i2;
794 char indx1[32] = { 0 };
795 char indx2[32] = { 0 };
800 switch (
bytes[0] >> 6) {
801 case 0: ret = -1;
break;
802 case 1: p1 =
'w';
break;
803 case 2: p1 =
'd';
break;
804 case 3: p1 =
'q';
break;
817 sign =
idx.sign ?
'+' :
'-';
819 snprintf(indx1, 32,
"(%c%u, %c%u)", sign,
840 sign =
idx.sign ?
'+' :
'-';
853 char indx[32] = { 0 };
854 unsigned long immed = 0;
855 unsigned formathex = 0;
857 switch (
bytes[0] >> 6) {
888 sign =
idx.sign ?
'+' :
'-';
917 op1,
indx, formathex, immed);
int bits(struct state *s, int need)
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
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 long
static int decode_sub(const ut8 *bytes, ebc_command_t *cmd)
static int decode_movrel(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmpulte(const ut8 *bytes, ebc_command_t *cmd)
static int decode_break(const ut8 *bytes, ebc_command_t *cmd)
static int decode_jmp(const ut8 *bytes, ebc_command_t *cmd)
static int decode_call(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmpugte(const ut8 *bytes, ebc_command_t *cmd)
static int decode_storesp(const ut8 *bytes, ebc_command_t *cmd)
static int decode_index64(const ut8 *data, ebc_index_t *index)
static int decode_div(const ut8 *bytes, ebc_command_t *cmd)
struct ebc_index ebc_index_t
static int decode_mov_args(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmpgte(const ut8 *bytes, ebc_command_t *cmd)
static const char * dedic_regs[]
static int decode_movi(const ut8 *bytes, ebc_command_t *cmd)
static int decode_jmp8(const ut8 *bytes, ebc_command_t *cmd)
static int decode_movsn(const ut8 *bytes, ebc_command_t *cmd)
#define CHK_SNPRINTF(dst, sz, fmt,...)
static int decode_movin(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmplte(const ut8 *bytes, ebc_command_t *cmd)
static int decode_mov(const ut8 *bytes, ebc_command_t *cmd)
static int decode_mulu(const ut8 *bytes, ebc_command_t *cmd)
static int decode_add(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmpeq(const ut8 *bytes, ebc_command_t *cmd)
static int decode_neg(const ut8 *bytes, ebc_command_t *cmd)
static int decode_movn(const ut8 *bytes, ebc_command_t *cmd)
static const char * instr_names[]
static int decode_mul(const ut8 *bytes, ebc_command_t *cmd)
static int decode_index32(const ut8 *data, ebc_index_t *index)
static int decode_push_pop(const ut8 *bytes, ebc_command_t *cmd)
static int decode_index16(const ut8 *data, ebc_index_t *index)
int ebc_decode_command(const ut8 *instr, ebc_command_t *cmd)
static int decode_ret(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmp(const ut8 *bytes, ebc_command_t *cmd)
static int decode_divu(const ut8 *bytes, ebc_command_t *cmd)
int(* decode)(const ut8 *, ebc_command_t *cmd)
static int decode_arith(const ut8 *bytes, ebc_command_t *cmd)
static int decode_not(const ut8 *bytes, ebc_command_t *cmd)
static int decode_cmpi(const ut8 *bytes, ebc_command_t *cmd)
static int decode_movsn_args(const ut8 *bytes, ebc_command_t *cmd)
static int decode_invalid(const ut8 *bytes, ebc_command_t *cmd)
static int decode_loadsp(const ut8 *bytes, ebc_command_t *cmd)
static decode decodes[EBC_COMMAND_NUM]
#define EBC_N_BIT_MASK(n)
#define EBC_OPERANDS_MAXLEN
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int indx(const char **ptr, const char **list, int error, const char **expr)