2 // <insn-word> { "+" <insn-word> }
14 // IGEN config - mips16
15 :option:16:insn-bit-size:16
16 :option:16:hi-bit-nr:15
17 :option:16:insn-specifying-widths:true
18 :option:16:gen-delayed-branch:false
20 // IGEN config - mips32/64..
21 :option:32:insn-bit-size:32
22 :option:32:hi-bit-nr:31
23 :option:32:insn-specifying-widths:true
24 :option:32:gen-delayed-branch:false
27 // Generate separate simulators for each target
28 // :option::multi-sim:true
31 // Models known by this simulator
33 :model::mipsII:mipsII:
34 :model::mipsIII:mipsIII:
35 :model::mipsIV:mipsIV:
36 :model::mips16:mips16:
37 // start-sanitize-r5900
41 // start-sanitize-tx19
44 // start-sanitize-vr5400
45 :model::vr5400:vr5400:
46 // end-sanitize-vr5400
50 // Pseudo instructions known by IGEN
53 sim_io_eprintf (SD, "Illegal instruction at address 0x%lx\n",
55 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIGILL);
64 // CPU Instruction Set (mipsI - mipsIV)
68 000000,5.RS,5.RT,5.RD,00000,100000:SPECIAL:32::ADD
69 "add r<RD>, r<RS>, r<RT>"
74 // start-sanitize-vr5400
76 // end-sanitize-vr5400
77 // start-sanitize-r5900
81 // start-sanitize-tx19
85 ALU32_BEGIN (GPR[RS]);
91 001000,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDI
92 "addi r<RT>, r<RS>, IMMEDIATE"
97 // start-sanitize-vr5400
99 // end-sanitize-vr5400
100 // start-sanitize-r5900
102 // end-sanitize-r5900
104 // start-sanitize-tx19
108 ALU32_BEGIN (GPR[RS]);
109 ALU32_ADD (EXTEND16 (IMMEDIATE));
114 001001,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDIU
115 "add r<RT>, r<RS>, IMMEDIATE"
120 // start-sanitize-vr5400
122 // end-sanitize-vr5400
123 // start-sanitize-r5900
125 // end-sanitize-r5900
127 // start-sanitize-tx19
131 signed32 temp = GPR[RS] + EXTEND16 (IMMEDIATE);
132 GPR[RT] = EXTEND32 (temp);
136 000000,5.RS,5.RT,5.RD,00000,100001:SPECIAL:32::ADDU
141 // start-sanitize-vr5400
143 // end-sanitize-vr5400
144 // start-sanitize-r5900
146 // end-sanitize-r5900
148 // start-sanitize-tx19
152 signed32 temp = GPR[RS] + GPR[RT];
153 GPR[RD] = EXTEND32 (temp);
157 000000,5.RS,5.RT,5.RD,00000,100100:SPECIAL:32::AND
158 "and r<RD>, r<RS>, r<RT>"
163 // start-sanitize-vr5400
165 // end-sanitize-vr5400
166 // start-sanitize-r5900
168 // end-sanitize-r5900
170 // start-sanitize-tx19
174 GPR[RD] = GPR[RS] & GPR[RT];
178 001100,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ANDI
179 "and r<RT>, r<RS>, IMMEDIATE"
183 // start-sanitize-vr5400
185 // end-sanitize-vr5400
186 // start-sanitize-r5900
188 // end-sanitize-r5900
190 // start-sanitize-tx19
194 GPR[RT] = GPR[RS] & IMMEDIATE;
198 000100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQ
199 "beq r<RS>, r<RT>, OFFSET"
204 // start-sanitize-vr5400
206 // end-sanitize-vr5400
207 // start-sanitize-r5900
209 // end-sanitize-r5900
211 // start-sanitize-tx19
215 address_word offset = EXTEND16 (OFFSET) << 2;
216 if (GPR[RS] == GPR[RT])
217 DELAY_SLOT (PC + offset);
221 010100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQL
222 "beql r<RS>, r<RT>, <OFFSET>"
226 // start-sanitize-vr5400
228 // end-sanitize-vr5400
229 // start-sanitize-r5900
231 // end-sanitize-r5900
233 // start-sanitize-tx19
237 address_word offset = EXTEND16 (OFFSET) << 2;
238 if (GPR[RS] == GPR[RT])
239 DELAY_SLOT (PC + offset);
241 NULLIFY_NEXT_INSTRUCTION ();
245 000001,5.RS,00001,16.OFFSET:REGIMM:32::BGEZ
246 "bgez r<RS>, <OFFSET>"
251 // start-sanitize-vr5400
253 // end-sanitize-vr5400
254 // start-sanitize-r5900
256 // end-sanitize-r5900
258 // start-sanitize-tx19
262 address_word offset = EXTEND16 (OFFSET) << 2;
264 DELAY_SLOT (PC + offset);
268 000001,5.RS!31,10001,16.OFFSET:REGIMM:32::BGEZAL
269 "bgezal r<RS>, <OFFSET>"
274 // start-sanitize-vr5400
276 // end-sanitize-vr5400
277 // start-sanitize-r5900
279 // end-sanitize-r5900
281 // start-sanitize-tx19
285 address_word offset = EXTEND16 (OFFSET) << 2;
288 DELAY_SLOT (PC + offset);
292 000001,5.RS!31,10011,16.OFFSET:REGIMM:32::BGEZALL
293 "bgezall r<RS>, <OFFSET>"
297 // start-sanitize-vr5400
299 // end-sanitize-vr5400
300 // start-sanitize-r5900
302 // end-sanitize-r5900
304 // start-sanitize-tx19
308 address_word offset = EXTEND16 (OFFSET) << 2;
310 /* NOTE: The branch occurs AFTER the next instruction has been
313 DELAY_SLOT (PC + offset);
315 NULLIFY_NEXT_INSTRUCTION ();
319 000001,5.RS,00011,16.OFFSET:REGIMM:32::BGEZL
320 "bgezl r<RS>, <OFFSET>"
324 // start-sanitize-vr5400
326 // end-sanitize-vr5400
327 // start-sanitize-r5900
329 // end-sanitize-r5900
331 // start-sanitize-tx19
335 address_word offset = EXTEND16 (OFFSET) << 2;
337 DELAY_SLOT (PC + offset);
339 NULLIFY_NEXT_INSTRUCTION ();
343 000111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZ
344 "bgtz r<RS>, <OFFSET>"
349 // start-sanitize-vr5400
351 // end-sanitize-vr5400
352 // start-sanitize-r5900
354 // end-sanitize-r5900
356 // start-sanitize-tx19
360 address_word offset = EXTEND16 (OFFSET) << 2;
362 DELAY_SLOT (PC + offset);
366 010111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZL
367 "bgtzl r<RS>, <OFFSET>"
371 // start-sanitize-vr5400
373 // end-sanitize-vr5400
374 // start-sanitize-r5900
376 // end-sanitize-r5900
378 // start-sanitize-tx19
382 address_word offset = EXTEND16 (OFFSET) << 2;
383 /* NOTE: The branch occurs AFTER the next instruction has been
386 DELAY_SLOT (PC + offset);
388 NULLIFY_NEXT_INSTRUCTION ();
392 000110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZ
393 "blez r<RS>, <OFFSET>"
398 // start-sanitize-vr5400
400 // end-sanitize-vr5400
401 // start-sanitize-r5900
403 // end-sanitize-r5900
405 // start-sanitize-tx19
409 address_word offset = EXTEND16 (OFFSET) << 2;
410 /* NOTE: The branch occurs AFTER the next instruction has been
413 DELAY_SLOT (PC + offset);
417 010110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZL
418 "bgezl r<RS>, <OFFSET>"
422 // start-sanitize-vr5400
424 // end-sanitize-vr5400
425 // start-sanitize-r5900
427 // end-sanitize-r5900
429 // start-sanitize-tx19
433 address_word offset = EXTEND16 (OFFSET) << 2;
435 DELAY_SLOT (PC + offset);
437 NULLIFY_NEXT_INSTRUCTION ();
441 000001,5.RS,00000,16.OFFSET:REGIMM:32::BLTZ
442 "bltz r<RS>, <OFFSET>"
447 // start-sanitize-vr5400
449 // end-sanitize-vr5400
450 // start-sanitize-r5900
452 // end-sanitize-r5900
454 // start-sanitize-tx19
458 address_word offset = EXTEND16 (OFFSET) << 2;
460 DELAY_SLOT (PC + offset);
464 000001,5.RS!31,10000,16.OFFSET:REGIMM:32::BLTZAL
465 "bltzal r<RS>, <OFFSET>"
470 // start-sanitize-vr5400
472 // end-sanitize-vr5400
473 // start-sanitize-r5900
475 // end-sanitize-r5900
477 // start-sanitize-tx19
481 address_word offset = EXTEND16 (OFFSET) << 2;
483 /* NOTE: The branch occurs AFTER the next instruction has been
486 DELAY_SLOT (PC + offset);
490 000001,5.RS!31,10010,16.OFFSET:REGIMM:32::BLTZALL
491 "bltzall r<RS>, <OFFSET>"
495 // start-sanitize-vr5400
497 // end-sanitize-vr5400
498 // start-sanitize-r5900
500 // end-sanitize-r5900
502 // start-sanitize-tx19
506 address_word offset = EXTEND16 (OFFSET) << 2;
509 DELAY_SLOT (PC + offset);
511 NULLIFY_NEXT_INSTRUCTION ();
515 000001,5.RS,00010,16.OFFSET:REGIMM:32::BLTZL
516 "bltzl r<RS>, <OFFSET>"
520 // start-sanitize-vr5400
522 // end-sanitize-vr5400
523 // start-sanitize-r5900
525 // end-sanitize-r5900
527 // start-sanitize-tx19
531 address_word offset = EXTEND16 (OFFSET) << 2;
532 /* NOTE: The branch occurs AFTER the next instruction has been
535 DELAY_SLOT (PC + offset);
537 NULLIFY_NEXT_INSTRUCTION ();
541 000101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNE
542 "bne r<RS>, r<RT>, <OFFSET>"
547 // start-sanitize-vr5400
549 // end-sanitize-vr5400
550 // start-sanitize-r5900
552 // end-sanitize-r5900
554 // start-sanitize-tx19
558 address_word offset = EXTEND16 (OFFSET) << 2;
559 if (GPR[RS] != GPR[RT])
560 DELAY_SLOT (PC + offset);
564 010101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNEL
565 "bnel r<RS>, r<RT>, <OFFSET>"
569 // start-sanitize-vr5400
571 // end-sanitize-vr5400
572 // start-sanitize-r5900
574 // end-sanitize-r5900
576 // start-sanitize-tx19
580 address_word offset = EXTEND16 (OFFSET) << 2;
581 if (GPR[RS] != GPR[RT])
582 DELAY_SLOT (PC + offset);
584 NULLIFY_NEXT_INSTRUCTION ();
588 000000,20.CODE,001101:SPECIAL:32::BREAK
594 // start-sanitize-vr5400
596 // end-sanitize-vr5400
597 // start-sanitize-r5900
599 // end-sanitize-r5900
601 // start-sanitize-tx19
605 SignalException(BreakPoint, instruction_0);
609 0100,ZZ!0!1!3,26.COP_FUN:NORMAL:32::COPz
615 // start-sanitize-vr5400
617 // end-sanitize-vr5400
618 // start-sanitize-r5900
620 // end-sanitize-r5900
622 // start-sanitize-tx19
626 DecodeCoproc (instruction_0);
630 000000,5.RS,5.RT,5.RD,00000,101100:SPECIAL:64::DADD
631 "dadd r<RD>, r<RS>, r<RT>"
634 // start-sanitize-vr5400
636 // end-sanitize-vr5400
637 // start-sanitize-r5900
639 // end-sanitize-r5900
641 // start-sanitize-tx19
645 ALU64_BEGIN (GPR[RS]);
651 011000,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDI
652 "daddi r<RT>, r<RS>, <IMMEDIATE>"
655 // start-sanitize-vr5400
657 // end-sanitize-vr5400
658 // start-sanitize-r5900
660 // end-sanitize-r5900
662 // start-sanitize-tx19
666 ALU64_BEGIN (GPR[RS]);
667 ALU64_ADD (EXTEND16 (IMMEDIATE));
672 011001,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDIU
673 "daddu r<RT>, r<RS>, <IMMEDIATE>"
676 // start-sanitize-vr5400
678 // end-sanitize-vr5400
679 // start-sanitize-r5900
681 // end-sanitize-r5900
683 // start-sanitize-tx19
687 GPR[RT] = GPR[RS] + EXTEND16 (IMMEDIATE);
691 000000,5.RS,5.RT,5.RD,00000,101101:SPECIAL:64::DADDU
692 "daddu r<RD>, r<RS>, r<RT>"
695 // start-sanitize-vr5400
697 // end-sanitize-vr5400
698 // start-sanitize-r5900
700 // end-sanitize-r5900
702 // start-sanitize-tx19
706 GPR[RD] = GPR[RS] + GPR[RT];
710 000000,5.RS,5.RT,0000000000011110:SPECIAL:64::DDIV
714 // start-sanitize-vr5400
716 // end-sanitize-vr5400
717 // start-sanitize-r5900
719 // end-sanitize-r5900
721 // start-sanitize-tx19
725 CHECKHILO ("Division");
727 signed64 n = GPR[RS];
728 signed64 d = GPR[RT];
731 LO = SIGNED64 (0x8000000000000000);
734 else if (d == -1 && n == SIGNED64 (0x8000000000000000))
736 LO = SIGNED64 (0x8000000000000000);
749 000000,5.RS,5.RT,0000000000,011111:SPECIAL:64::DDIVU
754 // start-sanitize-vr5400
756 // end-sanitize-vr5400
757 // start-sanitize-tx19
761 CHECKHILO ("Division");
763 unsigned64 n = GPR[RS];
764 unsigned64 d = GPR[RT];
767 LO = SIGNED64 (0x8000000000000000);
779 000000,5.RS,5.RT,0000000000011010:SPECIAL:32::DIV
785 // start-sanitize-vr5400
787 // end-sanitize-vr5400
788 // start-sanitize-r5900
790 // end-sanitize-r5900
792 // start-sanitize-tx19
796 CHECKHILO("Division");
798 signed32 n = GPR[RS];
799 signed32 d = GPR[RT];
802 LO = EXTEND32 (0x80000000);
805 else if (d == -1 && d == 0x80000000)
807 LO = EXTEND32 (0x80000000);
812 LO = EXTEND32 (n / d);
813 HI = EXTEND32 (n % d);
819 000000,5.RS,5.RT,0000000000011011:SPECIAL:32::DIVU
825 // start-sanitize-vr5400
827 // end-sanitize-vr5400
828 // start-sanitize-r5900
830 // end-sanitize-r5900
832 // start-sanitize-tx19
836 CHECKHILO ("Division");
838 unsigned32 n = GPR[RS];
839 unsigned32 d = GPR[RT];
842 LO = EXTEND32 (0x80000000);
847 LO = EXTEND32 (n / d);
848 HI = EXTEND32 (n % d);
854 000000,5.RS,5.RT,0000000000011100:SPECIAL:64::DMULT
858 // start-sanitize-vr5400
860 // end-sanitize-vr5400
862 // start-sanitize-tx19
866 CHECKHILO ("Multiplication");
868 signed64 op1 = GPR[RS];
869 signed64 op2 = GPR[RT];
878 /* make it unsigned */
889 /* multuply out the 4 sub products */
890 m00 = (VL4_8 (op1) * VL4_8 (op2));
891 m10 = (VH4_8 (op1) * VL4_8 (op2));
892 m01 = (VL4_8 (op1) * VH4_8 (op2));
893 m11 = (VH4_8 (op1) * VH4_8 (op2));
894 /* add the products */
895 mid = VH4_8 (m00) + VL4_8 (m10) + VL4_8 (m01);
896 lo = U8_4 (mid, m00);
897 hi = m11 + VH4_8 (mid) + VH4_8 (m01) + VH4_8 (m10);
898 /* save the result */
916 000000,5.RS,5.RT,0000000000011101:SPECIAL:64::DMULTU
917 "dmultu r<RS>, r<RT>"
920 // start-sanitize-vr5400
922 // end-sanitize-vr5400
924 // start-sanitize-tx19
928 CHECKHILO ("Multiplication");
930 signed64 op1 = GPR[RS];
931 signed64 op2 = GPR[RT];
939 /* multuply out the 4 sub products */
940 m00 = (VL4_8 (op1) * VL4_8 (op2));
941 m10 = (VH4_8 (op1) * VL4_8 (op2));
942 m01 = (VL4_8 (op1) * VH4_8 (op2));
943 m11 = (VH4_8 (op1) * VH4_8 (op2));
944 /* add the products */
945 mid = VH4_8 (m00) + VL4_8 (m10) + VL4_8 (m01);
946 lo = U8_4 (mid, m00);
947 hi = m11 + VH4_8 (mid) + VH4_8 (m01) + VH4_8 (m10);
948 /* save the result */
955 00000000000,5.RT,5.RD,5.SHIFT,111000:SPECIAL:64::DSLL
956 "dsll r<RD>, r<RT>, <SA>"
959 // start-sanitize-vr5400
961 // end-sanitize-vr5400
962 // start-sanitize-r5900
964 // end-sanitize-r5900
966 // start-sanitize-tx19
971 GPR[RD] = GPR[RT] << s;
975 00000000000,5.RT,5.RD,5.SHIFT,111100:SPECIAL:64::DSLL32
976 "dsll32 r<RD>, r<RT>, <SA>"
979 // start-sanitize-vr5400
981 // end-sanitize-vr5400
982 // start-sanitize-r5900
984 // end-sanitize-r5900
986 // start-sanitize-tx19
991 GPR[RD] = GPR[RT] << s;
995 000000,5.RS,5.RT,5.RD,00000010100:SPECIAL:64::DSLLV
996 "dsllv r<RD>, r<RT>, r<RS>"
999 // start-sanitize-vr5400
1001 // end-sanitize-vr5400
1002 // start-sanitize-r5900
1004 // end-sanitize-r5900
1006 // start-sanitize-tx19
1008 // end-sanitize-tx19
1010 int s = MASKED64 (GPR[RS], 5, 0);
1011 GPR[RD] = GPR[RT] << s;
1015 00000000000,5.RT,5.RD,5.SHIFT,111011:SPECIAL:64::DSRA
1016 "dsra r<RD>, r<RT>, <SA>"
1019 // start-sanitize-vr5400
1021 // end-sanitize-vr5400
1022 // start-sanitize-r5900
1024 // end-sanitize-r5900
1026 // start-sanitize-tx19
1028 // end-sanitize-tx19
1031 GPR[RD] = ((signed64) GPR[RT]) >> s;
1035 00000000000,5.RT,5.RD,5.SHIFT,111111:SPECIAL:64::DSRA32
1036 "dsra32 r<RT>, r<RD>, <SA>"
1039 // start-sanitize-vr5400
1041 // end-sanitize-vr5400
1042 // start-sanitize-r5900
1044 // end-sanitize-r5900
1046 // start-sanitize-tx19
1048 // end-sanitize-tx19
1051 GPR[RD] = ((signed64) GPR[RT]) >> s;
1055 000000,5.RS,5.RT,5.RD,00000010111:SPECIAL:64::DSRAV
1056 "dsra32 r<RT>, r<RD>, r<RS>"
1059 // start-sanitize-vr5400
1061 // end-sanitize-vr5400
1062 // start-sanitize-r5900
1064 // end-sanitize-r5900
1066 // start-sanitize-tx19
1068 // end-sanitize-tx19
1070 int s = MASKED64 (GPR[RS], 5, 0);
1071 GPR[RD] = ((signed64) GPR[RT]) >> s;
1075 00000000000,5.RT,5.RD,5.SHIFT,111010:SPECIAL:64::DSRL
1076 "dsrav r<RD>, r<RT>, <SA>"
1079 // start-sanitize-vr5400
1081 // end-sanitize-vr5400
1082 // start-sanitize-r5900
1084 // end-sanitize-r5900
1086 // start-sanitize-tx19
1088 // end-sanitize-tx19
1091 GPR[RD] = (unsigned64) GPR[RT] >> s;
1095 00000000000,5.RT,5.RD,5.SHIFT,111110:SPECIAL:64::DSRL32
1096 "dsrl32 r<RD>, r<RT>, <SA>"
1099 // start-sanitize-vr5400
1101 // end-sanitize-vr5400
1102 // start-sanitize-r5900
1104 // end-sanitize-r5900
1106 // start-sanitize-tx19
1108 // end-sanitize-tx19
1111 GPR[RD] = (unsigned64) GPR[RT] >> s;
1115 000000,5.RS,5.RT,5.RD,00000010110:SPECIAL:64::DSRLV
1116 "dsrl32 r<RD>, r<RT>, r<RS>"
1119 // start-sanitize-vr5400
1121 // end-sanitize-vr5400
1122 // start-sanitize-r5900
1124 // end-sanitize-r5900
1126 // start-sanitize-tx19
1128 // end-sanitize-tx19
1130 int s = MASKED64 (GPR[RS], 5, 0);
1131 GPR[RD] = (unsigned64) GPR[RT] >> s;
1135 000000,5.RS,5.RT,5.RD,00000101110:SPECIAL:64::DSUB
1136 "dsub r<RD>, r<RS>, r<RT>"
1139 // start-sanitize-vr5400
1141 // end-sanitize-vr5400
1142 // start-sanitize-r5900
1144 // end-sanitize-r5900
1146 // start-sanitize-tx19
1148 // end-sanitize-tx19
1150 ALU64_BEGIN (GPR[RS]);
1151 ALU64_SUB (GPR[RT]);
1152 ALU64_END (GPR[RD]);
1156 000000,5.RS,5.RT,5.RD,00000101111:SPECIAL:64::DSUBU
1157 "dsubu r<RD>, r<RS>, r<RT>"
1160 // start-sanitize-vr5400
1162 // end-sanitize-vr5400
1163 // start-sanitize-r5900
1165 // end-sanitize-r5900
1167 // start-sanitize-tx19
1169 // end-sanitize-tx19
1171 GPR[RD] = GPR[RS] - GPR[RT];
1175 000010,26.INSTR_INDEX:NORMAL:32::J
1181 // start-sanitize-vr5400
1183 // end-sanitize-vr5400
1184 // start-sanitize-r5900
1186 // end-sanitize-r5900
1188 // start-sanitize-tx19
1190 // end-sanitize-tx19
1192 /* NOTE: The region used is that of the delay slot NIA and NOT the
1193 current instruction */
1194 address_word region = (NIA & MASK (63, 28));
1195 DELAY_SLOT (region | (INSTR_INDEX << 2));
1199 000011,26.INSTR_INDEX:NORMAL:32::JAL
1205 // start-sanitize-vr5400
1207 // end-sanitize-vr5400
1208 // start-sanitize-r5900
1210 // end-sanitize-r5900
1212 // start-sanitize-tx19
1214 // end-sanitize-tx19
1216 /* NOTE: The region used is that of the delay slot and NOT the
1217 current instruction */
1218 address_word region = (NIA & MASK (63, 28));
1220 DELAY_SLOT (region | (INSTR_INDEX << 2));
1224 000000,5.RS,00000,5.RD,00000001001:SPECIAL:32::JALR
1225 "jalr r<RS>":RD == 31
1231 // start-sanitize-vr5400
1233 // end-sanitize-vr5400
1234 // start-sanitize-r5900
1236 // end-sanitize-r5900
1238 // start-sanitize-tx19
1240 // end-sanitize-tx19
1242 address_word temp = GPR[RS];
1248 000000,5.RS,000000000000000001000:SPECIAL:32::JR
1254 // start-sanitize-vr5400
1256 // end-sanitize-vr5400
1257 // start-sanitize-r5900
1259 // end-sanitize-r5900
1261 // start-sanitize-tx19
1263 // end-sanitize-tx19
1265 DELAY_SLOT (GPR[RS]);
1269 100000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LB
1270 "lb r<RT>, <OFFSET>(r<BASE>)"
1275 // start-sanitize-vr5400
1277 // end-sanitize-vr5400
1278 // start-sanitize-r5900
1280 // end-sanitize-r5900
1282 // start-sanitize-tx19
1284 // end-sanitize-tx19
1286 unsigned32 instruction = instruction_0;
1287 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1288 int destreg = ((instruction >> 16) & 0x0000001F);
1289 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1291 address_word vaddr = ((uword64)op1 + offset);
1295 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1298 uword64 memval1 = 0;
1300 unsigned int shift = 0;
1301 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1302 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1304 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1305 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
1306 byte = ((vaddr & mask) ^ (bigend << shift));
1307 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x000000FF),8));
1314 100100,5.BASE,5.RT,16.OFFSET:NORMAL:32::LBU
1315 "lbu r<RT>, <OFFSET>(r<BASE>)"
1320 // start-sanitize-vr5400
1322 // end-sanitize-vr5400
1323 // start-sanitize-r5900
1325 // end-sanitize-r5900
1327 // start-sanitize-tx19
1329 // end-sanitize-tx19
1331 unsigned32 instruction = instruction_0;
1332 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1333 int destreg = ((instruction >> 16) & 0x0000001F);
1334 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1336 address_word vaddr = ((unsigned64)op1 + offset);
1340 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1342 unsigned64 memval = 0;
1343 unsigned64 memval1 = 0;
1344 unsigned64 mask = 0x7;
1345 unsigned int shift = 0;
1346 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1347 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1349 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1350 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
1351 byte = ((vaddr & mask) ^ (bigend << shift));
1352 GPR[destreg] = (((memval >> (8 * byte)) & 0x000000FF));
1359 110111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LD
1360 "ld r<RT>, <OFFSET>(r<BASE>)"
1363 // start-sanitize-vr5400
1365 // end-sanitize-vr5400
1366 // start-sanitize-r5900
1368 // end-sanitize-r5900
1370 // start-sanitize-tx19
1372 // end-sanitize-tx19
1374 unsigned32 instruction = instruction_0;
1375 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1376 int destreg = ((instruction >> 16) & 0x0000001F);
1377 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1379 address_word vaddr = ((unsigned64)op1 + offset);
1382 if ((vaddr & 7) != 0)
1383 SignalExceptionAddressLoad();
1386 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1388 unsigned64 memval = 0;
1389 unsigned64 memval1 = 0;
1390 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1391 GPR[destreg] = memval;
1398 1101,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDCz
1399 "ldc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1403 // start-sanitize-vr5400
1405 // end-sanitize-vr5400
1406 // start-sanitize-r5900
1408 // end-sanitize-r5900
1410 // start-sanitize-tx19
1412 // end-sanitize-tx19
1414 unsigned32 instruction = instruction_0;
1415 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1416 int destreg = ((instruction >> 16) & 0x0000001F);
1417 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1419 address_word vaddr = ((unsigned64)op1 + offset);
1422 if ((vaddr & 7) != 0)
1423 SignalExceptionAddressLoad();
1426 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1428 unsigned64 memval = 0;
1429 unsigned64 memval1 = 0;
1430 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1431 COP_LD(((instruction >> 26) & 0x3),destreg,memval);;
1438 011010,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDL
1439 "ldl r<RT>, <OFFSET>(r<BASE>)"
1442 // start-sanitize-vr5400
1444 // end-sanitize-vr5400
1445 // start-sanitize-r5900
1447 // end-sanitize-r5900
1449 // start-sanitize-tx19
1451 // end-sanitize-tx19
1453 unsigned32 instruction = instruction_0;
1454 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1455 int destreg = ((instruction >> 16) & 0x0000001F);
1456 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1458 address_word vaddr = ((unsigned64)op1 + offset);
1462 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1464 unsigned64 memval = 0;
1465 unsigned64 memval1 = 0;
1466 unsigned64 mask = 7;
1467 unsigned int reverse = (ReverseEndian ? mask : 0);
1468 unsigned int bigend = (BigEndianCPU ? mask : 0);
1470 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1471 byte = ((vaddr & mask) ^ bigend);
1474 LoadMemory(&memval,&memval1,uncached,byte,paddr,vaddr,isDATA,isREAL);
1475 GPR[destreg] = ((memval << ((7 - byte) * 8)) | (GPR[destreg] & (((unsigned64)1 << ((7 - byte) * 8)) - 1)));
1482 011011,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDR
1483 "ldr r<RT>, <OFFSET>(r<BASE>)"
1486 // start-sanitize-vr5400
1488 // end-sanitize-vr5400
1489 // start-sanitize-r5900
1491 // end-sanitize-r5900
1493 // start-sanitize-tx19
1495 // end-sanitize-tx19
1497 unsigned32 instruction = instruction_0;
1498 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1499 int destreg = ((instruction >> 16) & 0x0000001F);
1500 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1502 address_word vaddr = ((unsigned64)op1 + offset);
1506 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1508 unsigned64 memval = 0;
1509 unsigned64 memval1 = 0;
1510 unsigned64 mask = 7;
1511 unsigned int reverse = (ReverseEndian ? mask : 0);
1512 unsigned int bigend = (BigEndianCPU ? mask : 0);
1514 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1515 byte = ((vaddr & mask) ^ bigend);
1518 LoadMemory(&memval,&memval1,uncached,(7 - byte),paddr,vaddr,isDATA,isREAL);
1524 srcmask = ((unsigned64)-1 << (8 * (8 - byte)));
1525 GPR[destreg] = ((GPR[destreg] & srcmask) | (memval >> (8 * byte)));
1533 100001,5.BASE,5.RT,16.OFFSET:NORMAL:32::LH
1534 "lh r<RT>, <OFFSET>(r<BASE>)"
1539 // start-sanitize-vr5400
1541 // end-sanitize-vr5400
1542 // start-sanitize-r5900
1544 // end-sanitize-r5900
1546 // start-sanitize-tx19
1548 // end-sanitize-tx19
1550 unsigned32 instruction = instruction_0;
1551 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1552 int destreg = ((instruction >> 16) & 0x0000001F);
1553 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1555 address_word vaddr = ((unsigned64)op1 + offset);
1558 if ((vaddr & 1) != 0)
1559 SignalExceptionAddressLoad();
1562 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1564 unsigned64 memval = 0;
1565 unsigned64 memval1 = 0;
1566 unsigned64 mask = 0x7;
1567 unsigned int shift = 1;
1568 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1569 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1571 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1572 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
1573 byte = ((vaddr & mask) ^ (bigend << shift));
1574 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x0000FFFF),16));
1581 100101,5.BASE,5.RT,16.OFFSET:NORMAL:32::LHU
1582 "lhu r<RT>, <OFFSET>(r<BASE>)"
1587 // start-sanitize-vr5400
1589 // end-sanitize-vr5400
1590 // start-sanitize-r5900
1592 // end-sanitize-r5900
1594 // start-sanitize-tx19
1596 // end-sanitize-tx19
1598 unsigned32 instruction = instruction_0;
1599 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1600 int destreg = ((instruction >> 16) & 0x0000001F);
1601 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1603 address_word vaddr = ((unsigned64)op1 + offset);
1606 if ((vaddr & 1) != 0)
1607 SignalExceptionAddressLoad();
1610 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1612 unsigned64 memval = 0;
1613 unsigned64 memval1 = 0;
1614 unsigned64 mask = 0x7;
1615 unsigned int shift = 1;
1616 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1617 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1619 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1620 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
1621 byte = ((vaddr & mask) ^ (bigend << shift));
1622 GPR[destreg] = (((memval >> (8 * byte)) & 0x0000FFFF));
1629 110000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LL
1630 "ll r<RT>, <OFFSET>(r<BASE>)"
1634 // start-sanitize-vr5400
1636 // end-sanitize-vr5400
1637 // start-sanitize-r5900
1639 // end-sanitize-r5900
1641 // start-sanitize-tx19
1643 // end-sanitize-tx19
1645 unsigned32 instruction = instruction_0;
1646 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1647 int destreg = ((instruction >> 16) & 0x0000001F);
1648 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1650 address_word vaddr = ((unsigned64)op1 + offset);
1653 if ((vaddr & 3) != 0)
1654 SignalExceptionAddressLoad();
1657 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1659 unsigned64 memval = 0;
1660 unsigned64 memval1 = 0;
1661 unsigned64 mask = 0x7;
1662 unsigned int shift = 2;
1663 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1664 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1666 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1667 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1668 byte = ((vaddr & mask) ^ (bigend << shift));
1669 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
1677 110100,5.BASE,5.RT,16.OFFSET:NORMAL:64::LLD
1678 "lld r<RT>, <OFFSET>(r<BASE>)"
1681 // start-sanitize-vr5400
1683 // end-sanitize-vr5400
1684 // start-sanitize-r5900
1686 // end-sanitize-r5900
1688 // start-sanitize-tx19
1690 // end-sanitize-tx19
1692 unsigned32 instruction = instruction_0;
1693 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1694 int destreg = ((instruction >> 16) & 0x0000001F);
1695 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1697 address_word vaddr = ((unsigned64)op1 + offset);
1700 if ((vaddr & 7) != 0)
1701 SignalExceptionAddressLoad();
1704 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1706 unsigned64 memval = 0;
1707 unsigned64 memval1 = 0;
1708 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1709 GPR[destreg] = memval;
1717 001111,00000,5.RT,16.IMMEDIATE:NORMAL:32::LUI
1718 "lui r<RT>, <IMMEDIATE>"
1723 // start-sanitize-vr5400
1725 // end-sanitize-vr5400
1726 // start-sanitize-r5900
1728 // end-sanitize-r5900
1730 // start-sanitize-tx19
1732 // end-sanitize-tx19
1734 GPR[RT] = EXTEND32 (IMMEDIATE << 16);
1738 100011,5.BASE,5.RT,16.OFFSET:NORMAL:32::LW
1739 "lw r<RT>, <OFFSET>(r<BASE>)"
1744 // start-sanitize-vr5400
1746 // end-sanitize-vr5400
1747 // start-sanitize-r5900
1749 // end-sanitize-r5900
1751 // start-sanitize-tx19
1753 // end-sanitize-tx19
1755 unsigned32 instruction = instruction_0;
1756 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1757 int destreg = ((instruction >> 16) & 0x0000001F);
1758 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1760 address_word vaddr = ((unsigned64)op1 + offset);
1763 if ((vaddr & 3) != 0)
1764 SignalExceptionAddressLoad();
1767 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1769 unsigned64 memval = 0;
1770 unsigned64 memval1 = 0;
1771 unsigned64 mask = 0x7;
1772 unsigned int shift = 2;
1773 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1774 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1776 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1777 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1778 byte = ((vaddr & mask) ^ (bigend << shift));
1779 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
1786 1100,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWCz
1787 "lwc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1792 // start-sanitize-vr5400
1794 // end-sanitize-vr5400
1795 // start-sanitize-r5900
1797 // end-sanitize-r5900
1799 // start-sanitize-tx19
1801 // end-sanitize-tx19
1803 unsigned32 instruction = instruction_0;
1804 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1805 int destreg = ((instruction >> 16) & 0x0000001F);
1806 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1808 address_word vaddr = ((unsigned64)op1 + offset);
1811 if ((vaddr & 3) != 0)
1812 SignalExceptionAddressLoad();
1815 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1817 unsigned64 memval = 0;
1818 unsigned64 memval1 = 0;
1819 unsigned64 mask = 0x7;
1820 unsigned int shift = 2;
1821 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1822 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1824 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1825 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1826 byte = ((vaddr & mask) ^ (bigend << shift));
1827 COP_LW(((instruction >> 26) & 0x3),destreg,(unsigned int)((memval >> (8 * byte)) & 0xFFFFFFFF));
1834 100010,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWL
1835 "lwl r<RT>, <OFFSET>(r<BASE>)"
1840 // start-sanitize-vr5400
1842 // end-sanitize-vr5400
1843 // start-sanitize-r5900
1845 // end-sanitize-r5900
1847 // start-sanitize-tx19
1849 // end-sanitize-tx19
1851 unsigned32 instruction = instruction_0;
1852 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1853 int destreg = ((instruction >> 16) & 0x0000001F);
1854 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1856 address_word vaddr = ((unsigned64)op1 + offset);
1860 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1862 unsigned64 memval = 0;
1863 unsigned64 memval1 = 0;
1864 unsigned64 mask = 3;
1865 unsigned int reverse = (ReverseEndian ? mask : 0);
1866 unsigned int bigend = (BigEndianCPU ? mask : 0);
1868 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1869 byte = ((vaddr & mask) ^ bigend);
1872 LoadMemory(&memval,&memval1,uncached,byte,paddr,vaddr,isDATA,isREAL);
1873 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
1876 GPR[destreg] = ((memval << ((3 - byte) * 8)) | (GPR[destreg] & (((unsigned64)1 << ((3 - byte) * 8)) - 1)));
1877 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1884 100110,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWR
1885 "lwr r<RT>, <OFFSET>(r<BASE>)"
1890 // start-sanitize-vr5400
1892 // end-sanitize-vr5400
1893 // start-sanitize-r5900
1895 // end-sanitize-r5900
1897 // start-sanitize-tx19
1899 // end-sanitize-tx19
1901 unsigned32 instruction = instruction_0;
1902 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1903 int destreg = ((instruction >> 16) & 0x0000001F);
1904 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1906 address_word vaddr = ((unsigned64)op1 + offset);
1910 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1912 unsigned64 memval = 0;
1913 unsigned64 memval1 = 0;
1914 unsigned64 mask = 3;
1915 unsigned int reverse = (ReverseEndian ? mask : 0);
1916 unsigned int bigend = (BigEndianCPU ? mask : 0);
1918 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1919 byte = ((vaddr & mask) ^ bigend);
1922 LoadMemory(&memval,&memval1,uncached,(3 - byte),paddr,vaddr,isDATA,isREAL);
1923 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
1931 srcmask = ((unsigned64)-1 << (8 * (4 - byte)));
1932 GPR[destreg] = ((GPR[destreg] & srcmask) | (memval >> (8 * byte)));
1934 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1941 100111,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWU
1942 "lwu r<RT>, <OFFSET>(r<BASE>)"
1945 // start-sanitize-vr5400
1947 // end-sanitize-vr5400
1948 // start-sanitize-r5900
1950 // end-sanitize-r5900
1952 // start-sanitize-tx19
1954 // end-sanitize-tx19
1956 unsigned32 instruction = instruction_0;
1957 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1958 int destreg = ((instruction >> 16) & 0x0000001F);
1959 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1961 address_word vaddr = ((unsigned64)op1 + offset);
1964 if ((vaddr & 3) != 0)
1965 SignalExceptionAddressLoad();
1968 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1970 unsigned64 memval = 0;
1971 unsigned64 memval1 = 0;
1972 unsigned64 mask = 0x7;
1973 unsigned int shift = 2;
1974 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1975 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1977 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1978 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1979 byte = ((vaddr & mask) ^ (bigend << shift));
1980 GPR[destreg] = (((memval >> (8 * byte)) & 0xFFFFFFFF));
1987 000000,0000000000,5.RD,00000,010000:SPECIAL:32::MFHI
1993 // start-sanitize-vr5400
1995 // end-sanitize-vr5400
1996 // start-sanitize-r5900
1998 // end-sanitize-r5900
2000 // start-sanitize-tx19
2002 // end-sanitize-tx19
2009 000000,0000000000,5.RD,00000,010010:SPECIAL:32::MFLO
2015 // start-sanitize-vr5400
2017 // end-sanitize-vr5400
2018 // start-sanitize-r5900
2020 // end-sanitize-r5900
2022 // start-sanitize-tx19
2024 // end-sanitize-tx19
2027 LOACCESS = 3; /* 3rd instruction will be safe */
2031 000000,5.RS,5.RT,5.RD,00000001011:SPECIAL:32::MOVN
2032 "movn r<RD>, r<RS>, r<RT>"
2034 // start-sanitize-vr5400
2036 // end-sanitize-vr5400
2037 // start-sanitize-r5900
2039 // end-sanitize-r5900
2046 000000,5.RS,5.RT,5.RD,00000001010:SPECIAL:32::MOVZ
2047 "movz r<RD>, r<RS>, r<RT>"
2049 // start-sanitize-vr5400
2051 // end-sanitize-vr5400
2052 // start-sanitize-r5900
2054 // end-sanitize-r5900
2061 000000,5.RS,000000000000000,010001:SPECIAL:32::MTHI
2067 // start-sanitize-vr5400
2069 // end-sanitize-vr5400
2070 // start-sanitize-r5900
2072 // end-sanitize-r5900
2074 // start-sanitize-tx19
2076 // end-sanitize-tx19
2079 sim_io_eprintf (sd, "MT (move-to) over-writing HI register value\n");
2081 HIACCESS = 3; /* 3rd instruction will be safe */
2085 000000,5.RS,000000000000000010011:SPECIAL:32::MTLO
2091 // start-sanitize-vr5400
2093 // end-sanitize-vr5400
2094 // start-sanitize-r5900
2096 // end-sanitize-r5900
2098 // start-sanitize-tx19
2100 // end-sanitize-tx19
2103 sim_io_eprintf (sd, "MT (move-to) over-writing LO register value\n");
2105 LOACCESS = 3; /* 3rd instruction will be safe */
2109 000000,5.RS,5.RT,5.RD,00000011000:SPECIAL:32::MULT
2115 // start-sanitize-vr5400
2117 // end-sanitize-vr5400
2118 // start-sanitize-r5900
2120 // end-sanitize-r5900
2122 // start-sanitize-tx19
2124 // end-sanitize-tx19
2127 CHECKHILO ("Multiplication");
2128 prod = (((signed64)(signed32) GPR[RS])
2129 * ((signed64)(signed32) GPR[RT]));
2130 LO = EXTEND32 (VL4_8 (prod));
2131 HI = EXTEND32 (VH4_8 (prod));
2135 000000,5.RS,5.RT,5.RD,00000011001:SPECIAL:32::MULTU
2136 "multu r<RS>, r<RT>"
2141 // start-sanitize-vr5400
2143 // end-sanitize-vr5400
2144 // start-sanitize-r5900
2146 // end-sanitize-r5900
2148 // start-sanitize-tx19
2150 // end-sanitize-tx19
2153 CHECKHILO ("Multiplication");
2154 prod = (((unsigned64)(unsigned32) GPR[RS])
2155 * ((unsigned64)(unsigned32) GPR[RT]));
2156 LO = EXTEND32 (VL4_8 (prod));
2157 HI = EXTEND32 (VH4_8 (prod));
2161 000000,5.RS,5.RT,5.RD,00000,100111:SPECIAL:32::NOR
2162 "nor r<RD>, r<RS>, r<RT>"
2167 // start-sanitize-vr5400
2169 // end-sanitize-vr5400
2170 // start-sanitize-r5900
2172 // end-sanitize-r5900
2174 // start-sanitize-tx19
2176 // end-sanitize-tx19
2178 GPR[RD] = ~ (GPR[RS] | GPR[RT]);
2182 000000,5.RS,5.RT,5.RD,00000,100101:SPECIAL:32::OR
2183 "or r<RD>, r<RS>, r<RT>"
2188 // start-sanitize-vr5400
2190 // end-sanitize-vr5400
2191 // start-sanitize-r5900
2193 // end-sanitize-r5900
2195 // start-sanitize-tx19
2197 // end-sanitize-tx19
2199 GPR[RD] = (GPR[RS] | GPR[RT]);
2203 001101,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ORI
2204 "ori r<RT>, r<RS>, <IMMEDIATE>"
2209 // start-sanitize-vr5400
2211 // end-sanitize-vr5400
2212 // start-sanitize-r5900
2214 // end-sanitize-r5900
2216 // start-sanitize-tx19
2218 // end-sanitize-tx19
2220 GPR[RT] = (GPR[RS] | IMMEDIATE);
2224 110011,5.RS,nnnnn,16.OFFSET:NORMAL:32::PREF
2226 // start-sanitize-vr5400
2228 // end-sanitize-vr5400
2229 // start-sanitize-r5900
2231 // end-sanitize-r5900
2233 unsigned32 instruction = instruction_0;
2234 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2235 int hint = ((instruction >> 16) & 0x0000001F);
2236 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2238 address_word vaddr = ((unsigned64)op1 + offset);
2242 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
2243 Prefetch(uncached,paddr,vaddr,isDATA,hint);
2248 101000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SB
2249 "sb r<RT>, <OFFSET>(r<BASE>)"
2254 // start-sanitize-vr5400
2256 // end-sanitize-vr5400
2257 // start-sanitize-r5900
2259 // end-sanitize-r5900
2261 // start-sanitize-tx19
2263 // end-sanitize-tx19
2265 unsigned32 instruction = instruction_0;
2266 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2267 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2268 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2270 address_word vaddr = ((unsigned64)op1 + offset);
2274 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2276 unsigned64 memval = 0;
2277 unsigned64 memval1 = 0;
2278 unsigned64 mask = 0x7;
2279 unsigned int shift = 0;
2280 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
2281 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
2283 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
2284 byte = ((vaddr & mask) ^ (bigend << shift));
2285 memval = ((unsigned64) op2 << (8 * byte));
2287 StoreMemory(uncached,AccessLength_BYTE,memval,memval1,paddr,vaddr,isREAL);
2295 111000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SC
2296 "sc r<RT>, <OFFSET>(r<BASE>)"
2300 // start-sanitize-vr5400
2302 // end-sanitize-vr5400
2303 // start-sanitize-r5900
2305 // end-sanitize-r5900
2307 // start-sanitize-tx19
2309 // end-sanitize-tx19
2311 unsigned32 instruction = instruction_0;
2312 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2313 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2314 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2316 address_word vaddr = ((unsigned64)op1 + offset);
2319 if ((vaddr & 3) != 0)
2320 SignalExceptionAddressStore();
2323 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2325 unsigned64 memval = 0;
2326 unsigned64 memval1 = 0;
2327 unsigned64 mask = 0x7;
2329 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2330 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2331 memval = ((unsigned64) op2 << (8 * byte));
2334 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2336 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
2343 111100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SCD
2344 "scd r<RT>, <OFFSET>(r<BASE>)"
2347 // start-sanitize-vr5400
2349 // end-sanitize-vr5400
2350 // start-sanitize-r5900
2352 // end-sanitize-r5900
2354 // start-sanitize-tx19
2356 // end-sanitize-tx19
2358 unsigned32 instruction = instruction_0;
2359 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2360 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2361 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2363 address_word vaddr = ((unsigned64)op1 + offset);
2366 if ((vaddr & 7) != 0)
2367 SignalExceptionAddressStore();
2370 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2372 unsigned64 memval = 0;
2373 unsigned64 memval1 = 0;
2377 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2379 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
2386 111111,5.BASE,5.RT,16.OFFSET:NORMAL:64::SD
2387 "sd r<RT>, <OFFSET>(r<BASE>)"
2390 // start-sanitize-vr5400
2392 // end-sanitize-vr5400
2393 // start-sanitize-r5900
2395 // end-sanitize-r5900
2397 // start-sanitize-tx19
2399 // end-sanitize-tx19
2401 unsigned32 instruction = instruction_0;
2402 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2403 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2404 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2406 address_word vaddr = ((unsigned64)op1 + offset);
2409 if ((vaddr & 7) != 0)
2410 SignalExceptionAddressStore();
2413 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2415 unsigned64 memval = 0;
2416 unsigned64 memval1 = 0;
2419 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2427 1111,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDCz
2428 "sdc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2432 // start-sanitize-vr5400
2434 // end-sanitize-vr5400
2435 // start-sanitize-r5900
2437 // end-sanitize-r5900
2439 // start-sanitize-tx19
2441 // end-sanitize-tx19
2443 unsigned32 instruction = instruction_0;
2444 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2445 int destreg = ((instruction >> 16) & 0x0000001F);
2446 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2448 address_word vaddr = ((unsigned64)op1 + offset);
2451 if ((vaddr & 7) != 0)
2452 SignalExceptionAddressStore();
2455 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2457 unsigned64 memval = 0;
2458 unsigned64 memval1 = 0;
2459 memval = (unsigned64)COP_SD(((instruction >> 26) & 0x3),destreg);
2461 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2469 101100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDL
2470 "sdl r<RT>, <OFFSET>(r<BASE>)"
2473 // start-sanitize-vr5400
2475 // end-sanitize-vr5400
2476 // start-sanitize-r5900
2478 // end-sanitize-r5900
2480 // start-sanitize-tx19
2482 // end-sanitize-tx19
2484 unsigned32 instruction = instruction_0;
2485 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2486 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2487 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2489 address_word vaddr = ((unsigned64)op1 + offset);
2493 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2495 unsigned64 memval = 0;
2496 unsigned64 memval1 = 0;
2497 unsigned64 mask = 7;
2498 unsigned int reverse = (ReverseEndian ? mask : 0);
2499 unsigned int bigend = (BigEndianCPU ? mask : 0);
2501 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
2502 byte = ((vaddr & mask) ^ bigend);
2505 memval = (op2 >> (8 * (7 - byte)));
2506 StoreMemory(uncached,byte,memval,memval1,paddr,vaddr,isREAL);
2513 101101,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDR
2514 "sdr r<RT>, <OFFSET>(r<BASE>)"
2517 // start-sanitize-vr5400
2519 // end-sanitize-vr5400
2520 // start-sanitize-r5900
2522 // end-sanitize-r5900
2524 // start-sanitize-tx19
2526 // end-sanitize-tx19
2528 unsigned32 instruction = instruction_0;
2529 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2530 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2531 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2533 address_word vaddr = ((unsigned64)op1 + offset);
2537 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2539 unsigned64 memval = 0;
2540 unsigned64 memval1 = 0;
2541 unsigned64 mask = 7;
2542 unsigned int reverse = (ReverseEndian ? mask : 0);
2543 unsigned int bigend = (BigEndianCPU ? mask : 0);
2545 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
2546 byte = ((vaddr & mask) ^ bigend);
2549 memval = ((unsigned64) op2 << (byte * 8));
2550 StoreMemory(uncached,(AccessLength_DOUBLEWORD - byte),memval,memval1,paddr,vaddr,isREAL);
2557 101001,5.BASE,5.RT,16.OFFSET:NORMAL:32::SH
2558 "sh r<RT>, <OFFSET>(r<BASE>)"
2563 // start-sanitize-vr5400
2565 // end-sanitize-vr5400
2566 // start-sanitize-r5900
2568 // end-sanitize-r5900
2570 // start-sanitize-tx19
2572 // end-sanitize-tx19
2574 unsigned32 instruction = instruction_0;
2575 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2576 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2577 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2579 address_word vaddr = ((unsigned64)op1 + offset);
2582 if ((vaddr & 1) != 0)
2583 SignalExceptionAddressStore();
2586 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2588 unsigned64 memval = 0;
2589 unsigned64 memval1 = 0;
2590 unsigned64 mask = 0x7;
2591 unsigned int shift = 1;
2592 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
2593 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
2595 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
2596 byte = ((vaddr & mask) ^ (bigend << shift));
2597 memval = ((unsigned64) op2 << (8 * byte));
2599 StoreMemory(uncached,AccessLength_HALFWORD,memval,memval1,paddr,vaddr,isREAL);
2607 00000000000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLL
2608 "sll r<RD>, r<RT>, <SHIFT>"
2613 // start-sanitize-vr5400
2615 // end-sanitize-vr5400
2616 // start-sanitize-r5900
2618 // end-sanitize-r5900
2620 // start-sanitize-tx19
2622 // end-sanitize-tx19
2625 unsigned32 temp = (GPR[RT] << s);
2626 GPR[RD] = EXTEND32 (temp);
2630 000000,5.RS,5.RT,5.RD,00000000100:SPECIAL:32::SLLV
2631 "sllv r<RD>, r<RT>, r<RS>"
2636 // start-sanitize-vr5400
2638 // end-sanitize-vr5400
2639 // start-sanitize-r5900
2641 // end-sanitize-r5900
2643 // start-sanitize-tx19
2645 // end-sanitize-tx19
2647 int s = MASKED (GPR[RS], 4, 0);
2648 unsigned32 temp = (GPR[RT] << s);
2649 GPR[RD] = EXTEND32 (temp);
2653 000000,5.RS,5.RT,5.RD,00000101010:SPECIAL:32::SLT
2654 "slt r<RD>, r<RS>, r<RT>"
2659 // start-sanitize-vr5400
2661 // end-sanitize-vr5400
2662 // start-sanitize-r5900
2664 // end-sanitize-r5900
2666 // start-sanitize-tx19
2668 // end-sanitize-tx19
2670 GPR[RD] = (GPR[RS] < GPR[RT]);
2674 001010,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTI
2675 "slti r<RT>, r<RS>, <IMMEDIATE>"
2680 // start-sanitize-vr5400
2682 // end-sanitize-vr5400
2683 // start-sanitize-r5900
2685 // end-sanitize-r5900
2687 // start-sanitize-tx19
2689 // end-sanitize-tx19
2691 GPR[RT] = (GPR[RS] < EXTEND16 (IMMEDIATE));
2695 001011,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTIU
2696 "sltiu r<RT>, r<RS>, <IMMEDIATE>"
2701 // start-sanitize-vr5400
2703 // end-sanitize-vr5400
2704 // start-sanitize-r5900
2706 // end-sanitize-r5900
2708 // start-sanitize-tx19
2710 // end-sanitize-tx19
2712 GPR[RT] = ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE));
2715 000000,5.RS,5.RT,5.RD,00000101011:SPECIAL:32::SLTU
2716 "sltu r<RD>, r<RS>, r<RT>"
2721 // start-sanitize-vr5400
2723 // end-sanitize-vr5400
2724 // start-sanitize-r5900
2726 // end-sanitize-r5900
2728 // start-sanitize-tx19
2730 // end-sanitize-tx19
2732 GPR[RD] = ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT]);
2736 000000,00000,5.RT,5.RD,5.SHIFT,000011:SPECIAL:32::SRA
2737 "sra r<RD>, r<RT>, <SHIFT>"
2742 // start-sanitize-vr5400
2744 // end-sanitize-vr5400
2745 // start-sanitize-r5900
2747 // end-sanitize-r5900
2749 // start-sanitize-tx19
2751 // end-sanitize-tx19
2754 signed32 temp = (signed32) GPR[RT] >> s;
2755 GPR[RD] = EXTEND32 (temp);
2759 000000,5.RS,5.RT,5.RD,00000000111:SPECIAL:32::SRAV
2760 "srav r<RD>, r<RT>, r<RS>"
2765 // start-sanitize-vr5400
2767 // end-sanitize-vr5400
2768 // start-sanitize-r5900
2770 // end-sanitize-r5900
2772 // start-sanitize-tx19
2774 // end-sanitize-tx19
2776 int s = MASKED (GPR[RS], 4, 0);
2777 signed32 temp = (signed32) GPR[RT] >> s;
2778 GPR[RD] = EXTEND32 (temp);
2782 000000,00000,5.RT,5.RD,5.SHIFT,000010:SPECIAL:32::SRL
2783 "srl r<RD>, r<RT>, <SHIFT>"
2788 // start-sanitize-vr5400
2790 // end-sanitize-vr5400
2791 // start-sanitize-r5900
2793 // end-sanitize-r5900
2795 // start-sanitize-tx19
2797 // end-sanitize-tx19
2800 unsigned32 temp = (unsigned32) GPR[RT] >> s;
2801 GPR[RD] = EXTEND32 (temp);
2805 000000,5.RS,5.RT,5.RD,00000000110:SPECIAL:32::SRLV
2806 "srlv r<RD>, r<RT>, r<RS>"
2811 // start-sanitize-vr5400
2813 // end-sanitize-vr5400
2814 // start-sanitize-r5900
2816 // end-sanitize-r5900
2818 // start-sanitize-tx19
2820 // end-sanitize-tx19
2822 int s = MASKED (GPR[RS], 4, 0);
2823 unsigned32 temp = (unsigned32) GPR[RT] >> s;
2824 GPR[RD] = EXTEND32 (temp);
2828 000000,5.RS,5.RT,5.RD,00000100010:SPECIAL:32::SUB
2829 "sub r<RD>, r<RS>, r<RT>"
2834 // start-sanitize-vr5400
2836 // end-sanitize-vr5400
2837 // start-sanitize-r5900
2839 // end-sanitize-r5900
2841 // start-sanitize-tx19
2843 // end-sanitize-tx19
2845 ALU32_BEGIN (GPR[RS]);
2846 ALU32_SUB (GPR[RT]);
2847 ALU32_END (GPR[RD]);
2851 000000,5.RS,5.RT,5.RD,00000100011:SPECIAL:32::SUBU
2852 "subu r<RD>, r<RS>, r<RT>"
2857 // start-sanitize-vr5400
2859 // end-sanitize-vr5400
2860 // start-sanitize-r5900
2862 // end-sanitize-r5900
2864 // start-sanitize-tx19
2866 // end-sanitize-tx19
2868 GPR[RD] = EXTEND32 (GPR[RS] - GPR[RT]);
2872 101011,5.BASE,5.RT,16.OFFSET:NORMAL:32::SW
2873 "sw r<RT>, <OFFSET>(r<BASE>)"
2878 // start-sanitize-vr5400
2880 // end-sanitize-vr5400
2881 // start-sanitize-r5900
2883 // end-sanitize-r5900
2885 // start-sanitize-tx19
2887 // end-sanitize-tx19
2889 unsigned32 instruction = instruction_0;
2890 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2891 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2892 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2894 address_word vaddr = ((unsigned64)op1 + offset);
2897 if ((vaddr & 3) != 0)
2898 SignalExceptionAddressStore();
2901 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2903 unsigned64 memval = 0;
2904 unsigned64 memval1 = 0;
2905 unsigned64 mask = 0x7;
2907 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2908 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2909 memval = ((unsigned64) op2 << (8 * byte));
2911 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2919 1110,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWCz
2920 "swc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2925 // start-sanitize-vr5400
2927 // end-sanitize-vr5400
2928 // start-sanitize-r5900
2930 // end-sanitize-r5900
2932 // start-sanitize-tx19
2934 // end-sanitize-tx19
2936 unsigned32 instruction = instruction_0;
2937 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2938 int destreg = ((instruction >> 16) & 0x0000001F);
2939 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2941 address_word vaddr = ((unsigned64)op1 + offset);
2944 if ((vaddr & 3) != 0)
2945 SignalExceptionAddressStore();
2948 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2950 unsigned64 memval = 0;
2951 unsigned64 memval1 = 0;
2952 unsigned64 mask = 0x7;
2954 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2955 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2956 memval = (((unsigned64)COP_SW(((instruction >> 26) & 0x3),destreg)) << (8 * byte));
2958 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2966 101010,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWL
2967 "swl r<RT>, <OFFSET>(r<BASE>)"
2972 // start-sanitize-vr5400
2974 // end-sanitize-vr5400
2975 // start-sanitize-r5900
2977 // end-sanitize-r5900
2979 // start-sanitize-tx19
2981 // end-sanitize-tx19
2983 unsigned32 instruction = instruction_0;
2984 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2985 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2986 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2988 address_word vaddr = ((unsigned64)op1 + offset);
2992 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2994 unsigned64 memval = 0;
2995 unsigned64 memval1 = 0;
2996 unsigned64 mask = 3;
2997 unsigned int reverse = (ReverseEndian ? mask : 0);
2998 unsigned int bigend = (BigEndianCPU ? mask : 0);
3000 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
3001 byte = ((vaddr & mask) ^ bigend);
3004 memval = (op2 >> (8 * (3 - byte)));
3005 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
3008 StoreMemory(uncached,byte,memval,memval1,paddr,vaddr,isREAL);
3015 101110,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWR
3016 "swr r<RT>, <OFFSET>(r<BASE>)"
3021 // start-sanitize-vr5400
3023 // end-sanitize-vr5400
3024 // start-sanitize-r5900
3026 // end-sanitize-r5900
3028 // start-sanitize-tx19
3030 // end-sanitize-tx19
3032 unsigned32 instruction = instruction_0;
3033 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
3034 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
3035 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
3037 address_word vaddr = ((unsigned64)op1 + offset);
3041 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
3043 unsigned64 memval = 0;
3044 unsigned64 memval1 = 0;
3045 unsigned64 mask = 3;
3046 unsigned int reverse = (ReverseEndian ? mask : 0);
3047 unsigned int bigend = (BigEndianCPU ? mask : 0);
3049 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
3050 byte = ((vaddr & mask) ^ bigend);
3053 memval = ((unsigned64) op2 << (byte * 8));
3054 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
3057 StoreMemory(uncached,(AccessLength_WORD - byte),memval,memval1,paddr,vaddr,isREAL);
3064 000000000000000000000,5.STYPE,001111:SPECIAL:32::SYNC
3070 // start-sanitize-vr5400
3072 // end-sanitize-vr5400
3073 // start-sanitize-r5900
3075 // end-sanitize-r5900
3077 // start-sanitize-tx19
3079 // end-sanitize-tx19
3081 SyncOperation (STYPE);
3085 000000,20.CODE,001100:SPECIAL:32::SYSCALL
3091 // start-sanitize-vr5400
3093 // end-sanitize-vr5400
3094 // start-sanitize-r5900
3096 // end-sanitize-r5900
3098 // start-sanitize-tx19
3100 // end-sanitize-tx19
3102 SignalException(SystemCall, instruction_0);
3106 000000,5.RS,5.RT,10.CODE,110100:SPECIAL:32::TEQ
3111 // start-sanitize-vr5400
3113 // end-sanitize-vr5400
3114 // start-sanitize-r5900
3116 // end-sanitize-r5900
3118 // start-sanitize-tx19
3120 // end-sanitize-tx19
3122 if (GPR[RS] == GPR[RT])
3123 SignalException(Trap, instruction_0);
3127 000001,5.RS,01100,16.IMMEDIATE:REGIMM:32::TEQI
3128 "teqi r<RS>, <IMMEDIATE>"
3132 // start-sanitize-vr5400
3134 // end-sanitize-vr5400
3135 // start-sanitize-r5900
3137 // end-sanitize-r5900
3139 // start-sanitize-tx19
3141 // end-sanitize-tx19
3143 if (GPR[RS] == EXTEND16 (IMMEDIATE))
3144 SignalException(Trap, instruction_0);
3148 000000,5.RS,5.RT,10.CODE,110000:SPECIAL:32::TGE
3153 // start-sanitize-vr5400
3155 // end-sanitize-vr5400
3156 // start-sanitize-r5900
3158 // end-sanitize-r5900
3160 // start-sanitize-tx19
3162 // end-sanitize-tx19
3164 if (GPR[RS] >= GPR[RT])
3165 SignalException(Trap, instruction_0);
3169 000001,5.RS,01000,16.IMMEDIATE:REGIMM:32::TGEI
3170 "tgei r<RS>, <IMMEDIATE>"
3174 // start-sanitize-vr5400
3176 // end-sanitize-vr5400
3177 // start-sanitize-r5900
3179 // end-sanitize-r5900
3181 // start-sanitize-tx19
3183 // end-sanitize-tx19
3185 if (GPR[RS] >= EXTEND16 (IMMEDIATE))
3186 SignalException(Trap, instruction_0);
3190 000001,5.RS,01001,16.IMMEDIATE:REGIMM:32::TGEIU
3191 "tgeiu r<RS>, <IMMEDIATE>"
3195 // start-sanitize-vr5400
3197 // end-sanitize-vr5400
3198 // start-sanitize-r5900
3200 // end-sanitize-r5900
3202 // start-sanitize-tx19
3204 // end-sanitize-tx19
3206 if ((unsigned_word) GPR[RS] >= (unsigned_word) EXTEND16 (IMMEDIATE))
3207 SignalException(Trap, instruction_0);
3211 000000,5.RS,5.RT,10.CODE,110001:SPECIAL:32::TGEU
3216 // start-sanitize-vr5400
3218 // end-sanitize-vr5400
3219 // start-sanitize-r5900
3221 // end-sanitize-r5900
3223 // start-sanitize-tx19
3225 // end-sanitize-tx19
3227 if ((unsigned_word) GPR[RS] >= (unsigned_word) GPR[RT])
3228 SignalException(Trap, instruction_0);
3232 000000,5.RS,5.RT,10.CODE,110010:SPECIAL:32::TLT
3237 // start-sanitize-vr5400
3239 // end-sanitize-vr5400
3240 // start-sanitize-r5900
3242 // end-sanitize-r5900
3244 // start-sanitize-tx19
3246 // end-sanitize-tx19
3248 if (GPR[RS] < GPR[RT])
3249 SignalException(Trap, instruction_0);
3253 000001,5.RS,01010,16.IMMEDIATE:REGIMM:32::TLTI
3254 "tlti r<RS>, <IMMEDIATE>"
3258 // start-sanitize-vr5400
3260 // end-sanitize-vr5400
3261 // start-sanitize-r5900
3263 // end-sanitize-r5900
3265 // start-sanitize-tx19
3267 // end-sanitize-tx19
3269 if (GPR[RS] < EXTEND16 (IMMEDIATE))
3270 SignalException(Trap, instruction_0);
3274 000001,5.RS,01011,16.IMMEDIATE:REGIMM:32::TLTIU
3275 "tltiu r<RS>, <IMMEDIATE>"
3279 // start-sanitize-vr5400
3281 // end-sanitize-vr5400
3282 // start-sanitize-r5900
3284 // end-sanitize-r5900
3286 // start-sanitize-tx19
3288 // end-sanitize-tx19
3290 if ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE))
3291 SignalException(Trap, instruction_0);
3295 000000,5.RS,5.RT,10.CODE,110011:SPECIAL:32::TLTU
3300 // start-sanitize-vr5400
3302 // end-sanitize-vr5400
3303 // start-sanitize-r5900
3305 // end-sanitize-r5900
3307 // start-sanitize-tx19
3309 // end-sanitize-tx19
3311 if ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT])
3312 SignalException(Trap, instruction_0);
3316 000000,5.RS,5.RT,10.CODE,110110:SPECIAL:32::TNE
3321 // start-sanitize-vr5400
3323 // end-sanitize-vr5400
3324 // start-sanitize-r5900
3326 // end-sanitize-r5900
3328 // start-sanitize-tx19
3330 // end-sanitize-tx19
3332 if (GPR[RS] != GPR[RT])
3333 SignalException(Trap, instruction_0);
3337 000001,5.RS,01110,16.IMMEDIATE:REGIMM:32::TNEI
3338 "tne r<RS>, <IMMEDIATE>"
3342 // start-sanitize-vr5400
3344 // end-sanitize-vr5400
3345 // start-sanitize-r5900
3347 // end-sanitize-r5900
3349 // start-sanitize-tx19
3351 // end-sanitize-tx19
3353 if (GPR[RS] != EXTEND16 (IMMEDIATE))
3354 SignalException(Trap, instruction_0);
3358 000000,5.RS,5.RT,5.RD,00000100110:SPECIAL:32::XOR
3359 "xor r<RD>, r<RS>, r<RT>"
3364 // start-sanitize-vr5400
3366 // end-sanitize-vr5400
3367 // start-sanitize-r5900
3369 // end-sanitize-r5900
3371 // start-sanitize-tx19
3373 // end-sanitize-tx19
3375 GPR[RD] = GPR[RS] ^ GPR[RT];
3379 001110,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::XORI
3380 "xori r<RT>, r<RS>, <IMMEDIATE>"
3385 // start-sanitize-vr5400
3387 // end-sanitize-vr5400
3388 // start-sanitize-r5900
3390 // end-sanitize-r5900
3392 // start-sanitize-tx19
3394 // end-sanitize-tx19
3396 GPR[RT] = GPR[RS] ^ IMMEDIATE;
3401 // MIPS Architecture:
3403 // FPU Instruction Set (COP1 & COP1X)
3411 case fmt_single: return "s";
3412 case fmt_double: return "d";
3413 case fmt_word: return "w";
3414 case fmt_long: return "l";
3415 default: return "?";
3439 case 00: return "f";
3440 case 01: return "un";
3441 case 02: return "eq";
3442 case 03: return "ueq";
3443 case 04: return "olt";
3444 case 05: return "ult";
3445 case 06: return "ole";
3446 case 07: return "ule";
3447 case 010: return "sf";
3448 case 011: return "ngle";
3449 case 012: return "seq";
3450 case 013: return "ngl";
3451 case 014: return "lt";
3452 case 015: return "nge";
3453 case 016: return "le";
3454 case 017: return "ngt";
3455 default: return "?";
3460 010001,10,3.FMT,00000,5.FS,5.FD,000101:COP1:32,f::ABS.fmt
3461 "abs.%s<FMT> f<FD>, f<FS>"
3466 // start-sanitize-vr5400
3468 // end-sanitize-vr5400
3469 // start-sanitize-r5900
3471 // end-sanitize-r5900
3473 // start-sanitize-tx19
3475 // end-sanitize-tx19
3477 unsigned32 instruction = instruction_0;
3478 int destreg = ((instruction >> 6) & 0x0000001F);
3479 int fs = ((instruction >> 11) & 0x0000001F);
3480 int format = ((instruction >> 21) & 0x00000007);
3482 if ((format != fmt_single) && (format != fmt_double))
3483 SignalException(ReservedInstruction,instruction);
3485 StoreFPR(destreg,format,AbsoluteValue(ValueFPR(fs,format),format));
3492 010001,10,3.FMT,5.FT,5.FS,5.FD,000000:COP1:32,f::ADD
3493 "add.%s<FMT> f<FD>, f<FS>, f<FT>"
3498 // start-sanitize-vr5400
3500 // end-sanitize-vr5400
3501 // start-sanitize-r5900
3503 // end-sanitize-r5900
3505 // start-sanitize-tx19
3507 // end-sanitize-tx19
3509 unsigned32 instruction = instruction_0;
3510 int destreg = ((instruction >> 6) & 0x0000001F);
3511 int fs = ((instruction >> 11) & 0x0000001F);
3512 int ft = ((instruction >> 16) & 0x0000001F);
3513 int format = ((instruction >> 21) & 0x00000007);
3515 if ((format != fmt_single) && (format != fmt_double))
3516 SignalException(ReservedInstruction, instruction);
3518 StoreFPR(destreg,format,Add(ValueFPR(fs,format),ValueFPR(ft,format),format));
3524 // FIXME: This does not correctly resolve mipsI-mipsIV differences.
3530 010001,01000,3.CC,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1
3531 "bc1%s<TF>%s<ND> <OFFSET>":CC == 0
3532 "bc1%s<TF>%s<ND> <CC>, <OFFSET>"
3537 // start-sanitize-vr5400
3539 // end-sanitize-vr5400
3540 // start-sanitize-r5900
3542 // end-sanitize-r5900
3544 // start-sanitize-tx19
3546 // end-sanitize-tx19
3548 unsigned32 instruction = instruction_0;
3549 signed_word offset = SIGNEXTEND((signed_word)(((instruction >> 0) & 0x0000FFFF) << 2),18);
3550 int boolean = ((instruction >> 16) & 0x00000001);
3551 int likely = ((instruction >> 17) & 0x00000001);
3552 int condition_code = ((instruction >> 18) & 0x00000007);
3554 if (condition_code != 0)
3555 SignalException(ReservedInstruction,instruction);
3557 int condition = (PREVCOC1() == boolean);
3558 /* NOTE: The branch occurs AFTER the next instruction has been executed */
3560 DELAY_SLOT (PC + offset);
3563 NULLIFY_NEXT_INSTRUCTION ();
3571 // FIXME: This does not correctly differentiate between mips*
3573 010001,10,3.FMT,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32::C.cond.fmt
3574 "c.%s<COND>.%s<FMT> f<FS>, f<FT>":CC == 0
3575 "c.%s<COND>.%s<FMT> <CC>, f<FS>, f<FT>"
3580 // start-sanitize-vr5400
3582 // end-sanitize-vr5400
3583 // start-sanitize-r5900
3585 // end-sanitize-r5900
3587 // start-sanitize-tx19
3589 // end-sanitize-tx19
3591 unsigned32 instruction = instruction_0;
3592 int cmpflags = ((instruction >> 0) & 0x0000000F);
3593 int condition_code = ((instruction >> 8) & 0x00000007);
3594 int fs = ((instruction >> 11) & 0x0000001F);
3595 int ft = ((instruction >> 16) & 0x0000001F);
3596 int format = ((instruction >> 21) & 0x00000007);
3597 if (condition_code != 0)
3599 SignalException(ReservedInstruction,instruction);
3603 if ((format != fmt_single) && (format != fmt_double))
3604 SignalException(ReservedInstruction,instruction);
3606 if (condition_code != 0)
3607 SignalException(ReservedInstruction,instruction);
3614 unsigned64 ofs = ValueFPR(fs,format);
3615 unsigned64 oft = ValueFPR(ft,format);
3616 if (NaN(ofs,format) || NaN(oft,format)) {
3617 if (FCSR & FP_ENABLE(IO)) {
3618 FCSR |= FP_CAUSE(IO);
3619 SignalExceptionFPE();
3623 less = Less(ofs,oft,format);
3624 equal = Equal(ofs,oft,format);
3628 int condition = (((cmpflags & (1 << 2)) && less) || ((cmpflags & (1 << 1)) && equal) || ((cmpflags & (1 << 0)) && unordered));
3629 SETFCC(condition_code,condition);
3637 010001,10,3.FMT,00000,5.FS,5.FD,001010:COP1:64::CEIL.L.fmt
3638 "ceil.l.%s<FMT> f<FD>, f<FS>"
3641 // start-sanitize-vr5400
3643 // end-sanitize-vr5400
3644 // start-sanitize-r5900
3646 // end-sanitize-r5900
3648 // start-sanitize-tx19
3650 // end-sanitize-tx19
3652 unsigned32 instruction = instruction_0;
3653 int destreg = ((instruction >> 6) & 0x0000001F);
3654 int fs = ((instruction >> 11) & 0x0000001F);
3655 int format = ((instruction >> 21) & 0x00000007);
3657 if ((format != fmt_single) && (format != fmt_double))
3658 SignalException(ReservedInstruction,instruction);
3660 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_long));
3665 010001,10,3.FMT,00000,5.FS,5.FD,001110:COP1:32::CEIL.W
3669 // start-sanitize-vr5400
3671 // end-sanitize-vr5400
3672 // start-sanitize-r5900
3674 // end-sanitize-r5900
3676 // start-sanitize-tx19
3678 // end-sanitize-tx19
3680 unsigned32 instruction = instruction_0;
3681 int destreg = ((instruction >> 6) & 0x0000001F);
3682 int fs = ((instruction >> 11) & 0x0000001F);
3683 int format = ((instruction >> 21) & 0x00000007);
3685 if ((format != fmt_single) && (format != fmt_double))
3686 SignalException(ReservedInstruction,instruction);
3688 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_word));
3695 01000100,x,10,kkkkk,vvvvv,00000000000:COP1S:32::CxC1
3700 // start-sanitize-vr5400
3702 // end-sanitize-vr5400
3703 // start-sanitize-r5900
3705 // end-sanitize-r5900
3707 // start-sanitize-tx19
3709 // end-sanitize-tx19
3711 unsigned32 instruction = instruction_0;
3712 int fs = ((instruction >> 11) & 0x0000001F);
3713 int ft = ((instruction >> 16) & 0x0000001F);
3714 int to = ((instruction >> 23) & 0x00000001);
3718 PENDING_FILL((fs + FCR0IDX),VL4_8(GPR[ft]));
3719 } else if (fs == 31) {
3720 PENDING_FILL((fs + FCR31IDX),VL4_8(GPR[ft]));
3722 PENDING_FILL(COCIDX,0); /* special case */
3723 } else { /* control from */
3725 PENDING_FILL(ft,SIGNEXTEND(FCR0,32));
3726 } else if (fs == 31) {
3727 PENDING_FILL(ft,SIGNEXTEND(FCR31,32));
3735 // FIXME: Does not correctly differentiate between mips*
3737 010001,10,3.FMT,00000,5.FS,5.FD,100001:COP1:32::CVT.D.fmt
3738 "cvt.d.%s<FMT> f<FD>, f<FS>"
3743 // start-sanitize-vr5400
3745 // end-sanitize-vr5400
3746 // start-sanitize-r5900
3748 // end-sanitize-r5900
3750 // start-sanitize-tx19
3752 // end-sanitize-tx19
3754 unsigned32 instruction = instruction_0;
3755 int destreg = ((instruction >> 6) & 0x0000001F);
3756 int fs = ((instruction >> 11) & 0x0000001F);
3757 int format = ((instruction >> 21) & 0x00000007);
3759 if ((format == fmt_double) | 0)
3760 SignalException(ReservedInstruction,instruction);
3762 StoreFPR(destreg,fmt_double,Convert(GETRM(),ValueFPR(fs,format),format,fmt_double));
3767 010001,10,3.FMT,00000,5.FS,5.FD,100101:COP1:64::CVT.L.fmt
3768 "cvt.l.%s<FMT> f<FD>, f<FS>"
3771 // start-sanitize-vr5400
3773 // end-sanitize-vr5400
3774 // start-sanitize-r5900
3776 // end-sanitize-r5900
3778 // start-sanitize-tx19
3780 // end-sanitize-tx19
3782 unsigned32 instruction = instruction_0;
3783 int destreg = ((instruction >> 6) & 0x0000001F);
3784 int fs = ((instruction >> 11) & 0x0000001F);
3785 int format = ((instruction >> 21) & 0x00000007);
3787 if ((format == fmt_long) | ((format == fmt_long) || (format == fmt_word)))
3788 SignalException(ReservedInstruction,instruction);
3790 StoreFPR(destreg,fmt_long,Convert(GETRM(),ValueFPR(fs,format),format,fmt_long));
3796 // FIXME: Does not correctly differentiate between mips*
3798 010001,10,3.FMT,00000,5.FS,5.FD,100000:COP1:32::CVT.S.fmt
3799 "cvt.s.%s<FMT> f<FD>, f<FS>"
3804 // start-sanitize-vr5400
3806 // end-sanitize-vr5400
3807 // start-sanitize-r5900
3809 // end-sanitize-r5900
3811 // start-sanitize-tx19
3813 // end-sanitize-tx19
3815 unsigned32 instruction = instruction_0;
3816 int destreg = ((instruction >> 6) & 0x0000001F);
3817 int fs = ((instruction >> 11) & 0x0000001F);
3818 int format = ((instruction >> 21) & 0x00000007);
3820 if ((format == fmt_single) | 0)
3821 SignalException(ReservedInstruction,instruction);
3823 StoreFPR(destreg,fmt_single,Convert(GETRM(),ValueFPR(fs,format),format,fmt_single));
3828 010001,10,3.FMT,00000,5.FS,5.FD,100100:COP1:32::CVT.W.fmt
3829 "cvt.w.%s<FMT> f<FD>, f<FS>"
3834 // start-sanitize-vr5400
3836 // end-sanitize-vr5400
3837 // start-sanitize-r5900
3839 // end-sanitize-r5900
3841 // start-sanitize-tx19
3843 // end-sanitize-tx19
3845 unsigned32 instruction = instruction_0;
3846 int destreg = ((instruction >> 6) & 0x0000001F);
3847 int fs = ((instruction >> 11) & 0x0000001F);
3848 int format = ((instruction >> 21) & 0x00000007);
3850 if ((format == fmt_word) | ((format == fmt_long) || (format == fmt_word)))
3851 SignalException(ReservedInstruction,instruction);
3853 StoreFPR(destreg,fmt_word,Convert(GETRM(),ValueFPR(fs,format),format,fmt_word));
3858 010001,10,3.FMT,5.FT,5.FS,5.FD,000011:COP1:32::DIV.fmt
3859 "div.%s<FMT> f<FD>, f<FS>, f<FT>"
3864 // start-sanitize-vr5400
3866 // end-sanitize-vr5400
3867 // start-sanitize-r5900
3869 // end-sanitize-r5900
3871 // start-sanitize-tx19
3873 // end-sanitize-tx19
3875 unsigned32 instruction = instruction_0;
3876 int destreg = ((instruction >> 6) & 0x0000001F);
3877 int fs = ((instruction >> 11) & 0x0000001F);
3878 int ft = ((instruction >> 16) & 0x0000001F);
3879 int format = ((instruction >> 21) & 0x00000007);
3881 if ((format != fmt_single) && (format != fmt_double))
3882 SignalException(ReservedInstruction,instruction);
3884 StoreFPR(destreg,format,Divide(ValueFPR(fs,format),ValueFPR(ft,format),format));
3891 01000100,x,01,5.FT,vvvvv,00000000000:COP1S:64::DMxC1
3894 // start-sanitize-vr5400
3896 // end-sanitize-vr5400
3897 // start-sanitize-r5900
3899 // end-sanitize-r5900
3901 // start-sanitize-tx19
3903 // end-sanitize-tx19
3905 unsigned32 instruction = instruction_0;
3906 int fs = ((instruction >> 11) & 0x0000001F);
3907 int ft = ((instruction >> 16) & 0x0000001F);
3908 int to = ((instruction >> 23) & 0x00000001);
3911 if (SizeFGR() == 64) {
3912 PENDING_FILL((fs + FGRIDX),GPR[ft]);
3914 if ((fs & 0x1) == 0)
3916 PENDING_FILL(((fs + 1) + FGRIDX),VH4_8(GPR[ft]));
3917 PENDING_FILL((fs + FGRIDX),VL4_8(GPR[ft]));
3920 if (SizeFGR() == 64) {
3921 PENDING_FILL(ft,FGR[fs]);
3923 if ((fs & 0x1) == 0) {
3924 PENDING_FILL(ft,(SET64HI(FGR[fs+1]) | FGR[fs]));
3926 PENDING_FILL(ft,SET64HI(0xDEADC0DE) | 0xBAD0BAD0);
3933 010001,10,3.FMT,00000,5.FS,5.FD,001011:COP1:64::FLOOR.L.fmt
3934 "floor.l.%s<FMT> f<FD>, f<FS>"
3937 // start-sanitize-vr5400
3939 // end-sanitize-vr5400
3940 // start-sanitize-r5900
3942 // end-sanitize-r5900
3944 // start-sanitize-tx19
3946 // end-sanitize-tx19
3948 unsigned32 instruction = instruction_0;
3949 int destreg = ((instruction >> 6) & 0x0000001F);
3950 int fs = ((instruction >> 11) & 0x0000001F);
3951 int format = ((instruction >> 21) & 0x00000007);
3953 if ((format != fmt_single) && (format != fmt_double))
3954 SignalException(ReservedInstruction,instruction);
3956 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_long));
3961 010001,10,3.FMT,00000,5.FS,5.FD,001111:COP1:32::FLOOR.W.fmt
3962 "floor.w.%s<FMT> f<FD>, f<FS>"
3966 // start-sanitize-vr5400
3968 // end-sanitize-vr5400
3969 // start-sanitize-r5900
3971 // end-sanitize-r5900
3973 // start-sanitize-tx19
3975 // end-sanitize-tx19
3977 unsigned32 instruction = instruction_0;
3978 int destreg = ((instruction >> 6) & 0x0000001F);
3979 int fs = ((instruction >> 11) & 0x0000001F);
3980 int format = ((instruction >> 21) & 0x00000007);
3982 if ((format != fmt_single) && (format != fmt_double))
3983 SignalException(ReservedInstruction,instruction);
3985 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_word));
3991 110101,5.BASE,5.FT,16.OFFSET:COP1:32::LDC1
3994 010011,5.BASE,5.INDEX,5.0,5.FD,000001:COP1X:64::LDXC1
3995 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
3997 // start-sanitize-vr5400
3999 // end-sanitize-vr5400
4000 // start-sanitize-r5900
4002 // end-sanitize-r5900
4004 unsigned32 instruction = instruction_0;
4005 int destreg = ((instruction >> 6) & 0x0000001F);
4006 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4007 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4009 address_word vaddr = ((unsigned64)op1 + op2);
4012 if ((vaddr & 7) != 0)
4013 SignalExceptionAddressLoad();
4016 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4018 unsigned64 memval = 0;
4019 unsigned64 memval1 = 0;
4020 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
4021 COP_LD(1,destreg,memval);;
4029 110001,5.BASE,5.FT,16.OFFSET:COP1:32::LWC1
4032 010011,5.BASE,5.INDEX,5.0,5.FD,000000:COP1X:32::LWXC1
4033 "lwxc1 f<FD>, r<INDEX>(r<BASE>)"
4035 // start-sanitize-vr5400
4037 // end-sanitize-vr5400
4038 // start-sanitize-r5900
4040 // end-sanitize-r5900
4042 unsigned32 instruction = instruction_0;
4043 int destreg = ((instruction >> 6) & 0x0000001F);
4044 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4045 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4047 address_word vaddr = ((unsigned64)op1 + op2);
4050 if ((vaddr & 3) != 0)
4051 SignalExceptionAddressLoad();
4054 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4056 unsigned64 memval = 0;
4057 unsigned64 memval1 = 0;
4058 unsigned64 mask = 0x7;
4059 unsigned int shift = 2;
4060 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4061 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4063 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4064 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
4065 byte = ((vaddr & mask) ^ (bigend << shift));
4066 COP_LW(1,destreg,(unsigned int)((memval >> (8 * byte)) & 0xFFFFFFFF));
4075 // FIXME: Not correct for mips*
4077 010011,5.FR,5.FT,5.FS,5.FD,100,001:COP1X:32::MADD.D
4078 "madd.d f<FD>, f<FR>, f<FS>, f<FT>"
4080 // start-sanitize-vr5400
4082 // end-sanitize-vr5400
4083 // start-sanitize-r5900
4085 // end-sanitize-r5900
4087 unsigned32 instruction = instruction_0;
4088 int destreg = ((instruction >> 6) & 0x0000001F);
4089 int fs = ((instruction >> 11) & 0x0000001F);
4090 int ft = ((instruction >> 16) & 0x0000001F);
4091 int fr = ((instruction >> 21) & 0x0000001F);
4093 StoreFPR(destreg,fmt_double,Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
4098 010011,5.FR,5.FT,5.FS,5.FD,100,000:COP1X:32::MADD.S
4099 "madd.s f<FD>, f<FR>, f<FS>, f<FT>"
4101 // start-sanitize-vr5400
4103 // end-sanitize-vr5400
4104 // start-sanitize-r5900
4106 // end-sanitize-r5900
4108 unsigned32 instruction = instruction_0;
4109 int destreg = ((instruction >> 6) & 0x0000001F);
4110 int fs = ((instruction >> 11) & 0x0000001F);
4111 int ft = ((instruction >> 16) & 0x0000001F);
4112 int fr = ((instruction >> 21) & 0x0000001F);
4114 StoreFPR(destreg,fmt_single,Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
4120 010001,00,X,00,5.RT,5.FS,00000000000:COP1S:32::MxC1
4121 "m<X>c1 r<RT>, f<FS>"
4126 // start-sanitize-vr5400
4128 // end-sanitize-vr5400
4129 // start-sanitize-r5900
4131 // end-sanitize-r5900
4133 // start-sanitize-tx19
4135 // end-sanitize-tx19
4137 unsigned32 instruction = instruction_0;
4138 int fs = ((instruction >> 11) & 0x0000001F);
4139 int ft = ((instruction >> 16) & 0x0000001F);
4140 int to = ((instruction >> 23) & 0x00000001);
4143 if (SizeFGR() == 64) {
4144 PENDING_FILL ((fs + FGRIDX), (SET64HI(0xDEADC0DE) | VL4_8(GPR[ft])));
4146 PENDING_FILL ((fs + FGRIDX), VL4_8(GPR[ft]));
4149 PENDING_FILL (ft, SIGNEXTEND(FGR[fs],32));
4155 010001,10,3.FMT,00000,5.FS,5.FD,000110:COP1:32::MOV.fmt
4156 "mov.%s<FMT> f<FD>, f<FS>"
4161 // start-sanitize-vr5400
4163 // end-sanitize-vr5400
4164 // start-sanitize-r5900
4166 // end-sanitize-r5900
4168 // start-sanitize-tx19
4170 // end-sanitize-tx19
4172 unsigned32 instruction = instruction_0;
4173 int destreg = ((instruction >> 6) & 0x0000001F);
4174 int fs = ((instruction >> 11) & 0x0000001F);
4175 int format = ((instruction >> 21) & 0x00000007);
4177 StoreFPR(destreg,format,ValueFPR(fs,format));
4183 000000,5.RS,3.CC,0,1.TF,5.RD,00000000001:SPECIAL:32::MOVtf
4184 "mov%s<TF> r<RD>, r<RS>, <CC>"
4186 // start-sanitize-vr5400
4188 // end-sanitize-vr5400
4189 // start-sanitize-r5900
4191 // end-sanitize-r5900
4193 if (GETFCC(CC) == TF)
4199 010001,10,3.FMT,3.CC,0,1.TF,5.FS,5.FD,010001:COP1:32::MOVtf.fmt
4200 "mov%s<TF>.%s<FMT> f<FD>, f<FS>, <CC>"
4202 // start-sanitize-vr5400
4204 // end-sanitize-vr5400
4205 // start-sanitize-r5900
4207 // end-sanitize-r5900
4209 unsigned32 instruction = instruction_0;
4210 int format = ((instruction >> 21) & 0x00000007);
4212 if (GETFCC(CC) == TF)
4213 StoreFPR (FD, format, ValueFPR (FS, format));
4215 StoreFPR (FD, format, ValueFPR (FD, format));
4220 010001,10,3.FMT,5.RT,5.FS,5.FD,010011:COP1:32::MOVN.fmt
4222 // start-sanitize-vr5400
4224 // end-sanitize-vr5400
4225 // start-sanitize-r5900
4227 // end-sanitize-r5900
4229 unsigned32 instruction = instruction_0;
4230 int destreg = ((instruction >> 6) & 0x0000001F);
4231 int fs = ((instruction >> 11) & 0x0000001F);
4232 int format = ((instruction >> 21) & 0x00000007);
4234 StoreFPR(destreg,format,ValueFPR(fs,format));
4242 // MOVT.fmt see MOVtf.fmt
4246 010001,10,3.FMT,5.RT,5.FS,5.FD,010010:COP1:32::MOVZ.fmt
4247 "movz.%s<FMT> f<FD>, f<FS>, r<RT>"
4249 // start-sanitize-vr5400
4251 // end-sanitize-vr5400
4252 // start-sanitize-r5900
4254 // end-sanitize-r5900
4256 unsigned32 instruction = instruction_0;
4257 int destreg = ((instruction >> 6) & 0x0000001F);
4258 int fs = ((instruction >> 11) & 0x0000001F);
4259 int format = ((instruction >> 21) & 0x00000007);
4261 StoreFPR(destreg,format,ValueFPR(fs,format));
4267 010011,5.FR,5.FT,5.FS,5.FD,101,001:COP1X:32::MSUB.D
4268 "msub.d f<FD>, f<FR>, f<FS>, f<FT>"
4270 // start-sanitize-vr5400
4272 // end-sanitize-vr5400
4273 // start-sanitize-r5900
4275 // end-sanitize-r5900
4277 unsigned32 instruction = instruction_0;
4278 int destreg = ((instruction >> 6) & 0x0000001F);
4279 int fs = ((instruction >> 11) & 0x0000001F);
4280 int ft = ((instruction >> 16) & 0x0000001F);
4281 int fr = ((instruction >> 21) & 0x0000001F);
4283 StoreFPR(destreg,fmt_double,(Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double),fmt_double));
4289 010011,5.FR,5.FT,5.FS,5.FD,101000:COP1X:32::MSUB.S
4290 "msub.s f<FD>, f<FR>, f<FS>, f<FT>"
4292 // start-sanitize-vr5400
4294 // end-sanitize-vr5400
4295 // start-sanitize-r5900
4297 // end-sanitize-r5900
4299 unsigned32 instruction = instruction_0;
4300 int destreg = ((instruction >> 6) & 0x0000001F);
4301 int fs = ((instruction >> 11) & 0x0000001F);
4302 int ft = ((instruction >> 16) & 0x0000001F);
4303 int fr = ((instruction >> 21) & 0x0000001F);
4305 StoreFPR(destreg,fmt_single,(Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single),fmt_single));
4313 010001,10,3.FMT,5.FT,5.FS,5.FD,000010:COP1:32::MUL.fmt
4314 "mul.%s<FMT> f<FD>, f<FS>, f<FT>"
4319 // start-sanitize-vr5400
4321 // end-sanitize-vr5400
4322 // start-sanitize-r5900
4324 // end-sanitize-r5900
4326 // start-sanitize-tx19
4328 // end-sanitize-tx19
4330 unsigned32 instruction = instruction_0;
4331 int destreg = ((instruction >> 6) & 0x0000001F);
4332 int fs = ((instruction >> 11) & 0x0000001F);
4333 int ft = ((instruction >> 16) & 0x0000001F);
4334 int format = ((instruction >> 21) & 0x00000007);
4336 if ((format != fmt_single) && (format != fmt_double))
4337 SignalException(ReservedInstruction,instruction);
4339 StoreFPR(destreg,format,Multiply(ValueFPR(fs,format),ValueFPR(ft,format),format));
4344 010001,10,3.FMT,00000,5.FS,5.FD,000111:COP1:32::NEG.fmt
4345 "neg.%s<FMT> f<FD>, f<FS>"
4350 // start-sanitize-vr5400
4352 // end-sanitize-vr5400
4353 // start-sanitize-r5900
4355 // end-sanitize-r5900
4357 // start-sanitize-tx19
4359 // end-sanitize-tx19
4361 unsigned32 instruction = instruction_0;
4362 int destreg = ((instruction >> 6) & 0x0000001F);
4363 int fs = ((instruction >> 11) & 0x0000001F);
4364 int format = ((instruction >> 21) & 0x00000007);
4366 if ((format != fmt_single) && (format != fmt_double))
4367 SignalException(ReservedInstruction,instruction);
4369 StoreFPR(destreg,format,Negate(ValueFPR(fs,format),format));
4375 010011,5.FR,5.FT,5.FS,5.FD,110001:COP1X:32::NMADD.D
4376 "nmadd.d f<FD>, f<FR>, f<FS>, f<FT>"
4378 // start-sanitize-vr5400
4380 // end-sanitize-vr5400
4382 unsigned32 instruction = instruction_0;
4383 int destreg = ((instruction >> 6) & 0x0000001F);
4384 int fs = ((instruction >> 11) & 0x0000001F);
4385 int ft = ((instruction >> 16) & 0x0000001F);
4386 int fr = ((instruction >> 21) & 0x0000001F);
4388 StoreFPR(destreg,fmt_double,Negate(Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double),fmt_double));
4394 010011,5.FR,5.FT,5.FS,5.FD,110000:COP1X:32::NMADD.S
4395 "nmadd.s f<FD>, f<FR>, f<FS>, f<FT>"
4397 // start-sanitize-vr5400
4399 // end-sanitize-vr5400
4401 unsigned32 instruction = instruction_0;
4402 int destreg = ((instruction >> 6) & 0x0000001F);
4403 int fs = ((instruction >> 11) & 0x0000001F);
4404 int ft = ((instruction >> 16) & 0x0000001F);
4405 int fr = ((instruction >> 21) & 0x0000001F);
4407 StoreFPR(destreg,fmt_single,Negate(Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single),fmt_single));
4413 010011,5.FR,5.FT,5.FS,5.FD,111001:COP1X:32::NMSUB.D
4414 "nmsub.d f<FD>, f<FR>, f<FS>, f<FT>"
4416 // start-sanitize-vr5400
4418 // end-sanitize-vr5400
4420 unsigned32 instruction = instruction_0;
4421 int destreg = ((instruction >> 6) & 0x0000001F);
4422 int fs = ((instruction >> 11) & 0x0000001F);
4423 int ft = ((instruction >> 16) & 0x0000001F);
4424 int fr = ((instruction >> 21) & 0x0000001F);
4426 StoreFPR(destreg,fmt_double,Negate(Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double),fmt_double));
4432 010011,5.FR,5.FT,5.FS,5.FD,111000:COP1X:32::NMSUB.S
4433 "nmsub.s f<FD>, f<FR>, f<FS>, f<FT>"
4435 // start-sanitize-vr5400
4437 // end-sanitize-vr5400
4439 unsigned32 instruction = instruction_0;
4440 int destreg = ((instruction >> 6) & 0x0000001F);
4441 int fs = ((instruction >> 11) & 0x0000001F);
4442 int ft = ((instruction >> 16) & 0x0000001F);
4443 int fr = ((instruction >> 21) & 0x0000001F);
4445 StoreFPR(destreg,fmt_single,Negate(Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single),fmt_single));
4450 010011,5.BASE,5.INDEX,5.HINT,00000001111:COP1X:32::PREFX
4451 "prefx <HINT>, r<INDEX>(r<BASE>)"
4453 // start-sanitize-vr5400
4455 // end-sanitize-vr5400
4457 unsigned32 instruction = instruction_0;
4458 int fs = ((instruction >> 11) & 0x0000001F);
4459 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4460 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4462 address_word vaddr = ((unsigned64)op1 + (unsigned64)op2);
4465 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4466 Prefetch(uncached,paddr,vaddr,isDATA,fs);
4470 010001,10,3.FMT,00000,5.FS,5.FD,010101:COP1:32::RECIP.fmt
4472 "recip.%s<FMT> f<FD>, f<FS>"
4473 // start-sanitize-vr5400
4475 // end-sanitize-vr5400
4477 unsigned32 instruction = instruction_0;
4478 int destreg = ((instruction >> 6) & 0x0000001F);
4479 int fs = ((instruction >> 11) & 0x0000001F);
4480 int format = ((instruction >> 21) & 0x00000007);
4482 if ((format != fmt_single) && (format != fmt_double))
4483 SignalException(ReservedInstruction,instruction);
4485 StoreFPR(destreg,format,Recip(ValueFPR(fs,format),format));
4490 010001,10,3.FMT,00000,5.FS,5.FD,001000:COP1:64::ROUND.L.fmt
4491 "round.l.%s<FMT> f<FD>, f<FS>"
4494 // start-sanitize-vr5400
4496 // end-sanitize-vr5400
4497 // start-sanitize-r5900
4499 // end-sanitize-r5900
4501 // start-sanitize-tx19
4503 // end-sanitize-tx19
4505 unsigned32 instruction = instruction_0;
4506 int destreg = ((instruction >> 6) & 0x0000001F);
4507 int fs = ((instruction >> 11) & 0x0000001F);
4508 int format = ((instruction >> 21) & 0x00000007);
4510 if ((format != fmt_single) && (format != fmt_double))
4511 SignalException(ReservedInstruction,instruction);
4513 StoreFPR(destreg,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_long));
4518 010001,10,3.FMT,00000,5.FS,5.FD,001100:COP1:32::ROUND.W.fmt
4519 "round.w.%s<FMT> f<FD>, f<FS>"
4523 // start-sanitize-vr5400
4525 // end-sanitize-vr5400
4526 // start-sanitize-r5900
4528 // end-sanitize-r5900
4530 // start-sanitize-tx19
4532 // end-sanitize-tx19
4534 unsigned32 instruction = instruction_0;
4535 int destreg = ((instruction >> 6) & 0x0000001F);
4536 int fs = ((instruction >> 11) & 0x0000001F);
4537 int format = ((instruction >> 21) & 0x00000007);
4539 if ((format != fmt_single) && (format != fmt_double))
4540 SignalException(ReservedInstruction,instruction);
4542 StoreFPR(destreg,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_word));
4547 010001,10,3.FMT,00000,5.FS,5.FD,010110:COP1:32::RSQRT.fmt
4549 "rsqrt.%s<FMT> f<FD>, f<FS>"
4550 // start-sanitize-vr5400
4552 // end-sanitize-vr5400
4554 unsigned32 instruction = instruction_0;
4555 int destreg = ((instruction >> 6) & 0x0000001F);
4556 int fs = ((instruction >> 11) & 0x0000001F);
4557 int format = ((instruction >> 21) & 0x00000007);
4559 if ((format != fmt_single) && (format != fmt_double))
4560 SignalException(ReservedInstruction,instruction);
4562 StoreFPR(destreg,format,Recip(SquareRoot(ValueFPR(fs,format),format),format));
4570 010011,5.RS,5.RT,vvvvv,00000001001:COP1X:64::SDXC1
4572 // start-sanitize-vr5400
4574 // end-sanitize-vr5400
4575 // start-sanitize-r5900
4577 // end-sanitize-r5900
4579 unsigned32 instruction = instruction_0;
4580 int fs = ((instruction >> 11) & 0x0000001F);
4581 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4582 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4584 address_word vaddr = ((unsigned64)op1 + op2);
4587 if ((vaddr & 7) != 0)
4588 SignalExceptionAddressStore();
4591 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
4593 unsigned64 memval = 0;
4594 unsigned64 memval1 = 0;
4595 memval = (unsigned64)COP_SD(1,fs);
4597 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
4605 010001,10,3.FMT,00000,5.FS,5.FD,000100:COP1:32::SQRT.fmt
4606 "sqrt.%s<FMT> f<FD>, f<FS>"
4610 // start-sanitize-vr5400
4612 // end-sanitize-vr5400
4613 // start-sanitize-r5900
4615 // end-sanitize-r5900
4617 // start-sanitize-tx19
4619 // end-sanitize-tx19
4621 unsigned32 instruction = instruction_0;
4622 int destreg = ((instruction >> 6) & 0x0000001F);
4623 int fs = ((instruction >> 11) & 0x0000001F);
4624 int format = ((instruction >> 21) & 0x00000007);
4626 if ((format != fmt_single) && (format != fmt_double))
4627 SignalException(ReservedInstruction,instruction);
4629 StoreFPR(destreg,format,(SquareRoot(ValueFPR(fs,format),format)));
4634 010001,10,3.FMT,5.FT,5.FS,5.FD,000001:COP1:32::SUB.fmt
4635 "sub.%s<FMT> f<FD>, f<FS>, f<FT>"
4640 // start-sanitize-vr5400
4642 // end-sanitize-vr5400
4643 // start-sanitize-r5900
4645 // end-sanitize-r5900
4647 // start-sanitize-tx19
4649 // end-sanitize-tx19
4651 unsigned32 instruction = instruction_0;
4652 int destreg = ((instruction >> 6) & 0x0000001F);
4653 int fs = ((instruction >> 11) & 0x0000001F);
4654 int ft = ((instruction >> 16) & 0x0000001F);
4655 int format = ((instruction >> 21) & 0x00000007);
4657 if ((format != fmt_single) && (format != fmt_double))
4658 SignalException(ReservedInstruction,instruction);
4660 StoreFPR(destreg,format,Sub(ValueFPR(fs,format),ValueFPR(ft,format),format));
4668 010011,5.BASE,5.INDEX,5.FS,00000,001000:COP1X:32::SWXC1
4669 "swxc1 f<FS>, r<INDEX>(r<BASE>)"
4671 // start-sanitize-vr5400
4673 // end-sanitize-vr5400
4674 // start-sanitize-r5900
4676 // end-sanitize-r5900
4678 unsigned32 instruction = instruction_0;
4679 int fs = ((instruction >> 11) & 0x0000001F);
4680 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4681 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4683 address_word vaddr = ((unsigned64)op1 + op2);
4686 if ((vaddr & 3) != 0)
4687 SignalExceptionAddressStore();
4690 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
4692 unsigned64 memval = 0;
4693 unsigned64 memval1 = 0;
4694 unsigned64 mask = 0x7;
4696 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
4697 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
4698 memval = (((unsigned64)COP_SW(1,fs)) << (8 * byte));
4700 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
4708 010001,10,3.FMT,00000,5.FS,5.FD,001001:COP1:64::TRUNC.L.fmt
4709 "trunc.l.%s<FMT> f<FD>, f<FS>"
4712 // start-sanitize-vr5400
4714 // end-sanitize-vr5400
4715 // start-sanitize-r5900
4717 // end-sanitize-r5900
4719 // start-sanitize-tx19
4721 // end-sanitize-tx19
4723 unsigned32 instruction = instruction_0;
4724 int destreg = ((instruction >> 6) & 0x0000001F);
4725 int fs = ((instruction >> 11) & 0x0000001F);
4726 int format = ((instruction >> 21) & 0x00000007);
4728 if ((format != fmt_single) && (format != fmt_double))
4729 SignalException(ReservedInstruction,instruction);
4731 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_long));
4736 010001,10,3.FMT,00000,5.FS,5.FD,001101:COP1:32::TRUNC.W
4737 "trunc.w.%s<FMT> f<FD>, f<FS>"
4741 // start-sanitize-vr5400
4743 // end-sanitize-vr5400
4744 // start-sanitize-r5900
4746 // end-sanitize-r5900
4748 // start-sanitize-tx19
4750 // end-sanitize-tx19
4752 unsigned32 instruction = instruction_0;
4753 int destreg = ((instruction >> 6) & 0x0000001F);
4754 int fs = ((instruction >> 11) & 0x0000001F);
4755 int format = ((instruction >> 21) & 0x00000007);
4757 if ((format != fmt_single) && (format != fmt_double))
4758 SignalException(ReservedInstruction,instruction);
4760 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_word));
4766 // MIPS Architecture:
4768 // System Control Instruction Set (COP0)
4772 010000,01000,00000,16.OFFSET:COP0:32::BC0F
4778 // start-sanitize-vr5400
4780 // end-sanitize-vr5400
4781 // start-sanitize-r5900
4783 // end-sanitize-r5900
4786 010000,01000,00010,16.OFFSET:COP0:32::BC0FL
4792 // start-sanitize-vr5400
4794 // end-sanitize-vr5400
4795 // start-sanitize-r5900
4797 // end-sanitize-r5900
4800 010000,01000,00001,16.OFFSET:COP0:32::BC0T
4806 // start-sanitize-r5900
4808 // end-sanitize-r5900
4812 010000,01000,00011,16.OFFSET:COP0:32::BC0TL
4818 // start-sanitize-vr5400
4820 // end-sanitize-vr5400
4821 // start-sanitize-r5900
4823 // end-sanitize-r5900
4826 101111,5.BASE,5.OP,16.OFFSET:NORMAL:32::CACHE
4829 // start-sanitize-vr5400
4831 // end-sanitize-vr5400
4832 // start-sanitize-r5900
4834 // end-sanitize-r5900
4836 // start-sanitize-tx19
4838 // end-sanitize-tx19
4840 unsigned32 instruction = instruction_0;
4841 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
4842 int hint = ((instruction >> 16) & 0x0000001F);
4843 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4845 address_word vaddr = (op1 + offset);
4848 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4849 CacheOp(hint,vaddr,paddr,instruction);
4854 010000,10000,000000000000000,111001:COP0:32::DI
4860 // start-sanitize-vr5400
4862 // end-sanitize-vr5400
4863 // start-sanitize-r5900
4865 // end-sanitize-r5900
4868 010000,10000,000000000000000,111000:COP0:32::EI
4874 // start-sanitize-vr5400
4876 // end-sanitize-vr5400
4877 // start-sanitize-r5900
4879 // end-sanitize-r5900
4882 010000,10000,000000000000000,011000:COP0:32::ERET
4886 // start-sanitize-vr5400
4888 // end-sanitize-vr5400
4889 // start-sanitize-r5900
4891 // end-sanitize-r5900
4894 010000,00000,5.RT,5.RD,00000,6.REGX:COP0:32::MFC0
4895 "mfc0 r<RT>, r<RD> # <REGX>"
4900 // start-sanitize-vr5400
4902 // end-sanitize-vr5400
4903 // start-sanitize-r5900
4905 // end-sanitize-r5900
4908 010000,00100,5.RT,5.RD,00000,6.REGX:COP0:32::MTC0
4909 "mtc0 r<RT>, r<RD> # <REGX>"
4914 // start-sanitize-vr5400
4916 // end-sanitize-vr5400
4917 // start-sanitize-r5900
4919 // end-sanitize-r5900
4922 010000,10000,000000000000000,001000:COP0:32::TLBP
4928 // start-sanitize-vr5400
4930 // end-sanitize-vr5400
4931 // start-sanitize-r5900
4933 // end-sanitize-r5900
4936 010000,10000,000000000000000,000001:COP0:32::TLBR
4942 // start-sanitize-vr5400
4944 // end-sanitize-vr5400
4945 // start-sanitize-r5900
4947 // end-sanitize-r5900
4950 010000,10000,000000000000000,000010:COP0:32::TLBWI
4956 // start-sanitize-vr5400
4958 // end-sanitize-vr5400
4959 // start-sanitize-r5900
4961 // end-sanitize-r5900
4964 010000,10000,000000000000000,000110:COP0:32::TLBWR
4970 // start-sanitize-vr5400
4972 // end-sanitize-vr5400
4973 // start-sanitize-r5900
4975 // end-sanitize-r5900
4979 // MIPS Architecture:
4981 // CPU Instruction Set (mips16)
4984 // The instructions in this section are ordered according
4985 // to http://www.sgi.com/MIPS/arch/MIPS16/mips16.pdf.
4988 // FIXME: Instead of having the code for mips16 instructions here.
4989 // these instructions should instead call the corresponding 32bit
4990 // instruction (or a function implementing that instructions code).
4993 // Load and Store Instructions
4996 10000,xxx,ddd,55555:RRI:16::LB
4999 unsigned32 instruction = instruction_0;
5000 signed_word op1 = (instruction >> 8) & 0x7;
5001 int destreg = (instruction >> 5) & 0x7;
5002 int offset = (instruction >> 0) & 0x1f;
5010 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5011 if (offset >= 0x8000)
5019 SignalException (ReservedInstruction, instruction);
5021 address_word vaddr = ((unsigned64)op1 + offset);
5025 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5027 unsigned64 memval = 0;
5028 unsigned64 memval1 = 0;
5029 unsigned64 mask = 0x7;
5030 unsigned int shift = 0;
5031 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5032 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5034 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5035 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
5036 byte = ((vaddr & mask) ^ (bigend << shift));
5037 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x000000FF),8));
5044 10100,xxx,ddd,55555:RRI:16::LBU
5047 unsigned32 instruction = instruction_0;
5048 signed_word op1 = (instruction >> 8) & 0x7;
5049 int destreg = (instruction >> 5) & 0x7;
5050 int offset = (instruction >> 0) & 0x1f;
5058 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5059 if (offset >= 0x8000)
5067 SignalException (ReservedInstruction, instruction);
5069 address_word vaddr = ((unsigned64)op1 + offset);
5073 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5075 unsigned64 memval = 0;
5076 unsigned64 memval1 = 0;
5077 unsigned64 mask = 0x7;
5078 unsigned int shift = 0;
5079 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5080 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5082 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5083 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
5084 byte = ((vaddr & mask) ^ (bigend << shift));
5085 GPR[destreg] = (((memval >> (8 * byte)) & 0x000000FF));
5092 10001,xxx,ddd,HHHHH:RRI:16::LH
5095 unsigned32 instruction = instruction_0;
5096 signed_word op1 = (instruction >> 8) & 0x7;
5097 int destreg = (instruction >> 5) & 0x7;
5098 int offset = (instruction >> 0) & 0x1f;
5106 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5107 if (offset >= 0x8000)
5116 SignalException (ReservedInstruction, instruction);
5118 address_word vaddr = ((unsigned64)op1 + offset);
5121 if ((vaddr & 1) != 0)
5122 SignalExceptionAddressLoad();
5125 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5127 unsigned64 memval = 0;
5128 unsigned64 memval1 = 0;
5129 unsigned64 mask = 0x7;
5130 unsigned int shift = 1;
5131 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5132 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5134 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5135 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
5136 byte = ((vaddr & mask) ^ (bigend << shift));
5137 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x0000FFFF),16));
5144 10101,xxx,ddd,HHHHH:RRI:16::LHU
5147 unsigned32 instruction = instruction_0;
5148 signed_word op1 = (instruction >> 8) & 0x7;
5149 int destreg = (instruction >> 5) & 0x7;
5150 int offset = (instruction >> 0) & 0x1f;
5158 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5159 if (offset >= 0x8000)
5168 SignalException (ReservedInstruction, instruction);
5170 address_word vaddr = ((unsigned64)op1 + offset);
5173 if ((vaddr & 1) != 0)
5174 SignalExceptionAddressLoad();
5177 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5179 unsigned64 memval = 0;
5180 unsigned64 memval1 = 0;
5181 unsigned64 mask = 0x7;
5182 unsigned int shift = 1;
5183 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5184 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5186 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5187 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
5188 byte = ((vaddr & mask) ^ (bigend << shift));
5189 GPR[destreg] = (((memval >> (8 * byte)) & 0x0000FFFF));
5196 10011,xxx,ddd,WWWWW:RRI:16::LW
5199 unsigned32 instruction = instruction_0;
5200 signed_word op1 = (instruction >> 8) & 0x7;
5201 int destreg = (instruction >> 5) & 0x7;
5202 int offset = (instruction >> 0) & 0x1f;
5210 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5211 if (offset >= 0x8000)
5220 SignalException (ReservedInstruction, instruction);
5222 address_word vaddr = ((unsigned64)op1 + offset);
5225 if ((vaddr & 3) != 0)
5226 SignalExceptionAddressLoad();
5229 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5231 unsigned64 memval = 0;
5232 unsigned64 memval1 = 0;
5233 unsigned64 mask = 0x7;
5234 unsigned int shift = 2;
5235 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5236 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5238 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5239 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
5240 byte = ((vaddr & mask) ^ (bigend << shift));
5241 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
5248 10110,ddd,VVVVVVVV,P:RI:16::LWPC
5251 unsigned32 instruction = instruction_0;
5252 int destreg = (instruction >> 8) & 0x7;
5253 int offset = (instruction >> 0) & 0xff;
5254 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
5259 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5260 if (offset >= 0x8000)
5269 SignalException (ReservedInstruction, instruction);
5271 address_word vaddr = ((unsigned64)op1 + offset);
5274 if ((vaddr & 3) != 0)
5275 SignalExceptionAddressLoad();
5278 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5280 unsigned64 memval = 0;
5281 unsigned64 memval1 = 0;
5282 unsigned64 mask = 0x7;
5283 unsigned int shift = 2;
5284 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5285 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5287 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5288 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
5289 byte = ((vaddr & mask) ^ (bigend << shift));
5290 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
5297 10010,ddd,VVVVVVVV,s:RI:16::LWSP
5300 unsigned32 instruction = instruction_0;
5301 int destreg = (instruction >> 8) & 0x7;
5302 int offset = (instruction >> 0) & 0xff;
5303 signed_word op1 = 29;
5308 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5309 if (offset >= 0x8000)
5319 SignalException (ReservedInstruction, instruction);
5321 address_word vaddr = ((unsigned64)op1 + offset);
5324 if ((vaddr & 3) != 0)
5325 SignalExceptionAddressLoad();
5328 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5330 unsigned64 memval = 0;
5331 unsigned64 memval1 = 0;
5332 unsigned64 mask = 0x7;
5333 unsigned int shift = 2;
5334 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5335 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5337 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5338 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
5339 byte = ((vaddr & mask) ^ (bigend << shift));
5340 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
5347 10111,xxx,ddd,WWWWW:RRI:16::LWU
5350 unsigned32 instruction = instruction_0;
5351 signed_word op1 = (instruction >> 8) & 0x7;
5352 int destreg = (instruction >> 5) & 0x7;
5353 int offset = (instruction >> 0) & 0x1f;
5361 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5362 if (offset >= 0x8000)
5371 SignalException (ReservedInstruction, instruction);
5373 address_word vaddr = ((unsigned64)op1 + offset);
5376 if ((vaddr & 3) != 0)
5377 SignalExceptionAddressLoad();
5380 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5382 unsigned64 memval = 0;
5383 unsigned64 memval1 = 0;
5384 unsigned64 mask = 0x7;
5385 unsigned int shift = 2;
5386 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5387 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5389 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5390 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
5391 byte = ((vaddr & mask) ^ (bigend << shift));
5392 GPR[destreg] = (((memval >> (8 * byte)) & 0xFFFFFFFF));
5399 00111,xxx,ddd,DDDDD:RRI:16::LD
5402 unsigned32 instruction = instruction_0;
5403 signed_word op1 = (instruction >> 8) & 0x7;
5404 int destreg = (instruction >> 5) & 0x7;
5405 int offset = (instruction >> 0) & 0x1f;
5413 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5414 if (offset >= 0x8000)
5423 SignalException (ReservedInstruction, instruction);
5425 address_word vaddr = ((unsigned64)op1 + offset);
5428 if ((vaddr & 7) != 0)
5429 SignalExceptionAddressLoad();
5432 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5434 unsigned64 memval = 0;
5435 unsigned64 memval1 = 0;
5436 unsigned64 mask = 0x7;
5437 unsigned int shift = 4;
5438 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5439 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5441 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
5442 GPR[destreg] = memval;
5449 11111100,ddd,5.RD,P:RI64:16::LDPC
5452 unsigned32 instruction = instruction_0;
5453 int destreg = (instruction >> 5) & 0x7;
5454 int offset = (instruction >> 0) & 0x1f;
5455 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x7;
5460 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5461 if (offset >= 0x8000)
5470 SignalException (ReservedInstruction, instruction);
5472 address_word vaddr = ((unsigned64)op1 + offset);
5475 if ((vaddr & 7) != 0)
5476 SignalExceptionAddressLoad();
5479 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5481 unsigned64 memval = 0;
5482 unsigned64 memval1 = 0;
5483 unsigned64 mask = 0x7;
5484 unsigned int shift = 4;
5485 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5486 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5488 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
5489 GPR[destreg] = memval;
5496 11111000,ddd,5.RD,s:RI64:16::LDSP
5499 unsigned32 instruction = instruction_0;
5500 int destreg = (instruction >> 5) & 0x7;
5501 int offset = (instruction >> 0) & 0x1f;
5502 signed_word op1 = 29;
5507 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5508 if (offset >= 0x8000)
5518 SignalException (ReservedInstruction, instruction);
5520 address_word vaddr = ((unsigned64)op1 + offset);
5523 if ((vaddr & 7) != 0)
5524 SignalExceptionAddressLoad();
5527 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5529 unsigned64 memval = 0;
5530 unsigned64 memval1 = 0;
5531 unsigned64 mask = 0x7;
5532 unsigned int shift = 4;
5533 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5534 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5536 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
5537 GPR[destreg] = memval;
5544 11000,xxx,yyy,55555:RRI:16::SB
5547 unsigned32 instruction = instruction_0;
5548 signed_word op1 = (instruction >> 8) & 0x7;
5549 signed_word op2 = (instruction >> 5) & 0x7;
5550 int offset = (instruction >> 0) & 0x1f;
5559 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5560 if (offset >= 0x8000)
5568 SignalException (ReservedInstruction, instruction);
5570 address_word vaddr = ((unsigned64)op1 + offset);
5574 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5576 unsigned64 memval = 0;
5577 unsigned64 memval1 = 0;
5578 unsigned64 mask = 0x7;
5579 unsigned int shift = 0;
5580 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5581 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5583 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5584 byte = ((vaddr & mask) ^ (bigend << shift));
5585 memval = ((unsigned64) op2 << (8 * byte));
5587 StoreMemory(uncached,AccessLength_BYTE,memval,memval1,paddr,vaddr,isREAL);
5595 11001,xxx,yyy,HHHHH:RRI:16::SH
5598 unsigned32 instruction = instruction_0;
5599 signed_word op1 = (instruction >> 8) & 0x7;
5600 signed_word op2 = (instruction >> 5) & 0x7;
5601 int offset = (instruction >> 0) & 0x1f;
5610 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5611 if (offset >= 0x8000)
5620 SignalException (ReservedInstruction, instruction);
5622 address_word vaddr = ((unsigned64)op1 + offset);
5625 if ((vaddr & 1) != 0)
5626 SignalExceptionAddressStore();
5629 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5631 unsigned64 memval = 0;
5632 unsigned64 memval1 = 0;
5633 unsigned64 mask = 0x7;
5634 unsigned int shift = 1;
5635 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5636 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5638 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5639 byte = ((vaddr & mask) ^ (bigend << shift));
5640 memval = ((unsigned64) op2 << (8 * byte));
5642 StoreMemory(uncached,AccessLength_HALFWORD,memval,memval1,paddr,vaddr,isREAL);
5650 11011,xxx,yyy,WWWWW:RRI:16::SW
5653 unsigned32 instruction = instruction_0;
5654 signed_word op1 = (instruction >> 8) & 0x7;
5655 signed_word op2 = (instruction >> 5) & 0x7;
5656 int offset = (instruction >> 0) & 0x1f;
5665 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5666 if (offset >= 0x8000)
5675 SignalException (ReservedInstruction, instruction);
5677 address_word vaddr = ((unsigned64)op1 + offset);
5680 if ((vaddr & 3) != 0)
5681 SignalExceptionAddressStore();
5684 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5686 unsigned64 memval = 0;
5687 unsigned64 memval1 = 0;
5688 unsigned64 mask = 0x7;
5690 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
5691 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
5692 memval = ((unsigned64) op2 << (8 * byte));
5694 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
5702 11010,yyy,VVVVVVVV,s:RI:16::SWSP
5705 unsigned32 instruction = instruction_0;
5706 signed_word op2 = (instruction >> 8) & 0x7;
5707 int offset = (instruction >> 0) & 0xff;
5708 signed_word op1 = 29;
5714 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5715 if (offset >= 0x8000)
5725 SignalException (ReservedInstruction, instruction);
5727 address_word vaddr = ((unsigned64)op1 + offset);
5730 if ((vaddr & 3) != 0)
5731 SignalExceptionAddressStore();
5734 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5736 unsigned64 memval = 0;
5737 unsigned64 memval1 = 0;
5738 unsigned64 mask = 0x7;
5740 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
5741 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
5742 memval = ((unsigned64) op2 << (8 * byte));
5744 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
5752 01100010,VVVVVVVV,Q,s:I8:16::SWRASP
5755 unsigned32 instruction = instruction_0;
5756 int offset = (instruction >> 0) & 0xff;
5757 signed_word op2 = 31;
5758 signed_word op1 = 29;
5761 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5762 if (offset >= 0x8000)
5773 SignalException (ReservedInstruction, instruction);
5775 address_word vaddr = ((unsigned64)op1 + offset);
5778 if ((vaddr & 3) != 0)
5779 SignalExceptionAddressStore();
5782 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5784 unsigned64 memval = 0;
5785 unsigned64 memval1 = 0;
5786 unsigned64 mask = 0x7;
5788 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
5789 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
5790 memval = ((unsigned64) op2 << (8 * byte));
5792 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
5800 01111,xxx,yyy,DDDDD:RRI:16::SD
5803 unsigned32 instruction = instruction_0;
5804 signed_word op1 = (instruction >> 8) & 0x7;
5805 signed_word op2 = (instruction >> 5) & 0x7;
5806 int offset = (instruction >> 0) & 0x1f;
5815 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5816 if (offset >= 0x8000)
5825 SignalException (ReservedInstruction, instruction);
5827 address_word vaddr = ((unsigned64)op1 + offset);
5830 if ((vaddr & 7) != 0)
5831 SignalExceptionAddressStore();
5834 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5836 unsigned64 memval = 0;
5837 unsigned64 memval1 = 0;
5840 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
5848 11111001,yyy,5.RD,s:RI64:16::SDSP
5851 unsigned32 instruction = instruction_0;
5852 signed_word op2 = (instruction >> 5) & 0x7;
5853 int offset = (instruction >> 0) & 0x1f;
5854 signed_word op1 = 29;
5860 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5861 if (offset >= 0x8000)
5871 SignalException (ReservedInstruction, instruction);
5873 address_word vaddr = ((unsigned64)op1 + offset);
5876 if ((vaddr & 7) != 0)
5877 SignalExceptionAddressStore();
5880 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5882 unsigned64 memval = 0;
5883 unsigned64 memval1 = 0;
5886 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
5894 11111010,CCCCCCCC,s,Q:I64:16::SDRASP
5897 unsigned32 instruction = instruction_0;
5898 int offset = (instruction >> 0) & 0xff;
5899 signed_word op1 = 29;
5900 signed_word op2 = 31;
5903 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5904 if (offset >= 0x8000)
5915 SignalException (ReservedInstruction, instruction);
5917 address_word vaddr = ((unsigned64)op1 + offset);
5920 if ((vaddr & 7) != 0)
5921 SignalExceptionAddressStore();
5924 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5926 unsigned64 memval = 0;
5927 unsigned64 memval1 = 0;
5930 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
5938 // ALU Immediate Instructions
5941 01101,ddd,UUUUUUUU,Z:RI:16::LI
5944 unsigned32 instruction = instruction_0;
5945 int destreg = (instruction >> 8) & 0x7;
5946 int op2 = (instruction >> 0) & 0xff;
5947 signed_word op1 = 0;
5952 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5959 SignalException (ReservedInstruction, instruction);
5962 GPR[destreg] = (op1 | op2);
5967 01000,xxx,ddd,04444:RRI_A:16::ADDIU
5970 unsigned32 instruction = instruction_0;
5971 signed_word op1 = (instruction >> 8) & 0x7;
5972 int destreg = (instruction >> 5) & 0x7;
5973 int op2 = (instruction >> 0) & 0xf;
5981 op2 |= ((extendval & 0xf) << 11) | (extendval & 0x7f0);
5992 SignalException (ReservedInstruction, instruction);
5994 unsigned int temp = (unsigned int)(op1 + op2);
5995 signed int tempS = (signed int)temp;
5996 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6001 01001,www,kkkkkkkk:RI:16::ADDIU8
6004 unsigned32 instruction = instruction_0;
6005 signed_word op1 = (instruction >> 8) & 0x7;
6007 int op2 = (instruction >> 0) & 0xff;
6014 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6025 SignalException (ReservedInstruction, instruction);
6027 unsigned int temp = (unsigned int)(op1 + op2);
6028 signed int tempS = (signed int)temp;
6029 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6034 01100011,KKKKKKKK,S:I8:16::ADJSP
6037 unsigned32 instruction = instruction_0;
6038 int op2 = (instruction >> 0) & 0xff;
6039 signed_word op1 = 29;
6043 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6057 SignalException (ReservedInstruction, instruction);
6059 unsigned int temp = (unsigned int)(op1 + op2);
6060 signed int tempS = (signed int)temp;
6061 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6066 00001,ddd,AAAAAAAA,P:RI:16::ADDIUPC
6069 unsigned32 instruction = instruction_0;
6070 int destreg = (instruction >> 8) & 0x7;
6071 int op2 = (instruction >> 0) & 0xff;
6072 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
6077 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6087 SignalException (ReservedInstruction, instruction);
6089 unsigned int temp = (unsigned int)(op1 + op2);
6090 signed int tempS = (signed int)temp;
6091 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6096 00000,ddd,AAAAAAAA,s:RI:16::ADDIUSP
6099 unsigned32 instruction = instruction_0;
6100 int destreg = (instruction >> 8) & 0x7;
6101 int op2 = (instruction >> 0) & 0xff;
6102 signed_word op1 = 29;
6107 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6118 SignalException (ReservedInstruction, instruction);
6120 unsigned int temp = (unsigned int)(op1 + op2);
6121 signed int tempS = (signed int)temp;
6122 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6127 01000,xxx,ddd,14444:RRI_A:16::DADDIU
6130 unsigned32 instruction = instruction_0;
6131 signed_word op1 = (instruction >> 8) & 0x7;
6132 int destreg = (instruction >> 5) & 0x7;
6133 int op2 = (instruction >> 0) & 0xf;
6141 op2 |= ((extendval & 0xf) << 11) | (extendval & 0x7f0);
6152 SignalException (ReservedInstruction, instruction);
6154 unsigned64 temp = (unsigned64)(op1 + op2);
6155 word64 tempS = (word64)temp;
6156 GPR[destreg] = (unsigned64)temp;
6161 11111101,www,jjjjj:RI64:16::DADDIU5
6164 unsigned32 instruction = instruction_0;
6165 signed_word op1 = (instruction >> 5) & 0x7;
6167 int op2 = (instruction >> 0) & 0x1f;
6174 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6185 SignalException (ReservedInstruction, instruction);
6187 unsigned64 temp = (unsigned64)(op1 + op2);
6188 word64 tempS = (word64)temp;
6189 GPR[destreg] = (unsigned64)temp;
6194 11111011,KKKKKKKK,S:I64:16::DADJSP
6197 unsigned32 instruction = instruction_0;
6198 int op2 = (instruction >> 0) & 0xff;
6199 signed_word op1 = 29;
6203 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6217 SignalException (ReservedInstruction, instruction);
6219 unsigned64 temp = (unsigned64)(op1 + op2);
6220 word64 tempS = (word64)temp;
6221 GPR[destreg] = (unsigned64)temp;
6226 11111110,ddd,EEEEE,P:RI64:16::DADDIUPC
6229 unsigned32 instruction = instruction_0;
6230 int destreg = (instruction >> 5) & 0x7;
6231 int op2 = (instruction >> 0) & 0x1f;
6232 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
6237 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6247 SignalException (ReservedInstruction, instruction);
6249 unsigned64 temp = (unsigned64)(op1 + op2);
6250 word64 tempS = (word64)temp;
6251 GPR[destreg] = (unsigned64)temp;
6256 11111111,ddd,EEEEE,s:RI64:16::DADDIUSP
6259 unsigned32 instruction = instruction_0;
6260 int destreg = (instruction >> 5) & 0x7;
6261 int op2 = (instruction >> 0) & 0x1f;
6262 signed_word op1 = 29;
6267 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6278 SignalException (ReservedInstruction, instruction);
6280 unsigned64 temp = (unsigned64)(op1 + op2);
6281 word64 tempS = (word64)temp;
6282 GPR[destreg] = (unsigned64)temp;
6287 01010,xxx,88888888,T:RI:16::SLTI
6290 unsigned32 instruction = instruction_0;
6291 signed_word op1 = (instruction >> 8) & 0x7;
6292 int op2 = (instruction >> 0) & 0xff;
6299 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6308 SignalException (ReservedInstruction, instruction);
6310 if ((word64)op1 < (word64)op2)
6318 01011,xxx,88888888,T:RI:16::SLTIU
6321 unsigned32 instruction = instruction_0;
6322 signed_word op1 = (instruction >> 8) & 0x7;
6323 int op2 = (instruction >> 0) & 0xff;
6330 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6339 SignalException (ReservedInstruction, instruction);
6341 if ((unsigned64)op1 < (unsigned64)op2)
6349 11101,xxx,yyy,01010,T:RR:16::CMP
6352 unsigned32 instruction = instruction_0;
6353 signed_word op1 = (instruction >> 8) & 0x7;
6354 signed_word op2 = (instruction >> 5) & 0x7;
6363 SignalException (ReservedInstruction, instruction);
6365 GPR[destreg] = (op1 ^ op2);
6370 01110,xxx,UUUUUUUU,T:RI:16::CMPI
6373 unsigned32 instruction = instruction_0;
6374 signed_word op1 = (instruction >> 8) & 0x7;
6375 int op2 = (instruction >> 0) & 0xff;
6382 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6389 SignalException (ReservedInstruction, instruction);
6391 GPR[destreg] = (op1 ^ op2);
6396 // Two/Three Operand, Register-Type
6399 11100,xxx,yyy,ddd,01:RRR:16::ADDU
6402 unsigned32 instruction = instruction_0;
6403 signed_word op1 = (instruction >> 8) & 0x7;
6404 signed_word op2 = (instruction >> 5) & 0x7;
6405 int destreg = (instruction >> 2) & 0x7;
6415 SignalException (ReservedInstruction, instruction);
6417 unsigned int temp = (unsigned int)(op1 + op2);
6418 signed int tempS = (signed int)temp;
6419 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6424 11100,xxx,yyy,ddd,11:RRR:16::SUBU
6427 unsigned32 instruction = instruction_0;
6428 signed_word op1 = (instruction >> 8) & 0x7;
6429 signed_word op2 = (instruction >> 5) & 0x7;
6430 int destreg = (instruction >> 2) & 0x7;
6440 SignalException (ReservedInstruction, instruction);
6442 unsigned int temp = (unsigned int)(op1 - op2);
6443 signed int tempS = (signed int)temp;
6444 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6449 11100,xxx,yyy,ddd,00:RRR:16::DADDU
6452 unsigned32 instruction = instruction_0;
6453 signed_word op1 = (instruction >> 8) & 0x7;
6454 signed_word op2 = (instruction >> 5) & 0x7;
6455 int destreg = (instruction >> 2) & 0x7;
6465 SignalException (ReservedInstruction, instruction);
6467 unsigned64 temp = (unsigned64)(op1 + op2);
6468 word64 tempS = (word64)temp;
6469 GPR[destreg] = (unsigned64)temp;
6474 11100,xxx,yyy,ddd,10:RRR:16::DSUBU
6477 unsigned32 instruction = instruction_0;
6478 signed_word op1 = (instruction >> 8) & 0x7;
6479 signed_word op2 = (instruction >> 5) & 0x7;
6480 int destreg = (instruction >> 2) & 0x7;
6490 SignalException (ReservedInstruction, instruction);
6492 unsigned64 temp = (unsigned64)(op1 - op2);
6493 word64 tempS = (word64)temp;
6494 GPR[destreg] = (unsigned64)temp;
6499 11101,xxx,yyy,00010,T:RR:16::SLT
6502 unsigned32 instruction = instruction_0;
6503 signed_word op1 = (instruction >> 8) & 0x7;
6504 signed_word op2 = (instruction >> 5) & 0x7;
6513 SignalException (ReservedInstruction, instruction);
6515 if ((word64)op1 < (word64)op2)
6523 11101,xxx,yyy,00011,T:RR:16::SLTU
6526 unsigned32 instruction = instruction_0;
6527 signed_word op1 = (instruction >> 8) & 0x7;
6528 signed_word op2 = (instruction >> 5) & 0x7;
6537 SignalException (ReservedInstruction, instruction);
6539 if ((unsigned64)op1 < (unsigned64)op2)
6547 11101,ddd,yyy,01011,Z:RR:16::NEG
6550 unsigned32 instruction = instruction_0;
6551 int destreg = (instruction >> 8) & 0x7;
6552 signed_word op2 = (instruction >> 5) & 0x7;
6553 signed_word op1 = 0;
6560 SignalException (ReservedInstruction, instruction);
6562 unsigned int temp = (unsigned int)(op1 - op2);
6563 signed int tempS = (signed int)temp;
6564 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6569 11101,www,yyy,01100:RR:16::AND
6572 unsigned32 instruction = instruction_0;
6573 signed_word op1 = (instruction >> 8) & 0x7;
6575 signed_word op2 = (instruction >> 5) & 0x7;
6584 SignalException (ReservedInstruction, instruction);
6586 GPR[destreg] = (op1 & op2);
6591 11101,www,yyy,01101:RR:16::OR
6594 unsigned32 instruction = instruction_0;
6595 signed_word op1 = (instruction >> 8) & 0x7;
6597 signed_word op2 = (instruction >> 5) & 0x7;
6606 SignalException (ReservedInstruction, instruction);
6609 GPR[destreg] = (op1 | op2);
6614 11101,www,yyy,01110:RR:16::XOR
6617 unsigned32 instruction = instruction_0;
6618 signed_word op1 = (instruction >> 8) & 0x7;
6620 signed_word op2 = (instruction >> 5) & 0x7;
6629 SignalException (ReservedInstruction, instruction);
6631 GPR[destreg] = (op1 ^ op2);
6636 11101,ddd,yyy,01111,Z:RR:16::NOT
6639 unsigned32 instruction = instruction_0;
6640 int destreg = (instruction >> 8) & 0x7;
6641 signed_word op2 = (instruction >> 5) & 0x7;
6642 signed_word op1 = 0;
6649 SignalException (ReservedInstruction, instruction);
6652 GPR[destreg] = ~(op1 | op2);
6657 01100111,ddd,XXXXX,z:I8_MOVR32:16::MOVR32
6660 unsigned32 instruction = instruction_0;
6661 int destreg = (instruction >> 5) & 0x7;
6662 signed_word op1 = (instruction >> 0) & 0x1f;
6663 signed_word op2 = 0;
6668 SignalException (ReservedInstruction, instruction);
6671 GPR[destreg] = (op1 | op2);
6676 01100101,YYYYY,xxx,z:I8_MOV32R:16::MOV32R
6679 unsigned32 instruction = instruction_0;
6680 int destreg = (instruction >> 3) & 0x1f;
6681 signed_word op1 = (instruction >> 0) & 0x7;
6682 signed_word op2 = 0;
6683 destreg = (destreg >> 2) | ((destreg & 3) << 3);
6688 SignalException (ReservedInstruction, instruction);
6691 GPR[destreg] = (op1 | op2);
6696 00110,ddd,yyy,sss,00:ISHIFT:16::SLL
6699 unsigned32 instruction = instruction_0;
6700 int destreg = (instruction >> 8) & 0x7;
6701 signed_word op2 = (instruction >> 5) & 0x7;
6702 int op1 = (instruction >> 2) & 0x7;
6710 op1 = (extendval >> 6) & 0x1f;
6719 SignalException (ReservedInstruction, instruction);
6721 GPR[destreg] = ((unsigned64)op2 << op1);
6722 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6727 00110,ddd,yyy,sss,10:ISHIFT:16::SRL
6730 unsigned32 instruction = instruction_0;
6731 int destreg = (instruction >> 8) & 0x7;
6732 signed_word op2 = (instruction >> 5) & 0x7;
6733 int op1 = (instruction >> 2) & 0x7;
6741 op1 = (extendval >> 6) & 0x1f;
6750 SignalException (ReservedInstruction, instruction);
6752 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6753 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6758 00110,ddd,yyy,sss,11:ISHIFT:16::SRA
6761 unsigned32 instruction = instruction_0;
6762 int destreg = (instruction >> 8) & 0x7;
6763 signed_word op2 = (instruction >> 5) & 0x7;
6764 int op1 = (instruction >> 2) & 0x7;
6772 op1 = (extendval >> 6) & 0x1f;
6781 SignalException (ReservedInstruction, instruction);
6783 unsigned int highbit = (unsigned int)1 << 31;
6784 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6785 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned int)1 << op1) - 1) << (32 - op1)) : 0);
6786 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6791 11101,xxx,vvv,00100:RR:16::SLLV
6794 unsigned32 instruction = instruction_0;
6795 signed_word op1 = (instruction >> 8) & 0x7;
6796 signed_word op2 = (instruction >> 5) & 0x7;
6806 SignalException (ReservedInstruction, instruction);
6809 GPR[destreg] = ((unsigned64)op2 << op1);
6810 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6815 11101,xxx,vvv,00110:RR:16::SRLV
6818 unsigned32 instruction = instruction_0;
6819 signed_word op1 = (instruction >> 8) & 0x7;
6820 signed_word op2 = (instruction >> 5) & 0x7;
6830 SignalException (ReservedInstruction, instruction);
6833 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6834 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6839 11101,xxx,vvv,00111:RR:16::SRAV
6842 unsigned32 instruction = instruction_0;
6843 signed_word op1 = (instruction >> 8) & 0x7;
6844 signed_word op2 = (instruction >> 5) & 0x7;
6854 SignalException (ReservedInstruction, instruction);
6856 unsigned int highbit = (unsigned int)1 << 31;
6858 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6859 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned int)1 << op1) - 1) << (32 - op1)) : 0);
6860 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6865 00110,ddd,yyy,[[[,01:ISHIFT:16::DSLL
6868 unsigned32 instruction = instruction_0;
6869 int destreg = (instruction >> 8) & 0x7;
6870 signed_word op2 = (instruction >> 5) & 0x7;
6871 int op1 = (instruction >> 2) & 0x7;
6879 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
6888 SignalException (ReservedInstruction, instruction);
6890 GPR[destreg] = ((unsigned64)op2 << op1);
6895 11101,XXX,vvv,01000:RR:16::DSRL
6898 unsigned32 instruction = instruction_0;
6899 int op1 = (instruction >> 8) & 0x7;
6900 signed_word op2 = (instruction >> 5) & 0x7;
6904 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
6917 SignalException (ReservedInstruction, instruction);
6919 GPR[destreg] = ((unsigned64)(op2) >> op1);
6924 11101,xxx,vvv,10011:RR:16::DSRA
6927 unsigned32 instruction = instruction_0;
6928 int op1 = (instruction >> 8) & 0x7;
6929 signed_word op2 = (instruction >> 5) & 0x7;
6933 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
6946 SignalException (ReservedInstruction, instruction);
6948 unsigned64 highbit = (unsigned64)1 << 63;
6949 GPR[destreg] = ((unsigned64)(op2) >> op1);
6950 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned64)1 << op1) - 1) << (64 - op1)) : 0);
6955 11101,xxx,vvv,10100:RR:16::DSLLV
6958 unsigned32 instruction = instruction_0;
6959 signed_word op1 = (instruction >> 8) & 0x7;
6960 signed_word op2 = (instruction >> 5) & 0x7;
6970 SignalException (ReservedInstruction, instruction);
6973 GPR[destreg] = ((unsigned64)op2 << op1);
6978 11101,xxx,vvv,10110:RR:16::DSRLV
6981 unsigned32 instruction = instruction_0;
6982 signed_word op1 = (instruction >> 8) & 0x7;
6983 signed_word op2 = (instruction >> 5) & 0x7;
6993 SignalException (ReservedInstruction, instruction);
6996 GPR[destreg] = ((unsigned64)(op2) >> op1);
7001 11101,xxx,vvv,10111:RR:16::DSRAV
7004 unsigned32 instruction = instruction_0;
7005 signed_word op1 = (instruction >> 8) & 0x7;
7006 signed_word op2 = (instruction >> 5) & 0x7;
7016 SignalException (ReservedInstruction, instruction);
7018 unsigned64 highbit = (unsigned64)1 << 63;
7020 GPR[destreg] = ((unsigned64)(op2) >> op1);
7021 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned64)1 << op1) - 1) << (64 - op1)) : 0);
7026 // Multiply /Divide Instructions
7029 11101,xxx,yyy,11000:RR:16::MULT
7032 unsigned32 instruction = instruction_0;
7033 signed_word op1 = (instruction >> 8) & 0x7;
7034 signed_word op2 = (instruction >> 5) & 0x7;
7042 SignalException (ReservedInstruction, instruction);
7044 CHECKHILO("Multiplication");
7046 unsigned64 temp = ((word64) op1 * (word64) op2);
7047 LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
7048 HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
7054 11101,xxx,yyy,11001:RR:16::MULTU
7057 unsigned32 instruction = instruction_0;
7058 signed_word op1 = (instruction >> 8) & 0x7;
7059 signed_word op2 = (instruction >> 5) & 0x7;
7067 SignalException (ReservedInstruction, instruction);
7069 CHECKHILO("Multiplication");
7071 unsigned64 temp = ((unsigned64)(op1 & 0xffffffff) * (unsigned64)(op2 & 0xffffffff));
7072 LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
7073 HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
7079 11101,xxx,yyy,11010:RR:16::DIV
7082 unsigned32 instruction = instruction_0;
7083 signed_word op1 = (instruction >> 8) & 0x7;
7084 signed_word op2 = (instruction >> 5) & 0x7;
7092 SignalException (ReservedInstruction, instruction);
7094 CHECKHILO("Division");
7100 LO = SIGNEXTEND(0x80000000,32);
7101 HI = SIGNEXTEND(0,32);
7103 else if (d2 == -1 && d1 == 0x80000000)
7105 LO = SIGNEXTEND(0x80000000,32);
7106 HI = SIGNEXTEND(0,32);
7110 LO = SIGNEXTEND((d1 / d2),32);
7111 HI = SIGNEXTEND((d1 % d2),32);
7118 11101,xxx,yyy,11011:RR:16::DIVU
7121 unsigned32 instruction = instruction_0;
7122 signed_word op1 = (instruction >> 8) & 0x7;
7123 signed_word op2 = (instruction >> 5) & 0x7;
7131 SignalException (ReservedInstruction, instruction);
7133 CHECKHILO("Division");
7135 unsigned int d1 = op1;
7136 unsigned int d2 = op2;
7139 LO = SIGNEXTEND(0x80000000,32);
7140 HI = SIGNEXTEND(0,32);
7142 else if (d2 == -1 && d1 == 0x80000000)
7144 LO = SIGNEXTEND(0x80000000,32);
7145 HI = SIGNEXTEND(0,32);
7149 LO = SIGNEXTEND((d1 / d2),32);
7150 HI = SIGNEXTEND((d1 % d2),32);
7157 11101,ddd,00010000:RR:16::MFHI
7160 unsigned32 instruction = instruction_0;
7161 int destreg = (instruction >> 8) & 0x7;
7165 SignalException (ReservedInstruction, instruction);
7168 HIACCESS = 3; /* 3rd instruction will be safe */
7173 11101,ddd,00010010:RR:16::MFLO
7176 unsigned32 instruction = instruction_0;
7177 int destreg = (instruction >> 8) & 0x7;
7181 SignalException (ReservedInstruction, instruction);
7184 LOACCESS = 3; /* 3rd instruction will be safe */
7189 11101,xxx,yyy,11100:RR:16::DMULT
7192 unsigned32 instruction = instruction_0;
7193 signed_word op1 = (instruction >> 8) & 0x7;
7194 signed_word op2 = (instruction >> 5) & 0x7;
7202 SignalException (ReservedInstruction, instruction);
7204 CHECKHILO("Multiplication");
7210 if (op1 < 0) { op1 = - op1; ++sign; }
7211 if (op2 < 0) { op2 = - op2; ++sign; }
7212 LO = ((unsigned64)VL4_8(op1) * VL4_8(op2));
7213 HI = ((unsigned64)VH4_8(op1) * VH4_8(op2));
7214 mid = ((unsigned64)VH4_8(op1) * VL4_8(op2));
7215 midhi = SET64HI(VL4_8(mid));
7216 temp = (LO + midhi);
7217 if ((temp == midhi) ? (LO != 0) : (temp < midhi))
7220 mid = ((unsigned64)VL4_8(op1) * VH4_8(op2));
7221 midhi = SET64HI(VL4_8(mid));
7222 LO = (temp + midhi);
7223 if ((LO == midhi) ? (temp != 0) : (LO < midhi))
7226 if (sign & 1) { LO = - LO; HI = (LO == 0 ? 0 : -1) - HI; }
7232 11101,xxx,yyy,11101:RR:16::DMULTU
7235 unsigned32 instruction = instruction_0;
7236 signed_word op1 = (instruction >> 8) & 0x7;
7237 signed_word op2 = (instruction >> 5) & 0x7;
7245 SignalException (ReservedInstruction, instruction);
7247 CHECKHILO("Multiplication");
7252 LO = ((unsigned64)VL4_8(op1) * VL4_8(op2));
7253 HI = ((unsigned64)VH4_8(op1) * VH4_8(op2));
7254 mid = ((unsigned64)VH4_8(op1) * VL4_8(op2));
7255 midhi = SET64HI(VL4_8(mid));
7256 temp = (LO + midhi);
7257 if ((temp == midhi) ? (LO != 0) : (temp < midhi))
7260 mid = ((unsigned64)VL4_8(op1) * VH4_8(op2));
7261 midhi = SET64HI(VL4_8(mid));
7262 LO = (temp + midhi);
7263 if ((LO == midhi) ? (temp != 0) : (LO < midhi))
7271 11101,xxx,yyy,11110:RR:16::DDIV
7274 unsigned32 instruction = instruction_0;
7275 signed_word op1 = (instruction >> 8) & 0x7;
7276 signed_word op2 = (instruction >> 5) & 0x7;
7284 SignalException (ReservedInstruction, instruction);
7286 CHECKHILO("Division");
7292 LO = SIGNED64 (0x8000000000000000);
7295 else if (d2 == -1 && d1 == SIGNED64 (0x8000000000000000))
7297 LO = SIGNED64 (0x8000000000000000);
7310 11101,xxx,yyy,11111:RR:16::DDIVU
7313 unsigned32 instruction = instruction_0;
7314 signed_word op1 = (instruction >> 8) & 0x7;
7315 signed_word op2 = (instruction >> 5) & 0x7;
7323 SignalException (ReservedInstruction, instruction);
7325 CHECKHILO("Division");
7327 unsigned64 d1 = op1;
7328 unsigned64 d2 = op2;
7331 LO = SIGNED64 (0x8000000000000000);
7334 else if (d2 == -1 && d1 == SIGNED64 (0x8000000000000000))
7336 LO = SIGNED64 (0x8000000000000000);
7349 // Jump and Branch Instructions
7354 00011,aaaaaaaaaaa:I:16::JAL
7357 unsigned32 instruction = instruction_0;
7358 unsigned_word op1 = (instruction >> 0) & 0x7ff;
7362 if (AddressTranslation (PC &~ (unsigned64) 1, isINSTRUCTION, isLOAD, &paddr, &uncached, isTARGET, isREAL))
7365 unsigned int reverse = (ReverseEndian ? 3 : 0);
7366 unsigned int bigend = (BigEndianCPU ? 3 : 0);
7368 paddr = ((paddr & ~0x7) | ((paddr & 0x7) ^ (reverse << 1)));
7369 LoadMemory (&memval,0,uncached, AccessLength_HALFWORD, paddr, PC, isINSTRUCTION, isREAL);
7370 byte = (((PC &~ (unsigned64) 1) & 0x7) ^ (bigend << 1));
7371 memval = (memval >> (8 * byte)) & 0xffff;
7372 op1 = (((op1 & 0x1f) << 23)
7373 | ((op1 & 0x3e0) << 13)
7375 if ((instruction & 0x400) == 0)
7380 op1 |= PC & ~ (unsigned64) 0x0fffffff;
7382 SignalException (ReservedInstruction, instruction);
7385 GPR[destreg] = (PC + 2); /* NOTE: The PC is already 2 ahead within the simulator */
7386 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
7387 so we just truncate it to 32 bits here. */
7389 /* NOTE: The jump occurs AFTER the next instruction has been executed */
7396 11101,xxx,00000000:RR:16::JR
7399 unsigned32 instruction = instruction_0;
7400 signed_word op1 = (instruction >> 8) & 0x7;
7405 SignalException (ReservedInstruction, instruction);
7407 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
7408 so we just truncate it to 32 bits here. */
7410 /* NOTE: The jump occurs AFTER the next instruction has been executed */
7417 1110100000100000,r:RR:16::JRRA
7420 unsigned32 instruction = instruction_0;
7421 signed_word op1 = 31;
7424 SignalException (ReservedInstruction, instruction);
7426 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
7427 so we just truncate it to 32 bits here. */
7429 /* NOTE: The jump occurs AFTER the next instruction has been executed */
7436 11101,xxx,01000000,R:RR:16::JALR
7439 unsigned32 instruction = instruction_0;
7440 signed_word op1 = (instruction >> 8) & 0x7;
7446 SignalException (ReservedInstruction, instruction);
7448 GPR[destreg] = (PC + 2); /* NOTE: The PC is already 2 ahead within the simulator */
7449 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
7450 so we just truncate it to 32 bits here. */
7452 /* NOTE: The jump occurs AFTER the next instruction has been executed */
7459 00100,xxx,pppppppp,z:RI:16::BEQZ
7462 unsigned32 instruction = instruction_0;
7463 signed_word op1 = (instruction >> 8) & 0x7;
7464 int offset = (instruction >> 0) & 0xff;
7465 signed_word op2 = 0;
7471 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7472 if (offset >= 0x8000)
7483 SignalException (ReservedInstruction, instruction);
7485 int condition = (op1 == op2);
7492 00101,xxx,pppppppp,z:RI:16::BNEZ
7495 unsigned32 instruction = instruction_0;
7496 signed_word op1 = (instruction >> 8) & 0x7;
7497 int offset = (instruction >> 0) & 0xff;
7498 signed_word op2 = 0;
7504 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7505 if (offset >= 0x8000)
7516 SignalException (ReservedInstruction, instruction);
7518 int condition = (op1 != op2);
7525 01100000,pppppppp,t,z:I8:16::BTEQZ
7528 unsigned32 instruction = instruction_0;
7529 int offset = (instruction >> 0) & 0xff;
7530 signed_word op1 = 24;
7531 signed_word op2 = 0;
7534 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7535 if (offset >= 0x8000)
7547 SignalException (ReservedInstruction, instruction);
7549 int condition = (op1 == op2);
7556 01100001,pppppppp,t,z:I8:16::BTNEZ
7559 unsigned32 instruction = instruction_0;
7560 int offset = (instruction >> 0) & 0xff;
7561 signed_word op1 = 24;
7562 signed_word op2 = 0;
7565 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7566 if (offset >= 0x8000)
7578 SignalException (ReservedInstruction, instruction);
7580 int condition = (op1 != op2);
7587 00010,qqqqqqqqqqq,z,Z:I:16::B
7590 unsigned32 instruction = instruction_0;
7591 int offset = (instruction >> 0) & 0x7ff;
7592 signed_word op2 = 0;
7593 signed_word op1 = 0;
7596 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7597 if (offset >= 0x8000)
7603 if (offset >= 0x400)
7608 SignalException (ReservedInstruction, instruction);
7610 int condition = (op1 == op2);
7617 // Special Instructions
7620 // See the front of the mips16 doc
7621 11110,eeeeeeeeeee:I:16::EXTEND
7624 unsigned32 instruction = instruction_0;
7625 int ext = (instruction >> 0) & 0x7ff;
7627 SignalException (ReservedInstruction, instruction);
7635 01100,******,00101:RR:16::BREAK
7638 unsigned32 instruction = instruction_0;
7640 SignalException (ReservedInstruction, instruction);
7642 SignalException(BreakPoint,instruction);
7647 // start-sanitize-r5900
7649 // FIXME: The instructions below which are typically r5900 specific
7650 // need to be merged back into the above.
7652 // end-sanitize-r5900
7653 // start-sanitize-r5900
7655 011100,5.RS,5.RT,0000000000011010:MMINORM:32::DIV1
7658 unsigned32 instruction = instruction_0;
7659 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7660 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7662 CHECKHILO("Division");
7668 LO1 = SIGNEXTEND(0x80000000,32);
7669 HI1 = SIGNEXTEND(0,32);
7671 else if (d2 == -1 && d1 == 0x80000000)
7673 LO1 = SIGNEXTEND(0x80000000,32);
7674 HI1 = SIGNEXTEND(0,32);
7678 LO1 = SIGNEXTEND((d1 / d2),32);
7679 HI1 = SIGNEXTEND((d1 % d2),32);
7685 // end-sanitize-r5900
7686 // start-sanitize-r5900
7688 011100,5.RS,5.RT,0000000000011011:MMINORM:32::DIVU1
7691 unsigned32 instruction = instruction_0;
7692 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7693 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7695 CHECKHILO("Division");
7697 unsigned int d1 = op1;
7698 unsigned int d2 = op2;
7701 LO1 = SIGNEXTEND(0x80000000,32);
7702 HI1 = SIGNEXTEND(0,32);
7704 else if (d2 == -1 && d1 == 0x80000000)
7706 LO1 = SIGNEXTEND(0x80000000,32);
7707 HI1 = SIGNEXTEND(0,32);
7711 LO1 = SIGNEXTEND((d1 / d2),32);
7712 HI1 = SIGNEXTEND((d1 % d2),32);
7718 // end-sanitize-r5900
7720 011101,26.INSTR_INDEX:NORMAL:32::JALX
7721 // start-sanitize-r5900
7723 // end-sanitize-r5900
7725 // start-sanitize-tx19
7727 // end-sanitize-tx19
7729 unsigned32 instruction = instruction_0;
7730 unsigned_word op1 = (((instruction >> 0) & 0x03FFFFFF) << 2);
7731 op1 |= (PC & ~0x0FFFFFFF); /* address of instruction in delay slot for the jump */
7734 GPR[destreg] = (PC + 4); /* NOTE: The PC is already 4 ahead within the simulator */
7736 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
7737 so we just truncate it to 32 bits here. */
7739 /* NOTE: The jump occurs AFTER the next instruction has been executed */
7741 /* JALDELAYSLOT(); FIXME */
7745 // start-sanitize-r5900
7747 011110,5.RS,5.RT,16.OFFSET:NORMAL:128::LQ
7750 unsigned32 instruction = instruction_0;
7751 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
7752 int destreg = ((instruction >> 16) & 0x0000001F);
7753 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7755 address_word vaddr = ((unsigned64)op1 + offset);
7758 if ((vaddr & 15) != 0)
7759 SignalExceptionAddressLoad();
7762 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
7764 unsigned64 memval = 0;
7765 unsigned64 memval1 = 0;
7766 unsigned64 mask = 0x7;
7767 unsigned int shift = 8;
7768 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
7769 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
7771 LoadMemory(&memval,&memval1,uncached,AccessLength_QUADWORD,paddr,vaddr,isDATA,isREAL);
7772 GPR[destreg] = memval;
7773 GPR1[destreg] = memval1;
7779 // end-sanitize-r5900
7780 // start-sanitize-r5900
7782 011100,5.RS,5.RT,5.RD,00000000000:MMINORM:32::MADD
7786 unsigned32 instruction = instruction_0;
7787 int destreg = ((instruction >> 11) & 0x0000001F);
7788 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7789 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7791 word64 prod = (word64)WORD64(VL4_8(HI),VL4_8(LO)) + ((word64)SIGNEXTEND(op1,32) * (word64)SIGNEXTEND(op2,32));
7792 LO = SIGNEXTEND(prod,32);
7793 HI = SIGNEXTEND( VH4_8(prod), 32);
7794 if( destreg != 0 ) GPR[destreg] = LO;
7798 // end-sanitize-r5900
7799 // start-sanitize-r5900
7801 011100,5.RS,5.RT,5.RD,00000000001:MMINORM:32::MADDU
7805 unsigned32 instruction = instruction_0;
7806 int destreg = ((instruction >> 11) & 0x0000001F);
7807 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7808 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7810 unsigned64 prod = (unsigned64)WORD64(VL4_8(HI),VL4_8(LO)) + ((unsigned64)VL4_8(op1) * (unsigned64)VL4_8(op2));
7811 LO = SIGNEXTEND(prod,32);
7812 HI = SIGNEXTEND( VH4_8(prod), 32);
7813 if( destreg != 0 ) GPR[destreg] = LO;
7817 // end-sanitize-r5900
7818 // start-sanitize-r5900
7820 011100,5.RS,5.RT,5.RD,00000100000:MMINORM:32::MADD1
7823 unsigned32 instruction = instruction_0;
7824 int destreg = ((instruction >> 11) & 0x0000001F);
7825 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7826 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7828 word64 prod = (word64)WORD64(VL4_8(HI1),VL4_8(LO1)) + ((word64)SIGNEXTEND(op1,32) * (word64)SIGNEXTEND(op2,32));
7829 LO1 = SIGNEXTEND(prod,32);
7830 HI1 = SIGNEXTEND( VH4_8(prod), 32);
7831 if( destreg != 0 ) GPR[destreg] = LO1;
7835 // end-sanitize-r5900
7836 // start-sanitize-r5900
7838 011100,5.RS,5.RT,5.RD,00000100001:MMINORM:32::MADDU1
7841 unsigned32 instruction = instruction_0;
7842 int destreg = ((instruction >> 11) & 0x0000001F);
7843 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7844 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7846 unsigned64 prod = (unsigned64)WORD64(VL4_8(HI1),VL4_8(LO1)) + ((unsigned64)VL4_8(op1) * (unsigned64)VL4_8(op2));
7847 LO1 = SIGNEXTEND(prod,32);
7848 HI1 = SIGNEXTEND( VH4_8(prod), 32);
7849 if( destreg != 0 ) GPR[destreg] = LO1;
7853 // end-sanitize-r5900
7854 // start-sanitize-r5900
7856 0111000000000000,5.RD,00000010000:MMINORM:32::MFHI1
7859 unsigned32 instruction = instruction_0;
7860 int destreg = ((instruction >> 11) & 0x0000001F);
7863 HI1ACCESS = 3; /* 3rd instruction will be safe */
7867 // end-sanitize-r5900
7868 // start-sanitize-r5900
7870 0111000000000000,5.RD,00000010010:MMINORM:32::MFLO1
7873 unsigned32 instruction = instruction_0;
7874 int destreg = ((instruction >> 11) & 0x0000001F);
7877 LO1ACCESS = 3; /* 3rd instruction will be safe */
7881 // end-sanitize-r5900
7882 // start-sanitize-r5900
7884 0000000000000000,5.RD,00000101000:SPECIAL:32::MFSA
7887 unsigned32 instruction = instruction_0;
7888 int destreg = ((instruction >> 11) & 0x0000001F);
7894 // end-sanitize-r5900
7895 // start-sanitize-r5900
7897 011100,5.RS,000000000000000010001:MMINORM:32::MTHI1
7900 unsigned32 instruction = instruction_0;
7901 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7904 sim_io_error(sd,"MT (move-to) over-writing HI register value\n");
7906 HI1ACCESS = 3; /* 3rd instruction will be safe */
7910 // end-sanitize-r5900
7911 // start-sanitize-r5900
7913 011100,5.RS,000000000000000010011:MMINORM:32::MTLO1
7916 unsigned32 instruction = instruction_0;
7917 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7920 sim_io_error(sd,"MT (move-to) over-writing LO register value");
7922 LO1ACCESS = 3; /* 3rd instruction will be safe */
7926 // end-sanitize-r5900
7927 // start-sanitize-r5900
7929 000000,5.RS,000000000000000101001:SPECIAL:32::MTSA
7932 unsigned32 instruction = instruction_0;
7933 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7939 // end-sanitize-r5900
7940 // start-sanitize-r5900
7942 000001,5.RS,11000,16.IMMEDIATE:REGIMM:32::MTSAB
7945 SA = ((GPR[RA] & 0xF) ^ (IMMEDIATE & 0xF)) * 8;
7948 // end-sanitize-r5900
7949 // start-sanitize-r5900
7951 000001,5.RS,11001,16.IMMEDIATE:REGIMM:32::MTSAH
7954 SA = ((GPR[RS] & 0x7) ^ (IMMEDIATE & 0x7)) * 16;
7957 // end-sanitize-r5900
7958 // start-sanitize-r5900
7960 011100,5.RS,5.RT,5.RD,00000011000:MMINORM:32::MULT1
7963 unsigned32 instruction = instruction_0;
7964 int destreg = ((instruction >> 11) & 0x0000001F);
7965 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7966 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7968 CHECKHILO("Multiplication");
7970 unsigned64 temp = ((word64) op1 * (word64) op2);
7971 LO1 = SIGNEXTEND((unsigned64)VL4_8(temp),32);
7972 HI1 = SIGNEXTEND((unsigned64)VH4_8(temp),32);
7979 // end-sanitize-r5900
7980 // start-sanitize-r5900
7982 011100,5.RS,5.RT,5.RD,00000011001:MMINORM:32::MULTU1
7985 unsigned32 instruction = instruction_0;
7986 int destreg = ((instruction >> 11) & 0x0000001F);
7987 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7988 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7990 CHECKHILO("Multiplication");
7992 unsigned64 temp = ((unsigned64)(op1 & 0xffffffff) * (unsigned64)(op2 & 0xffffffff));
7993 LO1 = SIGNEXTEND((unsigned64)VL4_8(temp),32);
7994 HI1 = SIGNEXTEND((unsigned64)VH4_8(temp),32);
8001 // end-sanitize-r5900
8002 // start-sanitize-r5900
8004 01110000000,5.RT,5.RD,00101101000:MMI1:32::PABSH
8007 unsigned32 instruction = instruction_0;
8008 int destreg = ((instruction >> 11) & 0x0000001F);
8009 signed_word rt_reg = GPR[RT];
8010 signed_word rt_reg1 = GPR1[RT];
8013 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
8016 GPR_SH(destreg,i) = RT_SH(i);
8017 else if (RT_SH(i) == -32768)
8018 GPR_SH(destreg,i) = 32767;
8020 GPR_SH(destreg,i) = -RT_SH(i);
8025 // end-sanitize-r5900
8026 // start-sanitize-r5900
8028 01110000000,5.RT,5.RD,00001101000:MMI1:32::PABSW
8031 unsigned32 instruction = instruction_0;
8032 int destreg = ((instruction >> 11) & 0x0000001F);
8033 signed_word rt_reg = GPR[RT];
8034 signed_word rt_reg1 = GPR1[RT];
8037 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8040 GPR_SW(destreg,i) = RT_SW(i);
8041 else if (RT_SW(i) == (int)0x80000000)
8042 GPR_SW(destreg,i) = (int)0x7FFFFFFF;
8044 GPR_SW(destreg,i) = -RT_SW(i);
8049 // end-sanitize-r5900
8050 // start-sanitize-r5900
8052 011100,5.RS,5.RT,5.RD,01000001000:MMI0:32::PADDB
8055 unsigned32 instruction = instruction_0;
8056 int destreg = ((instruction >> 11) & 0x0000001F);
8057 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8058 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8059 signed_word rt_reg = GPR[RT];
8060 signed_word rt_reg1 = GPR1[RT];
8063 for (i=0; i < BYTES_IN_MMI_REGS; i++)
8068 GPR_SB(destreg,i) = r;
8073 // end-sanitize-r5900
8074 // start-sanitize-r5900
8076 011100,5.RS,5.RT,5.RD,00100001000:MMI0:32::PADDH
8079 unsigned32 instruction = instruction_0;
8080 int destreg = ((instruction >> 11) & 0x0000001F);
8081 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8082 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8083 signed_word rt_reg = GPR[RT];
8084 signed_word rt_reg1 = GPR1[RT];
8087 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
8092 GPR_SH(destreg,i) = r;
8097 // end-sanitize-r5900
8098 // start-sanitize-r5900
8100 011100,5.RS,5.RT,5.RD,00000001000:MMI0:32::PADDW
8103 unsigned32 instruction = instruction_0;
8104 int destreg = ((instruction >> 11) & 0x0000001F);
8105 signed_word rs_reg = GPR[RS];
8106 signed_word rs_reg1 = GPR1[RS];
8107 signed_word rt_reg = GPR[RT];
8108 signed_word rt_reg1 = GPR1[RT];
8111 for (i=0; i < WORDS_IN_MMI_REGS; i++)
8113 signed64 s = RS_SW(i);
8114 signed64 t = RT_SW(i);
8116 GPR_SW(destreg,i) = r;
8121 // end-sanitize-r5900
8122 // start-sanitize-r5900
8124 011100,5.RS,5.RT,5.RD,11000001000:MMI0:32::PADDSB
8127 unsigned32 instruction = instruction_0;
8128 int destreg = ((instruction >> 11) & 0x0000001F);
8129 signed_word rs_reg = GPR[RS];
8130 signed_word rs_reg1 = GPR1[RS];
8131 signed_word rt_reg = GPR[RT];
8132 signed_word rt_reg1 = GPR1[RT];
8135 for (i=0; i < BYTES_IN_MMI_REGS; i++)
8141 GPR_SB(destreg,i) = 127;
8143 GPR_SB(destreg,i) = -128;
8145 GPR_SB(destreg,i) = r;
8150 // end-sanitize-r5900
8151 // start-sanitize-r5900
8153 011100,5.RS,5.RT,5.RD,10100001000:MMI0:32::PADDSH
8156 unsigned32 instruction = instruction_0;
8157 int destreg = ((instruction >> 11) & 0x0000001F);
8158 signed_word rs_reg = GPR[RS];
8159 signed_word rs_reg1 = GPR1[RS];
8160 signed_word rt_reg = GPR[RT];
8161 signed_word rt_reg1 = GPR1[RT];
8164 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
8170 GPR_SH(destreg,i) = 32767;
8171 else if (r < -32768)
8172 GPR_SH(destreg,i) = -32768;
8174 GPR_SH(destreg,i) = r;
8179 // end-sanitize-r5900
8180 // start-sanitize-r5900
8182 011100,5.RS,5.RT,5.RD,10000001000:MMI0:32::PADDSW
8185 unsigned32 instruction = instruction_0;
8186 int destreg = ((instruction >> 11) & 0x0000001F);
8187 signed_word rs_reg = GPR[RS];
8188 signed_word rs_reg1 = GPR1[RS];
8189 signed_word rt_reg = GPR[RT];
8190 signed_word rt_reg1 = GPR1[RT];
8193 for (i=0; i < WORDS_IN_MMI_REGS; i++)
8195 signed64 s = RS_SW(i);
8196 signed64 t = RT_SW(i);
8198 if (r > (int)0x7FFFFFFF)
8199 GPR_SW(destreg,i) = (int)0x7FFFFFFF;
8200 else if (r < (int)0x80000000)
8201 GPR_SW(destreg,i) = (int)0x80000000;
8203 GPR_SW(destreg,i) = r;
8208 // end-sanitize-r5900
8209 // start-sanitize-r5900
8211 011100,5.RS,5.RT,5.RD,11000101000:MMI1:32::PADDUB
8214 unsigned32 instruction = instruction_0;
8215 int destreg = ((instruction >> 11) & 0x0000001F);
8216 signed_word rs_reg = GPR[RS];
8217 signed_word rs_reg1 = GPR1[RS];
8218 signed_word rt_reg = GPR[RT];
8219 signed_word rt_reg1 = GPR1[RT];
8222 for (i=0; i < BYTES_IN_MMI_REGS; i++)
8224 unsigned int s = RS_UB(i);
8225 unsigned int t = RT_UB(i);
8226 unsigned int r = s + t;
8228 GPR_UB(destreg,i) = 0xFF;
8230 GPR_UB(destreg,i) = r;
8235 // end-sanitize-r5900
8236 // start-sanitize-r5900
8238 011100,5.RS,5.RT,5.RD,10100101000:MMI1:32::PADDUH
8241 unsigned32 instruction = instruction_0;
8242 int destreg = ((instruction >> 11) & 0x0000001F);
8243 signed_word rs_reg = GPR[RS];
8244 signed_word rs_reg1 = GPR1[RS];
8245 signed_word rt_reg = GPR[RT];
8246 signed_word rt_reg1 = GPR1[RT];
8249 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
8251 unsigned int s = RS_UH(i);
8252 unsigned int t = RT_UH(i);
8253 unsigned int r = s + t;
8255 GPR_UH(destreg,i) = 0xFFFF;
8257 GPR_UH(destreg,i) = r;
8262 // end-sanitize-r5900
8263 // start-sanitize-r5900
8265 011100,5.RS,5.RT,5.RD,10000101000:MMI1:32::PADDUW
8268 unsigned32 instruction = instruction_0;
8269 int destreg = ((instruction >> 11) & 0x0000001F);
8270 signed_word rs_reg = GPR[RS];
8271 signed_word rs_reg1 = GPR1[RS];
8272 signed_word rt_reg = GPR[RT];
8273 signed_word rt_reg1 = GPR1[RT];
8276 for (i=0; i < WORDS_IN_MMI_REGS; i++)
8278 unsigned64 s = RS_UW(i);
8279 unsigned64 t = RT_UW(i);
8280 unsigned64 r = s + t;
8282 GPR_UW(destreg,i) = 0xFFFFFFFF;
8284 GPR_UW(destreg,i) = r;
8289 // end-sanitize-r5900
8290 // start-sanitize-r5900
8292 011100,5.RS,5.RT,5.RD,00100101000:MMI1:32::PADSBH
8295 unsigned32 instruction = instruction_0;
8296 int destreg = ((instruction >> 11) & 0x0000001F);
8297 signed_word rs_reg = GPR[RS];
8298 signed_word rs_reg1 = GPR1[RS];
8299 signed_word rt_reg = GPR[RT];
8300 signed_word rt_reg1 = GPR1[RT];
8303 for(i=0;i<HALFWORDS_IN_MMI_REGS/2;i++)
8304 GPR_SH(destreg,i) = RS_SH(i) - RT_SH(i);
8305 for(;i<HALFWORDS_IN_MMI_REGS;i++)
8306 GPR_SH(destreg,i) = RS_SH(i) + RT_SH(i);
8310 // end-sanitize-r5900
8311 // start-sanitize-r5900
8313 011100,5.RS,5.RT,5.RD,10010001001:MMI2:32::PAND
8316 unsigned32 instruction = instruction_0;
8317 int destreg = ((instruction >> 11) & 0x0000001F);
8318 signed_word rs_reg = GPR[RS];
8319 signed_word rs_reg1 = GPR1[RS];
8320 signed_word rt_reg = GPR[RT];
8321 signed_word rt_reg1 = GPR1[RT];
8324 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8325 GPR_UW(destreg,i) = (RS_UW(i) & RT_UW(i));
8329 // end-sanitize-r5900
8330 // start-sanitize-r5900
8332 011100,5.RS,5.RT,5.RD,01010101000:MMI1:32::PCEQB
8335 unsigned32 instruction = instruction_0;
8336 int destreg = ((instruction >> 11) & 0x0000001F);
8337 signed_word rs_reg = GPR[RS];
8338 signed_word rs_reg1 = GPR1[RS];
8339 signed_word rt_reg = GPR[RT];
8340 signed_word rt_reg1 = GPR1[RT];
8343 for(i=0;i<BYTES_IN_MMI_REGS;i++)
8345 if (RS_SB(i) == RT_SB(i)) GPR_SB(destreg,i) = 0xFF;
8346 else GPR_SB(destreg,i) = 0;
8351 // end-sanitize-r5900
8352 // start-sanitize-r5900
8354 011100,5.RS,5.RT,5.RD,00110101000:MMI1:32::PCEQH
8357 unsigned32 instruction = instruction_0;
8358 int destreg = ((instruction >> 11) & 0x0000001F);
8359 signed_word rs_reg = GPR[RS];
8360 signed_word rs_reg1 = GPR1[RS];
8361 signed_word rt_reg = GPR[RT];
8362 signed_word rt_reg1 = GPR1[RT];
8365 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
8367 if (RS_SH(i) == RT_SH(i)) GPR_SH(destreg,i) = 0xFFFF;
8368 else GPR_SH(destreg,i) = 0;
8373 // end-sanitize-r5900
8374 // start-sanitize-r5900
8376 011100,5.RS,5.RT,5.RD,00010101000:MMI1:32::PCEQW
8379 unsigned32 instruction = instruction_0;
8380 int destreg = ((instruction >> 11) & 0x0000001F);
8381 signed_word rs_reg = GPR[RS];
8382 signed_word rs_reg1 = GPR1[RS];
8383 signed_word rt_reg = GPR[RT];
8384 signed_word rt_reg1 = GPR1[RT];
8387 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8389 if (RS_SW(i) == RT_SW(i)) GPR_SW(destreg,i) = 0xFFFFFFFF;
8390 else GPR_SW(destreg,i) = 0;
8395 // end-sanitize-r5900
8396 // start-sanitize-r5900
8398 011100,5.RS,5.RT,5.RD,01010001000:MMI0:32::PCGTB
8401 unsigned32 instruction = instruction_0;
8402 int destreg = ((instruction >> 11) & 0x0000001F);
8403 signed_word rs_reg = GPR[RS];
8404 signed_word rs_reg1 = GPR1[RS];
8405 signed_word rt_reg = GPR[RT];
8406 signed_word rt_reg1 = GPR1[RT];
8409 for(i=0;i<BYTES_IN_MMI_REGS;i++)
8411 if (RS_SB(i) > RT_SB(i)) GPR_SB(destreg,i) = 0xFF;
8412 else GPR_SB(destreg,i) = 0;
8417 // end-sanitize-r5900
8418 // start-sanitize-r5900
8420 011100,5.RS,5.RT,5.RD,00110001000:MMI0:32::PCGTH
8423 unsigned32 instruction = instruction_0;
8424 int destreg = ((instruction >> 11) & 0x0000001F);
8425 signed_word rs_reg = GPR[RS];
8426 signed_word rs_reg1 = GPR1[RS];
8427 signed_word rt_reg = GPR[RT];
8428 signed_word rt_reg1 = GPR1[RT];
8431 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
8433 if (RS_SH(i) > RT_SH(i)) GPR_SH(destreg,i) = 0xFFFF;
8434 else GPR_SH(destreg,i) = 0;
8439 // end-sanitize-r5900
8440 // start-sanitize-r5900
8442 011100,5.RS,5.RT,5.RD,00010001000:MMI0:32::PCGTW
8445 unsigned32 instruction = instruction_0;
8446 int destreg = ((instruction >> 11) & 0x0000001F);
8447 signed_word rs_reg = GPR[RS];
8448 signed_word rs_reg1 = GPR1[RS];
8449 signed_word rt_reg = GPR[RT];
8450 signed_word rt_reg1 = GPR1[RT];
8453 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8455 if (RS_SW(i) > RT_SW(i)) GPR_SW(destreg,i) = 0xFFFFFFFF;
8456 else GPR_SW(destreg,i) = 0;
8461 // end-sanitize-r5900
8462 // start-sanitize-r5900
8464 01110000000,5.RT,5.RD,11011101001:MMI3:32::PCPYH
8467 unsigned32 instruction = instruction_0;
8468 int destreg = ((instruction >> 11) & 0x0000001F);
8469 signed_word rt_reg = GPR[RT];
8470 signed_word rt_reg1 = GPR1[RT];
8472 GPR_UH(destreg,7) = GPR_UH(destreg,6) = GPR_UH(destreg,5) = GPR_UH(destreg,4) = RT_UH(4);
8473 GPR_UH(destreg,3) = GPR_UH(destreg,2) = GPR_UH(destreg,1) = GPR_UH(destreg,0) = RT_UH(0);
8477 // end-sanitize-r5900
8478 // start-sanitize-r5900
8480 011100,5.RS,5.RT,5.RD,01110001001:MMI2:32::PCPYLD
8483 unsigned32 instruction = instruction_0;
8484 int destreg = ((instruction >> 11) & 0x0000001F);
8485 signed_word rs_reg = GPR[RS];
8486 signed_word rs_reg1 = GPR1[RS];
8487 signed_word rt_reg = GPR[RT];
8488 signed_word rt_reg1 = GPR1[RT];
8490 GPR_UD(destreg,0) = RT_UD(0);
8491 GPR_UD(destreg,1) = RS_UD(0);
8495 // end-sanitize-r5900
8496 // start-sanitize-r5900
8498 011100,5.RS,5.RT,5.RD,01110101001:MMI3:32::PCPYUD
8501 unsigned32 instruction = instruction_0;
8502 int destreg = ((instruction >> 11) & 0x0000001F);
8503 signed_word rs_reg = GPR[RS];
8504 signed_word rs_reg1 = GPR1[RS];
8505 signed_word rt_reg = GPR[RT];
8506 signed_word rt_reg1 = GPR1[RT];
8508 GPR_UD(destreg,0) = RS_UD(1);
8509 GPR_UD(destreg,1) = RT_UD(1);
8513 // end-sanitize-r5900
8514 // start-sanitize-r5900
8516 011100,5.RS,5.RT,0000011101001001:MMI2:32::PDIVBW
8519 signed_word rs_reg = GPR[RS];
8520 signed_word rs_reg1 = GPR1[RS];
8521 signed_word rt_reg = GPR[RT];
8522 signed_word rt_reg1 = GPR1[RT];
8524 signed32 devisor = RT_SH(0);
8527 LO_SW(0) = -RS_SW(0);
8529 LO_SW(1) = -RS_SW(1);
8531 LO_SW(2) = -RS_SW(2);
8533 LO_SW(3) = -RS_SW(3);
8536 else if (devisor != 0)
8538 LO_SW(0) = RS_SW(0) / devisor;
8539 HI_SW(0) = SIGNEXTEND( (RS_SW(0) % devisor), 16 );
8540 LO_SW(1) = RS_SW(1) / devisor;
8541 HI_SW(1) = SIGNEXTEND( (RS_SW(1) % devisor), 16 );
8542 LO_SW(2) = RS_SW(2) / devisor;
8543 HI_SW(2) = SIGNEXTEND( (RS_SW(2) % devisor), 16 );
8544 LO_SW(3) = RS_SW(3) / devisor;
8545 HI_SW(3) = SIGNEXTEND( (RS_SW(3) % devisor), 16 );
8550 // end-sanitize-r5900
8551 // start-sanitize-r5900
8553 011100,5.RS,5.RT,0000001101101001:MMI3:32::PDIVUW
8556 signed_word rs_reg = GPR[RS];
8557 signed_word rs_reg1 = GPR1[RS];
8558 signed_word rt_reg = GPR[RT];
8559 signed_word rt_reg1 = GPR1[RT];
8563 LO = (signed32)(RS_UW(0) / RT_UW(0));
8564 HI = (signed32)(RS_UW(0) % RT_UW(0));
8568 LO1 = (signed32)(RS_UW(2) / RT_UW(2));
8569 HI1 = (signed32)(RS_UW(2) % RT_UW(2));
8574 // end-sanitize-r5900
8575 // start-sanitize-r5900
8577 011100,5.RS,5.RT,0000001101001001:MMI2:32::PDIVW
8580 signed_word rs_reg = GPR[RS];
8581 signed_word rs_reg1 = GPR1[RS];
8582 signed_word rt_reg = GPR[RT];
8583 signed_word rt_reg1 = GPR1[RT];
8590 else if (RT_UW(0) != 0)
8592 LO = (signed32)(RS_SW(0) / RT_SW(0));
8593 HI = (signed32)(RS_SW(0) % RT_SW(0));
8600 else if (RT_UW(2) != 0)
8602 LO1 = (signed32)(RS_SW(2) / RT_SW(2));
8603 HI1 = (signed32)(RS_SW(2) % RT_SW(2));
8608 // end-sanitize-r5900
8609 // start-sanitize-r5900
8611 01110000000,5.RT,5.RD,11010101001:MMI3:32::PEXCH
8614 unsigned32 instruction = instruction_0;
8615 int destreg = ((instruction >> 11) & 0x0000001F);
8616 signed_word rt_reg = GPR[RT];
8617 signed_word rt_reg1 = GPR1[RT];
8619 GPR_UH(destreg,0) = RT_UH(0);
8620 GPR_UH(destreg,1) = RT_UH(2);
8621 GPR_UH(destreg,2) = RT_UH(1);
8622 GPR_UH(destreg,3) = RT_UH(3);
8623 GPR_UH(destreg,4) = RT_UH(4);
8624 GPR_UH(destreg,5) = RT_UH(6);
8625 GPR_UH(destreg,6) = RT_UH(5);
8626 GPR_UH(destreg,7) = RT_UH(7);
8630 // end-sanitize-r5900
8631 // start-sanitize-r5900
8633 01110000000,5.RT,5.RD,11110101001:MMI3:32::PEXCW
8636 unsigned32 instruction = instruction_0;
8637 int destreg = ((instruction >> 11) & 0x0000001F);
8638 signed_word rt_reg = GPR[RT];
8639 signed_word rt_reg1 = GPR1[RT];
8641 GPR_UW(destreg,0) = RT_UW(0);
8642 GPR_UW(destreg,1) = RT_UW(2);
8643 GPR_UW(destreg,2) = RT_UW(1);
8644 GPR_UW(destreg,3) = RT_UW(3);
8648 // end-sanitize-r5900
8649 // start-sanitize-r5900
8651 01110000000,5.RT,5.RD,11010001001:MMI2:32::PEXOH
8654 unsigned32 instruction = instruction_0;
8655 int destreg = ((instruction >> 11) & 0x0000001F);
8656 signed_word rt_reg = GPR[RT];
8657 signed_word rt_reg1 = GPR1[RT];
8659 GPR_UH(destreg,0) = RT_UH(2);
8660 GPR_UH(destreg,1) = RT_UH(1);
8661 GPR_UH(destreg,2) = RT_UH(0);
8662 GPR_UH(destreg,3) = RT_UH(3);
8663 GPR_UH(destreg,4) = RT_UH(6);
8664 GPR_UH(destreg,5) = RT_UH(5);
8665 GPR_UH(destreg,6) = RT_UH(4);
8666 GPR_UH(destreg,7) = RT_UH(7);
8670 // end-sanitize-r5900
8671 // start-sanitize-r5900
8673 01110000000,5.RT,5.RD,11110001001:MMI2:32::PEXOW
8676 unsigned32 instruction = instruction_0;
8677 int destreg = ((instruction >> 11) & 0x0000001F);
8678 signed_word rt_reg = GPR[RT];
8679 signed_word rt_reg1 = GPR1[RT];
8681 GPR_UW(destreg,0) = RT_UW(2);
8682 GPR_UW(destreg,1) = RT_UW(1);
8683 GPR_UW(destreg,2) = RT_UW(0);
8684 GPR_UW(destreg,3) = RT_UW(3);
8688 // end-sanitize-r5900
8689 // start-sanitize-r5900
8691 01110000000,5.RT,5.RD,11110001000:MMI0:32::PEXT5
8694 unsigned32 instruction = instruction_0;
8695 int destreg = ((instruction >> 11) & 0x0000001F);
8696 signed_word rt_reg = GPR[RT];
8697 signed_word rt_reg1 = GPR1[RT];
8700 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8702 unsigned32 x = RT_UW(i);
8703 GPR_UW(destreg,i) = ((x & (1 << 15)) << (31 - 15))
8704 | ((x & (31 << 10)) << (19 - 10))
8705 | ((x & (31 << 5)) << (11 - 5))
8706 | ((x & (31 << 0)) << (3 - 0));
8711 // end-sanitize-r5900
8712 // start-sanitize-r5900
8714 011100,5.RS,5.RT,5.RD,11010001000:MMI0:32::PEXTLB
8717 unsigned32 instruction = instruction_0;
8718 int destreg = ((instruction >> 11) & 0x0000001F);
8719 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8720 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8721 signed_word rt_reg = GPR[RT];
8722 signed_word rt_reg1 = GPR1[RT];
8724 GPR_UB(destreg,0) = RT_UB(0);
8725 GPR_UB(destreg,1) = RS_UB(0);
8726 GPR_UB(destreg,2) = RT_UB(1);
8727 GPR_UB(destreg,3) = RS_UB(1);
8728 GPR_UB(destreg,4) = RT_UB(2);
8729 GPR_UB(destreg,5) = RS_UB(2);
8730 GPR_UB(destreg,6) = RT_UB(3);
8731 GPR_UB(destreg,7) = RS_UB(3);
8732 GPR_UB(destreg,8) = RT_UB(4);
8733 GPR_UB(destreg,9) = RS_UB(4);
8734 GPR_UB(destreg,10) = RT_UB(5);
8735 GPR_UB(destreg,11) = RS_UB(5);
8736 GPR_UB(destreg,12) = RT_UB(6);
8737 GPR_UB(destreg,13) = RS_UB(6);
8738 GPR_UB(destreg,14) = RT_UB(7);
8739 GPR_UB(destreg,15) = RS_UB(7);
8743 // end-sanitize-r5900
8744 // start-sanitize-r5900
8746 011100,5.RS,5.RT,5.RD,10110001000:MMI0:32::PEXTLH
8749 unsigned32 instruction = instruction_0;
8750 int destreg = ((instruction >> 11) & 0x0000001F);
8751 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8752 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8753 signed_word rt_reg = GPR[RT];
8754 signed_word rt_reg1 = GPR1[RT];
8756 GPR_UH(destreg,0) = RT_UH(0);
8757 GPR_UH(destreg,1) = RS_UH(0);
8758 GPR_UH(destreg,2) = RT_UH(1);
8759 GPR_UH(destreg,3) = RS_UH(1);
8760 GPR_UH(destreg,4) = RT_UH(2);
8761 GPR_UH(destreg,5) = RS_UH(2);
8762 GPR_UH(destreg,6) = RT_UH(3);
8763 GPR_UH(destreg,7) = RS_UH(3);
8767 // end-sanitize-r5900
8768 // start-sanitize-r5900
8770 011100,5.RS,5.RT,5.RD,10010001000:MMI0:32::PEXTLW
8773 unsigned32 instruction = instruction_0;
8774 int destreg = ((instruction >> 11) & 0x0000001F);
8775 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8776 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8777 signed_word rt_reg = GPR[RT];
8778 signed_word rt_reg1 = GPR1[RT];
8780 GPR_UW(destreg,0) = RT_UW(0);
8781 GPR_UW(destreg,1) = RS_UW(0);
8782 GPR_UW(destreg,2) = RT_UW(1);
8783 GPR_UW(destreg,3) = RS_UW(1);
8787 // end-sanitize-r5900
8788 // start-sanitize-r5900
8790 011100,5.RS,5.RT,5.RD,11010101000:MMI1:32::PEXTUB
8793 unsigned32 instruction = instruction_0;
8794 int destreg = ((instruction >> 11) & 0x0000001F);
8795 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8796 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8797 signed_word rt_reg = GPR[RT];
8798 signed_word rt_reg1 = GPR1[RT];
8800 GPR_UB(destreg,0) = RT_UB(8);
8801 GPR_UB(destreg,1) = RS_UB(8);
8802 GPR_UB(destreg,2) = RT_UB(9);
8803 GPR_UB(destreg,3) = RS_UB(9);
8804 GPR_UB(destreg,4) = RT_UB(10);
8805 GPR_UB(destreg,5) = RS_UB(10);
8806 GPR_UB(destreg,6) = RT_UB(11);
8807 GPR_UB(destreg,7) = RS_UB(11);
8808 GPR_UB(destreg,8) = RT_UB(12);
8809 GPR_UB(destreg,9) = RS_UB(12);
8810 GPR_UB(destreg,10) = RT_UB(13);
8811 GPR_UB(destreg,11) = RS_UB(13);
8812 GPR_UB(destreg,12) = RT_UB(14);
8813 GPR_UB(destreg,13) = RS_UB(14);
8814 GPR_UB(destreg,14) = RT_UB(15);
8815 GPR_UB(destreg,15) = RS_UB(15);
8819 // end-sanitize-r5900
8820 // start-sanitize-r5900
8822 011100,5.RS,5.RT,5.RD,10110101000:MMI1:32::PEXTUH
8825 unsigned32 instruction = instruction_0;
8826 int destreg = ((instruction >> 11) & 0x0000001F);
8827 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8828 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8829 signed_word rt_reg = GPR[RT];
8830 signed_word rt_reg1 = GPR1[RT];
8832 GPR_UH(destreg,0) = RT_UH(4);
8833 GPR_UH(destreg,1) = RS_UH(4);
8834 GPR_UH(destreg,2) = RT_UH(5);
8835 GPR_UH(destreg,3) = RS_UH(5);
8836 GPR_UH(destreg,4) = RT_UH(6);
8837 GPR_UH(destreg,5) = RS_UH(6);
8838 GPR_UH(destreg,6) = RT_UH(7);
8839 GPR_UH(destreg,7) = RS_UH(7);
8843 // end-sanitize-r5900
8844 // start-sanitize-r5900
8846 011100,5.RS,5.RT,5.RD,10010101000:MMI1:32::PEXTUW
8849 unsigned32 instruction = instruction_0;
8850 int destreg = ((instruction >> 11) & 0x0000001F);
8851 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8852 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8853 signed_word rt_reg = GPR[RT];
8854 signed_word rt_reg1 = GPR1[RT];
8856 GPR_UW(destreg,0) = RT_UW(2);
8857 GPR_UW(destreg,1) = RS_UW(2);
8858 GPR_UW(destreg,2) = RT_UW(3);
8859 GPR_UW(destreg,3) = RS_UW(3);
8863 // end-sanitize-r5900
8864 // start-sanitize-r5900
8866 011100,5.RS,5.RT,5.RD,10001001001:MMI2:32::PHMADDH
8869 unsigned32 instruction = instruction_0;
8870 int destreg = ((instruction >> 11) & 0x0000001F);
8871 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8872 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8873 signed_word rt_reg = GPR[RT];
8874 signed_word rt_reg1 = GPR1[RT];
8876 GPR_SW(destreg,0) = LO_SW(0) = (RS_SH(1) * RT_SH(1)) + (RS_SH(0) * RT_SH(0));
8877 GPR_SW(destreg,1) = HI_SW(0) = (RS_SH(3) * RT_SH(3)) + (RS_SH(2) * RT_SH(2));
8878 GPR_SW(destreg,2) = LO_SW(2) = (RS_SH(5) * RT_SH(5)) + (RS_SH(4) * RT_SH(4));
8879 GPR_SW(destreg,3) = HI_SW(2) = (RS_SH(7) * RT_SH(7)) + (RS_SH(6) * RT_SH(6));
8883 // end-sanitize-r5900
8884 // start-sanitize-r5900
8886 011100,5.RS,5.RT,5.RD,10101001001:MMI2:32::PHMSUBH
8889 unsigned32 instruction = instruction_0;
8890 int destreg = ((instruction >> 11) & 0x0000001F);
8891 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8892 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8893 signed_word rt_reg = GPR[RT];
8894 signed_word rt_reg1 = GPR1[RT];
8896 GPR_SW(destreg,0) = LO_SW(0) = (RS_SH(1) * RT_SH(1)) - (RS_SH(0) * RT_SH(0));
8897 GPR_SW(destreg,1) = HI_SW(0) = (RS_SH(3) * RT_SH(3)) - (RS_SH(2) * RT_SH(2));
8898 GPR_SW(destreg,2) = LO_SW(2) = (RS_SH(5) * RT_SH(5)) - (RS_SH(4) * RT_SH(4));
8899 GPR_SW(destreg,3) = HI_SW(2) = (RS_SH(7) * RT_SH(7)) - (RS_SH(6) * RT_SH(6));
8903 // end-sanitize-r5900
8904 // start-sanitize-r5900
8906 011100,5.RS,5.RT,5.RD,01010001001:MMI2:32::PINTH
8909 unsigned32 instruction = instruction_0;
8910 int destreg = ((instruction >> 11) & 0x0000001F);
8911 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8912 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8913 signed_word rt_reg = GPR[RT];
8914 signed_word rt_reg1 = GPR1[RT];
8916 GPR_UH(destreg,0) = RT_UH(0);
8917 GPR_UH(destreg,1) = RS_UH(4);
8918 GPR_UH(destreg,2) = RT_UH(1);
8919 GPR_UH(destreg,3) = RS_UH(5);
8920 GPR_UH(destreg,4) = RT_UH(2);
8921 GPR_UH(destreg,5) = RS_UH(6);
8922 GPR_UH(destreg,6) = RT_UH(3);
8923 GPR_UH(destreg,7) = RS_UH(7);
8927 // end-sanitize-r5900
8928 // start-sanitize-r5900
8930 011100,5.RS,5.RT,5.RD,01010101001:MMI3:32::PINTOH
8933 unsigned32 instruction = instruction_0;
8934 int destreg = ((instruction >> 11) & 0x0000001F);
8935 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8936 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8937 signed_word rt_reg = GPR[RT];
8938 signed_word rt_reg1 = GPR1[RT];
8940 GPR_UH(destreg,0) = RT_UH(0);
8941 GPR_UH(destreg,1) = RS_UH(0);
8942 GPR_UH(destreg,2) = RT_UH(2);
8943 GPR_UH(destreg,3) = RS_UH(2);
8944 GPR_UH(destreg,4) = RT_UH(4);
8945 GPR_UH(destreg,5) = RS_UH(4);
8946 GPR_UH(destreg,6) = RT_UH(6);
8947 GPR_UH(destreg,7) = RS_UH(6);
8951 // end-sanitize-r5900
8952 // start-sanitize-r5900
8954 011100,5.RS,00000,5.RD,00000000100:MMINORM:32::PLZCW
8957 unsigned32 instruction = instruction_0;
8958 int destreg = ((instruction >> 11) & 0x0000001F);
8959 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8960 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8962 unsigned long value;
8968 test = !!(value & (1 << 31));
8969 for(i=30; i>=0 && (test == !!(value & (1 << i))); i--)
8971 GPR_UW(destreg,0) = count;
8974 test = !!(value & (1 << 31));
8975 for(i=30; i>=0 && (test == !!(value & (1 << i))); i--)
8977 GPR_UW(destreg,1) = count;
8981 // end-sanitize-r5900
8982 // start-sanitize-r5900
8984 011100,5.RS,5.RT,5.RD,10000001001:MMI2:32::PMADDH
8987 unsigned32 instruction = instruction_0;
8988 int destreg = ((instruction >> 11) & 0x0000001F);
8989 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8990 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8991 signed_word rt_reg = GPR[RT];
8992 signed_word rt_reg1 = GPR1[RT];
8994 GPR_SW(destreg,0) = LO_SW(0) += (RS_SH(0) * RT_SH(0));
8995 LO_SW(1) += (RS_SH(1) * RT_SH(1));
8996 GPR_SW(destreg,1) = HI_SW(0) += (RS_SH(2) * RT_SH(2));
8997 HI_SW(1) += (RS_SH(3) * RT_SH(3));
8998 GPR_SW(destreg,2) = LO_SW(2) += (RS_SH(4) * RT_SH(4));
8999 LO_SW(3) += (RS_SH(5) * RT_SH(5));
9000 GPR_SW(destreg,3) = HI_SW(2) += (RS_SH(6) * RT_SH(6));
9001 HI_SW(3) += (RS_SH(7) * RT_SH(7));
9005 // end-sanitize-r5900
9006 // start-sanitize-r5900
9008 011100,5.RS,5.RT,5.RD,00000101001:MMI3:32::PMADDUW
9011 unsigned32 instruction = instruction_0;
9012 int destreg = ((instruction >> 11) & 0x0000001F);
9013 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9014 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9015 signed_word rt_reg = GPR[RT];
9016 signed_word rt_reg1 = GPR1[RT];
9018 unsigned64 sum0 = U8_4 (HI_SW(0), LO_SW(0));
9019 unsigned64 sum1 = U8_4 (HI_SW(2), LO_SW(2));
9020 unsigned64 prod0 = (unsigned64)RS_UW(0) * (unsigned64)RT_UW(0);
9021 unsigned64 prod1 = (unsigned64)RS_UW(2) * (unsigned64)RT_UW(2);
9024 GPR_UD(destreg,0) = sum0;
9025 GPR_UD(destreg,1) = sum1;
9026 LO = SIGNEXTEND( sum0, 32 );
9027 HI = SIGNEXTEND( VH4_8(sum0), 32 );
9028 LO1 = SIGNEXTEND( sum1, 32 );
9029 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
9033 // end-sanitize-r5900
9034 // start-sanitize-r5900
9036 011100,5.RS,5.RT,5.RD,00000001001:MMI2:32::PMADDW
9039 unsigned32 instruction = instruction_0;
9040 int destreg = ((instruction >> 11) & 0x0000001F);
9041 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9042 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9043 signed_word rt_reg = GPR[RT];
9044 signed_word rt_reg1 = GPR1[RT];
9046 signed64 sum0 = WORD64( HI_SW(0), LO_SW(0) );
9047 signed64 sum1 = WORD64( HI_SW(2), LO_SW(2) );
9048 signed64 prod0 = (signed64)RS_SW(0) * (signed64)RT_SW(0);
9049 signed64 prod1 = (signed64)RS_SW(2) * (signed64)RT_SW(2);
9052 GPR_SD(destreg,0) = sum0;
9053 GPR_SD(destreg,1) = sum1;
9054 LO = SIGNEXTEND( sum0, 32 );
9055 HI = SIGNEXTEND( VH4_8(sum0), 32 );
9056 LO1 = SIGNEXTEND( sum1, 32 );
9057 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
9061 // end-sanitize-r5900
9062 // start-sanitize-r5900
9064 011100,5.RS,5.RT,5.RD,00111001000:MMI0:32::PMAXH
9067 unsigned32 instruction = instruction_0;
9068 int destreg = ((instruction >> 11) & 0x0000001F);
9069 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9070 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9071 signed_word rt_reg = GPR[RT];
9072 signed_word rt_reg1 = GPR1[RT];
9075 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9077 if (RS_SH(i) > RT_SH(i)) GPR_SH(destreg,i) = RS_SH(i);
9078 else GPR_SH(destreg,i) = RT_SH(i);
9083 // end-sanitize-r5900
9084 // start-sanitize-r5900
9086 011100,5.RS,5.RT,5.RD,00011001000:MMI0:32::PMAXW
9089 unsigned32 instruction = instruction_0;
9090 int destreg = ((instruction >> 11) & 0x0000001F);
9091 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9092 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9093 signed_word rt_reg = GPR[RT];
9094 signed_word rt_reg1 = GPR1[RT];
9097 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9099 if (RS_SW(i) > RT_SW(i)) GPR_SW(destreg,i) = RS_SW(i);
9100 else GPR_SW(destreg,i) = RT_SW(i);
9105 // end-sanitize-r5900
9106 // start-sanitize-r5900
9108 0111000000000000,5.RD,01000001001:MMI2:32::PMFHI
9111 unsigned32 instruction = instruction_0;
9112 int destreg = ((instruction >> 11) & 0x0000001F);
9114 GPR_SD(destreg,0) = HI;
9115 GPR_SD(destreg,1) = HI1;
9119 // end-sanitize-r5900
9120 // start-sanitize-r5900
9122 0111000000000000,5.RD,01001001001:MMI2:32::PMFLO
9125 unsigned32 instruction = instruction_0;
9126 int destreg = ((instruction >> 11) & 0x0000001F);
9128 GPR_SD(destreg,0) = LO;
9129 GPR_SD(destreg,1) = LO1;
9133 // end-sanitize-r5900
9134 // start-sanitize-r5900
9136 0111000000000000,5.RD,5.SHIFT,110000:MMINORM:32::PMFHL
9139 unsigned32 instruction = instruction_0;
9140 int op1 = ((instruction >> 6) & 0x0000001F);
9141 int destreg = ((instruction >> 11) & 0x0000001F);
9145 GPR_UW(destreg,0) = LO_UW(0);
9146 GPR_UW(destreg,1) = HI_UW(0);
9147 GPR_UW(destreg,2) = LO_UW(2);
9148 GPR_UW(destreg,3) = HI_UW(2);
9152 GPR_UW(destreg,0) = LO_UW(1);
9153 GPR_UW(destreg,1) = HI_UW(1);
9154 GPR_UW(destreg,2) = LO_UW(3);
9155 GPR_UW(destreg,3) = HI_UW(3);
9159 /* NOTE: This code implements a saturate according to the
9160 figure on page B-115 and not according to the
9161 definition on page B-113 */
9162 signed64 t = ((unsigned64)HI_UW(0) << 32) | (unsigned64)LO_UW(0);
9163 signed64 u = ((unsigned64)HI_UW(2) << 32) | (unsigned64)LO_UW(2);
9164 if ( t > SIGNED64 (0x000000007FFFFFFF) )
9165 GPR_SD(destreg,0) = SIGNED64 (0x000000007FFFFFFF);
9166 else if ( t < - SIGNED64 (0x0000000080000000) )
9167 GPR_SD(destreg,0) = - SIGNED64 (0x0000000080000000);
9169 GPR_SD(destreg,0) = t;
9170 if ( u > SIGNED64 (0x000000007FFFFFFF) )
9171 GPR_SD(destreg,1) = SIGNED64 (0x000000007FFFFFFF);
9172 else if ( u < - SIGNED64 (0x0000000080000000) )
9173 GPR_SD(destreg,1) = - SIGNED64 (0x0000000080000000);
9175 GPR_SD(destreg,1) = u;
9179 GPR_UH(destreg,0) = LO_UH(0);
9180 GPR_UH(destreg,1) = LO_UH(2);
9181 GPR_UH(destreg,2) = HI_UH(0);
9182 GPR_UH(destreg,3) = HI_UH(2);
9183 GPR_UH(destreg,4) = LO_UH(4);
9184 GPR_UH(destreg,5) = LO_UH(6);
9185 GPR_UH(destreg,6) = HI_UH(4);
9186 GPR_UH(destreg,7) = HI_UH(6);
9190 if (LO_SW(0) > 0x7FFF)
9191 GPR_UH(destreg,0) = 0x7FFF;
9192 else if (LO_SW(0) < -0x8000)
9193 GPR_UH(destreg,0) = 0x8000;
9195 GPR_UH(destreg,0) = LO_UH(0);
9196 if (LO_SW(1) > 0x7FFF)
9197 GPR_UH(destreg,1) = 0x7FFF;
9198 else if (LO_SW(1) < -0x8000)
9199 GPR_UH(destreg,1) = 0x8000;
9201 GPR_UH(destreg,1) = LO_UH(2);
9202 if (HI_SW(0) > 0x7FFF)
9203 GPR_UH(destreg,2) = 0x7FFF;
9204 else if (HI_SW(0) < -0x8000)
9205 GPR_UH(destreg,2) = 0x8000;
9207 GPR_UH(destreg,2) = HI_UH(0);
9208 if (HI_SW(1) > 0x7FFF)
9209 GPR_UH(destreg,3) = 0x7FFF;
9210 else if (HI_SW(1) < -0x8000)
9211 GPR_UH(destreg,3) = 0x8000;
9213 GPR_UH(destreg,3) = HI_UH(2);
9214 if (LO_SW(2) > 0x7FFF)
9215 GPR_UH(destreg,4) = 0x7FFF;
9216 else if (LO_SW(2) < -0x8000)
9217 GPR_UH(destreg,4) = 0x8000;
9219 GPR_UH(destreg,4) = LO_UH(4);
9220 if (LO_SW(3) > 0x7FFF)
9221 GPR_UH(destreg,5) = 0x7FFF;
9222 else if (LO_SW(3) < -0x8000)
9223 GPR_UH(destreg,5) = 0x8000;
9225 GPR_UH(destreg,5) = LO_UH(6);
9226 if (HI_SW(2) > 0x7FFF)
9227 GPR_UH(destreg,6) = 0x7FFF;
9228 else if (HI_SW(2) < -0x8000)
9229 GPR_UH(destreg,6) = 0x8000;
9231 GPR_UH(destreg,6) = HI_UH(4);
9232 if (HI_SW(3) > 0x7FFF)
9233 GPR_UH(destreg,7) = 0x7FFF;
9234 else if (HI_SW(3) < -0x8000)
9235 GPR_UH(destreg,7) = 0x8000;
9237 GPR_UH(destreg,7) = HI_UH(6);
9242 // end-sanitize-r5900
9243 // start-sanitize-r5900
9245 011100,5.RS,5.RT,5.RD,00111101000:MMI1:32::PMINH
9248 unsigned32 instruction = instruction_0;
9249 int destreg = ((instruction >> 11) & 0x0000001F);
9250 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9251 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9252 signed_word rt_reg = GPR[RT];
9253 signed_word rt_reg1 = GPR1[RT];
9256 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9258 if (RS_SH(i) < RT_SH(i)) GPR_SH(destreg,i) = RS_SH(i);
9259 else GPR_SH(destreg,i) = RT_SH(i);
9264 // end-sanitize-r5900
9265 // start-sanitize-r5900
9267 011100,5.RS,5.RT,5.RD,00011101000:MMI1:32::PMINW
9270 unsigned32 instruction = instruction_0;
9271 int destreg = ((instruction >> 11) & 0x0000001F);
9272 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9273 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9274 signed_word rt_reg = GPR[RT];
9275 signed_word rt_reg1 = GPR1[RT];
9278 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9280 if (RS_SW(i) < RT_SW(i)) GPR_SW(destreg,i) = RS_SW(i);
9281 else GPR_SW(destreg,i) = RT_SW(i);
9286 // end-sanitize-r5900
9287 // start-sanitize-r5900
9289 011100,5.RS,5.RT,5.RD,10100001001:MMI2:32::PMSUBH
9292 unsigned32 instruction = instruction_0;
9293 int destreg = ((instruction >> 11) & 0x0000001F);
9294 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9295 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9296 signed_word rt_reg = GPR[RT];
9297 signed_word rt_reg1 = GPR1[RT];
9299 GPR_SW(destreg,0) = LO_SW(0) -= (RS_SH(0) * RT_SH(0));
9300 LO_SW(1) -= (RS_SH(1) * RT_SH(1));
9301 GPR_SW(destreg,1) = HI_SW(0) -= (RS_SH(2) * RT_SH(2));
9302 HI_SW(1) -= (RS_SH(3) * RT_SH(3));
9303 GPR_SW(destreg,2) = LO_SW(2) -= (RS_SH(4) * RT_SH(4));
9304 LO_SW(3) -= (RS_SH(5) * RT_SH(5));
9305 GPR_SW(destreg,3) = HI_SW(2) -= (RS_SH(6) * RT_SH(6));
9306 HI_SW(3) -= (RS_SH(7) * RT_SH(7));
9310 // end-sanitize-r5900
9311 // start-sanitize-r5900
9313 011100,5.RS,5.RT,5.RD,00100001001:MMI2:32::PMSUBW
9316 unsigned32 instruction = instruction_0;
9317 int destreg = ((instruction >> 11) & 0x0000001F);
9318 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9319 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9320 signed_word rt_reg = GPR[RT];
9321 signed_word rt_reg1 = GPR1[RT];
9323 signed64 sum0 = WORD64( HI_SW(0), LO_SW(0) );
9324 signed64 sum1 = WORD64( HI_SW(2), LO_SW(2) );
9325 signed64 prod0 = (signed64)RS_SW(0) * (signed64)RT_SW(0);
9326 signed64 prod1 = (signed64)RS_SW(2) * (signed64)RT_SW(2);
9329 GPR_SD(destreg,0) = sum0;
9330 GPR_SD(destreg,1) = sum1;
9331 LO = SIGNEXTEND( sum0, 32 );
9332 HI = SIGNEXTEND( VH4_8(sum0), 32 );
9333 LO1 = SIGNEXTEND( sum1, 32 );
9334 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
9338 // end-sanitize-r5900
9339 // start-sanitize-r5900
9341 011100,5.RS,000000000001000101001:MMI3:32::PMTHI
9344 unsigned32 instruction = instruction_0;
9345 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9346 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9353 // end-sanitize-r5900
9354 // start-sanitize-r5900
9356 011100,5.RS,000000000001001101001:MMI3:32::PMTLO
9359 unsigned32 instruction = instruction_0;
9360 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9361 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9368 // end-sanitize-r5900
9369 // start-sanitize-r5900
9371 011100,5.RS,000000000000000110001:MMINORM:32::PMTHL.LW
9374 unsigned32 instruction = instruction_0;
9375 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9376 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9378 LO_UW(0) = RS_UW(0);
9379 HI_UW(0) = RS_UW(1);
9380 LO_UW(2) = RS_UW(2);
9381 HI_UW(2) = RS_UW(3);
9385 // end-sanitize-r5900
9386 // start-sanitize-r5900
9388 011100,5.RS,5.RT,5.RD,11100001001:MMI2:32::PMULTH
9391 unsigned32 instruction = instruction_0;
9392 int destreg = ((instruction >> 11) & 0x0000001F);
9393 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9394 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9395 signed_word rt_reg = GPR[RT];
9396 signed_word rt_reg1 = GPR1[RT];
9398 GPR_SW(destreg,0) = LO_SW(0) = (RS_SH(0) * RT_SH(0));
9399 LO_SW(1) = (RS_SH(1) * RT_SH(1));
9400 GPR_SW(destreg,1) = HI_SW(0) = (RS_SH(2) * RT_SH(2));
9401 HI_SW(1) = (RS_SH(3) * RT_SH(3));
9402 GPR_SW(destreg,2) = LO_SW(2) = (RS_SH(4) * RT_SH(4));
9403 LO_SW(3) = (RS_SH(5) * RT_SH(5));
9404 GPR_SW(destreg,3) = HI_SW(2) = (RS_SH(6) * RT_SH(6));
9405 HI_SW(3) = (RS_SH(7) * RT_SH(7));
9409 // end-sanitize-r5900
9410 // start-sanitize-r5900
9412 011100,5.RS,5.RT,5.RD,01100101001:MMI3:32::PMULTUW
9415 unsigned32 instruction = instruction_0;
9416 int destreg = ((instruction >> 11) & 0x0000001F);
9417 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9418 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9419 signed_word rt_reg = GPR[RT];
9420 signed_word rt_reg1 = GPR1[RT];
9422 unsigned64 sum0 = 0;
9423 unsigned64 sum1 = 0;
9424 unsigned64 prod0 = (unsigned64)RS_UW(0) * (unsigned64)RT_UW(0);
9425 unsigned64 prod1 = (unsigned64)RS_UW(2) * (unsigned64)RT_UW(2);
9428 GPR_UD(destreg,0) = sum0;
9429 GPR_UD(destreg,1) = sum1;
9430 LO = SIGNEXTEND( sum0, 32 );
9431 HI = SIGNEXTEND( VH4_8(sum0), 32 );
9432 LO1 = SIGNEXTEND( sum1, 32 );
9433 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
9437 // end-sanitize-r5900
9438 // start-sanitize-r5900
9440 011100,5.RS,5.RT,5.RD,01100001001:MMI2:32::PMULTW
9443 unsigned32 instruction = instruction_0;
9444 int destreg = ((instruction >> 11) & 0x0000001F);
9445 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9446 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9447 signed_word rt_reg = GPR[RT];
9448 signed_word rt_reg1 = GPR1[RT];
9452 signed64 prod0 = (signed64)RS_SW(0) * (signed64)RT_SW(0);
9453 signed64 prod1 = (signed64)RS_SW(2) * (signed64)RT_SW(2);
9456 GPR_SD(destreg,0) = sum0;
9457 GPR_SD(destreg,1) = sum1;
9458 LO = SIGNEXTEND( sum0, 32 );
9459 HI = SIGNEXTEND( VH4_8(sum0), 32 );
9460 LO1 = SIGNEXTEND( sum1, 32 );
9461 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
9465 // end-sanitize-r5900
9466 // start-sanitize-r5900
9468 011100,5.RS,5.RT,5.RD,10011101001:MMI3:32::PNOR
9471 unsigned32 instruction = instruction_0;
9472 int destreg = ((instruction >> 11) & 0x0000001F);
9473 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9474 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9475 signed_word rt_reg = GPR[RT];
9476 signed_word rt_reg1 = GPR1[RT];
9479 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9480 GPR_UW(destreg,i) = ~(RS_UW(i) | RT_UW(i));
9484 // end-sanitize-r5900
9485 // start-sanitize-r5900
9487 011100,5.RS,5.RT,5.RD,10010101001:MMI3:32::POR
9490 unsigned32 instruction = instruction_0;
9491 int destreg = ((instruction >> 11) & 0x0000001F);
9492 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9493 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9494 signed_word rt_reg = GPR[RT];
9495 signed_word rt_reg1 = GPR1[RT];
9498 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9499 GPR_UW(destreg,i) = (RS_UW(i) | RT_UW(i));
9503 // end-sanitize-r5900
9504 // start-sanitize-r5900
9506 01110000000,5.RT,5.RD,11111001000:MMI0:32::PPAC5
9509 unsigned32 instruction = instruction_0;
9510 int destreg = ((instruction >> 11) & 0x0000001F);
9511 signed_word rt_reg = GPR[RT];
9512 signed_word rt_reg1 = GPR1[RT];
9515 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9517 unsigned32 x = RT_UW(i);
9518 GPR_UW(destreg,i) = ((x & (1 << 31)) >> (31 - 15))
9519 | ((x & (31 << 19)) >> (19 - 10))
9520 | ((x & (31 << 11)) >> (11 - 5))
9521 | ((x & (31 << 3)) >> (3 - 0));
9526 // end-sanitize-r5900
9527 // start-sanitize-r5900
9529 011100,5.RS,5.RT,5.RD,11011001000:MMI0:32::PPACB
9532 unsigned32 instruction = instruction_0;
9533 int destreg = ((instruction >> 11) & 0x0000001F);
9534 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9535 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9536 signed_word rt_reg = GPR[RT];
9537 signed_word rt_reg1 = GPR1[RT];
9539 GPR_UB(destreg,0) = RT_UB(0);
9540 GPR_UB(destreg,1) = RT_UB(2);
9541 GPR_UB(destreg,2) = RT_UB(4);
9542 GPR_UB(destreg,3) = RT_UB(6);
9543 GPR_UB(destreg,4) = RT_UB(8);
9544 GPR_UB(destreg,5) = RT_UB(10);
9545 GPR_UB(destreg,6) = RT_UB(12);
9546 GPR_UB(destreg,7) = RT_UB(14);
9547 GPR_UB(destreg,8) = RS_UB(0);
9548 GPR_UB(destreg,9) = RS_UB(2);
9549 GPR_UB(destreg,10) = RS_UB(4);
9550 GPR_UB(destreg,11) = RS_UB(6);
9551 GPR_UB(destreg,12) = RS_UB(8);
9552 GPR_UB(destreg,13) = RS_UB(10);
9553 GPR_UB(destreg,14) = RS_UB(12);
9554 GPR_UB(destreg,15) = RS_UB(14);
9558 // end-sanitize-r5900
9559 // start-sanitize-r5900
9561 011100,5.RS,5.RT,5.RD,10111001000:MMI0:32::PPACH
9564 unsigned32 instruction = instruction_0;
9565 int destreg = ((instruction >> 11) & 0x0000001F);
9566 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9567 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9568 signed_word rt_reg = GPR[RT];
9569 signed_word rt_reg1 = GPR1[RT];
9571 GPR_UH(destreg,0) = RT_UH(0);
9572 GPR_UH(destreg,1) = RT_UH(2);
9573 GPR_UH(destreg,2) = RT_UH(4);
9574 GPR_UH(destreg,3) = RT_UH(6);
9575 GPR_UH(destreg,4) = RS_UH(0);
9576 GPR_UH(destreg,5) = RS_UH(2);
9577 GPR_UH(destreg,6) = RS_UH(4);
9578 GPR_UH(destreg,7) = RS_UH(6);
9582 // end-sanitize-r5900
9583 // start-sanitize-r5900
9585 011100,5.RS,5.RT,5.RD,10011001000:MMI0:32::PPACW
9588 unsigned32 instruction = instruction_0;
9589 int destreg = ((instruction >> 11) & 0x0000001F);
9590 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9591 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9592 signed_word rt_reg = GPR[RT];
9593 signed_word rt_reg1 = GPR1[RT];
9595 GPR_UW(destreg,0) = RT_UW(0);
9596 GPR_UW(destreg,1) = RT_UW(2);
9597 GPR_UW(destreg,2) = RS_UW(0);
9598 GPR_UW(destreg,3) = RS_UW(2);
9602 // end-sanitize-r5900
9603 // start-sanitize-r5900
9605 01110000000,5.RT,5.RD,11011001001:MMI2:32::PREVH
9608 unsigned32 instruction = instruction_0;
9609 int destreg = ((instruction >> 11) & 0x0000001F);
9610 signed_word rt_reg = GPR[RT];
9611 signed_word rt_reg1 = GPR1[RT];
9613 GPR_UH(destreg,0) = RT_UH(3);
9614 GPR_UH(destreg,1) = RT_UH(2);
9615 GPR_UH(destreg,2) = RT_UH(1);
9616 GPR_UH(destreg,3) = RT_UH(0);
9617 GPR_UH(destreg,4) = RT_UH(7);
9618 GPR_UH(destreg,5) = RT_UH(6);
9619 GPR_UH(destreg,6) = RT_UH(5);
9620 GPR_UH(destreg,7) = RT_UH(4);
9624 // end-sanitize-r5900
9625 // start-sanitize-r5900
9627 01110000000,5.RT,5.RD,11111001001:MMI2:32::PROT3W
9630 unsigned32 instruction = instruction_0;
9631 int destreg = ((instruction >> 11) & 0x0000001F);
9632 signed_word rt_reg = GPR[RT];
9633 signed_word rt_reg1 = GPR1[RT];
9635 GPR_UW(destreg,0) = RT_UW(0);
9636 GPR_UW(destreg,1) = RT_UW(3);
9637 GPR_UW(destreg,2) = RT_UW(1);
9638 GPR_UW(destreg,3) = RT_UW(2);
9642 // end-sanitize-r5900
9643 // start-sanitize-r5900
9645 01110000000,5.RT,5.RD,5.SHIFT,110100:MMINORM:32::PSLLH
9648 unsigned32 instruction = instruction_0;
9649 int op1 = ((instruction >> 6) & 0x0000001F);
9650 int destreg = ((instruction >> 11) & 0x0000001F);
9651 signed_word rt_reg = GPR[RT];
9652 signed_word rt_reg1 = GPR1[RT];
9654 int shift_by = op1 & (16-1);
9656 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9657 GPR_UH(destreg,i) = (RT_UH(i) << shift_by);
9661 // end-sanitize-r5900
9662 // start-sanitize-r5900
9664 011100,5.RS,5.RT,5.RD,00010001001:MMI2:32::PSLLVW
9667 unsigned32 instruction = instruction_0;
9668 int destreg = ((instruction >> 11) & 0x0000001F);
9669 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9670 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9671 signed_word rt_reg = GPR[RT];
9672 signed_word rt_reg1 = GPR1[RT];
9674 int s0 = (RS_UB(0) & 0x1F);
9675 int s1 = (RS_UB(8) & 0x1F);
9676 signed32 temp0 = RT_UW(0) << s0;
9677 signed32 temp1 = RT_UW(2) << s1;
9678 GPR_SD(destreg,0) = (signed64)temp0;
9679 GPR_SD(destreg,1) = (signed64)temp1;
9683 // end-sanitize-r5900
9684 // start-sanitize-r5900
9686 01110000000,5.RT,5.RD,5.SHIFT,111100:MMINORM:32::PSLLW
9689 unsigned32 instruction = instruction_0;
9690 int op1 = ((instruction >> 6) & 0x0000001F);
9691 int destreg = ((instruction >> 11) & 0x0000001F);
9692 signed_word rt_reg = GPR[RT];
9693 signed_word rt_reg1 = GPR1[RT];
9695 int shift_by = op1 & (32-1);
9697 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9698 GPR_UW(destreg,i) = (RT_UW(i) << shift_by);
9702 // end-sanitize-r5900
9703 // start-sanitize-r5900
9705 01110000000,5.RT,5.RD,5.SHIFT,110111:MMINORM:32::PSRAH
9708 unsigned32 instruction = instruction_0;
9709 int op1 = ((instruction >> 6) & 0x0000001F);
9710 int destreg = ((instruction >> 11) & 0x0000001F);
9711 signed_word rt_reg = GPR[RT];
9712 signed_word rt_reg1 = GPR1[RT];
9714 int shift_by = op1 & (16-1);
9716 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9717 GPR_SH(destreg,i) = SIGNEXTEND( (RT_SH(i) >> shift_by), (16-shift_by) );
9721 // end-sanitize-r5900
9722 // start-sanitize-r5900
9724 011100,5.RS,5.RT,5.RD,00011101001:MMI3:32::PSRAVW
9727 unsigned32 instruction = instruction_0;
9728 int destreg = ((instruction >> 11) & 0x0000001F);
9729 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9730 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9731 signed_word rt_reg = GPR[RT];
9732 signed_word rt_reg1 = GPR1[RT];
9734 GPR_SD(destreg,0) = SIGNEXTEND( (RT_SW (0) >> (RS_UB(0) & 0x1F)), 32-(RS_UB(0) & 0x1F) );
9735 GPR_SD(destreg,1) = SIGNEXTEND( (RT_SW (2) >> (RS_UB(8) & 0x1F)), 32-(RS_UB(8) & 0x1F) );
9739 // end-sanitize-r5900
9740 // start-sanitize-r5900
9742 01110000000,5.RT,5.RD,5.SHIFT,111111:MMINORM:32::PSRAW
9745 unsigned32 instruction = instruction_0;
9746 int op1 = ((instruction >> 6) & 0x0000001F);
9747 int destreg = ((instruction >> 11) & 0x0000001F);
9748 signed_word rt_reg = GPR[RT];
9749 signed_word rt_reg1 = GPR1[RT];
9751 int shift_by = op1 & (32-1);
9753 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9754 GPR_SW(destreg,i) = SIGNEXTEND( (RT_SW(i) >> shift_by), (32-shift_by) );
9758 // end-sanitize-r5900
9759 // start-sanitize-r5900
9761 01110000000,5.RT,5.RD,5.SHIFT,110110:MMINORM:32::PSRLH
9764 unsigned32 instruction = instruction_0;
9765 int op1 = ((instruction >> 6) & 0x0000001F);
9766 int destreg = ((instruction >> 11) & 0x0000001F);
9767 signed_word rt_reg = GPR[RT];
9768 signed_word rt_reg1 = GPR1[RT];
9770 int shift_by = op1 & (16-1);
9772 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9773 GPR_UH(destreg,i) = (RT_UH(i) >> shift_by);
9777 // end-sanitize-r5900
9778 // start-sanitize-r5900
9780 011100,5.RS,5.RT,5.RD,00011001001:MMI2:32::PSRLVW
9783 unsigned32 instruction = instruction_0;
9784 int destreg = ((instruction >> 11) & 0x0000001F);
9785 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9786 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9787 signed_word rt_reg = GPR[RT];
9788 signed_word rt_reg1 = GPR1[RT];
9790 GPR_UD(destreg,0) = SIGNEXTEND ( RT_UW(0) >> (RS_UB(0) & 0x1F), 31);
9791 GPR_UD(destreg,1) = SIGNEXTEND ( RT_UW(2) >> (RS_UB(8) & 0x1F), 31);
9795 // end-sanitize-r5900
9796 // start-sanitize-r5900
9798 01110000000,5.RT,5.RD,5.SHIFT,111110:MMINORM:32::PSRLW
9801 unsigned32 instruction = instruction_0;
9802 int op1 = ((instruction >> 6) & 0x0000001F);
9803 int destreg = ((instruction >> 11) & 0x0000001F);
9804 signed_word rt_reg = GPR[RT];
9805 signed_word rt_reg1 = GPR1[RT];
9807 int shift_by = op1 & (32-1);
9809 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9810 GPR_UW(destreg,i) = (RT_UW(i) >> shift_by);
9814 // end-sanitize-r5900
9815 // start-sanitize-r5900
9817 011100,5.RS,5.RT,5.RD,01001001000:MMI0:32::PSUBB
9820 unsigned32 instruction = instruction_0;
9821 int destreg = ((instruction >> 11) & 0x0000001F);
9822 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9823 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9824 signed_word rt_reg = GPR[RT];
9825 signed_word rt_reg1 = GPR1[RT];
9828 for (i=0; i < BYTES_IN_MMI_REGS; i++)
9833 GPR_SB(destreg,i) = r;
9838 // end-sanitize-r5900
9839 // start-sanitize-r5900
9841 011100,5.RS,5.RT,5.RD,00101001000:MMI0:32::PSUBH
9844 unsigned32 instruction = instruction_0;
9845 int destreg = ((instruction >> 11) & 0x0000001F);
9846 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9847 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9848 signed_word rt_reg = GPR[RT];
9849 signed_word rt_reg1 = GPR1[RT];
9852 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
9857 GPR_SH(destreg,i) = r;
9862 // end-sanitize-r5900
9863 // start-sanitize-r5900
9865 011100,5.RS,5.RT,5.RD,11001001000:MMI0:32::PSUBSB
9868 unsigned32 instruction = instruction_0;
9869 int destreg = ((instruction >> 11) & 0x0000001F);
9870 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9871 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9872 signed_word rt_reg = GPR[RT];
9873 signed_word rt_reg1 = GPR1[RT];
9876 for (i=0; i < BYTES_IN_MMI_REGS; i++)
9882 GPR_SB(destreg,i) = 127;
9884 GPR_SB(destreg,i) = -128;
9886 GPR_SB(destreg,i) = r;
9891 // end-sanitize-r5900
9892 // start-sanitize-r5900
9894 011100,5.RS,5.RT,5.RD,10101001000:MMI0:32::PSUBSH
9897 unsigned32 instruction = instruction_0;
9898 int destreg = ((instruction >> 11) & 0x0000001F);
9899 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9900 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9901 signed_word rt_reg = GPR[RT];
9902 signed_word rt_reg1 = GPR1[RT];
9905 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
9911 GPR_SH(destreg,i) = 32767;
9912 else if (r < -32768)
9913 GPR_SH(destreg,i) = -32768;
9915 GPR_SH(destreg,i) = r;
9920 // end-sanitize-r5900
9921 // start-sanitize-r5900
9923 011100,5.RS,5.RT,5.RD,10001001000:MMI0:32::PSUBSW
9926 unsigned32 instruction = instruction_0;
9927 int destreg = ((instruction >> 11) & 0x0000001F);
9928 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9929 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9930 signed_word rt_reg = GPR[RT];
9931 signed_word rt_reg1 = GPR1[RT];
9934 for (i=0; i < WORDS_IN_MMI_REGS; i++)
9936 signed64 s = RS_SW(i);
9937 signed64 t = RT_SW(i);
9939 if (r > (int)0x7FFFFFFF)
9940 GPR_SW(destreg,i) = (int)0x7FFFFFFF;
9941 else if (r < (int)0x80000000)
9942 GPR_SW(destreg,i) = (int)0x80000000;
9944 GPR_SW(destreg,i) = r;
9949 // end-sanitize-r5900
9950 // start-sanitize-r5900
9952 011100,5.RS,5.RT,5.RD,11001101000:MMI1:32::PSUBUB
9955 unsigned32 instruction = instruction_0;
9956 int destreg = ((instruction >> 11) & 0x0000001F);
9957 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9958 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9959 signed_word rt_reg = GPR[RT];
9960 signed_word rt_reg1 = GPR1[RT];
9963 for (i=0; i < BYTES_IN_MMI_REGS; i++)
9965 unsigned int s = RS_UB(i);
9966 unsigned int t = RT_UB(i);
9967 unsigned int r = s - t;
9969 GPR_UB(destreg,i) = 0;
9971 GPR_UB(destreg,i) = r;
9976 // end-sanitize-r5900
9977 // start-sanitize-r5900
9979 011100,5.RS,5.RT,5.RD,10101101000:MMI1:32::PSUBUH
9982 unsigned32 instruction = instruction_0;
9983 int destreg = ((instruction >> 11) & 0x0000001F);
9984 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9985 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9986 signed_word rt_reg = GPR[RT];
9987 signed_word rt_reg1 = GPR1[RT];
9990 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
9992 unsigned int s = RS_UH(i);
9993 unsigned int t = RT_UH(i);
9994 unsigned int r = s - t;
9996 GPR_UH(destreg,i) = 0;
9998 GPR_UH(destreg,i) = r;
10003 // end-sanitize-r5900
10004 // start-sanitize-r5900
10006 011100,5.RS,5.RT,5.RD,10001101000:MMI1:32::PSUBUW
10009 unsigned32 instruction = instruction_0;
10010 int destreg = ((instruction >> 11) & 0x0000001F);
10011 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
10012 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
10013 signed_word rt_reg = GPR[RT];
10014 signed_word rt_reg1 = GPR1[RT];
10017 for (i=0; i < WORDS_IN_MMI_REGS; i++)
10019 unsigned64 s = RS_UW(i);
10020 unsigned64 t = RT_UW(i);
10021 unsigned64 r = s - t;
10022 if (r > 0xFFFFFFFF)
10023 GPR_UW(destreg,i) = 0;
10025 GPR_UW(destreg,i) = r;
10030 // end-sanitize-r5900
10031 // start-sanitize-r5900
10033 011100,5.RS,5.RT,5.RD,00001001000:MMI0:32::PSUBW
10036 unsigned32 instruction = instruction_0;
10037 int destreg = ((instruction >> 11) & 0x0000001F);
10038 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
10039 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
10040 signed_word rt_reg = GPR[RT];
10041 signed_word rt_reg1 = GPR1[RT];
10044 for (i=0; i < WORDS_IN_MMI_REGS; i++)
10046 signed64 s = RS_SW(i);
10047 signed64 t = RT_SW(i);
10048 signed64 r = s - t;
10049 GPR_SW(destreg,i) = r;
10054 // end-sanitize-r5900
10055 // start-sanitize-r5900
10057 011100,5.RS,5.RT,5.RD,10011001001:MMI2:32::PXOR
10060 unsigned32 instruction = instruction_0;
10061 int destreg = ((instruction >> 11) & 0x0000001F);
10062 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
10063 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
10064 signed_word rt_reg = GPR[RT];
10065 signed_word rt_reg1 = GPR1[RT];
10068 for(i=0;i<WORDS_IN_MMI_REGS;i++)
10069 GPR_UW(destreg,i) = (RS_UW(i) ^ RT_UW(i));
10073 // end-sanitize-r5900
10074 // start-sanitize-r5900
10076 011100,5.RS,5.RT,5.RD,11011101000:MMI1:32::QFSRV
10079 unsigned32 instruction = instruction_0;
10080 int destreg = ((instruction >> 11) & 0x0000001F);
10081 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
10082 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
10083 signed_word rt_reg = GPR[RT];
10084 signed_word rt_reg1 = GPR1[RT];
10086 int bytes = (SA / 8) % 16;
10088 SignalException(ReservedInstruction,instruction);
10092 for(i=0;i<(16-bytes);i++)
10093 GPR_SB(destreg,i) = RT_SB(bytes+i);
10095 GPR_SB(destreg,i) = RS_SB(i-(16-bytes));
10100 // end-sanitize-r5900
10101 // start-sanitize-r5900
10103 011111,5.RS,5.RT,16.OFFSET:NORMAL:128::SQ
10106 unsigned32 instruction = instruction_0;
10107 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
10108 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
10109 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
10110 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
10111 signed_word rt_reg = GPR[RT];
10112 signed_word rt_reg1 = GPR1[RT];
10114 address_word vaddr = ((unsigned64)op1 + offset);
10115 address_word paddr;
10117 if ((vaddr & 15) != 0)
10118 SignalExceptionAddressStore();
10121 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
10123 unsigned64 memval = 0;
10124 unsigned64 memval1 = 0;
10125 memval = rsigned_word;
10126 memval1 = rsigned_word1;
10128 StoreMemory(uncached,AccessLength_QUADWORD,memval,memval1,paddr,vaddr,isREAL);
10135 // end-sanitize-r5900
10137 // start-sanitize-cygnus-never
10139 // // FIXME FIXME FIXME What is this instruction?
10140 // 111011,5.RS,5.RT,16.OFFSET:NORMAL:32::<INT>
10145 // // start-sanitize-r5900
10147 // // end-sanitize-r5900
10149 // // start-sanitize-tx19
10151 // // end-sanitize-tx19
10153 // unsigned32 instruction = instruction_0;
10154 // signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
10155 // signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
10156 // signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
10158 // if (CoProcPresent(3))
10159 // SignalException(CoProcessorUnusable);
10161 // SignalException(ReservedInstruction,instruction);
10165 // end-sanitize-cygnus-never
10166 // start-sanitize-cygnus-never
10168 // // FIXME FIXME FIXME What is this?
10169 // 11100,******,00001:RR:16::SDBBP
10172 // unsigned32 instruction = instruction_0;
10173 // if (have_extendval)
10174 // SignalException (ReservedInstruction, instruction);
10176 // SignalException(DebugBreakPoint,instruction);
10180 // end-sanitize-cygnus-never
10181 // start-sanitize-cygnus-never
10183 // // FIXME FIXME FIXME What is this?
10184 // 000000,********************,001110:SPECIAL:32::SDBBP
10187 // unsigned32 instruction = instruction_0;
10189 // SignalException(DebugBreakPoint,instruction);
10193 // end-sanitize-cygnus-never
10194 // start-sanitize-cygnus-never
10196 // // FIXME FIXME FIXME This apparently belongs to the vr4100 which
10197 // // isn't yet reconized by this simulator.
10198 // 000000,5.RS,5.RT,0000000000101000:SPECIAL:32::MADD16
10201 // unsigned32 instruction = instruction_0;
10202 // signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
10203 // signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
10205 // CHECKHILO("Multiply-Add");
10207 // unsigned64 temp = (op1 * op2);
10208 // temp += (SET64HI(VL4_8(HI)) | VL4_8(LO));
10209 // LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
10210 // HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
10215 // end-sanitize-cygnus-never
10216 // start-sanitize-cygnus-never
10218 // // FIXME FIXME FIXME This apparently belongs to the vr4100 which
10219 // // isn't yet reconized by this simulator.
10220 // 000000,5.RS,5.RT,0000000000101001:SPECIAL:64::DMADD16
10223 // unsigned32 instruction = instruction_0;
10224 // signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
10225 // signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
10227 // CHECKHILO("Multiply-Add");
10229 // unsigned64 temp = (op1 * op2);
10235 // start-sanitize-cygnus-never