3 // In mips.igen, the semantics for many of the instructions were created
4 // using code generated by gencode. Those semantic segments could be
8 // <insn-word> { "+" <insn-word> }
15 // { <insn-mnemonic> }
20 // IGEN config - mips16
21 // :option:16::insn-bit-size:16
22 // :option:16::hi-bit-nr:15
23 :option:16::insn-specifying-widths:true
24 :option:16::gen-delayed-branch:false
26 // IGEN config - mips32/64..
27 // :option:32::insn-bit-size:32
28 // :option:32::hi-bit-nr:31
29 :option:32::insn-specifying-widths:true
30 :option:32::gen-delayed-branch:false
33 // Generate separate simulators for each target
34 // :option:::multi-sim:true
37 // Models known by this simulator
38 :model:::mipsI:mips3000:
39 :model:::mipsII:mips6000:
40 :model:::mipsIII:mips4000:
41 :model:::mipsIV:mips8000:
42 :model:::mips16:mips16:
43 :model:::r3900:mips3900:
44 :model:::vr4100:mips4100:
45 :model:::vr5000:mips5000:
49 // Pseudo instructions known by IGEN
52 SignalException (ReservedInstruction, 0);
56 // Pseudo instructions known by interp.c
57 // For grep - RSVD_INSTRUCTION, RSVD_INSTRUCTION_MASK
58 000000,5.*,5.*,5.*,5.OP,000101:SPECIAL:32::RSVD
61 SignalException (ReservedInstruction, instruction_0);
68 // Simulate a 32 bit delayslot instruction
71 :function:::address_word:delayslot32:address_word target
73 instruction_word delay_insn;
74 sim_events_slip (SD, 1);
76 CIA = CIA + 4; /* NOTE not mips16 */
77 STATE |= simDELAYSLOT;
78 delay_insn = IMEM32 (CIA); /* NOTE not mips16 */
79 idecode_issue (CPU_, delay_insn, (CIA));
80 STATE &= ~simDELAYSLOT;
84 :function:::address_word:nullify_next_insn32:
86 sim_events_slip (SD, 1);
87 dotrace (SD, CPU, tracefh, 2, CIA + 4, 4, "load instruction");
93 // Check that an access to a HI/LO register meets timing requirements
95 // The following requirements exist:
97 // - A MT {HI,LO} update was not immediatly preceeded by a MF {HI,LO} read
98 // - A OP {HI,LO} update was not immediatly preceeded by a MF {HI,LO} read
99 // - A MF {HI,LO} read was not corrupted by a preceeding MT{LO,HI} update
100 // corruption occures when MT{LO,HI} is preceeded by a OP {HI,LO}.
103 :function:::int:check_mf_cycles:hilo_history *history, signed64 time, const char *new
105 if (history->mf.timestamp + 3 > time)
107 sim_engine_abort (SD, CPU, CIA, "HILO: %s: %s at 0x%08lx too close to MF at 0x%08lx\n",
108 itable[MY_INDEX].name,
110 (long) history->mf.cia);
116 :function:::int:check_mt_hilo:hilo_history *history
117 *mipsI,mipsII,mipsIII,mipsIV:
121 signed64 time = sim_events_time (SD);
122 int ok = check_mf_cycles (SD_, history, time, "MT");
123 history->mt.timestamp = time;
124 history->mt.cia = CIA;
128 :function:::int:check_mt_hilo:hilo_history *history
131 signed64 time = sim_events_time (SD);
132 history->mt.timestamp = time;
133 history->mt.cia = CIA;
138 :function:::int:check_mf_hilo:hilo_history *history, hilo_history *peer
139 *mipsI,mipsII,mipsIII,mipsIV:
144 signed64 time = sim_events_time (SD);
147 && peer->mt.timestamp > history->op.timestamp
148 && history->mt.timestamp < history->op.timestamp
149 && ! (history->mf.timestamp > history->op.timestamp
150 && history->mf.timestamp < peer->mt.timestamp)
151 && ! (peer->mf.timestamp > history->op.timestamp
152 && peer->mf.timestamp < peer->mt.timestamp))
154 /* The peer has been written to since the last OP yet we have
156 sim_engine_abort (SD, CPU, CIA, "HILO: %s: MF at 0x%08lx following OP at 0x%08lx corrupted by MT at 0x%08lx\n",
157 itable[MY_INDEX].name,
159 (long) history->op.cia,
160 (long) peer->mt.cia);
163 history->mf.timestamp = time;
164 history->mf.cia = CIA;
170 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
171 *mipsI,mipsII,mipsIII,mipsIV:
175 signed64 time = sim_events_time (SD);
176 int ok = (check_mf_cycles (SD_, hi, time, "OP")
177 && check_mf_cycles (SD_, lo, time, "OP"));
178 hi->op.timestamp = time;
179 lo->op.timestamp = time;
185 // The r3900 mult and multu insns _can_ be exectuted immediatly after
187 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
190 /* FIXME: could record the fact that a stall occured if we want */
191 signed64 time = sim_events_time (SD);
192 hi->op.timestamp = time;
193 lo->op.timestamp = time;
200 :function:::int:check_div_hilo:hilo_history *hi, hilo_history *lo
201 *mipsI,mipsII,mipsIII,mipsIV:
206 signed64 time = sim_events_time (SD);
207 int ok = (check_mf_cycles (SD_, hi, time, "OP")
208 && check_mf_cycles (SD_, lo, time, "OP"));
209 hi->op.timestamp = time;
210 lo->op.timestamp = time;
221 // Mips Architecture:
223 // CPU Instruction Set (mipsI - mipsIV)
228 000000,5.RS,5.RT,5.RD,00000,100000:SPECIAL:32::ADD
229 "add r<RD>, r<RS>, r<RT>"
230 *mipsI,mipsII,mipsIII,mipsIV:
235 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
237 ALU32_BEGIN (GPR[RS]);
241 TRACE_ALU_RESULT (GPR[RD]);
246 001000,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDI
247 "addi r<RT>, r<RS>, IMMEDIATE"
248 *mipsI,mipsII,mipsIII,mipsIV:
253 TRACE_ALU_INPUT2 (GPR[RS], EXTEND16 (IMMEDIATE));
255 ALU32_BEGIN (GPR[RS]);
256 ALU32_ADD (EXTEND16 (IMMEDIATE));
259 TRACE_ALU_RESULT (GPR[RT]);
264 :function:::void:do_addiu:int rs, int rt, unsigned16 immediate
266 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
267 GPR[rt] = EXTEND32 (GPR[rs] + EXTEND16 (immediate));
268 TRACE_ALU_RESULT (GPR[rt]);
271 001001,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDIU
272 "addiu r<RT>, r<RS>, <IMMEDIATE>"
273 *mipsI,mipsII,mipsIII,mipsIV:
278 do_addiu (SD_, RS, RT, IMMEDIATE);
283 :function:::void:do_addu:int rs, int rt, int rd
285 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
286 GPR[rd] = EXTEND32 (GPR[rs] + GPR[rt]);
287 TRACE_ALU_RESULT (GPR[rd]);
290 000000,5.RS,5.RT,5.RD,00000,100001:SPECIAL:32::ADDU
291 "addu r<RD>, r<RS>, r<RT>"
292 *mipsI,mipsII,mipsIII,mipsIV:
297 do_addu (SD_, RS, RT, RD);
302 :function:::void:do_and:int rs, int rt, int rd
304 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
305 GPR[rd] = GPR[rs] & GPR[rt];
306 TRACE_ALU_RESULT (GPR[rd]);
309 000000,5.RS,5.RT,5.RD,00000,100100:SPECIAL:32::AND
310 "and r<RD>, r<RS>, r<RT>"
311 *mipsI,mipsII,mipsIII,mipsIV:
316 do_and (SD_, RS, RT, RD);
321 001100,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ANDI
322 "and r<RT>, r<RS>, <IMMEDIATE>"
323 *mipsI,mipsII,mipsIII,mipsIV:
328 TRACE_ALU_INPUT2 (GPR[RS], IMMEDIATE);
329 GPR[RT] = GPR[RS] & IMMEDIATE;
330 TRACE_ALU_RESULT (GPR[RT]);
335 000100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQ
336 "beq r<RS>, r<RT>, <OFFSET>"
337 *mipsI,mipsII,mipsIII,mipsIV:
342 address_word offset = EXTEND16 (OFFSET) << 2;
344 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
346 mark_branch_bug (NIA+offset);
347 DELAY_SLOT (NIA + offset);
353 010100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQL
354 "beql r<RS>, r<RT>, <OFFSET>"
362 address_word offset = EXTEND16 (OFFSET) << 2;
364 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
366 mark_branch_bug (NIA+offset);
367 DELAY_SLOT (NIA + offset);
370 NULLIFY_NEXT_INSTRUCTION ();
375 000001,5.RS,00001,16.OFFSET:REGIMM:32::BGEZ
376 "bgez r<RS>, <OFFSET>"
377 *mipsI,mipsII,mipsIII,mipsIV:
382 address_word offset = EXTEND16 (OFFSET) << 2;
384 if ((signed_word) GPR[RS] >= 0)
386 mark_branch_bug (NIA+offset);
387 DELAY_SLOT (NIA + offset);
393 000001,5.RS!31,10001,16.OFFSET:REGIMM:32::BGEZAL
394 "bgezal r<RS>, <OFFSET>"
395 *mipsI,mipsII,mipsIII,mipsIV:
400 address_word offset = EXTEND16 (OFFSET) << 2;
403 if ((signed_word) GPR[RS] >= 0)
405 mark_branch_bug (NIA+offset);
406 DELAY_SLOT (NIA + offset);
412 000001,5.RS!31,10011,16.OFFSET:REGIMM:32::BGEZALL
413 "bgezall r<RS>, <OFFSET>"
421 address_word offset = EXTEND16 (OFFSET) << 2;
424 /* NOTE: The branch occurs AFTER the next instruction has been
426 if ((signed_word) GPR[RS] >= 0)
428 mark_branch_bug (NIA+offset);
429 DELAY_SLOT (NIA + offset);
432 NULLIFY_NEXT_INSTRUCTION ();
437 000001,5.RS,00011,16.OFFSET:REGIMM:32::BGEZL
438 "bgezl r<RS>, <OFFSET>"
446 address_word offset = EXTEND16 (OFFSET) << 2;
448 if ((signed_word) GPR[RS] >= 0)
450 mark_branch_bug (NIA+offset);
451 DELAY_SLOT (NIA + offset);
454 NULLIFY_NEXT_INSTRUCTION ();
459 000111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZ
460 "bgtz r<RS>, <OFFSET>"
461 *mipsI,mipsII,mipsIII,mipsIV:
466 address_word offset = EXTEND16 (OFFSET) << 2;
468 if ((signed_word) GPR[RS] > 0)
470 mark_branch_bug (NIA+offset);
471 DELAY_SLOT (NIA + offset);
477 010111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZL
478 "bgtzl r<RS>, <OFFSET>"
486 address_word offset = EXTEND16 (OFFSET) << 2;
488 /* NOTE: The branch occurs AFTER the next instruction has been
490 if ((signed_word) GPR[RS] > 0)
492 mark_branch_bug (NIA+offset);
493 DELAY_SLOT (NIA + offset);
496 NULLIFY_NEXT_INSTRUCTION ();
501 000110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZ
502 "blez r<RS>, <OFFSET>"
503 *mipsI,mipsII,mipsIII,mipsIV:
508 address_word offset = EXTEND16 (OFFSET) << 2;
510 /* NOTE: The branch occurs AFTER the next instruction has been
512 if ((signed_word) GPR[RS] <= 0)
514 mark_branch_bug (NIA+offset);
515 DELAY_SLOT (NIA + offset);
521 010110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZL
522 "bgezl r<RS>, <OFFSET>"
530 address_word offset = EXTEND16 (OFFSET) << 2;
532 if ((signed_word) GPR[RS] <= 0)
534 mark_branch_bug (NIA+offset);
535 DELAY_SLOT (NIA + offset);
538 NULLIFY_NEXT_INSTRUCTION ();
543 000001,5.RS,00000,16.OFFSET:REGIMM:32::BLTZ
544 "bltz r<RS>, <OFFSET>"
545 *mipsI,mipsII,mipsIII,mipsIV:
550 address_word offset = EXTEND16 (OFFSET) << 2;
552 if ((signed_word) GPR[RS] < 0)
554 mark_branch_bug (NIA+offset);
555 DELAY_SLOT (NIA + offset);
561 000001,5.RS!31,10000,16.OFFSET:REGIMM:32::BLTZAL
562 "bltzal r<RS>, <OFFSET>"
563 *mipsI,mipsII,mipsIII,mipsIV:
568 address_word offset = EXTEND16 (OFFSET) << 2;
571 /* NOTE: The branch occurs AFTER the next instruction has been
573 if ((signed_word) GPR[RS] < 0)
575 mark_branch_bug (NIA+offset);
576 DELAY_SLOT (NIA + offset);
582 000001,5.RS!31,10010,16.OFFSET:REGIMM:32::BLTZALL
583 "bltzall r<RS>, <OFFSET>"
591 address_word offset = EXTEND16 (OFFSET) << 2;
594 if ((signed_word) GPR[RS] < 0)
596 mark_branch_bug (NIA+offset);
597 DELAY_SLOT (NIA + offset);
600 NULLIFY_NEXT_INSTRUCTION ();
605 000001,5.RS,00010,16.OFFSET:REGIMM:32::BLTZL
606 "bltzl r<RS>, <OFFSET>"
614 address_word offset = EXTEND16 (OFFSET) << 2;
616 /* NOTE: The branch occurs AFTER the next instruction has been
618 if ((signed_word) GPR[RS] < 0)
620 mark_branch_bug (NIA+offset);
621 DELAY_SLOT (NIA + offset);
624 NULLIFY_NEXT_INSTRUCTION ();
629 000101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNE
630 "bne r<RS>, r<RT>, <OFFSET>"
631 *mipsI,mipsII,mipsIII,mipsIV:
636 address_word offset = EXTEND16 (OFFSET) << 2;
638 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
640 mark_branch_bug (NIA+offset);
641 DELAY_SLOT (NIA + offset);
647 010101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNEL
648 "bnel r<RS>, r<RT>, <OFFSET>"
656 address_word offset = EXTEND16 (OFFSET) << 2;
658 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
660 mark_branch_bug (NIA+offset);
661 DELAY_SLOT (NIA + offset);
664 NULLIFY_NEXT_INSTRUCTION ();
669 000000,20.CODE,001101:SPECIAL:32::BREAK
671 *mipsI,mipsII,mipsIII,mipsIV:
676 /* Check for some break instruction which are reserved for use by the simulator. */
677 unsigned int break_code = instruction_0 & HALT_INSTRUCTION_MASK;
678 if (break_code == (HALT_INSTRUCTION & HALT_INSTRUCTION_MASK) ||
679 break_code == (HALT_INSTRUCTION2 & HALT_INSTRUCTION_MASK))
681 sim_engine_halt (SD, CPU, NULL, cia,
682 sim_exited, (unsigned int)(A0 & 0xFFFFFFFF));
684 else if (break_code == (BREAKPOINT_INSTRUCTION & HALT_INSTRUCTION_MASK) ||
685 break_code == (BREAKPOINT_INSTRUCTION2 & HALT_INSTRUCTION_MASK))
687 if (STATE & simDELAYSLOT)
688 PC = cia - 4; /* reference the branch instruction */
691 SignalException(BreakPoint, instruction_0);
696 /* If we get this far, we're not an instruction reserved by the sim. Raise
698 SignalException(BreakPoint, instruction_0);
707 000000,5.RS,5.RT,5.RD,00000,101100:SPECIAL:64::DADD
708 "dadd r<RD>, r<RS>, r<RT>"
714 /* this check's for overflow */
715 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
717 ALU64_BEGIN (GPR[RS]);
721 TRACE_ALU_RESULT (GPR[RD]);
726 011000,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDI
727 "daddi r<RT>, r<RS>, <IMMEDIATE>"
733 TRACE_ALU_INPUT2 (GPR[RS], EXTEND16 (IMMEDIATE));
735 ALU64_BEGIN (GPR[RS]);
736 ALU64_ADD (EXTEND16 (IMMEDIATE));
739 TRACE_ALU_RESULT (GPR[RT]);
744 :function:::void:do_daddiu:int rs, int rt, unsigned16 immediate
746 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
747 GPR[rt] = GPR[rs] + EXTEND16 (immediate);
748 TRACE_ALU_RESULT (GPR[rt]);
751 011001,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDIU
752 "daddu r<RT>, r<RS>, <IMMEDIATE>"
758 do_daddiu (SD_, RS, RT, IMMEDIATE);
763 :function:::void:do_daddu:int rs, int rt, int rd
765 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
766 GPR[rd] = GPR[rs] + GPR[rt];
767 TRACE_ALU_RESULT (GPR[rd]);
770 000000,5.RS,5.RT,5.RD,00000,101101:SPECIAL:64::DADDU
771 "daddu r<RD>, r<RS>, r<RT>"
777 do_daddu (SD_, RS, RT, RD);
782 :function:::void:do_ddiv:int rs, int rt
784 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
785 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
787 signed64 n = GPR[rs];
788 signed64 d = GPR[rt];
793 lo = SIGNED64 (0x8000000000000000);
796 else if (d == -1 && n == SIGNED64 (0x8000000000000000))
798 lo = SIGNED64 (0x8000000000000000);
809 TRACE_ALU_RESULT2 (HI, LO);
812 000000,5.RS,5.RT,0000000000011110:SPECIAL:64::DDIV
819 do_ddiv (SD_, RS, RT);
824 :function:::void:do_ddivu:int rs, int rt
826 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
827 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
829 unsigned64 n = GPR[rs];
830 unsigned64 d = GPR[rt];
835 lo = SIGNED64 (0x8000000000000000);
846 TRACE_ALU_RESULT2 (HI, LO);
849 000000,5.RS,5.RT,0000000000,011111:SPECIAL:64::DDIVU
856 do_ddivu (SD_, RS, RT);
861 :function:::void:do_div:int rs, int rt
863 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
864 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
866 signed32 n = GPR[rs];
867 signed32 d = GPR[rt];
870 LO = EXTEND32 (0x80000000);
873 else if (n == SIGNED32 (0x80000000) && d == -1)
875 LO = EXTEND32 (0x80000000);
880 LO = EXTEND32 (n / d);
881 HI = EXTEND32 (n % d);
884 TRACE_ALU_RESULT2 (HI, LO);
887 000000,5.RS,5.RT,0000000000011010:SPECIAL:32::DIV
889 *mipsI,mipsII,mipsIII,mipsIV:
894 do_div (SD_, RS, RT);
899 :function:::void:do_divu:int rs, int rt
901 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
902 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
904 unsigned32 n = GPR[rs];
905 unsigned32 d = GPR[rt];
908 LO = EXTEND32 (0x80000000);
913 LO = EXTEND32 (n / d);
914 HI = EXTEND32 (n % d);
917 TRACE_ALU_RESULT2 (HI, LO);
920 000000,5.RS,5.RT,0000000000011011:SPECIAL:32::DIVU
922 *mipsI,mipsII,mipsIII,mipsIV:
927 do_divu (SD_, RS, RT);
932 :function:::void:do_dmultx:int rs, int rt, int rd, int signed_p
942 unsigned64 op1 = GPR[rs];
943 unsigned64 op2 = GPR[rt];
944 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
945 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
946 /* make signed multiply unsigned */
961 /* multuply out the 4 sub products */
962 m00 = ((unsigned64) VL4_8 (op1) * (unsigned64) VL4_8 (op2));
963 m10 = ((unsigned64) VH4_8 (op1) * (unsigned64) VL4_8 (op2));
964 m01 = ((unsigned64) VL4_8 (op1) * (unsigned64) VH4_8 (op2));
965 m11 = ((unsigned64) VH4_8 (op1) * (unsigned64) VH4_8 (op2));
966 /* add the products */
967 mid = ((unsigned64) VH4_8 (m00)
968 + (unsigned64) VL4_8 (m10)
969 + (unsigned64) VL4_8 (m01));
970 lo = U8_4 (mid, m00);
972 + (unsigned64) VH4_8 (mid)
973 + (unsigned64) VH4_8 (m01)
974 + (unsigned64) VH4_8 (m10));
984 /* save the result HI/LO (and a gpr) */
989 TRACE_ALU_RESULT2 (HI, LO);
992 :function:::void:do_dmult:int rs, int rt, int rd
994 do_dmultx (SD_, rs, rt, rd, 1);
997 000000,5.RS,5.RT,0000000000011100:SPECIAL:64::DMULT
1002 do_dmult (SD_, RS, RT, 0);
1005 000000,5.RS,5.RT,5.RD,00000011100:SPECIAL:64::DMULT
1006 "dmult r<RS>, r<RT>":RD == 0
1007 "dmult r<RD>, r<RS>, r<RT>"
1010 do_dmult (SD_, RS, RT, RD);
1015 :function:::void:do_dmultu:int rs, int rt, int rd
1017 do_dmultx (SD_, rs, rt, rd, 0);
1020 000000,5.RS,5.RT,0000000000011101:SPECIAL:64::DMULTU
1021 "dmultu r<RS>, r<RT>"
1025 do_dmultu (SD_, RS, RT, 0);
1028 000000,5.RS,5.RT,5.RD,00000011101:SPECIAL:64::DMULTU
1029 "dmultu r<RD>, r<RS>, r<RT>":RD == 0
1030 "dmultu r<RS>, r<RT>"
1033 do_dmultu (SD_, RS, RT, RD);
1036 :function:::void:do_dsll:int rt, int rd, int shift
1038 GPR[rd] = GPR[rt] << shift;
1041 :function:::void:do_dsllv:int rs, int rt, int rd
1043 int s = MASKED64 (GPR[rs], 5, 0);
1044 GPR[rd] = GPR[rt] << s;
1048 00000000000,5.RT,5.RD,5.SHIFT,111000:SPECIAL:64::DSLL
1049 "dsll r<RD>, r<RT>, <SHIFT>"
1055 do_dsll (SD_, RT, RD, SHIFT);
1059 00000000000,5.RT,5.RD,5.SHIFT,111100:SPECIAL:64::DSLL32
1060 "dsll32 r<RD>, r<RT>, <SHIFT>"
1067 GPR[RD] = GPR[RT] << s;
1070 000000,5.RS,5.RT,5.RD,00000010100:SPECIAL:64::DSLLV
1071 "dsllv r<RD>, r<RT>, r<RS>"
1077 do_dsllv (SD_, RS, RT, RD);
1080 :function:::void:do_dsra:int rt, int rd, int shift
1082 GPR[rd] = ((signed64) GPR[rt]) >> shift;
1086 00000000000,5.RT,5.RD,5.SHIFT,111011:SPECIAL:64::DSRA
1087 "dsra r<RD>, r<RT>, <SHIFT>"
1093 do_dsra (SD_, RT, RD, SHIFT);
1097 00000000000,5.RT,5.RD,5.SHIFT,111111:SPECIAL:64::DSRA32
1098 "dsra32 r<RT>, r<RD>, <SHIFT>"
1105 GPR[RD] = ((signed64) GPR[RT]) >> s;
1109 :function:::void:do_dsrav:int rs, int rt, int rd
1111 int s = MASKED64 (GPR[rs], 5, 0);
1112 TRACE_ALU_INPUT2 (GPR[rt], s);
1113 GPR[rd] = ((signed64) GPR[rt]) >> s;
1114 TRACE_ALU_RESULT (GPR[rd]);
1117 000000,5.RS,5.RT,5.RD,00000010111:SPECIAL:64::DSRAV
1118 "dsra32 r<RT>, r<RD>, r<RS>"
1124 do_dsrav (SD_, RS, RT, RD);
1127 :function:::void:do_dsrl:int rt, int rd, int shift
1129 GPR[rd] = (unsigned64) GPR[rt] >> shift;
1133 00000000000,5.RT,5.RD,5.SHIFT,111010:SPECIAL:64::DSRL
1134 "dsrl r<RD>, r<RT>, <SHIFT>"
1140 do_dsrl (SD_, RT, RD, SHIFT);
1144 00000000000,5.RT,5.RD,5.SHIFT,111110:SPECIAL:64::DSRL32
1145 "dsrl32 r<RD>, r<RT>, <SHIFT>"
1152 GPR[RD] = (unsigned64) GPR[RT] >> s;
1156 :function:::void:do_dsrlv:int rs, int rt, int rd
1158 int s = MASKED64 (GPR[rs], 5, 0);
1159 GPR[rd] = (unsigned64) GPR[rt] >> s;
1164 000000,5.RS,5.RT,5.RD,00000010110:SPECIAL:64::DSRLV
1165 "dsrl32 r<RD>, r<RT>, r<RS>"
1171 do_dsrlv (SD_, RS, RT, RD);
1175 000000,5.RS,5.RT,5.RD,00000101110:SPECIAL:64::DSUB
1176 "dsub r<RD>, r<RS>, r<RT>"
1182 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
1184 ALU64_BEGIN (GPR[RS]);
1185 ALU64_SUB (GPR[RT]);
1186 ALU64_END (GPR[RD]);
1188 TRACE_ALU_RESULT (GPR[RD]);
1192 :function:::void:do_dsubu:int rs, int rt, int rd
1194 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1195 GPR[rd] = GPR[rs] - GPR[rt];
1196 TRACE_ALU_RESULT (GPR[rd]);
1199 000000,5.RS,5.RT,5.RD,00000101111:SPECIAL:64::DSUBU
1200 "dsubu r<RD>, r<RS>, r<RT>"
1206 do_dsubu (SD_, RS, RT, RD);
1210 000010,26.INSTR_INDEX:NORMAL:32::J
1212 *mipsI,mipsII,mipsIII,mipsIV:
1217 /* NOTE: The region used is that of the delay slot NIA and NOT the
1218 current instruction */
1219 address_word region = (NIA & MASK (63, 28));
1220 DELAY_SLOT (region | (INSTR_INDEX << 2));
1224 000011,26.INSTR_INDEX:NORMAL:32::JAL
1226 *mipsI,mipsII,mipsIII,mipsIV:
1231 /* NOTE: The region used is that of the delay slot and NOT the
1232 current instruction */
1233 address_word region = (NIA & MASK (63, 28));
1235 DELAY_SLOT (region | (INSTR_INDEX << 2));
1238 000000,5.RS,00000,5.RD,00000001001:SPECIAL:32::JALR
1239 "jalr r<RS>":RD == 31
1241 *mipsI,mipsII,mipsIII,mipsIV:
1246 address_word temp = GPR[RS];
1252 000000,5.RS,000000000000000001000:SPECIAL:32::JR
1254 *mipsI,mipsII,mipsIII,mipsIV:
1259 DELAY_SLOT (GPR[RS]);
1263 :function:::unsigned_word:do_load:unsigned access, address_word base, address_word offset
1265 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1266 address_word reverseendian = (ReverseEndian ? (mask ^ access) : 0);
1267 address_word bigendiancpu = (BigEndianCPU ? (mask ^ access) : 0);
1274 vaddr = base + offset;
1275 if ((vaddr & access) != 0)
1277 SIM_CORE_SIGNAL (SD, STATE_CPU (SD, 0), cia, read_map, access+1, vaddr, read_transfer, sim_core_unaligned_signal);
1279 AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
1280 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
1281 LoadMemory (&memval, NULL, uncached, access, paddr, vaddr, isDATA, isREAL);
1282 byte = ((vaddr & mask) ^ bigendiancpu);
1283 return (memval >> (8 * byte));
1287 100000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LB
1288 "lb r<RT>, <OFFSET>(r<BASE>)"
1289 *mipsI,mipsII,mipsIII,mipsIV:
1294 GPR[RT] = EXTEND8 (do_load (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET)));
1298 100100,5.BASE,5.RT,16.OFFSET:NORMAL:32::LBU
1299 "lbu r<RT>, <OFFSET>(r<BASE>)"
1300 *mipsI,mipsII,mipsIII,mipsIV:
1305 GPR[RT] = do_load (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET));
1309 110111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LD
1310 "ld r<RT>, <OFFSET>(r<BASE>)"
1316 GPR[RT] = EXTEND64 (do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
1320 1101,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDCz
1321 "ldc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1329 COP_LD (ZZ, RT, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
1335 011010,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDL
1336 "ldl r<RT>, <OFFSET>(r<BASE>)"
1342 GPR[RT] = do_load_left (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1346 011011,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDR
1347 "ldr r<RT>, <OFFSET>(r<BASE>)"
1353 GPR[RT] = do_load_right (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1357 100001,5.BASE,5.RT,16.OFFSET:NORMAL:32::LH
1358 "lh r<RT>, <OFFSET>(r<BASE>)"
1359 *mipsI,mipsII,mipsIII,mipsIV:
1364 GPR[RT] = EXTEND16 (do_load (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET)));
1368 100101,5.BASE,5.RT,16.OFFSET:NORMAL:32::LHU
1369 "lhu r<RT>, <OFFSET>(r<BASE>)"
1370 *mipsI,mipsII,mipsIII,mipsIV:
1375 GPR[RT] = do_load (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET));
1379 110000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LL
1380 "ll r<RT>, <OFFSET>(r<BASE>)"
1387 unsigned32 instruction = instruction_0;
1388 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1389 int destreg = ((instruction >> 16) & 0x0000001F);
1390 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1392 address_word vaddr = ((unsigned64)op1 + offset);
1395 if ((vaddr & 3) != 0)
1397 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, read_transfer, sim_core_unaligned_signal);
1401 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1403 unsigned64 memval = 0;
1404 unsigned64 memval1 = 0;
1405 unsigned64 mask = 0x7;
1406 unsigned int shift = 2;
1407 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1408 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1410 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1411 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1412 byte = ((vaddr & mask) ^ (bigend << shift));
1413 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
1421 110100,5.BASE,5.RT,16.OFFSET:NORMAL:64::LLD
1422 "lld r<RT>, <OFFSET>(r<BASE>)"
1428 unsigned32 instruction = instruction_0;
1429 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1430 int destreg = ((instruction >> 16) & 0x0000001F);
1431 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1433 address_word vaddr = ((unsigned64)op1 + offset);
1436 if ((vaddr & 7) != 0)
1438 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 8, vaddr, read_transfer, sim_core_unaligned_signal);
1442 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1444 unsigned64 memval = 0;
1445 unsigned64 memval1 = 0;
1446 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1447 GPR[destreg] = memval;
1455 001111,00000,5.RT,16.IMMEDIATE:NORMAL:32::LUI
1456 "lui r<RT>, <IMMEDIATE>"
1457 *mipsI,mipsII,mipsIII,mipsIV:
1462 TRACE_ALU_INPUT1 (IMMEDIATE);
1463 GPR[RT] = EXTEND32 (IMMEDIATE << 16);
1464 TRACE_ALU_RESULT (GPR[RT]);
1468 100011,5.BASE,5.RT,16.OFFSET:NORMAL:32::LW
1469 "lw r<RT>, <OFFSET>(r<BASE>)"
1470 *mipsI,mipsII,mipsIII,mipsIV:
1475 GPR[RT] = EXTEND32 (do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
1479 1100,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWCz
1480 "lwc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1481 *mipsI,mipsII,mipsIII,mipsIV:
1486 COP_LW (ZZ, RT, do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
1490 :function:::unsigned_word:do_load_left:unsigned access, address_word base, address_word offset, unsigned_word rt
1492 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1493 address_word reverseendian = (ReverseEndian ? -1 : 0);
1494 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
1503 unsigned_word lhs_mask;
1506 vaddr = base + offset;
1507 AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
1508 paddr = (paddr ^ (reverseendian & mask));
1509 if (BigEndianMem == 0)
1510 paddr = paddr & ~access;
1512 /* compute where within the word/mem we are */
1513 byte = ((vaddr ^ bigendiancpu) & access); /* 0..access */
1514 word = ((vaddr ^ bigendiancpu) & (mask & ~access)) / (access + 1); /* 0..1 */
1515 nr_lhs_bits = 8 * byte + 8;
1516 nr_rhs_bits = 8 * access - 8 * byte;
1517 /* nr_lhs_bits + nr_rhs_bits == 8 * (accesss + 1) */
1519 /* fprintf (stderr, "l[wd]l: 0x%08lx%08lx 0x%08lx%08lx %d:%d %d+%d\n",
1520 (long) ((unsigned64) vaddr >> 32), (long) vaddr,
1521 (long) ((unsigned64) paddr >> 32), (long) paddr,
1522 word, byte, nr_lhs_bits, nr_rhs_bits); */
1524 LoadMemory (&memval, NULL, uncached, byte, paddr, vaddr, isDATA, isREAL);
1527 /* GPR{31..32-NR_LHS_BITS} = memval{NR_LHS_BITS-1..0} */
1528 temp = (memval << nr_rhs_bits);
1532 /* GPR{31..32-NR_LHS_BITS = memval{32+NR_LHS_BITS..32} */
1533 temp = (memval >> nr_lhs_bits);
1535 lhs_mask = LSMASK (nr_lhs_bits + nr_rhs_bits - 1, nr_rhs_bits);
1536 rt = (rt & ~lhs_mask) | (temp & lhs_mask);
1538 /* fprintf (stderr, "l[wd]l: 0x%08lx%08lx -> 0x%08lx%08lx & 0x%08lx%08lx -> 0x%08lx%08lx\n",
1539 (long) ((unsigned64) memval >> 32), (long) memval,
1540 (long) ((unsigned64) temp >> 32), (long) temp,
1541 (long) ((unsigned64) lhs_mask >> 32), (long) lhs_mask,
1542 (long) (rt >> 32), (long) rt); */
1547 100010,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWL
1548 "lwl r<RT>, <OFFSET>(r<BASE>)"
1549 *mipsI,mipsII,mipsIII,mipsIV:
1554 GPR[RT] = EXTEND32 (do_load_left (SD_, AccessLength_WORD, GPR[BASE], EXTEND32 (OFFSET), GPR[RT]));
1558 :function:::unsigned_word:do_load_right:unsigned access, address_word base, address_word offset, unsigned_word rt
1560 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1561 address_word reverseendian = (ReverseEndian ? -1 : 0);
1562 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
1569 vaddr = base + offset;
1570 AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
1571 /* NOTE: SPEC is wrong, has `BigEndianMem == 0' not `BigEndianMem != 0' */
1572 paddr = (paddr ^ (reverseendian & mask));
1573 if (BigEndianMem != 0)
1574 paddr = paddr & ~access;
1575 byte = ((vaddr & mask) ^ (bigendiancpu & mask));
1576 /* NOTE: SPEC is wrong, had `byte' not `access - byte'. See SW. */
1577 LoadMemory (&memval, NULL, uncached, access - (access & byte), paddr, vaddr, isDATA, isREAL);
1578 /* printf ("lr: 0x%08lx %d@0x%08lx 0x%08lx\n",
1579 (long) paddr, byte, (long) paddr, (long) memval); */
1581 unsigned_word screen = LSMASK (8 * (access - (byte & access) + 1) - 1, 0);
1583 rt |= (memval >> (8 * byte)) & screen;
1589 100110,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWR
1590 "lwr r<RT>, <OFFSET>(r<BASE>)"
1591 *mipsI,mipsII,mipsIII,mipsIV:
1596 GPR[RT] = EXTEND32 (do_load_right (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]));
1600 100111,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWU
1601 "lwu r<RT>, <OFFSET>(r<BASE>)"
1607 GPR[RT] = do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET));
1611 :function:::void:do_mfhi:int rd
1613 check_mf_hilo (SD_, HIHISTORY, LOHISTORY);
1614 TRACE_ALU_INPUT1 (HI);
1616 TRACE_ALU_RESULT (GPR[rd]);
1619 000000,0000000000,5.RD,00000,010000:SPECIAL:32::MFHI
1621 *mipsI,mipsII,mipsIII,mipsIV:
1631 :function:::void:do_mflo:int rd
1633 check_mf_hilo (SD_, LOHISTORY, HIHISTORY);
1634 TRACE_ALU_INPUT1 (LO);
1636 TRACE_ALU_RESULT (GPR[rd]);
1639 000000,0000000000,5.RD,00000,010010:SPECIAL:32::MFLO
1641 *mipsI,mipsII,mipsIII,mipsIV:
1651 000000,5.RS,5.RT,5.RD,00000001011:SPECIAL:32::MOVN
1652 "movn r<RD>, r<RS>, r<RT>"
1662 000000,5.RS,5.RT,5.RD,00000001010:SPECIAL:32::MOVZ
1663 "movz r<RD>, r<RS>, r<RT>"
1673 000000,5.RS,000000000000000,010001:SPECIAL:32::MTHI
1675 *mipsI,mipsII,mipsIII,mipsIV:
1680 check_mt_hilo (SD_, HIHISTORY);
1686 000000,5.RS,000000000000000010011:SPECIAL:32::MTLO
1688 *mipsI,mipsII,mipsIII,mipsIV:
1693 check_mt_hilo (SD_, LOHISTORY);
1699 :function:::void:do_mult:int rs, int rt, int rd
1702 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1703 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1704 prod = (((signed64)(signed32) GPR[rs])
1705 * ((signed64)(signed32) GPR[rt]));
1706 LO = EXTEND32 (VL4_8 (prod));
1707 HI = EXTEND32 (VH4_8 (prod));
1710 TRACE_ALU_RESULT2 (HI, LO);
1713 000000,5.RS,5.RT,00000,00000011000:SPECIAL:32::MULT
1715 *mipsI,mipsII,mipsIII,mipsIV:
1718 do_mult (SD_, RS, RT, 0);
1722 000000,5.RS,5.RT,5.RD,00000011000:SPECIAL:32::MULT
1723 "mult r<RD>, r<RS>, r<RT>"
1727 do_mult (SD_, RS, RT, RD);
1731 :function:::void:do_multu:int rs, int rt, int rd
1734 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1735 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1736 prod = (((unsigned64)(unsigned32) GPR[rs])
1737 * ((unsigned64)(unsigned32) GPR[rt]));
1738 LO = EXTEND32 (VL4_8 (prod));
1739 HI = EXTEND32 (VH4_8 (prod));
1742 TRACE_ALU_RESULT2 (HI, LO);
1745 000000,5.RS,5.RT,00000,00000011001:SPECIAL:32::MULTU
1746 "multu r<RS>, r<RT>"
1747 *mipsI,mipsII,mipsIII,mipsIV:
1750 do_multu (SD_, RS, RT, 0);
1753 000000,5.RS,5.RT,5.RD,00000011001:SPECIAL:32::MULTU
1754 "multu r<RD>, r<RS>, r<RT>"
1758 do_multu (SD_, RS, RT, 0);
1762 :function:::void:do_nor:int rs, int rt, int rd
1764 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1765 GPR[rd] = ~ (GPR[rs] | GPR[rt]);
1766 TRACE_ALU_RESULT (GPR[rd]);
1769 000000,5.RS,5.RT,5.RD,00000,100111:SPECIAL:32::NOR
1770 "nor r<RD>, r<RS>, r<RT>"
1771 *mipsI,mipsII,mipsIII,mipsIV:
1776 do_nor (SD_, RS, RT, RD);
1780 :function:::void:do_or:int rs, int rt, int rd
1782 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1783 GPR[rd] = (GPR[rs] | GPR[rt]);
1784 TRACE_ALU_RESULT (GPR[rd]);
1787 000000,5.RS,5.RT,5.RD,00000,100101:SPECIAL:32::OR
1788 "or r<RD>, r<RS>, r<RT>"
1789 *mipsI,mipsII,mipsIII,mipsIV:
1794 do_or (SD_, RS, RT, RD);
1799 :function:::void:do_ori:int rs, int rt, unsigned immediate
1801 TRACE_ALU_INPUT2 (GPR[rs], immediate);
1802 GPR[rt] = (GPR[rs] | immediate);
1803 TRACE_ALU_RESULT (GPR[rt]);
1806 001101,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ORI
1807 "ori r<RT>, r<RS>, <IMMEDIATE>"
1808 *mipsI,mipsII,mipsIII,mipsIV:
1813 do_ori (SD_, RS, RT, IMMEDIATE);
1817 110011,5.RS,nnnnn,16.OFFSET:NORMAL:32::PREF
1821 unsigned32 instruction = instruction_0;
1822 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1823 int hint = ((instruction >> 16) & 0x0000001F);
1824 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1826 address_word vaddr = ((unsigned64)op1 + offset);
1830 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1831 Prefetch(uncached,paddr,vaddr,isDATA,hint);
1836 :function:::void:do_store:unsigned access, address_word base, address_word offset, unsigned_word word
1838 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1839 address_word reverseendian = (ReverseEndian ? (mask ^ access) : 0);
1840 address_word bigendiancpu = (BigEndianCPU ? (mask ^ access) : 0);
1847 vaddr = base + offset;
1848 if ((vaddr & access) != 0)
1850 SIM_CORE_SIGNAL (SD, STATE_CPU(SD, 0), cia, read_map, access+1, vaddr, write_transfer, sim_core_unaligned_signal);
1852 AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
1853 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
1854 byte = ((vaddr & mask) ^ bigendiancpu);
1855 memval = (word << (8 * byte));
1856 StoreMemory (uncached, access, memval, 0, paddr, vaddr, isREAL);
1860 101000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SB
1861 "sb r<RT>, <OFFSET>(r<BASE>)"
1862 *mipsI,mipsII,mipsIII,mipsIV:
1867 do_store (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1871 111000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SC
1872 "sc r<RT>, <OFFSET>(r<BASE>)"
1879 unsigned32 instruction = instruction_0;
1880 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1881 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
1882 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1884 address_word vaddr = ((unsigned64)op1 + offset);
1887 if ((vaddr & 3) != 0)
1889 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, write_transfer, sim_core_unaligned_signal);
1893 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
1895 unsigned64 memval = 0;
1896 unsigned64 memval1 = 0;
1897 unsigned64 mask = 0x7;
1899 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
1900 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
1901 memval = ((unsigned64) op2 << (8 * byte));
1904 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
1906 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
1913 111100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SCD
1914 "scd r<RT>, <OFFSET>(r<BASE>)"
1920 unsigned32 instruction = instruction_0;
1921 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1922 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
1923 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1925 address_word vaddr = ((unsigned64)op1 + offset);
1928 if ((vaddr & 7) != 0)
1930 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 8, vaddr, write_transfer, sim_core_unaligned_signal);
1934 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
1936 unsigned64 memval = 0;
1937 unsigned64 memval1 = 0;
1941 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
1943 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
1950 111111,5.BASE,5.RT,16.OFFSET:NORMAL:64::SD
1951 "sd r<RT>, <OFFSET>(r<BASE>)"
1957 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1961 1111,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDCz
1962 "sdc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1969 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (ZZ, RT));
1973 101100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDL
1974 "sdl r<RT>, <OFFSET>(r<BASE>)"
1980 do_store_left (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1984 101101,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDR
1985 "sdr r<RT>, <OFFSET>(r<BASE>)"
1991 do_store_right (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1995 101001,5.BASE,5.RT,16.OFFSET:NORMAL:32::SH
1996 "sh r<RT>, <OFFSET>(r<BASE>)"
1997 *mipsI,mipsII,mipsIII,mipsIV:
2002 do_store (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2006 :function:::void:do_sll:int rt, int rd, int shift
2008 unsigned32 temp = (GPR[rt] << shift);
2009 TRACE_ALU_INPUT2 (GPR[rt], shift);
2010 GPR[rd] = EXTEND32 (temp);
2011 TRACE_ALU_RESULT (GPR[rd]);
2014 00000000000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLL
2015 "sll r<RD>, r<RT>, <SHIFT>"
2016 *mipsI,mipsII,mipsIII,mipsIV:
2021 do_sll (SD_, RT, RD, SHIFT);
2025 :function:::void:do_sllv:int rs, int rt, int rd
2027 int s = MASKED (GPR[rs], 4, 0);
2028 unsigned32 temp = (GPR[rt] << s);
2029 TRACE_ALU_INPUT2 (GPR[rt], s);
2030 GPR[rd] = EXTEND32 (temp);
2031 TRACE_ALU_RESULT (GPR[rd]);
2034 000000,5.RS,5.RT,5.RD,00000000100:SPECIAL:32::SLLV
2035 "sllv r<RD>, r<RT>, r<RS>"
2036 *mipsI,mipsII,mipsIII,mipsIV:
2041 do_sllv (SD_, RS, RT, RD);
2045 :function:::void:do_slt:int rs, int rt, int rd
2047 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2048 GPR[rd] = ((signed_word) GPR[rs] < (signed_word) GPR[rt]);
2049 TRACE_ALU_RESULT (GPR[rd]);
2052 000000,5.RS,5.RT,5.RD,00000101010:SPECIAL:32::SLT
2053 "slt r<RD>, r<RS>, r<RT>"
2054 *mipsI,mipsII,mipsIII,mipsIV:
2059 do_slt (SD_, RS, RT, RD);
2063 :function:::void:do_slti:int rs, int rt, unsigned16 immediate
2065 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
2066 GPR[rt] = ((signed_word) GPR[rs] < (signed_word) EXTEND16 (immediate));
2067 TRACE_ALU_RESULT (GPR[rt]);
2070 001010,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTI
2071 "slti r<RT>, r<RS>, <IMMEDIATE>"
2072 *mipsI,mipsII,mipsIII,mipsIV:
2077 do_slti (SD_, RS, RT, IMMEDIATE);
2081 :function:::void:do_sltiu:int rs, int rt, unsigned16 immediate
2083 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
2084 GPR[rt] = ((unsigned_word) GPR[rs] < (unsigned_word) EXTEND16 (immediate));
2085 TRACE_ALU_RESULT (GPR[rt]);
2088 001011,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTIU
2089 "sltiu r<RT>, r<RS>, <IMMEDIATE>"
2090 *mipsI,mipsII,mipsIII,mipsIV:
2095 do_sltiu (SD_, RS, RT, IMMEDIATE);
2100 :function:::void:do_sltu:int rs, int rt, int rd
2102 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2103 GPR[rd] = ((unsigned_word) GPR[rs] < (unsigned_word) GPR[rt]);
2104 TRACE_ALU_RESULT (GPR[rd]);
2107 000000,5.RS,5.RT,5.RD,00000101011:SPECIAL:32::SLTU
2108 "sltu r<RD>, r<RS>, r<RT>"
2109 *mipsI,mipsII,mipsIII,mipsIV:
2114 do_sltu (SD_, RS, RT, RD);
2118 :function:::void:do_sra:int rt, int rd, int shift
2120 signed32 temp = (signed32) GPR[rt] >> shift;
2121 TRACE_ALU_INPUT2 (GPR[rt], shift);
2122 GPR[rd] = EXTEND32 (temp);
2123 TRACE_ALU_RESULT (GPR[rd]);
2126 000000,00000,5.RT,5.RD,5.SHIFT,000011:SPECIAL:32::SRA
2127 "sra r<RD>, r<RT>, <SHIFT>"
2128 *mipsI,mipsII,mipsIII,mipsIV:
2133 do_sra (SD_, RT, RD, SHIFT);
2138 :function:::void:do_srav:int rs, int rt, int rd
2140 int s = MASKED (GPR[rs], 4, 0);
2141 signed32 temp = (signed32) GPR[rt] >> s;
2142 TRACE_ALU_INPUT2 (GPR[rt], s);
2143 GPR[rd] = EXTEND32 (temp);
2144 TRACE_ALU_RESULT (GPR[rd]);
2147 000000,5.RS,5.RT,5.RD,00000000111:SPECIAL:32::SRAV
2148 "srav r<RD>, r<RT>, r<RS>"
2149 *mipsI,mipsII,mipsIII,mipsIV:
2154 do_srav (SD_, RS, RT, RD);
2159 :function:::void:do_srl:int rt, int rd, int shift
2161 unsigned32 temp = (unsigned32) GPR[rt] >> shift;
2162 TRACE_ALU_INPUT2 (GPR[rt], shift);
2163 GPR[rd] = EXTEND32 (temp);
2164 TRACE_ALU_RESULT (GPR[rd]);
2167 000000,00000,5.RT,5.RD,5.SHIFT,000010:SPECIAL:32::SRL
2168 "srl r<RD>, r<RT>, <SHIFT>"
2169 *mipsI,mipsII,mipsIII,mipsIV:
2174 do_srl (SD_, RT, RD, SHIFT);
2178 :function:::void:do_srlv:int rs, int rt, int rd
2180 int s = MASKED (GPR[rs], 4, 0);
2181 unsigned32 temp = (unsigned32) GPR[rt] >> s;
2182 TRACE_ALU_INPUT2 (GPR[rt], s);
2183 GPR[rd] = EXTEND32 (temp);
2184 TRACE_ALU_RESULT (GPR[rd]);
2187 000000,5.RS,5.RT,5.RD,00000000110:SPECIAL:32::SRLV
2188 "srlv r<RD>, r<RT>, r<RS>"
2189 *mipsI,mipsII,mipsIII,mipsIV:
2194 do_srlv (SD_, RS, RT, RD);
2198 000000,5.RS,5.RT,5.RD,00000100010:SPECIAL:32::SUB
2199 "sub r<RD>, r<RS>, r<RT>"
2200 *mipsI,mipsII,mipsIII,mipsIV:
2205 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
2207 ALU32_BEGIN (GPR[RS]);
2208 ALU32_SUB (GPR[RT]);
2209 ALU32_END (GPR[RD]);
2211 TRACE_ALU_RESULT (GPR[RD]);
2215 :function:::void:do_subu:int rs, int rt, int rd
2217 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2218 GPR[rd] = EXTEND32 (GPR[rs] - GPR[rt]);
2219 TRACE_ALU_RESULT (GPR[rd]);
2222 000000,5.RS,5.RT,5.RD,00000100011:SPECIAL:32::SUBU
2223 "subu r<RD>, r<RS>, r<RT>"
2224 *mipsI,mipsII,mipsIII,mipsIV:
2229 do_subu (SD_, RS, RT, RD);
2233 101011,5.BASE,5.RT,16.OFFSET:NORMAL:32::SW
2234 "sw r<RT>, <OFFSET>(r<BASE>)"
2235 *mipsI,mipsII,mipsIII,mipsIV:
2240 do_store (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2244 1110,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWCz
2245 "swc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2246 *mipsI,mipsII,mipsIII,mipsIV:
2251 do_store (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), COP_SW (ZZ, RT));
2256 :function:::void:do_store_left:unsigned access, address_word base, address_word offset, unsigned_word rt
2258 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
2259 address_word reverseendian = (ReverseEndian ? -1 : 0);
2260 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
2270 vaddr = base + offset;
2271 AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
2272 paddr = (paddr ^ (reverseendian & mask));
2273 if (BigEndianMem == 0)
2274 paddr = paddr & ~access;
2276 /* compute where within the word/mem we are */
2277 byte = ((vaddr ^ bigendiancpu) & access); /* 0..access */
2278 word = ((vaddr ^ bigendiancpu) & (mask & ~access)) / (access + 1); /* 0..1 */
2279 nr_lhs_bits = 8 * byte + 8;
2280 nr_rhs_bits = 8 * access - 8 * byte;
2281 /* nr_lhs_bits + nr_rhs_bits == 8 * (accesss + 1) */
2282 /* fprintf (stderr, "s[wd]l: 0x%08lx%08lx 0x%08lx%08lx %d:%d %d+%d\n",
2283 (long) ((unsigned64) vaddr >> 32), (long) vaddr,
2284 (long) ((unsigned64) paddr >> 32), (long) paddr,
2285 word, byte, nr_lhs_bits, nr_rhs_bits); */
2289 memval = (rt >> nr_rhs_bits);
2293 memval = (rt << nr_lhs_bits);
2295 /* fprintf (stderr, "s[wd]l: 0x%08lx%08lx -> 0x%08lx%08lx\n",
2296 (long) ((unsigned64) rt >> 32), (long) rt,
2297 (long) ((unsigned64) memval >> 32), (long) memval); */
2298 StoreMemory (uncached, byte, memval, 0, paddr, vaddr, isREAL);
2302 101010,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWL
2303 "swl r<RT>, <OFFSET>(r<BASE>)"
2304 *mipsI,mipsII,mipsIII,mipsIV:
2309 do_store_left (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2313 :function:::void:do_store_right:unsigned access, address_word base, address_word offset, unsigned_word rt
2315 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
2316 address_word reverseendian = (ReverseEndian ? -1 : 0);
2317 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
2324 vaddr = base + offset;
2325 AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
2326 paddr = (paddr ^ (reverseendian & mask));
2327 if (BigEndianMem != 0)
2329 byte = ((vaddr & mask) ^ (bigendiancpu & mask));
2330 memval = (rt << (byte * 8));
2331 StoreMemory (uncached, access - (access & byte), memval, 0, paddr, vaddr, isREAL);
2334 101110,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWR
2335 "swr r<RT>, <OFFSET>(r<BASE>)"
2336 *mipsI,mipsII,mipsIII,mipsIV:
2341 do_store_right (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2345 000000000000000000000,5.STYPE,001111:SPECIAL:32::SYNC
2355 SyncOperation (STYPE);
2359 000000,20.CODE,001100:SPECIAL:32::SYSCALL
2361 *mipsI,mipsII,mipsIII,mipsIV:
2366 SignalException(SystemCall, instruction_0);
2370 000000,5.RS,5.RT,10.CODE,110100:SPECIAL:32::TEQ
2378 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
2379 SignalException(Trap, instruction_0);
2383 000001,5.RS,01100,16.IMMEDIATE:REGIMM:32::TEQI
2384 "teqi r<RS>, <IMMEDIATE>"
2391 if ((signed_word) GPR[RS] == (signed_word) EXTEND16 (IMMEDIATE))
2392 SignalException(Trap, instruction_0);
2396 000000,5.RS,5.RT,10.CODE,110000:SPECIAL:32::TGE
2404 if ((signed_word) GPR[RS] >= (signed_word) GPR[RT])
2405 SignalException(Trap, instruction_0);
2409 000001,5.RS,01000,16.IMMEDIATE:REGIMM:32::TGEI
2410 "tgei r<RS>, <IMMEDIATE>"
2417 if ((signed_word) GPR[RS] >= (signed_word) EXTEND16 (IMMEDIATE))
2418 SignalException(Trap, instruction_0);
2422 000001,5.RS,01001,16.IMMEDIATE:REGIMM:32::TGEIU
2423 "tgeiu r<RS>, <IMMEDIATE>"
2430 if ((unsigned_word) GPR[RS] >= (unsigned_word) EXTEND16 (IMMEDIATE))
2431 SignalException(Trap, instruction_0);
2435 000000,5.RS,5.RT,10.CODE,110001:SPECIAL:32::TGEU
2443 if ((unsigned_word) GPR[RS] >= (unsigned_word) GPR[RT])
2444 SignalException(Trap, instruction_0);
2448 000000,5.RS,5.RT,10.CODE,110010:SPECIAL:32::TLT
2456 if ((signed_word) GPR[RS] < (signed_word) GPR[RT])
2457 SignalException(Trap, instruction_0);
2461 000001,5.RS,01010,16.IMMEDIATE:REGIMM:32::TLTI
2462 "tlti r<RS>, <IMMEDIATE>"
2469 if ((signed_word) GPR[RS] < (signed_word) EXTEND16 (IMMEDIATE))
2470 SignalException(Trap, instruction_0);
2474 000001,5.RS,01011,16.IMMEDIATE:REGIMM:32::TLTIU
2475 "tltiu r<RS>, <IMMEDIATE>"
2482 if ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE))
2483 SignalException(Trap, instruction_0);
2487 000000,5.RS,5.RT,10.CODE,110011:SPECIAL:32::TLTU
2495 if ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT])
2496 SignalException(Trap, instruction_0);
2500 000000,5.RS,5.RT,10.CODE,110110:SPECIAL:32::TNE
2508 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
2509 SignalException(Trap, instruction_0);
2513 000001,5.RS,01110,16.IMMEDIATE:REGIMM:32::TNEI
2514 "tne r<RS>, <IMMEDIATE>"
2521 if ((signed_word) GPR[RS] != (signed_word) EXTEND16 (IMMEDIATE))
2522 SignalException(Trap, instruction_0);
2526 :function:::void:do_xor:int rs, int rt, int rd
2528 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2529 GPR[rd] = GPR[rs] ^ GPR[rt];
2530 TRACE_ALU_RESULT (GPR[rd]);
2533 000000,5.RS,5.RT,5.RD,00000100110:SPECIAL:32::XOR
2534 "xor r<RD>, r<RS>, r<RT>"
2535 *mipsI,mipsII,mipsIII,mipsIV:
2540 do_xor (SD_, RS, RT, RD);
2544 :function:::void:do_xori:int rs, int rt, unsigned16 immediate
2546 TRACE_ALU_INPUT2 (GPR[rs], immediate);
2547 GPR[rt] = GPR[rs] ^ immediate;
2548 TRACE_ALU_RESULT (GPR[rt]);
2551 001110,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::XORI
2552 "xori r<RT>, r<RS>, <IMMEDIATE>"
2553 *mipsI,mipsII,mipsIII,mipsIV:
2558 do_xori (SD_, RS, RT, IMMEDIATE);
2563 // MIPS Architecture:
2565 // FPU Instruction Set (COP1 & COP1X)
2573 case fmt_single: return "s";
2574 case fmt_double: return "d";
2575 case fmt_word: return "w";
2576 case fmt_long: return "l";
2577 default: return "?";
2587 default: return "?";
2607 :%s::::COND:int cond
2611 case 00: return "f";
2612 case 01: return "un";
2613 case 02: return "eq";
2614 case 03: return "ueq";
2615 case 04: return "olt";
2616 case 05: return "ult";
2617 case 06: return "ole";
2618 case 07: return "ule";
2619 case 010: return "sf";
2620 case 011: return "ngle";
2621 case 012: return "seq";
2622 case 013: return "ngl";
2623 case 014: return "lt";
2624 case 015: return "nge";
2625 case 016: return "le";
2626 case 017: return "ngt";
2627 default: return "?";
2632 010001,10,3.FMT,00000,5.FS,5.FD,000101:COP1:32,f::ABS.fmt
2633 "abs.%s<FMT> f<FD>, f<FS>"
2634 *mipsI,mipsII,mipsIII,mipsIV:
2639 unsigned32 instruction = instruction_0;
2640 int destreg = ((instruction >> 6) & 0x0000001F);
2641 int fs = ((instruction >> 11) & 0x0000001F);
2642 int format = ((instruction >> 21) & 0x00000007);
2644 if ((format != fmt_single) && (format != fmt_double))
2645 SignalException(ReservedInstruction,instruction);
2647 StoreFPR(destreg,format,AbsoluteValue(ValueFPR(fs,format),format));
2653 010001,10,3.FMT,5.FT,5.FS,5.FD,000000:COP1:32,f::ADD.fmt
2654 "add.%s<FMT> f<FD>, f<FS>, f<FT>"
2655 *mipsI,mipsII,mipsIII,mipsIV:
2660 unsigned32 instruction = instruction_0;
2661 int destreg = ((instruction >> 6) & 0x0000001F);
2662 int fs = ((instruction >> 11) & 0x0000001F);
2663 int ft = ((instruction >> 16) & 0x0000001F);
2664 int format = ((instruction >> 21) & 0x00000007);
2666 if ((format != fmt_single) && (format != fmt_double))
2667 SignalException(ReservedInstruction, instruction);
2669 StoreFPR(destreg,format,Add(ValueFPR(fs,format),ValueFPR(ft,format),format));
2680 010001,01000,3.0,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1a
2681 "bc1%s<TF>%s<ND> <OFFSET>"
2682 *mipsI,mipsII,mipsIII:
2684 check_branch_bug ();
2685 TRACE_BRANCH_INPUT (PREVCOC1());
2686 if (PREVCOC1() == TF)
2688 address_word dest = NIA + (EXTEND16 (OFFSET) << 2);
2689 TRACE_BRANCH_RESULT (dest);
2690 mark_branch_bug (dest);
2695 TRACE_BRANCH_RESULT (0);
2696 NULLIFY_NEXT_INSTRUCTION ();
2700 TRACE_BRANCH_RESULT (NIA);
2704 010001,01000,3.CC,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1b
2705 "bc1%s<TF>%s<ND> <OFFSET>":CC == 0
2706 "bc1%s<TF>%s<ND> <CC>, <OFFSET>"
2712 check_branch_bug ();
2713 if (GETFCC(CC) == TF)
2715 address_word dest = NIA + (EXTEND16 (OFFSET) << 2);
2716 mark_branch_bug (dest);
2721 NULLIFY_NEXT_INSTRUCTION ();
2734 :function:::void:do_c_cond_fmt:int fmt, int ft, int fs, int cc, int cond, instruction_word insn
2736 if ((fmt != fmt_single) && (fmt != fmt_double))
2737 SignalException (ReservedInstruction, insn);
2744 unsigned64 ofs = ValueFPR (fs, fmt);
2745 unsigned64 oft = ValueFPR (ft, fmt);
2746 if (NaN (ofs, fmt) || NaN (oft, fmt))
2748 if (FCSR & FP_ENABLE (IO))
2750 FCSR |= FP_CAUSE (IO);
2751 SignalExceptionFPE ();
2759 less = Less (ofs, oft, fmt);
2760 equal = Equal (ofs, oft, fmt);
2763 condition = (((cond & (1 << 2)) && less)
2764 || ((cond & (1 << 1)) && equal)
2765 || ((cond & (1 << 0)) && unordered));
2766 SETFCC (cc, condition);
2770 010001,10,3.FMT,5.FT,5.FS,3.0,00,11,4.COND:COP1:32::C.cond.fmta
2771 "c.%s<COND>.%s<FMT> f<FS>, f<FT>"
2772 *mipsI,mipsII,mipsIII:
2774 do_c_cond_fmt (SD_, FMT, FT, FS, 0, COND, instruction_0);
2777 010001,10,3.FMT,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32::C.cond.fmtb
2778 "c.%s<COND>.%s<FMT> f<FS>, f<FT>":CC == 0
2779 "c.%s<COND>.%s<FMT> <CC>, f<FS>, f<FT>"
2785 do_c_cond_fmt (SD_, FMT, FT, FS, CC, COND, instruction_0);
2789 010001,10,3.FMT,00000,5.FS,5.FD,001010:COP1:64::CEIL.L.fmt
2790 "ceil.l.%s<FMT> f<FD>, f<FS>"
2797 unsigned32 instruction = instruction_0;
2798 int destreg = ((instruction >> 6) & 0x0000001F);
2799 int fs = ((instruction >> 11) & 0x0000001F);
2800 int format = ((instruction >> 21) & 0x00000007);
2802 if ((format != fmt_single) && (format != fmt_double))
2803 SignalException(ReservedInstruction,instruction);
2805 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_long));
2810 010001,10,3.FMT,00000,5.FS,5.FD,001110:COP1:32::CEIL.W
2818 unsigned32 instruction = instruction_0;
2819 int destreg = ((instruction >> 6) & 0x0000001F);
2820 int fs = ((instruction >> 11) & 0x0000001F);
2821 int format = ((instruction >> 21) & 0x00000007);
2823 if ((format != fmt_single) && (format != fmt_double))
2824 SignalException(ReservedInstruction,instruction);
2826 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_word));
2833 010001,00,X,10,5.RT,5.FS,00000000000:COP1Sa:32::CxC1
2834 "c%s<X>c1 r<RT>, f<FS>"
2842 PENDING_FILL((FS + FCR0IDX),VL4_8(GPR[RT]));
2844 PENDING_FILL((FS + FCR31IDX),VL4_8(GPR[RT]));
2846 PENDING_FILL(COCIDX,0); /* special case */
2849 { /* control from */
2851 PENDING_FILL(RT,SIGNEXTEND(FCR0,32));
2853 PENDING_FILL(RT,SIGNEXTEND(FCR31,32));
2857 010001,00,X,10,5.RT,5.FS,00000000000:COP1Sb:32::CxC1
2858 "c%s<X>c1 r<RT>, f<FS>"
2867 TRACE_ALU_INPUT1 (GPR[RT]);
2870 FCR0 = VL4_8(GPR[RT]);
2871 TRACE_ALU_RESULT (FCR0);
2875 FCR31 = VL4_8(GPR[RT]);
2876 SETFCC(0,((FCR31 & (1 << 23)) ? 1 : 0));
2877 TRACE_ALU_RESULT (FCR31);
2881 TRACE_ALU_RESULT0 ();
2886 { /* control from */
2889 TRACE_ALU_INPUT1 (FCR0);
2890 GPR[RT] = SIGNEXTEND (FCR0, 32);
2894 TRACE_ALU_INPUT1 (FCR31);
2895 GPR[RT] = SIGNEXTEND (FCR31, 32);
2897 TRACE_ALU_RESULT (GPR[RT]);
2904 // FIXME: Does not correctly differentiate between mips*
2906 010001,10,3.FMT,00000,5.FS,5.FD,100001:COP1:32::CVT.D.fmt
2907 "cvt.d.%s<FMT> f<FD>, f<FS>"
2908 *mipsI,mipsII,mipsIII,mipsIV:
2913 unsigned32 instruction = instruction_0;
2914 int destreg = ((instruction >> 6) & 0x0000001F);
2915 int fs = ((instruction >> 11) & 0x0000001F);
2916 int format = ((instruction >> 21) & 0x00000007);
2918 if ((format == fmt_double) | 0)
2919 SignalException(ReservedInstruction,instruction);
2921 StoreFPR(destreg,fmt_double,Convert(GETRM(),ValueFPR(fs,format),format,fmt_double));
2926 010001,10,3.FMT,00000,5.FS,5.FD,100101:COP1:64::CVT.L.fmt
2927 "cvt.l.%s<FMT> f<FD>, f<FS>"
2934 unsigned32 instruction = instruction_0;
2935 int destreg = ((instruction >> 6) & 0x0000001F);
2936 int fs = ((instruction >> 11) & 0x0000001F);
2937 int format = ((instruction >> 21) & 0x00000007);
2939 if ((format == fmt_long) | ((format == fmt_long) || (format == fmt_word)))
2940 SignalException(ReservedInstruction,instruction);
2942 StoreFPR(destreg,fmt_long,Convert(GETRM(),ValueFPR(fs,format),format,fmt_long));
2948 // FIXME: Does not correctly differentiate between mips*
2950 010001,10,3.FMT,00000,5.FS,5.FD,100000:COP1:32::CVT.S.fmt
2951 "cvt.s.%s<FMT> f<FD>, f<FS>"
2952 *mipsI,mipsII,mipsIII,mipsIV:
2957 unsigned32 instruction = instruction_0;
2958 int destreg = ((instruction >> 6) & 0x0000001F);
2959 int fs = ((instruction >> 11) & 0x0000001F);
2960 int format = ((instruction >> 21) & 0x00000007);
2962 if ((format == fmt_single) | 0)
2963 SignalException(ReservedInstruction,instruction);
2965 StoreFPR(destreg,fmt_single,Convert(GETRM(),ValueFPR(fs,format),format,fmt_single));
2970 010001,10,3.FMT,00000,5.FS,5.FD,100100:COP1:32::CVT.W.fmt
2971 "cvt.w.%s<FMT> f<FD>, f<FS>"
2972 *mipsI,mipsII,mipsIII,mipsIV:
2977 unsigned32 instruction = instruction_0;
2978 int destreg = ((instruction >> 6) & 0x0000001F);
2979 int fs = ((instruction >> 11) & 0x0000001F);
2980 int format = ((instruction >> 21) & 0x00000007);
2982 if ((format == fmt_word) | ((format == fmt_long) || (format == fmt_word)))
2983 SignalException(ReservedInstruction,instruction);
2985 StoreFPR(destreg,fmt_word,Convert(GETRM(),ValueFPR(fs,format),format,fmt_word));
2990 010001,10,3.FMT,5.FT,5.FS,5.FD,000011:COP1:32::DIV.fmt
2991 "div.%s<FMT> f<FD>, f<FS>, f<FT>"
2992 *mipsI,mipsII,mipsIII,mipsIV:
2997 unsigned32 instruction = instruction_0;
2998 int destreg = ((instruction >> 6) & 0x0000001F);
2999 int fs = ((instruction >> 11) & 0x0000001F);
3000 int ft = ((instruction >> 16) & 0x0000001F);
3001 int format = ((instruction >> 21) & 0x00000007);
3003 if ((format != fmt_single) && (format != fmt_double))
3004 SignalException(ReservedInstruction,instruction);
3006 StoreFPR(destreg,format,Divide(ValueFPR(fs,format),ValueFPR(ft,format),format));
3013 010001,00,X,01,5.RT,5.FS,00000000000:COP1Sa:64::DMxC1
3014 "dm%s<X>c1 r<RT>, f<FS>"
3019 if (SizeFGR() == 64)
3020 PENDING_FILL((FS + FGRIDX),GPR[RT]);
3021 else if ((FS & 0x1) == 0)
3023 PENDING_FILL(((FS + 1) + FGRIDX),VH4_8(GPR[RT]));
3024 PENDING_FILL((FS + FGRIDX),VL4_8(GPR[RT]));
3029 if (SizeFGR() == 64)
3030 PENDING_FILL(RT,FGR[FS]);
3031 else if ((FS & 0x1) == 0)
3032 PENDING_FILL(RT,(SET64HI(FGR[FS+1]) | FGR[FS]));
3034 PENDING_FILL(RT,SET64HI(0xDEADC0DE) | 0xBAD0BAD0);
3037 010001,00,X,01,5.RT,5.FS,00000000000:COP1Sb:64::DMxC1
3038 "dm%s<X>c1 r<RT>, f<FS>"
3046 if (SizeFGR() == 64)
3047 StoreFPR (FS, fmt_uninterpreted_64, GPR[RT]);
3048 else if ((FS & 0x1) == 0)
3049 StoreFPR (FS, fmt_uninterpreted_64, SET64HI (FGR[FS+1]) | FGR[FS]);
3053 if (SizeFGR() == 64)
3055 else if ((FS & 0x1) == 0)
3056 GPR[RT] = SET64HI (FGR[FS+1]) | FGR[FS];
3058 GPR[RT] = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
3063 010001,10,3.FMT,00000,5.FS,5.FD,001011:COP1:64::FLOOR.L.fmt
3064 "floor.l.%s<FMT> f<FD>, f<FS>"
3071 unsigned32 instruction = instruction_0;
3072 int destreg = ((instruction >> 6) & 0x0000001F);
3073 int fs = ((instruction >> 11) & 0x0000001F);
3074 int format = ((instruction >> 21) & 0x00000007);
3076 if ((format != fmt_single) && (format != fmt_double))
3077 SignalException(ReservedInstruction,instruction);
3079 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_long));
3084 010001,10,3.FMT,00000,5.FS,5.FD,001111:COP1:32::FLOOR.W.fmt
3085 "floor.w.%s<FMT> f<FD>, f<FS>"
3093 unsigned32 instruction = instruction_0;
3094 int destreg = ((instruction >> 6) & 0x0000001F);
3095 int fs = ((instruction >> 11) & 0x0000001F);
3096 int format = ((instruction >> 21) & 0x00000007);
3098 if ((format != fmt_single) && (format != fmt_double))
3099 SignalException(ReservedInstruction,instruction);
3101 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_word));
3106 110101,5.BASE,5.FT,16.OFFSET:COP1:64::LDC1
3107 "ldc1 f<FT>, <OFFSET>(r<BASE>)"
3115 COP_LD (1, FT, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
3119 010011,5.BASE,5.INDEX,5.0,5.FD,000001:COP1X:64::LDXC1
3120 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
3124 COP_LD (1, FD, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX]));
3129 110001,5.BASE,5.FT,16.OFFSET:COP1:32::LWC1
3130 "lwc1 f<FT>, <OFFSET>(r<BASE>)"
3131 *mipsI,mipsII,mipsIII,mipsIV:
3136 COP_LW (1, FT, do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
3140 010011,5.BASE,5.INDEX,5.0,5.FD,000000:COP1X:32::LWXC1
3141 "lwxc1 f<FD>, r<INDEX>(r<BASE>)"
3145 COP_LW (1, FD, do_load (SD_, AccessLength_WORD, GPR[BASE], GPR[INDEX]));
3151 // FIXME: Not correct for mips*
3153 010011,5.FR,5.FT,5.FS,5.FD,100,001:COP1X:32,f::MADD.D
3154 "madd.d f<FD>, f<FR>, f<FS>, f<FT>"
3158 unsigned32 instruction = instruction_0;
3159 int destreg = ((instruction >> 6) & 0x0000001F);
3160 int fs = ((instruction >> 11) & 0x0000001F);
3161 int ft = ((instruction >> 16) & 0x0000001F);
3162 int fr = ((instruction >> 21) & 0x0000001F);
3164 StoreFPR(destreg,fmt_double,Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
3169 010011,5.FR,5.FT,5.FS,5.FD,100,000:COP1X:32,f::MADD.S
3170 "madd.s f<FD>, f<FR>, f<FS>, f<FT>"
3174 unsigned32 instruction = instruction_0;
3175 int destreg = ((instruction >> 6) & 0x0000001F);
3176 int fs = ((instruction >> 11) & 0x0000001F);
3177 int ft = ((instruction >> 16) & 0x0000001F);
3178 int fr = ((instruction >> 21) & 0x0000001F);
3180 StoreFPR(destreg,fmt_single,Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
3187 010001,00,X,00,5.RT,5.FS,00000000000:COP1Sa:32::MxC1
3188 "m%s<X>c1 r<RT>, f<FS>"
3195 if (SizeFGR() == 64)
3196 PENDING_FILL ((FS + FGRIDX), (SET64HI(0xDEADC0DE) | VL4_8(GPR[RT])));
3198 PENDING_FILL ((FS + FGRIDX), VL4_8(GPR[RT]));
3201 PENDING_FILL (RT, SIGNEXTEND(FGR[FS],32));
3203 010001,00,X,00,5.RT,5.FS,00000000000:COP1Sb:32::MxC1
3204 "m%s<X>c1 r<RT>, f<FS>"
3213 StoreFPR (FS, fmt_uninterpreted_32, VL4_8 (GPR[RT]));
3215 GPR[RT] = SIGNEXTEND(FGR[FS],32);
3219 010001,10,3.FMT,00000,5.FS,5.FD,000110:COP1:32::MOV.fmt
3220 "mov.%s<FMT> f<FD>, f<FS>"
3221 *mipsI,mipsII,mipsIII,mipsIV:
3226 unsigned32 instruction = instruction_0;
3227 int destreg = ((instruction >> 6) & 0x0000001F);
3228 int fs = ((instruction >> 11) & 0x0000001F);
3229 int format = ((instruction >> 21) & 0x00000007);
3231 StoreFPR(destreg,format,ValueFPR(fs,format));
3237 000000,5.RS,3.CC,0,1.TF,5.RD,00000000001:SPECIAL:32::MOVtf
3238 "mov%s<TF> r<RD>, r<RS>, <CC>"
3242 if (GETFCC(CC) == TF)
3248 010001,10,3.FMT,3.CC,0,1.TF,5.FS,5.FD,010001:COP1:32::MOVtf.fmt
3249 "mov%s<TF>.%s<FMT> f<FD>, f<FS>, <CC>"
3253 unsigned32 instruction = instruction_0;
3254 int format = ((instruction >> 21) & 0x00000007);
3256 if (GETFCC(CC) == TF)
3257 StoreFPR (FD, format, ValueFPR (FS, format));
3259 StoreFPR (FD, format, ValueFPR (FD, format));
3264 010001,10,3.FMT,5.RT,5.FS,5.FD,010011:COP1:32::MOVN.fmt
3268 unsigned32 instruction = instruction_0;
3269 int destreg = ((instruction >> 6) & 0x0000001F);
3270 int fs = ((instruction >> 11) & 0x0000001F);
3271 int format = ((instruction >> 21) & 0x00000007);
3273 StoreFPR(destreg,format,ValueFPR(fs,format));
3281 // MOVT.fmt see MOVtf.fmt
3285 010001,10,3.FMT,5.RT,5.FS,5.FD,010010:COP1:32::MOVZ.fmt
3286 "movz.%s<FMT> f<FD>, f<FS>, r<RT>"
3290 unsigned32 instruction = instruction_0;
3291 int destreg = ((instruction >> 6) & 0x0000001F);
3292 int fs = ((instruction >> 11) & 0x0000001F);
3293 int format = ((instruction >> 21) & 0x00000007);
3295 StoreFPR(destreg,format,ValueFPR(fs,format));
3301 010011,5.FR,5.FT,5.FS,5.FD,101,001:COP1X:32::MSUB.D
3302 "msub.d f<FD>, f<FR>, f<FS>, f<FT>"
3306 unsigned32 instruction = instruction_0;
3307 int destreg = ((instruction >> 6) & 0x0000001F);
3308 int fs = ((instruction >> 11) & 0x0000001F);
3309 int ft = ((instruction >> 16) & 0x0000001F);
3310 int fr = ((instruction >> 21) & 0x0000001F);
3312 StoreFPR(destreg,fmt_double,Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
3318 010011,5.FR,5.FT,5.FS,5.FD,101000:COP1X:32::MSUB.S
3319 "msub.s f<FD>, f<FR>, f<FS>, f<FT>"
3323 unsigned32 instruction = instruction_0;
3324 int destreg = ((instruction >> 6) & 0x0000001F);
3325 int fs = ((instruction >> 11) & 0x0000001F);
3326 int ft = ((instruction >> 16) & 0x0000001F);
3327 int fr = ((instruction >> 21) & 0x0000001F);
3329 StoreFPR(destreg,fmt_single,Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
3337 010001,10,3.FMT,5.FT,5.FS,5.FD,000010:COP1:32::MUL.fmt
3338 "mul.%s<FMT> f<FD>, f<FS>, f<FT>"
3339 *mipsI,mipsII,mipsIII,mipsIV:
3344 unsigned32 instruction = instruction_0;
3345 int destreg = ((instruction >> 6) & 0x0000001F);
3346 int fs = ((instruction >> 11) & 0x0000001F);
3347 int ft = ((instruction >> 16) & 0x0000001F);
3348 int format = ((instruction >> 21) & 0x00000007);
3350 if ((format != fmt_single) && (format != fmt_double))
3351 SignalException(ReservedInstruction,instruction);
3353 StoreFPR(destreg,format,Multiply(ValueFPR(fs,format),ValueFPR(ft,format),format));
3358 010001,10,3.FMT,00000,5.FS,5.FD,000111:COP1:32::NEG.fmt
3359 "neg.%s<FMT> f<FD>, f<FS>"
3360 *mipsI,mipsII,mipsIII,mipsIV:
3365 unsigned32 instruction = instruction_0;
3366 int destreg = ((instruction >> 6) & 0x0000001F);
3367 int fs = ((instruction >> 11) & 0x0000001F);
3368 int format = ((instruction >> 21) & 0x00000007);
3370 if ((format != fmt_single) && (format != fmt_double))
3371 SignalException(ReservedInstruction,instruction);
3373 StoreFPR(destreg,format,Negate(ValueFPR(fs,format),format));
3379 010011,5.FR,5.FT,5.FS,5.FD,110001:COP1X:32::NMADD.D
3380 "nmadd.d f<FD>, f<FR>, f<FS>, f<FT>"
3384 unsigned32 instruction = instruction_0;
3385 int destreg = ((instruction >> 6) & 0x0000001F);
3386 int fs = ((instruction >> 11) & 0x0000001F);
3387 int ft = ((instruction >> 16) & 0x0000001F);
3388 int fr = ((instruction >> 21) & 0x0000001F);
3390 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));
3396 010011,5.FR,5.FT,5.FS,5.FD,110000:COP1X:32::NMADD.S
3397 "nmadd.s f<FD>, f<FR>, f<FS>, f<FT>"
3401 unsigned32 instruction = instruction_0;
3402 int destreg = ((instruction >> 6) & 0x0000001F);
3403 int fs = ((instruction >> 11) & 0x0000001F);
3404 int ft = ((instruction >> 16) & 0x0000001F);
3405 int fr = ((instruction >> 21) & 0x0000001F);
3407 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));
3413 010011,5.FR,5.FT,5.FS,5.FD,111001:COP1X:32::NMSUB.D
3414 "nmsub.d f<FD>, f<FR>, f<FS>, f<FT>"
3418 unsigned32 instruction = instruction_0;
3419 int destreg = ((instruction >> 6) & 0x0000001F);
3420 int fs = ((instruction >> 11) & 0x0000001F);
3421 int ft = ((instruction >> 16) & 0x0000001F);
3422 int fr = ((instruction >> 21) & 0x0000001F);
3424 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));
3430 010011,5.FR,5.FT,5.FS,5.FD,111000:COP1X:32::NMSUB.S
3431 "nmsub.s f<FD>, f<FR>, f<FS>, f<FT>"
3435 unsigned32 instruction = instruction_0;
3436 int destreg = ((instruction >> 6) & 0x0000001F);
3437 int fs = ((instruction >> 11) & 0x0000001F);
3438 int ft = ((instruction >> 16) & 0x0000001F);
3439 int fr = ((instruction >> 21) & 0x0000001F);
3441 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));
3446 010011,5.BASE,5.INDEX,5.HINT,00000001111:COP1X:32::PREFX
3447 "prefx <HINT>, r<INDEX>(r<BASE>)"
3451 unsigned32 instruction = instruction_0;
3452 int fs = ((instruction >> 11) & 0x0000001F);
3453 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
3454 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
3456 address_word vaddr = ((unsigned64)op1 + (unsigned64)op2);
3459 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
3460 Prefetch(uncached,paddr,vaddr,isDATA,fs);
3464 010001,10,3.FMT,00000,5.FS,5.FD,010101:COP1:32::RECIP.fmt
3466 "recip.%s<FMT> f<FD>, f<FS>"
3469 unsigned32 instruction = instruction_0;
3470 int destreg = ((instruction >> 6) & 0x0000001F);
3471 int fs = ((instruction >> 11) & 0x0000001F);
3472 int format = ((instruction >> 21) & 0x00000007);
3474 if ((format != fmt_single) && (format != fmt_double))
3475 SignalException(ReservedInstruction,instruction);
3477 StoreFPR(destreg,format,Recip(ValueFPR(fs,format),format));
3482 010001,10,3.FMT,00000,5.FS,5.FD,001000:COP1:64::ROUND.L.fmt
3483 "round.l.%s<FMT> f<FD>, f<FS>"
3490 unsigned32 instruction = instruction_0;
3491 int destreg = ((instruction >> 6) & 0x0000001F);
3492 int fs = ((instruction >> 11) & 0x0000001F);
3493 int format = ((instruction >> 21) & 0x00000007);
3495 if ((format != fmt_single) && (format != fmt_double))
3496 SignalException(ReservedInstruction,instruction);
3498 StoreFPR(destreg,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_long));
3503 010001,10,3.FMT,00000,5.FS,5.FD,001100:COP1:32::ROUND.W.fmt
3504 "round.w.%s<FMT> f<FD>, f<FS>"
3512 unsigned32 instruction = instruction_0;
3513 int destreg = ((instruction >> 6) & 0x0000001F);
3514 int fs = ((instruction >> 11) & 0x0000001F);
3515 int format = ((instruction >> 21) & 0x00000007);
3517 if ((format != fmt_single) && (format != fmt_double))
3518 SignalException(ReservedInstruction,instruction);
3520 StoreFPR(destreg,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_word));
3525 010001,10,3.FMT,00000,5.FS,5.FD,010110:COP1:32::RSQRT.fmt
3527 "rsqrt.%s<FMT> f<FD>, f<FS>"
3530 unsigned32 instruction = instruction_0;
3531 int destreg = ((instruction >> 6) & 0x0000001F);
3532 int fs = ((instruction >> 11) & 0x0000001F);
3533 int format = ((instruction >> 21) & 0x00000007);
3535 if ((format != fmt_single) && (format != fmt_double))
3536 SignalException(ReservedInstruction,instruction);
3538 StoreFPR(destreg,format,Recip(SquareRoot(ValueFPR(fs,format),format),format));
3543 111101,5.BASE,5.FT,16.OFFSET:COP1:64::SDC1
3544 "sdc1 f<FT>, <OFFSET>(r<BASE>)"
3552 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (1, FT));
3556 010011,5.BASE,5.INDEX,5.FS,00000001001:COP1X:64::SDXC1
3557 "ldxc1 f<FS>, r<INDEX>(r<BASE>)"
3561 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX], COP_SD (1, FS));
3565 010001,10,3.FMT,00000,5.FS,5.FD,000100:COP1:32::SQRT.fmt
3566 "sqrt.%s<FMT> f<FD>, f<FS>"
3574 unsigned32 instruction = instruction_0;
3575 int destreg = ((instruction >> 6) & 0x0000001F);
3576 int fs = ((instruction >> 11) & 0x0000001F);
3577 int format = ((instruction >> 21) & 0x00000007);
3579 if ((format != fmt_single) && (format != fmt_double))
3580 SignalException(ReservedInstruction,instruction);
3582 StoreFPR(destreg,format,(SquareRoot(ValueFPR(fs,format),format)));
3587 010001,10,3.FMT,5.FT,5.FS,5.FD,000001:COP1:32::SUB.fmt
3588 "sub.%s<FMT> f<FD>, f<FS>, f<FT>"
3589 *mipsI,mipsII,mipsIII,mipsIV:
3594 unsigned32 instruction = instruction_0;
3595 int destreg = ((instruction >> 6) & 0x0000001F);
3596 int fs = ((instruction >> 11) & 0x0000001F);
3597 int ft = ((instruction >> 16) & 0x0000001F);
3598 int format = ((instruction >> 21) & 0x00000007);
3600 if ((format != fmt_single) && (format != fmt_double))
3601 SignalException(ReservedInstruction,instruction);
3603 StoreFPR(destreg,format,Sub(ValueFPR(fs,format),ValueFPR(ft,format),format));
3609 111001,5.BASE,5.FT,16.OFFSET:COP1:32::SWC1
3610 "swc1 f<FT>, <OFFSET>(r<BASE>)"
3611 *mipsI,mipsII,mipsIII,mipsIV:
3616 unsigned32 instruction = instruction_0;
3617 signed_word offset = EXTEND16 (OFFSET);
3618 int destreg UNUSED = ((instruction >> 16) & 0x0000001F);
3619 signed_word op1 UNUSED = GPR[((instruction >> 21) & 0x0000001F)];
3621 address_word vaddr = ((uword64)op1 + offset);
3624 if ((vaddr & 3) != 0)
3626 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, AccessLength_WORD+1, vaddr, write_transfer, sim_core_unaligned_signal);
3630 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
3633 uword64 memval1 = 0;
3634 uword64 mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
3635 address_word reverseendian = (ReverseEndian ?(mask ^ AccessLength_WORD): 0);
3636 address_word bigendiancpu = (BigEndianCPU ?(mask ^ AccessLength_WORD): 0);
3638 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
3639 byte = ((vaddr & mask) ^ bigendiancpu);
3640 memval = (((uword64)COP_SW(((instruction >> 26) & 0x3),destreg)) << (8 * byte));
3641 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
3648 010011,5.BASE,5.INDEX,5.FS,00000,001000:COP1X:32::SWXC1
3649 "swxc1 f<FS>, r<INDEX>(r<BASE>)"
3653 unsigned32 instruction = instruction_0;
3654 int fs = ((instruction >> 11) & 0x0000001F);
3655 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
3656 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
3658 address_word vaddr = ((unsigned64)op1 + op2);
3661 if ((vaddr & 3) != 0)
3663 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, write_transfer, sim_core_unaligned_signal);
3667 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
3669 unsigned64 memval = 0;
3670 unsigned64 memval1 = 0;
3671 unsigned64 mask = 0x7;
3673 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
3674 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
3675 memval = (((unsigned64)COP_SW(1,fs)) << (8 * byte));
3677 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
3685 010001,10,3.FMT,00000,5.FS,5.FD,001001:COP1:64::TRUNC.L.fmt
3686 "trunc.l.%s<FMT> f<FD>, f<FS>"
3693 unsigned32 instruction = instruction_0;
3694 int destreg = ((instruction >> 6) & 0x0000001F);
3695 int fs = ((instruction >> 11) & 0x0000001F);
3696 int format = ((instruction >> 21) & 0x00000007);
3698 if ((format != fmt_single) && (format != fmt_double))
3699 SignalException(ReservedInstruction,instruction);
3701 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_long));
3706 010001,10,3.FMT,00000,5.FS,5.FD,001101:COP1:32::TRUNC.W
3707 "trunc.w.%s<FMT> f<FD>, f<FS>"
3715 unsigned32 instruction = instruction_0;
3716 int destreg = ((instruction >> 6) & 0x0000001F);
3717 int fs = ((instruction >> 11) & 0x0000001F);
3718 int format = ((instruction >> 21) & 0x00000007);
3720 if ((format != fmt_single) && (format != fmt_double))
3721 SignalException(ReservedInstruction,instruction);
3723 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_word));
3729 // MIPS Architecture:
3731 // System Control Instruction Set (COP0)
3735 010000,01000,00000,16.OFFSET:COP0:32::BC0F
3737 *mipsI,mipsII,mipsIII,mipsIV:
3742 010000,01000,00010,16.OFFSET:COP0:32::BC0FL
3744 *mipsI,mipsII,mipsIII,mipsIV:
3749 010000,01000,00001,16.OFFSET:COP0:32::BC0T
3751 *mipsI,mipsII,mipsIII,mipsIV:
3755 010000,01000,00011,16.OFFSET:COP0:32::BC0TL
3757 *mipsI,mipsII,mipsIII,mipsIV:
3762 101111,5.BASE,5.OP,16.OFFSET:NORMAL:32::CACHE
3769 unsigned32 instruction = instruction_0;
3770 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
3771 int hint = ((instruction >> 16) & 0x0000001F);
3772 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
3774 address_word vaddr = (op1 + offset);
3777 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
3778 CacheOp(hint,vaddr,paddr,instruction);
3783 010000,10000,000000000000000,111001:COP0:32::DI
3785 *mipsI,mipsII,mipsIII,mipsIV:
3790 010000,10000,000000000000000,111000:COP0:32::EI
3792 *mipsI,mipsII,mipsIII,mipsIV:
3797 010000,10000,000000000000000,011000:COP0:32::ERET
3804 if (SR & status_ERL)
3806 /* Oops, not yet available */
3807 sim_io_printf (SD, "Warning: ERET when SR[ERL] set not supported");
3819 010000,00000,5.RT,5.RD,00000,6.REGX:COP0:32::MFC0
3820 "mfc0 r<RT>, r<RD> # <REGX>"
3821 *mipsI,mipsII,mipsIII,mipsIV:
3826 TRACE_ALU_INPUT0 ();
3827 DecodeCoproc (instruction_0);
3828 TRACE_ALU_RESULT (GPR[RT]);
3831 010000,00100,5.RT,5.RD,00000,6.REGX:COP0:32::MTC0
3832 "mtc0 r<RT>, r<RD> # <REGX>"
3833 *mipsI,mipsII,mipsIII,mipsIV:
3838 DecodeCoproc (instruction_0);
3842 010000,10000,000000000000000,010000:COP0:32::RFE
3844 *mipsI,mipsII,mipsIII,mipsIV:
3849 DecodeCoproc (instruction_0);
3853 0100,ZZ!0!1!3,5.COP_FUN0!8,5.COP_FUN1,16.COP_FUN2:NORMAL:32::COPz
3854 "cop<ZZ> <COP_FUN0><COP_FUN1><COP_FUN2>"
3855 *mipsI,mipsII,mipsIII,mipsIV:
3859 DecodeCoproc (instruction_0);
3864 010000,10000,000000000000000,001000:COP0:32::TLBP
3866 *mipsI,mipsII,mipsIII,mipsIV:
3871 010000,10000,000000000000000,000001:COP0:32::TLBR
3873 *mipsI,mipsII,mipsIII,mipsIV:
3878 010000,10000,000000000000000,000010:COP0:32::TLBWI
3880 *mipsI,mipsII,mipsIII,mipsIV:
3885 010000,10000,000000000000000,000110:COP0:32::TLBWR
3887 *mipsI,mipsII,mipsIII,mipsIV: