Rizin
unix-like reverse engineering framework and cli tools
disassembler.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 deroad <wargio@libero.it>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include "disassembler.h"
5 #include "common.h"
6 
23 typedef ut32 (*Decode)(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb);
24 
25 typedef struct avr_decoder_t {
26  cchar* name; /* instruction name */
27  AVROpMnem id; /* instruction identifier */
28  ut32 cycles; /* number of execution cycles */
29  ut16 cbits; /* constant bits */
30  ut16 mbits; /* mask to compare with constant bits */
31  ut32 opsize; /* instruction size */
34 
35 static ut32 avr_unique(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
36  aop->mnemonic = id;
38  return 2;
39 }
40 
41 static ut32 avr_rdddddrrrr(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
42  ut16 Rr = data[0] & 0x000F;
43  ut16 Rd = ((data[0] & 0x01F0) >> 4);
44  Rr |= ((data[0] & 0x0200) >> 5);
45 
46  aop->param[0] = Rd;
47  aop->param[1] = Rr;
48  if (Rd == Rr) {
49  aop->param[0] = Rd;
50  if (!strncmp(name, "adc", 3)) {
51  aop->mnemonic = AVR_OP_ROL;
52  rz_strbuf_setf(sb, "rol r%u", Rd);
53  } else if (!strncmp(name, "add", 3)) {
54  aop->mnemonic = AVR_OP_LSL;
55  rz_strbuf_setf(sb, "lsl r%u", Rd);
56  } else if (!strncmp(name, "and", 3)) {
57  aop->mnemonic = AVR_OP_TST;
58  rz_strbuf_setf(sb, "tst r%u", Rd);
59  } else if (!strncmp(name, "eor", 3)) {
60  aop->mnemonic = AVR_OP_CLR;
61  rz_strbuf_setf(sb, "clr r%u", Rd);
62  } else {
63  aop->mnemonic = id;
64  rz_strbuf_setf(sb, "%s r%u, r%u", name, Rd, Rr);
65  }
66  } else {
67  aop->mnemonic = id;
68  rz_strbuf_setf(sb, "%s r%u, r%u", name, Rd, Rr);
69  }
70 
71  return 2;
72 }
73 
74 
75 static ut32 avr_KKddKKKK(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
76  ut16 K = data[0] & 0x000F;
77  ut16 Rd = 24 + ((data[0] & 0x0030) >> 3);
78  K |= ((data[0] & 0x00C0) >> 2);
79 
80  aop->mnemonic = id;
81  aop->param[0] = Rd + 1;
82  aop->param[1] = Rd;
83  aop->param[2] = K;
84  rz_strbuf_setf(sb, "%s r%u:r%u, 0x%02x", name, Rd + 1, Rd, K);
85  return 2;
86 }
87 
88 
89 static ut32 avr_KKKKddddKKKK(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
90  ut16 K = data[0] & 0x000F;
91  ut16 Rd = 16 + ((data[0] & 0x00F0) >> 4);
92  K |= ((data[0] & 0x0F00) >> 4);
93 
94  aop->param[0] = Rd;
95  if (K == 0xFF && !strncmp(name, "ldi", 3)) {
96  aop->mnemonic = AVR_OP_SER;
97  rz_strbuf_setf(sb, "ser r%u", Rd);
98  } else {
99  aop->mnemonic = id;
100  aop->param[1] = K;
101  rz_strbuf_setf(sb, "%s r%u, 0x%02x", name, Rd, K);
102  }
103 
104  return 2;
105 }
106 
107 
108 static ut32 avr_dddddcccc(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
109  ut16 Rd = ((data[0] & 0x01F0) >> 4);
110 
111  aop->mnemonic = id;
112  aop->param[0] = Rd;
113  rz_strbuf_setf(sb, "%s r%u", name, Rd);
114  return 2;
115 }
116 
117 
118 static ut32 avr_dddddcbbb(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
119  ut16 b = data[0] & 0x0007;
120  ut16 Rd = ((data[0] & 0x01F0) >> 4);
121 
122  aop->mnemonic = id;
123  aop->param[0] = Rd;
124  aop->param[1] = b;
125  rz_strbuf_setf(sb, "%s r%u, %u", name, Rd, b);
126  return 2;
127 }
128 
129 
130 static ut32 avr_kkkkkkkccc(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
131  st16 k = (data[0] & 0x03F8) >> 3;
132  k *= 2;
133  if (k & 0x0080) {
134  // manually extend signed value
135  k |= 0xFF00;
136  k = -(~k) + 1;
137  } else {
138  k += 2;
139  }
140  pc += k;
141 
142  aop->mnemonic = id;
143  aop->param[0] = pc;
144  rz_strbuf_setf(sb, "%s 0x%" PFMT64x, name, pc);
145  return 2;
146 }
147 
148 
149 static ut32 avr_kkkkkccck(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
150  st32 k = data[0] & 0x0001;
151  k |= ((data[0] & 0x01F0) >> 3);
152  k <<= 16;
153  k |= data[1];
154  k *= 2;
155 
156  aop->mnemonic = id;
157  aop->param[0] = (k >> 16) & 0xFFFF;
158  aop->param[1] = k & 0xFFFF;
159  rz_strbuf_setf(sb, "%s 0x%x", name, k);
160  return 4;
161 }
162 
163 
164 static ut32 avr_AAAAAbbb(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
165  ut16 b = data[0] & 0x0007;
166  ut16 A = ((data[0] & 0x00F8) >> 3);
167 
168  aop->mnemonic = id;
169  aop->param[0] = A;
170  aop->param[1] = b;
171  rz_strbuf_setf(sb, "%s 0x%02x, %u", name, A, b);
172  return 2;
173 }
174 
175 
176 static ut32 avr_KKKKcccc(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
177  ut16 K = ((data[0] & 0x00F0) >> 4);
178 
179  aop->mnemonic = id;
180  aop->param[0] = K;
181  rz_strbuf_setf(sb, "%s 0x%02x", name, K);
182  return 2;
183 }
184 
185 
186 static ut32 avr_dddddcccc_z(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
187  ut16 Rd = ((data[0] & 0x01F0) >> 4);
188 
189  aop->mnemonic = id;
190  aop->param[0] = Rd;
191  aop->param[1] = 'Z';
192  rz_strbuf_setf(sb, "%s r%u, Z", name, Rd);
193  return 2;
194 }
195 
196 
197 static ut32 avr_dddddcccc_zp(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
198  ut16 Rd = ((data[0] & 0x01F0) >> 4);
199 
200  aop->mnemonic = id;
201  aop->param[0] = Rd;
202  aop->param[1] = 'Z';
203  aop->param[2] = '+';
204  aop->param[3] = 1;
205  rz_strbuf_setf(sb, "%s r%u, Z+", name, Rd);
206  return 2;
207 }
208 
209 
210 static ut32 avr_dddcrrr(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
211  ut16 Rr = 16 + (data[0] & 0x0007);
212  ut16 Rd = 16 + ((data[0] & 0x0070) >> 4);
213 
214  aop->mnemonic = id;
215  aop->param[0] = Rd;
216  aop->param[1] = Rr;
217  rz_strbuf_setf(sb, "%s r%u, r%u", name, Rd, Rr);
218  return 2;
219 }
220 
221 
222 static ut32 avr_AAdddddAAAA(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
223  ut16 A = data[0] & 0x000F;
224  ut16 Rd = ((data[0] & 0x01F0) >> 4);
225  A |= ((data[0] & 0x0600) >> 5);
226 
227  aop->mnemonic = id;
228  aop->param[0] = Rd;
229  aop->param[1] = A;
230  rz_strbuf_setf(sb, "%s r%u, 0x%02x", name, Rd, A);
231  return 2;
232 }
233 
234 
235 static ut32 avr_dddddcccc_x(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
236  ut16 Rd = ((data[0] & 0x01F0) >> 4);
237 
238  aop->mnemonic = id;
239  aop->param[0] = Rd;
240  aop->param[1] = 'X';
241  rz_strbuf_setf(sb, "%s r%u, X", name, Rd);
242  return 2;
243 }
244 
245 
246 static ut32 avr_dddddcccc_xp(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
247  ut16 Rd = ((data[0] & 0x01F0) >> 4);
248 
249  aop->mnemonic = id;
250  aop->param[0] = Rd;
251  aop->param[1] = 'X';
252  aop->param[2] = '+';
253  aop->param[3] = 1;
254  rz_strbuf_setf(sb, "%s r%u, X+", name, Rd);
255  return 2;
256 }
257 
258 
259 static ut32 avr_dddddcccc_xm(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
260  ut16 Rd = ((data[0] & 0x01F0) >> 4);
261 
262  aop->mnemonic = id;
263  aop->param[0] = Rd;
264  aop->param[1] = 'X';
265  aop->param[2] = '-';
266  aop->param[3] = 1;
267  rz_strbuf_setf(sb, "%s r%u, -X", name, Rd);
268  return 2;
269 }
270 
271 
272 static ut32 avr_dddddcccc_y(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
273  ut16 Rd = ((data[0] & 0x01F0) >> 4);
274 
275  aop->mnemonic = id;
276  aop->param[0] = Rd;
277  aop->param[1] = 'Y';
278  rz_strbuf_setf(sb, "%s r%u, Y", name, Rd);
279  return 2;
280 }
281 
282 
283 static ut32 avr_dddddcccc_yp(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
284  ut16 Rd = ((data[0] & 0x01F0) >> 4);
285 
286  aop->mnemonic = id;
287  aop->param[0] = Rd;
288  aop->param[1] = 'Y';
289  aop->param[2] = '+';
290  aop->param[3] = 1;
291  rz_strbuf_setf(sb, "%s r%u, Y+", name, Rd);
292  return 2;
293 }
294 
295 
296 static ut32 avr_dddddcccc_ym(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
297  ut16 Rd = ((data[0] & 0x01F0) >> 4);
298 
299  aop->mnemonic = id;
300  aop->param[0] = Rd;
301  aop->param[1] = 'Y';
302  aop->param[2] = '-';
303  aop->param[3] = 1;
304  rz_strbuf_setf(sb, "%s r%u, -Y", name, Rd);
305  return 2;
306 }
307 
308 
310  ut16 q = data[0] & 0x0007;
311  ut16 Rd = ((data[0] & 0x01F0) >> 4);
312  q |= ((data[0] & 0x0C00) >> 7);
313  q |= ((data[0] & 0x2000) >> 8);
314 
315  aop->mnemonic = id;
316  aop->param[0] = Rd;
317  aop->param[1] = 'Y';
318  aop->param[2] = '+';
319  aop->param[3] = q;
320  rz_strbuf_setf(sb, "%s r%u, Y+%u", name, Rd, q);
321  return 2;
322 }
323 
324 
325 static ut32 avr_dddddcccc_zm(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
326  ut16 Rd = ((data[0] & 0x01F0) >> 4);
327 
328  aop->mnemonic = id;
329  aop->param[0] = Rd;
330  aop->param[1] = 'Z';
331  aop->param[2] = '-';
332  aop->param[3] = 1;
333  rz_strbuf_setf(sb, "%s r%u, -Z", name, Rd);
334  return 2;
335 }
336 
337 
339  ut16 q = data[0] & 0x0007;
340  ut16 Rd = ((data[0] & 0x01F0) >> 4);
341  q |= ((data[0] & 0x0C00) >> 7);
342  q |= ((data[0] & 0x2000) >> 8);
343 
344  aop->mnemonic = id;
345  aop->param[0] = Rd;
346  aop->param[1] = 'Z';
347  aop->param[2] = '+';
348  aop->param[3] = q;
349  rz_strbuf_setf(sb, "%s r%u, Z+%u", name, Rd, q);
350  return 2;
351 }
352 
353 
355  ut16 Rd = ((data[0] & 0x01F0) >> 4);
356  aop->mnemonic = id;
357  aop->param[0] = Rd;
358  aop->param[1] = data[1];
359  rz_strbuf_setf(sb, "%s r%u, 0x%02x", name, Rd, data[1]);
360  return 4;
361 }
362 
363 
365  ut16 k = data[0] & 0x000F;
366  ut16 Rd = 16 + ((data[0] & 0x00F0) >> 4);
367  k |= ((data[0] & 0x0700) >> 4);
368  aop->mnemonic = id;
369  aop->param[0] = Rd;
370  aop->param[1] = k;
371  rz_strbuf_setf(sb, "%s r%u, 0x%02x", name, Rd, k);
372  return 2;
373 }
374 
375 
376 static ut32 avr_ddddrrrr(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
377  ut16 Rr = data[0] & 0x000F;
378  ut16 Rd = ((data[0] & 0x00F0) >> 4);
379 
380  Rr *= 2;
381  Rd *= 2;
382 
383  aop->mnemonic = id;
384  aop->param[0] = Rd;
385  aop->param[1] = Rr;
386  rz_strbuf_setf(sb, "%s r%u, r%u", name, Rd, Rr);
387  return 2;
388 }
389 
390 
391 static ut32 avr_ddddrrrr_2x(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
392  ut16 Rr = data[0] & 0x000F;
393  ut16 Rd = ((data[0] & 0x00F0) >> 4);
394  Rr += 16;
395  Rd += 16;
396 
397  aop->mnemonic = id;
398  aop->param[0] = Rd;
399  aop->param[1] = Rr;
400  rz_strbuf_setf(sb, "%s r%u, r%u", name, Rd, Rr);
401  return 2;
402 }
403 
404 
405 static ut32 avr_AArrrrrAAAA(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
406  ut16 A = data[0] & 0x000F;
407  ut16 Rr = ((data[0] & 0x01F0) >> 4);
408  A |= ((data[0] & 0x0600) >> 5);
409 
410  aop->mnemonic = id;
411  aop->param[0] = A;
412  aop->param[1] = Rr;
413  rz_strbuf_setf(sb, "%s 0x%02x, r%u", name, A, Rr);
414  return 2;
415 }
416 
417 
418 static ut32 avr_kkkkkkkkkkkk(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
419  st16 k = data[0] & 0x0FFF;
420  k *= 2;
421  if (k & 0x1000) {
422  // manually extend signed value
423  k |= 0xF000;
424  k = -(~k) + 1;
425  } else {
426  k += 2;
427  }
428 
429  pc += k;
430 
431  aop->mnemonic = id;
432  aop->param[0] = pc;
433  rz_strbuf_setf(sb, "%s 0x%" PFMT64x, name, pc);
434  return 2;
435 }
436 
437 
438 static ut32 avr_rrrrrcbbb(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
439  ut16 b = data[0] & 0x0007;
440  ut16 Rr = ((data[0] & 0x01F0) >> 4);
441 
442  aop->mnemonic = id;
443  aop->param[0] = Rr;
444  aop->param[1] = b;
445  rz_strbuf_setf(sb, "%s r%u, %u", name, Rr, b);
446  return 2;
447 }
448 
449 
450 static ut32 avr_ddddcccc(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
451  ut16 Rd = 16 + ((data[0] & 0x00F0) >> 4);
452 
453  aop->mnemonic = id;
454  aop->param[0] = Rd;
455  rz_strbuf_setf(sb, "%s r%u", name, Rd);
456  return 2;
457 }
458 
459 
460 static ut32 avr_spmz(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
461  aop->mnemonic = id;
462  aop->param[0] = 'Z';
463  aop->param[1] = '+';
464  rz_strbuf_setf(sb, "%s Z+", name);
465  return 2;
466 }
467 
468 
469 static ut32 avr_rrrrrcccc_x(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
470  ut16 Rr = ((data[0] & 0x01F0) >> 4);
471 
472  aop->mnemonic = id;
473  aop->param[0] = Rr;
474  aop->param[1] = 'X';
475  rz_strbuf_setf(sb, "%s X, r%u", name, Rr);
476  return 2;
477 }
478 
479 
480 static ut32 avr_rrrrrcccc_xp(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
481  ut16 Rr = ((data[0] & 0x01F0) >> 4);
482 
483  aop->mnemonic = id;
484  aop->param[0] = Rr;
485  aop->param[1] = 'X';
486  aop->param[2] = '+';
487  aop->param[3] = 1;
488  rz_strbuf_setf(sb, "%s X+1, r%u", name, Rr);
489  return 2;
490 }
491 
492 
493 static ut32 avr_rrrrrcccc_xm(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
494  ut16 Rr = ((data[0] & 0x01F0) >> 4);
495 
496  aop->mnemonic = id;
497  aop->param[0] = Rr;
498  aop->param[1] = 'X';
499  aop->param[2] = '-';
500  aop->param[3] = 1;
501  rz_strbuf_setf(sb, "%s -X, r%u", name, Rr);
502  return 2;
503 }
504 
505 
506 static ut32 avr_rrrrrcccc_y(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
507  ut16 Rr = ((data[0] & 0x01F0) >> 4);
508 
509  aop->mnemonic = id;
510  aop->param[0] = Rr;
511  aop->param[1] = 'Y';
512  rz_strbuf_setf(sb, "%s Y, r%u", name, Rr);
513  return 2;
514 }
515 
516 
517 static ut32 avr_rrrrrcccc_yp(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
518  ut16 Rr = ((data[0] & 0x01F0) >> 4);
519 
520  aop->mnemonic = id;
521  aop->param[0] = Rr;
522  aop->param[1] = 'Y';
523  aop->param[2] = '+';
524  aop->param[3] = 1;
525  rz_strbuf_setf(sb, "%s Y+1, r%u", name, Rr);
526  return 2;
527 }
528 
529 
530 static ut32 avr_rrrrrcccc_ym(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
531  ut16 Rr = ((data[0] & 0x01F0) >> 4);
532 
533  aop->mnemonic = id;
534  aop->param[0] = Rr;
535  aop->param[1] = 'Y';
536  aop->param[2] = '-';
537  aop->param[3] = 1;
538  rz_strbuf_setf(sb, "%s -Y, r%u", name, Rr);
539  return 2;
540 }
541 
542 
544  ut16 q = data[0] & 0x0007;
545  ut16 Rr = ((data[0] & 0x01F0) >> 4);
546  q |= ((data[0] & 0x0C00) >> 7);
547  q |= ((data[0] & 0x2000) >> 8);
548 
549  aop->mnemonic = id;
550  aop->param[0] = Rr;
551  aop->param[1] = 'Y';
552  aop->param[2] = '+';
553  aop->param[3] = q;
554  rz_strbuf_setf(sb, "%s Y+%u, r%u", name, q, Rr);
555  return 2;
556 }
557 
558 
559 static ut32 avr_rrrrrcccc_z(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
560  ut16 Rr = ((data[0] & 0x01F0) >> 4);
561 
562  aop->mnemonic = id;
563  aop->param[0] = Rr;
564  aop->param[1] = 'Z';
565  rz_strbuf_setf(sb, "%s Z, r%u", name, Rr);
566  return 2;
567 }
568 
569 
570 static ut32 avr_rrrrrcccc_zp(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
571  ut16 Rr = ((data[0] & 0x01F0) >> 4);
572 
573  aop->mnemonic = id;
574  aop->param[0] = Rr;
575  aop->param[1] = 'Z';
576  aop->param[2] = '+';
577  aop->param[3] = 1;
578  rz_strbuf_setf(sb, "%s Z+1, r%u", name, Rr);
579  return 2;
580 }
581 
582 
583 static ut32 avr_rrrrrcccc_zm(cchar* name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb) {
584  ut16 Rr = ((data[0] & 0x01F0) >> 4);
585 
586  aop->mnemonic = id;
587  aop->param[0] = Rr;
588  aop->param[1] = 'Z';
589  aop->param[2] = '-';
590  aop->param[3] = 1;
591  rz_strbuf_setf(sb, "%s -Z, r%u", name, Rr);
592  return 2;
593 }
594 
595 
597  ut16 q = data[0] & 0x0007;
598  ut16 Rr = ((data[0] & 0x01F0) >> 4);
599  q |= ((data[0] & 0x0C00) >> 7);
600  q |= ((data[0] & 0x2000) >> 8);
601 
602  aop->mnemonic = id;
603  aop->param[0] = Rr;
604  aop->param[1] = 'Z';
605  aop->param[2] = '+';
606  aop->param[3] = q;
607  rz_strbuf_setf(sb, "%s Z+%u, r%u", name, q, Rr);
608  return 2;
609 }
610 
611 
613  ut16 Rd = ((data[0] & 0x01F0) >> 4);
614 
615  aop->mnemonic = id;
616  aop->param[0] = data[1];
617  aop->param[1] = Rd;
618  rz_strbuf_setf(sb, "%s 0x%02x, r%u", name, data[1], Rd);
619  return 4;
620 }
621 
622 
624  ut16 k = data[0] & 0x000F;
625  ut16 Rd = 16 + ((data[0] & 0x00F0) >> 4);
626  k |= ((data[0] & 0x0700) >> 4);
627 
628  aop->mnemonic = id;
629  aop->param[0] = k;
630  aop->param[1] = Rd;
631  rz_strbuf_setf(sb, "%s 0x%02x, r%u", name, k, Rd);
632  return 2;
633 }
634 
635 
636 static const AvrInstruction instructions[] = {
637  { "adc", AVR_OP_ADC /* 000111rdddddrrrr */, 2, 0x1C00, 0xFC00, 2, avr_rdddddrrrr },
638  { "add", AVR_OP_ADD /* 000011rdddddrrrr */, 2, 0x0C00, 0xFC00, 2, avr_rdddddrrrr },
639  { "adiw", AVR_OP_ADIW /* 10010110KKddKKKK */, 2, 0x9600, 0xFF00, 2, avr_KKddKKKK },
640  { "and", AVR_OP_AND /* 001000rdddddrrrr */, 2, 0x2000, 0xFC00, 2, avr_rdddddrrrr },
641  { "andi", AVR_OP_ANDI /* 0111KKKKddddKKKK */, 2, 0x7000, 0xF000, 2, avr_KKKKddddKKKK },
642  { "asr", AVR_OP_ASR /* 1001010ddddd0101 */, 2, 0x9405, 0xFE0F, 2, avr_dddddcccc },
643  { "bld", AVR_OP_BLD /* 1111100ddddd0bbb */, 2, 0xF800, 0xFE08, 2, avr_dddddcbbb },
644  { "brcc", AVR_OP_BRCC /* 111101kkkkkkk000 */, 1, 0xF400, 0xFC07, 2, avr_kkkkkkkccc },
645  { "brcs", AVR_OP_BRCS /* 111100kkkkkkk000 */, 1, 0xF000, 0xFC07, 2, avr_kkkkkkkccc },
646  { "break", AVR_OP_BREAK /* 1001010110011000 */, 1, 0x9598, 0xFFFF, 2, avr_unique },
647  { "breq", AVR_OP_BREQ /* 111100kkkkkkk001 */, 1, 0xF001, 0xFC07, 2, avr_kkkkkkkccc },
648  { "brge", AVR_OP_BRGE /* 111101kkkkkkk100 */, 1, 0xF404, 0xFC07, 2, avr_kkkkkkkccc },
649  { "brhc", AVR_OP_BRHC /* 111101kkkkkkk101 */, 1, 0xF405, 0xFC07, 2, avr_kkkkkkkccc },
650  { "brhs", AVR_OP_BRHS /* 111100kkkkkkk101 */, 1, 0xF005, 0xFC07, 2, avr_kkkkkkkccc },
651  { "brid", AVR_OP_BRID /* 111101kkkkkkk111 */, 1, 0xF407, 0xFC07, 2, avr_kkkkkkkccc },
652  { "brie", AVR_OP_BRIE /* 111100kkkkkkk111 */, 1, 0xF007, 0xFC07, 2, avr_kkkkkkkccc },
653  { "brlo", AVR_OP_BRLO /* 111100kkkkkkk000 */, 1, 0xF000, 0xFC07, 2, avr_kkkkkkkccc },
654  { "brlt", AVR_OP_BRLT /* 111100kkkkkkk100 */, 1, 0xF004, 0xFC07, 2, avr_kkkkkkkccc },
655  { "brmi", AVR_OP_BRMI /* 111100kkkkkkk010 */, 1, 0xF002, 0xFC07, 2, avr_kkkkkkkccc },
656  { "brne", AVR_OP_BRNE /* 111101kkkkkkk001 */, 1, 0xF401, 0xFC07, 2, avr_kkkkkkkccc },
657  { "brpl", AVR_OP_BRPL /* 111101kkkkkkk010 */, 1, 0xF402, 0xFC07, 2, avr_kkkkkkkccc },
658  { "brsh", AVR_OP_BRSH /* 111101kkkkkkk000 */, 1, 0xF400, 0xFC07, 2, avr_kkkkkkkccc },
659  { "brtc", AVR_OP_BRTC /* 111101kkkkkkk110 */, 1, 0xF406, 0xFC07, 2, avr_kkkkkkkccc },
660  { "brts", AVR_OP_BRTS /* 111100kkkkkkk110 */, 1, 0xF006, 0xFC07, 2, avr_kkkkkkkccc },
661  { "brvc", AVR_OP_BRVC /* 111101kkkkkkk011 */, 1, 0xF403, 0xFC07, 2, avr_kkkkkkkccc },
662  { "brvs", AVR_OP_BRVS /* 111100kkkkkkk011 */, 1, 0xF003, 0xFC07, 2, avr_kkkkkkkccc },
663  { "bst", AVR_OP_BST /* 1111101ddddd0bbb */, 2, 0xFA00, 0xFE08, 2, avr_dddddcbbb },
664  { "call", AVR_OP_CALL /* 1001010kkkkk111k kkkkkkkkkkkkkkkk */, 4, 0x940E, 0xFE0E, 4, avr_kkkkkccck },
665  { "cbi", AVR_OP_CBI /* 10011000AAAAAbbb */, 2, 0x9800, 0xFF00, 2, avr_AAAAAbbb },
666  { "clc", AVR_OP_CLC /* 1001010010001000 */, 2, 0x9488, 0xFFFF, 2, avr_unique },
667  { "clh", AVR_OP_CLH /* 1001010011011000 */, 2, 0x94D8, 0xFFFF, 2, avr_unique },
668  { "cli", AVR_OP_CLI /* 1001010011111000 */, 2, 0x94F8, 0xFFFF, 2, avr_unique },
669  { "cln", AVR_OP_CLN /* 1001010010101000 */, 2, 0x94A8, 0xFFFF, 2, avr_unique },
670  { "cls", AVR_OP_CLS /* 1001010011001000 */, 2, 0x94C8, 0xFFFF, 2, avr_unique },
671  { "clt", AVR_OP_CLT /* 1001010011101000 */, 2, 0x94E8, 0xFFFF, 2, avr_unique },
672  { "clv", AVR_OP_CLV /* 1001010010111000 */, 2, 0x94B8, 0xFFFF, 2, avr_unique },
673  { "clz", AVR_OP_CLZ /* 1001010010011000 */, 2, 0x9498, 0xFFFF, 2, avr_unique },
674  { "com", AVR_OP_COM /* 1001010ddddd0000 */, 2, 0x9400, 0xFE0F, 2, avr_dddddcccc },
675  { "cp", AVR_OP_CP /* 000101rdddddrrrr */, 2, 0x1400, 0xFC00, 2, avr_rdddddrrrr },
676  { "cpc", AVR_OP_CPC /* 000001rdddddrrrr */, 2, 0x0400, 0xFC00, 2, avr_rdddddrrrr },
677  { "cpi", AVR_OP_CPI /* 0011KKKKddddKKKK */, 2, 0x3000, 0xF000, 2, avr_KKKKddddKKKK },
678  { "cpse", AVR_OP_CPSE /* 000100rdddddrrrr */, 1, 0x1000, 0xFC00, 2, avr_rdddddrrrr },
679  { "dec", AVR_OP_DEC /* 1001010ddddd1010 */, 2, 0x940A, 0xFE0F, 2, avr_dddddcccc },
680  { "des", AVR_OP_DES /* 10010100KKKK1011 */, 1, 0x940B, 0xFF0F, 2, avr_KKKKcccc },
681  { "eicall", AVR_OP_EICALL /* 1001010100011001 */, 4, 0x9519, 0xFFFF, 2, avr_unique },
682  { "eijmp", AVR_OP_EIJMP /* 1001010000011001 */, 2, 0x9419, 0xFFFF, 2, avr_unique },
683  { "elpm", AVR_OP_ELPM /* 1001010111011000 */, 2, 0x95D8, 0xFFFF, 2, avr_unique },
684  { "elpm", AVR_OP_ELPM /* 1001000ddddd0110 */, 2, 0x9006, 0xFE0F, 2, avr_dddddcccc_z },
685  { "elpm", AVR_OP_ELPM /* 1001000ddddd0111 */, 2, 0x9007, 0xFE0F, 2, avr_dddddcccc_zp },
686  { "eor", AVR_OP_EOR /* 001001rdddddrrrr */, 2, 0x2400, 0xFC00, 2, avr_rdddddrrrr },
687  { "fmul", AVR_OP_FMUL /* 000000110ddd1rrr */, 2, 0x0308, 0xFF88, 2, avr_dddcrrr },
688  { "fmuls", AVR_OP_FMULS /* 000000111ddd0rrr */, 2, 0x0380, 0xFF88, 2, avr_dddcrrr },
689  { "fmulsu", AVR_OP_FMULSU /* 000000111ddd1rrr */, 2, 0x0388, 0xFF88, 2, avr_dddcrrr },
690  { "icall", AVR_OP_ICALL /* 1001010100001001 */, 2, 0x9509, 0xFFFF, 2, avr_unique },
691  { "ijmp", AVR_OP_IJMP /* 1001010000001001 */, 2, 0x9409, 0xFFFF, 2, avr_unique },
692  { "in", AVR_OP_IN /* 10110AAdddddAAAA */, 2, 0xB000, 0xF800, 2, avr_AAdddddAAAA },
693  { "inc", AVR_OP_INC /* 1001010ddddd0011 */, 2, 0x9403, 0xFE0F, 2, avr_dddddcccc },
694  { "jmp", AVR_OP_JMP /* 1001010kkkkk110k kkkkkkkkkkkkkkkk */, 3, 0x940C, 0xFE0E, 4, avr_kkkkkccck },
695  { "lac", AVR_OP_LAC /* 1001001rrrrr0110 */, 2, 0x9206, 0xFE0F, 2, avr_rrrrrcccc_z },
696  { "las", AVR_OP_LAS /* 1001001rrrrr0101 */, 2, 0x9205, 0xFE0F, 2, avr_rrrrrcccc_z },
697  { "lat", AVR_OP_LAT /* 1001001rrrrr0111 */, 2, 0x9207, 0xFE0F, 2, avr_rrrrrcccc_z },
698  { "ld", AVR_OP_LD /* 1001000ddddd1100 */, 2, 0x900C, 0xFE0F, 2, avr_dddddcccc_x },
699  { "ld", AVR_OP_LD /* 1001000ddddd1101 */, 2, 0x900D, 0xFE0F, 2, avr_dddddcccc_xp },
700  { "ld", AVR_OP_LD /* 1001000ddddd1110 */, 2, 0x900E, 0xFE0F, 2, avr_dddddcccc_xm },
701  { "ld", AVR_OP_LD /* 1000000ddddd1000 */, 2, 0x8008, 0xFE0F, 2, avr_dddddcccc_y },
702  { "ld", AVR_OP_LD /* 1001000ddddd1001 */, 2, 0x9009, 0xFE0F, 2, avr_dddddcccc_yp },
703  { "ld", AVR_OP_LD /* 1001000ddddd1010 */, 2, 0x900A, 0xFE0F, 2, avr_dddddcccc_ym },
704  { "ldd", AVR_OP_LDD /* 10q0qq0ddddd1qqq */, 2, 0x8008, 0xD208, 2, avr_qcqqcdddddcqqq_y },
705  { "ld", AVR_OP_LD /* 1001000ddddd0000 */, 2, 0x8000, 0xFE0F, 2, avr_dddddcccc_z },
706  { "ld", AVR_OP_LD /* 1001000ddddd0001 */, 2, 0x9001, 0xFE0F, 2, avr_dddddcccc_zp },
707  { "ld", AVR_OP_LD /* 1001000ddddd0010 */, 2, 0x9002, 0xFE0F, 2, avr_dddddcccc_zm },
708  { "ldd", AVR_OP_LDD /* 10q0qq0ddddd0qqq */, 3, 0x8000, 0xD208, 2, avr_qcqqcdddddcqqq_z },
709  { "ldi", AVR_OP_LDI /* 1110KKKKddddKKKK */, 2, 0xE000, 0xF000, 2, avr_KKKKddddKKKK },
710  { "lds", AVR_OP_LDS /* 1001000ddddd0000 kkkkkkkkkkkkkkkk */, 4, 0x9000, 0xFE0F, 4, avr_dddddcccc_load32 },
711  { "lds", AVR_OP_LDS /* 10100kkkddddkkkk */, 2, 0xA000, 0xF800, 2, avr_kkkddddkkkk_load16 },
712  { "lpm", AVR_OP_LPM /* 1001010111001000 */, 2, 0x95C8, 0xFFFF, 2, avr_unique },
713  { "lpm", AVR_OP_LPM /* 1001000ddddd0100 */, 2, 0x9004, 0xFE0F, 2, avr_dddddcccc_z },
714  { "lpm", AVR_OP_LPM /* 1001000ddddd0101 */, 2, 0x9005, 0xFE0F, 2, avr_dddddcccc_zp },
715  { "lsr", AVR_OP_LSR /* 1001010ddddd0110 */, 2, 0x9406, 0xFE0F, 2, avr_dddddcccc },
716  { "mov", AVR_OP_MOV /* 001011rdddddrrrr */, 2, 0x2C00, 0xFC00, 2, avr_rdddddrrrr },
717  { "movw", AVR_OP_MOVW /* 00000001ddddrrrr */, 2, 0x0100, 0xFF00, 2, avr_ddddrrrr },
718  { "mul", AVR_OP_MUL /* 100111rdddddrrrr */, 2, 0x9C00, 0xFC00, 2, avr_rdddddrrrr },
719  { "muls", AVR_OP_MULS /* 00000010ddddrrrr */, 2, 0x0200, 0xFF00, 2, avr_ddddrrrr_2x },
720  { "mulsu", AVR_OP_MULSU /* 000000110ddd0rrr */, 2, 0x0300, 0xFF88, 2, avr_dddcrrr },
721  { "neg", AVR_OP_NEG /* 1001010ddddd0001 */, 2, 0x9401, 0xFE0F, 2, avr_dddddcccc },
722  { "nop", AVR_OP_NOP /* 0000000000000000 */, 2, 0x0000, 0xFFFF, 2, avr_unique },
723  { "or", AVR_OP_OR /* 001010rdddddrrrr */, 2, 0x2800, 0xFC00, 2, avr_rdddddrrrr },
724  { "ori", AVR_OP_ORI /* 0110KKKKddddKKKK */, 2, 0x6000, 0xF000, 2, avr_KKKKddddKKKK },
725  { "out", AVR_OP_OUT /* 10111AArrrrrAAAA */, 2, 0xB800, 0xF800, 2, avr_AArrrrrAAAA },
726  { "pop", AVR_OP_POP /* 1001000ddddd1111 */, 2, 0x900F, 0xFE0F, 2, avr_dddddcccc },
727  { "push", AVR_OP_PUSH /* 1001001ddddd1111 */, 2, 0x920F, 0xFE0F, 2, avr_dddddcccc },
728  { "rcall", AVR_OP_RCALL /* 1101kkkkkkkkkkkk */, 4, 0xD000, 0xF000, 2, avr_kkkkkkkkkkkk },
729  { "ret", AVR_OP_RET /* 1001010100001000 */, 2, 0x9508, 0xFFFF, 2, avr_unique },
730  { "reti", AVR_OP_RETI /* 1001010100011000 */, 2, 0x9518, 0xFFFF, 2, avr_unique },
731  { "rjmp", AVR_OP_RJMP /* 1100kkkkkkkkkkkk */, 2, 0xC000, 0xF000, 2, avr_kkkkkkkkkkkk },
732  { "ror", AVR_OP_ROR /* 1001010ddddd0111 */, 2, 0x9407, 0xFE0F, 2, avr_dddddcccc },
733  { "sbc", AVR_OP_SBC /* 000010rdddddrrrr */, 2, 0x0800, 0xFC00, 2, avr_rdddddrrrr },
734  { "sbci", AVR_OP_SBCI /* 0100KKKKddddKKKK */, 2, 0x4000, 0xF000, 2, avr_KKKKddddKKKK },
735  { "sbi", AVR_OP_SBI /* 10011010AAAAAbbb */, 1, 0x9A00, 0xFF00, 2, avr_AAAAAbbb },
736  { "sbic", AVR_OP_SBIC /* 10011001AAAAAbbb */, 1, 0x9900, 0xFF00, 2, avr_AAAAAbbb },
737  { "sbis", AVR_OP_SBIS /* 10011011AAAAAbbb */, 1, 0x9B00, 0xFF00, 2, avr_AAAAAbbb },
738  { "sbiw", AVR_OP_SBIW /* 10010111KKddKKKK */, 1, 0x9700, 0xFF00, 2, avr_KKddKKKK },
739  { "sbrc", AVR_OP_SBRC /* 1111110rrrrr0bbb */, 1, 0xFC00, 0xFE08, 2, avr_rrrrrcbbb },
740  { "sbrs", AVR_OP_SBRS /* 1111111rrrrr0bbb */, 1, 0xFE00, 0xFE08, 2, avr_rrrrrcbbb },
741  { "sec", AVR_OP_SEC /* 1001010000001000 */, 2, 0x9408, 0xFFFF, 2, avr_unique },
742  { "seh", AVR_OP_SEH /* 1001010001011000 */, 2, 0x9458, 0xFFFF, 2, avr_unique },
743  { "sei", AVR_OP_SEI /* 1001010001111000 */, 2, 0x9478, 0xFFFF, 2, avr_unique },
744  { "sen", AVR_OP_SEN /* 1001010000101000 */, 2, 0x9428, 0xFFFF, 2, avr_unique },
745  { "ser", AVR_OP_SER /* 11101111dddd1111 */, 2, 0xEF0F, 0xFF0F, 2, avr_ddddcccc },
746  { "ses", AVR_OP_SES /* 1001010001001000 */, 2, 0x9448, 0xFFFF, 2, avr_unique },
747  { "set", AVR_OP_SET /* 1001010001101000 */, 2, 0x9468, 0xFFFF, 2, avr_unique },
748  { "sev", AVR_OP_SEV /* 1001010000111000 */, 2, 0x9438, 0xFFFF, 2, avr_unique },
749  { "sez", AVR_OP_SEZ /* 1001010000011000 */, 2, 0x9418, 0xFFFF, 2, avr_unique },
750  { "sleep", AVR_OP_SLEEP /* 1001010110001000 */, 2, 0x9588, 0xFFFF, 2, avr_unique },
751  { "spm", AVR_OP_SPM /* 1001010111101000 */, 1, 0x95E8, 0xFFFF, 2, avr_unique },
752  { "spm", AVR_OP_SPM /* 1001010111111000 */, 1, 0x95F8, 0xFFFF, 2, avr_spmz },
753  { "st", AVR_OP_ST /* 1001001rrrrr1100 */, 2, 0x920C, 0xFE0F, 2, avr_rrrrrcccc_x },
754  { "st", AVR_OP_ST /* 1001001rrrrr1101 */, 2, 0x920D, 0xFE0F, 2, avr_rrrrrcccc_xp },
755  { "st", AVR_OP_ST /* 1001001rrrrr1110 */, 2, 0x920E, 0xFE0F, 2, avr_rrrrrcccc_xm },
756  { "st", AVR_OP_ST /* 1000001rrrrr1000 */, 2, 0x8208, 0xFE0F, 2, avr_rrrrrcccc_y },
757  { "st", AVR_OP_ST /* 1001001rrrrr1001 */, 2, 0x9209, 0xFE0F, 2, avr_rrrrrcccc_yp },
758  { "st", AVR_OP_ST /* 1001001rrrrr1010 */, 2, 0x920A, 0xFE0F, 2, avr_rrrrrcccc_ym },
759  { "std", AVR_OP_STD /* 10q0qq1rrrrr1qqq */, 2, 0x8208, 0xD208, 2, avr_qcqqcrrrrrcqqq_y },
760  { "st", AVR_OP_ST /* 1000001rrrrr0000 */, 2, 0x8200, 0xFE0F, 2, avr_rrrrrcccc_z },
761  { "st", AVR_OP_ST /* 1001001rrrrr0001 */, 2, 0x9201, 0xFE0F, 2, avr_rrrrrcccc_zp },
762  { "st", AVR_OP_ST /* 1001001rrrrr0010 */, 2, 0x9202, 0xFE0F, 2, avr_rrrrrcccc_zm },
763  { "std", AVR_OP_STD /* 10q0qq1rrrrr0qqq */, 2, 0x8200, 0xD208, 2, avr_qcqqcrrrrrcqqq_z },
764  { "sts", AVR_OP_STS /* 1001001ddddd0000 kkkkkkkkkkkkkkkk */, 2, 0x9200, 0xFE0F, 4, avr_dddddcccc_store32 },
765  { "sts", AVR_OP_STS /* 10101kkkddddkkkk */, 2, 0xA800, 0xF800, 2, avr_kkkddddkkkk_store16 },
766  { "sub", AVR_OP_SUB /* 000110rdddddrrrr */, 2, 0x1800, 0xFC00, 2, avr_rdddddrrrr },
767  { "subi", AVR_OP_SUBI /* 0101KKKKddddKKKK */, 2, 0x5000, 0xF000, 2, avr_KKKKddddKKKK },
768  { "swap", AVR_OP_SWAP /* 1001010ddddd0010 */, 2, 0x9402, 0xFE0F, 2, avr_dddddcccc },
769  { "wdr", AVR_OP_WDR /* 1001010110101000 */, 2, 0x95A8, 0xFFFF, 2, avr_unique },
770  { "xch", AVR_OP_XCH /* 1001001rrrrr0100 */, 2, 0x9204, 0xFE0F, 2, avr_rrrrrcccc_z }
771 };
772 
773 ut32 avr_disassembler(const ut8 *buffer, const ut32 size, ut64 pc, bool be, AVROp *aop, RzStrBuf *sb) {
774  rz_return_val_if_fail(buffer && size && aop && sb, false);
775  if (size < 2) {
776  return AVR_INVALID_SIZE;
777  }
778 
779  ut16 masked;
780  ut16 data[2] = {0};
781 
782  data[0] = rz_read_ble16(buffer, be);
783 
784  memset(aop, 0, sizeof(AVROp));
785  for (ut32 i = 0; i < RZ_ARRAY_SIZE(instructions); ++i) {
786  masked = data[0] & instructions[i].mbits;
787  if (masked == instructions[i].cbits) {
788  if (instructions[i].opsize > 2) {
789  if (size < instructions[i].opsize) {
790  return AVR_INVALID_SIZE;
791  }
792  data[1] = be ? rz_read_at_be16(buffer, 2) : rz_read_at_le16(buffer, 2);
793  }
794  const char *name = instructions[i].name;
795  AVROpMnem id = instructions[i].id;
796  aop->size = instructions[i].decode(name, id, data, pc, aop, sb);
797  aop->mask = instructions[i].mbits;
798  return aop->size;
799  }
800  }
801  return AVR_INVALID_SIZE;
802 }
lzma_index ** i
Definition: index.h:629
#define A(x)
Definition: arc.h:165
static ut32 avr_qcqqcrrrrrcqqq_z(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:596
static ut32 avr_qcqqcdddddcqqq_y(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:309
static ut32 avr_rrrrrcccc_xp(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:480
static const AvrInstruction instructions[]
Definition: disassembler.c:636
static ut32 avr_spmz(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:460
static ut32 avr_kkkkkkkkkkkk(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:418
static ut32 avr_kkkkkccck(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:149
static ut32 avr_unique(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:35
static ut32 avr_rrrrrcccc_z(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:559
static ut32 avr_dddddcccc_yp(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:283
static ut32 avr_dddddcccc_ym(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:296
static ut32 avr_qcqqcdddddcqqq_z(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:338
static ut32 avr_dddddcccc_y(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:272
static ut32 avr_qcqqcrrrrrcqqq_y(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:543
static ut32 avr_dddcrrr(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:210
static ut32 avr_AArrrrrAAAA(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:405
ut32 avr_disassembler(const ut8 *buffer, const ut32 size, ut64 pc, bool be, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:773
static ut32 avr_KKKKddddKKKK(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:89
static ut32 avr_AAdddddAAAA(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:222
static ut32 avr_ddddcccc(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:450
static ut32 avr_dddddcccc_zp(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:197
static ut32 avr_ddddrrrr_2x(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:391
static ut32 avr_rdddddrrrr(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:41
static ut32 avr_ddddrrrr(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:376
static ut32 avr_dddddcccc_xm(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:259
static ut32 avr_kkkkkkkccc(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:130
static ut32 avr_dddddcccc_store32(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:612
static ut32 avr_dddddcccc_zm(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:325
static ut32 avr_kkkddddkkkk_load16(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:364
static ut32 avr_dddddcccc_z(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:186
static ut32 avr_dddddcccc_xp(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:246
static ut32 avr_rrrrrcccc_zp(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:570
static ut32 avr_dddddcccc_x(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:235
static ut32 avr_rrrrrcccc_y(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:506
static ut32 avr_KKddKKKK(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:75
static ut32 avr_KKKKcccc(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:176
static ut32 avr_rrrrrcccc_zm(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:583
static ut32 avr_rrrrrcbbb(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:438
ut32(* Decode)(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:23
static ut32 avr_dddddcbbb(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:118
static ut32 avr_rrrrrcccc_xm(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:493
static ut32 avr_AAAAAbbb(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:164
static ut32 avr_rrrrrcccc_ym(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:530
static ut32 avr_rrrrrcccc_yp(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:517
static ut32 avr_dddddcccc(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:108
static ut32 avr_kkkddddkkkk_store16(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:623
struct avr_decoder_t AvrInstruction
static ut32 avr_rrrrrcccc_x(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:469
static ut32 avr_dddddcccc_load32(cchar *name, AVROpMnem id, ut16 data[2], ut64 pc, AVROp *aop, RzStrBuf *sb)
Definition: disassembler.c:354
AVROpMnem
Definition: disassembler.h:9
@ AVR_OP_AND
Definition: disassembler.h:14
@ AVR_OP_INC
Definition: disassembler.h:66
@ AVR_OP_BREAK
Definition: disassembler.h:20
@ AVR_OP_DEC
Definition: disassembler.h:54
@ AVR_OP_BRNE
Definition: disassembler.h:30
@ AVR_OP_MUL
Definition: disassembler.h:80
@ AVR_OP_CP
Definition: disassembler.h:50
@ AVR_OP_CPC
Definition: disassembler.h:51
@ AVR_OP_SPM
Definition: disassembler.h:114
@ AVR_OP_IJMP
Definition: disassembler.h:64
@ AVR_OP_LDD
Definition: disassembler.h:72
@ AVR_OP_FMULSU
Definition: disassembler.h:62
@ AVR_OP_LAT
Definition: disassembler.h:70
@ AVR_OP_BRSH
Definition: disassembler.h:32
@ AVR_OP_SWAP
Definition: disassembler.h:120
@ AVR_OP_CBI
Definition: disassembler.h:39
@ AVR_OP_LSR
Definition: disassembler.h:77
@ AVR_OP_SBCI
Definition: disassembler.h:97
@ AVR_OP_BRGE
Definition: disassembler.h:22
@ AVR_OP_ADIW
Definition: disassembler.h:13
@ AVR_OP_CPSE
Definition: disassembler.h:53
@ AVR_OP_SBRC
Definition: disassembler.h:102
@ AVR_OP_ASR
Definition: disassembler.h:16
@ AVR_OP_CLH
Definition: disassembler.h:41
@ AVR_OP_CLZ
Definition: disassembler.h:48
@ AVR_OP_SEN
Definition: disassembler.h:107
@ AVR_OP_ADC
Definition: disassembler.h:11
@ AVR_OP_BRPL
Definition: disassembler.h:31
@ AVR_OP_BRLT
Definition: disassembler.h:28
@ AVR_OP_MOVW
Definition: disassembler.h:79
@ AVR_OP_CLT
Definition: disassembler.h:46
@ AVR_OP_NOP
Definition: disassembler.h:84
@ AVR_OP_BRCS
Definition: disassembler.h:19
@ AVR_OP_MOV
Definition: disassembler.h:78
@ AVR_OP_EOR
Definition: disassembler.h:59
@ AVR_OP_SEI
Definition: disassembler.h:106
@ AVR_OP_SES
Definition: disassembler.h:109
@ AVR_OP_BRTS
Definition: disassembler.h:34
@ AVR_OP_LSL
Definition: disassembler.h:76
@ AVR_OP_SEV
Definition: disassembler.h:111
@ AVR_OP_LDI
Definition: disassembler.h:73
@ AVR_OP_SUB
Definition: disassembler.h:118
@ AVR_OP_ROL
Definition: disassembler.h:94
@ AVR_OP_SER
Definition: disassembler.h:108
@ AVR_OP_COM
Definition: disassembler.h:49
@ AVR_OP_ORI
Definition: disassembler.h:86
@ AVR_OP_BRCC
Definition: disassembler.h:18
@ AVR_OP_LDS
Definition: disassembler.h:74
@ AVR_OP_LPM
Definition: disassembler.h:75
@ AVR_OP_RJMP
Definition: disassembler.h:93
@ AVR_OP_STS
Definition: disassembler.h:117
@ AVR_OP_LAS
Definition: disassembler.h:69
@ AVR_OP_SEH
Definition: disassembler.h:105
@ AVR_OP_XCH
Definition: disassembler.h:123
@ AVR_OP_LAC
Definition: disassembler.h:68
@ AVR_OP_ADD
Definition: disassembler.h:12
@ AVR_OP_BRLO
Definition: disassembler.h:27
@ AVR_OP_SBIC
Definition: disassembler.h:99
@ AVR_OP_BRIE
Definition: disassembler.h:26
@ AVR_OP_ST
Definition: disassembler.h:115
@ AVR_OP_BRTC
Definition: disassembler.h:33
@ AVR_OP_ICALL
Definition: disassembler.h:63
@ AVR_OP_SBIW
Definition: disassembler.h:101
@ AVR_OP_FMUL
Definition: disassembler.h:60
@ AVR_OP_CLV
Definition: disassembler.h:47
@ AVR_OP_OUT
Definition: disassembler.h:87
@ AVR_OP_CLN
Definition: disassembler.h:43
@ AVR_OP_CLI
Definition: disassembler.h:42
@ AVR_OP_RETI
Definition: disassembler.h:92
@ AVR_OP_CLS
Definition: disassembler.h:45
@ AVR_OP_SET
Definition: disassembler.h:110
@ AVR_OP_BREQ
Definition: disassembler.h:21
@ AVR_OP_MULS
Definition: disassembler.h:81
@ AVR_OP_ANDI
Definition: disassembler.h:15
@ AVR_OP_BRMI
Definition: disassembler.h:29
@ AVR_OP_SEZ
Definition: disassembler.h:112
@ AVR_OP_ROR
Definition: disassembler.h:95
@ AVR_OP_POP
Definition: disassembler.h:88
@ AVR_OP_BRHS
Definition: disassembler.h:24
@ AVR_OP_SEC
Definition: disassembler.h:104
@ AVR_OP_EIJMP
Definition: disassembler.h:57
@ AVR_OP_OR
Definition: disassembler.h:85
@ AVR_OP_FMULS
Definition: disassembler.h:61
@ AVR_OP_BRHC
Definition: disassembler.h:23
@ AVR_OP_SBIS
Definition: disassembler.h:100
@ AVR_OP_CPI
Definition: disassembler.h:52
@ AVR_OP_TST
Definition: disassembler.h:121
@ AVR_OP_SBI
Definition: disassembler.h:98
@ AVR_OP_RET
Definition: disassembler.h:91
@ AVR_OP_BRVS
Definition: disassembler.h:36
@ AVR_OP_PUSH
Definition: disassembler.h:89
@ AVR_OP_BRID
Definition: disassembler.h:25
@ AVR_OP_SBC
Definition: disassembler.h:96
@ AVR_OP_LD
Definition: disassembler.h:71
@ AVR_OP_CLR
Definition: disassembler.h:44
@ AVR_OP_SBRS
Definition: disassembler.h:103
@ AVR_OP_EICALL
Definition: disassembler.h:56
@ AVR_OP_BRVC
Definition: disassembler.h:35
@ AVR_OP_STD
Definition: disassembler.h:116
@ AVR_OP_ELPM
Definition: disassembler.h:58
@ AVR_OP_DES
Definition: disassembler.h:55
@ AVR_OP_BST
Definition: disassembler.h:37
@ AVR_OP_IN
Definition: disassembler.h:65
@ AVR_OP_NEG
Definition: disassembler.h:83
@ AVR_OP_BLD
Definition: disassembler.h:17
@ AVR_OP_CALL
Definition: disassembler.h:38
@ AVR_OP_WDR
Definition: disassembler.h:122
@ AVR_OP_SUBI
Definition: disassembler.h:119
@ AVR_OP_CLC
Definition: disassembler.h:40
@ AVR_OP_SLEEP
Definition: disassembler.h:113
@ AVR_OP_MULSU
Definition: disassembler.h:82
@ AVR_OP_RCALL
Definition: disassembler.h:90
@ AVR_OP_JMP
Definition: disassembler.h:67
static SblHeader sb
Definition: bin_mbn.c:26
uint16_t ut16
uint32_t ut32
const char * k
Definition: dsignal.c:11
voidpf void uLong size
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
const char cchar
Definition: common.h:9
#define AVR_INVALID_SIZE
Definition: common.h:7
const char * name
Definition: op.c:541
int id
Definition: op.c:540
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static ut16 rz_read_at_le16(const void *src, size_t offset)
Definition: rz_endian.h:214
static ut16 rz_read_ble16(const void *src, bool big_endian)
Definition: rz_endian.h:493
static ut16 rz_read_at_be16(const void *src, size_t offset)
Definition: rz_endian.h:55
RZ_API const char * rz_strbuf_set(RzStrBuf *sb, const char *s)
Definition: strbuf.c:153
RZ_API const char * rz_strbuf_setf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define PFMT64x
Definition: rz_types.h:393
#define st16
Definition: rz_types_base.h:14
#define st32
Definition: rz_types_base.h:12
#define b(i)
Definition: sha256.c:42
cchar * name
Definition: disassembler.c:26
AVROpMnem id
Definition: disassembler.c:27
ut16 param[4]
Definition: disassembler.h:131
AVROpMnem mnemonic
Definition: disassembler.h:129
Definition: buffer.h:15
Definition: z80asm.h:102
Definitions common to the whole liblzma library.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()