Merge tag 'pull-la-20220808' of https://gitlab.com/rth7680/qemu into staging
[qemu.git] / disas / nanomips.cpp
1 /*
2 * Source file for nanoMIPS disassembler component of QEMU
3 *
4 * Copyright (C) 2018 Wave Computing, Inc.
5 * Copyright (C) 2018 Matthew Fortune <matthew.fortune@mips.com>
6 * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 *
21 */
22
23 /*
24 * Documentation used while implementing this component:
25 *
26 * [1] "MIPS® Architecture Base: nanoMIPS32(tm) Instruction Set Technical
27 * Reference Manual", Revision 01.01, April 27, 2018
28 */
29
30 #include "qemu/osdep.h"
31 #include "disas/dis-asm.h"
32
33 #include <cstring>
34 #include <stdexcept>
35 #include <sstream>
36 #include <stdio.h>
37 #include <stdarg.h>
38
39 #include "nanomips.h"
40
41 #define IMGASSERTONCE(test)
42
43
44 int nanomips_dis(char *buf,
45 unsigned address,
46 unsigned short one,
47 unsigned short two,
48 unsigned short three)
49 {
50 std::string disasm;
51 uint16 bits[3] = {one, two, three};
52
53 NMD::TABLE_ENTRY_TYPE type;
54 NMD d(address, NMD::ALL_ATTRIBUTES);
55 int size = d.Disassemble(bits, disasm, type);
56
57 strcpy(buf, disasm.c_str());
58 return size;
59 }
60
61 int print_insn_nanomips(bfd_vma memaddr, struct disassemble_info *info)
62 {
63 int status;
64 bfd_byte buffer[2];
65 uint16_t insn1 = 0, insn2 = 0, insn3 = 0;
66 char buf[200];
67
68 info->bytes_per_chunk = 2;
69 info->display_endian = info->endian;
70 info->insn_info_valid = 1;
71 info->branch_delay_insns = 0;
72 info->data_size = 0;
73 info->insn_type = dis_nonbranch;
74 info->target = 0;
75 info->target2 = 0;
76
77 status = (*info->read_memory_func)(memaddr, buffer, 2, info);
78 if (status != 0) {
79 (*info->memory_error_func)(status, memaddr, info);
80 return -1;
81 }
82
83 if (info->endian == BFD_ENDIAN_BIG) {
84 insn1 = bfd_getb16(buffer);
85 } else {
86 insn1 = bfd_getl16(buffer);
87 }
88 (*info->fprintf_func)(info->stream, "%04x ", insn1);
89
90 /* Handle 32-bit opcodes. */
91 if ((insn1 & 0x1000) == 0) {
92 status = (*info->read_memory_func)(memaddr + 2, buffer, 2, info);
93 if (status != 0) {
94 (*info->memory_error_func)(status, memaddr + 2, info);
95 return -1;
96 }
97
98 if (info->endian == BFD_ENDIAN_BIG) {
99 insn2 = bfd_getb16(buffer);
100 } else {
101 insn2 = bfd_getl16(buffer);
102 }
103 (*info->fprintf_func)(info->stream, "%04x ", insn2);
104 } else {
105 (*info->fprintf_func)(info->stream, " ");
106 }
107 /* Handle 48-bit opcodes. */
108 if ((insn1 >> 10) == 0x18) {
109 status = (*info->read_memory_func)(memaddr + 4, buffer, 2, info);
110 if (status != 0) {
111 (*info->memory_error_func)(status, memaddr + 4, info);
112 return -1;
113 }
114
115 if (info->endian == BFD_ENDIAN_BIG) {
116 insn3 = bfd_getb16(buffer);
117 } else {
118 insn3 = bfd_getl16(buffer);
119 }
120 (*info->fprintf_func)(info->stream, "%04x ", insn3);
121 } else {
122 (*info->fprintf_func)(info->stream, " ");
123 }
124
125 int length = nanomips_dis(buf, memaddr, insn1, insn2, insn3);
126
127 /* FIXME: Should probably use a hash table on the major opcode here. */
128
129 (*info->fprintf_func) (info->stream, "%s", buf);
130 if (length > 0) {
131 return length / 8;
132 }
133
134 info->insn_type = dis_noninsn;
135
136 return insn3 ? 6 : insn2 ? 4 : 2;
137 }
138
139
140 namespace img
141 {
142 address addr32(address a)
143 {
144 return a;
145 }
146
147 std::string format(const char *format, ...)
148 {
149 char buffer[256];
150 va_list args;
151 va_start(args, format);
152 int err = vsprintf(buffer, format, args);
153 if (err < 0) {
154 perror(buffer);
155 }
156 va_end(args);
157 return buffer;
158 }
159
160 std::string format(const char *format,
161 std::string s)
162 {
163 char buffer[256];
164
165 sprintf(buffer, format, s.c_str());
166
167 return buffer;
168 }
169
170 std::string format(const char *format,
171 std::string s1,
172 std::string s2)
173 {
174 char buffer[256];
175
176 sprintf(buffer, format, s1.c_str(), s2.c_str());
177
178 return buffer;
179 }
180
181 std::string format(const char *format,
182 std::string s1,
183 std::string s2,
184 std::string s3)
185 {
186 char buffer[256];
187
188 sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str());
189
190 return buffer;
191 }
192
193 std::string format(const char *format,
194 std::string s1,
195 std::string s2,
196 std::string s3,
197 std::string s4)
198 {
199 char buffer[256];
200
201 sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str(),
202 s4.c_str());
203
204 return buffer;
205 }
206
207 std::string format(const char *format,
208 std::string s1,
209 std::string s2,
210 std::string s3,
211 std::string s4,
212 std::string s5)
213 {
214 char buffer[256];
215
216 sprintf(buffer, format, s1.c_str(), s2.c_str(), s3.c_str(),
217 s4.c_str(), s5.c_str());
218
219 return buffer;
220 }
221
222 std::string format(const char *format,
223 uint64 d,
224 std::string s2)
225 {
226 char buffer[256];
227
228 sprintf(buffer, format, d, s2.c_str());
229
230 return buffer;
231 }
232
233 std::string format(const char *format,
234 std::string s1,
235 uint64 d,
236 std::string s2)
237 {
238 char buffer[256];
239
240 sprintf(buffer, format, s1.c_str(), d, s2.c_str());
241
242 return buffer;
243 }
244
245 std::string format(const char *format,
246 std::string s1,
247 std::string s2,
248 uint64 d)
249 {
250 char buffer[256];
251
252 sprintf(buffer, format, s1.c_str(), s2.c_str(), d);
253
254 return buffer;
255 }
256
257 char as_char(int c)
258 {
259 return static_cast<char>(c);
260 }
261 };
262
263
264 std::string to_string(img::address a)
265 {
266 char buffer[256];
267 sprintf(buffer, "0x%" PRIx64, a);
268 return buffer;
269 }
270
271
272 uint64 extract_bits(uint64 data, uint32 bit_offset, uint32 bit_size)
273 {
274 return (data << (64 - (bit_size + bit_offset))) >> (64 - bit_size);
275 }
276
277
278 int64 sign_extend(int64 data, int msb)
279 {
280 uint64 shift = 63 - msb;
281 return (data << shift) >> shift;
282 }
283
284
285 uint64 NMD::renumber_registers(uint64 index, uint64 *register_list,
286 size_t register_list_size)
287 {
288 if (index < register_list_size) {
289 return register_list[index];
290 }
291
292 throw std::runtime_error(img::format(
293 "Invalid register mapping index %" PRIu64
294 ", size of list = %zu",
295 index, register_list_size));
296 }
297
298
299 /*
300 * NMD::decode_gpr_gpr4() - decoder for 'gpr4' gpr encoding type
301 *
302 * Map a 4-bit code to the 5-bit register space according to this pattern:
303 *
304 * 1 0
305 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
306 * | | | | | | | | | | | | | | | |
307 * | | | | | | | | | | | | | | | |
308 * | | | | | | | | | | | └---------------┐
309 * | | | | | | | | | | └---------------┐ |
310 * | | | | | | | | | └---------------┐ | |
311 * | | | | | | | | └---------------┐ | | |
312 * | | | | | | | | | | | | | | | |
313 * | | | | | | | | | | | | | | | |
314 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
315 * 3 2 1 0
316 *
317 * Used in handling following instructions:
318 *
319 * - ADDU[4X4]
320 * - LW[4X4]
321 * - MOVEP[REV]
322 * - MUL[4X4]
323 * - SW[4X4]
324 */
325 uint64 NMD::decode_gpr_gpr4(uint64 d)
326 {
327 static uint64 register_list[] = { 8, 9, 10, 11, 4, 5, 6, 7,
328 16, 17, 18, 19, 20, 21, 22, 23 };
329 return renumber_registers(d, register_list,
330 sizeof(register_list) / sizeof(register_list[0]));
331 }
332
333
334 /*
335 * NMD::decode_gpr_gpr4_zero() - decoder for 'gpr4.zero' gpr encoding type
336 *
337 * Map a 4-bit code to the 5-bit register space according to this pattern:
338 *
339 * 1 0
340 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
341 * | | | | | | | | | | | | | | | |
342 * | | | | | | | | | | | | └---------------------┐
343 * | | | | | | | | | | | └---------------┐ |
344 * | | | | | | | | | | └---------------┐ | |
345 * | | | | | | | | | └---------------┐ | | |
346 * | | | | | | | | └---------------┐ | | | |
347 * | | | | | | | | | | | | | | | |
348 * | | | | | | | | | | | | | | | |
349 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
350 * 3 2 1 0
351 *
352 * This pattern is the same one used for 'gpr4' gpr encoding type, except for
353 * the input value 3, that is mapped to the output value 0 instead of 11.
354 *
355 * Used in handling following instructions:
356 *
357 * - MOVE.BALC
358 * - MOVEP
359 * - SW[4X4]
360 */
361 uint64 NMD::decode_gpr_gpr4_zero(uint64 d)
362 {
363 static uint64 register_list[] = { 8, 9, 10, 0, 4, 5, 6, 7,
364 16, 17, 18, 19, 20, 21, 22, 23 };
365 return renumber_registers(d, register_list,
366 sizeof(register_list) / sizeof(register_list[0]));
367 }
368
369
370 /*
371 * NMD::decode_gpr_gpr3() - decoder for 'gpr3' gpr encoding type
372 *
373 * Map a 3-bit code to the 5-bit register space according to this pattern:
374 *
375 * 7 6 5 4 3 2 1 0
376 * | | | | | | | |
377 * | | | | | | | |
378 * | | | └-----------------------┐
379 * | | └-----------------------┐ |
380 * | └-----------------------┐ | |
381 * └-----------------------┐ | | |
382 * | | | | | | | |
383 * ┌-------┘ | | | | | | |
384 * | ┌-------┘ | | | | | |
385 * | | ┌-------┘ | | | | |
386 * | | | ┌-------┘ | | | |
387 * | | | | | | | |
388 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
389 * 3 2 1 0
390 *
391 * Used in handling following instructions:
392 *
393 * - ADDIU[R1.SP]
394 * - ADDIU[R2]
395 * - ADDU[16]
396 * - AND[16]
397 * - ANDI[16]
398 * - BEQC[16]
399 * - BEQZC[16]
400 * - BNEC[16]
401 * - BNEZC[16]
402 * - LB[16]
403 * - LBU[16]
404 * - LH[16]
405 * - LHU[16]
406 * - LI[16]
407 * - LW[16]
408 * - LW[GP16]
409 * - LWXS[16]
410 * - NOT[16]
411 * - OR[16]
412 * - SB[16]
413 * - SH[16]
414 * - SLL[16]
415 * - SRL[16]
416 * - SUBU[16]
417 * - SW[16]
418 * - XOR[16]
419 */
420 uint64 NMD::decode_gpr_gpr3(uint64 d)
421 {
422 static uint64 register_list[] = { 16, 17, 18, 19, 4, 5, 6, 7 };
423 return renumber_registers(d, register_list,
424 sizeof(register_list) / sizeof(register_list[0]));
425 }
426
427
428 /*
429 * NMD::decode_gpr_gpr3_src_store() - decoder for 'gpr3.src.store' gpr encoding
430 * type
431 *
432 * Map a 3-bit code to the 5-bit register space according to this pattern:
433 *
434 * 7 6 5 4 3 2 1 0
435 * | | | | | | | |
436 * | | | | | | | └-----------------------┐
437 * | | | └-----------------------┐ |
438 * | | └-----------------------┐ | |
439 * | └-----------------------┐ | | |
440 * └-----------------------┐ | | | |
441 * | | | | | | | |
442 * ┌-------┘ | | | | | | |
443 * | ┌-------┘ | | | | | |
444 * | | ┌-------┘ | | | | |
445 * | | | | | | | |
446 * | | | | | | | |
447 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
448 * 3 2 1 0
449 *
450 * This pattern is the same one used for 'gpr3' gpr encoding type, except for
451 * the input value 0, that is mapped to the output value 0 instead of 16.
452 *
453 * Used in handling following instructions:
454 *
455 * - SB[16]
456 * - SH[16]
457 * - SW[16]
458 * - SW[GP16]
459 */
460 uint64 NMD::decode_gpr_gpr3_src_store(uint64 d)
461 {
462 static uint64 register_list[] = { 0, 17, 18, 19, 4, 5, 6, 7 };
463 return renumber_registers(d, register_list,
464 sizeof(register_list) / sizeof(register_list[0]));
465 }
466
467
468 /*
469 * NMD::decode_gpr_gpr2_reg1() - decoder for 'gpr2.reg1' gpr encoding type
470 *
471 * Map a 2-bit code to the 5-bit register space according to this pattern:
472 *
473 * 3 2 1 0
474 * | | | |
475 * | | | |
476 * | | | └-------------------┐
477 * | | └-------------------┐ |
478 * | └-------------------┐ | |
479 * └-------------------┐ | | |
480 * | | | |
481 * | | | |
482 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
483 * 3 2 1 0
484 *
485 * Used in handling following instructions:
486 *
487 * - MOVEP
488 * - MOVEP[REV]
489 */
490 uint64 NMD::decode_gpr_gpr2_reg1(uint64 d)
491 {
492 static uint64 register_list[] = { 4, 5, 6, 7 };
493 return renumber_registers(d, register_list,
494 sizeof(register_list) / sizeof(register_list[0]));
495 }
496
497
498 /*
499 * NMD::decode_gpr_gpr2_reg2() - decoder for 'gpr2.reg2' gpr encoding type
500 *
501 * Map a 2-bit code to the 5-bit register space according to this pattern:
502 *
503 * 3 2 1 0
504 * | | | |
505 * | | | |
506 * | | | └-----------------┐
507 * | | └-----------------┐ |
508 * | └-----------------┐ | |
509 * └-----------------┐ | | |
510 * | | | |
511 * | | | |
512 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
513 * 3 2 1 0
514 *
515 * Used in handling following instructions:
516 *
517 * - MOVEP
518 * - MOVEP[REV]
519 */
520 uint64 NMD::decode_gpr_gpr2_reg2(uint64 d)
521 {
522 static uint64 register_list[] = { 5, 6, 7, 8 };
523 return renumber_registers(d, register_list,
524 sizeof(register_list) / sizeof(register_list[0]));
525 }
526
527
528 /*
529 * NMD::decode_gpr_gpr1() - decoder for 'gpr1' gpr encoding type
530 *
531 * Map a 1-bit code to the 5-bit register space according to this pattern:
532 *
533 * 1 0
534 * | |
535 * | |
536 * | └---------------------┐
537 * └---------------------┐ |
538 * | |
539 * | |
540 * | |
541 * | |
542 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
543 * 3 2 1 0
544 *
545 * Used in handling following instruction:
546 *
547 * - MOVE.BALC
548 */
549 uint64 NMD::decode_gpr_gpr1(uint64 d)
550 {
551 static uint64 register_list[] = { 4, 5 };
552 return renumber_registers(d, register_list,
553 sizeof(register_list) / sizeof(register_list[0]));
554 }
555
556
557 uint64 NMD::copy(uint64 d)
558 {
559 return d;
560 }
561
562
563 int64 NMD::copy(int64 d)
564 {
565 return d;
566 }
567
568
569 int64 NMD::neg_copy(uint64 d)
570 {
571 return 0ll - d;
572 }
573
574
575 int64 NMD::neg_copy(int64 d)
576 {
577 return -d;
578 }
579
580
581 /* strange wrapper around gpr3 */
582 uint64 NMD::encode_rs3_and_check_rs3_ge_rt3(uint64 d)
583 {
584 return decode_gpr_gpr3(d);
585 }
586
587
588 /* strange wrapper around gpr3 */
589 uint64 NMD::encode_rs3_and_check_rs3_lt_rt3(uint64 d)
590 {
591 return decode_gpr_gpr3(d);
592 }
593
594
595 /* nop - done by extraction function */
596 uint64 NMD::encode_s_from_address(uint64 d)
597 {
598 return d;
599 }
600
601
602 /* nop - done by extraction function */
603 uint64 NMD::encode_u_from_address(uint64 d)
604 {
605 return d;
606 }
607
608
609 /* nop - done by extraction function */
610 uint64 NMD::encode_s_from_s_hi(uint64 d)
611 {
612 return d;
613 }
614
615
616 uint64 NMD::encode_count3_from_count(uint64 d)
617 {
618 IMGASSERTONCE(d < 8);
619 return d == 0ull ? 8ull : d;
620 }
621
622
623 uint64 NMD::encode_shift3_from_shift(uint64 d)
624 {
625 IMGASSERTONCE(d < 8);
626 return d == 0ull ? 8ull : d;
627 }
628
629
630 /* special value for load literal */
631 int64 NMD::encode_eu_from_s_li16(uint64 d)
632 {
633 IMGASSERTONCE(d < 128);
634 return d == 127 ? -1 : (int64)d;
635 }
636
637
638 uint64 NMD::encode_msbd_from_size(uint64 d)
639 {
640 IMGASSERTONCE(d < 32);
641 return d + 1;
642 }
643
644
645 uint64 NMD::encode_eu_from_u_andi16(uint64 d)
646 {
647 IMGASSERTONCE(d < 16);
648 if (d == 12) {
649 return 0x00ffull;
650 }
651 if (d == 13) {
652 return 0xffffull;
653 }
654 return d;
655 }
656
657
658 uint64 NMD::encode_msbd_from_pos_and_size(uint64 d)
659 {
660 IMGASSERTONCE(0);
661 return d;
662 }
663
664
665 /* save16 / restore16 ???? */
666 uint64 NMD::encode_rt1_from_rt(uint64 d)
667 {
668 return d ? 31 : 30;
669 }
670
671
672 /* ? */
673 uint64 NMD::encode_lsb_from_pos_and_size(uint64 d)
674 {
675 return d;
676 }
677
678
679 std::string NMD::save_restore_list(uint64 rt, uint64 count, uint64 gp)
680 {
681 std::string str;
682
683 for (uint64 counter = 0; counter != count; counter++) {
684 bool use_gp = gp && (counter == count - 1);
685 uint64 this_rt = use_gp ? 28 : ((rt & 0x10) | (rt + counter)) & 0x1f;
686 str += img::format(",%s", GPR(this_rt));
687 }
688
689 return str;
690 }
691
692
693 std::string NMD::GPR(uint64 reg)
694 {
695 static const char *gpr_reg[32] = {
696 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
697 "a4", "a5", "a6", "a7", "r12", "r13", "r14", "r15",
698 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
699 "r24", "r25", "k0", "k1", "gp", "sp", "fp", "ra"
700 };
701
702 if (reg < 32) {
703 return gpr_reg[reg];
704 }
705
706 throw std::runtime_error(img::format("Invalid GPR register index %" PRIu64,
707 reg));
708 }
709
710
711 std::string NMD::FPR(uint64 reg)
712 {
713 static const char *fpr_reg[32] = {
714 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
715 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
716 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
717 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"
718 };
719
720 if (reg < 32) {
721 return fpr_reg[reg];
722 }
723
724 throw std::runtime_error(img::format("Invalid FPR register index %" PRIu64,
725 reg));
726 }
727
728
729 std::string NMD::AC(uint64 reg)
730 {
731 static const char *ac_reg[4] = {
732 "ac0", "ac1", "ac2", "ac3"
733 };
734
735 if (reg < 4) {
736 return ac_reg[reg];
737 }
738
739 throw std::runtime_error(img::format("Invalid AC register index %" PRIu64,
740 reg));
741 }
742
743
744 std::string NMD::IMMEDIATE(uint64 value)
745 {
746 return img::format("0x%" PRIx64, value);
747 }
748
749
750 std::string NMD::IMMEDIATE(int64 value)
751 {
752 return img::format("%" PRId64, value);
753 }
754
755
756 std::string NMD::CPR(uint64 reg)
757 {
758 /* needs more work */
759 return img::format("CP%" PRIu64, reg);
760 }
761
762
763 std::string NMD::ADDRESS(uint64 value, int instruction_size)
764 {
765 /* token for string replace */
766 /* const char TOKEN_REPLACE = (char)0xa2; */
767 img::address address = m_pc + value + instruction_size;
768 /* symbol replacement */
769 /* return img::as_char(TOKEN_REPLACE) + to_string(address); */
770 return to_string(address);
771 }
772
773
774 uint64 NMD::extract_op_code_value(const uint16 * data, int size)
775 {
776 switch (size) {
777 case 16:
778 return data[0];
779 case 32:
780 return ((uint64)data[0] << 16) | data[1];
781 case 48:
782 return ((uint64)data[0] << 32) | ((uint64)data[1] << 16) | data[2];
783 default:
784 return data[0];
785 }
786 }
787
788
789 int NMD::Disassemble(const uint16 * data, std::string & dis,
790 NMD::TABLE_ENTRY_TYPE & type)
791 {
792 return Disassemble(data, dis, type, MAJOR, 2);
793 }
794
795
796 /*
797 * Recurse through tables until the instruction is found then return
798 * the string and size
799 *
800 * inputs:
801 * pointer to a word stream,
802 * disassember table and size
803 * returns:
804 * instruction size - negative is error
805 * disassembly string - on error will constain error string
806 */
807 int NMD::Disassemble(const uint16 * data, std::string & dis,
808 NMD::TABLE_ENTRY_TYPE & type, const Pool *table,
809 int table_size)
810 {
811 try
812 {
813 for (int i = 0; i < table_size; i++) {
814 uint64 op_code = extract_op_code_value(data,
815 table[i].instructions_size);
816 if ((op_code & table[i].mask) == table[i].value) {
817 /* possible match */
818 conditional_function cond = table[i].condition;
819 if ((cond == 0) || (this->*cond)(op_code)) {
820 try
821 {
822 if (table[i].type == pool) {
823 return Disassemble(data, dis, type,
824 table[i].next_table,
825 table[i].next_table_size);
826 } else if ((table[i].type == instruction) ||
827 (table[i].type == call_instruction) ||
828 (table[i].type == branch_instruction) ||
829 (table[i].type == return_instruction)) {
830 if ((table[i].attributes != 0) &&
831 (m_requested_instruction_categories &
832 table[i].attributes) == 0) {
833 /*
834 * failed due to instruction having
835 * an ASE attribute and the requested version
836 * not having that attribute
837 */
838 dis = "ASE attribute mismatch";
839 return -5;
840 }
841 disassembly_function dis_fn = table[i].disassembly;
842 if (dis_fn == 0) {
843 dis = "disassembler failure - bad table entry";
844 return -6;
845 }
846 type = table[i].type;
847 dis = (this->*dis_fn)(op_code);
848 return table[i].instructions_size;
849 } else {
850 dis = "reserved instruction";
851 return -2;
852 }
853 }
854 catch (std::runtime_error & e)
855 {
856 dis = e.what();
857 return -3; /* runtime error */
858 }
859 }
860 }
861 }
862 }
863 catch (std::exception & e)
864 {
865 dis = e.what();
866 return -4; /* runtime error */
867 }
868
869 dis = "failed to disassemble";
870 return -1; /* failed to disassemble */
871 }
872
873
874 uint64 NMD::extract_code_18_to_0(uint64 instruction)
875 {
876 uint64 value = 0;
877 value |= extract_bits(instruction, 0, 19);
878 return value;
879 }
880
881
882 uint64 NMD::extract_shift3_2_1_0(uint64 instruction)
883 {
884 uint64 value = 0;
885 value |= extract_bits(instruction, 0, 3);
886 return value;
887 }
888
889
890 uint64 NMD::extract_u_11_10_9_8_7_6_5_4_3__s3(uint64 instruction)
891 {
892 uint64 value = 0;
893 value |= extract_bits(instruction, 3, 9) << 3;
894 return value;
895 }
896
897
898 uint64 NMD::extract_count_3_2_1_0(uint64 instruction)
899 {
900 uint64 value = 0;
901 value |= extract_bits(instruction, 0, 4);
902 return value;
903 }
904
905
906 uint64 NMD::extract_rtz3_9_8_7(uint64 instruction)
907 {
908 uint64 value = 0;
909 value |= extract_bits(instruction, 7, 3);
910 return value;
911 }
912
913
914 uint64 NMD::extract_u_17_to_1__s1(uint64 instruction)
915 {
916 uint64 value = 0;
917 value |= extract_bits(instruction, 1, 17) << 1;
918 return value;
919 }
920
921
922 int64 NMD::extract_s__se9_20_19_18_17_16_15_14_13_12_11(uint64 instruction)
923 {
924 int64 value = 0;
925 value |= extract_bits(instruction, 11, 10);
926 value = sign_extend(value, 9);
927 return value;
928 }
929
930
931 int64 NMD::extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(uint64 instruction)
932 {
933 int64 value = 0;
934 value |= extract_bits(instruction, 0, 1) << 11;
935 value |= extract_bits(instruction, 1, 10) << 1;
936 value = sign_extend(value, 11);
937 return value;
938 }
939
940
941 uint64 NMD::extract_u_10(uint64 instruction)
942 {
943 uint64 value = 0;
944 value |= extract_bits(instruction, 10, 1);
945 return value;
946 }
947
948
949 uint64 NMD::extract_rtz4_27_26_25_23_22_21(uint64 instruction)
950 {
951 uint64 value = 0;
952 value |= extract_bits(instruction, 21, 3);
953 value |= extract_bits(instruction, 25, 1) << 3;
954 return value;
955 }
956
957
958 uint64 NMD::extract_sa_15_14_13_12_11(uint64 instruction)
959 {
960 uint64 value = 0;
961 value |= extract_bits(instruction, 11, 5);
962 return value;
963 }
964
965
966 uint64 NMD::extract_shift_4_3_2_1_0(uint64 instruction)
967 {
968 uint64 value = 0;
969 value |= extract_bits(instruction, 0, 5);
970 return value;
971 }
972
973
974 uint64 NMD::extract_shiftx_10_9_8_7__s1(uint64 instruction)
975 {
976 uint64 value = 0;
977 value |= extract_bits(instruction, 7, 4) << 1;
978 return value;
979 }
980
981
982 uint64 NMD::extract_hint_25_24_23_22_21(uint64 instruction)
983 {
984 uint64 value = 0;
985 value |= extract_bits(instruction, 21, 5);
986 return value;
987 }
988
989
990 uint64 NMD::extract_count3_14_13_12(uint64 instruction)
991 {
992 uint64 value = 0;
993 value |= extract_bits(instruction, 12, 3);
994 return value;
995 }
996
997
998 int64 NMD::extract_s__se31_0_11_to_2_20_to_12_s12(uint64 instruction)
999 {
1000 int64 value = 0;
1001 value |= extract_bits(instruction, 0, 1) << 31;
1002 value |= extract_bits(instruction, 2, 10) << 21;
1003 value |= extract_bits(instruction, 12, 9) << 12;
1004 value = sign_extend(value, 31);
1005 return value;
1006 }
1007
1008
1009 int64 NMD::extract_s__se7_0_6_5_4_3_2_1_s1(uint64 instruction)
1010 {
1011 int64 value = 0;
1012 value |= extract_bits(instruction, 0, 1) << 7;
1013 value |= extract_bits(instruction, 1, 6) << 1;
1014 value = sign_extend(value, 7);
1015 return value;
1016 }
1017
1018
1019 uint64 NMD::extract_u2_10_9(uint64 instruction)
1020 {
1021 uint64 value = 0;
1022 value |= extract_bits(instruction, 9, 2);
1023 return value;
1024 }
1025
1026
1027 uint64 NMD::extract_code_25_24_23_22_21_20_19_18_17_16(uint64 instruction)
1028 {
1029 uint64 value = 0;
1030 value |= extract_bits(instruction, 16, 10);
1031 return value;
1032 }
1033
1034
1035 uint64 NMD::extract_rs_20_19_18_17_16(uint64 instruction)
1036 {
1037 uint64 value = 0;
1038 value |= extract_bits(instruction, 16, 5);
1039 return value;
1040 }
1041
1042
1043 uint64 NMD::extract_u_2_1__s1(uint64 instruction)
1044 {
1045 uint64 value = 0;
1046 value |= extract_bits(instruction, 1, 2) << 1;
1047 return value;
1048 }
1049
1050
1051 uint64 NMD::extract_stripe_6(uint64 instruction)
1052 {
1053 uint64 value = 0;
1054 value |= extract_bits(instruction, 6, 1);
1055 return value;
1056 }
1057
1058
1059 uint64 NMD::extract_ac_15_14(uint64 instruction)
1060 {
1061 uint64 value = 0;
1062 value |= extract_bits(instruction, 14, 2);
1063 return value;
1064 }
1065
1066
1067 uint64 NMD::extract_shift_20_19_18_17_16(uint64 instruction)
1068 {
1069 uint64 value = 0;
1070 value |= extract_bits(instruction, 16, 5);
1071 return value;
1072 }
1073
1074
1075 uint64 NMD::extract_rdl_25_24(uint64 instruction)
1076 {
1077 uint64 value = 0;
1078 value |= extract_bits(instruction, 24, 1);
1079 return value;
1080 }
1081
1082
1083 int64 NMD::extract_s__se10_0_9_8_7_6_5_4_3_2_1_s1(uint64 instruction)
1084 {
1085 int64 value = 0;
1086 value |= extract_bits(instruction, 0, 1) << 10;
1087 value |= extract_bits(instruction, 1, 9) << 1;
1088 value = sign_extend(value, 10);
1089 return value;
1090 }
1091
1092
1093 uint64 NMD::extract_eu_6_5_4_3_2_1_0(uint64 instruction)
1094 {
1095 uint64 value = 0;
1096 value |= extract_bits(instruction, 0, 7);
1097 return value;
1098 }
1099
1100
1101 uint64 NMD::extract_shift_5_4_3_2_1_0(uint64 instruction)
1102 {
1103 uint64 value = 0;
1104 value |= extract_bits(instruction, 0, 6);
1105 return value;
1106 }
1107
1108
1109 uint64 NMD::extract_count_19_18_17_16(uint64 instruction)
1110 {
1111 uint64 value = 0;
1112 value |= extract_bits(instruction, 16, 4);
1113 return value;
1114 }
1115
1116
1117 uint64 NMD::extract_code_2_1_0(uint64 instruction)
1118 {
1119 uint64 value = 0;
1120 value |= extract_bits(instruction, 0, 3);
1121 return value;
1122 }
1123
1124
1125 uint64 NMD::extract_u_11_10_9_8_7_6_5_4_3_2_1_0(uint64 instruction)
1126 {
1127 uint64 value = 0;
1128 value |= extract_bits(instruction, 0, 12);
1129 return value;
1130 }
1131
1132
1133 uint64 NMD::extract_rs_4_3_2_1_0(uint64 instruction)
1134 {
1135 uint64 value = 0;
1136 value |= extract_bits(instruction, 0, 5);
1137 return value;
1138 }
1139
1140
1141 uint64 NMD::extract_u_20_to_3__s3(uint64 instruction)
1142 {
1143 uint64 value = 0;
1144 value |= extract_bits(instruction, 3, 18) << 3;
1145 return value;
1146 }
1147
1148
1149 uint64 NMD::extract_u_3_2_1_0__s2(uint64 instruction)
1150 {
1151 uint64 value = 0;
1152 value |= extract_bits(instruction, 0, 4) << 2;
1153 return value;
1154 }
1155
1156
1157 uint64 NMD::extract_cofun_25_24_23(uint64 instruction)
1158 {
1159 uint64 value = 0;
1160 value |= extract_bits(instruction, 3, 23);
1161 return value;
1162 }
1163
1164
1165 uint64 NMD::extract_u_2_1_0__s2(uint64 instruction)
1166 {
1167 uint64 value = 0;
1168 value |= extract_bits(instruction, 0, 3) << 2;
1169 return value;
1170 }
1171
1172
1173 uint64 NMD::extract_rd3_3_2_1(uint64 instruction)
1174 {
1175 uint64 value = 0;
1176 value |= extract_bits(instruction, 1, 3);
1177 return value;
1178 }
1179
1180
1181 uint64 NMD::extract_sa_15_14_13_12(uint64 instruction)
1182 {
1183 uint64 value = 0;
1184 value |= extract_bits(instruction, 12, 4);
1185 return value;
1186 }
1187
1188
1189 uint64 NMD::extract_rt_25_24_23_22_21(uint64 instruction)
1190 {
1191 uint64 value = 0;
1192 value |= extract_bits(instruction, 21, 5);
1193 return value;
1194 }
1195
1196
1197 uint64 NMD::extract_ru_7_6_5_4_3(uint64 instruction)
1198 {
1199 uint64 value = 0;
1200 value |= extract_bits(instruction, 3, 5);
1201 return value;
1202 }
1203
1204
1205 uint64 NMD::extract_u_17_to_0(uint64 instruction)
1206 {
1207 uint64 value = 0;
1208 value |= extract_bits(instruction, 0, 18);
1209 return value;
1210 }
1211
1212
1213 uint64 NMD::extract_rsz4_4_2_1_0(uint64 instruction)
1214 {
1215 uint64 value = 0;
1216 value |= extract_bits(instruction, 0, 3);
1217 value |= extract_bits(instruction, 4, 1) << 3;
1218 return value;
1219 }
1220
1221
1222 int64 NMD::extract_s__se21_0_20_to_1_s1(uint64 instruction)
1223 {
1224 int64 value = 0;
1225 value |= extract_bits(instruction, 0, 1) << 21;
1226 value |= extract_bits(instruction, 1, 20) << 1;
1227 value = sign_extend(value, 21);
1228 return value;
1229 }
1230
1231
1232 uint64 NMD::extract_op_25_to_3(uint64 instruction)
1233 {
1234 uint64 value = 0;
1235 value |= extract_bits(instruction, 3, 23);
1236 return value;
1237 }
1238
1239
1240 uint64 NMD::extract_rs4_4_2_1_0(uint64 instruction)
1241 {
1242 uint64 value = 0;
1243 value |= extract_bits(instruction, 0, 3);
1244 value |= extract_bits(instruction, 4, 1) << 3;
1245 return value;
1246 }
1247
1248
1249 uint64 NMD::extract_bit_23_22_21(uint64 instruction)
1250 {
1251 uint64 value = 0;
1252 value |= extract_bits(instruction, 21, 3);
1253 return value;
1254 }
1255
1256
1257 uint64 NMD::extract_rt_41_40_39_38_37(uint64 instruction)
1258 {
1259 uint64 value = 0;
1260 value |= extract_bits(instruction, 37, 5);
1261 return value;
1262 }
1263
1264
1265 int64 NMD::extract_shift__se5_21_20_19_18_17_16(uint64 instruction)
1266 {
1267 int64 value = 0;
1268 value |= extract_bits(instruction, 16, 6);
1269 value = sign_extend(value, 5);
1270 return value;
1271 }
1272
1273
1274 uint64 NMD::extract_rd2_3_8(uint64 instruction)
1275 {
1276 uint64 value = 0;
1277 value |= extract_bits(instruction, 3, 1) << 1;
1278 value |= extract_bits(instruction, 8, 1);
1279 return value;
1280 }
1281
1282
1283 uint64 NMD::extract_code_17_to_0(uint64 instruction)
1284 {
1285 uint64 value = 0;
1286 value |= extract_bits(instruction, 0, 18);
1287 return value;
1288 }
1289
1290
1291 uint64 NMD::extract_size_20_19_18_17_16(uint64 instruction)
1292 {
1293 uint64 value = 0;
1294 value |= extract_bits(instruction, 16, 5);
1295 return value;
1296 }
1297
1298
1299 int64 NMD::extract_s__se8_15_7_6_5_4_3_2_s2(uint64 instruction)
1300 {
1301 int64 value = 0;
1302 value |= extract_bits(instruction, 2, 6) << 2;
1303 value |= extract_bits(instruction, 15, 1) << 8;
1304 value = sign_extend(value, 8);
1305 return value;
1306 }
1307
1308
1309 uint64 NMD::extract_u_15_to_0(uint64 instruction)
1310 {
1311 uint64 value = 0;
1312 value |= extract_bits(instruction, 0, 16);
1313 return value;
1314 }
1315
1316
1317 uint64 NMD::extract_fs_20_19_18_17_16(uint64 instruction)
1318 {
1319 uint64 value = 0;
1320 value |= extract_bits(instruction, 16, 5);
1321 return value;
1322 }
1323
1324
1325 int64 NMD::extract_s__se8_15_7_6_5_4_3_2_1_0(uint64 instruction)
1326 {
1327 int64 value = 0;
1328 value |= extract_bits(instruction, 0, 8);
1329 value |= extract_bits(instruction, 15, 1) << 8;
1330 value = sign_extend(value, 8);
1331 return value;
1332 }
1333
1334
1335 uint64 NMD::extract_stype_20_19_18_17_16(uint64 instruction)
1336 {
1337 uint64 value = 0;
1338 value |= extract_bits(instruction, 16, 5);
1339 return value;
1340 }
1341
1342
1343 uint64 NMD::extract_rtl_11(uint64 instruction)
1344 {
1345 uint64 value = 0;
1346 value |= extract_bits(instruction, 9, 1);
1347 return value;
1348 }
1349
1350
1351 uint64 NMD::extract_hs_20_19_18_17_16(uint64 instruction)
1352 {
1353 uint64 value = 0;
1354 value |= extract_bits(instruction, 16, 5);
1355 return value;
1356 }
1357
1358
1359 uint64 NMD::extract_sel_13_12_11(uint64 instruction)
1360 {
1361 uint64 value = 0;
1362 value |= extract_bits(instruction, 11, 3);
1363 return value;
1364 }
1365
1366
1367 uint64 NMD::extract_lsb_4_3_2_1_0(uint64 instruction)
1368 {
1369 uint64 value = 0;
1370 value |= extract_bits(instruction, 0, 5);
1371 return value;
1372 }
1373
1374
1375 uint64 NMD::extract_gp_2(uint64 instruction)
1376 {
1377 uint64 value = 0;
1378 value |= extract_bits(instruction, 2, 1);
1379 return value;
1380 }
1381
1382
1383 uint64 NMD::extract_rt3_9_8_7(uint64 instruction)
1384 {
1385 uint64 value = 0;
1386 value |= extract_bits(instruction, 7, 3);
1387 return value;
1388 }
1389
1390
1391 uint64 NMD::extract_ft_25_24_23_22_21(uint64 instruction)
1392 {
1393 uint64 value = 0;
1394 value |= extract_bits(instruction, 21, 5);
1395 return value;
1396 }
1397
1398
1399 uint64 NMD::extract_u_17_16_15_14_13_12_11(uint64 instruction)
1400 {
1401 uint64 value = 0;
1402 value |= extract_bits(instruction, 11, 7);
1403 return value;
1404 }
1405
1406
1407 uint64 NMD::extract_cs_20_19_18_17_16(uint64 instruction)
1408 {
1409 uint64 value = 0;
1410 value |= extract_bits(instruction, 16, 5);
1411 return value;
1412 }
1413
1414
1415 uint64 NMD::extract_rt4_9_7_6_5(uint64 instruction)
1416 {
1417 uint64 value = 0;
1418 value |= extract_bits(instruction, 5, 3);
1419 value |= extract_bits(instruction, 9, 1) << 3;
1420 return value;
1421 }
1422
1423
1424 uint64 NMD::extract_msbt_10_9_8_7_6(uint64 instruction)
1425 {
1426 uint64 value = 0;
1427 value |= extract_bits(instruction, 6, 5);
1428 return value;
1429 }
1430
1431
1432 uint64 NMD::extract_u_5_4_3_2_1_0__s2(uint64 instruction)
1433 {
1434 uint64 value = 0;
1435 value |= extract_bits(instruction, 0, 6) << 2;
1436 return value;
1437 }
1438
1439
1440 uint64 NMD::extract_sa_15_14_13(uint64 instruction)
1441 {
1442 uint64 value = 0;
1443 value |= extract_bits(instruction, 13, 3);
1444 return value;
1445 }
1446
1447
1448 int64 NMD::extract_s__se14_0_13_to_1_s1(uint64 instruction)
1449 {
1450 int64 value = 0;
1451 value |= extract_bits(instruction, 0, 1) << 14;
1452 value |= extract_bits(instruction, 1, 13) << 1;
1453 value = sign_extend(value, 14);
1454 return value;
1455 }
1456
1457
1458 uint64 NMD::extract_rs3_6_5_4(uint64 instruction)
1459 {
1460 uint64 value = 0;
1461 value |= extract_bits(instruction, 4, 3);
1462 return value;
1463 }
1464
1465
1466 uint64 NMD::extract_u_31_to_0__s32(uint64 instruction)
1467 {
1468 uint64 value = 0;
1469 value |= extract_bits(instruction, 0, 32) << 32;
1470 return value;
1471 }
1472
1473
1474 uint64 NMD::extract_shift_10_9_8_7_6(uint64 instruction)
1475 {
1476 uint64 value = 0;
1477 value |= extract_bits(instruction, 6, 5);
1478 return value;
1479 }
1480
1481
1482 uint64 NMD::extract_cs_25_24_23_22_21(uint64 instruction)
1483 {
1484 uint64 value = 0;
1485 value |= extract_bits(instruction, 21, 5);
1486 return value;
1487 }
1488
1489
1490 uint64 NMD::extract_shiftx_11_10_9_8_7_6(uint64 instruction)
1491 {
1492 uint64 value = 0;
1493 value |= extract_bits(instruction, 6, 6);
1494 return value;
1495 }
1496
1497
1498 uint64 NMD::extract_rt_9_8_7_6_5(uint64 instruction)
1499 {
1500 uint64 value = 0;
1501 value |= extract_bits(instruction, 5, 5);
1502 return value;
1503 }
1504
1505
1506 uint64 NMD::extract_op_25_24_23_22_21(uint64 instruction)
1507 {
1508 uint64 value = 0;
1509 value |= extract_bits(instruction, 21, 5);
1510 return value;
1511 }
1512
1513
1514 uint64 NMD::extract_u_6_5_4_3_2_1_0__s2(uint64 instruction)
1515 {
1516 uint64 value = 0;
1517 value |= extract_bits(instruction, 0, 7) << 2;
1518 return value;
1519 }
1520
1521
1522 uint64 NMD::extract_bit_16_15_14_13_12_11(uint64 instruction)
1523 {
1524 uint64 value = 0;
1525 value |= extract_bits(instruction, 11, 6);
1526 return value;
1527 }
1528
1529
1530 uint64 NMD::extract_mask_20_19_18_17_16_15_14(uint64 instruction)
1531 {
1532 uint64 value = 0;
1533 value |= extract_bits(instruction, 14, 7);
1534 return value;
1535 }
1536
1537
1538 uint64 NMD::extract_eu_3_2_1_0(uint64 instruction)
1539 {
1540 uint64 value = 0;
1541 value |= extract_bits(instruction, 0, 4);
1542 return value;
1543 }
1544
1545
1546 uint64 NMD::extract_u_7_6_5_4__s4(uint64 instruction)
1547 {
1548 uint64 value = 0;
1549 value |= extract_bits(instruction, 4, 4) << 4;
1550 return value;
1551 }
1552
1553
1554 int64 NMD::extract_s__se8_15_7_6_5_4_3_s3(uint64 instruction)
1555 {
1556 int64 value = 0;
1557 value |= extract_bits(instruction, 3, 5) << 3;
1558 value |= extract_bits(instruction, 15, 1) << 8;
1559 value = sign_extend(value, 8);
1560 return value;
1561 }
1562
1563
1564 uint64 NMD::extract_ft_15_14_13_12_11(uint64 instruction)
1565 {
1566 uint64 value = 0;
1567 value |= extract_bits(instruction, 11, 5);
1568 return value;
1569 }
1570
1571
1572 int64 NMD::extract_s__se31_15_to_0_31_to_16(uint64 instruction)
1573 {
1574 int64 value = 0;
1575 value |= extract_bits(instruction, 0, 16) << 16;
1576 value |= extract_bits(instruction, 16, 16);
1577 value = sign_extend(value, 31);
1578 return value;
1579 }
1580
1581
1582 uint64 NMD::extract_u_20_19_18_17_16_15_14_13(uint64 instruction)
1583 {
1584 uint64 value = 0;
1585 value |= extract_bits(instruction, 13, 8);
1586 return value;
1587 }
1588
1589
1590 uint64 NMD::extract_u_17_to_2__s2(uint64 instruction)
1591 {
1592 uint64 value = 0;
1593 value |= extract_bits(instruction, 2, 16) << 2;
1594 return value;
1595 }
1596
1597
1598 uint64 NMD::extract_rd_15_14_13_12_11(uint64 instruction)
1599 {
1600 uint64 value = 0;
1601 value |= extract_bits(instruction, 11, 5);
1602 return value;
1603 }
1604
1605
1606 uint64 NMD::extract_c0s_20_19_18_17_16(uint64 instruction)
1607 {
1608 uint64 value = 0;
1609 value |= extract_bits(instruction, 16, 5);
1610 return value;
1611 }
1612
1613
1614 uint64 NMD::extract_code_1_0(uint64 instruction)
1615 {
1616 uint64 value = 0;
1617 value |= extract_bits(instruction, 0, 2);
1618 return value;
1619 }
1620
1621
1622 int64 NMD::extract_s__se25_0_24_to_1_s1(uint64 instruction)
1623 {
1624 int64 value = 0;
1625 value |= extract_bits(instruction, 0, 1) << 25;
1626 value |= extract_bits(instruction, 1, 24) << 1;
1627 value = sign_extend(value, 25);
1628 return value;
1629 }
1630
1631
1632 uint64 NMD::extract_u_1_0(uint64 instruction)
1633 {
1634 uint64 value = 0;
1635 value |= extract_bits(instruction, 0, 2);
1636 return value;
1637 }
1638
1639
1640 uint64 NMD::extract_u_3_8__s2(uint64 instruction)
1641 {
1642 uint64 value = 0;
1643 value |= extract_bits(instruction, 3, 1) << 3;
1644 value |= extract_bits(instruction, 8, 1) << 2;
1645 return value;
1646 }
1647
1648
1649 uint64 NMD::extract_fd_15_14_13_12_11(uint64 instruction)
1650 {
1651 uint64 value = 0;
1652 value |= extract_bits(instruction, 11, 5);
1653 return value;
1654 }
1655
1656
1657 uint64 NMD::extract_u_4_3_2_1_0__s2(uint64 instruction)
1658 {
1659 uint64 value = 0;
1660 value |= extract_bits(instruction, 0, 5) << 2;
1661 return value;
1662 }
1663
1664
1665 uint64 NMD::extract_rtz4_9_7_6_5(uint64 instruction)
1666 {
1667 uint64 value = 0;
1668 value |= extract_bits(instruction, 5, 3);
1669 value |= extract_bits(instruction, 9, 1) << 3;
1670 return value;
1671 }
1672
1673
1674 uint64 NMD::extract_sel_15_14_13_12_11(uint64 instruction)
1675 {
1676 uint64 value = 0;
1677 value |= extract_bits(instruction, 11, 5);
1678 return value;
1679 }
1680
1681
1682 uint64 NMD::extract_ct_25_24_23_22_21(uint64 instruction)
1683 {
1684 uint64 value = 0;
1685 value |= extract_bits(instruction, 21, 5);
1686 return value;
1687 }
1688
1689
1690 uint64 NMD::extract_u_20_to_2__s2(uint64 instruction)
1691 {
1692 uint64 value = 0;
1693 value |= extract_bits(instruction, 2, 19) << 2;
1694 return value;
1695 }
1696
1697
1698 int64 NMD::extract_s__se3_4_2_1_0(uint64 instruction)
1699 {
1700 int64 value = 0;
1701 value |= extract_bits(instruction, 0, 3);
1702 value |= extract_bits(instruction, 4, 1) << 3;
1703 value = sign_extend(value, 3);
1704 return value;
1705 }
1706
1707
1708 uint64 NMD::extract_u_3_2_1_0__s1(uint64 instruction)
1709 {
1710 uint64 value = 0;
1711 value |= extract_bits(instruction, 0, 4) << 1;
1712 return value;
1713 }
1714
1715
1716
1717 bool NMD::ADDIU_32__cond(uint64 instruction)
1718 {
1719 uint64 rt = extract_rt_25_24_23_22_21(instruction);
1720 return rt != 0;
1721 }
1722
1723
1724 bool NMD::ADDIU_RS5__cond(uint64 instruction)
1725 {
1726 uint64 rt = extract_rt_9_8_7_6_5(instruction);
1727 return rt != 0;
1728 }
1729
1730
1731 bool NMD::BALRSC_cond(uint64 instruction)
1732 {
1733 uint64 rt = extract_rt_25_24_23_22_21(instruction);
1734 return rt != 0;
1735 }
1736
1737
1738 bool NMD::BEQC_16__cond(uint64 instruction)
1739 {
1740 uint64 rs3 = extract_rs3_6_5_4(instruction);
1741 uint64 rt3 = extract_rt3_9_8_7(instruction);
1742 uint64 u = extract_u_3_2_1_0__s1(instruction);
1743 return rs3 < rt3 && u != 0;
1744 }
1745
1746
1747 bool NMD::BNEC_16__cond(uint64 instruction)
1748 {
1749 uint64 rs3 = extract_rs3_6_5_4(instruction);
1750 uint64 rt3 = extract_rt3_9_8_7(instruction);
1751 uint64 u = extract_u_3_2_1_0__s1(instruction);
1752 return rs3 >= rt3 && u != 0;
1753 }
1754
1755
1756 bool NMD::MOVE_cond(uint64 instruction)
1757 {
1758 uint64 rt = extract_rt_9_8_7_6_5(instruction);
1759 return rt != 0;
1760 }
1761
1762
1763 bool NMD::P16_BR1_cond(uint64 instruction)
1764 {
1765 uint64 u = extract_u_3_2_1_0__s1(instruction);
1766 return u != 0;
1767 }
1768
1769
1770 bool NMD::PREF_S9__cond(uint64 instruction)
1771 {
1772 uint64 hint = extract_hint_25_24_23_22_21(instruction);
1773 return hint != 31;
1774 }
1775
1776
1777 bool NMD::PREFE_cond(uint64 instruction)
1778 {
1779 uint64 hint = extract_hint_25_24_23_22_21(instruction);
1780 return hint != 31;
1781 }
1782
1783
1784 bool NMD::SLTU_cond(uint64 instruction)
1785 {
1786 uint64 rd = extract_rd_15_14_13_12_11(instruction);
1787 return rd != 0;
1788 }
1789
1790
1791
1792 /*
1793 * ABS.D fd, fs - Floating Point Absolute Value
1794 *
1795 * 3 2 1
1796 * 10987654321098765432109876543210
1797 * 010001 00000 000101
1798 * fmt -----
1799 * fs -----
1800 * fd -----
1801 */
1802 std::string NMD::ABS_D(uint64 instruction)
1803 {
1804 uint64 fd_value = extract_ft_25_24_23_22_21(instruction);
1805 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
1806
1807 std::string fs = FPR(copy(fs_value));
1808 std::string fd = FPR(copy(fd_value));
1809
1810 return img::format("ABS.D %s, %s", fd, fs);
1811 }
1812
1813
1814 /*
1815 * ABS.S fd, fs - Floating Point Absolute Value
1816 *
1817 * 3 2 1
1818 * 10987654321098765432109876543210
1819 * 010001 00000 000101
1820 * fmt -----
1821 * fd -----
1822 * fs -----
1823 */
1824 std::string NMD::ABS_S(uint64 instruction)
1825 {
1826 uint64 fd_value = extract_ft_25_24_23_22_21(instruction);
1827 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
1828
1829 std::string fs = FPR(copy(fs_value));
1830 std::string fd = FPR(copy(fd_value));
1831
1832 return img::format("ABS.S %s, %s", fd, fs);
1833 }
1834
1835
1836 /*
1837 * [DSP] ABSQ_S.PH rt, rs - Find absolute value of two fractional halfwords
1838 * with 16-bit saturation
1839 *
1840 * 3 2 1
1841 * 10987654321098765432109876543210
1842 * 001000 0001000100111111
1843 * rt -----
1844 * rs -----
1845 */
1846 std::string NMD::ABSQ_S_PH(uint64 instruction)
1847 {
1848 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
1849 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
1850
1851 std::string rt = GPR(copy(rt_value));
1852 std::string rs = GPR(copy(rs_value));
1853
1854 return img::format("ABSQ_S.PH %s, %s", rt, rs);
1855 }
1856
1857
1858 /*
1859 * [DSP] ABSQ_S.QB rt, rs - Find absolute value of four fractional byte values
1860 * with 8-bit saturation
1861 *
1862 * 3 2 1
1863 * 10987654321098765432109876543210
1864 * 001000 0000000100111111
1865 * rt -----
1866 * rs -----
1867 */
1868 std::string NMD::ABSQ_S_QB(uint64 instruction)
1869 {
1870 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
1871 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
1872
1873 std::string rt = GPR(copy(rt_value));
1874 std::string rs = GPR(copy(rs_value));
1875
1876 return img::format("ABSQ_S.QB %s, %s", rt, rs);
1877 }
1878
1879
1880 /*
1881 * [DSP] ABSQ_S.W rt, rs - Find absolute value of fractional word with 32-bit
1882 * saturation
1883 *
1884 * 3 2 1
1885 * 10987654321098765432109876543210
1886 * 001000 0010000100111111
1887 * rt -----
1888 * rs -----
1889 */
1890 std::string NMD::ABSQ_S_W(uint64 instruction)
1891 {
1892 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
1893 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
1894
1895 std::string rt = GPR(copy(rt_value));
1896 std::string rs = GPR(copy(rs_value));
1897
1898 return img::format("ABSQ_S.W %s, %s", rt, rs);
1899 }
1900
1901
1902 /*
1903 *
1904 *
1905 * 3 2 1
1906 * 10987654321098765432109876543210
1907 * 001000 0010000100111111
1908 * rt -----
1909 * rs -----
1910 */
1911 std::string NMD::ACLR(uint64 instruction)
1912 {
1913 uint64 bit_value = extract_bit_23_22_21(instruction);
1914 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
1915 int64 s_value = extract_s__se8_15_7_6_5_4_3_2_1_0(instruction);
1916
1917 std::string bit = IMMEDIATE(copy(bit_value));
1918 std::string s = IMMEDIATE(copy(s_value));
1919 std::string rs = GPR(copy(rs_value));
1920
1921 return img::format("ACLR %s, %s(%s)", bit, s, rs);
1922 }
1923
1924
1925 /*
1926 *
1927 *
1928 * 3 2 1
1929 * 10987654321098765432109876543210
1930 * 001000 0010000100111111
1931 * rt -----
1932 * rs -----
1933 */
1934 std::string NMD::ADD(uint64 instruction)
1935 {
1936 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
1937 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
1938 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
1939
1940 std::string rd = GPR(copy(rd_value));
1941 std::string rs = GPR(copy(rs_value));
1942 std::string rt = GPR(copy(rt_value));
1943
1944 return img::format("ADD %s, %s, %s", rd, rs, rt);
1945 }
1946
1947
1948 /*
1949 * ADD.D fd, fs, ft - Floating Point Add
1950 *
1951 * 3 2 1
1952 * 10987654321098765432109876543210
1953 * 010001 000101
1954 * fmt -----
1955 * ft -----
1956 * fs -----
1957 * fd -----
1958 */
1959 std::string NMD::ADD_D(uint64 instruction)
1960 {
1961 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
1962 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
1963 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
1964
1965 std::string ft = FPR(copy(ft_value));
1966 std::string fs = FPR(copy(fs_value));
1967 std::string fd = FPR(copy(fd_value));
1968
1969 return img::format("ADD.D %s, %s, %s", fd, fs, ft);
1970 }
1971
1972
1973 /*
1974 * ADD.S fd, fs, ft - Floating Point Add
1975 *
1976 * 3 2 1
1977 * 10987654321098765432109876543210
1978 * 010001 000101
1979 * fmt -----
1980 * ft -----
1981 * fs -----
1982 * fd -----
1983 */
1984 std::string NMD::ADD_S(uint64 instruction)
1985 {
1986 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
1987 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
1988 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
1989
1990 std::string ft = FPR(copy(ft_value));
1991 std::string fs = FPR(copy(fs_value));
1992 std::string fd = FPR(copy(fd_value));
1993
1994 return img::format("ADD.S %s, %s, %s", fd, fs, ft);
1995 }
1996
1997
1998 /*
1999 *
2000 *
2001 * 3 2 1
2002 * 10987654321098765432109876543210
2003 * 001000 0010000100111111
2004 * rt -----
2005 * rs -----
2006 */
2007 std::string NMD::ADDIU_32_(uint64 instruction)
2008 {
2009 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2010 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2011 uint64 u_value = extract_u_15_to_0(instruction);
2012
2013 std::string rt = GPR(copy(rt_value));
2014 std::string rs = GPR(copy(rs_value));
2015 std::string u = IMMEDIATE(copy(u_value));
2016
2017 return img::format("ADDIU %s, %s, %s", rt, rs, u);
2018 }
2019
2020
2021 /*
2022 *
2023 *
2024 * 3 2 1
2025 * 10987654321098765432109876543210
2026 * 001000 0010000100111111
2027 * rt -----
2028 * rs -----
2029 */
2030 std::string NMD::ADDIU_48_(uint64 instruction)
2031 {
2032 uint64 rt_value = extract_rt_41_40_39_38_37(instruction);
2033 int64 s_value = extract_s__se31_15_to_0_31_to_16(instruction);
2034
2035 std::string rt = GPR(copy(rt_value));
2036 std::string s = IMMEDIATE(copy(s_value));
2037
2038 return img::format("ADDIU %s, %s", rt, s);
2039 }
2040
2041
2042 /*
2043 *
2044 *
2045 * 3 2 1
2046 * 10987654321098765432109876543210
2047 * 001000 0010000100111111
2048 * rt -----
2049 * rs -----
2050 */
2051 std::string NMD::ADDIU_GP48_(uint64 instruction)
2052 {
2053 uint64 rt_value = extract_rt_41_40_39_38_37(instruction);
2054 int64 s_value = extract_s__se31_15_to_0_31_to_16(instruction);
2055
2056 std::string rt = GPR(copy(rt_value));
2057 std::string s = IMMEDIATE(copy(s_value));
2058
2059 return img::format("ADDIU %s, $%d, %s", rt, 28, s);
2060 }
2061
2062
2063 /*
2064 *
2065 *
2066 * 3 2 1
2067 * 10987654321098765432109876543210
2068 * 001000 0010000100111111
2069 * rt -----
2070 * rs -----
2071 */
2072 std::string NMD::ADDIU_GP_B_(uint64 instruction)
2073 {
2074 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2075 uint64 u_value = extract_u_17_to_0(instruction);
2076
2077 std::string rt = GPR(copy(rt_value));
2078 std::string u = IMMEDIATE(copy(u_value));
2079
2080 return img::format("ADDIU %s, $%d, %s", rt, 28, u);
2081 }
2082
2083
2084 /*
2085 *
2086 *
2087 * 3 2 1
2088 * 10987654321098765432109876543210
2089 * 001000 0010000100111111
2090 * rt -----
2091 * rs -----
2092 */
2093 std::string NMD::ADDIU_GP_W_(uint64 instruction)
2094 {
2095 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2096 uint64 u_value = extract_u_20_to_2__s2(instruction);
2097
2098 std::string rt = GPR(copy(rt_value));
2099 std::string u = IMMEDIATE(copy(u_value));
2100
2101 return img::format("ADDIU %s, $%d, %s", rt, 28, u);
2102 }
2103
2104
2105 /*
2106 *
2107 *
2108 * 3 2 1
2109 * 10987654321098765432109876543210
2110 * 001000 0010000100111111
2111 * rt -----
2112 * rs -----
2113 */
2114 std::string NMD::ADDIU_NEG_(uint64 instruction)
2115 {
2116 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2117 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2118 uint64 u_value = extract_u_11_10_9_8_7_6_5_4_3_2_1_0(instruction);
2119
2120 std::string rt = GPR(copy(rt_value));
2121 std::string rs = GPR(copy(rs_value));
2122 std::string u = IMMEDIATE(neg_copy(u_value));
2123
2124 return img::format("ADDIU %s, %s, %s", rt, rs, u);
2125 }
2126
2127
2128 /*
2129 *
2130 *
2131 * 3 2 1
2132 * 10987654321098765432109876543210
2133 * 001000 0010000100111111
2134 * rt -----
2135 * rs -----
2136 */
2137 std::string NMD::ADDIU_R1_SP_(uint64 instruction)
2138 {
2139 uint64 u_value = extract_u_5_4_3_2_1_0__s2(instruction);
2140 uint64 rt3_value = extract_rt3_9_8_7(instruction);
2141
2142 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
2143 std::string u = IMMEDIATE(copy(u_value));
2144
2145 return img::format("ADDIU %s, $%d, %s", rt3, 29, u);
2146 }
2147
2148
2149 /*
2150 *
2151 *
2152 * 3 2 1
2153 * 10987654321098765432109876543210
2154 * 001000 0010000100111111
2155 * rt -----
2156 * rs -----
2157 */
2158 std::string NMD::ADDIU_R2_(uint64 instruction)
2159 {
2160 uint64 rt3_value = extract_rt3_9_8_7(instruction);
2161 uint64 rs3_value = extract_rs3_6_5_4(instruction);
2162 uint64 u_value = extract_u_2_1_0__s2(instruction);
2163
2164 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
2165 std::string rs3 = GPR(decode_gpr_gpr3(rs3_value));
2166 std::string u = IMMEDIATE(copy(u_value));
2167
2168 return img::format("ADDIU %s, %s, %s", rt3, rs3, u);
2169 }
2170
2171
2172 /*
2173 * ADDIU[RS5] rt, s5 - Add Signed Word and Set Carry Bit
2174 *
2175 * 5432109876543210
2176 * 100100 1
2177 * rt -----
2178 * s - ---
2179 */
2180 std::string NMD::ADDIU_RS5_(uint64 instruction)
2181 {
2182 uint64 rt_value = extract_rt_9_8_7_6_5(instruction);
2183 int64 s_value = extract_s__se3_4_2_1_0(instruction);
2184
2185 std::string rt = GPR(copy(rt_value));
2186 std::string s = IMMEDIATE(copy(s_value));
2187
2188 return img::format("ADDIU %s, %s", rt, s);
2189 }
2190
2191
2192 /*
2193 *
2194 *
2195 * 3 2 1
2196 * 10987654321098765432109876543210
2197 * 001000 x1110000101
2198 * rt -----
2199 * rs -----
2200 * rd -----
2201 */
2202 std::string NMD::ADDIUPC_32_(uint64 instruction)
2203 {
2204 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2205 int64 s_value = extract_s__se21_0_20_to_1_s1(instruction);
2206
2207 std::string rt = GPR(copy(rt_value));
2208 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
2209
2210 return img::format("ADDIUPC %s, %s", rt, s);
2211 }
2212
2213
2214 /*
2215 *
2216 *
2217 * 3 2 1
2218 * 10987654321098765432109876543210
2219 * 001000 x1110000101
2220 * rt -----
2221 * rs -----
2222 * rd -----
2223 */
2224 std::string NMD::ADDIUPC_48_(uint64 instruction)
2225 {
2226 uint64 rt_value = extract_rt_41_40_39_38_37(instruction);
2227 int64 s_value = extract_s__se31_15_to_0_31_to_16(instruction);
2228
2229 std::string rt = GPR(copy(rt_value));
2230 std::string s = ADDRESS(encode_s_from_address(s_value), 6);
2231
2232 return img::format("ADDIUPC %s, %s", rt, s);
2233 }
2234
2235
2236 /*
2237 * [DSP] ADDQ.PH rd, rt, rs - Add fractional halfword vectors
2238 *
2239 * 3 2 1
2240 * 10987654321098765432109876543210
2241 * 001000 00000001101
2242 * rt -----
2243 * rs -----
2244 * rd -----
2245 */
2246 std::string NMD::ADDQ_PH(uint64 instruction)
2247 {
2248 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2249 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2250 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2251
2252 std::string rd = GPR(copy(rd_value));
2253 std::string rs = GPR(copy(rs_value));
2254 std::string rt = GPR(copy(rt_value));
2255
2256 return img::format("ADDQ.PH %s, %s, %s", rd, rs, rt);
2257 }
2258
2259
2260 /*
2261 * [DSP] ADDQ_S.PH rd, rt, rs - Add fractional halfword vectors with 16-bit
2262 * saturation
2263 *
2264 * 3 2 1
2265 * 10987654321098765432109876543210
2266 * 001000 10000001101
2267 * rt -----
2268 * rs -----
2269 * rd -----
2270 */
2271 std::string NMD::ADDQ_S_PH(uint64 instruction)
2272 {
2273 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2274 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2275 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2276
2277 std::string rd = GPR(copy(rd_value));
2278 std::string rs = GPR(copy(rs_value));
2279 std::string rt = GPR(copy(rt_value));
2280
2281 return img::format("ADDQ_S.PH %s, %s, %s", rd, rs, rt);
2282 }
2283
2284
2285 /*
2286 * [DSP] ADDQ_S.W rd, rt, rs - Add fractional words with 32-bit saturation
2287 *
2288 * 3 2 1
2289 * 10987654321098765432109876543210
2290 * 001000 x1100000101
2291 * rt -----
2292 * rs -----
2293 * rd -----
2294 */
2295 std::string NMD::ADDQ_S_W(uint64 instruction)
2296 {
2297 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2298 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2299 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2300
2301 std::string rd = GPR(copy(rd_value));
2302 std::string rs = GPR(copy(rs_value));
2303 std::string rt = GPR(copy(rt_value));
2304
2305 return img::format("ADDQ_S.W %s, %s, %s", rd, rs, rt);
2306 }
2307
2308
2309 /*
2310 * [DSP] ADDQH.PH rd, rt, rs - Add fractional halfword vectors and shift
2311 * right to halve results
2312 *
2313 * 3 2 1
2314 * 10987654321098765432109876543210
2315 * 001000 00001001101
2316 * rt -----
2317 * rs -----
2318 * rd -----
2319 */
2320 std::string NMD::ADDQH_PH(uint64 instruction)
2321 {
2322 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2323 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2324 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2325
2326 std::string rd = GPR(copy(rd_value));
2327 std::string rs = GPR(copy(rs_value));
2328 std::string rt = GPR(copy(rt_value));
2329
2330 return img::format("ADDQH.PH %s, %s, %s", rd, rs, rt);
2331 }
2332
2333
2334 /*
2335 * [DSP] ADDQH_R.PH rd, rt, rs - Add fractional halfword vectors and shift
2336 * right to halve results with rounding
2337 *
2338 * 3 2 1
2339 * 10987654321098765432109876543210
2340 * 001000 10001001101
2341 * rt -----
2342 * rs -----
2343 * rd -----
2344 */
2345 std::string NMD::ADDQH_R_PH(uint64 instruction)
2346 {
2347 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2348 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2349 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2350
2351 std::string rd = GPR(copy(rd_value));
2352 std::string rs = GPR(copy(rs_value));
2353 std::string rt = GPR(copy(rt_value));
2354
2355 return img::format("ADDQH_R.PH %s, %s, %s", rd, rs, rt);
2356 }
2357
2358
2359 /*
2360 * [DSP] ADDQH_R.W rd, rt, rs - Add fractional words and shift right to halve
2361 * results with rounding
2362 *
2363 * 3 2 1
2364 * 10987654321098765432109876543210
2365 * 001000 00010001101
2366 * rt -----
2367 * rs -----
2368 * rd -----
2369 */
2370 std::string NMD::ADDQH_R_W(uint64 instruction)
2371 {
2372 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2373 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2374 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2375
2376 std::string rd = GPR(copy(rd_value));
2377 std::string rs = GPR(copy(rs_value));
2378 std::string rt = GPR(copy(rt_value));
2379
2380 return img::format("ADDQH_R.W %s, %s, %s", rd, rs, rt);
2381 }
2382
2383
2384 /*
2385 * [DSP] ADDQH.W rd, rt, rs - Add fractional words and shift right to halve
2386 * results
2387 *
2388 * 3 2 1
2389 * 10987654321098765432109876543210
2390 * 001000 10010001101
2391 * rt -----
2392 * rs -----
2393 * rd -----
2394 */
2395 std::string NMD::ADDQH_W(uint64 instruction)
2396 {
2397 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2398 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2399 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2400
2401 std::string rd = GPR(copy(rd_value));
2402 std::string rs = GPR(copy(rs_value));
2403 std::string rt = GPR(copy(rt_value));
2404
2405 return img::format("ADDQH.W %s, %s, %s", rd, rs, rt);
2406 }
2407
2408
2409 /*
2410 * [DSP] ADDSC rd, rt, rs - Add two signed words and set carry bit
2411 *
2412 * 3 2 1
2413 * 10987654321098765432109876543210
2414 * 001000 x1110000101
2415 * rt -----
2416 * rs -----
2417 * rd -----
2418 */
2419 std::string NMD::ADDSC(uint64 instruction)
2420 {
2421 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2422 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2423 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2424
2425 std::string rd = GPR(copy(rd_value));
2426 std::string rs = GPR(copy(rs_value));
2427 std::string rt = GPR(copy(rt_value));
2428
2429 return img::format("ADDSC %s, %s, %s", rd, rs, rt);
2430 }
2431
2432
2433 /*
2434 * ADDU[16] rd3, rs3, rt3 -
2435 *
2436 * 5432109876543210
2437 * 101100 0
2438 * rt3 ---
2439 * rs3 ---
2440 * rd3 ---
2441 */
2442 std::string NMD::ADDU_16_(uint64 instruction)
2443 {
2444 uint64 rt3_value = extract_rt3_9_8_7(instruction);
2445 uint64 rs3_value = extract_rs3_6_5_4(instruction);
2446 uint64 rd3_value = extract_rd3_3_2_1(instruction);
2447
2448 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
2449 std::string rs3 = GPR(decode_gpr_gpr3(rs3_value));
2450 std::string rd3 = GPR(decode_gpr_gpr3(rd3_value));
2451
2452 return img::format("ADDU %s, %s, %s", rd3, rs3, rt3);
2453 }
2454
2455
2456 /*
2457 *
2458 *
2459 * 3 2 1
2460 * 10987654321098765432109876543210
2461 * 001000 x1110000101
2462 * rt -----
2463 * rs -----
2464 * rd -----
2465 */
2466 std::string NMD::ADDU_32_(uint64 instruction)
2467 {
2468 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2469 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2470 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2471
2472 std::string rd = GPR(copy(rd_value));
2473 std::string rs = GPR(copy(rs_value));
2474 std::string rt = GPR(copy(rt_value));
2475
2476 return img::format("ADDU %s, %s, %s", rd, rs, rt);
2477 }
2478
2479
2480 /*
2481 *
2482 *
2483 * 3 2 1
2484 * 10987654321098765432109876543210
2485 * 001000 x1110000101
2486 * rt -----
2487 * rs -----
2488 * rd -----
2489 */
2490 std::string NMD::ADDU_4X4_(uint64 instruction)
2491 {
2492 uint64 rt4_value = extract_rt4_9_7_6_5(instruction);
2493 uint64 rs4_value = extract_rs4_4_2_1_0(instruction);
2494
2495 std::string rs4 = GPR(decode_gpr_gpr4(rs4_value));
2496 std::string rt4 = GPR(decode_gpr_gpr4(rt4_value));
2497
2498 return img::format("ADDU %s, %s", rs4, rt4);
2499 }
2500
2501
2502 /*
2503 * [DSP] ADDU.PH rd, rt, rs - Add two pairs of unsigned halfwords
2504 *
2505 * 3 2 1
2506 * 10987654321098765432109876543210
2507 * 001000 00100001101
2508 * rt -----
2509 * rs -----
2510 * rd -----
2511 */
2512 std::string NMD::ADDU_PH(uint64 instruction)
2513 {
2514 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2515 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2516 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2517
2518 std::string rd = GPR(copy(rd_value));
2519 std::string rs = GPR(copy(rs_value));
2520 std::string rt = GPR(copy(rt_value));
2521
2522 return img::format("ADDU.PH %s, %s, %s", rd, rs, rt);
2523 }
2524
2525
2526 /*
2527 * ADDU.QB rd, rt, rs - Unsigned Add Quad Byte Vectors
2528 *
2529 * 3 2 1
2530 * 10987654321098765432109876543210
2531 * 001000 00011001101
2532 * rt -----
2533 * rs -----
2534 * rd -----
2535 */
2536 std::string NMD::ADDU_QB(uint64 instruction)
2537 {
2538 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2539 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2540 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2541
2542 std::string rd = GPR(copy(rd_value));
2543 std::string rs = GPR(copy(rs_value));
2544 std::string rt = GPR(copy(rt_value));
2545
2546 return img::format("ADDU.QB %s, %s, %s", rd, rs, rt);
2547 }
2548
2549
2550 /*
2551 * [DSP] ADDU_S.PH rd, rt, rs - Add two pairs of unsigned halfwords with 16-bit
2552 * saturation
2553 *
2554 * 3 2 1
2555 * 10987654321098765432109876543210
2556 * 001000 10100001101
2557 * rt -----
2558 * rs -----
2559 * rd -----
2560 */
2561 std::string NMD::ADDU_S_PH(uint64 instruction)
2562 {
2563 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2564 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2565 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2566
2567 std::string rd = GPR(copy(rd_value));
2568 std::string rs = GPR(copy(rs_value));
2569 std::string rt = GPR(copy(rt_value));
2570
2571 return img::format("ADDU_S.PH %s, %s, %s", rd, rs, rt);
2572 }
2573
2574
2575 /*
2576 * ADDU_S.QB rd, rt, rs - Unsigned Add Quad Byte Vectors
2577 *
2578 * 3 2 1
2579 * 10987654321098765432109876543210
2580 * 001000 10011001101
2581 * rt -----
2582 * rs -----
2583 * rd -----
2584 */
2585 std::string NMD::ADDU_S_QB(uint64 instruction)
2586 {
2587 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2588 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2589 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2590
2591 std::string rd = GPR(copy(rd_value));
2592 std::string rs = GPR(copy(rs_value));
2593 std::string rt = GPR(copy(rt_value));
2594
2595 return img::format("ADDU_S.QB %s, %s, %s", rd, rs, rt);
2596 }
2597
2598
2599 /*
2600 * ADDUH.QB rd, rt, rs - Unsigned Add Vector Quad-Bytes And Right Shift
2601 * to Halve Results
2602 *
2603 * 3 2 1
2604 * 10987654321098765432109876543210
2605 * 001000 00101001101
2606 * rt -----
2607 * rs -----
2608 * rd -----
2609 */
2610 std::string NMD::ADDUH_QB(uint64 instruction)
2611 {
2612 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2613 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2614 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2615
2616 std::string rd = GPR(copy(rd_value));
2617 std::string rs = GPR(copy(rs_value));
2618 std::string rt = GPR(copy(rt_value));
2619
2620 return img::format("ADDUH.QB %s, %s, %s", rd, rs, rt);
2621 }
2622
2623
2624 /*
2625 * ADDUH_R.QB rd, rt, rs - Unsigned Add Vector Quad-Bytes And Right Shift
2626 * to Halve Results
2627 *
2628 * 3 2 1
2629 * 10987654321098765432109876543210
2630 * 001000 10101001101
2631 * rt -----
2632 * rs -----
2633 * rd -----
2634 */
2635 std::string NMD::ADDUH_R_QB(uint64 instruction)
2636 {
2637 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2638 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2639 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2640
2641 std::string rd = GPR(copy(rd_value));
2642 std::string rs = GPR(copy(rs_value));
2643 std::string rt = GPR(copy(rt_value));
2644
2645 return img::format("ADDUH_R.QB %s, %s, %s", rd, rs, rt);
2646 }
2647
2648 /*
2649 * ADDWC rd, rt, rs - Add Word with Carry Bit
2650 *
2651 * 3 2 1
2652 * 10987654321098765432109876543210
2653 * 001000 x1111000101
2654 * rt -----
2655 * rs -----
2656 * rd -----
2657 */
2658 std::string NMD::ADDWC(uint64 instruction)
2659 {
2660 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2661 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2662 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2663
2664 std::string rd = GPR(copy(rd_value));
2665 std::string rs = GPR(copy(rs_value));
2666 std::string rt = GPR(copy(rt_value));
2667
2668 return img::format("ADDWC %s, %s, %s", rd, rs, rt);
2669 }
2670
2671
2672 /*
2673 *
2674 *
2675 * 3 2 1
2676 * 10987654321098765432109876543210
2677 * 001000 x1110000101
2678 * rt -----
2679 * rs -----
2680 * rd -----
2681 */
2682 std::string NMD::ALUIPC(uint64 instruction)
2683 {
2684 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2685 int64 s_value = extract_s__se31_0_11_to_2_20_to_12_s12(instruction);
2686
2687 std::string rt = GPR(copy(rt_value));
2688 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
2689
2690 return img::format("ALUIPC %s, %%pcrel_hi(%s)", rt, s);
2691 }
2692
2693
2694 /*
2695 * AND[16] rt3, rs3 -
2696 *
2697 * 5432109876543210
2698 * 101100
2699 * rt3 ---
2700 * rs3 ---
2701 * eu ----
2702 */
2703 std::string NMD::AND_16_(uint64 instruction)
2704 {
2705 uint64 rt3_value = extract_rt3_9_8_7(instruction);
2706 uint64 rs3_value = extract_rs3_6_5_4(instruction);
2707
2708 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
2709 std::string rs3 = GPR(decode_gpr_gpr3(rs3_value));
2710
2711 return img::format("AND %s, %s", rs3, rt3);
2712 }
2713
2714
2715 /*
2716 *
2717 *
2718 * 3 2 1
2719 * 10987654321098765432109876543210
2720 * 001000 x1110000101
2721 * rt -----
2722 * rs -----
2723 * rd -----
2724 */
2725 std::string NMD::AND_32_(uint64 instruction)
2726 {
2727 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2728 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2729 uint64 rd_value = extract_rd_15_14_13_12_11(instruction);
2730
2731 std::string rd = GPR(copy(rd_value));
2732 std::string rs = GPR(copy(rs_value));
2733 std::string rt = GPR(copy(rt_value));
2734
2735 return img::format("AND %s, %s, %s", rd, rs, rt);
2736 }
2737
2738
2739 /*
2740 * ANDI rt, rs, u -
2741 *
2742 * 5432109876543210
2743 * 101100
2744 * rt3 ---
2745 * rs3 ---
2746 * eu ----
2747 */
2748 std::string NMD::ANDI_16_(uint64 instruction)
2749 {
2750 uint64 rt3_value = extract_rt3_9_8_7(instruction);
2751 uint64 rs3_value = extract_rs3_6_5_4(instruction);
2752 uint64 eu_value = extract_eu_3_2_1_0(instruction);
2753
2754 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
2755 std::string rs3 = GPR(decode_gpr_gpr3(rs3_value));
2756 std::string eu = IMMEDIATE(encode_eu_from_u_andi16(eu_value));
2757
2758 return img::format("ANDI %s, %s, %s", rt3, rs3, eu);
2759 }
2760
2761
2762 /*
2763 *
2764 *
2765 * 3 2 1
2766 * 10987654321098765432109876543210
2767 * 001000 x1110000101
2768 * rt -----
2769 * rs -----
2770 * rd -----
2771 */
2772 std::string NMD::ANDI_32_(uint64 instruction)
2773 {
2774 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2775 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2776 uint64 u_value = extract_u_11_10_9_8_7_6_5_4_3_2_1_0(instruction);
2777
2778 std::string rt = GPR(copy(rt_value));
2779 std::string rs = GPR(copy(rs_value));
2780 std::string u = IMMEDIATE(copy(u_value));
2781
2782 return img::format("ANDI %s, %s, %s", rt, rs, u);
2783 }
2784
2785
2786 /*
2787 *
2788 *
2789 * 3 2 1
2790 * 10987654321098765432109876543210
2791 * 001000 x1110000101
2792 * rt -----
2793 * rs -----
2794 * rd -----
2795 */
2796 std::string NMD::APPEND(uint64 instruction)
2797 {
2798 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2799 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2800 uint64 sa_value = extract_sa_15_14_13_12_11(instruction);
2801
2802 std::string rt = GPR(copy(rt_value));
2803 std::string rs = GPR(copy(rs_value));
2804 std::string sa = IMMEDIATE(copy(sa_value));
2805
2806 return img::format("APPEND %s, %s, %s", rt, rs, sa);
2807 }
2808
2809
2810 /*
2811 *
2812 *
2813 * 3 2 1
2814 * 10987654321098765432109876543210
2815 * 001000 x1110000101
2816 * rt -----
2817 * rs -----
2818 * rd -----
2819 */
2820 std::string NMD::ASET(uint64 instruction)
2821 {
2822 uint64 bit_value = extract_bit_23_22_21(instruction);
2823 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2824 int64 s_value = extract_s__se8_15_7_6_5_4_3_2_1_0(instruction);
2825
2826 std::string bit = IMMEDIATE(copy(bit_value));
2827 std::string s = IMMEDIATE(copy(s_value));
2828 std::string rs = GPR(copy(rs_value));
2829
2830 return img::format("ASET %s, %s(%s)", bit, s, rs);
2831 }
2832
2833
2834 /*
2835 *
2836 *
2837 * 3 2 1
2838 * 10987654321098765432109876543210
2839 * 001000 x1110000101
2840 * rt -----
2841 * rs -----
2842 * rd -----
2843 */
2844 std::string NMD::BALC_16_(uint64 instruction)
2845 {
2846 int64 s_value = extract_s__se10_0_9_8_7_6_5_4_3_2_1_s1(instruction);
2847
2848 std::string s = ADDRESS(encode_s_from_address(s_value), 2);
2849
2850 return img::format("BALC %s", s);
2851 }
2852
2853
2854 /*
2855 *
2856 *
2857 * 3 2 1
2858 * 10987654321098765432109876543210
2859 * 001000 x1110000101
2860 * rt -----
2861 * rs -----
2862 * rd -----
2863 */
2864 std::string NMD::BALC_32_(uint64 instruction)
2865 {
2866 int64 s_value = extract_s__se25_0_24_to_1_s1(instruction);
2867
2868 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
2869
2870 return img::format("BALC %s", s);
2871 }
2872
2873
2874 /*
2875 *
2876 *
2877 * 3 2 1
2878 * 10987654321098765432109876543210
2879 * 001000 x1110000101
2880 * rt -----
2881 * rs -----
2882 * rd -----
2883 */
2884 std::string NMD::BALRSC(uint64 instruction)
2885 {
2886 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2887 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
2888
2889 std::string rt = GPR(copy(rt_value));
2890 std::string rs = GPR(copy(rs_value));
2891
2892 return img::format("BALRSC %s, %s", rt, rs);
2893 }
2894
2895
2896 /*
2897 *
2898 *
2899 * 3 2 1
2900 * 10987654321098765432109876543210
2901 * 001000 x1110000101
2902 * rt -----
2903 * rs -----
2904 * rd -----
2905 */
2906 std::string NMD::BBEQZC(uint64 instruction)
2907 {
2908 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2909 uint64 bit_value = extract_bit_16_15_14_13_12_11(instruction);
2910 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
2911
2912 std::string rt = GPR(copy(rt_value));
2913 std::string bit = IMMEDIATE(copy(bit_value));
2914 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
2915
2916 return img::format("BBEQZC %s, %s, %s", rt, bit, s);
2917 }
2918
2919
2920 /*
2921 *
2922 *
2923 * 3 2 1
2924 * 10987654321098765432109876543210
2925 * 001000 x1110000101
2926 * rt -----
2927 * rs -----
2928 * rd -----
2929 */
2930 std::string NMD::BBNEZC(uint64 instruction)
2931 {
2932 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
2933 uint64 bit_value = extract_bit_16_15_14_13_12_11(instruction);
2934 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
2935
2936 std::string rt = GPR(copy(rt_value));
2937 std::string bit = IMMEDIATE(copy(bit_value));
2938 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
2939
2940 return img::format("BBNEZC %s, %s, %s", rt, bit, s);
2941 }
2942
2943
2944 /*
2945 *
2946 *
2947 * 3 2 1
2948 * 10987654321098765432109876543210
2949 * 001000 x1110000101
2950 * rt -----
2951 * rs -----
2952 * rd -----
2953 */
2954 std::string NMD::BC_16_(uint64 instruction)
2955 {
2956 int64 s_value = extract_s__se10_0_9_8_7_6_5_4_3_2_1_s1(instruction);
2957
2958 std::string s = ADDRESS(encode_s_from_address(s_value), 2);
2959
2960 return img::format("BC %s", s);
2961 }
2962
2963
2964 /*
2965 *
2966 *
2967 * 3 2 1
2968 * 10987654321098765432109876543210
2969 * 001000 x1110000101
2970 * rt -----
2971 * rs -----
2972 * rd -----
2973 */
2974 std::string NMD::BC_32_(uint64 instruction)
2975 {
2976 int64 s_value = extract_s__se25_0_24_to_1_s1(instruction);
2977
2978 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
2979
2980 return img::format("BC %s", s);
2981 }
2982
2983
2984 /*
2985 *
2986 *
2987 * 3 2 1
2988 * 10987654321098765432109876543210
2989 * 001000 x1110000101
2990 * rt -----
2991 * rs -----
2992 * rd -----
2993 */
2994 std::string NMD::BC1EQZC(uint64 instruction)
2995 {
2996 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
2997 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
2998
2999 std::string ft = FPR(copy(ft_value));
3000 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3001
3002 return img::format("BC1EQZC %s, %s", ft, s);
3003 }
3004
3005
3006 /*
3007 *
3008 *
3009 * 3 2 1
3010 * 10987654321098765432109876543210
3011 * 001000 x1110000101
3012 * rt -----
3013 * rs -----
3014 * rd -----
3015 */
3016 std::string NMD::BC1NEZC(uint64 instruction)
3017 {
3018 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3019 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3020
3021 std::string ft = FPR(copy(ft_value));
3022 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3023
3024 return img::format("BC1NEZC %s, %s", ft, s);
3025 }
3026
3027
3028 /*
3029 *
3030 *
3031 * 3 2 1
3032 * 10987654321098765432109876543210
3033 * 001000 x1110000101
3034 * rt -----
3035 * rs -----
3036 * rd -----
3037 */
3038 std::string NMD::BC2EQZC(uint64 instruction)
3039 {
3040 uint64 ct_value = extract_ct_25_24_23_22_21(instruction);
3041 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3042
3043 std::string ct = CPR(copy(ct_value));
3044 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3045
3046 return img::format("BC2EQZC %s, %s", ct, s);
3047 }
3048
3049
3050 /*
3051 *
3052 *
3053 * 3 2 1
3054 * 10987654321098765432109876543210
3055 * 001000 x1110000101
3056 * rt -----
3057 * rs -----
3058 * rd -----
3059 */
3060 std::string NMD::BC2NEZC(uint64 instruction)
3061 {
3062 uint64 ct_value = extract_ct_25_24_23_22_21(instruction);
3063 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3064
3065 std::string ct = CPR(copy(ct_value));
3066 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3067
3068 return img::format("BC2NEZC %s, %s", ct, s);
3069 }
3070
3071
3072 /*
3073 *
3074 *
3075 * 3 2 1
3076 * 10987654321098765432109876543210
3077 * 001000 x1110000101
3078 * rt -----
3079 * rs -----
3080 * rd -----
3081 */
3082 std::string NMD::BEQC_16_(uint64 instruction)
3083 {
3084 uint64 rt3_value = extract_rt3_9_8_7(instruction);
3085 uint64 rs3_value = extract_rs3_6_5_4(instruction);
3086 uint64 u_value = extract_u_3_2_1_0__s1(instruction);
3087
3088 std::string rs3 = GPR(encode_rs3_and_check_rs3_lt_rt3(rs3_value));
3089 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
3090 std::string u = ADDRESS(encode_u_from_address(u_value), 2);
3091
3092 return img::format("BEQC %s, %s, %s", rs3, rt3, u);
3093 }
3094
3095
3096 /*
3097 *
3098 *
3099 * 3 2 1
3100 * 10987654321098765432109876543210
3101 * 001000 x1110000101
3102 * rt -----
3103 * rs -----
3104 * rd -----
3105 */
3106 std::string NMD::BEQC_32_(uint64 instruction)
3107 {
3108 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3109 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3110 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3111
3112 std::string rs = GPR(copy(rs_value));
3113 std::string rt = GPR(copy(rt_value));
3114 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3115
3116 return img::format("BEQC %s, %s, %s", rs, rt, s);
3117 }
3118
3119
3120 /*
3121 *
3122 *
3123 * 3 2 1
3124 * 10987654321098765432109876543210
3125 * 001000 x1110000101
3126 * rt -----
3127 * rs -----
3128 * rd -----
3129 */
3130 std::string NMD::BEQIC(uint64 instruction)
3131 {
3132 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3133 uint64 u_value = extract_u_17_16_15_14_13_12_11(instruction);
3134 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
3135
3136 std::string rt = GPR(copy(rt_value));
3137 std::string u = IMMEDIATE(copy(u_value));
3138 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3139
3140 return img::format("BEQIC %s, %s, %s", rt, u, s);
3141 }
3142
3143
3144 /*
3145 *
3146 *
3147 * 3 2 1
3148 * 10987654321098765432109876543210
3149 * 001000 x1110000101
3150 * rt -----
3151 * rs -----
3152 * rd -----
3153 */
3154 std::string NMD::BEQZC_16_(uint64 instruction)
3155 {
3156 uint64 rt3_value = extract_rt3_9_8_7(instruction);
3157 int64 s_value = extract_s__se7_0_6_5_4_3_2_1_s1(instruction);
3158
3159 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
3160 std::string s = ADDRESS(encode_s_from_address(s_value), 2);
3161
3162 return img::format("BEQZC %s, %s", rt3, s);
3163 }
3164
3165
3166 /*
3167 *
3168 *
3169 * 3 2 1
3170 * 10987654321098765432109876543210
3171 * 001000 x1110000101
3172 * rt -----
3173 * rs -----
3174 * rd -----
3175 */
3176 std::string NMD::BGEC(uint64 instruction)
3177 {
3178 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3179 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3180 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3181
3182 std::string rs = GPR(copy(rs_value));
3183 std::string rt = GPR(copy(rt_value));
3184 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3185
3186 return img::format("BGEC %s, %s, %s", rs, rt, s);
3187 }
3188
3189
3190 /*
3191 *
3192 *
3193 * 3 2 1
3194 * 10987654321098765432109876543210
3195 * 001000 x1110000101
3196 * rt -----
3197 * rs -----
3198 * rd -----
3199 */
3200 std::string NMD::BGEIC(uint64 instruction)
3201 {
3202 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3203 uint64 u_value = extract_u_17_16_15_14_13_12_11(instruction);
3204 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
3205
3206 std::string rt = GPR(copy(rt_value));
3207 std::string u = IMMEDIATE(copy(u_value));
3208 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3209
3210 return img::format("BGEIC %s, %s, %s", rt, u, s);
3211 }
3212
3213
3214 /*
3215 *
3216 *
3217 * 3 2 1
3218 * 10987654321098765432109876543210
3219 * 001000 x1110000101
3220 * rt -----
3221 * rs -----
3222 * rd -----
3223 */
3224 std::string NMD::BGEIUC(uint64 instruction)
3225 {
3226 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3227 uint64 u_value = extract_u_17_16_15_14_13_12_11(instruction);
3228 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
3229
3230 std::string rt = GPR(copy(rt_value));
3231 std::string u = IMMEDIATE(copy(u_value));
3232 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3233
3234 return img::format("BGEIUC %s, %s, %s", rt, u, s);
3235 }
3236
3237
3238 /*
3239 *
3240 *
3241 * 3 2 1
3242 * 10987654321098765432109876543210
3243 * 001000 x1110000101
3244 * rt -----
3245 * rs -----
3246 * rd -----
3247 */
3248 std::string NMD::BGEUC(uint64 instruction)
3249 {
3250 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3251 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3252 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3253
3254 std::string rs = GPR(copy(rs_value));
3255 std::string rt = GPR(copy(rt_value));
3256 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3257
3258 return img::format("BGEUC %s, %s, %s", rs, rt, s);
3259 }
3260
3261
3262 /*
3263 *
3264 *
3265 * 3 2 1
3266 * 10987654321098765432109876543210
3267 * 001000 x1110000101
3268 * rt -----
3269 * rs -----
3270 * rd -----
3271 */
3272 std::string NMD::BLTC(uint64 instruction)
3273 {
3274 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3275 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3276 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3277
3278 std::string rs = GPR(copy(rs_value));
3279 std::string rt = GPR(copy(rt_value));
3280 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3281
3282 return img::format("BLTC %s, %s, %s", rs, rt, s);
3283 }
3284
3285
3286 /*
3287 *
3288 *
3289 * 3 2 1
3290 * 10987654321098765432109876543210
3291 * 001000 x1110000101
3292 * rt -----
3293 * rs -----
3294 * rd -----
3295 */
3296 std::string NMD::BLTIC(uint64 instruction)
3297 {
3298 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3299 uint64 u_value = extract_u_17_16_15_14_13_12_11(instruction);
3300 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
3301
3302 std::string rt = GPR(copy(rt_value));
3303 std::string u = IMMEDIATE(copy(u_value));
3304 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3305
3306 return img::format("BLTIC %s, %s, %s", rt, u, s);
3307 }
3308
3309
3310 /*
3311 *
3312 *
3313 * 3 2 1
3314 * 10987654321098765432109876543210
3315 * 001000 x1110000101
3316 * rt -----
3317 * rs -----
3318 * rd -----
3319 */
3320 std::string NMD::BLTIUC(uint64 instruction)
3321 {
3322 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3323 uint64 u_value = extract_u_17_16_15_14_13_12_11(instruction);
3324 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
3325
3326 std::string rt = GPR(copy(rt_value));
3327 std::string u = IMMEDIATE(copy(u_value));
3328 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3329
3330 return img::format("BLTIUC %s, %s, %s", rt, u, s);
3331 }
3332
3333
3334 /*
3335 *
3336 *
3337 * 3 2 1
3338 * 10987654321098765432109876543210
3339 * 001000 x1110000101
3340 * rt -----
3341 * rs -----
3342 * rd -----
3343 */
3344 std::string NMD::BLTUC(uint64 instruction)
3345 {
3346 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3347 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3348 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3349
3350 std::string rs = GPR(copy(rs_value));
3351 std::string rt = GPR(copy(rt_value));
3352 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3353
3354 return img::format("BLTUC %s, %s, %s", rs, rt, s);
3355 }
3356
3357
3358 /*
3359 *
3360 *
3361 * 3 2 1
3362 * 10987654321098765432109876543210
3363 * 001000 x1110000101
3364 * rt -----
3365 * rs -----
3366 * rd -----
3367 */
3368 std::string NMD::BNEC_16_(uint64 instruction)
3369 {
3370 uint64 rt3_value = extract_rt3_9_8_7(instruction);
3371 uint64 rs3_value = extract_rs3_6_5_4(instruction);
3372 uint64 u_value = extract_u_3_2_1_0__s1(instruction);
3373
3374 std::string rs3 = GPR(encode_rs3_and_check_rs3_ge_rt3(rs3_value));
3375 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
3376 std::string u = ADDRESS(encode_u_from_address(u_value), 2);
3377
3378 return img::format("BNEC %s, %s, %s", rs3, rt3, u);
3379 }
3380
3381
3382 /*
3383 *
3384 *
3385 * 3 2 1
3386 * 10987654321098765432109876543210
3387 * 001000 x1110000101
3388 * rt -----
3389 * rs -----
3390 * rd -----
3391 */
3392 std::string NMD::BNEC_32_(uint64 instruction)
3393 {
3394 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3395 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3396 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3397
3398 std::string rs = GPR(copy(rs_value));
3399 std::string rt = GPR(copy(rt_value));
3400 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3401
3402 return img::format("BNEC %s, %s, %s", rs, rt, s);
3403 }
3404
3405
3406 /*
3407 *
3408 *
3409 * 3 2 1
3410 * 10987654321098765432109876543210
3411 * 001000 x1110000101
3412 * rt -----
3413 * rs -----
3414 * rd -----
3415 */
3416 std::string NMD::BNEIC(uint64 instruction)
3417 {
3418 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3419 uint64 u_value = extract_u_17_16_15_14_13_12_11(instruction);
3420 int64 s_value = extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction);
3421
3422 std::string rt = GPR(copy(rt_value));
3423 std::string u = IMMEDIATE(copy(u_value));
3424 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3425
3426 return img::format("BNEIC %s, %s, %s", rt, u, s);
3427 }
3428
3429
3430 /*
3431 *
3432 *
3433 * 3 2 1
3434 * 10987654321098765432109876543210
3435 * 001000 x1110000101
3436 * rt -----
3437 * rs -----
3438 * rd -----
3439 */
3440 std::string NMD::BNEZC_16_(uint64 instruction)
3441 {
3442 uint64 rt3_value = extract_rt3_9_8_7(instruction);
3443 int64 s_value = extract_s__se7_0_6_5_4_3_2_1_s1(instruction);
3444
3445 std::string rt3 = GPR(decode_gpr_gpr3(rt3_value));
3446 std::string s = ADDRESS(encode_s_from_address(s_value), 2);
3447
3448 return img::format("BNEZC %s, %s", rt3, s);
3449 }
3450
3451
3452 /*
3453 * [DSP] BPOSGE32C offset - Branch on greater than or equal to value 32 in
3454 * DSPControl Pos field
3455 *
3456 * 3 2 1
3457 * 10987654321098765432109876543210
3458 * 100010xxxxx0010001
3459 * s[13:1] -------------
3460 * s[14] -
3461 */
3462 std::string NMD::BPOSGE32C(uint64 instruction)
3463 {
3464 int64 s_value = extract_s__se14_0_13_to_1_s1(instruction);
3465
3466 std::string s = ADDRESS(encode_s_from_address(s_value), 4);
3467
3468 return img::format("BPOSGE32C %s", s);
3469 }
3470
3471
3472 /*
3473 *
3474 *
3475 * 3 2 1
3476 * 10987654321098765432109876543210
3477 * 001000 x1110000101
3478 * rt -----
3479 * rs -----
3480 * rd -----
3481 */
3482 std::string NMD::BREAK_16_(uint64 instruction)
3483 {
3484 uint64 code_value = extract_code_2_1_0(instruction);
3485
3486 std::string code = IMMEDIATE(copy(code_value));
3487
3488 return img::format("BREAK %s", code);
3489 }
3490
3491
3492 /*
3493 * BREAK code - Break. Cause a Breakpoint exception
3494 *
3495 * 3 2 1
3496 * 10987654321098765432109876543210
3497 * 001000 x1110000101
3498 * rt -----
3499 * rs -----
3500 * rd -----
3501 */
3502 std::string NMD::BREAK_32_(uint64 instruction)
3503 {
3504 uint64 code_value = extract_code_18_to_0(instruction);
3505
3506 std::string code = IMMEDIATE(copy(code_value));
3507
3508 return img::format("BREAK %s", code);
3509 }
3510
3511
3512 /*
3513 *
3514 *
3515 * 3 2 1
3516 * 10987654321098765432109876543210
3517 * 001000 x1110000101
3518 * rt -----
3519 * rs -----
3520 * rd -----
3521 */
3522 std::string NMD::BRSC(uint64 instruction)
3523 {
3524 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3525
3526 std::string rs = GPR(copy(rs_value));
3527
3528 return img::format("BRSC %s", rs);
3529 }
3530
3531
3532 /*
3533 *
3534 *
3535 * 3 2 1
3536 * 10987654321098765432109876543210
3537 * 001000 x1110000101
3538 * rt -----
3539 * rs -----
3540 * rd -----
3541 */
3542 std::string NMD::CACHE(uint64 instruction)
3543 {
3544 uint64 op_value = extract_op_25_24_23_22_21(instruction);
3545 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3546 int64 s_value = extract_s__se8_15_7_6_5_4_3_2_1_0(instruction);
3547
3548 std::string op = IMMEDIATE(copy(op_value));
3549 std::string s = IMMEDIATE(copy(s_value));
3550 std::string rs = GPR(copy(rs_value));
3551
3552 return img::format("CACHE %s, %s(%s)", op, s, rs);
3553 }
3554
3555
3556 /*
3557 *
3558 *
3559 * 3 2 1
3560 * 10987654321098765432109876543210
3561 * 001000 x1110000101
3562 * rt -----
3563 * rs -----
3564 * rd -----
3565 */
3566 std::string NMD::CACHEE(uint64 instruction)
3567 {
3568 uint64 op_value = extract_op_25_24_23_22_21(instruction);
3569 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3570 int64 s_value = extract_s__se8_15_7_6_5_4_3_2_1_0(instruction);
3571
3572 std::string op = IMMEDIATE(copy(op_value));
3573 std::string s = IMMEDIATE(copy(s_value));
3574 std::string rs = GPR(copy(rs_value));
3575
3576 return img::format("CACHEE %s, %s(%s)", op, s, rs);
3577 }
3578
3579
3580 /*
3581 *
3582 *
3583 * 3 2 1
3584 * 10987654321098765432109876543210
3585 * 001000 x1110000101
3586 * rt -----
3587 * rs -----
3588 * rd -----
3589 */
3590 std::string NMD::CEIL_L_D(uint64 instruction)
3591 {
3592 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3593 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3594
3595 std::string ft = FPR(copy(ft_value));
3596 std::string fs = FPR(copy(fs_value));
3597
3598 return img::format("CEIL.L.D %s, %s", ft, fs);
3599 }
3600
3601
3602 /*
3603 *
3604 *
3605 * 3 2 1
3606 * 10987654321098765432109876543210
3607 * 001000 x1110000101
3608 * rt -----
3609 * rs -----
3610 * rd -----
3611 */
3612 std::string NMD::CEIL_L_S(uint64 instruction)
3613 {
3614 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3615 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3616
3617 std::string ft = FPR(copy(ft_value));
3618 std::string fs = FPR(copy(fs_value));
3619
3620 return img::format("CEIL.L.S %s, %s", ft, fs);
3621 }
3622
3623
3624 /*
3625 *
3626 *
3627 * 3 2 1
3628 * 10987654321098765432109876543210
3629 * 001000 x1110000101
3630 * rt -----
3631 * rs -----
3632 * rd -----
3633 */
3634 std::string NMD::CEIL_W_D(uint64 instruction)
3635 {
3636 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3637 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3638
3639 std::string ft = FPR(copy(ft_value));
3640 std::string fs = FPR(copy(fs_value));
3641
3642 return img::format("CEIL.W.D %s, %s", ft, fs);
3643 }
3644
3645
3646 /*
3647 *
3648 *
3649 * 3 2 1
3650 * 10987654321098765432109876543210
3651 * 001000 x1110000101
3652 * rt -----
3653 * rs -----
3654 * rd -----
3655 */
3656 std::string NMD::CEIL_W_S(uint64 instruction)
3657 {
3658 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3659 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3660
3661 std::string ft = FPR(copy(ft_value));
3662 std::string fs = FPR(copy(fs_value));
3663
3664 return img::format("CEIL.W.S %s, %s", ft, fs);
3665 }
3666
3667
3668 /*
3669 *
3670 *
3671 * 3 2 1
3672 * 10987654321098765432109876543210
3673 * 001000 x1110000101
3674 * rt -----
3675 * rs -----
3676 * rd -----
3677 */
3678 std::string NMD::CFC1(uint64 instruction)
3679 {
3680 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3681 uint64 cs_value = extract_cs_20_19_18_17_16(instruction);
3682
3683 std::string rt = GPR(copy(rt_value));
3684 std::string cs = CPR(copy(cs_value));
3685
3686 return img::format("CFC1 %s, %s", rt, cs);
3687 }
3688
3689
3690 /*
3691 *
3692 *
3693 * 3 2 1
3694 * 10987654321098765432109876543210
3695 * 001000 x1110000101
3696 * rt -----
3697 * rs -----
3698 * rd -----
3699 */
3700 std::string NMD::CFC2(uint64 instruction)
3701 {
3702 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3703 uint64 cs_value = extract_cs_20_19_18_17_16(instruction);
3704
3705 std::string rt = GPR(copy(rt_value));
3706 std::string cs = CPR(copy(cs_value));
3707
3708 return img::format("CFC2 %s, %s", rt, cs);
3709 }
3710
3711
3712 /*
3713 *
3714 *
3715 * 3 2 1
3716 * 10987654321098765432109876543210
3717 * 001000 x1110000101
3718 * rt -----
3719 * rs -----
3720 * rd -----
3721 */
3722 std::string NMD::CLASS_D(uint64 instruction)
3723 {
3724 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3725 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3726
3727 std::string ft = FPR(copy(ft_value));
3728 std::string fs = FPR(copy(fs_value));
3729
3730 return img::format("CLASS.D %s, %s", ft, fs);
3731 }
3732
3733
3734 /*
3735 *
3736 *
3737 * 3 2 1
3738 * 10987654321098765432109876543210
3739 * 001000 x1110000101
3740 * rt -----
3741 * rs -----
3742 * rd -----
3743 */
3744 std::string NMD::CLASS_S(uint64 instruction)
3745 {
3746 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3747 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3748
3749 std::string ft = FPR(copy(ft_value));
3750 std::string fs = FPR(copy(fs_value));
3751
3752 return img::format("CLASS.S %s, %s", ft, fs);
3753 }
3754
3755
3756 /*
3757 *
3758 *
3759 * 3 2 1
3760 * 10987654321098765432109876543210
3761 * 001000 x1110000101
3762 * rt -----
3763 * rs -----
3764 * rd -----
3765 */
3766 std::string NMD::CLO(uint64 instruction)
3767 {
3768 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3769 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3770
3771 std::string rt = GPR(copy(rt_value));
3772 std::string rs = GPR(copy(rs_value));
3773
3774 return img::format("CLO %s, %s", rt, rs);
3775 }
3776
3777
3778 /*
3779 *
3780 *
3781 * 3 2 1
3782 * 10987654321098765432109876543210
3783 * 001000 x1110000101
3784 * rt -----
3785 * rs -----
3786 * rd -----
3787 */
3788 std::string NMD::CLZ(uint64 instruction)
3789 {
3790 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3791 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3792
3793 std::string rt = GPR(copy(rt_value));
3794 std::string rs = GPR(copy(rs_value));
3795
3796 return img::format("CLZ %s, %s", rt, rs);
3797 }
3798
3799
3800 /*
3801 *
3802 *
3803 * 3 2 1
3804 * 10987654321098765432109876543210
3805 * 001000 x1110000101
3806 * rt -----
3807 * rs -----
3808 * rd -----
3809 */
3810 std::string NMD::CMP_AF_D(uint64 instruction)
3811 {
3812 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3813 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3814 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
3815
3816 std::string fd = FPR(copy(fd_value));
3817 std::string fs = FPR(copy(fs_value));
3818 std::string ft = FPR(copy(ft_value));
3819
3820 return img::format("CMP.AF.D %s, %s, %s", fd, fs, ft);
3821 }
3822
3823
3824 /*
3825 *
3826 *
3827 * 3 2 1
3828 * 10987654321098765432109876543210
3829 * 001000 x1110000101
3830 * rt -----
3831 * rs -----
3832 * rd -----
3833 */
3834 std::string NMD::CMP_AF_S(uint64 instruction)
3835 {
3836 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3837 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3838 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
3839
3840 std::string fd = FPR(copy(fd_value));
3841 std::string fs = FPR(copy(fs_value));
3842 std::string ft = FPR(copy(ft_value));
3843
3844 return img::format("CMP.AF.S %s, %s, %s", fd, fs, ft);
3845 }
3846
3847
3848 /*
3849 *
3850 *
3851 * 3 2 1
3852 * 10987654321098765432109876543210
3853 * 001000 x1110000101
3854 * rt -----
3855 * rs -----
3856 * rd -----
3857 */
3858 std::string NMD::CMP_EQ_D(uint64 instruction)
3859 {
3860 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3861 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3862 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
3863
3864 std::string fd = FPR(copy(fd_value));
3865 std::string fs = FPR(copy(fs_value));
3866 std::string ft = FPR(copy(ft_value));
3867
3868 return img::format("CMP.EQ.D %s, %s, %s", fd, fs, ft);
3869 }
3870
3871
3872 /*
3873 * [DSP] CMP.EQ.PH rs, rt - Compare vectors of signed integer halfword values
3874 *
3875 * 3 2 1
3876 * 10987654321098765432109876543210
3877 * 001000 xxxxxx0000000101
3878 * rt -----
3879 * rs -----
3880 */
3881 std::string NMD::CMP_EQ_PH(uint64 instruction)
3882 {
3883 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3884 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3885
3886 std::string rs = GPR(copy(rs_value));
3887 std::string rt = GPR(copy(rt_value));
3888
3889 return img::format("CMP.EQ.PH %s, %s", rs, rt);
3890 }
3891
3892
3893 /*
3894 *
3895 *
3896 * 3 2 1
3897 * 10987654321098765432109876543210
3898 * 001000 x1110000101
3899 * rt -----
3900 * rs -----
3901 * rd -----
3902 */
3903 std::string NMD::CMP_EQ_S(uint64 instruction)
3904 {
3905 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3906 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3907 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
3908
3909 std::string fd = FPR(copy(fd_value));
3910 std::string fs = FPR(copy(fs_value));
3911 std::string ft = FPR(copy(ft_value));
3912
3913 return img::format("CMP.EQ.S %s, %s, %s", fd, fs, ft);
3914 }
3915
3916
3917 /*
3918 *
3919 *
3920 * 3 2 1
3921 * 10987654321098765432109876543210
3922 * 001000 x1110000101
3923 * rt -----
3924 * rs -----
3925 * rd -----
3926 */
3927 std::string NMD::CMP_LE_D(uint64 instruction)
3928 {
3929 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3930 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3931 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
3932
3933 std::string fd = FPR(copy(fd_value));
3934 std::string fs = FPR(copy(fs_value));
3935 std::string ft = FPR(copy(ft_value));
3936
3937 return img::format("CMP.LE.D %s, %s, %s", fd, fs, ft);
3938 }
3939
3940
3941 /*
3942 * [DSP] CMP.LE.PH rs, rt - Compare vectors of signed integer halfword values
3943 *
3944 * 3 2 1
3945 * 10987654321098765432109876543210
3946 * 001000 xxxxxx0010000101
3947 * rt -----
3948 * rs -----
3949 */
3950 std::string NMD::CMP_LE_PH(uint64 instruction)
3951 {
3952 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
3953 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
3954
3955 std::string rs = GPR(copy(rs_value));
3956 std::string rt = GPR(copy(rt_value));
3957
3958 return img::format("CMP.LE.PH %s, %s", rs, rt);
3959 }
3960
3961
3962 /*
3963 *
3964 *
3965 * 3 2 1
3966 * 10987654321098765432109876543210
3967 * 001000 x1110000101
3968 * rt -----
3969 * rs -----
3970 * rd -----
3971 */
3972 std::string NMD::CMP_LE_S(uint64 instruction)
3973 {
3974 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3975 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
3976 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
3977
3978 std::string fd = FPR(copy(fd_value));
3979 std::string fs = FPR(copy(fs_value));
3980 std::string ft = FPR(copy(ft_value));
3981
3982 return img::format("CMP.LE.S %s, %s, %s", fd, fs, ft);
3983 }
3984
3985
3986 /*
3987 *
3988 *
3989 * 3 2 1
3990 * 10987654321098765432109876543210
3991 * 001000 x1110000101
3992 * rt -----
3993 * rs -----
3994 * rd -----
3995 */
3996 std::string NMD::CMP_LT_D(uint64 instruction)
3997 {
3998 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
3999 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
4000 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);
4001
4002 std::string fd = FPR(copy(fd_value));
4003 std::string fs = FPR(copy(fs_value));
4004 std::string ft = FPR(copy(ft_value));
4005
4006 return img::format("CMP.LT.D %s, %s, %s", fd, fs, ft);
4007 }
4008
4009
4010 /*
4011 * [DSP] CMP.LT.PH rs, rt - Compare vectors of signed integer halfword values
4012 *
4013 * 3 2 1
4014 * 10987654321098765432109876543210
4015 * 001000 xxxxxx0001000101
4016 * rt -----
4017 * rs -----
4018 */
4019 std::string NMD::CMP_LT_PH(uint64 instruction)
4020 {
4021 uint64 rt_value = extract_rt_25_24_23_22_21(instruction);
4022 uint64 rs_value = extract_rs_20_19_18_17_16(instruction);
4023
4024 std::string rs = GPR(copy(rs_value));
4025 std::string rt = GPR(copy(rt_value));
4026
4027 return img::format("CMP.LT.PH %s, %s", rs, rt);
4028 }
4029
4030
4031 /*
4032 *
4033 *
4034 * 3 2 1
4035 * 10987654321098765432109876543210
4036 * 001000 x1110000101
4037 * rt -----
4038 * rs -----
4039 * rd -----
4040 */
4041 std::string NMD::CMP_LT_S(uint64 instruction)
4042 {
4043 uint64 ft_value = extract_ft_25_24_23_22_21(instruction);
4044 uint64 fs_value = extract_fs_20_19_18_17_16(instruction);
4045 uint64 fd_value = extract_fd_15_14_13_12_11(instruction);