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:true
20 // IGEN config - mipsI..
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:true
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
47 // Pseudo instructions known by IGEN
50 sim_io_eprintf (SD, "Illegal instruction at address 0x%lx\n",
52 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIGILL);
61 // CPU Instruction Set (mipsI - mipsIV)
65 000000,5.RS,5.RT,5.RD,00000,100000:SPECIAL:32::ADD
66 "add r<RD>, r<RS>, r<RT>"
71 // start-sanitize-r5900
75 // start-sanitize-tx19
79 ALU32_BEGIN (GPR[RS]);
85 001000,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDI
86 "addi r<RT>, r<RS>, IMMEDIATE"
91 // start-sanitize-r5900
95 // start-sanitize-tx19
99 ALU32_BEGIN (GPR[RS]);
100 ALU32_ADD (EXTEND16 (IMMEDIATE));
105 001001,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDIU
106 "add r<RT>, r<RS>, IMMEDIATE"
111 // start-sanitize-r5900
113 // end-sanitize-r5900
115 // start-sanitize-tx19
119 signed32 temp = GPR[RS] + EXTEND16 (IMMEDIATE);
120 GPR[RT] = EXTEND32 (temp);
124 000000,5.RS,5.RT,5.RD,00000,100001:SPECIAL:32::ADDU
129 // start-sanitize-r5900
131 // end-sanitize-r5900
133 // start-sanitize-tx19
137 signed32 temp = GPR[RS] + GPR[RT];
138 GPR[RD] = EXTEND32 (temp);
142 000000,5.RS,5.RT,5.RD,00000,100100:SPECIAL:32::AND
143 "and r<RD>, r<RS>, r<RT>"
148 // start-sanitize-r5900
150 // end-sanitize-r5900
152 // start-sanitize-tx19
156 GPR[RD] = GPR[RS] & GPR[RT];
160 001100,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ANDI
161 "and r<RT>, r<RS>, IMMEDIATE"
165 // start-sanitize-r5900
167 // end-sanitize-r5900
169 // start-sanitize-tx19
173 GPR[RT] = GPR[RS] & IMMEDIATE;
177 000100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQ
178 "beq r<RS>, r<RT>, OFFSET"
183 // start-sanitize-r5900
185 // end-sanitize-r5900
187 // start-sanitize-tx19
191 address_word offset = EXTEND16 (OFFSET) << 2;
192 if (GPR[RS] == GPR[RT])
193 DSPC = (PC + offset);
197 010100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQL
198 "beql r<RS>, r<RT>, <OFFSET>"
202 // start-sanitize-r5900
204 // end-sanitize-r5900
206 // start-sanitize-tx19
210 address_word offset = EXTEND16 (OFFSET) << 2;
211 if (GPR[RS] == GPR[RT])
212 DSPC = (PC + offset);
218 000001,5.RS,00001,16.OFFSET:REGIMM:32::BGEZ
219 "bgez r<RS>, <OFFSET>"
224 // start-sanitize-r5900
226 // end-sanitize-r5900
228 // start-sanitize-tx19
232 address_word offset = EXTEND16 (OFFSET) << 2;
234 DSPC = (PC + offset);
238 000001,5.RS!31,10001,16.OFFSET:REGIMM:32::BGEZAL
239 "bgezal r<RS>, <OFFSET>"
244 // start-sanitize-r5900
246 // end-sanitize-r5900
248 // start-sanitize-tx19
252 address_word offset = EXTEND16 (OFFSET) << 2;
255 DSPC = (PC + offset);
259 000001,5.RS!31,10011,16.OFFSET:REGIMM:32::BGEZALL
260 "bgezall r<RS>, <OFFSET>"
264 // start-sanitize-r5900
266 // end-sanitize-r5900
268 // start-sanitize-tx19
272 address_word offset = EXTEND16 (OFFSET) << 2;
274 /* NOTE: The branch occurs AFTER the next instruction has been
277 DSPC = (PC + offset);
283 000001,5.RS,00011,16.OFFSET:REGIMM:32::BGEZL
284 "bgezl r<RS>, <OFFSET>"
288 // start-sanitize-r5900
290 // end-sanitize-r5900
292 // start-sanitize-tx19
296 address_word offset = EXTEND16 (OFFSET) << 2;
298 DSPC = (PC + offset);
304 000111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZ
305 "bgtz r<RS>, <OFFSET>"
310 // start-sanitize-r5900
312 // end-sanitize-r5900
314 // start-sanitize-tx19
318 address_word offset = EXTEND16 (OFFSET) << 2;
320 DSPC = (PC + offset);
324 010111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZL
325 "bgtzl r<RS>, <OFFSET>"
329 // start-sanitize-r5900
331 // end-sanitize-r5900
333 // start-sanitize-tx19
337 address_word offset = EXTEND16 (OFFSET) << 2;
338 /* NOTE: The branch occurs AFTER the next instruction has been
341 DSPC = (PC + offset);
347 000110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZ
348 "blez r<RS>, <OFFSET>"
353 // start-sanitize-r5900
355 // end-sanitize-r5900
357 // start-sanitize-tx19
361 address_word offset = EXTEND16 (OFFSET) << 2;
362 /* NOTE: The branch occurs AFTER the next instruction has been
365 DSPC = (PC + offset);
369 010110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZL
370 "bgezl r<RS>, <OFFSET>"
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
387 DSPC = (PC + offset);
395 000001,5.RS,00000,16.OFFSET:REGIMM:32::BLTZ
396 "bltz r<RS>, <OFFSET>"
401 // start-sanitize-r5900
403 // end-sanitize-r5900
405 // start-sanitize-tx19
409 address_word offset = EXTEND16 (OFFSET) << 2;
411 DSPC = (PC + offset);
415 000001,5.RS!31,10000,16.OFFSET:REGIMM:32::BLTZAL
416 "bltzal r<RS>, <OFFSET>"
421 // start-sanitize-r5900
423 // end-sanitize-r5900
425 // start-sanitize-tx19
429 address_word offset = EXTEND16 (OFFSET) << 2;
431 /* NOTE: The branch occurs AFTER the next instruction has been
434 DSPC = (PC + offset);
438 000001,5.RS!31,10010,16.OFFSET:REGIMM:32::BLTZALL
439 "bltzall r<RS>, <OFFSET>"
443 // start-sanitize-r5900
445 // end-sanitize-r5900
447 // start-sanitize-tx19
451 address_word offset = EXTEND16 (OFFSET) << 2;
454 DSPC = (PC + offset);
460 000001,5.RS,00010,16.OFFSET:REGIMM:32::BLTZL
461 "bltzl r<RS>, <OFFSET>"
465 // start-sanitize-r5900
467 // end-sanitize-r5900
469 // start-sanitize-tx19
473 address_word offset = EXTEND16 (OFFSET) << 2;
474 /* NOTE: The branch occurs AFTER the next instruction has been
477 DSPC = (PC + offset);
483 000101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNE
484 "bne r<RS>, r<RT>, <OFFSET>"
489 // start-sanitize-r5900
491 // end-sanitize-r5900
493 // start-sanitize-tx19
497 address_word offset = EXTEND16 (OFFSET) << 2;
498 if (GPR[RS] != GPR[RT])
499 DSPC = (PC + offset);
503 010101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNEL
504 "bnel r<RS>, r<RT>, <OFFSET>"
508 // start-sanitize-r5900
510 // end-sanitize-r5900
512 // start-sanitize-tx19
516 /* NOTE: The branch occurs AFTER the next instruction has been
518 if (GPR[RS] != GPR[RT])
520 DSPC = (PC + offset);
528 000000,20.CODE,001101:SPECIAL:32::BREAK
534 // start-sanitize-r5900
536 // end-sanitize-r5900
538 // start-sanitize-tx19
542 SignalException(BreakPoint, instruction_0);
546 0100,ZZ!0!1!3,26.COP_FUN:NORMAL:32::COPz
552 // start-sanitize-r5900
554 // end-sanitize-r5900
556 // start-sanitize-tx19
560 decode_coproc (SD, instruction_0);
564 000000,5.RS,5.RT,5.RD,00000,101100:SPECIAL:64::DADD
565 "dadd r<RD>, r<RS>, r<RT>"
568 // start-sanitize-r5900
570 // end-sanitize-r5900
572 // start-sanitize-tx19
576 ALU64_BEGIN (GPR[RS]);
582 011000,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDI
583 "daddi r<RT>, r<RS>, <IMMEDIATE>"
586 // start-sanitize-r5900
588 // end-sanitize-r5900
590 // start-sanitize-tx19
594 ALU64_BEGIN (GPR[RS]);
595 ALU64_ADD (EXTEND16 (IMMEDIATE));
600 011001,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDIU
601 "daddu r<RT>, r<RS>, <IMMEDIATE>"
604 // start-sanitize-r5900
606 // end-sanitize-r5900
608 // start-sanitize-tx19
612 GPR[RT] = GPR[RS] + EXTEND16 (immediate);
616 000000,5.RS,5.RT,5.RD,00000,101101:SPECIAL:64::DADDU
617 "daddu r<RD>, r<RS>, r<RT>"
620 // start-sanitize-r5900
622 // end-sanitize-r5900
624 // start-sanitize-tx19
628 GPR[RD] = GPR[RS] + GPR[RT];
632 000000,5.RS,5.RT,0000000000011110:SPECIAL:64::DDIV
636 // start-sanitize-r5900
638 // end-sanitize-r5900
640 // start-sanitize-tx19
644 CHECKHILO ("Division");
646 signed64 n = GPR[RS];
647 signed64 d = GPR[RT];
650 LO = SIGNED64 (0x8000000000000000);
653 else if (d == -1 && n == SIGNED64 (0x8000000000000000))
655 LO = SIGNED64 (0x8000000000000000);
668 000000,5.RS,5.RT,0000000000,011111:SPECIAL:64::DDIVU
673 // start-sanitize-tx19
677 CHECKHILO ("Division");
679 unsigned64 n = GPR[RS];
680 unsigned64 d = GPR[RT];
683 LO = SIGNED64 (0x8000000000000000);
695 000000,5.RS,5.RT,0000000000011010:SPECIAL:32::DIV
701 // start-sanitize-r5900
703 // end-sanitize-r5900
705 // start-sanitize-tx19
709 CHECKHILO("Division");
711 signed32 n = GPR[RS];
712 signed32 d = GPR[RT];
715 LO = EXTEND32 (0x80000000);
718 else if (d == -1 && d == 0x80000000)
720 LO = EXTEND32 (0x80000000);
725 LO = EXTEND32 (n / d);
726 HI = EXTEND32 (n % d);
732 000000,5.RS,5.RT,0000000000011011:SPECIAL:32::DIVU
738 // start-sanitize-r5900
740 // end-sanitize-r5900
742 // start-sanitize-tx19
746 CHECKHILO ("Division");
748 unsigned32 n = GPR[RS];
749 unsigned32 d = GPR[RT];
752 LO = EXTEND32 (0x80000000);
757 LO = EXTEND32 (n / d);
758 HI = EXTEND32 (n % d);
764 000000,5.RS,5.RT,0000000000011100:SPECIAL:64::DMULT
769 // start-sanitize-tx19
773 CHECKHILO ("Multiplication");
775 signed64 op1 = GPR[RS];
776 signed64 op2 = GPR[RT];
785 /* make it unsigned */
796 /* multuply out the 4 sub products */
797 m00 = (VL4_8 (op1) * VL4_8 (op2));
798 m10 = (VH4_8 (op1) * VL4_8 (op2));
799 m01 = (VL4_8 (op1) * VH4_8 (op2));
800 m11 = (VH4_8 (op1) * VH4_8 (op2));
801 /* add the products */
802 mid = VH4_8 (m00) + VL4_8 (m10) + VL4_8 (m01);
803 lo = U8_4 (mid, m00);
804 hi = m11 + VH4_8 (mid) + VH4_8 (m01) + VH4_8 (m10);
805 /* save the result */
823 000000,5.RS,5.RT,0000000000011101:SPECIAL:64::DMULTU
824 "dmultu r<RS>, r<RT>"
828 // start-sanitize-tx19
832 CHECKHILO ("Multiplication");
834 signed64 op1 = GPR[RS];
835 signed64 op2 = GPR[RT];
843 /* multuply out the 4 sub products */
844 m00 = (VL4_8 (op1) * VL4_8 (op2));
845 m10 = (VH4_8 (op1) * VL4_8 (op2));
846 m01 = (VL4_8 (op1) * VH4_8 (op2));
847 m11 = (VH4_8 (op1) * VH4_8 (op2));
848 /* add the products */
849 mid = VH4_8 (m00) + VL4_8 (m10) + VL4_8 (m01);
850 lo = U8_4 (mid, m00);
851 hi = m11 + VH4_8 (mid) + VH4_8 (m01) + VH4_8 (m10);
852 /* save the result */
859 00000000000,5.RT,5.RD,5.SHIFT,111000:SPECIAL:64::DSLL
860 "dsll r<RD>, r<RT>, <SA>"
863 // start-sanitize-r5900
865 // end-sanitize-r5900
867 // start-sanitize-tx19
872 GPR[RD] = GPR[RT] << s;
876 00000000000,5.RT,5.RD,5.SHIFT,111100:SPECIAL:64::DSLL32
877 "dsll32 r<RD>, r<RT>, <SA>"
880 // start-sanitize-r5900
882 // end-sanitize-r5900
884 // start-sanitize-tx19
889 GPR[RD] = GPR[RT] << s;
893 000000,5.RS,5.RT,5.RD,00000010100:SPECIAL:64::DSLLV
894 "dsllv r<RD>, r<RT>, r<RS>"
897 // start-sanitize-r5900
899 // end-sanitize-r5900
901 // start-sanitize-tx19
905 int s = MASKED64 (GPR[RS], 5, 0);
906 GPR[RD] = GPR[RT] << s;
910 00000000000,5.RT,5.RD,5.SHIFT,111011:SPECIAL:64::DSRA
911 "dsra r<RD>, r<RT>, <SA>"
914 // start-sanitize-r5900
916 // end-sanitize-r5900
918 // start-sanitize-tx19
923 GPR[RD] = ((signed64) GPR[RT]) >> s;
927 00000000000,5.RT,5.RD,5.SHIFT,111111:SPECIAL:64::DSRA32
928 "dsra32 r<RT>, r<RD>, <SA>"
931 // start-sanitize-r5900
933 // end-sanitize-r5900
935 // start-sanitize-tx19
940 GPR[RD] = ((signed64) GPR[RT]) >> s;
944 000000,5.RS,5.RT,5.RD,00000010111:SPECIAL:64::DSRAV
945 "dsra32 r<RT>, r<RD>, r<RS>"
948 // start-sanitize-r5900
950 // end-sanitize-r5900
952 // start-sanitize-tx19
956 int s = MASKED64 (GPR[RS], 5, 0);
957 GPR[RD] = ((signed64) GPR[RT]) >> s;
961 00000000000,5.RT,5.RD,5.SHIFT,111010:SPECIAL:64::DSRL
962 "dsrav r<RD>, r<RT>, <SA>"
965 // start-sanitize-r5900
967 // end-sanitize-r5900
969 // start-sanitize-tx19
974 GPR[RD] = (unsigned64) GPR[RT] >> s;
978 00000000000,5.RT,5.RD,5.SHIFT,111110:SPECIAL:64::DSRL32
979 "dsrl32 r<RD>, r<RT>, <SA>"
982 // start-sanitize-r5900
984 // end-sanitize-r5900
986 // start-sanitize-tx19
991 GPR[RD] = (unsigned64) GPR[RT] >> s;
995 000000,5.RS,5.RT,5.RD,00000010110:SPECIAL:64::DSRLV
996 "dsrl32 r<RD>, r<RT>, r<RS>"
999 // start-sanitize-r5900
1001 // end-sanitize-r5900
1003 // start-sanitize-tx19
1005 // end-sanitize-tx19
1007 int s = MASKED64 (GPR[RS], 5, 0);
1008 GPR[RD] = (unsigned64) GPR[RT] >> s;
1012 000000,5.RS,5.RT,5.RD,00000101110:SPECIAL:64::DSUB
1013 "dsub r<RD>, r<RS>, r<RT>"
1016 // start-sanitize-r5900
1018 // end-sanitize-r5900
1020 // start-sanitize-tx19
1022 // end-sanitize-tx19
1024 ALU64_BEGIN (GPR[RS]);
1025 ALU64_SUB (GPR[RT]);
1026 ALU64_END (GPR[RD]);
1030 000000,5.RS,5.RT,5.RD,00000101111:SPECIAL:64::DSUBU
1031 "dsubu r<RD>, r<RS>, r<RT>"
1034 // start-sanitize-r5900
1036 // end-sanitize-r5900
1038 // start-sanitize-tx19
1040 // end-sanitize-tx19
1042 GPR[RD] = GPR[RS] - GPR[RT];
1046 000010,26.INSTR_INDEX:NORMAL:32::J
1052 // start-sanitize-r5900
1054 // end-sanitize-r5900
1056 // start-sanitize-tx19
1058 // end-sanitize-tx19
1060 /* NOTE: The region used is that of the delay slot and NOT the
1061 current instruction */
1062 address_word region = cia.dp & MASK (63, 28);
1063 DSPC = region | (INSTR_INDEX << 2);
1067 000011,26.INSTR_INDEX:NORMAL:32::JAL
1073 // start-sanitize-r5900
1075 // end-sanitize-r5900
1077 // start-sanitize-tx19
1079 // end-sanitize-tx19
1081 /* NOTE: The region used is that of the delay slot and NOT the
1082 current instruction */
1083 address_word region = cia.dp & MASK (63, 28);
1085 DSPC = region | (INSTR_INDEX << 2);
1089 000000,5.RS,00000,5.RD,00000001001:SPECIAL:32::JALR
1090 "jalr r<RS>":RD == 31
1096 // start-sanitize-r5900
1098 // end-sanitize-r5900
1100 // start-sanitize-tx19
1102 // end-sanitize-tx19
1104 address_word temp = GPR[RS];
1110 000000,5.RS,000000000000000001000:SPECIAL:32::JR
1116 // start-sanitize-r5900
1118 // end-sanitize-r5900
1120 // start-sanitize-tx19
1122 // end-sanitize-tx19
1128 100000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LB
1129 "lb r<RT>, <OFFSET>(r<BASE>)"
1134 // start-sanitize-r5900
1136 // end-sanitize-r5900
1138 // start-sanitize-tx19
1140 // end-sanitize-tx19
1142 unsigned32 instruction = instruction_0;
1143 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1144 int destreg = ((instruction >> 16) & 0x0000001F);
1145 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1147 uword64 vaddr = ((uword64)op1 + offset);
1151 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1154 uword64 memval1 = 0;
1156 unsigned int shift = 0;
1157 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1158 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1160 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1161 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
1162 byte = ((vaddr & mask) ^ (bigend << shift));
1163 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x000000FF),8));
1170 100100,5.BASE,5.RT,16.OFFSET:NORMAL:32::LBU
1171 "lbu r<RT>, <OFFSET>(r<BASE>)"
1176 // start-sanitize-r5900
1178 // end-sanitize-r5900
1180 // start-sanitize-tx19
1182 // end-sanitize-tx19
1184 unsigned32 instruction = instruction_0;
1185 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1186 int destreg = ((instruction >> 16) & 0x0000001F);
1187 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1189 unsigned64 vaddr = ((unsigned64)op1 + offset);
1193 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1195 unsigned64 memval = 0;
1196 unsigned64 memval1 = 0;
1197 unsigned64 mask = 0x7;
1198 unsigned int shift = 0;
1199 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1200 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1202 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1203 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
1204 byte = ((vaddr & mask) ^ (bigend << shift));
1205 GPR[destreg] = (((memval >> (8 * byte)) & 0x000000FF));
1212 110111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LD
1213 "ld r<RT>, <OFFSET>(r<BASE>)"
1216 // start-sanitize-r5900
1218 // end-sanitize-r5900
1220 // start-sanitize-tx19
1222 // end-sanitize-tx19
1224 unsigned32 instruction = instruction_0;
1225 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1226 int destreg = ((instruction >> 16) & 0x0000001F);
1227 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1229 unsigned64 vaddr = ((unsigned64)op1 + offset);
1232 if ((vaddr & 7) != 0)
1233 SignalExceptionAddressLoad();
1236 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1238 unsigned64 memval = 0;
1239 unsigned64 memval1 = 0;
1240 unsigned64 mask = 0x7;
1241 unsigned int shift = 4;
1242 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1243 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1245 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1246 GPR[destreg] = memval;
1253 1101,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDCz
1254 "ldc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1258 // start-sanitize-r5900
1260 // end-sanitize-r5900
1262 // start-sanitize-tx19
1264 // end-sanitize-tx19
1266 unsigned32 instruction = instruction_0;
1267 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1268 int destreg = ((instruction >> 16) & 0x0000001F);
1269 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1271 unsigned64 vaddr = ((unsigned64)op1 + offset);
1274 if ((vaddr & 7) != 0)
1275 SignalExceptionAddressLoad();
1278 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1280 unsigned64 memval = 0;
1281 unsigned64 memval1 = 0;
1282 unsigned64 mask = 0x7;
1283 unsigned int shift = 4;
1284 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1285 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1287 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1288 COP_LD(((instruction >> 26) & 0x3),destreg,memval);;
1295 011010,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDL
1296 "ldl r<RT>, <OFFSET>(r<BASE>)"
1299 // start-sanitize-r5900
1301 // end-sanitize-r5900
1303 // start-sanitize-tx19
1305 // end-sanitize-tx19
1307 unsigned32 instruction = instruction_0;
1308 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1309 int destreg = ((instruction >> 16) & 0x0000001F);
1310 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1312 unsigned64 vaddr = ((unsigned64)op1 + offset);
1316 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1318 unsigned64 memval = 0;
1319 unsigned64 memval1 = 0;
1320 unsigned64 mask = 7;
1321 unsigned int reverse = (ReverseEndian ? mask : 0);
1322 unsigned int bigend = (BigEndianCPU ? mask : 0);
1324 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1325 byte = ((vaddr & mask) ^ bigend);
1328 LoadMemory(&memval,&memval1,uncached,byte,paddr,vaddr,isDATA,isREAL);
1329 GPR[destreg] = ((memval << ((7 - byte) * 8)) | (GPR[destreg] & (((unsigned64)1 << ((7 - byte) * 8)) - 1)));
1336 011011,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDR
1337 "ldr r<RT>, <OFFSET>(r<BASE>)"
1340 // start-sanitize-r5900
1342 // end-sanitize-r5900
1344 // start-sanitize-tx19
1346 // end-sanitize-tx19
1348 unsigned32 instruction = instruction_0;
1349 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1350 int destreg = ((instruction >> 16) & 0x0000001F);
1351 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1353 unsigned64 vaddr = ((unsigned64)op1 + offset);
1357 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1359 unsigned64 memval = 0;
1360 unsigned64 memval1 = 0;
1361 unsigned64 mask = 7;
1362 unsigned int reverse = (ReverseEndian ? mask : 0);
1363 unsigned int bigend = (BigEndianCPU ? mask : 0);
1365 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1366 byte = ((vaddr & mask) ^ bigend);
1369 LoadMemory(&memval,&memval1,uncached,(7 - byte),paddr,vaddr,isDATA,isREAL);
1375 srcmask = ((unsigned64)-1 << (8 * (8 - byte)));
1376 GPR[destreg] = ((GPR[destreg] & srcmask) | (memval >> (8 * byte)));
1384 100001,5.BASE,5.RT,16.OFFSET:NORMAL:32::LH
1385 "lh r<RT>, <OFFSET>(r<BASE>)"
1390 // start-sanitize-r5900
1392 // end-sanitize-r5900
1394 // start-sanitize-tx19
1396 // end-sanitize-tx19
1398 unsigned32 instruction = instruction_0;
1399 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1400 int destreg = ((instruction >> 16) & 0x0000001F);
1401 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1403 unsigned64 vaddr = ((unsigned64)op1 + offset);
1406 if ((vaddr & 1) != 0)
1407 SignalExceptionAddressLoad();
1410 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1412 unsigned64 memval = 0;
1413 unsigned64 memval1 = 0;
1414 unsigned64 mask = 0x7;
1415 unsigned int shift = 1;
1416 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1417 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1419 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1420 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
1421 byte = ((vaddr & mask) ^ (bigend << shift));
1422 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x0000FFFF),16));
1429 100101,5.BASE,5.RT,16.OFFSET:NORMAL:32::LHU
1430 "lhu r<RT>, <OFFSET>(r<BASE>)"
1435 // start-sanitize-r5900
1437 // end-sanitize-r5900
1439 // start-sanitize-tx19
1441 // end-sanitize-tx19
1443 unsigned32 instruction = instruction_0;
1444 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1445 int destreg = ((instruction >> 16) & 0x0000001F);
1446 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1448 unsigned64 vaddr = ((unsigned64)op1 + offset);
1451 if ((vaddr & 1) != 0)
1452 SignalExceptionAddressLoad();
1455 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1457 unsigned64 memval = 0;
1458 unsigned64 memval1 = 0;
1459 unsigned64 mask = 0x7;
1460 unsigned int shift = 1;
1461 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1462 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1464 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1465 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
1466 byte = ((vaddr & mask) ^ (bigend << shift));
1467 GPR[destreg] = (((memval >> (8 * byte)) & 0x0000FFFF));
1474 110000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LL
1475 "ll r<RT>, <OFFSET>(r<BASE>)"
1479 // start-sanitize-r5900
1481 // end-sanitize-r5900
1483 // start-sanitize-tx19
1485 // end-sanitize-tx19
1487 unsigned32 instruction = instruction_0;
1488 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1489 int destreg = ((instruction >> 16) & 0x0000001F);
1490 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1492 unsigned64 vaddr = ((unsigned64)op1 + offset);
1495 if ((vaddr & 3) != 0)
1496 SignalExceptionAddressLoad();
1499 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1501 unsigned64 memval = 0;
1502 unsigned64 memval1 = 0;
1503 unsigned64 mask = 0x7;
1504 unsigned int shift = 2;
1505 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1506 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1508 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1509 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1510 byte = ((vaddr & mask) ^ (bigend << shift));
1511 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
1519 110100,5.BASE,5.RT,16.OFFSET:NORMAL:64::LLD
1520 "lld r<RT>, <OFFSET>(r<BASE>)"
1523 // start-sanitize-r5900
1525 // end-sanitize-r5900
1527 // start-sanitize-tx19
1529 // end-sanitize-tx19
1531 unsigned32 instruction = instruction_0;
1532 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1533 int destreg = ((instruction >> 16) & 0x0000001F);
1534 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1536 unsigned64 vaddr = ((unsigned64)op1 + offset);
1539 if ((vaddr & 7) != 0)
1540 SignalExceptionAddressLoad();
1543 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1545 unsigned64 memval = 0;
1546 unsigned64 memval1 = 0;
1547 unsigned64 mask = 0x7;
1548 unsigned int shift = 4;
1549 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1550 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1552 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1553 GPR[destreg] = memval;
1561 001111,00000,5.RT,16.IMMEDIATE:NORMAL:32::LUI
1562 "lui r<RT>, <IMMEDIATE>"
1567 // start-sanitize-r5900
1569 // end-sanitize-r5900
1571 // start-sanitize-tx19
1573 // end-sanitize-tx19
1575 GPR[RT] = EXTEND32 (IMMEDIATE << 16);
1579 100011,5.BASE,5.RT,16.OFFSET:NORMAL:32::LW
1580 "lw r<RT>, <OFFSET>(r<BASE>)"
1585 // start-sanitize-r5900
1587 // end-sanitize-r5900
1589 // start-sanitize-tx19
1591 // end-sanitize-tx19
1593 unsigned32 instruction = instruction_0;
1594 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1595 int destreg = ((instruction >> 16) & 0x0000001F);
1596 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1598 unsigned64 vaddr = ((unsigned64)op1 + offset);
1601 if ((vaddr & 3) != 0)
1602 SignalExceptionAddressLoad();
1605 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1607 unsigned64 memval = 0;
1608 unsigned64 memval1 = 0;
1609 unsigned64 mask = 0x7;
1610 unsigned int shift = 2;
1611 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1612 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1614 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1615 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1616 byte = ((vaddr & mask) ^ (bigend << shift));
1617 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
1624 1100,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWCz
1625 "lwc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1630 // start-sanitize-r5900
1632 // end-sanitize-r5900
1634 // start-sanitize-tx19
1636 // end-sanitize-tx19
1638 unsigned32 instruction = instruction_0;
1639 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1640 int destreg = ((instruction >> 16) & 0x0000001F);
1641 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1643 unsigned64 vaddr = ((unsigned64)op1 + offset);
1646 if ((vaddr & 3) != 0)
1647 SignalExceptionAddressLoad();
1650 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1652 unsigned64 memval = 0;
1653 unsigned64 memval1 = 0;
1654 unsigned64 mask = 0x7;
1655 unsigned int shift = 2;
1656 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1657 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1659 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1660 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1661 byte = ((vaddr & mask) ^ (bigend << shift));
1662 COP_LW(((instruction >> 26) & 0x3),destreg,(unsigned int)((memval >> (8 * byte)) & 0xFFFFFFFF));
1669 100010,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWL
1670 "lwl r<RT>, <OFFSET>(r<BASE>)"
1675 // start-sanitize-r5900
1677 // end-sanitize-r5900
1679 // start-sanitize-tx19
1681 // end-sanitize-tx19
1683 unsigned32 instruction = instruction_0;
1684 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1685 int destreg = ((instruction >> 16) & 0x0000001F);
1686 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1688 unsigned64 vaddr = ((unsigned64)op1 + offset);
1692 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1694 unsigned64 memval = 0;
1695 unsigned64 memval1 = 0;
1696 unsigned64 mask = 3;
1697 unsigned int reverse = (ReverseEndian ? mask : 0);
1698 unsigned int bigend = (BigEndianCPU ? mask : 0);
1700 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1701 byte = ((vaddr & mask) ^ bigend);
1704 LoadMemory(&memval,&memval1,uncached,byte,paddr,vaddr,isDATA,isREAL);
1705 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
1708 GPR[destreg] = ((memval << ((3 - byte) * 8)) | (GPR[destreg] & (((unsigned64)1 << ((3 - byte) * 8)) - 1)));
1709 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1716 100110,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWR
1717 "lwr r<RT>, <OFFSET>(r<BASE>)"
1722 // start-sanitize-r5900
1724 // end-sanitize-r5900
1726 // start-sanitize-tx19
1728 // end-sanitize-tx19
1730 unsigned32 instruction = instruction_0;
1731 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1732 int destreg = ((instruction >> 16) & 0x0000001F);
1733 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1735 unsigned64 vaddr = ((unsigned64)op1 + offset);
1739 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1741 unsigned64 memval = 0;
1742 unsigned64 memval1 = 0;
1743 unsigned64 mask = 3;
1744 unsigned int reverse = (ReverseEndian ? mask : 0);
1745 unsigned int bigend = (BigEndianCPU ? mask : 0);
1747 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
1748 byte = ((vaddr & mask) ^ bigend);
1751 LoadMemory(&memval,&memval1,uncached,(3 - byte),paddr,vaddr,isDATA,isREAL);
1752 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
1760 srcmask = ((unsigned64)-1 << (8 * (4 - byte)));
1761 GPR[destreg] = ((GPR[destreg] & srcmask) | (memval >> (8 * byte)));
1763 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
1770 100111,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWU
1771 "lwu r<RT>, <OFFSET>(r<BASE>)"
1774 // start-sanitize-r5900
1776 // end-sanitize-r5900
1778 // start-sanitize-tx19
1780 // end-sanitize-tx19
1782 unsigned32 instruction = instruction_0;
1783 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1784 int destreg = ((instruction >> 16) & 0x0000001F);
1785 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1787 unsigned64 vaddr = ((unsigned64)op1 + offset);
1790 if ((vaddr & 3) != 0)
1791 SignalExceptionAddressLoad();
1794 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1796 unsigned64 memval = 0;
1797 unsigned64 memval1 = 0;
1798 unsigned64 mask = 0x7;
1799 unsigned int shift = 2;
1800 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1801 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1803 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1804 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1805 byte = ((vaddr & mask) ^ (bigend << shift));
1806 GPR[destreg] = (((memval >> (8 * byte)) & 0xFFFFFFFF));
1813 000000,0000000000,5.RD,00000,010000:SPECIAL:32::MFHI
1819 // start-sanitize-r5900
1821 // end-sanitize-r5900
1823 // start-sanitize-tx19
1825 // end-sanitize-tx19
1832 000000,0000000000,5.RD,00000,010010:SPECIAL:32::MFLO
1838 // start-sanitize-r5900
1840 // end-sanitize-r5900
1842 // start-sanitize-tx19
1844 // end-sanitize-tx19
1847 LOACCESS = 3; /* 3rd instruction will be safe */
1851 000000,5.RS,5.RT,5.RD,00000001011:SPECIAL:32::MOVN
1852 "movn r<RD>, r<RS>, r<RT>"
1854 // start-sanitize-r5900
1856 // end-sanitize-r5900
1863 000000,5.RS,5.RT,5.RD,00000001010:SPECIAL:32::MOVZ
1864 "movz r<RD>, r<RS>, r<RT>"
1866 // start-sanitize-r5900
1868 // end-sanitize-r5900
1875 000000,5.RS,000000000000000,010001:SPECIAL:32::MTHI
1881 // start-sanitize-r5900
1883 // end-sanitize-r5900
1885 // start-sanitize-tx19
1887 // end-sanitize-tx19
1890 sim_io_eprintf (sd, "MT (move-to) over-writing HI register value\n");
1892 HIACCESS = 3; /* 3rd instruction will be safe */
1896 000000,5.RS,000000000000000010011:SPECIAL:32::MTLO
1902 // start-sanitize-r5900
1904 // end-sanitize-r5900
1906 // start-sanitize-tx19
1908 // end-sanitize-tx19
1911 sim_io_eprintf (sd, "MT (move-to) over-writing LO register value\n");
1913 LOACCESS = 3; /* 3rd instruction will be safe */
1917 000000,5.RS,5.RT,5.RD,00000011000:SPECIAL:32::MULT
1923 // start-sanitize-r5900
1925 // end-sanitize-r5900
1927 // start-sanitize-tx19
1929 // end-sanitize-tx19
1932 CHECKHILO ("Multiplication");
1933 prod = (((signed64)(signed32) GPR[RS])
1934 * ((signed64)(signed32) GPR[RT]));
1935 LO = EXTEND32 (VL4_8 (prod));
1936 HI = EXTEND32 (VH4_8 (prod));
1940 000000,5.RS,5.RT,5.RD,00000011001:SPECIAL:32::MULTU
1941 "multu r<RS>, r<RT>"
1946 // start-sanitize-r5900
1948 // end-sanitize-r5900
1950 // start-sanitize-tx19
1952 // end-sanitize-tx19
1955 CHECKHILO ("Multiplication");
1956 prod = (((unsigned64)(unsigned32) GPR[RS])
1957 * ((unsigned64)(unsigned32) GPR[RT]));
1958 LO = EXTEND32 (VL4_8 (prod));
1959 HI = EXTEND32 (VH4_8 (prod));
1963 000000,5.RS,5.RT,5.RD,00000,100111:SPECIAL:32::NOR
1964 "nor r<RD>, r<RS>, r<RT>"
1969 // start-sanitize-r5900
1971 // end-sanitize-r5900
1973 // start-sanitize-tx19
1975 // end-sanitize-tx19
1977 GPR[RD] = ~ (GPR[RS] | GPR[RT]);
1981 000000,5.RS,5.RT,5.RD,00000,100101:SPECIAL:32::OR
1982 "or r<RD>, r<RS>, r<RT>"
1987 // start-sanitize-r5900
1989 // end-sanitize-r5900
1991 // start-sanitize-tx19
1993 // end-sanitize-tx19
1995 GPR[RD] = (GPR[RS] | GPR[RT]);
1999 001101,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ORI
2000 "ori r<RT>, r<RS>, <IMMEDIATE>"
2005 // start-sanitize-r5900
2007 // end-sanitize-r5900
2009 // start-sanitize-tx19
2011 // end-sanitize-tx19
2013 GPR[RT] = (GPR[RS] | IMMEDIATE);
2017 110011,5.RS,nnnnn,16.OFFSET:NORMAL:32::PREF
2019 // start-sanitize-r5900
2021 // end-sanitize-r5900
2023 unsigned32 instruction = instruction_0;
2024 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2025 int hint = ((instruction >> 16) & 0x0000001F);
2026 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2028 unsigned64 vaddr = ((unsigned64)op1 + offset);
2032 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
2033 Prefetch(uncached,paddr,vaddr,isDATA,hint);
2038 101000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SB
2039 "sb r<RT>, <OFFSET>(r<BASE>)"
2044 // start-sanitize-r5900
2046 // end-sanitize-r5900
2048 // start-sanitize-tx19
2050 // end-sanitize-tx19
2052 unsigned32 instruction = instruction_0;
2053 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2054 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2055 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2057 unsigned64 vaddr = ((unsigned64)op1 + offset);
2061 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2063 unsigned64 memval = 0;
2064 unsigned64 memval1 = 0;
2065 unsigned64 mask = 0x7;
2066 unsigned int shift = 0;
2067 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
2068 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
2070 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
2071 byte = ((vaddr & mask) ^ (bigend << shift));
2072 memval = ((unsigned64) op2 << (8 * byte));
2074 StoreMemory(uncached,AccessLength_BYTE,memval,memval1,paddr,vaddr,isREAL);
2082 111000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SC
2083 "sc r<RT>, <OFFSET>(r<BASE>)"
2087 // start-sanitize-r5900
2089 // end-sanitize-r5900
2091 // start-sanitize-tx19
2093 // end-sanitize-tx19
2095 unsigned32 instruction = instruction_0;
2096 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2097 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2098 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2100 unsigned64 vaddr = ((unsigned64)op1 + offset);
2103 if ((vaddr & 3) != 0)
2104 SignalExceptionAddressStore();
2107 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2109 unsigned64 memval = 0;
2110 unsigned64 memval1 = 0;
2111 unsigned64 mask = 0x7;
2113 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2114 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2115 memval = ((unsigned64) op2 << (8 * byte));
2118 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2120 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
2127 111100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SCD
2128 "scd r<RT>, <OFFSET>(r<BASE>)"
2131 // start-sanitize-r5900
2133 // end-sanitize-r5900
2135 // start-sanitize-tx19
2137 // end-sanitize-tx19
2139 unsigned32 instruction = instruction_0;
2140 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2141 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2142 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2144 unsigned64 vaddr = ((unsigned64)op1 + offset);
2147 if ((vaddr & 7) != 0)
2148 SignalExceptionAddressStore();
2151 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2153 unsigned64 memval = 0;
2154 unsigned64 memval1 = 0;
2158 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2160 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
2167 111111,5.BASE,5.RT,16.OFFSET:NORMAL:64::SD
2168 "sd r<RT>, <OFFSET>(r<BASE>)"
2171 // start-sanitize-r5900
2173 // end-sanitize-r5900
2175 // start-sanitize-tx19
2177 // end-sanitize-tx19
2179 unsigned32 instruction = instruction_0;
2180 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2181 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2182 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2184 unsigned64 vaddr = ((unsigned64)op1 + offset);
2187 if ((vaddr & 7) != 0)
2188 SignalExceptionAddressStore();
2191 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2193 unsigned64 memval = 0;
2194 unsigned64 memval1 = 0;
2197 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2205 1111,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDCz
2206 "sdc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2210 // start-sanitize-r5900
2212 // end-sanitize-r5900
2214 // start-sanitize-tx19
2216 // end-sanitize-tx19
2218 unsigned32 instruction = instruction_0;
2219 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2220 int destreg = ((instruction >> 16) & 0x0000001F);
2221 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2223 unsigned64 vaddr = ((unsigned64)op1 + offset);
2226 if ((vaddr & 7) != 0)
2227 SignalExceptionAddressStore();
2230 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2232 unsigned64 memval = 0;
2233 unsigned64 memval1 = 0;
2234 memval = (unsigned64)COP_SD(((instruction >> 26) & 0x3),destreg);
2236 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2244 101100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDL
2245 "sdl r<RT>, <OFFSET>(r<BASE>)"
2248 // start-sanitize-r5900
2250 // end-sanitize-r5900
2252 // start-sanitize-tx19
2254 // end-sanitize-tx19
2256 unsigned32 instruction = instruction_0;
2257 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2258 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2259 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2261 unsigned64 vaddr = ((unsigned64)op1 + offset);
2265 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2267 unsigned64 memval = 0;
2268 unsigned64 memval1 = 0;
2269 unsigned64 mask = 7;
2270 unsigned int reverse = (ReverseEndian ? mask : 0);
2271 unsigned int bigend = (BigEndianCPU ? mask : 0);
2273 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
2274 byte = ((vaddr & mask) ^ bigend);
2277 memval = (op2 >> (8 * (7 - byte)));
2278 StoreMemory(uncached,byte,memval,memval1,paddr,vaddr,isREAL);
2285 101101,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDR
2286 "sdr r<RT>, <OFFSET>(r<BASE>)"
2289 // start-sanitize-r5900
2291 // end-sanitize-r5900
2293 // start-sanitize-tx19
2295 // end-sanitize-tx19
2297 unsigned32 instruction = instruction_0;
2298 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2299 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2300 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2302 unsigned64 vaddr = ((unsigned64)op1 + offset);
2306 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2308 unsigned64 memval = 0;
2309 unsigned64 memval1 = 0;
2310 unsigned64 mask = 7;
2311 unsigned int reverse = (ReverseEndian ? mask : 0);
2312 unsigned int bigend = (BigEndianCPU ? mask : 0);
2314 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
2315 byte = ((vaddr & mask) ^ bigend);
2318 memval = ((unsigned64) op2 << (byte * 8));
2319 StoreMemory(uncached,(AccessLength_DOUBLEWORD - byte),memval,memval1,paddr,vaddr,isREAL);
2326 101001,5.BASE,5.RT,16.OFFSET:NORMAL:32::SH
2327 "sh r<RT>, <OFFSET>(r<BASE>)"
2332 // start-sanitize-r5900
2334 // end-sanitize-r5900
2336 // start-sanitize-tx19
2338 // end-sanitize-tx19
2340 unsigned32 instruction = instruction_0;
2341 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2342 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2343 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2345 unsigned64 vaddr = ((unsigned64)op1 + offset);
2348 if ((vaddr & 1) != 0)
2349 SignalExceptionAddressStore();
2352 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2354 unsigned64 memval = 0;
2355 unsigned64 memval1 = 0;
2356 unsigned64 mask = 0x7;
2357 unsigned int shift = 1;
2358 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
2359 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
2361 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
2362 byte = ((vaddr & mask) ^ (bigend << shift));
2363 memval = ((unsigned64) op2 << (8 * byte));
2365 StoreMemory(uncached,AccessLength_HALFWORD,memval,memval1,paddr,vaddr,isREAL);
2373 00000000000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLL
2374 "sll r<RD>, r<RT>, <SHIFT>"
2379 // start-sanitize-r5900
2381 // end-sanitize-r5900
2383 // start-sanitize-tx19
2385 // end-sanitize-tx19
2388 unsigned32 temp = (GPR[RT] << s);
2389 GPR[RD] = EXTEND32 (temp);
2393 000000,5.RS,5.RT,5.RD,00000000100:SPECIAL:32::SLLV
2394 "sllv r<RD>, r<RT>, r<RS>"
2399 // start-sanitize-r5900
2401 // end-sanitize-r5900
2403 // start-sanitize-tx19
2405 // end-sanitize-tx19
2407 int s = MASKED (GPR[RS], 4, 0);
2408 unsigned32 temp = (GPR[RT] << s);
2409 GPR[RD] = EXTEND32 (temp);
2413 000000,5.RS,5.RT,5.RD,00000101010:SPECIAL:32::SLT
2414 "slt r<RD>, r<RS>, r<RT>"
2419 // start-sanitize-r5900
2421 // end-sanitize-r5900
2423 // start-sanitize-tx19
2425 // end-sanitize-tx19
2427 GPR[RD] = (GPR[RS] < GPR[RT]);
2431 001010,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTI
2432 "slti r<RT>, r<RS>, <IMMEDIATE>"
2437 // start-sanitize-r5900
2439 // end-sanitize-r5900
2441 // start-sanitize-tx19
2443 // end-sanitize-tx19
2445 GPR[RT] = (GPR[RS] < EXTEND16 (IMMEDIATE));
2449 001011,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTIU
2450 "sltiu r<RT>, r<RS>, <IMMEDIATE>"
2455 // start-sanitize-r5900
2457 // end-sanitize-r5900
2459 // start-sanitize-tx19
2461 // end-sanitize-tx19
2463 GPR[RT] = ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE));
2466 000000,5.RS,5.RT,5.RD,00000101011:SPECIAL:32::SLTU
2467 "sltu r<RD>, r<RS>, r<RT>"
2472 // start-sanitize-r5900
2474 // end-sanitize-r5900
2476 // start-sanitize-tx19
2478 // end-sanitize-tx19
2480 GPR[RD] = ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT]);
2484 000000,00000,5.RT,5.RD,5.SHIFT,000011:SPECIAL:32::SRA
2485 "sra r<RD>, r<RT>, <SHIFT>"
2490 // start-sanitize-r5900
2492 // end-sanitize-r5900
2494 // start-sanitize-tx19
2496 // end-sanitize-tx19
2499 signed32 temp = (signed32) GPR[RT] >> s;
2500 GPR[RD] = EXTEND32 (temp);
2504 000000,5.RS,5.RT,5.RD,00000000111:SPECIAL:32::SRAV
2505 "srav r<RD>, r<RT>, r<RS>"
2510 // start-sanitize-r5900
2512 // end-sanitize-r5900
2514 // start-sanitize-tx19
2516 // end-sanitize-tx19
2518 int s = MASKED (GPR[RS], 4, 0);
2519 signed32 temp = (signed32) GPR[RT] >> s;
2520 GPR[RD] = EXTEND32 (temp);
2524 000000,00000,5.RT,5.RD,5.SHIFT,000010:SPECIAL:32::SRL
2525 "srl r<RD>, r<RT>, <SHIFT>"
2530 // start-sanitize-r5900
2532 // end-sanitize-r5900
2534 // start-sanitize-tx19
2536 // end-sanitize-tx19
2539 unsigned32 temp = (unsigned32) GPR[RT] >> s;
2540 GPR[RD] = EXTEND32 (temp);
2544 000000,5.RS,5.RT,5.RD,00000000110:SPECIAL:32::SRLV
2545 "srlv r<RD>, r<RT>, r<RS>"
2550 // start-sanitize-r5900
2552 // end-sanitize-r5900
2554 // start-sanitize-tx19
2556 // end-sanitize-tx19
2558 int s = MASKED (GPR[RS], 4, 0);
2559 unsigned32 temp = (unsigned32) GPR[RT] >> s;
2560 GPR[RD] = EXTEND32 (temp);
2564 000000,5.RS,5.RT,5.RD,00000100010:SPECIAL:32::SUB
2565 "sub r<RD>, r<RS>, r<RT>"
2570 // start-sanitize-r5900
2572 // end-sanitize-r5900
2574 // start-sanitize-tx19
2576 // end-sanitize-tx19
2578 ALU32_BEGIN (GPR[RS]);
2579 ALU32_SUB (GPR[RT]);
2580 ALU32_END (GPR[RD]);
2584 000000,5.RS,5.RT,5.RD,00000100011:SPECIAL:32::SUBU
2585 "subu r<RD>, r<RS>, r<RT>"
2590 // start-sanitize-r5900
2592 // end-sanitize-r5900
2594 // start-sanitize-tx19
2596 // end-sanitize-tx19
2598 GPR[RD] = EXTEND32 (GPR[RS] - GPR[RT]);
2602 101011,5.BASE,5.RT,16.OFFSET:NORMAL:32::SW
2603 "sw r<RT>, <OFFSET>(r<BASE>)"
2608 // start-sanitize-r5900
2610 // end-sanitize-r5900
2612 // start-sanitize-tx19
2614 // end-sanitize-tx19
2616 unsigned32 instruction = instruction_0;
2617 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2618 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2619 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2621 unsigned64 vaddr = ((unsigned64)op1 + offset);
2624 if ((vaddr & 3) != 0)
2625 SignalExceptionAddressStore();
2628 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2630 unsigned64 memval = 0;
2631 unsigned64 memval1 = 0;
2632 unsigned64 mask = 0x7;
2634 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2635 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2636 memval = ((unsigned64) op2 << (8 * byte));
2638 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2646 1110,ZZ!0!1!3,5.RS,5.RT,16.OFFSET:NORMAL:32::SWCz
2647 "swc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2652 // start-sanitize-r5900
2654 // end-sanitize-r5900
2656 // start-sanitize-tx19
2658 // end-sanitize-tx19
2660 unsigned32 instruction = instruction_0;
2661 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2662 int destreg = ((instruction >> 16) & 0x0000001F);
2663 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2665 unsigned64 vaddr = ((unsigned64)op1 + offset);
2668 if ((vaddr & 3) != 0)
2669 SignalExceptionAddressStore();
2672 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2674 unsigned64 memval = 0;
2675 unsigned64 memval1 = 0;
2676 unsigned64 mask = 0x7;
2678 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2679 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2680 memval = (((unsigned64)COP_SW(((instruction >> 26) & 0x3),destreg)) << (8 * byte));
2682 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2690 101010,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWL
2691 "swl r<RT>, <OFFSET>(r<BASE>)"
2696 // start-sanitize-r5900
2698 // end-sanitize-r5900
2700 // start-sanitize-tx19
2702 // end-sanitize-tx19
2704 unsigned32 instruction = instruction_0;
2705 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2706 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2707 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2709 unsigned64 vaddr = ((unsigned64)op1 + offset);
2713 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2715 unsigned64 memval = 0;
2716 unsigned64 memval1 = 0;
2717 unsigned64 mask = 3;
2718 unsigned int reverse = (ReverseEndian ? mask : 0);
2719 unsigned int bigend = (BigEndianCPU ? mask : 0);
2721 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
2722 byte = ((vaddr & mask) ^ bigend);
2725 memval = (op2 >> (8 * (3 - byte)));
2726 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
2729 StoreMemory(uncached,byte,memval,memval1,paddr,vaddr,isREAL);
2736 101110,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWR
2737 "swr r<RT>, <OFFSET>(r<BASE>)"
2742 // start-sanitize-r5900
2744 // end-sanitize-r5900
2746 // start-sanitize-tx19
2748 // end-sanitize-tx19
2750 unsigned32 instruction = instruction_0;
2751 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2752 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2753 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2755 unsigned64 vaddr = ((unsigned64)op1 + offset);
2759 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2761 unsigned64 memval = 0;
2762 unsigned64 memval1 = 0;
2763 unsigned64 mask = 3;
2764 unsigned int reverse = (ReverseEndian ? mask : 0);
2765 unsigned int bigend = (BigEndianCPU ? mask : 0);
2767 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverse));
2768 byte = ((vaddr & mask) ^ bigend);
2771 memval = ((unsigned64) op2 << (byte * 8));
2772 if ((vaddr & (1 << 2)) ^ (BigEndianCPU << 2)) {
2775 StoreMemory(uncached,(AccessLength_WORD - byte),memval,memval1,paddr,vaddr,isREAL);
2782 000000000000000000000,5.STYPE,001111:SPECIAL:32::SYNC
2788 // start-sanitize-r5900
2790 // end-sanitize-r5900
2792 // start-sanitize-tx19
2794 // end-sanitize-tx19
2796 SyncOperation (sd, STYPE);
2800 000000,20.CODE,001100:SPECIAL:32::SYSCALL
2806 // start-sanitize-r5900
2808 // end-sanitize-r5900
2810 // start-sanitize-tx19
2812 // end-sanitize-tx19
2814 SignalException(SystemCall, instruction_0);
2818 000000,5.RS,5.RT,10.CODE,110100:SPECIAL:32::TEQ
2823 // start-sanitize-r5900
2825 // end-sanitize-r5900
2827 // start-sanitize-tx19
2829 // end-sanitize-tx19
2831 if (GPR[RS] == GPR[RT])
2832 SignalException(Trap, instruction_0);
2836 000001,5.RS,01100,16.IMMEDIATE:REGIMM:32::TEQI
2837 "teqi r<RS>, <IMMEDIATE>"
2841 // start-sanitize-r5900
2843 // end-sanitize-r5900
2845 // start-sanitize-tx19
2847 // end-sanitize-tx19
2849 if (GPR[RS] == EXTEND16 (IMMEDIATE))
2850 SignalException(Trap, instruction_0);
2854 000000,5.RS,5.RT,10.CODE,110000:SPECIAL:32::TGE
2859 // start-sanitize-r5900
2861 // end-sanitize-r5900
2863 // start-sanitize-tx19
2865 // end-sanitize-tx19
2867 if (GPR[RS] >= GPR[RT])
2868 SignalException(Trap, instruction_0);
2872 000001,5.RS,01000,16.IMMEDIATE:REGIMM:32::TGEI
2873 "tgei r<RS>, <IMMEDIATE>"
2877 // start-sanitize-r5900
2879 // end-sanitize-r5900
2881 // start-sanitize-tx19
2883 // end-sanitize-tx19
2885 if (GPR[RS] >= EXTEND16 (IMMEDIATE))
2886 SignalException(Trap, instruction_0);
2890 000001,5.RS,01001,16.IMMEDIATE:REGIMM:32::TGEIU
2891 "tgeiu r<RS>, <IMMEDIATE>"
2895 // start-sanitize-r5900
2897 // end-sanitize-r5900
2899 // start-sanitize-tx19
2901 // end-sanitize-tx19
2903 if ((unsigned_word) GPR[RS] >= (unsigned_word) EXTEND16 (IMMEDIATE))
2904 SignalException(Trap, instruction_0);
2908 000000,5.RS,5.RT,10.CODE,110001:SPECIAL:32::TGEU
2913 // start-sanitize-r5900
2915 // end-sanitize-r5900
2917 // start-sanitize-tx19
2919 // end-sanitize-tx19
2921 if ((unsigned_word) GPR[RS] >= (unsigned_word) GPR[RT])
2922 SignalException(Trap, instruction_0);
2926 000000,5.RS,5.RT,10.CODE,110010:SPECIAL:32::TLT
2931 // start-sanitize-r5900
2933 // end-sanitize-r5900
2935 // start-sanitize-tx19
2937 // end-sanitize-tx19
2939 if (GPR[RS] < GPR[RT])
2940 SignalException(Trap, instruction_0);
2944 000001,5.RS,01010,16.IMMEDIATE:REGIMM:32::TLTI
2945 "tlti r<RS>, <IMMEDIATE>"
2949 // start-sanitize-r5900
2951 // end-sanitize-r5900
2953 // start-sanitize-tx19
2955 // end-sanitize-tx19
2957 if (GPR[RS] < EXTEND16 (IMMEDIATE))
2958 SignalException(Trap, instruction_0);
2962 000001,5.RS,01011,16.IMMEDIATE:REGIMM:32::TLTIU
2963 "tltiu r<RS>, <IMMEDIATE>"
2967 // start-sanitize-r5900
2969 // end-sanitize-r5900
2971 // start-sanitize-tx19
2973 // end-sanitize-tx19
2975 if ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE))
2976 SignalException(Trap, instruction_0);
2980 000000,5.RS,5.RT,10.CODE,110011:SPECIAL:32::TLTU
2985 // start-sanitize-r5900
2987 // end-sanitize-r5900
2989 // start-sanitize-tx19
2991 // end-sanitize-tx19
2993 if ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT])
2994 SignalException(Trap, instruction_0);
2998 000000,5.RS,5.RT,10.CODE,110110:SPECIAL:32::TNE
3003 // start-sanitize-r5900
3005 // end-sanitize-r5900
3007 // start-sanitize-tx19
3009 // end-sanitize-tx19
3011 if (GPR[RS] != GPR[RT])
3012 SignalException(Trap, instruction_0);
3016 000001,5.RS,01110,16.IMMEDIATE:REGIMM:32::TNEI
3017 "tne r<RS>, <IMMEDIATE>"
3021 // start-sanitize-r5900
3023 // end-sanitize-r5900
3025 // start-sanitize-tx19
3027 // end-sanitize-tx19
3029 if (GPR[RS] != EXTEND16 (IMMEDIATE))
3030 SignalException(Trap, instruction_0);
3034 000000,5.RS,5.RT,5.RD,00000100110:SPECIAL:32::XOR
3035 "xor r<RD>, r<RS>, r<RT>"
3040 // start-sanitize-r5900
3042 // end-sanitize-r5900
3044 // start-sanitize-tx19
3046 // end-sanitize-tx19
3048 GPR[RD] = GPR[RS] ^ GPR[RT];
3052 001110,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::XORI
3053 "xori r<RT>, r<RS>, <IMMEDIATE>"
3058 // start-sanitize-r5900
3060 // end-sanitize-r5900
3062 // start-sanitize-tx19
3064 // end-sanitize-tx19
3066 GPR[RT] = GPR[RS] ^ IMMEDIATE;
3071 // MIPS Architecture:
3073 // FPU Instruction Set (COP1 & COP1X)
3081 case fmt_single: return "s";
3082 case fmt_double: return "d";
3083 case fmt_word: return "w";
3084 case fmt_long: return "l";
3085 default: return "?";
3109 case 00: return "f";
3110 case 01: return "un";
3111 case 02: return "eq";
3112 case 03: return "ueq";
3113 case 04: return "olt";
3114 case 05: return "ult";
3115 case 06: return "ole";
3116 case 07: return "ule";
3117 case 010: return "sf";
3118 case 011: return "ngle";
3119 case 012: return "seq";
3120 case 013: return "ngl";
3121 case 014: return "lt";
3122 case 015: return "nge";
3123 case 016: return "le";
3124 case 017: return "ngt";
3125 default: return "?";
3130 010001,10,3.FMT,00000,5.FS,5.FD,000101:COP1:32,f::ABS.fmt
3131 "abs.%s<FMT> f<FD>, f<FS>"
3136 // start-sanitize-r5900
3138 // end-sanitize-r5900
3140 // start-sanitize-tx19
3142 // end-sanitize-tx19
3144 unsigned32 instruction = instruction_0;
3145 int destreg = ((instruction >> 6) & 0x0000001F);
3146 int fs = ((instruction >> 11) & 0x0000001F);
3147 int format = ((instruction >> 21) & 0x00000007);
3149 if ((format != fmt_single) && (format != fmt_double))
3150 SignalException(ReservedInstruction,instruction);
3152 StoreFPR(destreg,format,AbsoluteValue(ValueFPR(fs,format),format));
3159 010001,10,3.FMT,5.FT,5.FS,5.FD,000000:COP1:32,f::ADD
3160 "add.%s<FMT> f<FD>, f<FS>, f<FT>"
3165 // start-sanitize-r5900
3167 // end-sanitize-r5900
3169 // start-sanitize-tx19
3171 // end-sanitize-tx19
3173 unsigned32 instruction = instruction_0;
3174 int destreg = ((instruction >> 6) & 0x0000001F);
3175 int fs = ((instruction >> 11) & 0x0000001F);
3176 int ft = ((instruction >> 16) & 0x0000001F);
3177 int format = ((instruction >> 21) & 0x00000007);
3179 if ((format != fmt_single) && (format != fmt_double))
3180 SignalException(ReservedInstruction, instruction);
3182 StoreFPR(destreg,format,Add(ValueFPR(fs,format),ValueFPR(ft,format),format));
3188 // FIXME: This does not correctly resolve mipsI-mipsIV differences.
3194 010001,01000,3.CC,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1
3195 "bc1%s<TF>%s<ND> <OFFSET>":CC == 0
3196 "bc1%s<TF>%s<ND> <CC>, <OFFSET>"
3201 // start-sanitize-r5900
3203 // end-sanitize-r5900
3205 // start-sanitize-tx19
3207 // end-sanitize-tx19
3209 unsigned32 instruction = instruction_0;
3210 signed_word offset = SIGNEXTEND((signed_word)(((instruction >> 0) & 0x0000FFFF) << 2),18);
3211 int boolean = ((instruction >> 16) & 0x00000001);
3212 int likely = ((instruction >> 17) & 0x00000001);
3213 int condition_code = ((instruction >> 18) & 0x00000007);
3215 if (condition_code != 0)
3216 SignalException(ReservedInstruction,instruction);
3218 int condition = (PREVCOC1() == boolean);
3219 /* NOTE: The branch occurs AFTER the next instruction has been executed */
3221 DSPC = (PC + offset);
3232 // FIXME: This does not correctly differentiate between mips*
3234 010001,10,3.FMT,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32::C.cond.fmt
3235 "c.%s<COND>.%s<FMT> f<FS>, f<FT>":CC == 0
3236 "c.%s<COND>.%s<FMT> <CC>, f<FS>, f<FT>"
3241 // start-sanitize-r5900
3243 // end-sanitize-r5900
3245 // start-sanitize-tx19
3247 // end-sanitize-tx19
3249 unsigned32 instruction = instruction_0;
3250 int cmpflags = ((instruction >> 0) & 0x0000000F);
3251 int condition_code = ((instruction >> 8) & 0x00000007);
3252 int fs = ((instruction >> 11) & 0x0000001F);
3253 int ft = ((instruction >> 16) & 0x0000001F);
3254 int format = ((instruction >> 21) & 0x00000007);
3255 if (condition_code != 0)
3257 SignalException(ReservedInstruction,instruction);
3261 if ((format != fmt_single) && (format != fmt_double))
3262 SignalException(ReservedInstruction,instruction);
3264 if (condition_code != 0)
3265 SignalException(ReservedInstruction,instruction);
3272 unsigned64 ofs = ValueFPR(fs,format);
3273 unsigned64 oft = ValueFPR(ft,format);
3274 if (NaN(ofs,format) || NaN(oft,format)) {
3275 if (FCSR & FP_ENABLE(IO)) {
3276 FCSR |= FP_CAUSE(IO);
3277 SignalExceptionFPE();
3281 less = Less(ofs,oft,format);
3282 equal = Equal(ofs,oft,format);
3286 int condition = (((cmpflags & (1 << 2)) && less) || ((cmpflags & (1 << 1)) && equal) || ((cmpflags & (1 << 0)) && unordered));
3287 SETFCC(condition_code,condition);
3295 010001,10,3.FMT,00000,5.FS,5.FD,001010:COP1:64::CEIL.L.fmt
3296 "ceil.l.%s<FMT> f<FD>, f<FS>"
3299 // start-sanitize-r5900
3301 // end-sanitize-r5900
3303 // start-sanitize-tx19
3305 // end-sanitize-tx19
3307 unsigned32 instruction = instruction_0;
3308 int destreg = ((instruction >> 6) & 0x0000001F);
3309 int fs = ((instruction >> 11) & 0x0000001F);
3310 int format = ((instruction >> 21) & 0x00000007);
3312 if ((format != fmt_single) && (format != fmt_double))
3313 SignalException(ReservedInstruction,instruction);
3315 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_long));
3320 010001,10,3.FMT,00000,5.FS,5.FD,001110:COP1:32::CEIL.W
3324 // start-sanitize-r5900
3326 // end-sanitize-r5900
3328 // start-sanitize-tx19
3330 // end-sanitize-tx19
3332 unsigned32 instruction = instruction_0;
3333 int destreg = ((instruction >> 6) & 0x0000001F);
3334 int fs = ((instruction >> 11) & 0x0000001F);
3335 int format = ((instruction >> 21) & 0x00000007);
3337 if ((format != fmt_single) && (format != fmt_double))
3338 SignalException(ReservedInstruction,instruction);
3340 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_word));
3347 01000100,x,10,kkkkk,vvvvv,00000000000:COP1S:32::CxC1
3352 // start-sanitize-r5900
3354 // end-sanitize-r5900
3356 // start-sanitize-tx19
3358 // end-sanitize-tx19
3360 unsigned32 instruction = instruction_0;
3361 int fs = ((instruction >> 11) & 0x0000001F);
3362 int ft = ((instruction >> 16) & 0x0000001F);
3363 int to = ((instruction >> 23) & 0x00000001);
3367 PENDING_FILL((fs + FCR0IDX),VL4_8(GPR[ft]));
3368 } else if (fs == 31) {
3369 PENDING_FILL((fs + FCR31IDX),VL4_8(GPR[ft]));
3371 PENDING_FILL(COCIDX,0); /* special case */
3372 } else { /* control from */
3374 PENDING_FILL(ft,SIGNEXTEND(FCR0,32));
3375 } else if (fs == 31) {
3376 PENDING_FILL(ft,SIGNEXTEND(FCR31,32));
3384 // FIXME: Does not correctly differentiate between mips*
3386 010001,10,3.FMT,00000,5.FS,5.FD,100001:COP1:32::CVT.D.fmt
3387 "cvt.d.%s<FMT> f<FD>, f<FS>"
3392 // start-sanitize-r5900
3394 // end-sanitize-r5900
3396 // start-sanitize-tx19
3398 // end-sanitize-tx19
3400 unsigned32 instruction = instruction_0;
3401 int destreg = ((instruction >> 6) & 0x0000001F);
3402 int fs = ((instruction >> 11) & 0x0000001F);
3403 int format = ((instruction >> 21) & 0x00000007);
3405 if ((format == fmt_double) | 0)
3406 SignalException(ReservedInstruction,instruction);
3408 StoreFPR(destreg,fmt_double,Convert(GETRM(),ValueFPR(fs,format),format,fmt_double));
3413 010001,10,3.FMT,00000,5.FS,5.FD,100101:COP1:64::CVT.L.fmt
3414 "cvt.l.%s<FMT> f<FD>, f<FS>"
3417 // start-sanitize-r5900
3419 // end-sanitize-r5900
3421 // start-sanitize-tx19
3423 // end-sanitize-tx19
3425 unsigned32 instruction = instruction_0;
3426 int destreg = ((instruction >> 6) & 0x0000001F);
3427 int fs = ((instruction >> 11) & 0x0000001F);
3428 int format = ((instruction >> 21) & 0x00000007);
3430 if ((format == fmt_long) | ((format == fmt_long) || (format == fmt_word)))
3431 SignalException(ReservedInstruction,instruction);
3433 StoreFPR(destreg,fmt_long,Convert(GETRM(),ValueFPR(fs,format),format,fmt_long));
3439 // FIXME: Does not correctly differentiate between mips*
3441 010001,10,3.FMT,00000,5.FS,5.FD,100000:COP1:32::CVT.S.fmt
3442 "cvt.s.%s<FMT> f<FD>, f<FS>"
3447 // start-sanitize-r5900
3449 // end-sanitize-r5900
3451 // start-sanitize-tx19
3453 // end-sanitize-tx19
3455 unsigned32 instruction = instruction_0;
3456 int destreg = ((instruction >> 6) & 0x0000001F);
3457 int fs = ((instruction >> 11) & 0x0000001F);
3458 int format = ((instruction >> 21) & 0x00000007);
3460 if ((format == fmt_single) | 0)
3461 SignalException(ReservedInstruction,instruction);
3463 StoreFPR(destreg,fmt_single,Convert(GETRM(),ValueFPR(fs,format),format,fmt_single));
3468 010001,10,3.FMT,00000,5.FS,5.FD,100100:COP1:32::CVT.W.fmt
3469 "cvt.w.%s<FMT> f<FD>, f<FS>"
3474 // start-sanitize-r5900
3476 // end-sanitize-r5900
3478 // start-sanitize-tx19
3480 // end-sanitize-tx19
3482 unsigned32 instruction = instruction_0;
3483 int destreg = ((instruction >> 6) & 0x0000001F);
3484 int fs = ((instruction >> 11) & 0x0000001F);
3485 int format = ((instruction >> 21) & 0x00000007);
3487 if ((format == fmt_word) | ((format == fmt_long) || (format == fmt_word)))
3488 SignalException(ReservedInstruction,instruction);
3490 StoreFPR(destreg,fmt_word,Convert(GETRM(),ValueFPR(fs,format),format,fmt_word));
3495 010001,10,3.FMT,5.FT,5.FS,5.FD,000011:COP1:32::DIV.fmt
3496 "div.%s<FMT> f<FD>, f<FS>, f<FT>"
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,Divide(ValueFPR(fs,format),ValueFPR(ft,format),format));
3525 01000100,x,01,5.FT,vvvvv,00000000000:COP1S:64::DMxC1
3528 // start-sanitize-r5900
3530 // end-sanitize-r5900
3532 // start-sanitize-tx19
3534 // end-sanitize-tx19
3536 unsigned32 instruction = instruction_0;
3537 int fs = ((instruction >> 11) & 0x0000001F);
3538 int ft = ((instruction >> 16) & 0x0000001F);
3539 int to = ((instruction >> 23) & 0x00000001);
3542 if (SizeFGR() == 64) {
3543 PENDING_FILL((fs + FGRIDX),GPR[ft]);
3545 if ((fs & 0x1) == 0)
3547 PENDING_FILL(((fs + 1) + FGRIDX),VH4_8(GPR[ft]));
3548 PENDING_FILL((fs + FGRIDX),VL4_8(GPR[ft]));
3551 if (SizeFGR() == 64) {
3552 PENDING_FILL(ft,FGR[fs]);
3554 if ((fs & 0x1) == 0) {
3555 PENDING_FILL(ft,(SET64HI(FGR[fs+1]) | FGR[fs]));
3557 PENDING_FILL(ft,SET64HI(0xDEADC0DE) | 0xBAD0BAD0);
3564 010001,10,3.FMT,00000,5.FS,5.FD,001011:COP1:64::FLOOR.L.fmt
3565 "floor.l.%s<FMT> f<FD>, f<FS>"
3568 // start-sanitize-r5900
3570 // end-sanitize-r5900
3572 // start-sanitize-tx19
3574 // end-sanitize-tx19
3576 unsigned32 instruction = instruction_0;
3577 int destreg = ((instruction >> 6) & 0x0000001F);
3578 int fs = ((instruction >> 11) & 0x0000001F);
3579 int format = ((instruction >> 21) & 0x00000007);
3581 if ((format != fmt_single) && (format != fmt_double))
3582 SignalException(ReservedInstruction,instruction);
3584 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_long));
3589 010001,10,3.FMT,00000,5.FS,5.FD,001111:COP1:32::FLOOR.W.fmt
3590 "floor.w.%s<FMT> f<FD>, f<FS>"
3594 // start-sanitize-r5900
3596 // end-sanitize-r5900
3598 // start-sanitize-tx19
3600 // end-sanitize-tx19
3602 unsigned32 instruction = instruction_0;
3603 int destreg = ((instruction >> 6) & 0x0000001F);
3604 int fs = ((instruction >> 11) & 0x0000001F);
3605 int format = ((instruction >> 21) & 0x00000007);
3607 if ((format != fmt_single) && (format != fmt_double))
3608 SignalException(ReservedInstruction,instruction);
3610 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_word));
3616 110101,5.BASE,5.FT,16.OFFSET:COP1:32::LDC1
3619 010011,5.BASE,5.INDEX,5.0,5.FD,000001:COP1X:64::LDXC1
3620 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
3622 // start-sanitize-r5900
3624 // end-sanitize-r5900
3626 unsigned32 instruction = instruction_0;
3627 int destreg = ((instruction >> 6) & 0x0000001F);
3628 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
3629 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
3631 unsigned64 vaddr = ((unsigned64)op1 + op2);
3634 if ((vaddr & 7) != 0)
3635 SignalExceptionAddressLoad();
3638 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
3640 unsigned64 memval = 0;
3641 unsigned64 memval1 = 0;
3642 unsigned64 mask = 0x7;
3643 unsigned int shift = 4;
3644 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
3645 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
3647 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
3648 COP_LD(1,destreg,memval);;
3656 110001,5.BASE,5.FT,16.OFFSET:COP1:32::LWC1
3659 010011,5.BASE,5.INDEX,5.0,5.FD,000000:COP1X:32::LWXC1
3660 "lwxc1 f<FD>, r<INDEX>(r<BASE>)"
3662 // start-sanitize-r5900
3664 // end-sanitize-r5900
3666 unsigned32 instruction = instruction_0;
3667 int destreg = ((instruction >> 6) & 0x0000001F);
3668 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
3669 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
3671 unsigned64 vaddr = ((unsigned64)op1 + op2);
3674 if ((vaddr & 3) != 0)
3675 SignalExceptionAddressLoad();
3678 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
3680 unsigned64 memval = 0;
3681 unsigned64 memval1 = 0;
3682 unsigned64 mask = 0x7;
3683 unsigned int shift = 2;
3684 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
3685 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
3687 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
3688 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
3689 byte = ((vaddr & mask) ^ (bigend << shift));
3690 COP_LW(1,destreg,(unsigned int)((memval >> (8 * byte)) & 0xFFFFFFFF));
3699 // FIXME: Not correct for mips*
3701 010011,5.FR,5.FT,5.FS,5.FD,100,001:COP1X:32::MADD.D
3702 "madd.d f<FD>, f<FR>, f<FS>, f<FT>"
3704 // start-sanitize-r5900
3706 // end-sanitize-r5900
3708 unsigned32 instruction = instruction_0;
3709 int destreg = ((instruction >> 6) & 0x0000001F);
3710 int fs = ((instruction >> 11) & 0x0000001F);
3711 int ft = ((instruction >> 16) & 0x0000001F);
3712 int fr = ((instruction >> 21) & 0x0000001F);
3714 StoreFPR(destreg,fmt_double,Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
3719 010011,5.FR,5.FT,5.FS,5.FD,100,000:COP1X:32::MADD.S
3720 "madd.s f<FD>, f<FR>, f<FS>, f<FT>"
3722 // start-sanitize-r5900
3724 // end-sanitize-r5900
3726 unsigned32 instruction = instruction_0;
3727 int destreg = ((instruction >> 6) & 0x0000001F);
3728 int fs = ((instruction >> 11) & 0x0000001F);
3729 int ft = ((instruction >> 16) & 0x0000001F);
3730 int fr = ((instruction >> 21) & 0x0000001F);
3732 StoreFPR(destreg,fmt_single,Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
3738 010001,00,X,00,5.RT,5.FS,00000000000:COP1S:32::MxC1
3739 "m<X>c1 r<RT>, f<FS>"
3744 // start-sanitize-r5900
3746 // end-sanitize-r5900
3748 // start-sanitize-tx19
3750 // end-sanitize-tx19
3752 unsigned32 instruction = instruction_0;
3753 int fs = ((instruction >> 11) & 0x0000001F);
3754 int ft = ((instruction >> 16) & 0x0000001F);
3755 int to = ((instruction >> 23) & 0x00000001);
3758 if (SizeFGR() == 64) {
3759 PENDING_FILL ((fs + FGRIDX), (SET64HI(0xDEADC0DE) | VL4_8(GPR[ft])));
3761 PENDING_FILL ((fs + FGRIDX), VL4_8(GPR[ft]));
3764 PENDING_FILL (ft, SIGNEXTEND(FGR[fs],32));
3770 010001,10,3.FMT,00000,5.FS,5.FD,000110:COP1:32::MOV.fmt
3771 "mov.%s<FMT> f<FD>, f<FS>"
3776 // start-sanitize-r5900
3778 // end-sanitize-r5900
3780 // start-sanitize-tx19
3782 // end-sanitize-tx19
3784 unsigned32 instruction = instruction_0;
3785 int destreg = ((instruction >> 6) & 0x0000001F);
3786 int fs = ((instruction >> 11) & 0x0000001F);
3787 int format = ((instruction >> 21) & 0x00000007);
3789 StoreFPR(destreg,format,ValueFPR(fs,format));
3795 000000,5.RS,3.CC,0,1.TF,5.RD,00000000001:SPECIAL:32::MOVtf
3796 "mov%s<TF> r<RD>, r<RS>, <CC>"
3798 // start-sanitize-r5900
3800 // end-sanitize-r5900
3802 if (GETFCC(CC) == TF)
3808 010001,10,3.FMT,3.CC,0,1.TF,5.FS,5.FD,010001:COP1:32::MOVtf.fmt
3809 "mov%s<TF>.%s<FMT> f<FD>, f<FS>, <CC>"
3811 // start-sanitize-r5900
3813 // end-sanitize-r5900
3815 unsigned32 instruction = instruction_0;
3816 int format = ((instruction >> 21) & 0x00000007);
3818 if (GETFCC(CC) == TF)
3819 StoreFPR (FD, format, ValueFPR (FS, format));
3821 StoreFPR (FD, format, ValueFPR (FD, format));
3826 010001,10,3.FMT,5.RT,5.FS,5.FD,010011:COP1:32::MOVN.fmt
3828 // start-sanitize-r5900
3830 // end-sanitize-r5900
3832 unsigned32 instruction = instruction_0;
3833 int destreg = ((instruction >> 6) & 0x0000001F);
3834 int fs = ((instruction >> 11) & 0x0000001F);
3835 int format = ((instruction >> 21) & 0x00000007);
3837 StoreFPR(destreg,format,ValueFPR(fs,format));
3845 // MOVT.fmt see MOVtf.fmt
3849 010001,10,3.FMT,5.RT,5.FS,5.FD,010010:COP1:32::MOVZ.fmt
3850 "movz.%s<FMT> f<FD>, f<FS>, r<RT>"
3852 // start-sanitize-r5900
3854 // end-sanitize-r5900
3856 unsigned32 instruction = instruction_0;
3857 int destreg = ((instruction >> 6) & 0x0000001F);
3858 int fs = ((instruction >> 11) & 0x0000001F);
3859 int format = ((instruction >> 21) & 0x00000007);
3861 StoreFPR(destreg,format,ValueFPR(fs,format));
3867 010011,5.FR,5.FT,5.FS,5.FD,101,001:COP1X:32::MSUB.D
3868 "msub.d f<FD>, f<FR>, f<FS>, f<FT>"
3870 // start-sanitize-r5900
3872 // end-sanitize-r5900
3874 unsigned32 instruction = instruction_0;
3875 int destreg = ((instruction >> 6) & 0x0000001F);
3876 int fs = ((instruction >> 11) & 0x0000001F);
3877 int ft = ((instruction >> 16) & 0x0000001F);
3878 int fr = ((instruction >> 21) & 0x0000001F);
3880 StoreFPR(destreg,fmt_double,(Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double),fmt_double));
3886 010011,5.FR,5.FT,5.FS,5.FD,101000:COP1X:32::MSUB.S
3887 "msub.s f<FD>, f<FR>, f<FS>, f<FT>"
3889 // start-sanitize-r5900
3891 // end-sanitize-r5900
3893 unsigned32 instruction = instruction_0;
3894 int destreg = ((instruction >> 6) & 0x0000001F);
3895 int fs = ((instruction >> 11) & 0x0000001F);
3896 int ft = ((instruction >> 16) & 0x0000001F);
3897 int fr = ((instruction >> 21) & 0x0000001F);
3899 StoreFPR(destreg,fmt_single,(Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single),fmt_single));
3907 010001,10,3.FMT,5.FT,5.FS,5.FD,000010:COP1:32::MUL.fmt
3908 "mul.%s<FMT> f<FD>, f<FS>, f<FT>"
3913 // start-sanitize-r5900
3915 // end-sanitize-r5900
3917 // start-sanitize-tx19
3919 // end-sanitize-tx19
3921 unsigned32 instruction = instruction_0;
3922 int destreg = ((instruction >> 6) & 0x0000001F);
3923 int fs = ((instruction >> 11) & 0x0000001F);
3924 int ft = ((instruction >> 16) & 0x0000001F);
3925 int format = ((instruction >> 21) & 0x00000007);
3927 if ((format != fmt_single) && (format != fmt_double))
3928 SignalException(ReservedInstruction,instruction);
3930 StoreFPR(destreg,format,Multiply(ValueFPR(fs,format),ValueFPR(ft,format),format));
3935 010001,10,3.FMT,00000,5.FS,5.FD,000111:COP1:32::NEG.fmt
3936 "neg.%s<FMT> f<FD>, f<FS>"
3941 // start-sanitize-r5900
3943 // end-sanitize-r5900
3945 // start-sanitize-tx19
3947 // end-sanitize-tx19
3949 unsigned32 instruction = instruction_0;
3950 int destreg = ((instruction >> 6) & 0x0000001F);
3951 int fs = ((instruction >> 11) & 0x0000001F);
3952 int format = ((instruction >> 21) & 0x00000007);
3954 if ((format != fmt_single) && (format != fmt_double))
3955 SignalException(ReservedInstruction,instruction);
3957 StoreFPR(destreg,format,Negate(ValueFPR(fs,format),format));
3963 010011,5.FR,5.FT,5.FS,5.FD,110001:COP1X:32::NMADD.D
3964 "nmadd.d f<FD>, f<FR>, f<FS>, f<FT>"
3967 unsigned32 instruction = instruction_0;
3968 int destreg = ((instruction >> 6) & 0x0000001F);
3969 int fs = ((instruction >> 11) & 0x0000001F);
3970 int ft = ((instruction >> 16) & 0x0000001F);
3971 int fr = ((instruction >> 21) & 0x0000001F);
3973 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));
3979 010011,5.FR,5.FT,5.FS,5.FD,110000:COP1X:32::NMADD.S
3980 "nmadd.s f<FD>, f<FR>, f<FS>, f<FT>"
3983 unsigned32 instruction = instruction_0;
3984 int destreg = ((instruction >> 6) & 0x0000001F);
3985 int fs = ((instruction >> 11) & 0x0000001F);
3986 int ft = ((instruction >> 16) & 0x0000001F);
3987 int fr = ((instruction >> 21) & 0x0000001F);
3989 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));
3995 010011,5.FR,5.FT,5.FS,5.FD,111001:COP1X:32::NMSUB.D
3996 "nmsub.d f<FD>, f<FR>, f<FS>, f<FT>"
3999 unsigned32 instruction = instruction_0;
4000 int destreg = ((instruction >> 6) & 0x0000001F);
4001 int fs = ((instruction >> 11) & 0x0000001F);
4002 int ft = ((instruction >> 16) & 0x0000001F);
4003 int fr = ((instruction >> 21) & 0x0000001F);
4005 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));
4011 010011,5.FR,5.FT,5.FS,5.FD,111000:COP1X:32::NMSUB.S
4012 "nmsub.s f<FD>, f<FR>, f<FS>, f<FT>"
4015 unsigned32 instruction = instruction_0;
4016 int destreg = ((instruction >> 6) & 0x0000001F);
4017 int fs = ((instruction >> 11) & 0x0000001F);
4018 int ft = ((instruction >> 16) & 0x0000001F);
4019 int fr = ((instruction >> 21) & 0x0000001F);
4021 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));
4026 010011,5.BASE,5.INDEX,5.HINT,00000001111:COP1X:32::PREFX
4027 "prefx <HINT>, r<INDEX>(r<BASE>)"
4030 unsigned32 instruction = instruction_0;
4031 int fs = ((instruction >> 11) & 0x0000001F);
4032 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4033 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4035 unsigned64 vaddr = ((unsigned64)op1 + (unsigned64)op2);
4038 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4039 Prefetch(uncached,paddr,vaddr,isDATA,fs);
4043 010001,10,3.FMT,00000,5.FS,5.FD,010101:COP1:32::RECIP.fmt
4045 "recip.%s<FMT> f<FD>, f<FS>"
4047 unsigned32 instruction = instruction_0;
4048 int destreg = ((instruction >> 6) & 0x0000001F);
4049 int fs = ((instruction >> 11) & 0x0000001F);
4050 int format = ((instruction >> 21) & 0x00000007);
4052 if ((format != fmt_single) && (format != fmt_double))
4053 SignalException(ReservedInstruction,instruction);
4055 StoreFPR(destreg,format,Recip(ValueFPR(fs,format),format));
4060 010001,10,3.FMT,00000,5.FS,5.FD,001000:COP1:64::ROUND.L.fmt
4061 "round.l.%s<FMT> f<FD>, f<FS>"
4064 // start-sanitize-r5900
4066 // end-sanitize-r5900
4068 // start-sanitize-tx19
4070 // end-sanitize-tx19
4072 unsigned32 instruction = instruction_0;
4073 int destreg = ((instruction >> 6) & 0x0000001F);
4074 int fs = ((instruction >> 11) & 0x0000001F);
4075 int format = ((instruction >> 21) & 0x00000007);
4077 if ((format != fmt_single) && (format != fmt_double))
4078 SignalException(ReservedInstruction,instruction);
4080 StoreFPR(destreg,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_long));
4085 010001,10,3.FMT,00000,5.FS,5.FD,001100:COP1:32::ROUND.W.fmt
4086 "round.w.%s<FMT> f<FD>, f<FS>"
4090 // start-sanitize-r5900
4092 // end-sanitize-r5900
4094 // start-sanitize-tx19
4096 // end-sanitize-tx19
4098 unsigned32 instruction = instruction_0;
4099 int destreg = ((instruction >> 6) & 0x0000001F);
4100 int fs = ((instruction >> 11) & 0x0000001F);
4101 int format = ((instruction >> 21) & 0x00000007);
4103 if ((format != fmt_single) && (format != fmt_double))
4104 SignalException(ReservedInstruction,instruction);
4106 StoreFPR(destreg,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_word));
4111 010001,10,3.FMT,00000,5.FS,5.FD,010110:COP1:32::RSQRT.fmt
4113 "rsqrt.%s<FMT> f<FD>, f<FS>"
4115 unsigned32 instruction = instruction_0;
4116 int destreg = ((instruction >> 6) & 0x0000001F);
4117 int fs = ((instruction >> 11) & 0x0000001F);
4118 int format = ((instruction >> 21) & 0x00000007);
4120 if ((format != fmt_single) && (format != fmt_double))
4121 SignalException(ReservedInstruction,instruction);
4123 StoreFPR(destreg,format,Recip(SquareRoot(ValueFPR(fs,format),format)));
4131 010011,5.RS,5.RT,vvvvv,00000001001:COP1X:64::SDXC1
4133 // start-sanitize-r5900
4135 // end-sanitize-r5900
4137 unsigned32 instruction = instruction_0;
4138 int fs = ((instruction >> 11) & 0x0000001F);
4139 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4140 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4142 unsigned64 vaddr = ((unsigned64)op1 + op2);
4145 if ((vaddr & 7) != 0)
4146 SignalExceptionAddressStore();
4149 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
4151 unsigned64 memval = 0;
4152 unsigned64 memval1 = 0;
4153 memval = (unsigned64)COP_SD(1,fs);
4155 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
4163 010001,10,3.FMT,00000,5.FS,5.FD,000100:COP1:32::SQRT.fmt
4164 "sqrt.%s<FMT> f<FD>, f<FS>"
4168 // start-sanitize-r5900
4170 // end-sanitize-r5900
4172 // start-sanitize-tx19
4174 // end-sanitize-tx19
4176 unsigned32 instruction = instruction_0;
4177 int destreg = ((instruction >> 6) & 0x0000001F);
4178 int fs = ((instruction >> 11) & 0x0000001F);
4179 int format = ((instruction >> 21) & 0x00000007);
4181 if ((format != fmt_single) && (format != fmt_double))
4182 SignalException(ReservedInstruction,instruction);
4184 StoreFPR(destreg,format,(SquareRoot(ValueFPR(fs,format),format)));
4189 010001,10,3.FMT,5.FT,5.FS,5.FD,000001:COP1:32::SUB.fmt
4190 "sub.%s<FMT> f<FD>, f<FS>, f<FT>"
4195 // start-sanitize-r5900
4197 // end-sanitize-r5900
4199 // start-sanitize-tx19
4201 // end-sanitize-tx19
4203 unsigned32 instruction = instruction_0;
4204 int destreg = ((instruction >> 6) & 0x0000001F);
4205 int fs = ((instruction >> 11) & 0x0000001F);
4206 int ft = ((instruction >> 16) & 0x0000001F);
4207 int format = ((instruction >> 21) & 0x00000007);
4209 if ((format != fmt_single) && (format != fmt_double))
4210 SignalException(ReservedInstruction,instruction);
4212 StoreFPR(destreg,format,Sub(ValueFPR(fs,format),ValueFPR(ft,format),format));
4220 010011,5.BASE,5.FT,5.FS,00000,001000:COP1X:32::SWXC1
4221 "swxc1 f<FT>, r<OFFSET>(r<BASE>)"
4223 // start-sanitize-r5900
4225 // end-sanitize-r5900
4227 unsigned32 instruction = instruction_0;
4228 int fs = ((instruction >> 11) & 0x0000001F);
4229 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4230 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4232 unsigned64 vaddr = ((unsigned64)op1 + op2);
4235 if ((vaddr & 3) != 0)
4236 SignalExceptionAddressStore();
4239 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
4241 unsigned64 memval = 0;
4242 unsigned64 memval1 = 0;
4243 unsigned64 mask = 0x7;
4245 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
4246 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
4247 memval = (((unsigned64)COP_SW(1,fs)) << (8 * byte));
4249 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
4257 010001,10,3.FMT,00000,5.FS,5.FD,001001:COP1:64::TRUNC.L.fmt
4258 "trunc.l.%s<FMT> f<FD>, f<FS>"
4261 // start-sanitize-r5900
4263 // end-sanitize-r5900
4265 // start-sanitize-tx19
4267 // end-sanitize-tx19
4269 unsigned32 instruction = instruction_0;
4270 int destreg = ((instruction >> 6) & 0x0000001F);
4271 int fs = ((instruction >> 11) & 0x0000001F);
4272 int format = ((instruction >> 21) & 0x00000007);
4274 if ((format != fmt_single) && (format != fmt_double))
4275 SignalException(ReservedInstruction,instruction);
4277 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_long));
4282 010001,10,3.FMT,00000,5.FS,5.FD,001101:COP1:32::TRUNC.W
4283 "trunc.w.%s<FMT> f<FD>, f<FS>"
4287 // start-sanitize-r5900
4289 // end-sanitize-r5900
4291 // start-sanitize-tx19
4293 // end-sanitize-tx19
4295 unsigned32 instruction = instruction_0;
4296 int destreg = ((instruction >> 6) & 0x0000001F);
4297 int fs = ((instruction >> 11) & 0x0000001F);
4298 int format = ((instruction >> 21) & 0x00000007);
4300 if ((format != fmt_single) && (format != fmt_double))
4301 SignalException(ReservedInstruction,instruction);
4303 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_word));
4309 // MIPS Architecture:
4311 // System Control Instruction Set (COP0)
4315 010000,01000,00000,16.OFFSET:COP0:32::BC0F
4321 // start-sanitize-r5900
4323 // end-sanitize-r5900
4326 010000,01000,00010,16.OFFSET:COP0:32::BC0FL
4332 // start-sanitize-r5900
4334 // end-sanitize-r5900
4337 010000,01000,00001,16.OFFSET:COP0:32::BC0T
4343 // start-sanitize-r5900
4345 // end-sanitize-r5900
4349 010000,01000,00011,16.OFFSET:COP0:32::BC0TL
4355 // start-sanitize-r5900
4357 // end-sanitize-r5900
4360 101111,5.BASE,5.OP,16.OFFSET:NORMAL:32::CACHE
4363 // start-sanitize-r5900
4365 // end-sanitize-r5900
4367 // start-sanitize-tx19
4369 // end-sanitize-tx19
4371 unsigned32 instruction = instruction_0;
4372 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
4373 int hint = ((instruction >> 16) & 0x0000001F);
4374 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4376 unsigned64 vaddr = (op1 + offset);
4379 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4380 CacheOp(hint,vaddr,paddr,instruction);
4385 010000,10000,000000000000000,111001:COP0:32::DI
4391 // start-sanitize-r5900
4393 // end-sanitize-r5900
4396 010000,10000,000000000000000,111000:COP0:32::EI
4402 // start-sanitize-r5900
4404 // end-sanitize-r5900
4407 010000,10000,000000000000000,011000:COP0:32::ERET
4411 // start-sanitize-r5900
4413 // end-sanitize-r5900
4416 010000,00000,5.RT,5.RD,00000,6.REGX:COP0:32::MFC0
4417 "mfc0 r<RT>, r<RD> # <REGX>"
4422 // start-sanitize-r5900
4424 // end-sanitize-r5900
4427 010000,00100,5.RT,5.RD,00000,6.REGX:COP0:32::MTC0
4428 "mtc0 r<RT>, r<RD> # <REGX>"
4433 // start-sanitize-r5900
4435 // end-sanitize-r5900
4438 010000,10000,000000000000000,001000:COP0:32::TLBP
4444 // start-sanitize-r5900
4446 // end-sanitize-r5900
4449 010000,10000,000000000000000,000001:COP0:32::TLBR
4455 // start-sanitize-r5900
4457 // end-sanitize-r5900
4460 010000,10000,000000000000000,000010:COP0:32::TLBWI
4466 // start-sanitize-r5900
4468 // end-sanitize-r5900
4471 010000,10000,000000000000000,000110:COP0:32::TLBWR
4477 // start-sanitize-r5900
4479 // end-sanitize-r5900
4483 // MIPS Architecture:
4485 // CPU Instruction Set (mips16)
4488 // The instructions in this section are ordered according
4489 // to http://www.sgi.com/MIPS/arch/MIPS16/mips16.pdf.
4492 // Load and Store Instructions
4495 10000,xxx,ddd,55555:RRI:16::LB
4498 unsigned32 instruction = instruction_0;
4499 signed_word op1 = (instruction >> 8) & 0x7;
4500 int destreg = (instruction >> 5) & 0x7;
4501 int offset = (instruction >> 0) & 0x1f;
4509 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4510 if (offset >= 0x8000)
4518 SignalException (ReservedInstruction, instruction);
4520 unsigned64 vaddr = ((unsigned64)op1 + offset);
4524 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4526 unsigned64 memval = 0;
4527 unsigned64 memval1 = 0;
4528 unsigned64 mask = 0x7;
4529 unsigned int shift = 0;
4530 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4531 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4533 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4534 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
4535 byte = ((vaddr & mask) ^ (bigend << shift));
4536 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x000000FF),8));
4543 10100,xxx,ddd,55555:RRI:16::LBU
4546 unsigned32 instruction = instruction_0;
4547 signed_word op1 = (instruction >> 8) & 0x7;
4548 int destreg = (instruction >> 5) & 0x7;
4549 int offset = (instruction >> 0) & 0x1f;
4557 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4558 if (offset >= 0x8000)
4566 SignalException (ReservedInstruction, instruction);
4568 unsigned64 vaddr = ((unsigned64)op1 + offset);
4572 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4574 unsigned64 memval = 0;
4575 unsigned64 memval1 = 0;
4576 unsigned64 mask = 0x7;
4577 unsigned int shift = 0;
4578 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4579 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4581 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4582 LoadMemory(&memval,&memval1,uncached,AccessLength_BYTE,paddr,vaddr,isDATA,isREAL);
4583 byte = ((vaddr & mask) ^ (bigend << shift));
4584 GPR[destreg] = (((memval >> (8 * byte)) & 0x000000FF));
4591 10001,xxx,ddd,HHHHH:RRI:16::LH
4594 unsigned32 instruction = instruction_0;
4595 signed_word op1 = (instruction >> 8) & 0x7;
4596 int destreg = (instruction >> 5) & 0x7;
4597 int offset = (instruction >> 0) & 0x1f;
4605 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4606 if (offset >= 0x8000)
4615 SignalException (ReservedInstruction, instruction);
4617 unsigned64 vaddr = ((unsigned64)op1 + offset);
4620 if ((vaddr & 1) != 0)
4621 SignalExceptionAddressLoad();
4624 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4626 unsigned64 memval = 0;
4627 unsigned64 memval1 = 0;
4628 unsigned64 mask = 0x7;
4629 unsigned int shift = 1;
4630 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4631 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4633 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4634 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
4635 byte = ((vaddr & mask) ^ (bigend << shift));
4636 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0x0000FFFF),16));
4643 10101,xxx,ddd,HHHHH:RRI:16::LHU
4646 unsigned32 instruction = instruction_0;
4647 signed_word op1 = (instruction >> 8) & 0x7;
4648 int destreg = (instruction >> 5) & 0x7;
4649 int offset = (instruction >> 0) & 0x1f;
4657 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4658 if (offset >= 0x8000)
4667 SignalException (ReservedInstruction, instruction);
4669 unsigned64 vaddr = ((unsigned64)op1 + offset);
4672 if ((vaddr & 1) != 0)
4673 SignalExceptionAddressLoad();
4676 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4678 unsigned64 memval = 0;
4679 unsigned64 memval1 = 0;
4680 unsigned64 mask = 0x7;
4681 unsigned int shift = 1;
4682 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4683 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4685 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4686 LoadMemory(&memval,&memval1,uncached,AccessLength_HALFWORD,paddr,vaddr,isDATA,isREAL);
4687 byte = ((vaddr & mask) ^ (bigend << shift));
4688 GPR[destreg] = (((memval >> (8 * byte)) & 0x0000FFFF));
4695 10011,xxx,ddd,WWWWW:RRI:16::LW
4698 unsigned32 instruction = instruction_0;
4699 signed_word op1 = (instruction >> 8) & 0x7;
4700 int destreg = (instruction >> 5) & 0x7;
4701 int offset = (instruction >> 0) & 0x1f;
4709 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4710 if (offset >= 0x8000)
4719 SignalException (ReservedInstruction, instruction);
4721 unsigned64 vaddr = ((unsigned64)op1 + offset);
4724 if ((vaddr & 3) != 0)
4725 SignalExceptionAddressLoad();
4728 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4730 unsigned64 memval = 0;
4731 unsigned64 memval1 = 0;
4732 unsigned64 mask = 0x7;
4733 unsigned int shift = 2;
4734 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4735 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4737 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4738 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
4739 byte = ((vaddr & mask) ^ (bigend << shift));
4740 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
4747 10110,ddd,VVVVVVVV,P:RI:16::LWPC
4750 unsigned32 instruction = instruction_0;
4751 int destreg = (instruction >> 8) & 0x7;
4752 int offset = (instruction >> 0) & 0xff;
4753 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
4758 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4759 if (offset >= 0x8000)
4768 SignalException (ReservedInstruction, instruction);
4770 unsigned64 vaddr = ((unsigned64)op1 + offset);
4773 if ((vaddr & 3) != 0)
4774 SignalExceptionAddressLoad();
4777 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4779 unsigned64 memval = 0;
4780 unsigned64 memval1 = 0;
4781 unsigned64 mask = 0x7;
4782 unsigned int shift = 2;
4783 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4784 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4786 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4787 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
4788 byte = ((vaddr & mask) ^ (bigend << shift));
4789 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
4796 10010,ddd,VVVVVVVV,s:RI:16::LWSP
4799 unsigned32 instruction = instruction_0;
4800 int destreg = (instruction >> 8) & 0x7;
4801 int offset = (instruction >> 0) & 0xff;
4802 signed_word op1 = 29;
4807 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4808 if (offset >= 0x8000)
4818 SignalException (ReservedInstruction, instruction);
4820 unsigned64 vaddr = ((unsigned64)op1 + offset);
4823 if ((vaddr & 3) != 0)
4824 SignalExceptionAddressLoad();
4827 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4829 unsigned64 memval = 0;
4830 unsigned64 memval1 = 0;
4831 unsigned64 mask = 0x7;
4832 unsigned int shift = 2;
4833 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4834 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4836 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4837 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
4838 byte = ((vaddr & mask) ^ (bigend << shift));
4839 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
4846 10111,xxx,ddd,WWWWW:RRI:16::LWU
4849 unsigned32 instruction = instruction_0;
4850 signed_word op1 = (instruction >> 8) & 0x7;
4851 int destreg = (instruction >> 5) & 0x7;
4852 int offset = (instruction >> 0) & 0x1f;
4860 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4861 if (offset >= 0x8000)
4870 SignalException (ReservedInstruction, instruction);
4872 unsigned64 vaddr = ((unsigned64)op1 + offset);
4875 if ((vaddr & 3) != 0)
4876 SignalExceptionAddressLoad();
4879 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4881 unsigned64 memval = 0;
4882 unsigned64 memval1 = 0;
4883 unsigned64 mask = 0x7;
4884 unsigned int shift = 2;
4885 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4886 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4888 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
4889 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
4890 byte = ((vaddr & mask) ^ (bigend << shift));
4891 GPR[destreg] = (((memval >> (8 * byte)) & 0xFFFFFFFF));
4898 00111,xxx,ddd,DDDDD:RRI:16::LD
4901 unsigned32 instruction = instruction_0;
4902 signed_word op1 = (instruction >> 8) & 0x7;
4903 int destreg = (instruction >> 5) & 0x7;
4904 int offset = (instruction >> 0) & 0x1f;
4912 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4913 if (offset >= 0x8000)
4922 SignalException (ReservedInstruction, instruction);
4924 unsigned64 vaddr = ((unsigned64)op1 + offset);
4927 if ((vaddr & 7) != 0)
4928 SignalExceptionAddressLoad();
4931 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4933 unsigned64 memval = 0;
4934 unsigned64 memval1 = 0;
4935 unsigned64 mask = 0x7;
4936 unsigned int shift = 4;
4937 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4938 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4940 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
4941 GPR[destreg] = memval;
4948 11111100,ddd,5.RD,P:RI64:16::LDPC
4951 unsigned32 instruction = instruction_0;
4952 int destreg = (instruction >> 5) & 0x7;
4953 int offset = (instruction >> 0) & 0x1f;
4954 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x7;
4959 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
4960 if (offset >= 0x8000)
4969 SignalException (ReservedInstruction, instruction);
4971 unsigned64 vaddr = ((unsigned64)op1 + offset);
4974 if ((vaddr & 7) != 0)
4975 SignalExceptionAddressLoad();
4978 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4980 unsigned64 memval = 0;
4981 unsigned64 memval1 = 0;
4982 unsigned64 mask = 0x7;
4983 unsigned int shift = 4;
4984 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
4985 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
4987 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
4988 GPR[destreg] = memval;
4995 11111000,ddd,5.RD,s:RI64:16::LDSP
4998 unsigned32 instruction = instruction_0;
4999 int destreg = (instruction >> 5) & 0x7;
5000 int offset = (instruction >> 0) & 0x1f;
5001 signed_word op1 = 29;
5006 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5007 if (offset >= 0x8000)
5017 SignalException (ReservedInstruction, instruction);
5019 unsigned64 vaddr = ((unsigned64)op1 + offset);
5022 if ((vaddr & 7) != 0)
5023 SignalExceptionAddressLoad();
5026 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
5028 unsigned64 memval = 0;
5029 unsigned64 memval1 = 0;
5030 unsigned64 mask = 0x7;
5031 unsigned int shift = 4;
5032 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5033 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5035 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
5036 GPR[destreg] = memval;
5043 11000,xxx,yyy,55555:RRI:16::SB
5046 unsigned32 instruction = instruction_0;
5047 signed_word op1 = (instruction >> 8) & 0x7;
5048 signed_word op2 = (instruction >> 5) & 0x7;
5049 int offset = (instruction >> 0) & 0x1f;
5058 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5059 if (offset >= 0x8000)
5067 SignalException (ReservedInstruction, instruction);
5069 unsigned64 vaddr = ((unsigned64)op1 + offset);
5073 if (AddressTranslation(vaddr,isDATA,isSTORE,&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 byte = ((vaddr & mask) ^ (bigend << shift));
5084 memval = ((unsigned64) op2 << (8 * byte));
5086 StoreMemory(uncached,AccessLength_BYTE,memval,memval1,paddr,vaddr,isREAL);
5094 11001,xxx,yyy,HHHHH:RRI:16::SH
5097 unsigned32 instruction = instruction_0;
5098 signed_word op1 = (instruction >> 8) & 0x7;
5099 signed_word op2 = (instruction >> 5) & 0x7;
5100 int offset = (instruction >> 0) & 0x1f;
5109 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5110 if (offset >= 0x8000)
5119 SignalException (ReservedInstruction, instruction);
5121 unsigned64 vaddr = ((unsigned64)op1 + offset);
5124 if ((vaddr & 1) != 0)
5125 SignalExceptionAddressStore();
5128 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5130 unsigned64 memval = 0;
5131 unsigned64 memval1 = 0;
5132 unsigned64 mask = 0x7;
5133 unsigned int shift = 1;
5134 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
5135 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
5137 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
5138 byte = ((vaddr & mask) ^ (bigend << shift));
5139 memval = ((unsigned64) op2 << (8 * byte));
5141 StoreMemory(uncached,AccessLength_HALFWORD,memval,memval1,paddr,vaddr,isREAL);
5149 11011,xxx,yyy,WWWWW:RRI:16::SW
5152 unsigned32 instruction = instruction_0;
5153 signed_word op1 = (instruction >> 8) & 0x7;
5154 signed_word op2 = (instruction >> 5) & 0x7;
5155 int offset = (instruction >> 0) & 0x1f;
5164 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5165 if (offset >= 0x8000)
5174 SignalException (ReservedInstruction, instruction);
5176 unsigned64 vaddr = ((unsigned64)op1 + offset);
5179 if ((vaddr & 3) != 0)
5180 SignalExceptionAddressStore();
5183 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5185 unsigned64 memval = 0;
5186 unsigned64 memval1 = 0;
5187 unsigned64 mask = 0x7;
5189 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
5190 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
5191 memval = ((unsigned64) op2 << (8 * byte));
5193 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
5201 11010,yyy,VVVVVVVV,s:RI:16::SWSP
5204 unsigned32 instruction = instruction_0;
5205 signed_word op2 = (instruction >> 8) & 0x7;
5206 int offset = (instruction >> 0) & 0xff;
5207 signed_word op1 = 29;
5213 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5214 if (offset >= 0x8000)
5224 SignalException (ReservedInstruction, instruction);
5226 unsigned64 vaddr = ((unsigned64)op1 + offset);
5229 if ((vaddr & 3) != 0)
5230 SignalExceptionAddressStore();
5233 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5235 unsigned64 memval = 0;
5236 unsigned64 memval1 = 0;
5237 unsigned64 mask = 0x7;
5239 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
5240 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
5241 memval = ((unsigned64) op2 << (8 * byte));
5243 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
5251 01100010,VVVVVVVV,Q,s:I8:16::SWRASP
5254 unsigned32 instruction = instruction_0;
5255 int offset = (instruction >> 0) & 0xff;
5256 signed_word op2 = 31;
5257 signed_word op1 = 29;
5260 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5261 if (offset >= 0x8000)
5272 SignalException (ReservedInstruction, instruction);
5274 unsigned64 vaddr = ((unsigned64)op1 + offset);
5277 if ((vaddr & 3) != 0)
5278 SignalExceptionAddressStore();
5281 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5283 unsigned64 memval = 0;
5284 unsigned64 memval1 = 0;
5285 unsigned64 mask = 0x7;
5287 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
5288 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
5289 memval = ((unsigned64) op2 << (8 * byte));
5291 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
5299 01111,xxx,yyy,DDDDD:RRI:16::SD
5302 unsigned32 instruction = instruction_0;
5303 signed_word op1 = (instruction >> 8) & 0x7;
5304 signed_word op2 = (instruction >> 5) & 0x7;
5305 int offset = (instruction >> 0) & 0x1f;
5314 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5315 if (offset >= 0x8000)
5324 SignalException (ReservedInstruction, instruction);
5326 unsigned64 vaddr = ((unsigned64)op1 + offset);
5329 if ((vaddr & 7) != 0)
5330 SignalExceptionAddressStore();
5333 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5335 unsigned64 memval = 0;
5336 unsigned64 memval1 = 0;
5339 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
5347 11111001,yyy,5.RD,s:RI64:16::SDSP
5350 unsigned32 instruction = instruction_0;
5351 signed_word op2 = (instruction >> 5) & 0x7;
5352 int offset = (instruction >> 0) & 0x1f;
5353 signed_word op1 = 29;
5359 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5360 if (offset >= 0x8000)
5370 SignalException (ReservedInstruction, instruction);
5372 unsigned64 vaddr = ((unsigned64)op1 + offset);
5375 if ((vaddr & 7) != 0)
5376 SignalExceptionAddressStore();
5379 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5381 unsigned64 memval = 0;
5382 unsigned64 memval1 = 0;
5385 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
5393 11111010,CCCCCCCC,s,Q:I64:16::SDRASP
5396 unsigned32 instruction = instruction_0;
5397 int offset = (instruction >> 0) & 0xff;
5398 signed_word op1 = 29;
5399 signed_word op2 = 31;
5402 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5403 if (offset >= 0x8000)
5414 SignalException (ReservedInstruction, instruction);
5416 unsigned64 vaddr = ((unsigned64)op1 + offset);
5419 if ((vaddr & 7) != 0)
5420 SignalExceptionAddressStore();
5423 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
5425 unsigned64 memval = 0;
5426 unsigned64 memval1 = 0;
5429 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
5437 // ALU Immediate Instructions
5440 01101,ddd,UUUUUUUU,Z:RI:16::LI
5443 unsigned32 instruction = instruction_0;
5444 int destreg = (instruction >> 8) & 0x7;
5445 int op2 = (instruction >> 0) & 0xff;
5446 signed_word op1 = 0;
5451 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5458 SignalException (ReservedInstruction, instruction);
5461 GPR[destreg] = (op1 | op2);
5466 01000,xxx,ddd,04444:RRI_A:16::ADDIU
5469 unsigned32 instruction = instruction_0;
5470 signed_word op1 = (instruction >> 8) & 0x7;
5471 int destreg = (instruction >> 5) & 0x7;
5472 int op2 = (instruction >> 0) & 0xf;
5480 op2 |= ((extendval & 0xf) << 11) | (extendval & 0x7f0);
5491 SignalException (ReservedInstruction, instruction);
5493 unsigned int temp = (unsigned int)(op1 + op2);
5494 signed int tempS = (signed int)temp;
5495 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5500 01001,www,kkkkkkkk:RI:16::ADDIU8
5503 unsigned32 instruction = instruction_0;
5504 signed_word op1 = (instruction >> 8) & 0x7;
5506 int op2 = (instruction >> 0) & 0xff;
5513 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5524 SignalException (ReservedInstruction, instruction);
5526 unsigned int temp = (unsigned int)(op1 + op2);
5527 signed int tempS = (signed int)temp;
5528 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5533 01100011,KKKKKKKK,S:I8:16::ADJSP
5536 unsigned32 instruction = instruction_0;
5537 int op2 = (instruction >> 0) & 0xff;
5538 signed_word op1 = 29;
5542 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5556 SignalException (ReservedInstruction, instruction);
5558 unsigned int temp = (unsigned int)(op1 + op2);
5559 signed int tempS = (signed int)temp;
5560 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5565 00001,ddd,AAAAAAAA,P:RI:16::ADDIUPC
5568 unsigned32 instruction = instruction_0;
5569 int destreg = (instruction >> 8) & 0x7;
5570 int op2 = (instruction >> 0) & 0xff;
5571 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
5576 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5586 SignalException (ReservedInstruction, instruction);
5588 unsigned int temp = (unsigned int)(op1 + op2);
5589 signed int tempS = (signed int)temp;
5590 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5595 00000,ddd,AAAAAAAA,s:RI:16::ADDIUSP
5598 unsigned32 instruction = instruction_0;
5599 int destreg = (instruction >> 8) & 0x7;
5600 int op2 = (instruction >> 0) & 0xff;
5601 signed_word op1 = 29;
5606 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5617 SignalException (ReservedInstruction, instruction);
5619 unsigned int temp = (unsigned int)(op1 + op2);
5620 signed int tempS = (signed int)temp;
5621 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5626 01000,xxx,ddd,14444:RRI_A:16::DADDIU
5629 unsigned32 instruction = instruction_0;
5630 signed_word op1 = (instruction >> 8) & 0x7;
5631 int destreg = (instruction >> 5) & 0x7;
5632 int op2 = (instruction >> 0) & 0xf;
5640 op2 |= ((extendval & 0xf) << 11) | (extendval & 0x7f0);
5651 SignalException (ReservedInstruction, instruction);
5653 unsigned64 temp = (unsigned64)(op1 + op2);
5654 word64 tempS = (word64)temp;
5655 GPR[destreg] = (unsigned64)temp;
5660 11111101,www,jjjjj:RI64:16::DADDIU5
5663 unsigned32 instruction = instruction_0;
5664 signed_word op1 = (instruction >> 5) & 0x7;
5666 int op2 = (instruction >> 0) & 0x1f;
5673 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5684 SignalException (ReservedInstruction, instruction);
5686 unsigned64 temp = (unsigned64)(op1 + op2);
5687 word64 tempS = (word64)temp;
5688 GPR[destreg] = (unsigned64)temp;
5693 11111011,KKKKKKKK,S:I64:16::DADJSP
5696 unsigned32 instruction = instruction_0;
5697 int op2 = (instruction >> 0) & 0xff;
5698 signed_word op1 = 29;
5702 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5716 SignalException (ReservedInstruction, instruction);
5718 unsigned64 temp = (unsigned64)(op1 + op2);
5719 word64 tempS = (word64)temp;
5720 GPR[destreg] = (unsigned64)temp;
5725 11111110,ddd,EEEEE,P:RI64:16::DADDIUPC
5728 unsigned32 instruction = instruction_0;
5729 int destreg = (instruction >> 5) & 0x7;
5730 int op2 = (instruction >> 0) & 0x1f;
5731 signed_word op1 = ((INDELAYSLOT () ? (INJALDELAYSLOT () ? IPC - 4 : IPC - 2) : (have_extendval ? IPC - 2 : IPC)) & ~ (unsigned64) 1) & ~ (unsigned64) 0x3;
5736 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5746 SignalException (ReservedInstruction, instruction);
5748 unsigned64 temp = (unsigned64)(op1 + op2);
5749 word64 tempS = (word64)temp;
5750 GPR[destreg] = (unsigned64)temp;
5755 11111111,ddd,EEEEE,s:RI64:16::DADDIUSP
5758 unsigned32 instruction = instruction_0;
5759 int destreg = (instruction >> 5) & 0x7;
5760 int op2 = (instruction >> 0) & 0x1f;
5761 signed_word op1 = 29;
5766 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5777 SignalException (ReservedInstruction, instruction);
5779 unsigned64 temp = (unsigned64)(op1 + op2);
5780 word64 tempS = (word64)temp;
5781 GPR[destreg] = (unsigned64)temp;
5786 01010,xxx,88888888,T:RI:16::SLTI
5789 unsigned32 instruction = instruction_0;
5790 signed_word op1 = (instruction >> 8) & 0x7;
5791 int op2 = (instruction >> 0) & 0xff;
5798 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5807 SignalException (ReservedInstruction, instruction);
5809 if ((word64)op1 < (word64)op2)
5817 01011,xxx,88888888,T:RI:16::SLTIU
5820 unsigned32 instruction = instruction_0;
5821 signed_word op1 = (instruction >> 8) & 0x7;
5822 int op2 = (instruction >> 0) & 0xff;
5829 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5838 SignalException (ReservedInstruction, instruction);
5840 if ((unsigned64)op1 < (unsigned64)op2)
5848 11101,xxx,yyy,01010,T:RR:16::CMP
5851 unsigned32 instruction = instruction_0;
5852 signed_word op1 = (instruction >> 8) & 0x7;
5853 signed_word op2 = (instruction >> 5) & 0x7;
5862 SignalException (ReservedInstruction, instruction);
5864 GPR[destreg] = (op1 ^ op2);
5869 01110,xxx,UUUUUUUU,T:RI:16::CMPI
5872 unsigned32 instruction = instruction_0;
5873 signed_word op1 = (instruction >> 8) & 0x7;
5874 int op2 = (instruction >> 0) & 0xff;
5881 op2 |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
5888 SignalException (ReservedInstruction, instruction);
5890 GPR[destreg] = (op1 ^ op2);
5895 // Two/Three Operand, Register-Type
5898 11100,xxx,yyy,ddd,01:RRR:16::ADDU
5901 unsigned32 instruction = instruction_0;
5902 signed_word op1 = (instruction >> 8) & 0x7;
5903 signed_word op2 = (instruction >> 5) & 0x7;
5904 int destreg = (instruction >> 2) & 0x7;
5914 SignalException (ReservedInstruction, instruction);
5916 unsigned int temp = (unsigned int)(op1 + op2);
5917 signed int tempS = (signed int)temp;
5918 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5923 11100,xxx,yyy,ddd,11:RRR:16::SUBU
5926 unsigned32 instruction = instruction_0;
5927 signed_word op1 = (instruction >> 8) & 0x7;
5928 signed_word op2 = (instruction >> 5) & 0x7;
5929 int destreg = (instruction >> 2) & 0x7;
5939 SignalException (ReservedInstruction, instruction);
5941 unsigned int temp = (unsigned int)(op1 - op2);
5942 signed int tempS = (signed int)temp;
5943 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
5948 11100,xxx,yyy,ddd,00:RRR:16::DADDU
5951 unsigned32 instruction = instruction_0;
5952 signed_word op1 = (instruction >> 8) & 0x7;
5953 signed_word op2 = (instruction >> 5) & 0x7;
5954 int destreg = (instruction >> 2) & 0x7;
5964 SignalException (ReservedInstruction, instruction);
5966 unsigned64 temp = (unsigned64)(op1 + op2);
5967 word64 tempS = (word64)temp;
5968 GPR[destreg] = (unsigned64)temp;
5973 11100,xxx,yyy,ddd,10:RRR:16::DSUBU
5976 unsigned32 instruction = instruction_0;
5977 signed_word op1 = (instruction >> 8) & 0x7;
5978 signed_word op2 = (instruction >> 5) & 0x7;
5979 int destreg = (instruction >> 2) & 0x7;
5989 SignalException (ReservedInstruction, instruction);
5991 unsigned64 temp = (unsigned64)(op1 - op2);
5992 word64 tempS = (word64)temp;
5993 GPR[destreg] = (unsigned64)temp;
5998 11101,xxx,yyy,00010,T:RR:16::SLT
6001 unsigned32 instruction = instruction_0;
6002 signed_word op1 = (instruction >> 8) & 0x7;
6003 signed_word op2 = (instruction >> 5) & 0x7;
6012 SignalException (ReservedInstruction, instruction);
6014 if ((word64)op1 < (word64)op2)
6022 11101,xxx,yyy,00011,T:RR:16::SLTU
6025 unsigned32 instruction = instruction_0;
6026 signed_word op1 = (instruction >> 8) & 0x7;
6027 signed_word op2 = (instruction >> 5) & 0x7;
6036 SignalException (ReservedInstruction, instruction);
6038 if ((unsigned64)op1 < (unsigned64)op2)
6046 11101,ddd,yyy,01011,Z:RR:16::NEG
6049 unsigned32 instruction = instruction_0;
6050 int destreg = (instruction >> 8) & 0x7;
6051 signed_word op2 = (instruction >> 5) & 0x7;
6052 signed_word op1 = 0;
6059 SignalException (ReservedInstruction, instruction);
6061 unsigned int temp = (unsigned int)(op1 - op2);
6062 signed int tempS = (signed int)temp;
6063 GPR[destreg] = SIGNEXTEND(((unsigned64)temp),32);
6068 11101,www,yyy,01100:RR:16::AND
6071 unsigned32 instruction = instruction_0;
6072 signed_word op1 = (instruction >> 8) & 0x7;
6074 signed_word op2 = (instruction >> 5) & 0x7;
6083 SignalException (ReservedInstruction, instruction);
6085 GPR[destreg] = (op1 & op2);
6090 11101,www,yyy,01101:RR:16::OR
6093 unsigned32 instruction = instruction_0;
6094 signed_word op1 = (instruction >> 8) & 0x7;
6096 signed_word op2 = (instruction >> 5) & 0x7;
6105 SignalException (ReservedInstruction, instruction);
6108 GPR[destreg] = (op1 | op2);
6113 11101,www,yyy,01110:RR:16::XOR
6116 unsigned32 instruction = instruction_0;
6117 signed_word op1 = (instruction >> 8) & 0x7;
6119 signed_word op2 = (instruction >> 5) & 0x7;
6128 SignalException (ReservedInstruction, instruction);
6130 GPR[destreg] = (op1 ^ op2);
6135 11101,ddd,yyy,01111,Z:RR:16::NOT
6138 unsigned32 instruction = instruction_0;
6139 int destreg = (instruction >> 8) & 0x7;
6140 signed_word op2 = (instruction >> 5) & 0x7;
6141 signed_word op1 = 0;
6148 SignalException (ReservedInstruction, instruction);
6151 GPR[destreg] = ~(op1 | op2);
6156 01100111,ddd,XXXXX,z:I8_MOVR32:16::MOVR32
6159 unsigned32 instruction = instruction_0;
6160 int destreg = (instruction >> 5) & 0x7;
6161 signed_word op1 = (instruction >> 0) & 0x1f;
6162 signed_word op2 = 0;
6167 SignalException (ReservedInstruction, instruction);
6170 GPR[destreg] = (op1 | op2);
6175 01100101,YYYYY,xxx,z:I8_MOV32R:16::MOV32R
6178 unsigned32 instruction = instruction_0;
6179 int destreg = (instruction >> 3) & 0x1f;
6180 signed_word op1 = (instruction >> 0) & 0x7;
6181 signed_word op2 = 0;
6182 destreg = (destreg >> 2) | ((destreg & 3) << 3);
6187 SignalException (ReservedInstruction, instruction);
6190 GPR[destreg] = (op1 | op2);
6195 00110,ddd,yyy,sss,00:ISHIFT:16::SLL
6198 unsigned32 instruction = instruction_0;
6199 int destreg = (instruction >> 8) & 0x7;
6200 signed_word op2 = (instruction >> 5) & 0x7;
6201 int op1 = (instruction >> 2) & 0x7;
6209 op1 = (extendval >> 6) & 0x1f;
6218 SignalException (ReservedInstruction, instruction);
6220 GPR[destreg] = ((unsigned64)op2 << op1);
6221 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6226 00110,ddd,yyy,sss,10:ISHIFT:16::SRL
6229 unsigned32 instruction = instruction_0;
6230 int destreg = (instruction >> 8) & 0x7;
6231 signed_word op2 = (instruction >> 5) & 0x7;
6232 int op1 = (instruction >> 2) & 0x7;
6240 op1 = (extendval >> 6) & 0x1f;
6249 SignalException (ReservedInstruction, instruction);
6251 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6252 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6257 00110,ddd,yyy,sss,11:ISHIFT:16::SRA
6260 unsigned32 instruction = instruction_0;
6261 int destreg = (instruction >> 8) & 0x7;
6262 signed_word op2 = (instruction >> 5) & 0x7;
6263 int op1 = (instruction >> 2) & 0x7;
6271 op1 = (extendval >> 6) & 0x1f;
6280 SignalException (ReservedInstruction, instruction);
6282 unsigned int highbit = (unsigned int)1 << 31;
6283 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6284 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned int)1 << op1) - 1) << (32 - op1)) : 0);
6285 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6290 11101,xxx,vvv,00100:RR:16::SLLV
6293 unsigned32 instruction = instruction_0;
6294 signed_word op1 = (instruction >> 8) & 0x7;
6295 signed_word op2 = (instruction >> 5) & 0x7;
6305 SignalException (ReservedInstruction, instruction);
6308 GPR[destreg] = ((unsigned64)op2 << op1);
6309 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6314 11101,xxx,vvv,00110:RR:16::SRLV
6317 unsigned32 instruction = instruction_0;
6318 signed_word op1 = (instruction >> 8) & 0x7;
6319 signed_word op2 = (instruction >> 5) & 0x7;
6329 SignalException (ReservedInstruction, instruction);
6332 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6333 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6338 11101,xxx,vvv,00111:RR:16::SRAV
6341 unsigned32 instruction = instruction_0;
6342 signed_word op1 = (instruction >> 8) & 0x7;
6343 signed_word op2 = (instruction >> 5) & 0x7;
6353 SignalException (ReservedInstruction, instruction);
6355 unsigned int highbit = (unsigned int)1 << 31;
6357 GPR[destreg] = ((unsigned64)(op2 & 0xFFFFFFFF) >> op1);
6358 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned int)1 << op1) - 1) << (32 - op1)) : 0);
6359 GPR[destreg] = SIGNEXTEND(GPR[destreg],32);
6364 00110,ddd,yyy,[[[,01:ISHIFT:16::DSLL
6367 unsigned32 instruction = instruction_0;
6368 int destreg = (instruction >> 8) & 0x7;
6369 signed_word op2 = (instruction >> 5) & 0x7;
6370 int op1 = (instruction >> 2) & 0x7;
6378 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
6387 SignalException (ReservedInstruction, instruction);
6389 GPR[destreg] = ((unsigned64)op2 << op1);
6394 11101,XXX,vvv,01000:RR:16::DSRL
6397 unsigned32 instruction = instruction_0;
6398 int op1 = (instruction >> 8) & 0x7;
6399 signed_word op2 = (instruction >> 5) & 0x7;
6403 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
6416 SignalException (ReservedInstruction, instruction);
6418 GPR[destreg] = ((unsigned64)(op2) >> op1);
6423 11101,xxx,vvv,10011:RR:16::DSRA
6426 unsigned32 instruction = instruction_0;
6427 int op1 = (instruction >> 8) & 0x7;
6428 signed_word op2 = (instruction >> 5) & 0x7;
6432 op1 = ((extendval >> 6) & 0x1f) | (extendval & 0x20);
6445 SignalException (ReservedInstruction, instruction);
6447 unsigned64 highbit = (unsigned64)1 << 63;
6448 GPR[destreg] = ((unsigned64)(op2) >> op1);
6449 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned64)1 << op1) - 1) << (64 - op1)) : 0);
6454 11101,xxx,vvv,10100:RR:16::DSLLV
6457 unsigned32 instruction = instruction_0;
6458 signed_word op1 = (instruction >> 8) & 0x7;
6459 signed_word op2 = (instruction >> 5) & 0x7;
6469 SignalException (ReservedInstruction, instruction);
6472 GPR[destreg] = ((unsigned64)op2 << op1);
6477 11101,xxx,vvv,10110:RR:16::DSRLV
6480 unsigned32 instruction = instruction_0;
6481 signed_word op1 = (instruction >> 8) & 0x7;
6482 signed_word op2 = (instruction >> 5) & 0x7;
6492 SignalException (ReservedInstruction, instruction);
6495 GPR[destreg] = ((unsigned64)(op2) >> op1);
6500 11101,xxx,vvv,10111:RR:16::DSRAV
6503 unsigned32 instruction = instruction_0;
6504 signed_word op1 = (instruction >> 8) & 0x7;
6505 signed_word op2 = (instruction >> 5) & 0x7;
6515 SignalException (ReservedInstruction, instruction);
6517 unsigned64 highbit = (unsigned64)1 << 63;
6519 GPR[destreg] = ((unsigned64)(op2) >> op1);
6520 GPR[destreg] |= (op1 != 0 && (op2 & highbit) ? ((((unsigned64)1 << op1) - 1) << (64 - op1)) : 0);
6525 // Multiply /Divide Instructions
6528 11101,xxx,yyy,11000:RR:16::MULT
6531 unsigned32 instruction = instruction_0;
6532 signed_word op1 = (instruction >> 8) & 0x7;
6533 signed_word op2 = (instruction >> 5) & 0x7;
6541 SignalException (ReservedInstruction, instruction);
6543 CHECKHILO("Multiplication");
6545 unsigned64 temp = ((word64) op1 * (word64) op2);
6546 LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
6547 HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
6553 11101,xxx,yyy,11001:RR:16::MULTU
6556 unsigned32 instruction = instruction_0;
6557 signed_word op1 = (instruction >> 8) & 0x7;
6558 signed_word op2 = (instruction >> 5) & 0x7;
6566 SignalException (ReservedInstruction, instruction);
6568 CHECKHILO("Multiplication");
6570 unsigned64 temp = ((unsigned64)(op1 & 0xffffffff) * (unsigned64)(op2 & 0xffffffff));
6571 LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
6572 HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
6578 11101,xxx,yyy,11010:RR:16::DIV
6581 unsigned32 instruction = instruction_0;
6582 signed_word op1 = (instruction >> 8) & 0x7;
6583 signed_word op2 = (instruction >> 5) & 0x7;
6591 SignalException (ReservedInstruction, instruction);
6593 CHECKHILO("Division");
6599 LO = SIGNEXTEND(0x80000000,32);
6600 HI = SIGNEXTEND(0,32);
6602 else if (d2 == -1 && d1 == 0x80000000)
6604 LO = SIGNEXTEND(0x80000000,32);
6605 HI = SIGNEXTEND(0,32);
6609 LO = SIGNEXTEND((d1 / d2),32);
6610 HI = SIGNEXTEND((d1 % d2),32);
6617 11101,xxx,yyy,11011:RR:16::DIVU
6620 unsigned32 instruction = instruction_0;
6621 signed_word op1 = (instruction >> 8) & 0x7;
6622 signed_word op2 = (instruction >> 5) & 0x7;
6630 SignalException (ReservedInstruction, instruction);
6632 CHECKHILO("Division");
6634 unsigned int d1 = op1;
6635 unsigned int d2 = op2;
6638 LO = SIGNEXTEND(0x80000000,32);
6639 HI = SIGNEXTEND(0,32);
6641 else if (d2 == -1 && d1 == 0x80000000)
6643 LO = SIGNEXTEND(0x80000000,32);
6644 HI = SIGNEXTEND(0,32);
6648 LO = SIGNEXTEND((d1 / d2),32);
6649 HI = SIGNEXTEND((d1 % d2),32);
6656 11101,ddd,00010000:RR:16::MFHI
6659 unsigned32 instruction = instruction_0;
6660 int destreg = (instruction >> 8) & 0x7;
6664 SignalException (ReservedInstruction, instruction);
6667 HIACCESS = 3; /* 3rd instruction will be safe */
6672 11101,ddd,00010010:RR:16::MFLO
6675 unsigned32 instruction = instruction_0;
6676 int destreg = (instruction >> 8) & 0x7;
6680 SignalException (ReservedInstruction, instruction);
6683 LOACCESS = 3; /* 3rd instruction will be safe */
6688 11101,xxx,yyy,11100:RR:16::DMULT
6691 unsigned32 instruction = instruction_0;
6692 signed_word op1 = (instruction >> 8) & 0x7;
6693 signed_word op2 = (instruction >> 5) & 0x7;
6701 SignalException (ReservedInstruction, instruction);
6703 CHECKHILO("Multiplication");
6709 if (op1 < 0) { op1 = - op1; ++sign; }
6710 if (op2 < 0) { op2 = - op2; ++sign; }
6711 LO = ((unsigned64)VL4_8(op1) * VL4_8(op2));
6712 HI = ((unsigned64)VH4_8(op1) * VH4_8(op2));
6713 mid = ((unsigned64)VH4_8(op1) * VL4_8(op2));
6714 midhi = SET64HI(VL4_8(mid));
6715 temp = (LO + midhi);
6716 if ((temp == midhi) ? (LO != 0) : (temp < midhi))
6719 mid = ((unsigned64)VL4_8(op1) * VH4_8(op2));
6720 midhi = SET64HI(VL4_8(mid));
6721 LO = (temp + midhi);
6722 if ((LO == midhi) ? (temp != 0) : (LO < midhi))
6725 if (sign & 1) { LO = - LO; HI = (LO == 0 ? 0 : -1) - HI; }
6731 11101,xxx,yyy,11101:RR:16::DMULTU
6734 unsigned32 instruction = instruction_0;
6735 signed_word op1 = (instruction >> 8) & 0x7;
6736 signed_word op2 = (instruction >> 5) & 0x7;
6744 SignalException (ReservedInstruction, instruction);
6746 CHECKHILO("Multiplication");
6751 LO = ((unsigned64)VL4_8(op1) * VL4_8(op2));
6752 HI = ((unsigned64)VH4_8(op1) * VH4_8(op2));
6753 mid = ((unsigned64)VH4_8(op1) * VL4_8(op2));
6754 midhi = SET64HI(VL4_8(mid));
6755 temp = (LO + midhi);
6756 if ((temp == midhi) ? (LO != 0) : (temp < midhi))
6759 mid = ((unsigned64)VL4_8(op1) * VH4_8(op2));
6760 midhi = SET64HI(VL4_8(mid));
6761 LO = (temp + midhi);
6762 if ((LO == midhi) ? (temp != 0) : (LO < midhi))
6770 11101,xxx,yyy,11110:RR:16::DDIV
6773 unsigned32 instruction = instruction_0;
6774 signed_word op1 = (instruction >> 8) & 0x7;
6775 signed_word op2 = (instruction >> 5) & 0x7;
6783 SignalException (ReservedInstruction, instruction);
6785 CHECKHILO("Division");
6791 LO = SIGNED64 (0x8000000000000000);
6794 else if (d2 == -1 && d1 == SIGNED64 (0x8000000000000000))
6796 LO = SIGNED64 (0x8000000000000000);
6809 11101,xxx,yyy,11111:RR:16::DDIVU
6812 unsigned32 instruction = instruction_0;
6813 signed_word op1 = (instruction >> 8) & 0x7;
6814 signed_word op2 = (instruction >> 5) & 0x7;
6822 SignalException (ReservedInstruction, instruction);
6824 CHECKHILO("Division");
6826 unsigned64 d1 = op1;
6827 unsigned64 d2 = op2;
6830 LO = SIGNED64 (0x8000000000000000);
6833 else if (d2 == -1 && d1 == SIGNED64 (0x8000000000000000))
6835 LO = SIGNED64 (0x8000000000000000);
6848 // Jump and Branch Instructions
6853 00011,aaaaaaaaaaa:I:16::JAL
6856 unsigned32 instruction = instruction_0;
6857 unsigned_word op1 = (instruction >> 0) & 0x7ff;
6861 if (AddressTranslation (PC &~ (unsigned64) 1, isINSTRUCTION, isLOAD, &paddr, &uncached, isTARGET, isREAL))
6864 unsigned int reverse = (ReverseEndian ? 3 : 0);
6865 unsigned int bigend = (BigEndianCPU ? 3 : 0);
6867 paddr = ((paddr & ~0x7) | ((paddr & 0x7) ^ (reverse << 1)));
6868 LoadMemory (&memval,0,uncached, AccessLength_HALFWORD, paddr, PC, isINSTRUCTION, isREAL);
6869 byte = (((PC &~ (unsigned64) 1) & 0x7) ^ (bigend << 1));
6870 memval = (memval >> (8 * byte)) & 0xffff;
6871 op1 = (((op1 & 0x1f) << 23)
6872 | ((op1 & 0x3e0) << 13)
6874 if ((instruction & 0x400) == 0)
6879 op1 |= PC & ~ (unsigned64) 0x0fffffff;
6881 SignalException (ReservedInstruction, instruction);
6884 GPR[destreg] = (PC + 2); /* NOTE: The PC is already 2 ahead within the simulator */
6885 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
6886 so we just truncate it to 32 bits here. */
6888 /* NOTE: The jump occurs AFTER the next instruction has been executed */
6895 11101,xxx,00000000:RR:16::JR
6898 unsigned32 instruction = instruction_0;
6899 signed_word op1 = (instruction >> 8) & 0x7;
6904 SignalException (ReservedInstruction, instruction);
6906 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
6907 so we just truncate it to 32 bits here. */
6909 /* NOTE: The jump occurs AFTER the next instruction has been executed */
6916 1110100000100000,r:RR:16::JRRA
6919 unsigned32 instruction = instruction_0;
6920 signed_word op1 = 31;
6923 SignalException (ReservedInstruction, instruction);
6925 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
6926 so we just truncate it to 32 bits here. */
6928 /* NOTE: The jump occurs AFTER the next instruction has been executed */
6935 11101,xxx,01000000,R:RR:16::JALR
6938 unsigned32 instruction = instruction_0;
6939 signed_word op1 = (instruction >> 8) & 0x7;
6945 SignalException (ReservedInstruction, instruction);
6947 GPR[destreg] = (PC + 2); /* NOTE: The PC is already 2 ahead within the simulator */
6948 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
6949 so we just truncate it to 32 bits here. */
6951 /* NOTE: The jump occurs AFTER the next instruction has been executed */
6958 00100,xxx,pppppppp,z:RI:16::BEQZ
6961 unsigned32 instruction = instruction_0;
6962 signed_word op1 = (instruction >> 8) & 0x7;
6963 int offset = (instruction >> 0) & 0xff;
6964 signed_word op2 = 0;
6970 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
6971 if (offset >= 0x8000)
6982 SignalException (ReservedInstruction, instruction);
6984 int condition = (op1 == op2);
6991 00101,xxx,pppppppp,z:RI:16::BNEZ
6994 unsigned32 instruction = instruction_0;
6995 signed_word op1 = (instruction >> 8) & 0x7;
6996 int offset = (instruction >> 0) & 0xff;
6997 signed_word op2 = 0;
7003 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7004 if (offset >= 0x8000)
7015 SignalException (ReservedInstruction, instruction);
7017 int condition = (op1 != op2);
7024 01100000,pppppppp,t,z:I8:16::BTEQZ
7027 unsigned32 instruction = instruction_0;
7028 int offset = (instruction >> 0) & 0xff;
7029 signed_word op1 = 24;
7030 signed_word op2 = 0;
7033 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7034 if (offset >= 0x8000)
7046 SignalException (ReservedInstruction, instruction);
7048 int condition = (op1 == op2);
7055 01100001,pppppppp,t,z:I8:16::BTNEZ
7058 unsigned32 instruction = instruction_0;
7059 int offset = (instruction >> 0) & 0xff;
7060 signed_word op1 = 24;
7061 signed_word op2 = 0;
7064 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7065 if (offset >= 0x8000)
7077 SignalException (ReservedInstruction, instruction);
7079 int condition = (op1 != op2);
7086 00010,qqqqqqqqqqq,z,Z:I:16::B
7089 unsigned32 instruction = instruction_0;
7090 int offset = (instruction >> 0) & 0x7ff;
7091 signed_word op2 = 0;
7092 signed_word op1 = 0;
7095 offset |= ((extendval & 0x1f) << 11) | (extendval & 0x7e0);
7096 if (offset >= 0x8000)
7102 if (offset >= 0x400)
7107 SignalException (ReservedInstruction, instruction);
7109 int condition = (op1 == op2);
7116 // Special Instructions
7119 // See the front of the mips16 doc
7120 11110,eeeeeeeeeee:I:16::EXTEND
7123 unsigned32 instruction = instruction_0;
7124 int ext = (instruction >> 0) & 0x7ff;
7126 SignalException (ReservedInstruction, instruction);
7134 01100,******,00101:RR:16::BREAK
7137 unsigned32 instruction = instruction_0;
7139 SignalException (ReservedInstruction, instruction);
7141 SignalException(BreakPoint,instruction);
7146 // start-sanitize-r5900
7148 // FIXME: The instructions below which are typically r5900 specific
7149 // need to be merged back into the above.
7151 // end-sanitize-r5900
7152 // start-sanitize-r5900
7154 011100,5.RS,5.RT,0000000000011010:MMINORM:32::DIV1
7157 unsigned32 instruction = instruction_0;
7158 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7159 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7161 CHECKHILO("Division");
7167 LO1 = SIGNEXTEND(0x80000000,32);
7168 HI1 = SIGNEXTEND(0,32);
7170 else if (d2 == -1 && d1 == 0x80000000)
7172 LO1 = SIGNEXTEND(0x80000000,32);
7173 HI1 = SIGNEXTEND(0,32);
7177 LO1 = SIGNEXTEND((d1 / d2),32);
7178 HI1 = SIGNEXTEND((d1 % d2),32);
7184 // end-sanitize-r5900
7185 // start-sanitize-r5900
7187 011100,5.RS,5.RT,0000000000011011:MMINORM:32::DIVU1
7190 unsigned32 instruction = instruction_0;
7191 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7192 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7194 CHECKHILO("Division");
7196 unsigned int d1 = op1;
7197 unsigned int d2 = op2;
7200 LO1 = SIGNEXTEND(0x80000000,32);
7201 HI1 = SIGNEXTEND(0,32);
7203 else if (d2 == -1 && d1 == 0x80000000)
7205 LO1 = SIGNEXTEND(0x80000000,32);
7206 HI1 = SIGNEXTEND(0,32);
7210 LO1 = SIGNEXTEND((d1 / d2),32);
7211 HI1 = SIGNEXTEND((d1 % d2),32);
7217 // end-sanitize-r5900
7219 011101,26.INSTR_INDEX:NORMAL:32::JALX
7220 // start-sanitize-r5900
7222 // end-sanitize-r5900
7224 // start-sanitize-tx19
7226 // end-sanitize-tx19
7228 unsigned32 instruction = instruction_0;
7229 unsigned_word op1 = (((instruction >> 0) & 0x03FFFFFF) << 2);
7230 op1 |= (PC & ~0x0FFFFFFF); /* address of instruction in delay slot for the jump */
7233 GPR[destreg] = (PC + 4); /* NOTE: The PC is already 4 ahead within the simulator */
7235 /* NOTE: ??? Gdb gets confused if the PC is sign-extended,
7236 so we just truncate it to 32 bits here. */
7238 /* NOTE: The jump occurs AFTER the next instruction has been executed */
7244 // start-sanitize-r5900
7246 011110,5.RS,5.RT,16.OFFSET:NORMAL:128::LQ
7249 unsigned32 instruction = instruction_0;
7250 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
7251 int destreg = ((instruction >> 16) & 0x0000001F);
7252 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7254 unsigned64 vaddr = ((unsigned64)op1 + offset);
7257 if ((vaddr & 15) != 0)
7258 SignalExceptionAddressLoad();
7261 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
7263 unsigned64 memval = 0;
7264 unsigned64 memval1 = 0;
7265 unsigned64 mask = 0x7;
7266 unsigned int shift = 8;
7267 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
7268 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
7270 LoadMemory(&memval,&memval1,uncached,AccessLength_QUADWORD,paddr,vaddr,isDATA,isREAL);
7271 GPR[destreg] = memval;
7272 GPR1[destreg] = memval1;
7278 // end-sanitize-r5900
7279 // start-sanitize-r5900
7281 011100,5.RS,5.RT,5.RD,00000000000:MMINORM:32::MADD
7285 unsigned32 instruction = instruction_0;
7286 int destreg = ((instruction >> 11) & 0x0000001F);
7287 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7288 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7290 word64 prod = (word64)WORD64(VL4_8(HI),VL4_8(LO)) + ((word64)SIGNEXTEND(op1,32) * (word64)SIGNEXTEND(op2,32));
7291 LO = SIGNEXTEND(prod,32);
7292 HI = SIGNEXTEND( VH4_8(prod), 32);
7293 if( destreg != 0 ) GPR[destreg] = LO;
7297 // end-sanitize-r5900
7298 // start-sanitize-r5900
7300 011100,5.RS,5.RT,5.RD,00000000001:MMINORM:32::MADDU
7304 unsigned32 instruction = instruction_0;
7305 int destreg = ((instruction >> 11) & 0x0000001F);
7306 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7307 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7309 unsigned64 prod = (unsigned64)WORD64(VL4_8(HI),VL4_8(LO)) + ((unsigned64)VL4_8(op1) * (unsigned64)VL4_8(op2));
7310 LO = SIGNEXTEND(prod,32);
7311 HI = SIGNEXTEND( VH4_8(prod), 32);
7312 if( destreg != 0 ) GPR[destreg] = LO;
7316 // end-sanitize-r5900
7317 // start-sanitize-r5900
7319 011100,5.RS,5.RT,5.RD,00000100000:MMINORM:32::MADD1
7322 unsigned32 instruction = instruction_0;
7323 int destreg = ((instruction >> 11) & 0x0000001F);
7324 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7325 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7327 word64 prod = (word64)WORD64(VL4_8(HI1),VL4_8(LO1)) + ((word64)SIGNEXTEND(op1,32) * (word64)SIGNEXTEND(op2,32));
7328 LO1 = SIGNEXTEND(prod,32);
7329 HI1 = SIGNEXTEND( VH4_8(prod), 32);
7330 if( destreg != 0 ) GPR[destreg] = LO1;
7334 // end-sanitize-r5900
7335 // start-sanitize-r5900
7337 011100,5.RS,5.RT,5.RD,00000100001:MMINORM:32::MADDU1
7340 unsigned32 instruction = instruction_0;
7341 int destreg = ((instruction >> 11) & 0x0000001F);
7342 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7343 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7345 unsigned64 prod = (unsigned64)WORD64(VL4_8(HI1),VL4_8(LO1)) + ((unsigned64)VL4_8(op1) * (unsigned64)VL4_8(op2));
7346 LO1 = SIGNEXTEND(prod,32);
7347 HI1 = SIGNEXTEND( VH4_8(prod), 32);
7348 if( destreg != 0 ) GPR[destreg] = LO1;
7352 // end-sanitize-r5900
7353 // start-sanitize-r5900
7355 0111000000000000,5.RD,00000010000:MMINORM:32::MFHI1
7358 unsigned32 instruction = instruction_0;
7359 int destreg = ((instruction >> 11) & 0x0000001F);
7362 HI1ACCESS = 3; /* 3rd instruction will be safe */
7366 // end-sanitize-r5900
7367 // start-sanitize-r5900
7369 0111000000000000,5.RD,00000010010:MMINORM:32::MFLO1
7372 unsigned32 instruction = instruction_0;
7373 int destreg = ((instruction >> 11) & 0x0000001F);
7376 LO1ACCESS = 3; /* 3rd instruction will be safe */
7380 // end-sanitize-r5900
7381 // start-sanitize-r5900
7383 0000000000000000,5.RD,00000101000:SPECIAL:32::MFSA
7386 unsigned32 instruction = instruction_0;
7387 int destreg = ((instruction >> 11) & 0x0000001F);
7393 // end-sanitize-r5900
7394 // start-sanitize-r5900
7396 011100,5.RS,000000000000000010001:MMINORM:32::MTHI1
7399 unsigned32 instruction = instruction_0;
7400 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7403 sim_warning("MT (move-to) over-writing HI register value");
7405 HI1ACCESS = 3; /* 3rd instruction will be safe */
7409 // end-sanitize-r5900
7410 // start-sanitize-r5900
7412 011100,5.RS,000000000000000010011:MMINORM:32::MTLO1
7415 unsigned32 instruction = instruction_0;
7416 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7419 sim_warning("MT (move-to) over-writing LO register value");
7421 LO1ACCESS = 3; /* 3rd instruction will be safe */
7425 // end-sanitize-r5900
7426 // start-sanitize-r5900
7428 000000,5.RS,000000000000000101001:SPECIAL:32::MTSA
7431 unsigned32 instruction = instruction_0;
7432 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7438 // end-sanitize-r5900
7439 // start-sanitize-r5900
7441 000001,5.RS,11000,16.IMMEDIATE:REGIMM:32::MTSAB
7444 SA = ((GPR[RA] & 0xF) ^ (IMMEDIATE & 0xF)) * 8;
7447 // end-sanitize-r5900
7448 // start-sanitize-r5900
7450 000001,5.RS,11001,16.IMMEDIATE:REGIMM:32::MTSAH
7453 SA = ((GPR[RS] & 0x7) ^ (IMMEDIATE & 0x7)) * 16;
7456 // end-sanitize-r5900
7457 // start-sanitize-r5900
7459 011100,5.RS,5.RT,5.RD,00000011000:MMINORM:32::MULT1
7462 unsigned32 instruction = instruction_0;
7463 int destreg = ((instruction >> 11) & 0x0000001F);
7464 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7465 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7467 CHECKHILO("Multiplication");
7469 unsigned64 temp = ((word64) op1 * (word64) op2);
7470 LO1 = SIGNEXTEND((unsigned64)VL4_8(temp),32);
7471 HI1 = SIGNEXTEND((unsigned64)VH4_8(temp),32);
7478 // end-sanitize-r5900
7479 // start-sanitize-r5900
7481 011100,5.RS,5.RT,5.RD,00000011001:MMINORM:32::MULTU1
7484 unsigned32 instruction = instruction_0;
7485 int destreg = ((instruction >> 11) & 0x0000001F);
7486 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
7487 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
7489 CHECKHILO("Multiplication");
7491 unsigned64 temp = ((unsigned64)(op1 & 0xffffffff) * (unsigned64)(op2 & 0xffffffff));
7492 LO1 = SIGNEXTEND((unsigned64)VL4_8(temp),32);
7493 HI1 = SIGNEXTEND((unsigned64)VH4_8(temp),32);
7500 // end-sanitize-r5900
7501 // start-sanitize-r5900
7503 01110000000,5.RT,5.RD,00101101000:MMI1:32::PABSH
7506 unsigned32 instruction = instruction_0;
7507 int destreg = ((instruction >> 11) & 0x0000001F);
7508 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7509 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7512 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
7515 GPR_SH(destreg,i) = RT_SH(i);
7516 else if (RT_SH(i) == -32768)
7517 GPR_SH(destreg,i) = 32767;
7519 GPR_SH(destreg,i) = -RT_SH(i);
7524 // end-sanitize-r5900
7525 // start-sanitize-r5900
7527 01110000000,5.RT,5.RD,00001101000:MMI1:32::PABSW
7530 unsigned32 instruction = instruction_0;
7531 int destreg = ((instruction >> 11) & 0x0000001F);
7532 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7533 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7536 for(i=0;i<WORDS_IN_MMI_REGS;i++)
7539 GPR_SW(destreg,i) = RT_SW(i);
7540 else if (RT_SW(i) == (int)0x80000000)
7541 GPR_SW(destreg,i) = (int)0x7FFFFFFF;
7543 GPR_SW(destreg,i) = -RT_SW(i);
7548 // end-sanitize-r5900
7549 // start-sanitize-r5900
7551 011100,5.RS,5.RT,5.RD,01000001000:MMI0:32::PADDB
7554 unsigned32 instruction = instruction_0;
7555 int destreg = ((instruction >> 11) & 0x0000001F);
7556 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7557 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7558 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7559 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7562 for (i=0; i < BYTES_IN_MMI_REGS; i++)
7567 GPR_SB(destreg,i) = r;
7572 // end-sanitize-r5900
7573 // start-sanitize-r5900
7575 011100,5.RS,5.RT,5.RD,00100001000:MMI0:32::PADDH
7578 unsigned32 instruction = instruction_0;
7579 int destreg = ((instruction >> 11) & 0x0000001F);
7580 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7581 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7582 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7583 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7586 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
7591 GPR_SH(destreg,i) = r;
7596 // end-sanitize-r5900
7597 // start-sanitize-r5900
7599 011100,5.RS,5.RT,5.RD,00000001000:MMI0:32::PADDW
7602 unsigned32 instruction = instruction_0;
7603 int destreg = ((instruction >> 11) & 0x0000001F);
7604 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7605 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7606 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7607 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7610 for (i=0; i < WORDS_IN_MMI_REGS; i++)
7612 signed64 s = RS_SW(i);
7613 signed64 t = RT_SW(i);
7615 GPR_SW(destreg,i) = r;
7620 // end-sanitize-r5900
7621 // start-sanitize-r5900
7623 011100,5.RS,5.RT,5.RD,11000001000:MMI0:32::PADDSB
7626 unsigned32 instruction = instruction_0;
7627 int destreg = ((instruction >> 11) & 0x0000001F);
7628 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7629 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7630 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7631 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7634 for (i=0; i < BYTES_IN_MMI_REGS; i++)
7640 GPR_SB(destreg,i) = 127;
7642 GPR_SB(destreg,i) = -128;
7644 GPR_SB(destreg,i) = r;
7649 // end-sanitize-r5900
7650 // start-sanitize-r5900
7652 011100,5.RS,5.RT,5.RD,10100001000:MMI0:32::PADDSH
7655 unsigned32 instruction = instruction_0;
7656 int destreg = ((instruction >> 11) & 0x0000001F);
7657 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7658 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7659 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7660 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7663 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
7669 GPR_SH(destreg,i) = 32767;
7670 else if (r < -32768)
7671 GPR_SH(destreg,i) = -32768;
7673 GPR_SH(destreg,i) = r;
7678 // end-sanitize-r5900
7679 // start-sanitize-r5900
7681 011100,5.RS,5.RT,5.RD,10000001000:MMI0:32::PADDSW
7684 unsigned32 instruction = instruction_0;
7685 int destreg = ((instruction >> 11) & 0x0000001F);
7686 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7687 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7688 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7689 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7692 for (i=0; i < WORDS_IN_MMI_REGS; i++)
7694 signed64 s = RS_SW(i);
7695 signed64 t = RT_SW(i);
7697 if (r > (int)0x7FFFFFFF)
7698 GPR_SW(destreg,i) = (int)0x7FFFFFFF;
7699 else if (r < (int)0x80000000)
7700 GPR_SW(destreg,i) = (int)0x80000000;
7702 GPR_SW(destreg,i) = r;
7707 // end-sanitize-r5900
7708 // start-sanitize-r5900
7710 011100,5.RS,5.RT,5.RD,11000101000:MMI1:32::PADDUB
7713 unsigned32 instruction = instruction_0;
7714 int destreg = ((instruction >> 11) & 0x0000001F);
7715 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7716 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7717 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7718 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7721 for (i=0; i < BYTES_IN_MMI_REGS; i++)
7723 unsigned int s = RS_UB(i);
7724 unsigned int t = RT_UB(i);
7725 unsigned int r = s + t;
7727 GPR_UB(destreg,i) = 0xFF;
7729 GPR_UB(destreg,i) = r;
7734 // end-sanitize-r5900
7735 // start-sanitize-r5900
7737 011100,5.RS,5.RT,5.RD,10100101000:MMI1:32::PADDUH
7740 unsigned32 instruction = instruction_0;
7741 int destreg = ((instruction >> 11) & 0x0000001F);
7742 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7743 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7744 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7745 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7748 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
7750 unsigned int s = RS_UH(i);
7751 unsigned int t = RT_UH(i);
7752 unsigned int r = s + t;
7754 GPR_UH(destreg,i) = 0xFFFF;
7756 GPR_UH(destreg,i) = r;
7761 // end-sanitize-r5900
7762 // start-sanitize-r5900
7764 011100,5.RS,5.RT,5.RD,10000101000:MMI1:32::PADDUW
7767 unsigned32 instruction = instruction_0;
7768 int destreg = ((instruction >> 11) & 0x0000001F);
7769 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7770 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7771 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7772 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7775 for (i=0; i < WORDS_IN_MMI_REGS; i++)
7777 unsigned64 s = RS_UW(i);
7778 unsigned64 t = RT_UW(i);
7779 unsigned64 r = s + t;
7781 GPR_UW(destreg,i) = 0xFFFFFFFF;
7783 GPR_UW(destreg,i) = r;
7788 // end-sanitize-r5900
7789 // start-sanitize-r5900
7791 011100,5.RS,5.RT,5.RD,00100101000:MMI1:32::PADSBH
7794 unsigned32 instruction = instruction_0;
7795 int destreg = ((instruction >> 11) & 0x0000001F);
7796 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7797 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7798 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7799 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7802 for(i=0;i<HALFWORDS_IN_MMI_REGS/2;i++)
7803 GPR_SH(destreg,i) = RS_SH(i) - RT_SH(i);
7804 for(;i<HALFWORDS_IN_MMI_REGS;i++)
7805 GPR_SH(destreg,i) = RS_SH(i) + RT_SH(i);
7809 // end-sanitize-r5900
7810 // start-sanitize-r5900
7812 011100,5.RS,5.RT,5.RD,10010001001:MMI2:32::PAND
7815 unsigned32 instruction = instruction_0;
7816 int destreg = ((instruction >> 11) & 0x0000001F);
7817 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7818 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7819 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7820 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7823 for(i=0;i<WORDS_IN_MMI_REGS;i++)
7824 GPR_UW(destreg,i) = (RS_UW(i) & RT_UW(i));
7828 // end-sanitize-r5900
7829 // start-sanitize-r5900
7831 011100,5.RS,5.RT,5.RD,01010101000:MMI1:32::PCEQB
7834 unsigned32 instruction = instruction_0;
7835 int destreg = ((instruction >> 11) & 0x0000001F);
7836 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7837 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7838 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7839 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7842 for(i=0;i<BYTES_IN_MMI_REGS;i++)
7844 if (RS_SB(i) == RT_SB(i)) GPR_SB(destreg,i) = 0xFF;
7845 else GPR_SB(destreg,i) = 0;
7850 // end-sanitize-r5900
7851 // start-sanitize-r5900
7853 011100,5.RS,5.RT,5.RD,00110101000:MMI1:32::PCEQH
7856 unsigned32 instruction = instruction_0;
7857 int destreg = ((instruction >> 11) & 0x0000001F);
7858 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7859 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7860 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7861 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7864 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
7866 if (RS_SH(i) == RT_SH(i)) GPR_SH(destreg,i) = 0xFFFF;
7867 else GPR_SH(destreg,i) = 0;
7872 // end-sanitize-r5900
7873 // start-sanitize-r5900
7875 011100,5.RS,5.RT,5.RD,00010101000:MMI1:32::PCEQW
7878 unsigned32 instruction = instruction_0;
7879 int destreg = ((instruction >> 11) & 0x0000001F);
7880 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7881 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7882 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7883 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7886 for(i=0;i<WORDS_IN_MMI_REGS;i++)
7888 if (RS_SW(i) == RT_SW(i)) GPR_SW(destreg,i) = 0xFFFFFFFF;
7889 else GPR_SW(destreg,i) = 0;
7894 // end-sanitize-r5900
7895 // start-sanitize-r5900
7897 011100,5.RS,5.RT,5.RD,01010001000:MMI0:32::PCGTB
7900 unsigned32 instruction = instruction_0;
7901 int destreg = ((instruction >> 11) & 0x0000001F);
7902 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7903 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7904 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7905 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7908 for(i=0;i<BYTES_IN_MMI_REGS;i++)
7910 if (RS_SB(i) > RT_SB(i)) GPR_SB(destreg,i) = 0xFF;
7911 else GPR_SB(destreg,i) = 0;
7916 // end-sanitize-r5900
7917 // start-sanitize-r5900
7919 011100,5.RS,5.RT,5.RD,00110001000:MMI0:32::PCGTH
7922 unsigned32 instruction = instruction_0;
7923 int destreg = ((instruction >> 11) & 0x0000001F);
7924 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7925 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7926 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7927 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7930 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
7932 if (RS_SH(i) > RT_SH(i)) GPR_SH(destreg,i) = 0xFFFF;
7933 else GPR_SH(destreg,i) = 0;
7938 // end-sanitize-r5900
7939 // start-sanitize-r5900
7941 011100,5.RS,5.RT,5.RD,00010001000:MMI0:32::PCGTW
7944 unsigned32 instruction = instruction_0;
7945 int destreg = ((instruction >> 11) & 0x0000001F);
7946 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7947 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7948 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7949 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7952 for(i=0;i<WORDS_IN_MMI_REGS;i++)
7954 if (RS_SW(i) > RT_SW(i)) GPR_SW(destreg,i) = 0xFFFFFFFF;
7955 else GPR_SW(destreg,i) = 0;
7960 // end-sanitize-r5900
7961 // start-sanitize-r5900
7963 01110000000,5.RT,5.RD,11011101001:MMI3:32::PCPYH
7966 unsigned32 instruction = instruction_0;
7967 int destreg = ((instruction >> 11) & 0x0000001F);
7968 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7969 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7971 GPR_UH(destreg,7) = GPR_UH(destreg,6) = GPR_UH(destreg,5) = GPR_UH(destreg,4) = RT_UH(4);
7972 GPR_UH(destreg,3) = GPR_UH(destreg,2) = GPR_UH(destreg,1) = GPR_UH(destreg,0) = RT_UH(0);
7976 // end-sanitize-r5900
7977 // start-sanitize-r5900
7979 011100,5.RS,5.RT,5.RD,01110001001:MMI2:32::PCPYLD
7982 unsigned32 instruction = instruction_0;
7983 int destreg = ((instruction >> 11) & 0x0000001F);
7984 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
7985 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
7986 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
7987 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
7989 GPR_UD(destreg,0) = RT_UD(0);
7990 GPR_UD(destreg,1) = RS_UD(0);
7994 // end-sanitize-r5900
7995 // start-sanitize-r5900
7997 011100,5.RS,5.RT,5.RD,01110101001:MMI3:32::PCPYUD
8000 unsigned32 instruction = instruction_0;
8001 int destreg = ((instruction >> 11) & 0x0000001F);
8002 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8003 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8004 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8005 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8007 GPR_UD(destreg,0) = RS_UD(1);
8008 GPR_UD(destreg,1) = RT_UD(1);
8012 // end-sanitize-r5900
8013 // start-sanitize-r5900
8015 011100,5.RS,5.RT,0000011101001001:MMI2:32::PDIVBW
8018 unsigned32 instruction = instruction_0;
8019 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8020 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8021 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8022 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8024 signed32 devisor = RT_SH(0);
8027 LO_SW(0) = -RS_SW(0);
8029 LO_SW(1) = -RS_SW(1);
8031 LO_SW(2) = -RS_SW(2);
8033 LO_SW(3) = -RS_SW(3);
8036 else if (devisor != 0)
8038 LO_SW(0) = RS_SW(0) / devisor;
8039 HI_SW(0) = SIGNEXTEND( (RS_SW(0) % devisor), 16 );
8040 LO_SW(1) = RS_SW(1) / devisor;
8041 HI_SW(1) = SIGNEXTEND( (RS_SW(1) % devisor), 16 );
8042 LO_SW(2) = RS_SW(2) / devisor;
8043 HI_SW(2) = SIGNEXTEND( (RS_SW(2) % devisor), 16 );
8044 LO_SW(3) = RS_SW(3) / devisor;
8045 HI_SW(3) = SIGNEXTEND( (RS_SW(3) % devisor), 16 );
8050 // end-sanitize-r5900
8051 // start-sanitize-r5900
8053 011100,5.RS,5.RT,0000001101101001:MMI3:32::PDIVUW
8056 unsigned32 instruction = instruction_0;
8057 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8058 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8059 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8060 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8064 LO = (signed32)(RS_UW(0) / RT_UW(0));
8065 HI = (signed32)(RS_UW(0) % RT_UW(0));
8069 LO1 = (signed32)(RS_UW(2) / RT_UW(2));
8070 HI1 = (signed32)(RS_UW(2) % RT_UW(2));
8075 // end-sanitize-r5900
8076 // start-sanitize-r5900
8078 011100,5.RS,5.RT,0000001101001001:MMI2:32::PDIVW
8081 unsigned32 instruction = instruction_0;
8082 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8083 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8084 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8085 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8092 else if (RT_UW(0) != 0)
8094 LO = (signed32)(RS_SW(0) / RT_SW(0));
8095 HI = (signed32)(RS_SW(0) % RT_SW(0));
8102 else if (RT_UW(2) != 0)
8104 LO1 = (signed32)(RS_SW(2) / RT_SW(2));
8105 HI1 = (signed32)(RS_SW(2) % RT_SW(2));
8110 // end-sanitize-r5900
8111 // start-sanitize-r5900
8113 01110000000,5.RT,5.RD,11010101001:MMI3:32::PEXCH
8116 unsigned32 instruction = instruction_0;
8117 int destreg = ((instruction >> 11) & 0x0000001F);
8118 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8119 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8121 GPR_UH(destreg,0) = RT_UH(0);
8122 GPR_UH(destreg,1) = RT_UH(2);
8123 GPR_UH(destreg,2) = RT_UH(1);
8124 GPR_UH(destreg,3) = RT_UH(3);
8125 GPR_UH(destreg,4) = RT_UH(4);
8126 GPR_UH(destreg,5) = RT_UH(6);
8127 GPR_UH(destreg,6) = RT_UH(5);
8128 GPR_UH(destreg,7) = RT_UH(7);
8132 // end-sanitize-r5900
8133 // start-sanitize-r5900
8135 01110000000,5.RT,5.RD,11110101001:MMI3:32::PEXCW
8138 unsigned32 instruction = instruction_0;
8139 int destreg = ((instruction >> 11) & 0x0000001F);
8140 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8141 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8143 GPR_UW(destreg,0) = RT_UW(0);
8144 GPR_UW(destreg,1) = RT_UW(2);
8145 GPR_UW(destreg,2) = RT_UW(1);
8146 GPR_UW(destreg,3) = RT_UW(3);
8150 // end-sanitize-r5900
8151 // start-sanitize-r5900
8153 01110000000,5.RT,5.RD,11010001001:MMI2:32::PEXOH
8156 unsigned32 instruction = instruction_0;
8157 int destreg = ((instruction >> 11) & 0x0000001F);
8158 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8159 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8161 GPR_UH(destreg,0) = RT_UH(2);
8162 GPR_UH(destreg,1) = RT_UH(1);
8163 GPR_UH(destreg,2) = RT_UH(0);
8164 GPR_UH(destreg,3) = RT_UH(3);
8165 GPR_UH(destreg,4) = RT_UH(6);
8166 GPR_UH(destreg,5) = RT_UH(5);
8167 GPR_UH(destreg,6) = RT_UH(4);
8168 GPR_UH(destreg,7) = RT_UH(7);
8172 // end-sanitize-r5900
8173 // start-sanitize-r5900
8175 01110000000,5.RT,5.RD,11110001001:MMI2:32::PEXOW
8178 unsigned32 instruction = instruction_0;
8179 int destreg = ((instruction >> 11) & 0x0000001F);
8180 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8181 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8183 GPR_UW(destreg,0) = RT_UW(2);
8184 GPR_UW(destreg,1) = RT_UW(1);
8185 GPR_UW(destreg,2) = RT_UW(0);
8186 GPR_UW(destreg,3) = RT_UW(3);
8190 // end-sanitize-r5900
8191 // start-sanitize-r5900
8193 01110000000,5.RT,5.RD,11110001000:MMI0:32::PEXT5
8196 unsigned32 instruction = instruction_0;
8197 int destreg = ((instruction >> 11) & 0x0000001F);
8198 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8199 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8202 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8204 unsigned32 x = RT_UW(i);
8205 GPR_UW(destreg,i) = ((x & (1 << 15)) << (31 - 15))
8206 | ((x & (31 << 10)) << (19 - 10))
8207 | ((x & (31 << 5)) << (11 - 5))
8208 | ((x & (31 << 0)) << (3 - 0));
8213 // end-sanitize-r5900
8214 // start-sanitize-r5900
8216 011100,5.RS,5.RT,5.RD,11010001000:MMI0:32::PEXTLB
8219 unsigned32 instruction = instruction_0;
8220 int destreg = ((instruction >> 11) & 0x0000001F);
8221 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8222 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8223 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8224 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8226 GPR_UB(destreg,0) = RT_UB(0);
8227 GPR_UB(destreg,1) = RS_UB(0);
8228 GPR_UB(destreg,2) = RT_UB(1);
8229 GPR_UB(destreg,3) = RS_UB(1);
8230 GPR_UB(destreg,4) = RT_UB(2);
8231 GPR_UB(destreg,5) = RS_UB(2);
8232 GPR_UB(destreg,6) = RT_UB(3);
8233 GPR_UB(destreg,7) = RS_UB(3);
8234 GPR_UB(destreg,8) = RT_UB(4);
8235 GPR_UB(destreg,9) = RS_UB(4);
8236 GPR_UB(destreg,10) = RT_UB(5);
8237 GPR_UB(destreg,11) = RS_UB(5);
8238 GPR_UB(destreg,12) = RT_UB(6);
8239 GPR_UB(destreg,13) = RS_UB(6);
8240 GPR_UB(destreg,14) = RT_UB(7);
8241 GPR_UB(destreg,15) = RS_UB(7);
8245 // end-sanitize-r5900
8246 // start-sanitize-r5900
8248 011100,5.RS,5.RT,5.RD,10110001000:MMI0:32::PEXTLH
8251 unsigned32 instruction = instruction_0;
8252 int destreg = ((instruction >> 11) & 0x0000001F);
8253 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8254 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8255 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8256 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8258 GPR_UH(destreg,0) = RT_UH(0);
8259 GPR_UH(destreg,1) = RS_UH(0);
8260 GPR_UH(destreg,2) = RT_UH(1);
8261 GPR_UH(destreg,3) = RS_UH(1);
8262 GPR_UH(destreg,4) = RT_UH(2);
8263 GPR_UH(destreg,5) = RS_UH(2);
8264 GPR_UH(destreg,6) = RT_UH(3);
8265 GPR_UH(destreg,7) = RS_UH(3);
8269 // end-sanitize-r5900
8270 // start-sanitize-r5900
8272 011100,5.RS,5.RT,5.RD,10010001000:MMI0:32::PEXTLW
8275 unsigned32 instruction = instruction_0;
8276 int destreg = ((instruction >> 11) & 0x0000001F);
8277 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8278 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8279 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8280 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8282 GPR_UW(destreg,0) = RT_UW(0);
8283 GPR_UW(destreg,1) = RS_UW(0);
8284 GPR_UW(destreg,2) = RT_UW(1);
8285 GPR_UW(destreg,3) = RS_UW(1);
8289 // end-sanitize-r5900
8290 // start-sanitize-r5900
8292 011100,5.RS,5.RT,5.RD,11010101000:MMI1:32::PEXTUB
8295 unsigned32 instruction = instruction_0;
8296 int destreg = ((instruction >> 11) & 0x0000001F);
8297 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8298 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8299 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8300 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8302 GPR_UB(destreg,0) = RT_UB(8);
8303 GPR_UB(destreg,1) = RS_UB(8);
8304 GPR_UB(destreg,2) = RT_UB(9);
8305 GPR_UB(destreg,3) = RS_UB(9);
8306 GPR_UB(destreg,4) = RT_UB(10);
8307 GPR_UB(destreg,5) = RS_UB(10);
8308 GPR_UB(destreg,6) = RT_UB(11);
8309 GPR_UB(destreg,7) = RS_UB(11);
8310 GPR_UB(destreg,8) = RT_UB(12);
8311 GPR_UB(destreg,9) = RS_UB(12);
8312 GPR_UB(destreg,10) = RT_UB(13);
8313 GPR_UB(destreg,11) = RS_UB(13);
8314 GPR_UB(destreg,12) = RT_UB(14);
8315 GPR_UB(destreg,13) = RS_UB(14);
8316 GPR_UB(destreg,14) = RT_UB(15);
8317 GPR_UB(destreg,15) = RS_UB(15);
8321 // end-sanitize-r5900
8322 // start-sanitize-r5900
8324 011100,5.RS,5.RT,5.RD,10110101000:MMI1:32::PEXTUH
8327 unsigned32 instruction = instruction_0;
8328 int destreg = ((instruction >> 11) & 0x0000001F);
8329 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8330 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8331 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8332 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8334 GPR_UH(destreg,0) = RT_UH(4);
8335 GPR_UH(destreg,1) = RS_UH(4);
8336 GPR_UH(destreg,2) = RT_UH(5);
8337 GPR_UH(destreg,3) = RS_UH(5);
8338 GPR_UH(destreg,4) = RT_UH(6);
8339 GPR_UH(destreg,5) = RS_UH(6);
8340 GPR_UH(destreg,6) = RT_UH(7);
8341 GPR_UH(destreg,7) = RS_UH(7);
8345 // end-sanitize-r5900
8346 // start-sanitize-r5900
8348 011100,5.RS,5.RT,5.RD,10010101000:MMI1:32::PEXTUW
8351 unsigned32 instruction = instruction_0;
8352 int destreg = ((instruction >> 11) & 0x0000001F);
8353 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8354 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8355 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8356 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8358 GPR_UW(destreg,0) = RT_UW(2);
8359 GPR_UW(destreg,1) = RS_UW(2);
8360 GPR_UW(destreg,2) = RT_UW(3);
8361 GPR_UW(destreg,3) = RS_UW(3);
8365 // end-sanitize-r5900
8366 // start-sanitize-r5900
8368 011100,5.RS,5.RT,5.RD,10001001001:MMI2:32::PHMADDH
8371 unsigned32 instruction = instruction_0;
8372 int destreg = ((instruction >> 11) & 0x0000001F);
8373 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8374 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8375 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8376 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8378 GPR_SW(destreg,0) = LO_SW(0) = (RS_SH(1) * RT_SH(1)) + (RS_SH(0) * RT_SH(0));
8379 GPR_SW(destreg,1) = HI_SW(0) = (RS_SH(3) * RT_SH(3)) + (RS_SH(2) * RT_SH(2));
8380 GPR_SW(destreg,2) = LO_SW(2) = (RS_SH(5) * RT_SH(5)) + (RS_SH(4) * RT_SH(4));
8381 GPR_SW(destreg,3) = HI_SW(2) = (RS_SH(7) * RT_SH(7)) + (RS_SH(6) * RT_SH(6));
8385 // end-sanitize-r5900
8386 // start-sanitize-r5900
8388 011100,5.RS,5.RT,5.RD,10101001001:MMI2:32::PHMSUBH
8391 unsigned32 instruction = instruction_0;
8392 int destreg = ((instruction >> 11) & 0x0000001F);
8393 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8394 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8395 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8396 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8398 GPR_SW(destreg,0) = LO_SW(0) = (RS_SH(1) * RT_SH(1)) - (RS_SH(0) * RT_SH(0));
8399 GPR_SW(destreg,1) = HI_SW(0) = (RS_SH(3) * RT_SH(3)) - (RS_SH(2) * RT_SH(2));
8400 GPR_SW(destreg,2) = LO_SW(2) = (RS_SH(5) * RT_SH(5)) - (RS_SH(4) * RT_SH(4));
8401 GPR_SW(destreg,3) = HI_SW(2) = (RS_SH(7) * RT_SH(7)) - (RS_SH(6) * RT_SH(6));
8405 // end-sanitize-r5900
8406 // start-sanitize-r5900
8408 011100,5.RS,5.RT,5.RD,01010001001:MMI2:32::PINTH
8411 unsigned32 instruction = instruction_0;
8412 int destreg = ((instruction >> 11) & 0x0000001F);
8413 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8414 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8415 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8416 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8418 GPR_UH(destreg,0) = RT_UH(0);
8419 GPR_UH(destreg,1) = RS_UH(4);
8420 GPR_UH(destreg,2) = RT_UH(1);
8421 GPR_UH(destreg,3) = RS_UH(5);
8422 GPR_UH(destreg,4) = RT_UH(2);
8423 GPR_UH(destreg,5) = RS_UH(6);
8424 GPR_UH(destreg,6) = RT_UH(3);
8425 GPR_UH(destreg,7) = RS_UH(7);
8429 // end-sanitize-r5900
8430 // start-sanitize-r5900
8432 011100,5.RS,5.RT,5.RD,01010101001:MMI3:32::PINTOH
8435 unsigned32 instruction = instruction_0;
8436 int destreg = ((instruction >> 11) & 0x0000001F);
8437 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8438 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8439 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8440 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8442 GPR_UH(destreg,0) = RT_UH(0);
8443 GPR_UH(destreg,1) = RS_UH(0);
8444 GPR_UH(destreg,2) = RT_UH(2);
8445 GPR_UH(destreg,3) = RS_UH(2);
8446 GPR_UH(destreg,4) = RT_UH(4);
8447 GPR_UH(destreg,5) = RS_UH(4);
8448 GPR_UH(destreg,6) = RT_UH(6);
8449 GPR_UH(destreg,7) = RS_UH(6);
8453 // end-sanitize-r5900
8454 // start-sanitize-r5900
8456 011100,5.RS,00000,5.RD,00000000100:MMINORM:32::PLZCW
8459 unsigned32 instruction = instruction_0;
8460 int destreg = ((instruction >> 11) & 0x0000001F);
8461 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8462 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8464 unsigned long value;
8470 test = !!(value & (1 << 31));
8471 for(i=30; i>=0 && (test == !!(value & (1 << i))); i--)
8473 GPR_UW(destreg,0) = count;
8476 test = !!(value & (1 << 31));
8477 for(i=30; i>=0 && (test == !!(value & (1 << i))); i--)
8479 GPR_UW(destreg,1) = count;
8483 // end-sanitize-r5900
8484 // start-sanitize-r5900
8486 011100,5.RS,5.RT,5.RD,10000001001:MMI2:32::PMADDH
8489 unsigned32 instruction = instruction_0;
8490 int destreg = ((instruction >> 11) & 0x0000001F);
8491 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8492 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8493 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8494 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8496 GPR_SW(destreg,0) = LO_SW(0) += (RS_SH(0) * RT_SH(0));
8497 LO_SW(1) += (RS_SH(1) * RT_SH(1));
8498 GPR_SW(destreg,1) = HI_SW(0) += (RS_SH(2) * RT_SH(2));
8499 HI_SW(1) += (RS_SH(3) * RT_SH(3));
8500 GPR_SW(destreg,2) = LO_SW(2) += (RS_SH(4) * RT_SH(4));
8501 LO_SW(3) += (RS_SH(5) * RT_SH(5));
8502 GPR_SW(destreg,3) = HI_SW(2) += (RS_SH(6) * RT_SH(6));
8503 HI_SW(3) += (RS_SH(7) * RT_SH(7));
8507 // end-sanitize-r5900
8508 // start-sanitize-r5900
8510 011100,5.RS,5.RT,5.RD,00000101001:MMI3:32::PMADDUW
8513 unsigned32 instruction = instruction_0;
8514 int destreg = ((instruction >> 11) & 0x0000001F);
8515 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8516 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8517 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8518 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8520 unsigned64 sum0 = U8_4 (HI_SW(0), LO_SW(0));
8521 unsigned64 sum1 = u8_4 (HI_SW(2), LO_SW(2));
8522 unsigned64 prod0 = (unsigned64)RS_UW(0) * (unsigned64)RT_UW(0);
8523 unsigned64 prod1 = (unsigned64)RS_UW(2) * (unsigned64)RT_UW(2);
8526 GPR_UD(destreg,0) = sum0;
8527 GPR_UD(destreg,1) = sum1;
8528 LO = SIGNEXTEND( sum0, 32 );
8529 HI = SIGNEXTEND( VH4_8(sum0), 32 );
8530 LO1 = SIGNEXTEND( sum1, 32 );
8531 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
8535 // end-sanitize-r5900
8536 // start-sanitize-r5900
8538 011100,5.RS,5.RT,5.RD,00000001001:MMI2:32::PMADDW
8541 unsigned32 instruction = instruction_0;
8542 int destreg = ((instruction >> 11) & 0x0000001F);
8543 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8544 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8545 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8546 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8548 signed64 sum0 = WORD64( HI_SW(0), LO_SW(0) );
8549 signed64 sum1 = WORD64( HI_SW(2), LO_SW(2) );
8550 signed64 prod0 = (signed64)RS_SW(0) * (signed64)RT_SW(0);
8551 signed64 prod1 = (signed64)RS_SW(2) * (signed64)RT_SW(2);
8554 GPR_SD(destreg,0) = sum0;
8555 GPR_SD(destreg,1) = sum1;
8556 LO = SIGNEXTEND( sum0, 32 );
8557 HI = SIGNEXTEND( VH4_8(sum0), 32 );
8558 LO1 = SIGNEXTEND( sum1, 32 );
8559 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
8563 // end-sanitize-r5900
8564 // start-sanitize-r5900
8566 011100,5.RS,5.RT,5.RD,00111001000:MMI0:32::PMAXH
8569 unsigned32 instruction = instruction_0;
8570 int destreg = ((instruction >> 11) & 0x0000001F);
8571 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8572 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8573 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8574 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8577 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
8579 if (RS_SH(i) > RT_SH(i)) GPR_SH(destreg,i) = RS_SH(i);
8580 else GPR_SH(destreg,i) = RT_SH(i);
8585 // end-sanitize-r5900
8586 // start-sanitize-r5900
8588 011100,5.RS,5.RT,5.RD,00011001000:MMI0:32::PMAXW
8591 unsigned32 instruction = instruction_0;
8592 int destreg = ((instruction >> 11) & 0x0000001F);
8593 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8594 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8595 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8596 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8599 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8601 if (RS_SW(i) > RT_SW(i)) GPR_SW(destreg,i) = RS_SW(i);
8602 else GPR_SW(destreg,i) = RT_SW(i);
8607 // end-sanitize-r5900
8608 // start-sanitize-r5900
8610 0111000000000000,5.RD,01000001001:MMI2:32::PMFHI
8613 unsigned32 instruction = instruction_0;
8614 int destreg = ((instruction >> 11) & 0x0000001F);
8616 GPR_SD(destreg,0) = HI;
8617 GPR_SD(destreg,1) = HI1;
8621 // end-sanitize-r5900
8622 // start-sanitize-r5900
8624 0111000000000000,5.RD,01001001001:MMI2:32::PMFLO
8627 unsigned32 instruction = instruction_0;
8628 int destreg = ((instruction >> 11) & 0x0000001F);
8630 GPR_SD(destreg,0) = LO;
8631 GPR_SD(destreg,1) = LO1;
8635 // end-sanitize-r5900
8636 // start-sanitize-r5900
8638 0111000000000000,5.RD,5.SHIFT,110000:MMINORM:32::PMFHL
8641 unsigned32 instruction = instruction_0;
8642 int op1 = ((instruction >> 6) & 0x0000001F);
8643 int destreg = ((instruction >> 11) & 0x0000001F);
8647 GPR_UW(destreg,0) = LO_UW(0);
8648 GPR_UW(destreg,1) = HI_UW(0);
8649 GPR_UW(destreg,2) = LO_UW(2);
8650 GPR_UW(destreg,3) = HI_UW(2);
8654 GPR_UW(destreg,0) = LO_UW(1);
8655 GPR_UW(destreg,1) = HI_UW(1);
8656 GPR_UW(destreg,2) = LO_UW(3);
8657 GPR_UW(destreg,3) = HI_UW(3);
8661 /* NOTE: This code implements a saturate according to the
8662 figure on page B-115 and not according to the
8663 definition on page B-113 */
8664 signed64 t = ((unsigned64)HI_UW(0) << 32) | (unsigned64)LO_UW(0);
8665 signed64 u = ((unsigned64)HI_UW(2) << 32) | (unsigned64)LO_UW(2);
8666 if ( t > SIGNED64 (0x000000007FFFFFFF) )
8667 GPR_SD(destreg,0) = SIGNED64 (0x000000007FFFFFFF);
8668 else if ( t < - SIGNED64 (0x0000000080000000) )
8669 GPR_SD(destreg,0) = - SIGNED64 (0x0000000080000000);
8671 GPR_SD(destreg,0) = t;
8672 if ( u > SIGNED64 (0x000000007FFFFFFF) )
8673 GPR_SD(destreg,1) = SIGNED64 (0x000000007FFFFFFF);
8674 else if ( u < - SIGNED64 (0x0000000080000000) )
8675 GPR_SD(destreg,1) = - SIGNED64 (0x0000000080000000);
8677 GPR_SD(destreg,1) = u;
8681 GPR_UH(destreg,0) = LO_UH(0);
8682 GPR_UH(destreg,1) = LO_UH(2);
8683 GPR_UH(destreg,2) = HI_UH(0);
8684 GPR_UH(destreg,3) = HI_UH(2);
8685 GPR_UH(destreg,4) = LO_UH(4);
8686 GPR_UH(destreg,5) = LO_UH(6);
8687 GPR_UH(destreg,6) = HI_UH(4);
8688 GPR_UH(destreg,7) = HI_UH(6);
8692 if (LO_SW(0) > 0x7FFF)
8693 GPR_UH(destreg,0) = 0x7FFF;
8694 else if (LO_SW(0) < -0x8000)
8695 GPR_UH(destreg,0) = 0x8000;
8697 GPR_UH(destreg,0) = LO_UH(0);
8698 if (LO_SW(1) > 0x7FFF)
8699 GPR_UH(destreg,1) = 0x7FFF;
8700 else if (LO_SW(1) < -0x8000)
8701 GPR_UH(destreg,1) = 0x8000;
8703 GPR_UH(destreg,1) = LO_UH(2);
8704 if (HI_SW(0) > 0x7FFF)
8705 GPR_UH(destreg,2) = 0x7FFF;
8706 else if (HI_SW(0) < -0x8000)
8707 GPR_UH(destreg,2) = 0x8000;
8709 GPR_UH(destreg,2) = HI_UH(0);
8710 if (HI_SW(1) > 0x7FFF)
8711 GPR_UH(destreg,3) = 0x7FFF;
8712 else if (HI_SW(1) < -0x8000)
8713 GPR_UH(destreg,3) = 0x8000;
8715 GPR_UH(destreg,3) = HI_UH(2);
8716 if (LO_SW(2) > 0x7FFF)
8717 GPR_UH(destreg,4) = 0x7FFF;
8718 else if (LO_SW(2) < -0x8000)
8719 GPR_UH(destreg,4) = 0x8000;
8721 GPR_UH(destreg,4) = LO_UH(4);
8722 if (LO_SW(3) > 0x7FFF)
8723 GPR_UH(destreg,5) = 0x7FFF;
8724 else if (LO_SW(3) < -0x8000)
8725 GPR_UH(destreg,5) = 0x8000;
8727 GPR_UH(destreg,5) = LO_UH(6);
8728 if (HI_SW(2) > 0x7FFF)
8729 GPR_UH(destreg,6) = 0x7FFF;
8730 else if (HI_SW(2) < -0x8000)
8731 GPR_UH(destreg,6) = 0x8000;
8733 GPR_UH(destreg,6) = HI_UH(4);
8734 if (HI_SW(3) > 0x7FFF)
8735 GPR_UH(destreg,7) = 0x7FFF;
8736 else if (HI_SW(3) < -0x8000)
8737 GPR_UH(destreg,7) = 0x8000;
8739 GPR_UH(destreg,7) = HI_UH(6);
8744 // end-sanitize-r5900
8745 // start-sanitize-r5900
8747 011100,5.RS,5.RT,5.RD,00111101000:MMI1:32::PMINH
8750 unsigned32 instruction = instruction_0;
8751 int destreg = ((instruction >> 11) & 0x0000001F);
8752 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8753 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8754 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8755 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8758 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
8760 if (RS_SH(i) < RT_SH(i)) GPR_SH(destreg,i) = RS_SH(i);
8761 else GPR_SH(destreg,i) = RT_SH(i);
8766 // end-sanitize-r5900
8767 // start-sanitize-r5900
8769 011100,5.RS,5.RT,5.RD,00011101000:MMI1:32::PMINW
8772 unsigned32 instruction = instruction_0;
8773 int destreg = ((instruction >> 11) & 0x0000001F);
8774 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8775 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8776 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8777 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8780 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8782 if (RS_SW(i) < RT_SW(i)) GPR_SW(destreg,i) = RS_SW(i);
8783 else GPR_SW(destreg,i) = RT_SW(i);
8788 // end-sanitize-r5900
8789 // start-sanitize-r5900
8791 011100,5.RS,5.RT,5.RD,10100001001:MMI2:32::PMSUBH
8794 unsigned32 instruction = instruction_0;
8795 int destreg = ((instruction >> 11) & 0x0000001F);
8796 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8797 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8798 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8799 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8801 GPR_SW(destreg,0) = LO_SW(0) -= (RS_SH(0) * RT_SH(0));
8802 LO_SW(1) -= (RS_SH(1) * RT_SH(1));
8803 GPR_SW(destreg,1) = HI_SW(0) -= (RS_SH(2) * RT_SH(2));
8804 HI_SW(1) -= (RS_SH(3) * RT_SH(3));
8805 GPR_SW(destreg,2) = LO_SW(2) -= (RS_SH(4) * RT_SH(4));
8806 LO_SW(3) -= (RS_SH(5) * RT_SH(5));
8807 GPR_SW(destreg,3) = HI_SW(2) -= (RS_SH(6) * RT_SH(6));
8808 HI_SW(3) -= (RS_SH(7) * RT_SH(7));
8812 // end-sanitize-r5900
8813 // start-sanitize-r5900
8815 011100,5.RS,5.RT,5.RD,00100001001:MMI2:32::PMSUBW
8818 unsigned32 instruction = instruction_0;
8819 int destreg = ((instruction >> 11) & 0x0000001F);
8820 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8821 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8822 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8823 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8825 signed64 sum0 = WORD64( HI_SW(0), LO_SW(0) );
8826 signed64 sum1 = WORD64( HI_SW(2), LO_SW(2) );
8827 signed64 prod0 = (signed64)RS_SW(0) * (signed64)RT_SW(0);
8828 signed64 prod1 = (signed64)RS_SW(2) * (signed64)RT_SW(2);
8831 GPR_SD(destreg,0) = sum0;
8832 GPR_SD(destreg,1) = sum1;
8833 LO = SIGNEXTEND( sum0, 32 );
8834 HI = SIGNEXTEND( VH4_8(sum0), 32 );
8835 LO1 = SIGNEXTEND( sum1, 32 );
8836 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
8840 // end-sanitize-r5900
8841 // start-sanitize-r5900
8843 011100,5.RS,000000000001000101001:MMI3:32::PMTHI
8846 unsigned32 instruction = instruction_0;
8847 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8848 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8855 // end-sanitize-r5900
8856 // start-sanitize-r5900
8858 011100,5.RS,000000000001001101001:MMI3:32::PMTLO
8861 unsigned32 instruction = instruction_0;
8862 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8863 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8870 // end-sanitize-r5900
8871 // start-sanitize-r5900
8873 011100,5.RS,000000000000000110001:MMINORM:32::PMTHL.LW
8876 unsigned32 instruction = instruction_0;
8877 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8878 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8880 LO_UW(0) = RS_UW(0);
8881 HI_UW(0) = RS_UW(1);
8882 LO_UW(2) = RS_UW(2);
8883 HI_UW(2) = RS_UW(3);
8887 // end-sanitize-r5900
8888 // start-sanitize-r5900
8890 011100,5.RS,5.RT,5.RD,11100001001:MMI2:32::PMULTH
8893 unsigned32 instruction = instruction_0;
8894 int destreg = ((instruction >> 11) & 0x0000001F);
8895 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8896 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8897 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8898 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8900 GPR_SW(destreg,0) = LO_SW(0) = (RS_SH(0) * RT_SH(0));
8901 LO_SW(1) = (RS_SH(1) * RT_SH(1));
8902 GPR_SW(destreg,1) = HI_SW(0) = (RS_SH(2) * RT_SH(2));
8903 HI_SW(1) = (RS_SH(3) * RT_SH(3));
8904 GPR_SW(destreg,2) = LO_SW(2) = (RS_SH(4) * RT_SH(4));
8905 LO_SW(3) = (RS_SH(5) * RT_SH(5));
8906 GPR_SW(destreg,3) = HI_SW(2) = (RS_SH(6) * RT_SH(6));
8907 HI_SW(3) = (RS_SH(7) * RT_SH(7));
8911 // end-sanitize-r5900
8912 // start-sanitize-r5900
8914 011100,5.RS,5.RT,5.RD,01100101001:MMI3:32::PMULTUW
8917 unsigned32 instruction = instruction_0;
8918 int destreg = ((instruction >> 11) & 0x0000001F);
8919 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8920 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8921 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8922 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8924 unsigned64 sum0 = 0;
8925 unsigned64 sum1 = 0;
8926 unsigned64 prod0 = (unsigned64)RS_UW(0) * (unsigned64)RT_UW(0);
8927 unsigned64 prod1 = (unsigned64)RS_UW(2) * (unsigned64)RT_UW(2);
8930 GPR_UD(destreg,0) = sum0;
8931 GPR_UD(destreg,1) = sum1;
8932 LO = SIGNEXTEND( sum0, 32 );
8933 HI = SIGNEXTEND( VH4_8(sum0), 32 );
8934 LO1 = SIGNEXTEND( sum1, 32 );
8935 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
8939 // end-sanitize-r5900
8940 // start-sanitize-r5900
8942 011100,5.RS,5.RT,5.RD,01100001001:MMI2:32::PMULTW
8945 unsigned32 instruction = instruction_0;
8946 int destreg = ((instruction >> 11) & 0x0000001F);
8947 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8948 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8949 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8950 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8954 signed64 prod0 = (signed64)RS_SW(0) * (signed64)RT_SW(0);
8955 signed64 prod1 = (signed64)RS_SW(2) * (signed64)RT_SW(2);
8958 GPR_SD(destreg,0) = sum0;
8959 GPR_SD(destreg,1) = sum1;
8960 LO = SIGNEXTEND( sum0, 32 );
8961 HI = SIGNEXTEND( VH4_8(sum0), 32 );
8962 LO1 = SIGNEXTEND( sum1, 32 );
8963 HI1 = SIGNEXTEND( VH4_8(sum1), 32 );
8967 // end-sanitize-r5900
8968 // start-sanitize-r5900
8970 011100,5.RS,5.RT,5.RD,10011101001:MMI3:32::PNOR
8973 unsigned32 instruction = instruction_0;
8974 int destreg = ((instruction >> 11) & 0x0000001F);
8975 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8976 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8977 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8978 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
8981 for(i=0;i<WORDS_IN_MMI_REGS;i++)
8982 GPR_UW(destreg,i) = ~(RS_UW(i) | RT_UW(i));
8986 // end-sanitize-r5900
8987 // start-sanitize-r5900
8989 011100,5.RS,5.RT,5.RD,10010101001:MMI3:32::POR
8992 unsigned32 instruction = instruction_0;
8993 int destreg = ((instruction >> 11) & 0x0000001F);
8994 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
8995 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
8996 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
8997 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9000 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9001 GPR_UW(destreg,i) = (RS_UW(i) | RT_UW(i));
9005 // end-sanitize-r5900
9006 // start-sanitize-r5900
9008 01110000000,5.RT,5.RD,11111001000:MMI0:32::PPAC5
9011 unsigned32 instruction = instruction_0;
9012 int destreg = ((instruction >> 11) & 0x0000001F);
9013 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9014 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9017 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9019 unsigned32 x = RT_UW(i);
9020 GPR_UW(destreg,i) = ((x & (1 << 31)) >> (31 - 15))
9021 | ((x & (31 << 19)) >> (19 - 10))
9022 | ((x & (31 << 11)) >> (11 - 5))
9023 | ((x & (31 << 3)) >> (3 - 0));
9028 // end-sanitize-r5900
9029 // start-sanitize-r5900
9031 011100,5.RS,5.RT,5.RD,11011001000:MMI0:32::PPACB
9034 unsigned32 instruction = instruction_0;
9035 int destreg = ((instruction >> 11) & 0x0000001F);
9036 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9037 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9038 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9039 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9041 GPR_UB(destreg,0) = RT_UB(0);
9042 GPR_UB(destreg,1) = RT_UB(2);
9043 GPR_UB(destreg,2) = RT_UB(4);
9044 GPR_UB(destreg,3) = RT_UB(6);
9045 GPR_UB(destreg,4) = RT_UB(8);
9046 GPR_UB(destreg,5) = RT_UB(10);
9047 GPR_UB(destreg,6) = RT_UB(12);
9048 GPR_UB(destreg,7) = RT_UB(14);
9049 GPR_UB(destreg,8) = RS_UB(0);
9050 GPR_UB(destreg,9) = RS_UB(2);
9051 GPR_UB(destreg,10) = RS_UB(4);
9052 GPR_UB(destreg,11) = RS_UB(6);
9053 GPR_UB(destreg,12) = RS_UB(8);
9054 GPR_UB(destreg,13) = RS_UB(10);
9055 GPR_UB(destreg,14) = RS_UB(12);
9056 GPR_UB(destreg,15) = RS_UB(14);
9060 // end-sanitize-r5900
9061 // start-sanitize-r5900
9063 011100,5.RS,5.RT,5.RD,10111001000:MMI0:32::PPACH
9066 unsigned32 instruction = instruction_0;
9067 int destreg = ((instruction >> 11) & 0x0000001F);
9068 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9069 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9070 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9071 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9073 GPR_UH(destreg,0) = RT_UH(0);
9074 GPR_UH(destreg,1) = RT_UH(2);
9075 GPR_UH(destreg,2) = RT_UH(4);
9076 GPR_UH(destreg,3) = RT_UH(6);
9077 GPR_UH(destreg,4) = RS_UH(0);
9078 GPR_UH(destreg,5) = RS_UH(2);
9079 GPR_UH(destreg,6) = RS_UH(4);
9080 GPR_UH(destreg,7) = RS_UH(6);
9084 // end-sanitize-r5900
9085 // start-sanitize-r5900
9087 011100,5.RS,5.RT,5.RD,10011001000:MMI0:32::PPACW
9090 unsigned32 instruction = instruction_0;
9091 int destreg = ((instruction >> 11) & 0x0000001F);
9092 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9093 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9094 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9095 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9097 GPR_UW(destreg,0) = RT_UW(0);
9098 GPR_UW(destreg,1) = RT_UW(2);
9099 GPR_UW(destreg,2) = RS_UW(0);
9100 GPR_UW(destreg,3) = RS_UW(2);
9104 // end-sanitize-r5900
9105 // start-sanitize-r5900
9107 01110000000,5.RT,5.RD,11011001001:MMI2:32::PREVH
9110 unsigned32 instruction = instruction_0;
9111 int destreg = ((instruction >> 11) & 0x0000001F);
9112 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9113 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9115 GPR_UH(destreg,0) = RT_UH(3);
9116 GPR_UH(destreg,1) = RT_UH(2);
9117 GPR_UH(destreg,2) = RT_UH(1);
9118 GPR_UH(destreg,3) = RT_UH(0);
9119 GPR_UH(destreg,4) = RT_UH(7);
9120 GPR_UH(destreg,5) = RT_UH(6);
9121 GPR_UH(destreg,6) = RT_UH(5);
9122 GPR_UH(destreg,7) = RT_UH(4);
9126 // end-sanitize-r5900
9127 // start-sanitize-r5900
9129 01110000000,5.RT,5.RD,11111001001:MMI2:32::PROT3W
9132 unsigned32 instruction = instruction_0;
9133 int destreg = ((instruction >> 11) & 0x0000001F);
9134 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9135 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9137 GPR_UW(destreg,0) = RT_UW(0);
9138 GPR_UW(destreg,1) = RT_UW(3);
9139 GPR_UW(destreg,2) = RT_UW(1);
9140 GPR_UW(destreg,3) = RT_UW(2);
9144 // end-sanitize-r5900
9145 // start-sanitize-r5900
9147 01110000000,5.RT,5.RD,5.SHIFT,110100:MMINORM:32::PSLLH
9150 unsigned32 instruction = instruction_0;
9151 int op1 = ((instruction >> 6) & 0x0000001F);
9152 int destreg = ((instruction >> 11) & 0x0000001F);
9153 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9154 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9156 int shift_by = op1 & (16-1);
9158 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9159 GPR_UH(destreg,i) = (RT_UH(i) << shift_by);
9163 // end-sanitize-r5900
9164 // start-sanitize-r5900
9166 011100,5.RS,5.RT,5.RD,00010001001:MMI2:32::PSLLVW
9169 unsigned32 instruction = instruction_0;
9170 int destreg = ((instruction >> 11) & 0x0000001F);
9171 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9172 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9173 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9174 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9176 int s0 = (RS_UB(0) & 0x1F);
9177 int s1 = (RS_UB(8) & 0x1F);
9178 signed32 temp0 = RT_UW(0) << s0;
9179 signed32 temp1 = RT_UW(2) << s1;
9180 GPR_SD(destreg,0) = (signed64)temp0;
9181 GPR_SD(destreg,1) = (signed64)temp1;
9185 // end-sanitize-r5900
9186 // start-sanitize-r5900
9188 01110000000,5.RT,5.RD,5.SHIFT,111100:MMINORM:32::PSLLW
9191 unsigned32 instruction = instruction_0;
9192 int op1 = ((instruction >> 6) & 0x0000001F);
9193 int destreg = ((instruction >> 11) & 0x0000001F);
9194 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9195 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9197 int shift_by = op1 & (32-1);
9199 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9200 GPR_UW(destreg,i) = (RT_UW(i) << shift_by);
9204 // end-sanitize-r5900
9205 // start-sanitize-r5900
9207 01110000000,5.RT,5.RD,5.SHIFT,110111:MMINORM:32::PSRAH
9210 unsigned32 instruction = instruction_0;
9211 int op1 = ((instruction >> 6) & 0x0000001F);
9212 int destreg = ((instruction >> 11) & 0x0000001F);
9213 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9214 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9216 int shift_by = op1 & (16-1);
9218 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9219 GPR_SH(destreg,i) = SIGNEXTEND( (RT_SH(i) >> shift_by), (16-shift_by) );
9223 // end-sanitize-r5900
9224 // start-sanitize-r5900
9226 011100,5.RS,5.RT,5.RD,00011101001:MMI3:32::PSRAVW
9229 unsigned32 instruction = instruction_0;
9230 int destreg = ((instruction >> 11) & 0x0000001F);
9231 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9232 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9233 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9234 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9236 GPR_SD(destreg,0) = SIGNEXTEND( (RT_SW (0) >> (RS_UB(0) & 0x1F)), 32-(RS_UB(0) & 0x1F) );
9237 GPR_SD(destreg,1) = SIGNEXTEND( (RT_SW (2) >> (RS_UB(8) & 0x1F)), 32-(RS_UB(8) & 0x1F) );
9241 // end-sanitize-r5900
9242 // start-sanitize-r5900
9244 01110000000,5.RT,5.RD,5.SHIFT,111111:MMINORM:32::PSRAW
9247 unsigned32 instruction = instruction_0;
9248 int op1 = ((instruction >> 6) & 0x0000001F);
9249 int destreg = ((instruction >> 11) & 0x0000001F);
9250 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9251 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9253 int shift_by = op1 & (32-1);
9255 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9256 GPR_SW(destreg,i) = SIGNEXTEND( (RT_SW(i) >> shift_by), (32-shift_by) );
9260 // end-sanitize-r5900
9261 // start-sanitize-r5900
9263 01110000000,5.RT,5.RD,5.SHIFT,110110:MMINORM:32::PSRLH
9266 unsigned32 instruction = instruction_0;
9267 int op1 = ((instruction >> 6) & 0x0000001F);
9268 int destreg = ((instruction >> 11) & 0x0000001F);
9269 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9270 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9272 int shift_by = op1 & (16-1);
9274 for(i=0;i<HALFWORDS_IN_MMI_REGS;i++)
9275 GPR_UH(destreg,i) = (RT_UH(i) >> shift_by);
9279 // end-sanitize-r5900
9280 // start-sanitize-r5900
9282 011100,5.RS,5.RT,5.RD,00011001001:MMI2:32::PSRLVW
9285 unsigned32 instruction = instruction_0;
9286 int destreg = ((instruction >> 11) & 0x0000001F);
9287 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9288 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9289 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9290 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9292 GPR_UD(destreg,0) = SIGNEXTEND ( RT_UW(0) >> (RS_UB(0) & 0x1F), 31);
9293 GPR_UD(destreg,1) = SIGNEXTEND ( RT_UW(2) >> (RS_UB(8) & 0x1F), 31);
9297 // end-sanitize-r5900
9298 // start-sanitize-r5900
9300 01110000000,5.RT,5.RD,5.SHIFT,111110:MMINORM:32::PSRLW
9303 unsigned32 instruction = instruction_0;
9304 int op1 = ((instruction >> 6) & 0x0000001F);
9305 int destreg = ((instruction >> 11) & 0x0000001F);
9306 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9307 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9309 int shift_by = op1 & (32-1);
9311 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9312 GPR_UW(destreg,i) = (RT_UW(i) >> shift_by);
9316 // end-sanitize-r5900
9317 // start-sanitize-r5900
9319 011100,5.RS,5.RT,5.RD,01001001000:MMI0:32::PSUBB
9322 unsigned32 instruction = instruction_0;
9323 int destreg = ((instruction >> 11) & 0x0000001F);
9324 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9325 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9326 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9327 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9330 for (i=0; i < BYTES_IN_MMI_REGS; i++)
9335 GPR_SB(destreg,i) = r;
9340 // end-sanitize-r5900
9341 // start-sanitize-r5900
9343 011100,5.RS,5.RT,5.RD,00101001000:MMI0:32::PSUBH
9346 unsigned32 instruction = instruction_0;
9347 int destreg = ((instruction >> 11) & 0x0000001F);
9348 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9349 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9350 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9351 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9354 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
9359 GPR_SH(destreg,i) = r;
9364 // end-sanitize-r5900
9365 // start-sanitize-r5900
9367 011100,5.RS,5.RT,5.RD,11001001000:MMI0:32::PSUBSB
9370 unsigned32 instruction = instruction_0;
9371 int destreg = ((instruction >> 11) & 0x0000001F);
9372 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9373 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9374 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9375 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9378 for (i=0; i < BYTES_IN_MMI_REGS; i++)
9384 GPR_SB(destreg,i) = 127;
9386 GPR_SB(destreg,i) = -128;
9388 GPR_SB(destreg,i) = r;
9393 // end-sanitize-r5900
9394 // start-sanitize-r5900
9396 011100,5.RS,5.RT,5.RD,10101001000:MMI0:32::PSUBSH
9399 unsigned32 instruction = instruction_0;
9400 int destreg = ((instruction >> 11) & 0x0000001F);
9401 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9402 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9403 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9404 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9407 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
9413 GPR_SH(destreg,i) = 32767;
9414 else if (r < -32768)
9415 GPR_SH(destreg,i) = -32768;
9417 GPR_SH(destreg,i) = r;
9422 // end-sanitize-r5900
9423 // start-sanitize-r5900
9425 011100,5.RS,5.RT,5.RD,10001001000:MMI0:32::PSUBSW
9428 unsigned32 instruction = instruction_0;
9429 int destreg = ((instruction >> 11) & 0x0000001F);
9430 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9431 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9432 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9433 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9436 for (i=0; i < WORDS_IN_MMI_REGS; i++)
9438 signed64 s = RS_SW(i);
9439 signed64 t = RT_SW(i);
9441 if (r > (int)0x7FFFFFFF)
9442 GPR_SW(destreg,i) = (int)0x7FFFFFFF;
9443 else if (r < (int)0x80000000)
9444 GPR_SW(destreg,i) = (int)0x80000000;
9446 GPR_SW(destreg,i) = r;
9451 // end-sanitize-r5900
9452 // start-sanitize-r5900
9454 011100,5.RS,5.RT,5.RD,11001101000:MMI1:32::PSUBUB
9457 unsigned32 instruction = instruction_0;
9458 int destreg = ((instruction >> 11) & 0x0000001F);
9459 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9460 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9461 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9462 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9465 for (i=0; i < BYTES_IN_MMI_REGS; i++)
9467 unsigned int s = RS_UB(i);
9468 unsigned int t = RT_UB(i);
9469 unsigned int r = s - t;
9471 GPR_UB(destreg,i) = 0;
9473 GPR_UB(destreg,i) = r;
9478 // end-sanitize-r5900
9479 // start-sanitize-r5900
9481 011100,5.RS,5.RT,5.RD,10101101000:MMI1:32::PSUBUH
9484 unsigned32 instruction = instruction_0;
9485 int destreg = ((instruction >> 11) & 0x0000001F);
9486 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9487 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9488 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9489 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9492 for (i=0; i < HALFWORDS_IN_MMI_REGS; i++)
9494 unsigned int s = RS_UH(i);
9495 unsigned int t = RT_UH(i);
9496 unsigned int r = s - t;
9498 GPR_UH(destreg,i) = 0;
9500 GPR_UH(destreg,i) = r;
9505 // end-sanitize-r5900
9506 // start-sanitize-r5900
9508 011100,5.RS,5.RT,5.RD,10001101000:MMI1:32::PSUBUW
9511 unsigned32 instruction = instruction_0;
9512 int destreg = ((instruction >> 11) & 0x0000001F);
9513 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9514 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9515 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9516 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9519 for (i=0; i < WORDS_IN_MMI_REGS; i++)
9521 unsigned64 s = RS_UW(i);
9522 unsigned64 t = RT_UW(i);
9523 unsigned64 r = s - t;
9525 GPR_UW(destreg,i) = 0;
9527 GPR_UW(destreg,i) = r;
9532 // end-sanitize-r5900
9533 // start-sanitize-r5900
9535 011100,5.RS,5.RT,5.RD,00001001000:MMI0:32::PSUBW
9538 unsigned32 instruction = instruction_0;
9539 int destreg = ((instruction >> 11) & 0x0000001F);
9540 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9541 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9542 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9543 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9546 for (i=0; i < WORDS_IN_MMI_REGS; i++)
9548 signed64 s = RS_SW(i);
9549 signed64 t = RT_SW(i);
9551 GPR_SW(destreg,i) = r;
9556 // end-sanitize-r5900
9557 // start-sanitize-r5900
9559 011100,5.RS,5.RT,5.RD,10011001001:MMI2:32::PXOR
9562 unsigned32 instruction = instruction_0;
9563 int destreg = ((instruction >> 11) & 0x0000001F);
9564 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9565 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9566 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9567 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9570 for(i=0;i<WORDS_IN_MMI_REGS;i++)
9571 GPR_UW(destreg,i) = (RS_UW(i) ^ RT_UW(i));
9575 // end-sanitize-r5900
9576 // start-sanitize-r5900
9578 011100,5.RS,5.RT,5.RD,11011101000:MMI1:32::QFSRV
9581 unsigned32 instruction = instruction_0;
9582 int destreg = ((instruction >> 11) & 0x0000001F);
9583 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9584 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9585 signed_word rs_reg = GPR[((instruction >> 21) & 0x0000001F)];
9586 signed_word rs_reg1 = GPR1[((instruction >> 21) & 0x0000001F)];
9588 int bytes = (SA / 8) % 16;
9590 SignalException(ReservedInstruction,instruction);
9594 for(i=0;i<(16-bytes);i++)
9595 GPR_SB(destreg,i) = RT_SB(bytes+i);
9597 GPR_SB(destreg,i) = RS_SB(i-(16-bytes));
9602 // end-sanitize-r5900
9603 // start-sanitize-r5900
9605 011111,5.RS,5.RT,16.OFFSET:NORMAL:128::SQ
9608 unsigned32 instruction = instruction_0;
9609 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
9610 signed_word rsigned_word = GPR[((instruction >> 16) & 0x0000001F)];
9611 signed_word rsigned_word1 = GPR1[((instruction >> 16) & 0x0000001F)];
9612 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
9614 unsigned64 vaddr = ((unsigned64)op1 + offset);
9617 if ((vaddr & 15) != 0)
9618 SignalExceptionAddressStore();
9621 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
9623 unsigned64 memval = 0;
9624 unsigned64 memval1 = 0;
9625 memval = rsigned_word;
9626 memval1 = rsigned_word1;
9628 StoreMemory(uncached,AccessLength_QUADWORD,memval,memval1,paddr,vaddr,isREAL);
9635 // end-sanitize-r5900
9637 // start-sanitize-cygnus-never
9639 // // FIXME FIXME FIXME What is this instruction?
9640 // 111011,5.RS,5.RT,16.OFFSET:NORMAL:32::<INT>
9645 // // start-sanitize-r5900
9647 // // end-sanitize-r5900
9649 // // start-sanitize-tx19
9651 // // end-sanitize-tx19
9653 // unsigned32 instruction = instruction_0;
9654 // signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
9655 // signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
9656 // signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
9658 // if (CoProcPresent(3))
9659 // SignalException(CoProcessorUnusable);
9661 // SignalException(ReservedInstruction,instruction);
9665 // end-sanitize-cygnus-never
9666 // start-sanitize-cygnus-never
9668 // // FIXME FIXME FIXME What is this?
9669 // 11100,******,00001:RR:16::SDBBP
9672 // unsigned32 instruction = instruction_0;
9673 // if (have_extendval)
9674 // SignalException (ReservedInstruction, instruction);
9676 // SignalException(DebugBreakPoint,instruction);
9680 // end-sanitize-cygnus-never
9681 // start-sanitize-cygnus-never
9683 // // FIXME FIXME FIXME What is this?
9684 // 000000,********************,001110:SPECIAL:32::SDBBP
9687 // unsigned32 instruction = instruction_0;
9689 // SignalException(DebugBreakPoint,instruction);
9693 // end-sanitize-cygnus-never
9694 // start-sanitize-cygnus-never
9696 // // FIXME FIXME FIXME This apparently belongs to the vr4100 which
9697 // // isn't yet reconized by this simulator.
9698 // 000000,5.RS,5.RT,0000000000101000:SPECIAL:32::MADD16
9701 // unsigned32 instruction = instruction_0;
9702 // signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
9703 // signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
9705 // CHECKHILO("Multiply-Add");
9707 // unsigned64 temp = (op1 * op2);
9708 // temp += (SET64HI(VL4_8(HI)) | VL4_8(LO));
9709 // LO = SIGNEXTEND((unsigned64)VL4_8(temp),32);
9710 // HI = SIGNEXTEND((unsigned64)VH4_8(temp),32);
9715 // end-sanitize-cygnus-never
9716 // start-sanitize-cygnus-never
9718 // // FIXME FIXME FIXME This apparently belongs to the vr4100 which
9719 // // isn't yet reconized by this simulator.
9720 // 000000,5.RS,5.RT,0000000000101001:SPECIAL:64::DMADD16
9723 // unsigned32 instruction = instruction_0;
9724 // signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
9725 // signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
9727 // CHECKHILO("Multiply-Add");
9729 // unsigned64 temp = (op1 * op2);
9735 // start-sanitize-cygnus-never