2 * Source file for nanoMIPS disassembler component of QEMU
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>
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.
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.
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/>.
24 * Documentation used while implementing this component:
26 * [1] "MIPSĀ® Architecture Base: nanoMIPS32(tm) Instruction Set Technical
27 * Reference Manual", Revision 01.01, April 27, 2018
31 #include "qemu/osdep.h"
32 #include "disas/dis-asm.h"
43 #define IMGASSERTONCE(test)
46 int nanomips_dis(char *buf
,
53 uint16 bits
[3] = {one
, two
, three
};
55 NMD
::TABLE_ENTRY_TYPE type
;
56 NMD
d(address
, NMD
::ALL_ATTRIBUTES
);
57 int size
= d
.Disassemble(bits
, disasm
, type
);
59 strcpy(buf
, disasm
.c_str());
63 int print_insn_nanomips(bfd_vma memaddr
, struct disassemble_info
*info
)
67 uint16_t insn1
= 0, insn2
= 0, insn3
= 0;
70 info
->bytes_per_chunk
= 2;
71 info
->display_endian
= info
->endian
;
72 info
->insn_info_valid
= 1;
73 info
->branch_delay_insns
= 0;
75 info
->insn_type
= dis_nonbranch
;
79 status
= (*info
->read_memory_func
)(memaddr
, buffer
, 2, info
);
81 (*info
->memory_error_func
)(status
, memaddr
, info
);
85 if (info
->endian
== BFD_ENDIAN_BIG
) {
86 insn1
= bfd_getb16(buffer
);
88 insn1
= bfd_getl16(buffer
);
90 (*info
->fprintf_func
)(info
->stream
, "%04x ", insn1
);
92 /* Handle 32-bit opcodes. */
93 if ((insn1
& 0x1000) == 0) {
94 status
= (*info
->read_memory_func
)(memaddr
+ 2, buffer
, 2, info
);
96 (*info
->memory_error_func
)(status
, memaddr
+ 2, info
);
100 if (info
->endian
== BFD_ENDIAN_BIG
) {
101 insn2
= bfd_getb16(buffer
);
103 insn2
= bfd_getl16(buffer
);
105 (*info
->fprintf_func
)(info
->stream
, "%04x ", insn2
);
107 (*info
->fprintf_func
)(info
->stream
, " ");
109 /* Handle 48-bit opcodes. */
110 if ((insn1
>> 10) == 0x18) {
111 status
= (*info
->read_memory_func
)(memaddr
+ 4, buffer
, 2, info
);
113 (*info
->memory_error_func
)(status
, memaddr
+ 4, info
);
117 if (info
->endian
== BFD_ENDIAN_BIG
) {
118 insn3
= bfd_getb16(buffer
);
120 insn3
= bfd_getl16(buffer
);
122 (*info
->fprintf_func
)(info
->stream
, "%04x ", insn3
);
124 (*info
->fprintf_func
)(info
->stream
, " ");
127 int length
= nanomips_dis(buf
, memaddr
, insn1
, insn2
, insn3
);
129 /* FIXME: Should probably use a hash table on the major opcode here. */
131 (*info
->fprintf_func
) (info
->stream
, "%s", buf
);
136 info
->insn_type
= dis_noninsn
;
138 return insn3 ?
6 : insn2 ?
4 : 2;
144 address
addr32(address a
)
149 std
::string
format(const char *format
, ...)
153 va_start(args
, format
);
154 int err
= vsprintf(buffer
, format
, args
);
162 std
::string
format(const char *format
,
167 sprintf(buffer
, format
, s
.c_str());
172 std
::string
format(const char *format
,
178 sprintf(buffer
, format
, s1
.c_str(), s2
.c_str());
183 std
::string
format(const char *format
,
190 sprintf(buffer
, format
, s1
.c_str(), s2
.c_str(), s3
.c_str());
195 std
::string
format(const char *format
,
203 sprintf(buffer
, format
, s1
.c_str(), s2
.c_str(), s3
.c_str(),
209 std
::string
format(const char *format
,
218 sprintf(buffer
, format
, s1
.c_str(), s2
.c_str(), s3
.c_str(),
219 s4
.c_str(), s5
.c_str());
224 std
::string
format(const char *format
,
230 sprintf(buffer
, format
, d
, s2
.c_str());
235 std
::string
format(const char *format
,
242 sprintf(buffer
, format
, s1
.c_str(), d
, s2
.c_str());
247 std
::string
format(const char *format
,
254 sprintf(buffer
, format
, s1
.c_str(), s2
.c_str(), d
);
261 return static_cast<char>(c
);
266 std
::string
to_string(img
::address a
)
269 sprintf(buffer
, "0x%" PRIx64
, a
);
274 uint64
extract_bits(uint64 data
, uint32 bit_offset
, uint32 bit_size
)
276 return (data
<< (64 - (bit_size
+ bit_offset
))) >> (64 - bit_size
);
280 int64
sign_extend(int64 data
, int msb
)
282 uint64 shift
= 63 - msb
;
283 return (data
<< shift
) >> shift
;
287 uint64 NMD
::renumber_registers(uint64 index
, uint64
*register_list
,
288 size_t register_list_size
)
290 if (index
< register_list_size
) {
291 return register_list
[index
];
294 throw std
::runtime_error(img
::format(
295 "Invalid register mapping index %" PRIu64
296 ", size of list = %zu",
297 index
, register_list_size
));
302 * NMD::decode_gpr_gpr4() - decoder for 'gpr4' gpr encoding type
304 * Map a 4-bit code to the 5-bit register space according to this pattern:
307 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
308 * | | | | | | | | | | | | | | | |
309 * | | | | | | | | | | | | | | | |
310 * | | | | | | | | | | | ā---------------ā
311 * | | | | | | | | | | ā---------------ā |
312 * | | | | | | | | | ā---------------ā | |
313 * | | | | | | | | ā---------------ā | | |
314 * | | | | | | | | | | | | | | | |
315 * | | | | | | | | | | | | | | | |
316 * 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
319 * Used in handling following instructions:
327 uint64 NMD
::decode_gpr_gpr4(uint64 d
)
329 static uint64 register_list
[] = { 8, 9, 10, 11, 4, 5, 6, 7,
330 16, 17, 18, 19, 20, 21, 22, 23 };
331 return renumber_registers(d
, register_list
,
332 sizeof(register_list
) / sizeof(register_list
[0]));
337 * NMD::decode_gpr_gpr4_zero() - decoder for 'gpr4.zero' gpr encoding type
339 * Map a 4-bit code to the 5-bit register space according to this pattern:
342 * 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
343 * | | | | | | | | | | | | | | | |
344 * | | | | | | | | | | | | ā---------------------ā
345 * | | | | | | | | | | | ā---------------ā |
346 * | | | | | | | | | | ā---------------ā | |
347 * | | | | | | | | | ā---------------ā | | |
348 * | | | | | | | | ā---------------ā | | | |
349 * | | | | | | | | | | | | | | | |
350 * | | | | | | | | | | | | | | | |
351 * 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
354 * This pattern is the same one used for 'gpr4' gpr encoding type, except for
355 * the input value 3, that is mapped to the output value 0 instead of 11.
357 * Used in handling following instructions:
363 uint64 NMD
::decode_gpr_gpr4_zero(uint64 d
)
365 static uint64 register_list
[] = { 8, 9, 10, 0, 4, 5, 6, 7,
366 16, 17, 18, 19, 20, 21, 22, 23 };
367 return renumber_registers(d
, register_list
,
368 sizeof(register_list
) / sizeof(register_list
[0]));
373 * NMD::decode_gpr_gpr3() - decoder for 'gpr3' gpr encoding type
375 * Map a 3-bit code to the 5-bit register space according to this pattern:
380 * | | | ā-----------------------ā
381 * | | ā-----------------------ā |
382 * | ā-----------------------ā | |
383 * ā-----------------------ā | | |
385 * ā-------ā | | | | | | |
386 * | ā-------ā | | | | | |
387 * | | ā-------ā | | | | |
388 * | | | ā-------ā | | | |
390 * 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
393 * Used in handling following instructions:
422 uint64 NMD
::decode_gpr_gpr3(uint64 d
)
424 static uint64 register_list
[] = { 16, 17, 18, 19, 4, 5, 6, 7 };
425 return renumber_registers(d
, register_list
,
426 sizeof(register_list
) / sizeof(register_list
[0]));
431 * NMD::decode_gpr_gpr3_src_store() - decoder for 'gpr3.src.store' gpr encoding
434 * Map a 3-bit code to the 5-bit register space according to this pattern:
438 * | | | | | | | ā-----------------------ā
439 * | | | ā-----------------------ā |
440 * | | ā-----------------------ā | |
441 * | ā-----------------------ā | | |
442 * ā-----------------------ā | | | |
444 * ā-------ā | | | | | | |
445 * | ā-------ā | | | | | |
446 * | | ā-------ā | | | | |
449 * 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
452 * This pattern is the same one used for 'gpr3' gpr encoding type, except for
453 * the input value 0, that is mapped to the output value 0 instead of 16.
455 * Used in handling following instructions:
462 uint64 NMD
::decode_gpr_gpr3_src_store(uint64 d
)
464 static uint64 register_list
[] = { 0, 17, 18, 19, 4, 5, 6, 7 };
465 return renumber_registers(d
, register_list
,
466 sizeof(register_list
) / sizeof(register_list
[0]));
471 * NMD::decode_gpr_gpr2_reg1() - decoder for 'gpr2.reg1' gpr encoding type
473 * Map a 2-bit code to the 5-bit register space according to this pattern:
478 * | | | ā-------------------ā
479 * | | ā-------------------ā |
480 * | ā-------------------ā | |
481 * ā-------------------ā | | |
484 * 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
487 * Used in handling following instructions:
492 uint64 NMD
::decode_gpr_gpr2_reg1(uint64 d
)
494 static uint64 register_list
[] = { 4, 5, 6, 7 };
495 return renumber_registers(d
, register_list
,
496 sizeof(register_list
) / sizeof(register_list
[0]));
501 * NMD::decode_gpr_gpr2_reg2() - decoder for 'gpr2.reg2' gpr encoding type
503 * Map a 2-bit code to the 5-bit register space according to this pattern:
508 * | | | ā-----------------ā
509 * | | ā-----------------ā |
510 * | ā-----------------ā | |
511 * ā-----------------ā | | |
514 * 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
517 * Used in handling following instructions:
522 uint64 NMD
::decode_gpr_gpr2_reg2(uint64 d
)
524 static uint64 register_list
[] = { 5, 6, 7, 8 };
525 return renumber_registers(d
, register_list
,
526 sizeof(register_list
) / sizeof(register_list
[0]));
531 * NMD::decode_gpr_gpr1() - decoder for 'gpr1' gpr encoding type
533 * Map a 1-bit code to the 5-bit register space according to this pattern:
538 * | ā---------------------ā
539 * ā---------------------ā |
544 * 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
547 * Used in handling following instruction:
551 uint64 NMD
::decode_gpr_gpr1(uint64 d
)
553 static uint64 register_list
[] = { 4, 5 };
554 return renumber_registers(d
, register_list
,
555 sizeof(register_list
) / sizeof(register_list
[0]));
559 uint64 NMD
::copy(uint64 d
)
565 int64 NMD
::copy(int64 d
)
571 int64 NMD
::neg_copy(uint64 d
)
577 int64 NMD
::neg_copy(int64 d
)
583 /* strange wrapper around gpr3 */
584 uint64 NMD
::encode_rs3_and_check_rs3_ge_rt3(uint64 d
)
586 return decode_gpr_gpr3(d
);
590 /* strange wrapper around gpr3 */
591 uint64 NMD
::encode_rs3_and_check_rs3_lt_rt3(uint64 d
)
593 return decode_gpr_gpr3(d
);
597 /* nop - done by extraction function */
598 uint64 NMD
::encode_s_from_address(uint64 d
)
604 /* nop - done by extraction function */
605 uint64 NMD
::encode_u_from_address(uint64 d
)
611 /* nop - done by extraction function */
612 uint64 NMD
::encode_s_from_s_hi(uint64 d
)
618 uint64 NMD
::encode_count3_from_count(uint64 d
)
620 IMGASSERTONCE(d
< 8);
621 return d
== 0ull ?
8ull : d
;
625 uint64 NMD
::encode_shift3_from_shift(uint64 d
)
627 IMGASSERTONCE(d
< 8);
628 return d
== 0ull ?
8ull : d
;
632 /* special value for load literal */
633 int64 NMD
::encode_eu_from_s_li16(uint64 d
)
635 IMGASSERTONCE(d
< 128);
636 return d
== 127 ?
-1 : (int64
)d
;
640 uint64 NMD
::encode_msbd_from_size(uint64 d
)
642 IMGASSERTONCE(d
< 32);
647 uint64 NMD
::encode_eu_from_u_andi16(uint64 d
)
649 IMGASSERTONCE(d
< 16);
660 uint64 NMD
::encode_msbd_from_pos_and_size(uint64 d
)
667 /* save16 / restore16 ???? */
668 uint64 NMD
::encode_rt1_from_rt(uint64 d
)
675 uint64 NMD
::encode_lsb_from_pos_and_size(uint64 d
)
681 std
::string NMD
::save_restore_list(uint64 rt
, uint64 count
, uint64 gp
)
685 for (uint64 counter
= 0; counter
!= count
; counter
++) {
686 bool use_gp
= gp
&& (counter
== count
- 1);
687 uint64 this_rt
= use_gp ?
28 : ((rt
& 0x10) | (rt
+ counter
)) & 0x1f;
688 str
+= img
::format(",%s", GPR(this_rt
));
695 std
::string NMD
::GPR(uint64 reg
)
697 static const char *gpr_reg
[32] = {
698 "zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
699 "a4", "a5", "a6", "a7", "r12", "r13", "r14", "r15",
700 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
701 "r24", "r25", "k0", "k1", "gp", "sp", "fp", "ra"
708 throw std
::runtime_error(img
::format("Invalid GPR register index %" PRIu64
,
713 std
::string NMD
::FPR(uint64 reg
)
715 static const char *fpr_reg
[32] = {
716 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
717 "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
718 "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
719 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"
726 throw std
::runtime_error(img
::format("Invalid FPR register index %" PRIu64
,
731 std
::string NMD
::AC(uint64 reg
)
733 static const char *ac_reg
[4] = {
734 "ac0", "ac1", "ac2", "ac3"
741 throw std
::runtime_error(img
::format("Invalid AC register index %" PRIu64
,
746 std
::string NMD
::IMMEDIATE(uint64 value
)
748 return img
::format("0x%" PRIx64
, value
);
752 std
::string NMD
::IMMEDIATE(int64 value
)
754 return img
::format("%" PRId64
, value
);
758 std
::string NMD
::CPR(uint64 reg
)
760 /* needs more work */
761 return img
::format("CP%" PRIu64
, reg
);
765 std
::string NMD
::ADDRESS(uint64 value
, int instruction_size
)
767 /* token for string replace */
768 /* const char TOKEN_REPLACE = (char)0xa2; */
769 img
::address address
= m_pc
+ value
+ instruction_size
;
770 /* symbol replacement */
771 /* return img::as_char(TOKEN_REPLACE) + to_string(address); */
772 return to_string(address
);
776 uint64 NMD
::extract_op_code_value(const uint16
* data
, int size
)
782 return ((uint64
)data
[0] << 16) | data
[1];
784 return ((uint64
)data
[0] << 32) | ((uint64
)data
[1] << 16) | data
[2];
791 int NMD
::Disassemble(const uint16
* data
, std
::string
& dis
,
792 NMD
::TABLE_ENTRY_TYPE
& type
)
794 return Disassemble(data
, dis
, type
, MAJOR
, 2);
799 * Recurse through tables until the instruction is found then return
800 * the string and size
803 * pointer to a word stream,
804 * disassember table and size
806 * instruction size - negative is error
807 * disassembly string - on error will constain error string
809 int NMD
::Disassemble(const uint16
* data
, std
::string
& dis
,
810 NMD
::TABLE_ENTRY_TYPE
& type
, const Pool
*table
,
815 for (int i
= 0; i
< table_size
; i
++) {
816 uint64 op_code
= extract_op_code_value(data
,
817 table
[i
].instructions_size
);
818 if ((op_code
& table
[i
].mask
) == table
[i
].value
) {
820 conditional_function cond
= table
[i
].condition
;
821 if ((cond
== 0) || (this->*cond
)(op_code
)) {
824 if (table
[i
].type
== pool
) {
825 return Disassemble(data
, dis
, type
,
827 table
[i
].next_table_size
);
828 } else if ((table
[i
].type
== instruction
) ||
829 (table
[i
].type
== call_instruction
) ||
830 (table
[i
].type
== branch_instruction
) ||
831 (table
[i
].type
== return_instruction
)) {
832 if ((table
[i
].attributes
!= 0) &&
833 (m_requested_instruction_categories
&
834 table
[i
].attributes
) == 0) {
836 * failed due to instruction having
837 * an ASE attribute and the requested version
838 * not having that attribute
840 dis
= "ASE attribute missmatch";
843 disassembly_function dis_fn
= table
[i
].disassembly
;
845 dis
= "disassembler failure - bad table entry";
848 type
= table
[i
].type
;
849 dis
= (this->*dis_fn
)(op_code
);
850 return table
[i
].instructions_size
;
852 dis
= "reserved instruction";
856 catch (std
::runtime_error
& e
)
859 return -3; /* runtime error */
865 catch (std
::exception
& e
)
868 return -4; /* runtime error */
871 dis
= "failed to disassemble";
872 return -1; /* failed to disassemble */
876 uint64 NMD
::extract_code_18_to_0(uint64 instruction
)
879 value
|= extract_bits(instruction
, 0, 19);
884 uint64 NMD
::extract_shift3_2_1_0(uint64 instruction
)
887 value
|= extract_bits(instruction
, 0, 3);
892 uint64 NMD
::extract_u_11_10_9_8_7_6_5_4_3__s3(uint64 instruction
)
895 value
|= extract_bits(instruction
, 3, 9) << 3;
900 uint64 NMD
::extract_count_3_2_1_0(uint64 instruction
)
903 value
|= extract_bits(instruction
, 0, 4);
908 uint64 NMD
::extract_rtz3_9_8_7(uint64 instruction
)
911 value
|= extract_bits(instruction
, 7, 3);
916 uint64 NMD
::extract_u_17_to_1__s1(uint64 instruction
)
919 value
|= extract_bits(instruction
, 1, 17) << 1;
924 int64 NMD
::extract_s__se9_20_19_18_17_16_15_14_13_12_11(uint64 instruction
)
927 value
|= extract_bits(instruction
, 11, 10);
928 value
= sign_extend(value
, 9);
933 int64 NMD
::extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(uint64 instruction
)
936 value
|= extract_bits(instruction
, 0, 1) << 11;
937 value
|= extract_bits(instruction
, 1, 10) << 1;
938 value
= sign_extend(value
, 11);
943 uint64 NMD
::extract_u_10(uint64 instruction
)
946 value
|= extract_bits(instruction
, 10, 1);
951 uint64 NMD
::extract_rtz4_27_26_25_23_22_21(uint64 instruction
)
954 value
|= extract_bits(instruction
, 21, 3);
955 value
|= extract_bits(instruction
, 25, 1) << 3;
960 uint64 NMD
::extract_sa_15_14_13_12_11(uint64 instruction
)
963 value
|= extract_bits(instruction
, 11, 5);
968 uint64 NMD
::extract_shift_4_3_2_1_0(uint64 instruction
)
971 value
|= extract_bits(instruction
, 0, 5);
976 uint64 NMD
::extract_shiftx_10_9_8_7__s1(uint64 instruction
)
979 value
|= extract_bits(instruction
, 7, 4) << 1;
984 uint64 NMD
::extract_hint_25_24_23_22_21(uint64 instruction
)
987 value
|= extract_bits(instruction
, 21, 5);
992 uint64 NMD
::extract_count3_14_13_12(uint64 instruction
)
995 value
|= extract_bits(instruction
, 12, 3);
1000 int64 NMD
::extract_s__se31_0_11_to_2_20_to_12_s12(uint64 instruction
)
1003 value
|= extract_bits(instruction
, 0, 1) << 31;
1004 value
|= extract_bits(instruction
, 2, 10) << 21;
1005 value
|= extract_bits(instruction
, 12, 9) << 12;
1006 value
= sign_extend(value
, 31);
1011 int64 NMD
::extract_s__se7_0_6_5_4_3_2_1_s1(uint64 instruction
)
1014 value
|= extract_bits(instruction
, 0, 1) << 7;
1015 value
|= extract_bits(instruction
, 1, 6) << 1;
1016 value
= sign_extend(value
, 7);
1021 uint64 NMD
::extract_u2_10_9(uint64 instruction
)
1024 value
|= extract_bits(instruction
, 9, 2);
1029 uint64 NMD
::extract_code_25_24_23_22_21_20_19_18_17_16(uint64 instruction
)
1032 value
|= extract_bits(instruction
, 16, 10);
1037 uint64 NMD
::extract_rs_20_19_18_17_16(uint64 instruction
)
1040 value
|= extract_bits(instruction
, 16, 5);
1045 uint64 NMD
::extract_u_2_1__s1(uint64 instruction
)
1048 value
|= extract_bits(instruction
, 1, 2) << 1;
1053 uint64 NMD
::extract_stripe_6(uint64 instruction
)
1056 value
|= extract_bits(instruction
, 6, 1);
1061 uint64 NMD
::extract_ac_15_14(uint64 instruction
)
1064 value
|= extract_bits(instruction
, 14, 2);
1069 uint64 NMD
::extract_shift_20_19_18_17_16(uint64 instruction
)
1072 value
|= extract_bits(instruction
, 16, 5);
1077 uint64 NMD
::extract_rdl_25_24(uint64 instruction
)
1080 value
|= extract_bits(instruction
, 24, 1);
1085 int64 NMD
::extract_s__se10_0_9_8_7_6_5_4_3_2_1_s1(uint64 instruction
)
1088 value
|= extract_bits(instruction
, 0, 1) << 10;
1089 value
|= extract_bits(instruction
, 1, 9) << 1;
1090 value
= sign_extend(value
, 10);
1095 uint64 NMD
::extract_eu_6_5_4_3_2_1_0(uint64 instruction
)
1098 value
|= extract_bits(instruction
, 0, 7);
1103 uint64 NMD
::extract_shift_5_4_3_2_1_0(uint64 instruction
)
1106 value
|= extract_bits(instruction
, 0, 6);
1111 uint64 NMD
::extract_count_19_18_17_16(uint64 instruction
)
1114 value
|= extract_bits(instruction
, 16, 4);
1119 uint64 NMD
::extract_code_2_1_0(uint64 instruction
)
1122 value
|= extract_bits(instruction
, 0, 3);
1127 uint64 NMD
::extract_u_11_10_9_8_7_6_5_4_3_2_1_0(uint64 instruction
)
1130 value
|= extract_bits(instruction
, 0, 12);
1135 uint64 NMD
::extract_rs_4_3_2_1_0(uint64 instruction
)
1138 value
|= extract_bits(instruction
, 0, 5);
1143 uint64 NMD
::extract_u_20_to_3__s3(uint64 instruction
)
1146 value
|= extract_bits(instruction
, 3, 18) << 3;
1151 uint64 NMD
::extract_u_3_2_1_0__s2(uint64 instruction
)
1154 value
|= extract_bits(instruction
, 0, 4) << 2;
1159 uint64 NMD
::extract_cofun_25_24_23(uint64 instruction
)
1162 value
|= extract_bits(instruction
, 3, 23);
1167 uint64 NMD
::extract_u_2_1_0__s2(uint64 instruction
)
1170 value
|= extract_bits(instruction
, 0, 3) << 2;
1175 uint64 NMD
::extract_rd3_3_2_1(uint64 instruction
)
1178 value
|= extract_bits(instruction
, 1, 3);
1183 uint64 NMD
::extract_sa_15_14_13_12(uint64 instruction
)
1186 value
|= extract_bits(instruction
, 12, 4);
1191 uint64 NMD
::extract_rt_25_24_23_22_21(uint64 instruction
)
1194 value
|= extract_bits(instruction
, 21, 5);
1199 uint64 NMD
::extract_ru_7_6_5_4_3(uint64 instruction
)
1202 value
|= extract_bits(instruction
, 3, 5);
1207 uint64 NMD
::extract_u_17_to_0(uint64 instruction
)
1210 value
|= extract_bits(instruction
, 0, 18);
1215 uint64 NMD
::extract_rsz4_4_2_1_0(uint64 instruction
)
1218 value
|= extract_bits(instruction
, 0, 3);
1219 value
|= extract_bits(instruction
, 4, 1) << 3;
1224 int64 NMD
::extract_s__se21_0_20_to_1_s1(uint64 instruction
)
1227 value
|= extract_bits(instruction
, 0, 1) << 21;
1228 value
|= extract_bits(instruction
, 1, 20) << 1;
1229 value
= sign_extend(value
, 21);
1234 uint64 NMD
::extract_op_25_to_3(uint64 instruction
)
1237 value
|= extract_bits(instruction
, 3, 23);
1242 uint64 NMD
::extract_rs4_4_2_1_0(uint64 instruction
)
1245 value
|= extract_bits(instruction
, 0, 3);
1246 value
|= extract_bits(instruction
, 4, 1) << 3;
1251 uint64 NMD
::extract_bit_23_22_21(uint64 instruction
)
1254 value
|= extract_bits(instruction
, 21, 3);
1259 uint64 NMD
::extract_rt_41_40_39_38_37(uint64 instruction
)
1262 value
|= extract_bits(instruction
, 37, 5);
1267 int64 NMD
::extract_shift__se5_21_20_19_18_17_16(uint64 instruction
)
1270 value
|= extract_bits(instruction
, 16, 6);
1271 value
= sign_extend(value
, 5);
1276 uint64 NMD
::extract_rd2_3_8(uint64 instruction
)
1279 value
|= extract_bits(instruction
, 3, 1) << 1;
1280 value
|= extract_bits(instruction
, 8, 1);
1285 uint64 NMD
::extract_code_17_to_0(uint64 instruction
)
1288 value
|= extract_bits(instruction
, 0, 18);
1293 uint64 NMD
::extract_size_20_19_18_17_16(uint64 instruction
)
1296 value
|= extract_bits(instruction
, 16, 5);
1301 int64 NMD
::extract_s__se8_15_7_6_5_4_3_2_s2(uint64 instruction
)
1304 value
|= extract_bits(instruction
, 2, 6) << 2;
1305 value
|= extract_bits(instruction
, 15, 1) << 8;
1306 value
= sign_extend(value
, 8);
1311 uint64 NMD
::extract_u_15_to_0(uint64 instruction
)
1314 value
|= extract_bits(instruction
, 0, 16);
1319 uint64 NMD
::extract_fs_20_19_18_17_16(uint64 instruction
)
1322 value
|= extract_bits(instruction
, 16, 5);
1327 int64 NMD
::extract_s__se8_15_7_6_5_4_3_2_1_0(uint64 instruction
)
1330 value
|= extract_bits(instruction
, 0, 8);
1331 value
|= extract_bits(instruction
, 15, 1) << 8;
1332 value
= sign_extend(value
, 8);
1337 uint64 NMD
::extract_stype_20_19_18_17_16(uint64 instruction
)
1340 value
|= extract_bits(instruction
, 16, 5);
1345 uint64 NMD
::extract_rtl_11(uint64 instruction
)
1348 value
|= extract_bits(instruction
, 9, 1);
1353 uint64 NMD
::extract_hs_20_19_18_17_16(uint64 instruction
)
1356 value
|= extract_bits(instruction
, 16, 5);
1361 uint64 NMD
::extract_sel_13_12_11(uint64 instruction
)
1364 value
|= extract_bits(instruction
, 11, 3);
1369 uint64 NMD
::extract_lsb_4_3_2_1_0(uint64 instruction
)
1372 value
|= extract_bits(instruction
, 0, 5);
1377 uint64 NMD
::extract_gp_2(uint64 instruction
)
1380 value
|= extract_bits(instruction
, 2, 1);
1385 uint64 NMD
::extract_rt3_9_8_7(uint64 instruction
)
1388 value
|= extract_bits(instruction
, 7, 3);
1393 uint64 NMD
::extract_ft_25_24_23_22_21(uint64 instruction
)
1396 value
|= extract_bits(instruction
, 21, 5);
1401 uint64 NMD
::extract_u_17_16_15_14_13_12_11(uint64 instruction
)
1404 value
|= extract_bits(instruction
, 11, 7);
1409 uint64 NMD
::extract_cs_20_19_18_17_16(uint64 instruction
)
1412 value
|= extract_bits(instruction
, 16, 5);
1417 uint64 NMD
::extract_rt4_9_7_6_5(uint64 instruction
)
1420 value
|= extract_bits(instruction
, 5, 3);
1421 value
|= extract_bits(instruction
, 9, 1) << 3;
1426 uint64 NMD
::extract_msbt_10_9_8_7_6(uint64 instruction
)
1429 value
|= extract_bits(instruction
, 6, 5);
1434 uint64 NMD
::extract_u_5_4_3_2_1_0__s2(uint64 instruction
)
1437 value
|= extract_bits(instruction
, 0, 6) << 2;
1442 uint64 NMD
::extract_sa_15_14_13(uint64 instruction
)
1445 value
|= extract_bits(instruction
, 13, 3);
1450 int64 NMD
::extract_s__se14_0_13_to_1_s1(uint64 instruction
)
1453 value
|= extract_bits(instruction
, 0, 1) << 14;
1454 value
|= extract_bits(instruction
, 1, 13) << 1;
1455 value
= sign_extend(value
, 14);
1460 uint64 NMD
::extract_rs3_6_5_4(uint64 instruction
)
1463 value
|= extract_bits(instruction
, 4, 3);
1468 uint64 NMD
::extract_u_31_to_0__s32(uint64 instruction
)
1471 value
|= extract_bits(instruction
, 0, 32) << 32;
1476 uint64 NMD
::extract_shift_10_9_8_7_6(uint64 instruction
)
1479 value
|= extract_bits(instruction
, 6, 5);
1484 uint64 NMD
::extract_cs_25_24_23_22_21(uint64 instruction
)
1487 value
|= extract_bits(instruction
, 21, 5);
1492 uint64 NMD
::extract_shiftx_11_10_9_8_7_6(uint64 instruction
)
1495 value
|= extract_bits(instruction
, 6, 6);
1500 uint64 NMD
::extract_rt_9_8_7_6_5(uint64 instruction
)
1503 value
|= extract_bits(instruction
, 5, 5);
1508 uint64 NMD
::extract_op_25_24_23_22_21(uint64 instruction
)
1511 value
|= extract_bits(instruction
, 21, 5);
1516 uint64 NMD
::extract_u_6_5_4_3_2_1_0__s2(uint64 instruction
)
1519 value
|= extract_bits(instruction
, 0, 7) << 2;
1524 uint64 NMD
::extract_bit_16_15_14_13_12_11(uint64 instruction
)
1527 value
|= extract_bits(instruction
, 11, 6);
1532 uint64 NMD
::extract_mask_20_19_18_17_16_15_14(uint64 instruction
)
1535 value
|= extract_bits(instruction
, 14, 7);
1540 uint64 NMD
::extract_eu_3_2_1_0(uint64 instruction
)
1543 value
|= extract_bits(instruction
, 0, 4);
1548 uint64 NMD
::extract_u_7_6_5_4__s4(uint64 instruction
)
1551 value
|= extract_bits(instruction
, 4, 4) << 4;
1556 int64 NMD
::extract_s__se8_15_7_6_5_4_3_s3(uint64 instruction
)
1559 value
|= extract_bits(instruction
, 3, 5) << 3;
1560 value
|= extract_bits(instruction
, 15, 1) << 8;
1561 value
= sign_extend(value
, 8);
1566 uint64 NMD
::extract_ft_15_14_13_12_11(uint64 instruction
)
1569 value
|= extract_bits(instruction
, 11, 5);
1574 int64 NMD
::extract_s__se31_15_to_0_31_to_16(uint64 instruction
)
1577 value
|= extract_bits(instruction
, 0, 16) << 16;
1578 value
|= extract_bits(instruction
, 16, 16);
1579 value
= sign_extend(value
, 31);
1584 uint64 NMD
::extract_u_20_19_18_17_16_15_14_13(uint64 instruction
)
1587 value
|= extract_bits(instruction
, 13, 8);
1592 uint64 NMD
::extract_u_17_to_2__s2(uint64 instruction
)
1595 value
|= extract_bits(instruction
, 2, 16) << 2;
1600 uint64 NMD
::extract_rd_15_14_13_12_11(uint64 instruction
)
1603 value
|= extract_bits(instruction
, 11, 5);
1608 uint64 NMD
::extract_c0s_20_19_18_17_16(uint64 instruction
)
1611 value
|= extract_bits(instruction
, 16, 5);
1616 uint64 NMD
::extract_code_1_0(uint64 instruction
)
1619 value
|= extract_bits(instruction
, 0, 2);
1624 int64 NMD
::extract_s__se25_0_24_to_1_s1(uint64 instruction
)
1627 value
|= extract_bits(instruction
, 0, 1) << 25;
1628 value
|= extract_bits(instruction
, 1, 24) << 1;
1629 value
= sign_extend(value
, 25);
1634 uint64 NMD
::extract_u_1_0(uint64 instruction
)
1637 value
|= extract_bits(instruction
, 0, 2);
1642 uint64 NMD
::extract_u_3_8__s2(uint64 instruction
)
1645 value
|= extract_bits(instruction
, 3, 1) << 3;
1646 value
|= extract_bits(instruction
, 8, 1) << 2;
1651 uint64 NMD
::extract_fd_15_14_13_12_11(uint64 instruction
)
1654 value
|= extract_bits(instruction
, 11, 5);
1659 uint64 NMD
::extract_u_4_3_2_1_0__s2(uint64 instruction
)
1662 value
|= extract_bits(instruction
, 0, 5) << 2;
1667 uint64 NMD
::extract_rtz4_9_7_6_5(uint64 instruction
)
1670 value
|= extract_bits(instruction
, 5, 3);
1671 value
|= extract_bits(instruction
, 9, 1) << 3;
1676 uint64 NMD
::extract_sel_15_14_13_12_11(uint64 instruction
)
1679 value
|= extract_bits(instruction
, 11, 5);
1684 uint64 NMD
::extract_ct_25_24_23_22_21(uint64 instruction
)
1687 value
|= extract_bits(instruction
, 21, 5);
1692 uint64 NMD
::extract_u_20_to_2__s2(uint64 instruction
)
1695 value
|= extract_bits(instruction
, 2, 19) << 2;
1700 int64 NMD
::extract_s__se3_4_2_1_0(uint64 instruction
)
1703 value
|= extract_bits(instruction
, 0, 3);
1704 value
|= extract_bits(instruction
, 4, 1) << 3;
1705 value
= sign_extend(value
, 3);
1710 uint64 NMD
::extract_u_3_2_1_0__s1(uint64 instruction
)
1713 value
|= extract_bits(instruction
, 0, 4) << 1;
1719 bool NMD
::ADDIU_32__cond(uint64 instruction
)
1721 uint64 rt
= extract_rt_25_24_23_22_21(instruction
);
1726 bool NMD
::ADDIU_RS5__cond(uint64 instruction
)
1728 uint64 rt
= extract_rt_9_8_7_6_5(instruction
);
1733 bool NMD
::BALRSC_cond(uint64 instruction
)
1735 uint64 rt
= extract_rt_25_24_23_22_21(instruction
);
1740 bool NMD
::BEQC_16__cond(uint64 instruction
)
1742 uint64 rs3
= extract_rs3_6_5_4(instruction
);
1743 uint64 rt3
= extract_rt3_9_8_7(instruction
);
1744 uint64 u
= extract_u_3_2_1_0__s1(instruction
);
1745 return rs3
< rt3
&& u
!= 0;
1749 bool NMD
::BNEC_16__cond(uint64 instruction
)
1751 uint64 rs3
= extract_rs3_6_5_4(instruction
);
1752 uint64 rt3
= extract_rt3_9_8_7(instruction
);
1753 uint64 u
= extract_u_3_2_1_0__s1(instruction
);
1754 return rs3
>= rt3
&& u
!= 0;
1758 bool NMD
::MOVE_cond(uint64 instruction
)
1760 uint64 rt
= extract_rt_9_8_7_6_5(instruction
);
1765 bool NMD
::P16_BR1_cond(uint64 instruction
)
1767 uint64 u
= extract_u_3_2_1_0__s1(instruction
);
1772 bool NMD
::PREF_S9__cond(uint64 instruction
)
1774 uint64 hint
= extract_hint_25_24_23_22_21(instruction
);
1779 bool NMD
::PREFE_cond(uint64 instruction
)
1781 uint64 hint
= extract_hint_25_24_23_22_21(instruction
);
1786 bool NMD
::SLTU_cond(uint64 instruction
)
1788 uint64 rd
= extract_rd_15_14_13_12_11(instruction
);
1795 * ABS.D fd, fs - Floating Point Absolute Value
1798 * 10987654321098765432109876543210
1799 * 010001 00000 000101
1804 std
::string NMD
::ABS_D(uint64 instruction
)
1806 uint64 fd_value
= extract_ft_25_24_23_22_21(instruction
);
1807 uint64 fs_value
= extract_fs_20_19_18_17_16(instruction
);
1809 std
::string fs
= FPR(copy(fs_value
));
1810 std
::string fd
= FPR(copy(fd_value
));
1812 return img
::format("ABS.D %s, %s", fd
, fs
);
1817 * ABS.S fd, fs - Floating Point Absolute Value
1820 * 10987654321098765432109876543210
1821 * 010001 00000 000101
1826 std
::string NMD
::ABS_S(uint64 instruction
)
1828 uint64 fd_value
= extract_ft_25_24_23_22_21(instruction
);
1829 uint64 fs_value
= extract_fs_20_19_18_17_16(instruction
);
1831 std
::string fs
= FPR(copy(fs_value
));
1832 std
::string fd
= FPR(copy(fd_value
));
1834 return img
::format("ABS.S %s, %s", fd
, fs
);
1839 * [DSP] ABSQ_S.PH rt, rs - Find absolute value of two fractional halfwords
1840 * with 16-bit saturation
1843 * 10987654321098765432109876543210
1844 * 001000 0001000100111111
1848 std
::string NMD
::ABSQ_S_PH(uint64 instruction
)
1850 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
1851 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
1853 std
::string rt
= GPR(copy(rt_value
));
1854 std
::string rs
= GPR(copy(rs_value
));
1856 return img
::format("ABSQ_S.PH %s, %s", rt
, rs
);
1861 * [DSP] ABSQ_S.QB rt, rs - Find absolute value of four fractional byte values
1862 * with 8-bit saturation
1865 * 10987654321098765432109876543210
1866 * 001000 0000000100111111
1870 std
::string NMD
::ABSQ_S_QB(uint64 instruction
)
1872 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
1873 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
1875 std
::string rt
= GPR(copy(rt_value
));
1876 std
::string rs
= GPR(copy(rs_value
));
1878 return img
::format("ABSQ_S.QB %s, %s", rt
, rs
);
1883 * [DSP] ABSQ_S.W rt, rs - Find absolute value of fractional word with 32-bit
1887 * 10987654321098765432109876543210
1888 * 001000 0010000100111111
1892 std
::string NMD
::ABSQ_S_W(uint64 instruction
)
1894 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
1895 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
1897 std
::string rt
= GPR(copy(rt_value
));
1898 std
::string rs
= GPR(copy(rs_value
));
1900 return img
::format("ABSQ_S.W %s, %s", rt
, rs
);
1908 * 10987654321098765432109876543210
1909 * 001000 0010000100111111
1913 std
::string NMD
::ACLR(uint64 instruction
)
1915 uint64 bit_value
= extract_bit_23_22_21(instruction
);
1916 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
1917 int64 s_value
= extract_s__se8_15_7_6_5_4_3_2_1_0(instruction
);
1919 std
::string bit
= IMMEDIATE(copy(bit_value
));
1920 std
::string s
= IMMEDIATE(copy(s_value
));
1921 std
::string rs
= GPR(copy(rs_value
));
1923 return img
::format("ACLR %s, %s(%s)", bit
, s
, rs
);
1931 * 10987654321098765432109876543210
1932 * 001000 0010000100111111
1936 std
::string NMD
::ADD(uint64 instruction
)
1938 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
1939 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
1940 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
1942 std
::string rd
= GPR(copy(rd_value
));
1943 std
::string rs
= GPR(copy(rs_value
));
1944 std
::string rt
= GPR(copy(rt_value
));
1946 return img
::format("ADD %s, %s, %s", rd
, rs
, rt
);
1951 * ADD.D fd, fs, ft - Floating Point Add
1954 * 10987654321098765432109876543210
1961 std
::string NMD
::ADD_D(uint64 instruction
)
1963 uint64 ft_value
= extract_ft_25_24_23_22_21(instruction
);
1964 uint64 fs_value
= extract_fs_20_19_18_17_16(instruction
);
1965 uint64 fd_value
= extract_fd_15_14_13_12_11(instruction
);
1967 std
::string ft
= FPR(copy(ft_value
));
1968 std
::string fs
= FPR(copy(fs_value
));
1969 std
::string fd
= FPR(copy(fd_value
));
1971 return img
::format("ADD.D %s, %s, %s", fd
, fs
, ft
);
1976 * ADD.S fd, fs, ft - Floating Point Add
1979 * 10987654321098765432109876543210
1986 std
::string NMD
::ADD_S(uint64 instruction
)
1988 uint64 ft_value
= extract_ft_25_24_23_22_21(instruction
);
1989 uint64 fs_value
= extract_fs_20_19_18_17_16(instruction
);
1990 uint64 fd_value
= extract_fd_15_14_13_12_11(instruction
);
1992 std
::string ft
= FPR(copy(ft_value
));
1993 std
::string fs
= FPR(copy(fs_value
));
1994 std
::string fd
= FPR(copy(fd_value
));
1996 return img
::format("ADD.S %s, %s, %s", fd
, fs
, ft
);
2004 * 10987654321098765432109876543210
2005 * 001000 0010000100111111
2009 std
::string NMD
::ADDIU_32_(uint64 instruction
)
2011 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2012 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2013 uint64 u_value
= extract_u_15_to_0(instruction
);
2015 std
::string rt
= GPR(copy(rt_value
));
2016 std
::string rs
= GPR(copy(rs_value
));
2017 std
::string u
= IMMEDIATE(copy(u_value
));
2019 return img
::format("ADDIU %s, %s, %s", rt
, rs
, u
);
2027 * 10987654321098765432109876543210
2028 * 001000 0010000100111111
2032 std
::string NMD
::ADDIU_48_(uint64 instruction
)
2034 uint64 rt_value
= extract_rt_41_40_39_38_37(instruction
);
2035 int64 s_value
= extract_s__se31_15_to_0_31_to_16(instruction
);
2037 std
::string rt
= GPR(copy(rt_value
));
2038 std
::string s
= IMMEDIATE(copy(s_value
));
2040 return img
::format("ADDIU %s, %s", rt
, s
);
2048 * 10987654321098765432109876543210
2049 * 001000 0010000100111111
2053 std
::string NMD
::ADDIU_GP48_(uint64 instruction
)
2055 uint64 rt_value
= extract_rt_41_40_39_38_37(instruction
);
2056 int64 s_value
= extract_s__se31_15_to_0_31_to_16(instruction
);
2058 std
::string rt
= GPR(copy(rt_value
));
2059 std
::string s
= IMMEDIATE(copy(s_value
));
2061 return img
::format("ADDIU %s, $%d, %s", rt
, 28, s
);
2069 * 10987654321098765432109876543210
2070 * 001000 0010000100111111
2074 std
::string NMD
::ADDIU_GP_B_(uint64 instruction
)
2076 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2077 uint64 u_value
= extract_u_17_to_0(instruction
);
2079 std
::string rt
= GPR(copy(rt_value
));
2080 std
::string u
= IMMEDIATE(copy(u_value
));
2082 return img
::format("ADDIU %s, $%d, %s", rt
, 28, u
);
2090 * 10987654321098765432109876543210
2091 * 001000 0010000100111111
2095 std
::string NMD
::ADDIU_GP_W_(uint64 instruction
)
2097 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2098 uint64 u_value
= extract_u_20_to_2__s2(instruction
);
2100 std
::string rt
= GPR(copy(rt_value
));
2101 std
::string u
= IMMEDIATE(copy(u_value
));
2103 return img
::format("ADDIU %s, $%d, %s", rt
, 28, u
);
2111 * 10987654321098765432109876543210
2112 * 001000 0010000100111111
2116 std
::string NMD
::ADDIU_NEG_(uint64 instruction
)
2118 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2119 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2120 uint64 u_value
= extract_u_11_10_9_8_7_6_5_4_3_2_1_0(instruction
);
2122 std
::string rt
= GPR(copy(rt_value
));
2123 std
::string rs
= GPR(copy(rs_value
));
2124 std
::string u
= IMMEDIATE(neg_copy(u_value
));
2126 return img
::format("ADDIU %s, %s, %s", rt
, rs
, u
);
2134 * 10987654321098765432109876543210
2135 * 001000 0010000100111111
2139 std
::string NMD
::ADDIU_R1_SP_(uint64 instruction
)
2141 uint64 u_value
= extract_u_5_4_3_2_1_0__s2(instruction
);
2142 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
2144 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
2145 std
::string u
= IMMEDIATE(copy(u_value
));
2147 return img
::format("ADDIU %s, $%d, %s", rt3
, 29, u
);
2155 * 10987654321098765432109876543210
2156 * 001000 0010000100111111
2160 std
::string NMD
::ADDIU_R2_(uint64 instruction
)
2162 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
2163 uint64 rs3_value
= extract_rs3_6_5_4(instruction
);
2164 uint64 u_value
= extract_u_2_1_0__s2(instruction
);
2166 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
2167 std
::string rs3
= GPR(decode_gpr_gpr3(rs3_value
));
2168 std
::string u
= IMMEDIATE(copy(u_value
));
2170 return img
::format("ADDIU %s, %s, %s", rt3
, rs3
, u
);
2175 * ADDIU[RS5] rt, s5 - Add Signed Word and Set Carry Bit
2182 std
::string NMD
::ADDIU_RS5_(uint64 instruction
)
2184 uint64 rt_value
= extract_rt_9_8_7_6_5(instruction
);
2185 int64 s_value
= extract_s__se3_4_2_1_0(instruction
);
2187 std
::string rt
= GPR(copy(rt_value
));
2188 std
::string s
= IMMEDIATE(copy(s_value
));
2190 return img
::format("ADDIU %s, %s", rt
, s
);
2198 * 10987654321098765432109876543210
2199 * 001000 x1110000101
2204 std
::string NMD
::ADDIUPC_32_(uint64 instruction
)
2206 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2207 int64 s_value
= extract_s__se21_0_20_to_1_s1(instruction
);
2209 std
::string rt
= GPR(copy(rt_value
));
2210 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
2212 return img
::format("ADDIUPC %s, %s", rt
, s
);
2220 * 10987654321098765432109876543210
2221 * 001000 x1110000101
2226 std
::string NMD
::ADDIUPC_48_(uint64 instruction
)
2228 uint64 rt_value
= extract_rt_41_40_39_38_37(instruction
);
2229 int64 s_value
= extract_s__se31_15_to_0_31_to_16(instruction
);
2231 std
::string rt
= GPR(copy(rt_value
));
2232 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 6);
2234 return img
::format("ADDIUPC %s, %s", rt
, s
);
2239 * [DSP] ADDQ.PH rd, rt, rs - Add fractional halfword vectors
2242 * 10987654321098765432109876543210
2243 * 001000 00000001101
2248 std
::string NMD
::ADDQ_PH(uint64 instruction
)
2250 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2251 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2252 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2254 std
::string rd
= GPR(copy(rd_value
));
2255 std
::string rs
= GPR(copy(rs_value
));
2256 std
::string rt
= GPR(copy(rt_value
));
2258 return img
::format("ADDQ.PH %s, %s, %s", rd
, rs
, rt
);
2263 * [DSP] ADDQ_S.PH rd, rt, rs - Add fractional halfword vectors with 16-bit
2267 * 10987654321098765432109876543210
2268 * 001000 10000001101
2273 std
::string NMD
::ADDQ_S_PH(uint64 instruction
)
2275 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2276 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2277 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2279 std
::string rd
= GPR(copy(rd_value
));
2280 std
::string rs
= GPR(copy(rs_value
));
2281 std
::string rt
= GPR(copy(rt_value
));
2283 return img
::format("ADDQ_S.PH %s, %s, %s", rd
, rs
, rt
);
2288 * [DSP] ADDQ_S.W rd, rt, rs - Add fractional words with 32-bit saturation
2291 * 10987654321098765432109876543210
2292 * 001000 x1100000101
2297 std
::string NMD
::ADDQ_S_W(uint64 instruction
)
2299 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2300 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2301 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2303 std
::string rd
= GPR(copy(rd_value
));
2304 std
::string rs
= GPR(copy(rs_value
));
2305 std
::string rt
= GPR(copy(rt_value
));
2307 return img
::format("ADDQ_S.W %s, %s, %s", rd
, rs
, rt
);
2312 * [DSP] ADDQH.PH rd, rt, rs - Add fractional halfword vectors and shift
2313 * right to halve results
2316 * 10987654321098765432109876543210
2317 * 001000 00001001101
2322 std
::string NMD
::ADDQH_PH(uint64 instruction
)
2324 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2325 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2326 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2328 std
::string rd
= GPR(copy(rd_value
));
2329 std
::string rs
= GPR(copy(rs_value
));
2330 std
::string rt
= GPR(copy(rt_value
));
2332 return img
::format("ADDQH.PH %s, %s, %s", rd
, rs
, rt
);
2337 * [DSP] ADDQH_R.PH rd, rt, rs - Add fractional halfword vectors and shift
2338 * right to halve results with rounding
2341 * 10987654321098765432109876543210
2342 * 001000 10001001101
2347 std
::string NMD
::ADDQH_R_PH(uint64 instruction
)
2349 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2350 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2351 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2353 std
::string rd
= GPR(copy(rd_value
));
2354 std
::string rs
= GPR(copy(rs_value
));
2355 std
::string rt
= GPR(copy(rt_value
));
2357 return img
::format("ADDQH_R.PH %s, %s, %s", rd
, rs
, rt
);
2362 * [DSP] ADDQH_R.W rd, rt, rs - Add fractional words and shift right to halve
2363 * results with rounding
2366 * 10987654321098765432109876543210
2367 * 001000 00010001101
2372 std
::string NMD
::ADDQH_R_W(uint64 instruction
)
2374 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2375 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2376 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2378 std
::string rd
= GPR(copy(rd_value
));
2379 std
::string rs
= GPR(copy(rs_value
));
2380 std
::string rt
= GPR(copy(rt_value
));
2382 return img
::format("ADDQH_R.W %s, %s, %s", rd
, rs
, rt
);
2387 * [DSP] ADDQH.W rd, rt, rs - Add fractional words and shift right to halve
2391 * 10987654321098765432109876543210
2392 * 001000 10010001101
2397 std
::string NMD
::ADDQH_W(uint64 instruction
)
2399 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2400 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2401 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2403 std
::string rd
= GPR(copy(rd_value
));
2404 std
::string rs
= GPR(copy(rs_value
));
2405 std
::string rt
= GPR(copy(rt_value
));
2407 return img
::format("ADDQH.W %s, %s, %s", rd
, rs
, rt
);
2412 * [DSP] ADDSC rd, rt, rs - Add two signed words and set carry bit
2415 * 10987654321098765432109876543210
2416 * 001000 x1110000101
2421 std
::string NMD
::ADDSC(uint64 instruction
)
2423 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2424 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2425 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2427 std
::string rd
= GPR(copy(rd_value
));
2428 std
::string rs
= GPR(copy(rs_value
));
2429 std
::string rt
= GPR(copy(rt_value
));
2431 return img
::format("ADDSC %s, %s, %s", rd
, rs
, rt
);
2436 * ADDU[16] rd3, rs3, rt3 -
2444 std
::string NMD
::ADDU_16_(uint64 instruction
)
2446 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
2447 uint64 rs3_value
= extract_rs3_6_5_4(instruction
);
2448 uint64 rd3_value
= extract_rd3_3_2_1(instruction
);
2450 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
2451 std
::string rs3
= GPR(decode_gpr_gpr3(rs3_value
));
2452 std
::string rd3
= GPR(decode_gpr_gpr3(rd3_value
));
2454 return img
::format("ADDU %s, %s, %s", rd3
, rs3
, rt3
);
2462 * 10987654321098765432109876543210
2463 * 001000 x1110000101
2468 std
::string NMD
::ADDU_32_(uint64 instruction
)
2470 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2471 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2472 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2474 std
::string rd
= GPR(copy(rd_value
));
2475 std
::string rs
= GPR(copy(rs_value
));
2476 std
::string rt
= GPR(copy(rt_value
));
2478 return img
::format("ADDU %s, %s, %s", rd
, rs
, rt
);
2486 * 10987654321098765432109876543210
2487 * 001000 x1110000101
2492 std
::string NMD
::ADDU_4X4_(uint64 instruction
)
2494 uint64 rt4_value
= extract_rt4_9_7_6_5(instruction
);
2495 uint64 rs4_value
= extract_rs4_4_2_1_0(instruction
);
2497 std
::string rs4
= GPR(decode_gpr_gpr4(rs4_value
));
2498 std
::string rt4
= GPR(decode_gpr_gpr4(rt4_value
));
2500 return img
::format("ADDU %s, %s", rs4
, rt4
);
2505 * [DSP] ADDU.PH rd, rt, rs - Add two pairs of unsigned halfwords
2508 * 10987654321098765432109876543210
2509 * 001000 00100001101
2514 std
::string NMD
::ADDU_PH(uint64 instruction
)
2516 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2517 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2518 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2520 std
::string rd
= GPR(copy(rd_value
));
2521 std
::string rs
= GPR(copy(rs_value
));
2522 std
::string rt
= GPR(copy(rt_value
));
2524 return img
::format("ADDU.PH %s, %s, %s", rd
, rs
, rt
);
2529 * ADDU.QB rd, rt, rs - Unsigned Add Quad Byte Vectors
2532 * 10987654321098765432109876543210
2533 * 001000 00011001101
2538 std
::string NMD
::ADDU_QB(uint64 instruction
)
2540 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2541 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2542 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2544 std
::string rd
= GPR(copy(rd_value
));
2545 std
::string rs
= GPR(copy(rs_value
));
2546 std
::string rt
= GPR(copy(rt_value
));
2548 return img
::format("ADDU.QB %s, %s, %s", rd
, rs
, rt
);
2553 * [DSP] ADDU_S.PH rd, rt, rs - Add two pairs of unsigned halfwords with 16-bit
2557 * 10987654321098765432109876543210
2558 * 001000 10100001101
2563 std
::string NMD
::ADDU_S_PH(uint64 instruction
)
2565 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2566 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2567 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2569 std
::string rd
= GPR(copy(rd_value
));
2570 std
::string rs
= GPR(copy(rs_value
));
2571 std
::string rt
= GPR(copy(rt_value
));
2573 return img
::format("ADDU_S.PH %s, %s, %s", rd
, rs
, rt
);
2578 * ADDU_S.QB rd, rt, rs - Unsigned Add Quad Byte Vectors
2581 * 10987654321098765432109876543210
2582 * 001000 10011001101
2587 std
::string NMD
::ADDU_S_QB(uint64 instruction
)
2589 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2590 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2591 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2593 std
::string rd
= GPR(copy(rd_value
));
2594 std
::string rs
= GPR(copy(rs_value
));
2595 std
::string rt
= GPR(copy(rt_value
));
2597 return img
::format("ADDU_S.QB %s, %s, %s", rd
, rs
, rt
);
2602 * ADDUH.QB rd, rt, rs - Unsigned Add Vector Quad-Bytes And Right Shift
2606 * 10987654321098765432109876543210
2607 * 001000 00101001101
2612 std
::string NMD
::ADDUH_QB(uint64 instruction
)
2614 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2615 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2616 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2618 std
::string rd
= GPR(copy(rd_value
));
2619 std
::string rs
= GPR(copy(rs_value
));
2620 std
::string rt
= GPR(copy(rt_value
));
2622 return img
::format("ADDUH.QB %s, %s, %s", rd
, rs
, rt
);
2627 * ADDUH_R.QB rd, rt, rs - Unsigned Add Vector Quad-Bytes And Right Shift
2631 * 10987654321098765432109876543210
2632 * 001000 10101001101
2637 std
::string NMD
::ADDUH_R_QB(uint64 instruction
)
2639 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2640 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2641 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2643 std
::string rd
= GPR(copy(rd_value
));
2644 std
::string rs
= GPR(copy(rs_value
));
2645 std
::string rt
= GPR(copy(rt_value
));
2647 return img
::format("ADDUH_R.QB %s, %s, %s", rd
, rs
, rt
);
2651 * ADDWC rd, rt, rs - Add Word with Carry Bit
2654 * 10987654321098765432109876543210
2655 * 001000 x1111000101
2660 std
::string NMD
::ADDWC(uint64 instruction
)
2662 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2663 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2664 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2666 std
::string rd
= GPR(copy(rd_value
));
2667 std
::string rs
= GPR(copy(rs_value
));
2668 std
::string rt
= GPR(copy(rt_value
));
2670 return img
::format("ADDWC %s, %s, %s", rd
, rs
, rt
);
2678 * 10987654321098765432109876543210
2679 * 001000 x1110000101
2684 std
::string NMD
::ALUIPC(uint64 instruction
)
2686 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2687 int64 s_value
= extract_s__se31_0_11_to_2_20_to_12_s12(instruction
);
2689 std
::string rt
= GPR(copy(rt_value
));
2690 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
2692 return img
::format("ALUIPC %s, %%pcrel_hi(%s)", rt
, s
);
2697 * AND[16] rt3, rs3 -
2705 std
::string NMD
::AND_16_(uint64 instruction
)
2707 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
2708 uint64 rs3_value
= extract_rs3_6_5_4(instruction
);
2710 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
2711 std
::string rs3
= GPR(decode_gpr_gpr3(rs3_value
));
2713 return img
::format("AND %s, %s", rs3
, rt3
);
2721 * 10987654321098765432109876543210
2722 * 001000 x1110000101
2727 std
::string NMD
::AND_32_(uint64 instruction
)
2729 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2730 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2731 uint64 rd_value
= extract_rd_15_14_13_12_11(instruction
);
2733 std
::string rd
= GPR(copy(rd_value
));
2734 std
::string rs
= GPR(copy(rs_value
));
2735 std
::string rt
= GPR(copy(rt_value
));
2737 return img
::format("AND %s, %s, %s", rd
, rs
, rt
);
2750 std
::string NMD
::ANDI_16_(uint64 instruction
)
2752 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
2753 uint64 rs3_value
= extract_rs3_6_5_4(instruction
);
2754 uint64 eu_value
= extract_eu_3_2_1_0(instruction
);
2756 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
2757 std
::string rs3
= GPR(decode_gpr_gpr3(rs3_value
));
2758 std
::string eu
= IMMEDIATE(encode_eu_from_u_andi16(eu_value
));
2760 return img
::format("ANDI %s, %s, %s", rt3
, rs3
, eu
);
2768 * 10987654321098765432109876543210
2769 * 001000 x1110000101
2774 std
::string NMD
::ANDI_32_(uint64 instruction
)
2776 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2777 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2778 uint64 u_value
= extract_u_11_10_9_8_7_6_5_4_3_2_1_0(instruction
);
2780 std
::string rt
= GPR(copy(rt_value
));
2781 std
::string rs
= GPR(copy(rs_value
));
2782 std
::string u
= IMMEDIATE(copy(u_value
));
2784 return img
::format("ANDI %s, %s, %s", rt
, rs
, u
);
2792 * 10987654321098765432109876543210
2793 * 001000 x1110000101
2798 std
::string NMD
::APPEND(uint64 instruction
)
2800 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2801 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2802 uint64 sa_value
= extract_sa_15_14_13_12_11(instruction
);
2804 std
::string rt
= GPR(copy(rt_value
));
2805 std
::string rs
= GPR(copy(rs_value
));
2806 std
::string sa
= IMMEDIATE(copy(sa_value
));
2808 return img
::format("APPEND %s, %s, %s", rt
, rs
, sa
);
2816 * 10987654321098765432109876543210
2817 * 001000 x1110000101
2822 std
::string NMD
::ASET(uint64 instruction
)
2824 uint64 bit_value
= extract_bit_23_22_21(instruction
);
2825 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2826 int64 s_value
= extract_s__se8_15_7_6_5_4_3_2_1_0(instruction
);
2828 std
::string bit
= IMMEDIATE(copy(bit_value
));
2829 std
::string s
= IMMEDIATE(copy(s_value
));
2830 std
::string rs
= GPR(copy(rs_value
));
2832 return img
::format("ASET %s, %s(%s)", bit
, s
, rs
);
2840 * 10987654321098765432109876543210
2841 * 001000 x1110000101
2846 std
::string NMD
::BALC_16_(uint64 instruction
)
2848 int64 s_value
= extract_s__se10_0_9_8_7_6_5_4_3_2_1_s1(instruction
);
2850 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 2);
2852 return img
::format("BALC %s", s
);
2860 * 10987654321098765432109876543210
2861 * 001000 x1110000101
2866 std
::string NMD
::BALC_32_(uint64 instruction
)
2868 int64 s_value
= extract_s__se25_0_24_to_1_s1(instruction
);
2870 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
2872 return img
::format("BALC %s", s
);
2880 * 10987654321098765432109876543210
2881 * 001000 x1110000101
2886 std
::string NMD
::BALRSC(uint64 instruction
)
2888 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2889 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
2891 std
::string rt
= GPR(copy(rt_value
));
2892 std
::string rs
= GPR(copy(rs_value
));
2894 return img
::format("BALRSC %s, %s", rt
, rs
);
2902 * 10987654321098765432109876543210
2903 * 001000 x1110000101
2908 std
::string NMD
::BBEQZC(uint64 instruction
)
2910 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2911 uint64 bit_value
= extract_bit_16_15_14_13_12_11(instruction
);
2912 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
2914 std
::string rt
= GPR(copy(rt_value
));
2915 std
::string bit
= IMMEDIATE(copy(bit_value
));
2916 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
2918 return img
::format("BBEQZC %s, %s, %s", rt
, bit
, s
);
2926 * 10987654321098765432109876543210
2927 * 001000 x1110000101
2932 std
::string NMD
::BBNEZC(uint64 instruction
)
2934 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
2935 uint64 bit_value
= extract_bit_16_15_14_13_12_11(instruction
);
2936 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
2938 std
::string rt
= GPR(copy(rt_value
));
2939 std
::string bit
= IMMEDIATE(copy(bit_value
));
2940 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
2942 return img
::format("BBNEZC %s, %s, %s", rt
, bit
, s
);
2950 * 10987654321098765432109876543210
2951 * 001000 x1110000101
2956 std
::string NMD
::BC_16_(uint64 instruction
)
2958 int64 s_value
= extract_s__se10_0_9_8_7_6_5_4_3_2_1_s1(instruction
);
2960 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 2);
2962 return img
::format("BC %s", s
);
2970 * 10987654321098765432109876543210
2971 * 001000 x1110000101
2976 std
::string NMD
::BC_32_(uint64 instruction
)
2978 int64 s_value
= extract_s__se25_0_24_to_1_s1(instruction
);
2980 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
2982 return img
::format("BC %s", s
);
2990 * 10987654321098765432109876543210
2991 * 001000 x1110000101
2996 std
::string NMD
::BC1EQZC(uint64 instruction
)
2998 uint64 ft_value
= extract_ft_25_24_23_22_21(instruction
);
2999 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3001 std
::string ft
= FPR(copy(ft_value
));
3002 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3004 return img
::format("BC1EQZC %s, %s", ft
, s
);
3012 * 10987654321098765432109876543210
3013 * 001000 x1110000101
3018 std
::string NMD
::BC1NEZC(uint64 instruction
)
3020 uint64 ft_value
= extract_ft_25_24_23_22_21(instruction
);
3021 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3023 std
::string ft
= FPR(copy(ft_value
));
3024 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3026 return img
::format("BC1NEZC %s, %s", ft
, s
);
3034 * 10987654321098765432109876543210
3035 * 001000 x1110000101
3040 std
::string NMD
::BC2EQZC(uint64 instruction
)
3042 uint64 ct_value
= extract_ct_25_24_23_22_21(instruction
);
3043 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3045 std
::string ct
= CPR(copy(ct_value
));
3046 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3048 return img
::format("BC2EQZC %s, %s", ct
, s
);
3056 * 10987654321098765432109876543210
3057 * 001000 x1110000101
3062 std
::string NMD
::BC2NEZC(uint64 instruction
)
3064 uint64 ct_value
= extract_ct_25_24_23_22_21(instruction
);
3065 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3067 std
::string ct
= CPR(copy(ct_value
));
3068 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3070 return img
::format("BC2NEZC %s, %s", ct
, s
);
3078 * 10987654321098765432109876543210
3079 * 001000 x1110000101
3084 std
::string NMD
::BEQC_16_(uint64 instruction
)
3086 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
3087 uint64 rs3_value
= extract_rs3_6_5_4(instruction
);
3088 uint64 u_value
= extract_u_3_2_1_0__s1(instruction
);
3090 std
::string rs3
= GPR(encode_rs3_and_check_rs3_lt_rt3(rs3_value
));
3091 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
3092 std
::string u
= ADDRESS(encode_u_from_address(u_value
), 2);
3094 return img
::format("BEQC %s, %s, %s", rs3
, rt3
, u
);
3102 * 10987654321098765432109876543210
3103 * 001000 x1110000101
3108 std
::string NMD
::BEQC_32_(uint64 instruction
)
3110 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3111 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3112 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3114 std
::string rs
= GPR(copy(rs_value
));
3115 std
::string rt
= GPR(copy(rt_value
));
3116 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3118 return img
::format("BEQC %s, %s, %s", rs
, rt
, s
);
3126 * 10987654321098765432109876543210
3127 * 001000 x1110000101
3132 std
::string NMD
::BEQIC(uint64 instruction
)
3134 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3135 uint64 u_value
= extract_u_17_16_15_14_13_12_11(instruction
);
3136 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
3138 std
::string rt
= GPR(copy(rt_value
));
3139 std
::string u
= IMMEDIATE(copy(u_value
));
3140 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3142 return img
::format("BEQIC %s, %s, %s", rt
, u
, s
);
3150 * 10987654321098765432109876543210
3151 * 001000 x1110000101
3156 std
::string NMD
::BEQZC_16_(uint64 instruction
)
3158 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
3159 int64 s_value
= extract_s__se7_0_6_5_4_3_2_1_s1(instruction
);
3161 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
3162 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 2);
3164 return img
::format("BEQZC %s, %s", rt3
, s
);
3172 * 10987654321098765432109876543210
3173 * 001000 x1110000101
3178 std
::string NMD
::BGEC(uint64 instruction
)
3180 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3181 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3182 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3184 std
::string rs
= GPR(copy(rs_value
));
3185 std
::string rt
= GPR(copy(rt_value
));
3186 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3188 return img
::format("BGEC %s, %s, %s", rs
, rt
, s
);
3196 * 10987654321098765432109876543210
3197 * 001000 x1110000101
3202 std
::string NMD
::BGEIC(uint64 instruction
)
3204 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3205 uint64 u_value
= extract_u_17_16_15_14_13_12_11(instruction
);
3206 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
3208 std
::string rt
= GPR(copy(rt_value
));
3209 std
::string u
= IMMEDIATE(copy(u_value
));
3210 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3212 return img
::format("BGEIC %s, %s, %s", rt
, u
, s
);
3220 * 10987654321098765432109876543210
3221 * 001000 x1110000101
3226 std
::string NMD
::BGEIUC(uint64 instruction
)
3228 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3229 uint64 u_value
= extract_u_17_16_15_14_13_12_11(instruction
);
3230 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
3232 std
::string rt
= GPR(copy(rt_value
));
3233 std
::string u
= IMMEDIATE(copy(u_value
));
3234 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3236 return img
::format("BGEIUC %s, %s, %s", rt
, u
, s
);
3244 * 10987654321098765432109876543210
3245 * 001000 x1110000101
3250 std
::string NMD
::BGEUC(uint64 instruction
)
3252 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3253 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3254 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3256 std
::string rs
= GPR(copy(rs_value
));
3257 std
::string rt
= GPR(copy(rt_value
));
3258 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3260 return img
::format("BGEUC %s, %s, %s", rs
, rt
, s
);
3268 * 10987654321098765432109876543210
3269 * 001000 x1110000101
3274 std
::string NMD
::BLTC(uint64 instruction
)
3276 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3277 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3278 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3280 std
::string rs
= GPR(copy(rs_value
));
3281 std
::string rt
= GPR(copy(rt_value
));
3282 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3284 return img
::format("BLTC %s, %s, %s", rs
, rt
, s
);
3292 * 10987654321098765432109876543210
3293 * 001000 x1110000101
3298 std
::string NMD
::BLTIC(uint64 instruction
)
3300 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3301 uint64 u_value
= extract_u_17_16_15_14_13_12_11(instruction
);
3302 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
3304 std
::string rt
= GPR(copy(rt_value
));
3305 std
::string u
= IMMEDIATE(copy(u_value
));
3306 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3308 return img
::format("BLTIC %s, %s, %s", rt
, u
, s
);
3316 * 10987654321098765432109876543210
3317 * 001000 x1110000101
3322 std
::string NMD
::BLTIUC(uint64 instruction
)
3324 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3325 uint64 u_value
= extract_u_17_16_15_14_13_12_11(instruction
);
3326 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
3328 std
::string rt
= GPR(copy(rt_value
));
3329 std
::string u
= IMMEDIATE(copy(u_value
));
3330 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3332 return img
::format("BLTIUC %s, %s, %s", rt
, u
, s
);
3340 * 10987654321098765432109876543210
3341 * 001000 x1110000101
3346 std
::string NMD
::BLTUC(uint64 instruction
)
3348 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3349 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3350 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3352 std
::string rs
= GPR(copy(rs_value
));
3353 std
::string rt
= GPR(copy(rt_value
));
3354 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3356 return img
::format("BLTUC %s, %s, %s", rs
, rt
, s
);
3364 * 10987654321098765432109876543210
3365 * 001000 x1110000101
3370 std
::string NMD
::BNEC_16_(uint64 instruction
)
3372 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
3373 uint64 rs3_value
= extract_rs3_6_5_4(instruction
);
3374 uint64 u_value
= extract_u_3_2_1_0__s1(instruction
);
3376 std
::string rs3
= GPR(encode_rs3_and_check_rs3_ge_rt3(rs3_value
));
3377 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
3378 std
::string u
= ADDRESS(encode_u_from_address(u_value
), 2);
3380 return img
::format("BNEC %s, %s, %s", rs3
, rt3
, u
);
3388 * 10987654321098765432109876543210
3389 * 001000 x1110000101
3394 std
::string NMD
::BNEC_32_(uint64 instruction
)
3396 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3397 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3398 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3400 std
::string rs
= GPR(copy(rs_value
));
3401 std
::string rt
= GPR(copy(rt_value
));
3402 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3404 return img
::format("BNEC %s, %s, %s", rs
, rt
, s
);
3412 * 10987654321098765432109876543210
3413 * 001000 x1110000101
3418 std
::string NMD
::BNEIC(uint64 instruction
)
3420 uint64 rt_value
= extract_rt_25_24_23_22_21(instruction
);
3421 uint64 u_value
= extract_u_17_16_15_14_13_12_11(instruction
);
3422 int64 s_value
= extract_s__se11_0_10_9_8_7_6_5_4_3_2_1_0_s1(instruction
);
3424 std
::string rt
= GPR(copy(rt_value
));
3425 std
::string u
= IMMEDIATE(copy(u_value
));
3426 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3428 return img
::format("BNEIC %s, %s, %s", rt
, u
, s
);
3436 * 10987654321098765432109876543210
3437 * 001000 x1110000101
3442 std
::string NMD
::BNEZC_16_(uint64 instruction
)
3444 uint64 rt3_value
= extract_rt3_9_8_7(instruction
);
3445 int64 s_value
= extract_s__se7_0_6_5_4_3_2_1_s1(instruction
);
3447 std
::string rt3
= GPR(decode_gpr_gpr3(rt3_value
));
3448 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 2);
3450 return img
::format("BNEZC %s, %s", rt3
, s
);
3455 * [DSP] BPOSGE32C offset - Branch on greater than or equal to value 32 in
3456 * DSPControl Pos field
3459 * 10987654321098765432109876543210
3460 * 100010xxxxx0010001
3461 * s[13:1] -------------
3464 std
::string NMD
::BPOSGE32C(uint64 instruction
)
3466 int64 s_value
= extract_s__se14_0_13_to_1_s1(instruction
);
3468 std
::string s
= ADDRESS(encode_s_from_address(s_value
), 4);
3470 return img
::format("BPOSGE32C %s", s
);
3478 * 10987654321098765432109876543210
3479 * 001000 x1110000101
3484 std
::string NMD
::BREAK_16_(uint64 instruction
)
3486 uint64 code_value
= extract_code_2_1_0(instruction
);
3488 std
::string code
= IMMEDIATE(copy(code_value
));
3490 return img
::format("BREAK %s", code
);
3495 * BREAK code - Break. Cause a Breakpoint exception
3498 * 10987654321098765432109876543210
3499 * 001000 x1110000101
3504 std
::string NMD
::BREAK_32_(uint64 instruction
)
3506 uint64 code_value
= extract_code_18_to_0(instruction
);
3508 std
::string code
= IMMEDIATE(copy(code_value
));
3510 return img
::format("BREAK %s", code
);
3518 * 10987654321098765432109876543210
3519 * 001000 x1110000101
3524 std
::string NMD
::BRSC(uint64 instruction
)
3526 uint64 rs_value
= extract_rs_20_19_18_17_16(instruction
);
3528 std
::string rs
= GPR(copy(rs_value
));
3530 return img
::format("BRSC %s", rs
);
3538 * 10987654321098765432109876543210
3539 * 001000 x1110000101