Rizin
unix-like reverse engineering framework and cli tools
propeller_disas.h File Reference

Go to the source code of this file.

Classes

struct  propeller_cmd
 

Macros

#define PROP_INSTR_MAXLEN   32
 

Enumerations

enum  propeller_opcodes {
  PROP_ABS = 0x2A , PROP_ABSNEG = 0x2B , PROP_ADD = 0x20 , PROP_ADDABS = 0x22 ,
  PROP_ADDS = 0x34 , PROP_ADDSX = 0x36 , PROP_ADDX = 0x32 , PROP_AND = 0x18 ,
  PROP_ANDN = 0x19 , PROP_CALL = 0x17 , PROP_CMP = 0x21 , PROP_CMPS = 0x30 ,
  PROP_CMPSUB = 0x38 , PROP_CMPSX = 0x31 , PROP_CMPX = 0x33 , PROP_DJNZ = 0x39 ,
  PROP_HUBOP = 0x03 , PROP_JMP = 0x17 , PROP_JMPRET = 0x17 , PROP_MAX = 0x13 ,
  PROP_MAXS = 0x11 , PROP_MIN = 0x12 , PROP_MINS = 0x10 , PROP_MOV = 0x28 ,
  PROP_MOVD = 0x15 , PROP_MOVI = 0x16 , PROP_MOVS = 0x14 , PROP_MUXC = 0x1c ,
  PROP_MUXNC = 0x1d , PROP_MUXNZ = 0x1f , PROP_MUXZ = 0x1e , PROP_NEG = 0x29 ,
  PROP_NEGC = 0x2c , PROP_NEGNC = 0x2d , PROP_NEGNZ = 0x2f , PROP_NEGZ = 0x2e ,
  PROP_NOP = 0x00 , PROP_OR = 0x1a , PROP_RCL = 0x0d , PROP_RCR = 0x0c ,
  PROP_RDBYTE = 0x00 , PROP_RDLONG = 0x02 , PROP_RDWORD = 0x01 , PROP_RET = 0x17 ,
  PROP_REV = 0x0f , PROP_ROL = 0x09 , PROP_ROR = 0x08 , PROP_SAR = 0x0e ,
  PROP_SHL = 0x0b , PROP_SHR = 0x0a , PROP_SUB = 0x21 , PROP_SUBABS = 0x23 ,
  PROP_SUBS = 0x35 , PROP_SUBSX = 0x37 , PROP_SUBX = 0x33 , PROP_SUMC = 0x24 ,
  PROP_SUMNC = 0x25 , PROP_SUMNZ = 0x27 , PROP_SUMZ = 0x26 , PROP_TEST = 0x18 ,
  PROP_TESTN = 0x19 , PROP_TJNZ = 0x3a , PROP_TJZ = 0x3b , PROP_WAITCNT = 0x3e ,
  PROP_WAITPEQ = 0x3c , PROP_WAITPNE = 0x3d , PROP_WAITVID = 0x3f , PROP_WRBYTE = 0x00 ,
  PROP_WRLONG = 0x02 , PROP_WRWORD = 0x01 , PROP_XOR = 0x1b
}
 
enum  propeller_ext_opcodes {
  PROP_CLKSET = 0x18 , PROP_COGID = 0x19 , PROP_COGINIT = 0x1a , PROP_COGSTOP = 0x1b ,
  PROP_LOCKCLR = 0x1f , PROP_LOCKNEW = 0x1c , PROP_LOCKRET = 0x1d , PROP_LOCKSET = 0x1e
}
 
enum  propeller_conditions {
  PROP_IF_ALWAYS = 0xf , PROP_IF_NEVER = 0x0 , PROP_IF_E = 0xa , PROP_IF_NE = 0x5 ,
  PROP_IF_A = 0x1 , PROP_IF_B = 0xc , PROP_IF_AE = 0x3 , PROP_IF_BE = 0xe ,
  PROP_IF_C_EQ_Z = 0x9 , PROP_IF_C_NE_Z = 0x6 , PROP_IF_C_AND_Z = 0x8 , PROP_IF_C_AND_NZ = 0x4 ,
  PROP_IF_NC_AND_Z = 0x2 , PROP_IF_NZ_OR_NC = 0x7 , PROP_IF_NZ_OR_C = 0xd , PROP_IF_Z_OR_NC = 0xb
}
 

Functions

int propeller_decode_command (const ut8 *instr, struct propeller_cmd *cmd)
 

Macro Definition Documentation

◆ PROP_INSTR_MAXLEN

#define PROP_INSTR_MAXLEN   32

Definition at line 7 of file propeller_disas.h.

Enumeration Type Documentation

◆ propeller_conditions

Enumerator
PROP_IF_ALWAYS 
PROP_IF_NEVER 
PROP_IF_E 
PROP_IF_NE 
PROP_IF_A 
PROP_IF_B 
PROP_IF_AE 
PROP_IF_BE 
PROP_IF_C_EQ_Z 
PROP_IF_C_NE_Z 
PROP_IF_C_AND_Z 
PROP_IF_C_AND_NZ 
PROP_IF_NC_AND_Z 
PROP_IF_NZ_OR_NC 
PROP_IF_NZ_OR_C 
PROP_IF_Z_OR_NC 

Definition at line 94 of file propeller_disas.h.

94  {
95  PROP_IF_ALWAYS = 0xf,
96  PROP_IF_NEVER = 0x0,
97  PROP_IF_E = 0xa,
98  PROP_IF_NE = 0x5,
99  PROP_IF_A = 0x1,
100  PROP_IF_B = 0xc,
101  PROP_IF_AE = 0x3,
102  PROP_IF_BE = 0xe,
103  PROP_IF_C_EQ_Z = 0x9,
104  PROP_IF_C_NE_Z = 0x6,
105  PROP_IF_C_AND_Z = 0x8,
106  PROP_IF_C_AND_NZ = 0x4,
107  PROP_IF_NC_AND_Z = 0x2,
108  PROP_IF_NZ_OR_NC = 0x7,
109  PROP_IF_NZ_OR_C = 0xd,
110  PROP_IF_Z_OR_NC = 0xb,
111 };
@ PROP_IF_BE
@ PROP_IF_B
@ PROP_IF_C_NE_Z
@ PROP_IF_NZ_OR_C
@ PROP_IF_ALWAYS
@ PROP_IF_E
@ PROP_IF_AE
@ PROP_IF_C_AND_Z
@ PROP_IF_C_AND_NZ
@ PROP_IF_Z_OR_NC
@ PROP_IF_NC_AND_Z
@ PROP_IF_C_EQ_Z
@ PROP_IF_NEVER
@ PROP_IF_NE
@ PROP_IF_NZ_OR_NC
@ PROP_IF_A

◆ propeller_ext_opcodes

Enumerator
PROP_CLKSET 
PROP_COGID 
PROP_COGINIT 
PROP_COGSTOP 
PROP_LOCKCLR 
PROP_LOCKNEW 
PROP_LOCKRET 
PROP_LOCKSET 

Definition at line 83 of file propeller_disas.h.

83  {
84  PROP_CLKSET = 0x18,
85  PROP_COGID = 0x19,
86  PROP_COGINIT = 0x1a,
87  PROP_COGSTOP = 0x1b,
88  PROP_LOCKCLR = 0x1f,
89  PROP_LOCKNEW = 0x1c,
90  PROP_LOCKRET = 0x1d,
91  PROP_LOCKSET = 0x1e,
92 };
@ PROP_LOCKNEW
@ PROP_CLKSET
@ PROP_COGSTOP
@ PROP_LOCKRET
@ PROP_LOCKSET
@ PROP_COGINIT
@ PROP_LOCKCLR
@ PROP_COGID

◆ propeller_opcodes

Enumerator
PROP_ABS 
PROP_ABSNEG 
PROP_ADD 
PROP_ADDABS 
PROP_ADDS 
PROP_ADDSX 
PROP_ADDX 
PROP_AND 
PROP_ANDN 
PROP_CALL 
PROP_CMP 
PROP_CMPS 
PROP_CMPSUB 
PROP_CMPSX 
PROP_CMPX 
PROP_DJNZ 
PROP_HUBOP 
PROP_JMP 
PROP_JMPRET 
PROP_MAX 
PROP_MAXS 
PROP_MIN 
PROP_MINS 
PROP_MOV 
PROP_MOVD 
PROP_MOVI 
PROP_MOVS 
PROP_MUXC 
PROP_MUXNC 
PROP_MUXNZ 
PROP_MUXZ 
PROP_NEG 
PROP_NEGC 
PROP_NEGNC 
PROP_NEGNZ 
PROP_NEGZ 
PROP_NOP 
PROP_OR 
PROP_RCL 
PROP_RCR 
PROP_RDBYTE 
PROP_RDLONG 
PROP_RDWORD 
PROP_RET 
PROP_REV 
PROP_ROL 
PROP_ROR 
PROP_SAR 
PROP_SHL 
PROP_SHR 
PROP_SUB 
PROP_SUBABS 
PROP_SUBS 
PROP_SUBSX 
PROP_SUBX 
PROP_SUMC 
PROP_SUMNC 
PROP_SUMNZ 
PROP_SUMZ 
PROP_TEST 
PROP_TESTN 
PROP_TJNZ 
PROP_TJZ 
PROP_WAITCNT 
PROP_WAITPEQ 
PROP_WAITPNE 
PROP_WAITVID 
PROP_WRBYTE 
PROP_WRLONG 
PROP_WRWORD 
PROP_XOR 

Definition at line 9 of file propeller_disas.h.

9  {
10  PROP_ABS = 0x2A,
11  PROP_ABSNEG = 0x2B,
12  PROP_ADD = 0x20,
13  PROP_ADDABS = 0x22,
14  PROP_ADDS = 0x34,
15  PROP_ADDSX = 0x36,
16  PROP_ADDX = 0x32,
17  PROP_AND = 0x18,
18  PROP_ANDN = 0x19,
19  PROP_CALL = 0x17,
20  PROP_CMP = 0x21,
21  PROP_CMPS = 0x30,
22  PROP_CMPSUB = 0x38,
23  PROP_CMPSX = 0x31,
24  PROP_CMPX = 0x33,
25  PROP_DJNZ = 0x39,
26  PROP_HUBOP = 0x03,
27  PROP_JMP = 0x17,
28  PROP_JMPRET = 0x17,
29  PROP_MAX = 0x13,
30  PROP_MAXS = 0x11,
31  PROP_MIN = 0x12,
32  PROP_MINS = 0x10,
33  PROP_MOV = 0x28,
34  PROP_MOVD = 0x15,
35  PROP_MOVI = 0x16,
36  PROP_MOVS = 0x14,
37  PROP_MUXC = 0x1c,
38  PROP_MUXNC = 0x1d,
39  PROP_MUXNZ = 0x1f,
40  PROP_MUXZ = 0x1e,
41  PROP_NEG = 0x29,
42  PROP_NEGC = 0x2c,
43  PROP_NEGNC = 0x2d,
44  PROP_NEGNZ = 0x2f,
45  PROP_NEGZ = 0x2e,
46  PROP_NOP = 0x00,
47  PROP_OR = 0x1a,
48  PROP_RCL = 0x0d,
49  PROP_RCR = 0x0c,
50  PROP_RDBYTE = 0x00,
51  PROP_RDLONG = 0x02,
52  PROP_RDWORD = 0x01,
53  PROP_RET = 0x17,
54  PROP_REV = 0x0f,
55  PROP_ROL = 0x09,
56  PROP_ROR = 0x08,
57  PROP_SAR = 0x0e,
58  PROP_SHL = 0x0b,
59  PROP_SHR = 0x0a,
60  PROP_SUB = 0x21,
61  PROP_SUBABS = 0x23,
62  PROP_SUBS = 0x35,
63  PROP_SUBSX = 0x37,
64  PROP_SUBX = 0x33,
65  PROP_SUMC = 0x24,
66  PROP_SUMNC = 0x25,
67  PROP_SUMNZ = 0x27,
68  PROP_SUMZ = 0x26,
69  PROP_TEST = 0x18,
70  PROP_TESTN = 0x19,
71  PROP_TJNZ = 0x3a,
72  PROP_TJZ = 0x3b,
73  PROP_WAITCNT = 0x3e,
74  PROP_WAITPEQ = 0x3c,
75  PROP_WAITPNE = 0x3d,
76  PROP_WAITVID = 0x3f,
77  PROP_WRBYTE = 0x00,
78  PROP_WRLONG = 0x02,
79  PROP_WRWORD = 0x01,
80  PROP_XOR = 0x1b,
81 };
@ PROP_WAITPEQ
@ PROP_MOVS
@ PROP_MOVD
@ PROP_SUMNZ
@ PROP_MIN
@ PROP_CALL
@ PROP_RDWORD
@ PROP_CMPSUB
@ PROP_ANDN
@ PROP_RCR
@ PROP_ADDX
@ PROP_SUMNC
@ PROP_REV
@ PROP_SUBX
@ PROP_WRWORD
@ PROP_XOR
@ PROP_NEG
@ PROP_MOVI
@ PROP_NEGZ
@ PROP_CMPX
@ PROP_SHL
@ PROP_RDBYTE
@ PROP_ADDSX
@ PROP_ABSNEG
@ PROP_TJZ
@ PROP_TJNZ
@ PROP_SHR
@ PROP_RCL
@ PROP_NEGC
@ PROP_NEGNC
@ PROP_MUXC
@ PROP_NEGNZ
@ PROP_SUBABS
@ PROP_SAR
@ PROP_CMP
@ PROP_MUXZ
@ PROP_ROR
@ PROP_JMPRET
@ PROP_TEST
@ PROP_MAXS
@ PROP_AND
@ PROP_MINS
@ PROP_WAITPNE
@ PROP_RDLONG
@ PROP_ADDABS
@ PROP_ADDS
@ PROP_MOV
@ PROP_WAITCNT
@ PROP_NOP
@ PROP_MUXNZ
@ PROP_WRBYTE
@ PROP_MUXNC
@ PROP_SUMZ
@ PROP_WRLONG
@ PROP_WAITVID
@ PROP_HUBOP
@ PROP_TESTN
@ PROP_ADD
@ PROP_SUMC
@ PROP_SUBS
@ PROP_ROL
@ PROP_OR
@ PROP_MAX
@ PROP_JMP
@ PROP_DJNZ
@ PROP_CMPS
@ PROP_SUB
@ PROP_SUBSX
@ PROP_RET
@ PROP_CMPSX
@ PROP_ABS

Function Documentation

◆ propeller_decode_command()

int propeller_decode_command ( const ut8 instr,
struct propeller_cmd cmd 
)

Definition at line 205 of file propeller_disas.c.

205  {
206  int ret = -1;
207  ut32 in;
208  ut16 opcode;
209 
210  in = rz_read_be32(instr);
211 
212  opcode = get_opcode(in);
213 
214  if (!get_con(in)) {
215  snprintf(cmd->instr, PROP_INSTR_MAXLEN, "nop");
216  cmd->operands[0] = '\0';
217  return 4;
218  }
219 
220  switch (opcode) {
221  case PROP_ABS:
222  case PROP_ABSNEG:
223  case PROP_ADD:
224  case PROP_ADDABS:
225  case PROP_ADDS:
226  case PROP_ADDSX:
227  case PROP_ADDX:
228  case PROP_AND:
229  case PROP_ANDN:
230  case PROP_CMP:
231  case PROP_CMPS:
232  case PROP_CMPSUB:
233  case PROP_CMPSX:
234  case PROP_CMPX:
235  case PROP_DJNZ:
236  case PROP_MAX:
237  case PROP_MAXS:
238  case PROP_MIN:
239  case PROP_MINS:
240  case PROP_MOV:
241  case PROP_MOVD:
242  case PROP_MOVI:
243  case PROP_MOVS:
244  case PROP_MUXC:
245  case PROP_MUXNC:
246  case PROP_MUXNZ:
247  case PROP_MUXZ:
248  case PROP_NEG:
249  case PROP_NEGC:
250  case PROP_NEGNC:
251  case PROP_NEGNZ:
252  case PROP_NEGZ:
253  case PROP_OR:
254  case PROP_RCL:
255  case PROP_RCR:
256  case PROP_RDBYTE:
257  case PROP_RDLONG:
258  case PROP_RDWORD:
259  // case PROP_RET:
260  case PROP_REV:
261  case PROP_ROL:
262  case PROP_ROR:
263  case PROP_SAR:
264  case PROP_SHL:
265  case PROP_SHR:
266  case PROP_SUBABS:
267  case PROP_SUBS:
268  case PROP_SUBSX:
269  // case PROP_SUBX:
270  case PROP_SUMC:
271  case PROP_SUMNC:
272  case PROP_SUMNZ:
273  case PROP_SUMZ:
274  // case PROP_TEST:
275  case PROP_TJZ:
276  case PROP_WAITCNT:
277  case PROP_WAITPEQ:
278  case PROP_WAITPNE:
279  case PROP_WAITVID:
280  case PROP_XOR:
281  snprintf(cmd->instr, sizeof cmd->instr, "%s", instrs[opcode]);
282 
283  if ((opcode == PROP_RDBYTE || opcode == PROP_RDLONG ||
284  opcode == PROP_RDWORD) &&
285  (!(get_zcri(in) & 0x2))) {
286  cmd->instr[0] = 'w';
287  cmd->instr[1] = 'r';
288  }
289 
290  if (opcode == PROP_SUB && in & 0x08000000) {
291  snprintf(cmd->instr, PROP_INSTR_MAXLEN - 1, "sub");
292  } else if (opcode == PROP_SUBX && in & 0x08000000) {
293  snprintf(cmd->instr, PROP_INSTR_MAXLEN - 1, "subx");
294  }
295 
296  if (is_immediate(in)) {
297  cmd->src = get_src(in);
298  cmd->dst = get_dst(in);
299  snprintf(cmd->operands, PROP_INSTR_MAXLEN - 1, "0x%x, #%d",
300  get_dst(in), get_src(in));
301  } else {
302  cmd->src = get_src(in) << 2;
303  cmd->dst = get_dst(in);
304  snprintf(cmd->operands, PROP_INSTR_MAXLEN - 1, "0x%x, 0x%x",
305  get_dst(in), get_src(in) << 2);
306  }
307 
308  ret = 4;
309  break;
310  case PROP_HUBOP:
311  ret = decode_ext_cmd(cmd, in);
312  if (ret == -1) {
313  snprintf(cmd->instr, PROP_INSTR_MAXLEN - 1, "%s",
314  instrs[opcode]);
315 
316  if (is_immediate(in)) {
317  cmd->src = get_src(in);
318  cmd->dst = get_dst(in);
319 
320  snprintf(cmd->operands, PROP_INSTR_MAXLEN - 1, "0x%x, #%d",
321  get_dst(in) << 2, get_src(in));
322  } else {
323  cmd->src = get_src(in);
324  cmd->dst = get_dst(in);
325 
326  snprintf(cmd->operands, PROP_INSTR_MAXLEN - 1, "0x%x, 0x%x",
327  get_dst(in), get_src(in));
328  }
329 
330  ret = 4;
331  }
332  break;
333  case PROP_JMP:
334  ret = decode_jmp(cmd, in);
335  break;
336  }
337 
338  cmd->opcode = opcode;
339 
340  if (ret > 0) {
341  decode_prefix(cmd, in);
342  }
343 
344  return ret;
345 }
const lzma_allocator const uint8_t * in
Definition: block.h:527
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
uint32_t ut32
snprintf
Definition: kernel.h:364
static const char * instrs[]
static ut8 get_zcri(ut32 instr)
static ut16 get_src(ut32 instr)
static int decode_jmp(struct propeller_cmd *cmd, ut32 instr)
static int decode_ext_cmd(struct propeller_cmd *cmd, ut32 instr)
static ut8 get_con(ut32 instr)
static ut16 get_opcode(ut32 instr)
static void decode_prefix(struct propeller_cmd *cmd, ut32 instr)
static int is_immediate(ut32 instr)
static ut16 get_dst(ut32 instr)
#define PROP_INSTR_MAXLEN
static ut32 rz_read_be32(const void *src)
Definition: rz_endian.h:87

References cmd, decode_ext_cmd(), decode_jmp(), decode_prefix(), get_con(), get_dst(), get_opcode(), get_src(), get_zcri(), in, instrs, is_immediate(), PROP_ABS, PROP_ABSNEG, PROP_ADD, PROP_ADDABS, PROP_ADDS, PROP_ADDSX, PROP_ADDX, PROP_AND, PROP_ANDN, PROP_CMP, PROP_CMPS, PROP_CMPSUB, PROP_CMPSX, PROP_CMPX, PROP_DJNZ, PROP_HUBOP, PROP_INSTR_MAXLEN, PROP_JMP, PROP_MAX, PROP_MAXS, PROP_MIN, PROP_MINS, PROP_MOV, PROP_MOVD, PROP_MOVI, PROP_MOVS, PROP_MUXC, PROP_MUXNC, PROP_MUXNZ, PROP_MUXZ, PROP_NEG, PROP_NEGC, PROP_NEGNC, PROP_NEGNZ, PROP_NEGZ, PROP_OR, PROP_RCL, PROP_RCR, PROP_RDBYTE, PROP_RDLONG, PROP_RDWORD, PROP_REV, PROP_ROL, PROP_ROR, PROP_SAR, PROP_SHL, PROP_SHR, PROP_SUB, PROP_SUBABS, PROP_SUBS, PROP_SUBSX, PROP_SUBX, PROP_SUMC, PROP_SUMNC, PROP_SUMNZ, PROP_SUMZ, PROP_TJZ, PROP_WAITCNT, PROP_WAITPEQ, PROP_WAITPNE, PROP_WAITVID, PROP_XOR, rz_read_be32(), and snprintf.

Referenced by disassemble(), and propeller_op().