Rizin
unix-like reverse engineering framework and cli tools
ebc_disas.c File Reference
#include "ebc_disas.h"
#include <rz_types.h>

Go to the source code of this file.

Classes

struct  ebc_index
 

Macros

#define CHK_SNPRINTF(dst, sz, fmt, ...)
 

Typedefs

typedef int(* decode) (const ut8 *, ebc_command_t *cmd)
 
typedef struct ebc_index ebc_index_t
 

Functions

static int decode_index16 (const ut8 *data, ebc_index_t *index)
 
static int decode_index32 (const ut8 *data, ebc_index_t *index)
 
static int decode_index64 (const ut8 *data, ebc_index_t *index)
 
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_jmp8 (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_call (const ut8 *bytes, 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_cmpeq (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_cmplte (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_cmpgte (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_cmpulte (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_cmpugte (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_not (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_neg (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_add (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_sub (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_mul (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_mulu (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_div (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_divu (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_arith (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_mov_args (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_mov (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_movsn_args (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_movsn (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_loadsp (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_storesp (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_push_pop (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_cmpi (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_movn (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_movi (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_movin (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_movrel (const ut8 *bytes, ebc_command_t *cmd)
 
static int decode_invalid (const ut8 *bytes, ebc_command_t *cmd)
 
int ebc_decode_command (const ut8 *instr, ebc_command_t *cmd)
 

Variables

static const char * instr_names []
 
static const char * dedic_regs []
 
static decode decodes [EBC_COMMAND_NUM]
 

Macro Definition Documentation

◆ CHK_SNPRINTF

#define CHK_SNPRINTF (   dst,
  sz,
  fmt,
  ... 
)
Value:
do { \
int len_chk_snprintf_ = snprintf(dst, sz, fmt, __VA_ARGS__); \
if (len_chk_snprintf_ >= sz) { \
return -1; \
} \
} while (0)
snprintf
Definition: kernel.h:364
char * dst
Definition: lz4.h:724

Definition at line 7 of file ebc_disas.c.

Typedef Documentation

◆ decode

typedef int(* decode) (const ut8 *, ebc_command_t *cmd)

Definition at line 88 of file ebc_disas.c.

◆ ebc_index_t

typedef struct ebc_index ebc_index_t

Function Documentation

◆ decode_add()

static int decode_add ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 365 of file ebc_disas.c.

365  {
366  char sign;
367  int ret = 2;
368  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
369  unsigned op1, op2;
370  char index[32] = { 0 };
371  ut16 immed;
372 
373  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u", instr_names[EBC_ADD],
374  bits);
375 
376  op1 = bytes[1] & 0x07;
377  op2 = (bytes[1] >> 4) & 0x07;
378 
379  if (TEST_BIT(bytes[0], 7)) {
380  ret = 4;
381  if (TEST_BIT(bytes[1], 7)) {
383  decode_index16(bytes + 2, &idx);
384  sign = idx.sign ? '+' : '-';
385  snprintf(index, sizeof(index),
386  " (%c%d, %c%d)", sign, idx.n, sign, idx.c);
387  } else {
388  immed = *(ut16 *)&bytes[2];
389  snprintf(index, sizeof(index), "(%u)", immed);
390  }
391  }
392 
393  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%sr%d, %sr%d%s",
394  TEST_BIT(bytes[1], 3) ? "@" : "", op1,
395  TEST_BIT(bytes[1], 7) ? "@" : "", op2, index);
396  return ret;
397 }
static ut8 bytes[32]
Definition: asm_arc.c:23
int bits(struct state *s, int need)
Definition: blast.c:72
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
Definition: sflib.h:79
uint16_t ut16
#define CHK_SNPRINTF(dst, sz, fmt,...)
Definition: ebc_disas.c:7
static const char * instr_names[]
Definition: ebc_disas.c:15
static int decode_index16(const ut8 *data, ebc_index_t *index)
Definition: ebc_disas.c:101
#define EBC_INSTR_MAXLEN
Definition: ebc_disas.h:20
#define EBC_OPERANDS_MAXLEN
Definition: ebc_disas.h:21
@ EBC_ADD
Definition: ebc_disas.h:42
#define TEST_BIT(x, n)
Definition: ebc_disas.h:27
int idx
Definition: setup.py:197

References bits(), bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_ADD, EBC_INSTR_MAXLEN, EBC_OPERANDS_MAXLEN, setup::idx, instr_names, snprintf, and TEST_BIT.

Referenced by decode_arith(), decode_div(), decode_divu(), decode_mul(), decode_mulu(), and decode_sub().

◆ decode_arith()

static int decode_arith ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 440 of file ebc_disas.c.

440  {
441  int ret = decode_add(bytes, cmd);
442  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
443  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
445  return ret;
446 }
static int decode_add(const ut8 *bytes, ebc_command_t *cmd)
Definition: ebc_disas.c:365
#define EBC_OPCODE_MASK
Definition: ebc_disas.h:9

References bits(), bytes, cmd, decode_add(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, instr_names, snprintf, and TEST_BIT.

◆ decode_break()

static int decode_break ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 131 of file ebc_disas.c.

131  {
133  snprintf(cmd->operands, EBC_OPERANDS_MAXLEN, "%d", bytes[1]);
134  return 2;
135 }
@ EBC_BREAK
Definition: ebc_disas.h:30

References bytes, cmd, EBC_BREAK, EBC_INSTR_MAXLEN, EBC_OPERANDS_MAXLEN, instr_names, and snprintf.

◆ decode_call()

static int decode_call ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 196 of file ebc_disas.c.

196  {
197  int ret;
198  short bits = 32;
199  ut8 op1 = bytes[1] & 0x7;
200  ut32 i1;
201  unsigned long i2;
202  ebc_index_t idx32;
203  char sign;
204 
205  if (!TEST_BIT(bytes[0], 6)) {
206  // CALL32
207  bits = 32;
208  ret = 2;
209  if (TEST_BIT(bytes[1], 3)) {
210  // operand 1 indirect
211  if (TEST_BIT(bytes[0], 7)) {
212  // immediate data is present
213  decode_index32(bytes + 2, &idx32);
214  sign = idx32.sign ? '+' : '-';
215 
217  "@r%d(%c%u, %c%u)",
218  op1, sign, idx32.n, sign, idx32.c);
219  ret = 6;
220  } else {
221  snprintf(cmd->operands, EBC_OPERANDS_MAXLEN,
222  "@r%d", op1);
223  }
224  } else {
225  // operand 1 direct
226  if (TEST_BIT(bytes[0], 7)) {
227  // immediate data present
228  i1 = *(ut32 *)(bytes + 2);
230  "r%d(0x%x)", op1, i1);
231  ret = 6;
232  } else {
233  // no immediate data present
235  "r%d", op1);
236  }
237  }
238  } else {
239  bits = 64;
240  ret = 10;
241  i2 = *(ut64 *)&bytes[2];
242  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "0x%lx", i2);
243  }
244  CHK_SNPRINTF(cmd->instr, EBC_INSTR_MAXLEN, "%s%d%s%s",
246  TEST_BIT(bytes[1], 5) ? "ex" : "",
247  TEST_BIT(bytes[1], 4) ? "" : "a");
248  return ret;
249 }
uint32_t ut32
static int decode_index32(const ut8 *data, ebc_index_t *index)
Definition: ebc_disas.c:111
@ EBC_CALL
Definition: ebc_disas.h:33
uint8_t ut8
Definition: lh5801.h:11
ut32 c
Definition: ebc_disas.c:97
enum ebc_index::@65 sign
ut32 n
Definition: ebc_disas.c:98
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References bits(), bytes, ebc_index::c, CHK_SNPRINTF, cmd, decode_index32(), EBC_CALL, EBC_INSTR_MAXLEN, EBC_OPERANDS_MAXLEN, i2, instr_names, ebc_index::n, ebc_index::sign, snprintf, TEST_BIT, and ut64().

◆ decode_cmp()

static int decode_cmp ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 258 of file ebc_disas.c.

258  {
259  int ret = 2;
260  int op1, op2;
261  char sign;
262  ut16 immed;
264 
265  op1 = bytes[1] & 0x07;
266  op2 = (bytes[1] >> 4) & 0x07;
267 
268  if (TEST_BIT(bytes[0], 7)) {
269  ret += 2;
270  if (TEST_BIT(bytes[1], 7)) {
271  decode_index16(bytes + 2, &idx);
272  sign = idx.sign ? '+' : '-';
274  "r%d, @r%d (%c%d, %c%d)",
275  op1, op2, sign, idx.n, sign, idx.c);
276  } else {
277  immed = *(ut16 *)&bytes[2];
279  "r%d, r%d %d", op1, op2, immed);
280  }
281  } else {
283  "r%d, r%d", op1, op2);
284  }
285 
286  return ret;
287 }

References bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_OPERANDS_MAXLEN, setup::idx, and TEST_BIT.

Referenced by decode_cmpeq(), decode_cmpgte(), decode_cmplte(), decode_cmpugte(), and decode_cmpulte().

◆ decode_cmpeq()

static int decode_cmpeq ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 289 of file ebc_disas.c.

289  {
290  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
291  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%deq",
293  return decode_cmp(bytes, cmd);
294 }
static int decode_cmp(const ut8 *bytes, ebc_command_t *cmd)
Definition: ebc_disas.c:258
@ EBC_CMPLTE
Definition: ebc_disas.h:36

References bits(), bytes, cmd, decode_cmp(), EBC_CMPLTE, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_cmpgte()

static int decode_cmpgte ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 303 of file ebc_disas.c.

303  {
304  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
305  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%dgte",
307  return decode_cmp(bytes, cmd);
308 }
@ EBC_CMPGTE
Definition: ebc_disas.h:37

References bits(), bytes, cmd, decode_cmp(), EBC_CMPGTE, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_cmpi()

static int decode_cmpi ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 633 of file ebc_disas.c.

633  {
634  int ret = 2;
635  unsigned op1 = bytes[1] & 0x07;
636  char op1c[32];
637  char indx[32] = { 0 };
638  char immed[32] = { 0 };
639  char *suff[] = { "eq", "lte", "gte", "ulte", "ugte" };
640 
641  snprintf(op1c, sizeof(op1c) - 1, "%sr%u",
642  TEST_BIT(bytes[1], 3) ? "@" : "", op1);
643 
644  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u%c%s",
646  TEST_BIT(bytes[0], 6) ? 64 : 32,
647  TEST_BIT(bytes[0], 7) ? 'd' : 'w',
648  suff[(bytes[0] & EBC_OPCODE_MASK) - EBC_CMPIEQ]);
649 
650  if (TEST_BIT(bytes[1], 4)) {
651  char sign;
653 
654  decode_index16(bytes + 2, &idx);
655 
656  sign = idx.sign ? '+' : '-';
657 
658  snprintf(indx, sizeof(indx), " (%c%u, %c%u)", sign, idx.n, sign, idx.c);
659 
660  ret += 2;
661  }
662 
663  if (TEST_BIT(bytes[0], 7)) {
664  ut32 im = *(ut32 *)(bytes + ret);
665  snprintf(immed, sizeof(immed), "%u", im);
666  ret += 4;
667  } else {
668  ut16 im = *(ut16 *)(bytes + ret);
669  snprintf(immed, sizeof(immed), "%u", im);
670  ret += 2;
671  }
672 
673  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, %s", op1c, indx, immed);
674  return ret;
675 }
@ EBC_CMPIEQ
Definition: ebc_disas.h:75
static int indx(const char **ptr, const char **list, int error, const char **expr)
Definition: z80asm.c:154

References bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_CMPIEQ, EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, indx(), instr_names, snprintf, and TEST_BIT.

◆ decode_cmplte()

static int decode_cmplte ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 296 of file ebc_disas.c.

296  {
297  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
298  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%dlte",
300  return decode_cmp(bytes, cmd);
301 }

References bits(), bytes, cmd, decode_cmp(), EBC_CMPLTE, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_cmpugte()

static int decode_cmpugte ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 317 of file ebc_disas.c.

317  {
318  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
319  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%dugte",
321  return decode_cmp(bytes, cmd);
322 }
@ EBC_CMPUGTE
Definition: ebc_disas.h:39

References bits(), bytes, cmd, decode_cmp(), EBC_CMPUGTE, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_cmpulte()

static int decode_cmpulte ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 310 of file ebc_disas.c.

310  {
311  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
312  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%dulte",
314  return decode_cmp(bytes, cmd);
315 }
@ EBC_CMPULTE
Definition: ebc_disas.h:38

References bits(), bytes, cmd, decode_cmp(), EBC_CMPULTE, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_div()

static int decode_div ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 424 of file ebc_disas.c.

424  {
425  int ret = decode_add(bytes, cmd);
426  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
427  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
429  return ret;
430 }
@ EBC_DIV
Definition: ebc_disas.h:46

References bits(), bytes, cmd, decode_add(), EBC_DIV, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_divu()

static int decode_divu ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 432 of file ebc_disas.c.

432  {
433  int ret = decode_add(bytes, cmd);
434  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
435  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
437  return ret;
438 }
@ EBC_DIVU
Definition: ebc_disas.h:47

References bits(), bytes, cmd, decode_add(), EBC_DIVU, EBC_INSTR_MAXLEN, instr_names, snprintf, and TEST_BIT.

◆ decode_index16()

static int decode_index16 ( const ut8 data,
ebc_index_t index 
)
static

Definition at line 101 of file ebc_disas.c.

101  {
102  ut16 tmp = *(ut16 *)data;
103  index->type = EBC_INDEX16;
104  index->sign = tmp & 0x8000 ? EBC_INDEX_PLUS : EBC_INDEX_MINUS;
105  index->a_width = ((tmp >> 12) & EBC_N_BIT_MASK(2)) * 2;
106  index->n = tmp & EBC_N_BIT_MASK(index->a_width);
107  index->c = (tmp >> index->a_width) & EBC_N_BIT_MASK(12 - index->a_width);
108  return 0;
109 }
#define EBC_N_BIT_MASK(n)
Definition: ebc_disas.h:24
enum ebc_index::@64 type
ut8 a_width
Definition: ebc_disas.c:96

References ebc_index::a_width, ebc_index::c, EBC_N_BIT_MASK, ebc_index::n, ebc_index::sign, autogen_x86imm::tmp, and ebc_index::type.

Referenced by decode_add(), decode_cmp(), decode_cmpi(), decode_mov_args(), decode_movi(), decode_movin(), decode_movn(), decode_movrel(), decode_movsn_args(), decode_not(), and decode_push_pop().

◆ decode_index32()

static int decode_index32 ( const ut8 data,
ebc_index_t index 
)
static

Definition at line 111 of file ebc_disas.c.

111  {
112  ut32 tmp = *(ut32 *)data;
113  index->type = EBC_INDEX32;
114  index->sign = tmp & EBC_NTH_BIT(31) ? EBC_INDEX_PLUS : EBC_INDEX_MINUS;
115  index->a_width = ((tmp >> 28) & EBC_N_BIT_MASK(2)) * 4;
116  index->n = tmp & EBC_N_BIT_MASK(index->a_width);
117  index->c = (tmp >> index->a_width) & EBC_N_BIT_MASK(28 - index->a_width);
118  return 0;
119 }
#define EBC_NTH_BIT(n)
Definition: ebc_disas.h:23

References ebc_index::a_width, ebc_index::c, EBC_N_BIT_MASK, EBC_NTH_BIT, ebc_index::n, ebc_index::sign, autogen_x86imm::tmp, and ebc_index::type.

Referenced by decode_call(), decode_jmp(), decode_mov_args(), decode_movin(), and decode_movn().

◆ decode_index64()

static int decode_index64 ( const ut8 data,
ebc_index_t index 
)
static

Definition at line 121 of file ebc_disas.c.

121  {
122  ut64 tmp = *(ut64 *)data;
123  index->type = EBC_INDEX64;
124  index->sign = tmp & EBC_NTH_BIT(63) ? EBC_INDEX_PLUS : EBC_INDEX_MINUS;
125  index->a_width = ((tmp >> 60) & EBC_N_BIT_MASK(2)) * 8;
126  index->n = tmp & EBC_N_BIT_MASK(index->a_width);
127  index->c = (tmp >> index->a_width) & EBC_N_BIT_MASK(60 - index->a_width);
128  return 0;
129 }

References ebc_index::a_width, ebc_index::c, EBC_N_BIT_MASK, EBC_NTH_BIT, ebc_index::n, ebc_index::sign, autogen_x86imm::tmp, ebc_index::type, and ut64().

Referenced by decode_mov_args(), and decode_movin().

◆ decode_invalid()

static int decode_invalid ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 921 of file ebc_disas.c.

921  {
922  return -1;
923 }

◆ decode_jmp()

static int decode_jmp ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 138 of file ebc_disas.c.

138  {
139  int ret;
140  int bits = 32;
141  char op1[32] = { 0 };
142  int32_t immed32;
143  ebc_index_t idx32;
144  char sign;
145  unsigned long immed;
146 
147  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%d%s", instr_names[EBC_JMP], bits,
148  TEST_BIT(bytes[1], 7) ? TEST_BIT(bytes[1], 6) ? "cs" : "cc" : "");
149 
150  if (TEST_BIT(bytes[0], 6)) {
151  immed = *(ut64 *)(bytes + 2);
152  ret = 10;
153  snprintf(cmd->operands, EBC_OPERANDS_MAXLEN, "0x%lx", immed);
154  } else {
155  if ((bytes[1] & 0x7) != 0) {
156  {
157  snprintf(op1, sizeof(op1), "%sr%u ",
158  TEST_BIT(bytes[1], 3) ? "@" : "", bytes[1] & 0x7);
159  }
160  }
161  if (TEST_BIT(bytes[0], 7)) {
162  if (TEST_BIT(bytes[1], 3)) {
163  decode_index32(bytes + 2, &idx32);
164  sign = idx32.sign ? '+' : '-';
165 
167  "%s(%c%u, %c%u)",
168  op1, sign, idx32.n, sign, idx32.c);
169  } else {
170  immed32 = *(int32_t *)(bytes + 2);
172  "%s0x%x", op1, immed32);
173  }
174  ret = 6;
175  } else {
176  snprintf(cmd->operands, EBC_OPERANDS_MAXLEN, "%s", op1);
177  ret = 2;
178  }
179  }
180 
181  return ret;
182 }
@ EBC_JMP
Definition: ebc_disas.h:31
int int32_t
Definition: sftypes.h:33

References bits(), bytes, ebc_index::c, CHK_SNPRINTF, cmd, decode_index32(), EBC_INSTR_MAXLEN, EBC_JMP, EBC_OPERANDS_MAXLEN, instr_names, ebc_index::n, ebc_index::sign, snprintf, TEST_BIT, and ut64().

◆ decode_jmp8()

static int decode_jmp8 ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 184 of file ebc_disas.c.

184  {
185  char suff[3] = { 0 };
186  if (TEST_BIT(bytes[0], 7)) {
187  const char *str = (TEST_BIT(bytes[0], 6)) ? "cs" : "cc";
188  snprintf(suff, 3, "%s", str);
189  }
190  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%s",
191  instr_names[bytes[0] & EBC_OPCODE_MASK], suff);
192  snprintf(cmd->operands, EBC_OPERANDS_MAXLEN, "0x%x", bytes[1]);
193  return 2;
194 }

References bytes, cmd, EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, instr_names, snprintf, cmd_descs_generate::str, and TEST_BIT.

◆ decode_loadsp()

static int decode_loadsp ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 576 of file ebc_disas.c.

576  {
577  int ret = 2;
578  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s",
580  snprintf(cmd->operands, EBC_OPERANDS_MAXLEN, "%s, r%u",
581  dedic_regs[bytes[1] & 0x7],
582  (bytes[1] >> 4) & 0x7);
583  return ret;
584 }
static const char * dedic_regs[]
Definition: ebc_disas.c:77

References bytes, cmd, dedic_regs, EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, instr_names, and snprintf.

◆ decode_mov()

static int decode_mov ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 525 of file ebc_disas.c.

525  {
526  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s",
528  return decode_mov_args(bytes, cmd);
529 }
static int decode_mov_args(const ut8 *bytes, ebc_command_t *cmd)
Definition: ebc_disas.c:448

References bytes, cmd, decode_mov_args(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, instr_names, and snprintf.

◆ decode_mov_args()

static int decode_mov_args ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 448 of file ebc_disas.c.

448  {
449  int ret = 2;
450  unsigned op1, op2;
451  char op1c[32], op2c[32];
452  char ind1[32] = { 0 }, ind2[32] = { 0 };
454  char sign;
455 
456  op1 = bytes[1] & 0x07;
457  op2 = (bytes[1] >> 4) & 0x07;
458 
459  snprintf(op1c, 32, "%sr%u", TEST_BIT(bytes[1], 3) ? "@" : "", op1);
460  snprintf(op2c, 32, "%sr%u", TEST_BIT(bytes[1], 7) ? "@" : "", op2);
461 
462  switch (bytes[0] & EBC_OPCODE_MASK) {
463  case EBC_MOVBW:
464  case EBC_MOVWW:
465  case EBC_MOVDW:
466  case EBC_MOVQW:
467  if (TEST_BIT(bytes[0], 7)) {
468  decode_index16(bytes + ret, &idx);
469  sign = idx.sign ? '+' : '-';
470  snprintf(ind1, 32, "(%c%u, %c%u)", sign,
471  idx.n, sign, idx.c);
472  ret += 2;
473  }
474  if (TEST_BIT(bytes[0], 6)) {
475  decode_index16(bytes + ret, &idx);
476  sign = idx.sign ? '+' : '-';
477  snprintf(ind2, 32, "(%c%u, %c%u)", sign,
478  idx.n, sign, idx.c);
479  ret += 2;
480  }
481  break;
482  case EBC_MOVBD:
483  case EBC_MOVWD:
484  case EBC_MOVDD:
485  case EBC_MOVQD:
486  if (TEST_BIT(bytes[0], 7)) {
487  decode_index32(bytes + ret, &idx);
488  sign = idx.sign ? '+' : '-';
489  snprintf(ind1, 32, "(%c%u, %c%u)", sign,
490  idx.n, sign, idx.c);
491  ret += 4;
492  }
493  if (TEST_BIT(bytes[0], 6)) {
494  decode_index32(bytes + ret, &idx);
495  sign = idx.sign ? '+' : '-';
496  snprintf(ind2, 32, "(%c%u, %c%u)", sign,
497  idx.n, sign, idx.c);
498  ret += 4;
499  }
500  break;
501  case EBC_MOVQQ:
502  if (TEST_BIT(bytes[0], 7)) {
503  decode_index64(bytes + ret, &idx);
504  sign = idx.sign ? '+' : '-';
505  snprintf(ind1, 32, "(%c%u, %c%u)", sign,
506  idx.n, sign, idx.c);
507  ret += 8;
508  }
509  if (TEST_BIT(bytes[0], 6)) {
510  decode_index64(bytes + ret, &idx);
511  sign = idx.sign ? '+' : '-';
512  snprintf(ind1, 32, "(%c%u, %c%u)", sign,
513  idx.n, sign, idx.c);
514  ret += 8;
515  }
516  break;
517  }
518 
519  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, %s%s",
520  op1c, ind1, op2c, ind2);
521 
522  return ret;
523 }
static int decode_index64(const ut8 *data, ebc_index_t *index)
Definition: ebc_disas.c:121
@ EBC_MOVDD
Definition: ebc_disas.h:65
@ EBC_MOVDW
Definition: ebc_disas.h:61
@ EBC_MOVQQ
Definition: ebc_disas.h:70
@ EBC_MOVQW
Definition: ebc_disas.h:62
@ EBC_MOVQD
Definition: ebc_disas.h:66
@ EBC_MOVWW
Definition: ebc_disas.h:60
@ EBC_MOVBW
Definition: ebc_disas.h:59
@ EBC_MOVBD
Definition: ebc_disas.h:63
@ EBC_MOVWD
Definition: ebc_disas.h:64

References bytes, CHK_SNPRINTF, cmd, decode_index16(), decode_index32(), decode_index64(), EBC_MOVBD, EBC_MOVBW, EBC_MOVDD, EBC_MOVDW, EBC_MOVQD, EBC_MOVQQ, EBC_MOVQW, EBC_MOVWD, EBC_MOVWW, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, snprintf, and TEST_BIT.

Referenced by decode_mov().

◆ decode_movi()

static int decode_movi ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 725 of file ebc_disas.c.

725  {
726  int ret = 2;
727  char p1 = 0, p2 = 0;
728  char indx[32] = { 0 };
729  char op1[32];
730  unsigned long immed = 0;
731 
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;
737  }
738 
739  if (ret < 0) {
740  return ret;
741  }
742 
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;
748  }
749 
750  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%c%c",
751  instr_names[bytes[0] & EBC_OPCODE_MASK], p1, p2);
752 
753  if (TEST_BIT(bytes[1], 6)) {
754  char sign;
756 
757  decode_index16(bytes + 2, &idx);
758  sign = idx.sign ? '+' : '-';
759 
760  snprintf(indx, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
761 
762  ret += 2;
763  }
764 
765  switch (p2) {
766  ut16 i1;
767  ut32 i2;
768  ut64 i3;
769  case 'w':
770  i1 = *(ut16 *)(bytes + ret);
771  immed = (unsigned long)i1;
772  ret += 2;
773  break;
774  case 'd':
775  i2 = *(ut32 *)(bytes + ret);
776  immed = (unsigned long)i2;
777  ret += 4;
778  break;
779  case 'q':
780  i3 = *(ut64 *)(bytes + ret);
781  immed = i3;
782  ret += 8;
783  break;
784  }
785 
786  snprintf(op1, 32, "%sr%u", TEST_BIT(bytes[1], 3) ? "@" : "", bytes[1] & 0x7);
787  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, %lu", op1, indx, immed);
788  return ret;
789 }
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
Definition: sflib.h:79

References bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, i2, setup::idx, indx(), instr_names, long, snprintf, TEST_BIT, and ut64().

◆ decode_movin()

static int decode_movin ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 791 of file ebc_disas.c.

791  {
792  int ret = 2;
793  char p1 = 0;
794  char indx1[32] = { 0 };
795  char indx2[32] = { 0 };
796  char op1[32];
797  char sign;
798  ebc_index_t idx = { 0 };
799 
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;
805  }
806 
807  if (ret < 0) {
808  return ret;
809  }
810 
811  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%c",
812  instr_names[bytes[0] & EBC_OPCODE_MASK], p1);
813 
814  if (TEST_BIT(bytes[1], 6)) {
815  decode_index16(bytes + 2, &idx);
816 
817  sign = idx.sign ? '+' : '-';
818 
819  snprintf(indx1, 32, "(%c%u, %c%u)", sign,
820  idx.n, sign, idx.c);
821 
822  ret += 2;
823  }
824 
825  switch (p1) {
826  case 'w':
827  decode_index16(bytes + ret, &idx);
828  ret += 2;
829  break;
830  case 'd':
831  decode_index32(bytes + ret, &idx);
832  ret += 4;
833  break;
834  case 'q':
835  decode_index64(bytes + ret, &idx);
836  ret += 8;
837  break;
838  }
839 
840  sign = idx.sign ? '+' : '-';
841 
842  snprintf(indx2, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
843 
844  snprintf(op1, 32, "%sr%u", TEST_BIT(bytes[1], 3) ? "@" : "", bytes[1] & 0x7);
845  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, %s", op1, indx1, indx2);
846  return ret;
847 }

References bytes, CHK_SNPRINTF, cmd, decode_index16(), decode_index32(), decode_index64(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, instr_names, snprintf, and TEST_BIT.

◆ decode_movn()

static int decode_movn ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 677 of file ebc_disas.c.

677  {
678  int ret = 2;
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 };
684  char sign;
686 
687  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s",
689 
690  snprintf(op1c, 32, "%sr%u", TEST_BIT(bytes[1], 3) ? "@" : "", op1);
691  snprintf(op2c, 32, "%sr%u", TEST_BIT(bytes[1], 7) ? "@" : "", op2);
692 
693  if ((bytes[0] & EBC_OPCODE_MASK) == EBC_MOVNW) {
694  if (TEST_BIT(bytes[0], 7)) {
695  decode_index16(bytes + ret, &idx);
696  sign = idx.sign ? '+' : '-';
697  snprintf(indx1, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
698  ret += 2;
699  }
700  if (TEST_BIT(bytes[0], 6)) {
701  decode_index16(bytes + ret, &idx);
702  sign = idx.sign ? '+' : '-';
703  snprintf(indx2, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
704  ret += 2;
705  }
706  } else {
707  if (TEST_BIT(bytes[0], 7)) {
708  decode_index32(bytes + ret, &idx);
709  sign = idx.sign ? '+' : '-';
710  snprintf(indx1, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
711  ret += 4;
712  }
713  if (TEST_BIT(bytes[0], 6)) {
714  decode_index32(bytes + ret, &idx);
715  sign = idx.sign ? '+' : '-';
716  snprintf(indx2, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
717  ret += 4;
718  }
719  }
720 
721  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, %s%s", op1c, indx1, op2c, indx2);
722  return ret;
723 }
@ EBC_MOVNW
Definition: ebc_disas.h:80

References bytes, CHK_SNPRINTF, cmd, decode_index16(), decode_index32(), EBC_INSTR_MAXLEN, EBC_MOVNW, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, instr_names, snprintf, and TEST_BIT.

◆ decode_movrel()

static int decode_movrel ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 849 of file ebc_disas.c.

849  {
850  int ret = 2;
851  char p1 = 0;
852  char op1[32];
853  char indx[32] = { 0 };
854  unsigned long immed = 0;
855  unsigned formathex = 0;
856 
857  switch (bytes[0] >> 6) {
858  case 0:
859  ret = -1;
860  break;
861  case 1:
862  p1 = 'w';
863  formathex = 4;
864  break;
865  case 2:
866  p1 = 'd';
867  formathex = 8;
868  break;
869  case 3:
870  p1 = 'q';
871  formathex = 16;
872  break;
873  }
874 
875  if (ret < 0) {
876  return ret;
877  }
878 
879  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%c",
880  instr_names[bytes[0] & EBC_OPCODE_MASK], p1);
881  snprintf(op1, 32, "%sr%u", TEST_BIT(bytes[1], 3) ? "@" : "", bytes[1] & 0x7);
882 
883  if (TEST_BIT(bytes[1], 6)) {
885  char sign;
886 
887  decode_index16(bytes + 2, &idx);
888  sign = idx.sign ? '+' : '-';
889 
890  snprintf(indx, 32, "(%c%u, %c%u)", sign, idx.n, sign, idx.c);
891 
892  ret += 2;
893  }
894 
895  ut16 v16;
896  ut32 v32;
897  ut64 v64;
898  switch (p1) {
899  case 'w':
900  v16 = *(ut16 *)(bytes + 2);
901  immed = v16;
902  ret += 2;
903  break;
904  case 'd':
905  v32 = *(ut32 *)(bytes + 2);
906  immed = v32;
907  ret += 4;
908  break;
909  case 'q':
910  v64 = *(ut64 *)(bytes + 2);
911  immed = v64;
912  ret += 8;
913  break;
914  }
915 
916  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, 0x%0*lx",
917  op1, indx, formathex, immed);
918  return ret;
919 }

References bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, indx(), instr_names, snprintf, TEST_BIT, and ut64().

◆ decode_movsn()

static int decode_movsn ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 570 of file ebc_disas.c.

570  {
571  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s",
573  return decode_movsn_args(bytes, cmd);
574 }
static int decode_movsn_args(const ut8 *bytes, ebc_command_t *cmd)
Definition: ebc_disas.c:531

References bytes, cmd, decode_movsn_args(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, instr_names, and snprintf.

◆ decode_movsn_args()

static int decode_movsn_args ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 531 of file ebc_disas.c.

531  {
532  int ret = 2;
533  unsigned op1, op2;
534  char op1c[32], op2c[32], sign;
535  char ind1[32] = { 0 }, ind2[32] = { 0 };
536 
537  op1 = bytes[1] & 0x07;
538  op2 = (bytes[1] >> 4) & 0x07;
539 
540  snprintf(op1c, 32, "%sr%u", TEST_BIT(bytes[1], 3) ? "@" : "", op1);
541  snprintf(op2c, 32, "%sr%u", TEST_BIT(bytes[1], 7) ? "@" : "", op2);
542 
543  switch (bytes[0] & EBC_OPCODE_MASK) {
544  case EBC_MOVSNW:
545  if (TEST_BIT(bytes[0], 7)) {
547  ret += 2;
548  decode_index16(bytes + 2, &idx);
549  sign = idx.sign ? '+' : '-';
550  snprintf(ind1, 32, "(%c%u, %c%u)",
551  sign, idx.n, sign, idx.c);
552  }
553  if (TEST_BIT(bytes[0], 6)) {
555  decode_index16(bytes + ret, &idx);
556  sign = idx.sign ? '+' : '-';
557  snprintf(ind2, 32, "(%c%u, %c%u)",
558  sign, idx.n, sign, idx.c);
559  ret += 2;
560  }
561  break;
562  case EBC_MOVSND:
563  break;
564  }
565  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s%s, %s%s",
566  op1c, ind1, op2c, ind2);
567  return ret;
568 }
@ EBC_MOVSNW
Definition: ebc_disas.h:67
@ EBC_MOVSND
Definition: ebc_disas.h:68

References bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_MOVSND, EBC_MOVSNW, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, snprintf, and TEST_BIT.

Referenced by decode_movsn().

◆ decode_mul()

static int decode_mul ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 407 of file ebc_disas.c.

407  {
408  int ret = decode_add(bytes, cmd);
409  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
410  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
412  return ret;
413 }
@ EBC_MUL
Definition: ebc_disas.h:44

References bits(), bytes, cmd, decode_add(), EBC_INSTR_MAXLEN, EBC_MUL, instr_names, snprintf, and TEST_BIT.

◆ decode_mulu()

static int decode_mulu ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 415 of file ebc_disas.c.

415  {
416  int ret = decode_add(bytes, cmd);
417  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
418 
419  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
421  return ret;
422 }
@ EBC_MULU
Definition: ebc_disas.h:45

References bits(), bytes, cmd, decode_add(), EBC_INSTR_MAXLEN, EBC_MULU, instr_names, snprintf, and TEST_BIT.

◆ decode_neg()

static int decode_neg ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 358 of file ebc_disas.c.

358  {
359  int ret = decode_not(bytes, cmd);
360  cmd->instr[1] = 'e';
361  cmd->instr[2] = 'g';
362  return ret;
363 }
static int decode_not(const ut8 *bytes, ebc_command_t *cmd)
Definition: ebc_disas.c:324

References bytes, cmd, and decode_not().

◆ decode_not()

static int decode_not ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 324 of file ebc_disas.c.

324  {
325  int ret = 2;
326  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
327  unsigned op1, op2;
328  char index[32] = { 0 };
329  ut16 immed;
330 
331  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u", instr_names[EBC_NOT],
332  bits);
333 
334  op1 = bytes[1] & 0x07;
335  op2 = (bytes[1] >> 4) & 0x07;
336 
337  if (TEST_BIT(bytes[0], 7)) {
338  // immediate/index present
339  ret = 4;
340  if (TEST_BIT(bytes[1], 7)) {
342  decode_index16(bytes + 2, &idx);
343  snprintf(index, 32, " (%c%d, %c%d)",
344  idx.sign ? '+' : '-', idx.n,
345  idx.sign ? '+' : '-', idx.c);
346  } else {
347  immed = *(ut16 *)&bytes[2];
348  snprintf(index, 32, "(%u)", immed);
349  }
350  }
351 
352  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%sr%d, %sr%d%s",
353  TEST_BIT(bytes[1], 3) ? "@" : "", op1,
354  TEST_BIT(bytes[1], 7) ? "@" : "", op2, index);
355  return ret;
356 }
@ EBC_NOT
Definition: ebc_disas.h:40

References bits(), bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_INSTR_MAXLEN, EBC_NOT, EBC_OPERANDS_MAXLEN, setup::idx, instr_names, snprintf, and TEST_BIT.

Referenced by decode_neg().

◆ decode_push_pop()

static int decode_push_pop ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 597 of file ebc_disas.c.

597  {
598  int ret = 2;
599  unsigned op1 = bytes[1] & 0x07;
600  char op1c[32];
601 
602  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
604  TEST_BIT(bytes[0], 6) ? 64 : 32);
605 
606  snprintf(op1c, sizeof(op1c), "%sr%d",
607  TEST_BIT(bytes[1], 3) ? "@" : "", op1);
608 
609  if (TEST_BIT(bytes[0], 7)) {
610  ret += 2;
611  if (TEST_BIT(bytes[1], 3)) {
613  char sign;
614  decode_index16(bytes + 2, &idx);
615 
616  sign = idx.sign ? '+' : '-';
617 
618  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s (%c%d, %c%d)",
619  op1c, sign, idx.n, sign, idx.c);
620  } else {
621  ut16 immed = *(ut16 *)(bytes + 2);
622 
623  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s %u",
624  op1c, immed);
625  }
626  } else {
627  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "%s", op1c);
628  }
629 
630  return ret;
631 }

References bytes, CHK_SNPRINTF, cmd, decode_index16(), EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, setup::idx, instr_names, snprintf, and TEST_BIT.

◆ decode_ret()

static int decode_ret ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 251 of file ebc_disas.c.

251  {
252  int ret = 2;
254  cmd->operands[0] = '\0';
255  return ret;
256 }
@ EBC_RET
Definition: ebc_disas.h:34

References cmd, EBC_INSTR_MAXLEN, EBC_RET, instr_names, and snprintf.

◆ decode_storesp()

static int decode_storesp ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 586 of file ebc_disas.c.

586  {
587  int ret = 2;
588  unsigned op2 = (bytes[1] >> 4) & 0x07;
589  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s",
591  CHK_SNPRINTF(cmd->operands, EBC_OPERANDS_MAXLEN, "r%u, %s",
592  bytes[1] & 0x7,
593  op2 < 2 ? dedic_regs[op2] : "RESERVED_DEDICATED_REG");
594  return ret;
595 }

References bytes, CHK_SNPRINTF, cmd, dedic_regs, EBC_INSTR_MAXLEN, EBC_OPCODE_MASK, EBC_OPERANDS_MAXLEN, instr_names, and snprintf.

◆ decode_sub()

static int decode_sub ( const ut8 bytes,
ebc_command_t cmd 
)
static

Definition at line 399 of file ebc_disas.c.

399  {
400  int ret = decode_add(bytes, cmd);
401  unsigned bits = TEST_BIT(bytes[0], 6) ? 64 : 32;
402  snprintf(cmd->instr, EBC_INSTR_MAXLEN, "%s%u",
404  return ret;
405 }
@ EBC_SUB
Definition: ebc_disas.h:43

References bits(), bytes, cmd, decode_add(), EBC_INSTR_MAXLEN, EBC_SUB, instr_names, snprintf, and TEST_BIT.

◆ ebc_decode_command()

int ebc_decode_command ( const ut8 instr,
ebc_command_t cmd 
)

Definition at line 986 of file ebc_disas.c.

986  {
987  if ((instr[0] & EBC_OPCODE_MASK) > 0x39) {
988  {
989  return -1;
990  }
991  }
992  return decodes[instr[0] & EBC_OPCODE_MASK](instr, cmd);
993 }
static decode decodes[EBC_COMMAND_NUM]
Definition: ebc_disas.c:925

References cmd, decodes, and EBC_OPCODE_MASK.

Referenced by disassemble(), and ebc_op().

Variable Documentation

◆ decodes

decode decodes[EBC_COMMAND_NUM]
static

Definition at line 925 of file ebc_disas.c.

Referenced by ebc_decode_command().

◆ dedic_regs

const char* dedic_regs[]
static
Initial value:
= {
"FLAGS",
"IP",
"DR_RESERVED1",
"DR_RESERVED2",
"DR_RESERVED3",
"DR_RESERVED4",
"DR_RESERVED5",
"DR_RESERVED6"
}

Definition at line 77 of file ebc_disas.c.

Referenced by decode_loadsp(), and decode_storesp().

◆ instr_names