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 are defined below.
39 // When placing models in the instruction descriptions, please place
40 // them one per line, in the order given here.
44 // Instructions and related functions for these models are included in
46 :model:::mipsI:mips3000:
47 :model:::mipsII:mips6000:
48 :model:::mipsIII:mips4000:
49 :model:::mipsIV:mips8000:
50 :model:::mipsV:mipsisaV:
54 // Standard MIPS ISA instructions used for these models are listed here,
55 // as are functions needed by those standard instructions. Instructions
56 // which are model-dependent and which are not in the standard MIPS ISAs
57 // (or which pre-date or use different encodings than the standard
58 // instructions) are (for the most part) in separate .igen files.
59 :model:::vr4100:mips4100: // vr.igen
60 :model:::vr5000:mips5000:
61 :model:::r3900:mips3900: // tx.igen
63 // MIPS Application Specific Extensions (ASEs)
65 // Instructions for the ASEs are in separate .igen files.
66 :model:::mips16:mips16: // m16.igen (and m16.dc)
69 // Pseudo instructions known by IGEN
72 SignalException (ReservedInstruction, 0);
76 // Pseudo instructions known by interp.c
77 // For grep - RSVD_INSTRUCTION, RSVD_INSTRUCTION_MASK
78 000000,5.*,5.*,5.*,5.OP,000101:SPECIAL:32::RSVD
81 SignalException (ReservedInstruction, instruction_0);
88 // Simulate a 32 bit delayslot instruction
91 :function:::address_word:delayslot32:address_word target
93 instruction_word delay_insn;
94 sim_events_slip (SD, 1);
96 CIA = CIA + 4; /* NOTE not mips16 */
97 STATE |= simDELAYSLOT;
98 delay_insn = IMEM32 (CIA); /* NOTE not mips16 */
99 ENGINE_ISSUE_PREFIX_HOOK();
100 idecode_issue (CPU_, delay_insn, (CIA));
101 STATE &= ~simDELAYSLOT;
105 :function:::address_word:nullify_next_insn32:
107 sim_events_slip (SD, 1);
108 dotrace (SD, CPU, tracefh, 2, CIA + 4, 4, "load instruction");
114 // Check that an access to a HI/LO register meets timing requirements
116 // The following requirements exist:
118 // - A MT {HI,LO} update was not immediatly preceeded by a MF {HI,LO} read
119 // - A OP {HI,LO} update was not immediatly preceeded by a MF {HI,LO} read
120 // - A MF {HI,LO} read was not corrupted by a preceeding MT{LO,HI} update
121 // corruption occures when MT{LO,HI} is preceeded by a OP {HI,LO}.
124 :function:::int:check_mf_cycles:hilo_history *history, signed64 time, const char *new
126 if (history->mf.timestamp + 3 > time)
128 sim_engine_abort (SD, CPU, CIA, "HILO: %s: %s at 0x%08lx too close to MF at 0x%08lx\n",
129 itable[MY_INDEX].name,
131 (long) history->mf.cia);
137 :function:::int:check_mt_hilo:hilo_history *history
146 signed64 time = sim_events_time (SD);
147 int ok = check_mf_cycles (SD_, history, time, "MT");
148 history->mt.timestamp = time;
149 history->mt.cia = CIA;
153 :function:::int:check_mt_hilo:hilo_history *history
156 signed64 time = sim_events_time (SD);
157 history->mt.timestamp = time;
158 history->mt.cia = CIA;
163 :function:::int:check_mf_hilo:hilo_history *history, hilo_history *peer
173 signed64 time = sim_events_time (SD);
176 && peer->mt.timestamp > history->op.timestamp
177 && history->mt.timestamp < history->op.timestamp
178 && ! (history->mf.timestamp > history->op.timestamp
179 && history->mf.timestamp < peer->mt.timestamp)
180 && ! (peer->mf.timestamp > history->op.timestamp
181 && peer->mf.timestamp < peer->mt.timestamp))
183 /* The peer has been written to since the last OP yet we have
185 sim_engine_abort (SD, CPU, CIA, "HILO: %s: MF at 0x%08lx following OP at 0x%08lx corrupted by MT at 0x%08lx\n",
186 itable[MY_INDEX].name,
188 (long) history->op.cia,
189 (long) peer->mt.cia);
192 history->mf.timestamp = time;
193 history->mf.cia = CIA;
199 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
208 signed64 time = sim_events_time (SD);
209 int ok = (check_mf_cycles (SD_, hi, time, "OP")
210 && check_mf_cycles (SD_, lo, time, "OP"));
211 hi->op.timestamp = time;
212 lo->op.timestamp = time;
218 // The r3900 mult and multu insns _can_ be exectuted immediatly after
220 :function:::int:check_mult_hilo:hilo_history *hi, hilo_history *lo
223 /* FIXME: could record the fact that a stall occured if we want */
224 signed64 time = sim_events_time (SD);
225 hi->op.timestamp = time;
226 lo->op.timestamp = time;
233 :function:::int:check_div_hilo:hilo_history *hi, hilo_history *lo
243 signed64 time = sim_events_time (SD);
244 int ok = (check_mf_cycles (SD_, hi, time, "OP")
245 && check_mf_cycles (SD_, lo, time, "OP"));
246 hi->op.timestamp = time;
247 lo->op.timestamp = time;
256 // Check that the 64-bit instruction can currently be used, and signal
257 // an ReservedInstruction exception if not.
260 :function:::void:check_u64:instruction_word insn
267 // On mips64, if UserMode check SR:PX & SR:UX bits.
268 // The check should be similar to mips64 for any with PX/UX bit equivalents.
274 // MIPS Architecture:
276 // CPU Instruction Set (mipsI - mipsV)
281 000000,5.RS,5.RT,5.RD,00000,100000:SPECIAL:32::ADD
282 "add r<RD>, r<RS>, r<RT>"
292 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
294 ALU32_BEGIN (GPR[RS]);
296 ALU32_END (GPR[RD]); /* This checks for overflow. */
298 TRACE_ALU_RESULT (GPR[RD]);
303 001000,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDI
304 "addi r<RT>, r<RS>, <IMMEDIATE>"
314 TRACE_ALU_INPUT2 (GPR[RS], EXTEND16 (IMMEDIATE));
316 ALU32_BEGIN (GPR[RS]);
317 ALU32_ADD (EXTEND16 (IMMEDIATE));
318 ALU32_END (GPR[RT]); /* This checks for overflow. */
320 TRACE_ALU_RESULT (GPR[RT]);
325 :function:::void:do_addiu:int rs, int rt, unsigned16 immediate
327 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
328 GPR[rt] = EXTEND32 (GPR[rs] + EXTEND16 (immediate));
329 TRACE_ALU_RESULT (GPR[rt]);
332 001001,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ADDIU
333 "addiu r<RT>, r<RS>, <IMMEDIATE>"
343 do_addiu (SD_, RS, RT, IMMEDIATE);
348 :function:::void:do_addu:int rs, int rt, int rd
350 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
351 GPR[rd] = EXTEND32 (GPR[rs] + GPR[rt]);
352 TRACE_ALU_RESULT (GPR[rd]);
355 000000,5.RS,5.RT,5.RD,00000,100001:SPECIAL:32::ADDU
356 "addu r<RD>, r<RS>, r<RT>"
366 do_addu (SD_, RS, RT, RD);
371 :function:::void:do_and:int rs, int rt, int rd
373 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
374 GPR[rd] = GPR[rs] & GPR[rt];
375 TRACE_ALU_RESULT (GPR[rd]);
378 000000,5.RS,5.RT,5.RD,00000,100100:SPECIAL:32::AND
379 "and r<RD>, r<RS>, r<RT>"
389 do_and (SD_, RS, RT, RD);
394 001100,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ANDI
395 "and r<RT>, r<RS>, <IMMEDIATE>"
405 TRACE_ALU_INPUT2 (GPR[RS], IMMEDIATE);
406 GPR[RT] = GPR[RS] & IMMEDIATE;
407 TRACE_ALU_RESULT (GPR[RT]);
412 000100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQ
413 "beq r<RS>, r<RT>, <OFFSET>"
423 address_word offset = EXTEND16 (OFFSET) << 2;
425 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
427 mark_branch_bug (NIA+offset);
428 DELAY_SLOT (NIA + offset);
434 010100,5.RS,5.RT,16.OFFSET:NORMAL:32::BEQL
435 "beql r<RS>, r<RT>, <OFFSET>"
444 address_word offset = EXTEND16 (OFFSET) << 2;
446 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
448 mark_branch_bug (NIA+offset);
449 DELAY_SLOT (NIA + offset);
452 NULLIFY_NEXT_INSTRUCTION ();
457 000001,5.RS,00001,16.OFFSET:REGIMM:32::BGEZ
458 "bgez r<RS>, <OFFSET>"
468 address_word offset = EXTEND16 (OFFSET) << 2;
470 if ((signed_word) GPR[RS] >= 0)
472 mark_branch_bug (NIA+offset);
473 DELAY_SLOT (NIA + offset);
479 000001,5.RS!31,10001,16.OFFSET:REGIMM:32::BGEZAL
480 "bgezal r<RS>, <OFFSET>"
490 address_word offset = EXTEND16 (OFFSET) << 2;
493 if ((signed_word) GPR[RS] >= 0)
495 mark_branch_bug (NIA+offset);
496 DELAY_SLOT (NIA + offset);
502 000001,5.RS!31,10011,16.OFFSET:REGIMM:32::BGEZALL
503 "bgezall r<RS>, <OFFSET>"
512 address_word offset = EXTEND16 (OFFSET) << 2;
515 /* NOTE: The branch occurs AFTER the next instruction has been
517 if ((signed_word) GPR[RS] >= 0)
519 mark_branch_bug (NIA+offset);
520 DELAY_SLOT (NIA + offset);
523 NULLIFY_NEXT_INSTRUCTION ();
528 000001,5.RS,00011,16.OFFSET:REGIMM:32::BGEZL
529 "bgezl r<RS>, <OFFSET>"
538 address_word offset = EXTEND16 (OFFSET) << 2;
540 if ((signed_word) GPR[RS] >= 0)
542 mark_branch_bug (NIA+offset);
543 DELAY_SLOT (NIA + offset);
546 NULLIFY_NEXT_INSTRUCTION ();
551 000111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZ
552 "bgtz r<RS>, <OFFSET>"
562 address_word offset = EXTEND16 (OFFSET) << 2;
564 if ((signed_word) GPR[RS] > 0)
566 mark_branch_bug (NIA+offset);
567 DELAY_SLOT (NIA + offset);
573 010111,5.RS,00000,16.OFFSET:NORMAL:32::BGTZL
574 "bgtzl r<RS>, <OFFSET>"
583 address_word offset = EXTEND16 (OFFSET) << 2;
585 /* NOTE: The branch occurs AFTER the next instruction has been
587 if ((signed_word) GPR[RS] > 0)
589 mark_branch_bug (NIA+offset);
590 DELAY_SLOT (NIA + offset);
593 NULLIFY_NEXT_INSTRUCTION ();
598 000110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZ
599 "blez r<RS>, <OFFSET>"
609 address_word offset = EXTEND16 (OFFSET) << 2;
611 /* NOTE: The branch occurs AFTER the next instruction has been
613 if ((signed_word) GPR[RS] <= 0)
615 mark_branch_bug (NIA+offset);
616 DELAY_SLOT (NIA + offset);
622 010110,5.RS,00000,16.OFFSET:NORMAL:32::BLEZL
623 "bgezl r<RS>, <OFFSET>"
632 address_word offset = EXTEND16 (OFFSET) << 2;
634 if ((signed_word) GPR[RS] <= 0)
636 mark_branch_bug (NIA+offset);
637 DELAY_SLOT (NIA + offset);
640 NULLIFY_NEXT_INSTRUCTION ();
645 000001,5.RS,00000,16.OFFSET:REGIMM:32::BLTZ
646 "bltz r<RS>, <OFFSET>"
656 address_word offset = EXTEND16 (OFFSET) << 2;
658 if ((signed_word) GPR[RS] < 0)
660 mark_branch_bug (NIA+offset);
661 DELAY_SLOT (NIA + offset);
667 000001,5.RS!31,10000,16.OFFSET:REGIMM:32::BLTZAL
668 "bltzal r<RS>, <OFFSET>"
678 address_word offset = EXTEND16 (OFFSET) << 2;
681 /* NOTE: The branch occurs AFTER the next instruction has been
683 if ((signed_word) GPR[RS] < 0)
685 mark_branch_bug (NIA+offset);
686 DELAY_SLOT (NIA + offset);
692 000001,5.RS!31,10010,16.OFFSET:REGIMM:32::BLTZALL
693 "bltzall r<RS>, <OFFSET>"
702 address_word offset = EXTEND16 (OFFSET) << 2;
705 if ((signed_word) GPR[RS] < 0)
707 mark_branch_bug (NIA+offset);
708 DELAY_SLOT (NIA + offset);
711 NULLIFY_NEXT_INSTRUCTION ();
716 000001,5.RS,00010,16.OFFSET:REGIMM:32::BLTZL
717 "bltzl r<RS>, <OFFSET>"
726 address_word offset = EXTEND16 (OFFSET) << 2;
728 /* NOTE: The branch occurs AFTER the next instruction has been
730 if ((signed_word) GPR[RS] < 0)
732 mark_branch_bug (NIA+offset);
733 DELAY_SLOT (NIA + offset);
736 NULLIFY_NEXT_INSTRUCTION ();
741 000101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNE
742 "bne r<RS>, r<RT>, <OFFSET>"
752 address_word offset = EXTEND16 (OFFSET) << 2;
754 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
756 mark_branch_bug (NIA+offset);
757 DELAY_SLOT (NIA + offset);
763 010101,5.RS,5.RT,16.OFFSET:NORMAL:32::BNEL
764 "bnel r<RS>, r<RT>, <OFFSET>"
773 address_word offset = EXTEND16 (OFFSET) << 2;
775 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
777 mark_branch_bug (NIA+offset);
778 DELAY_SLOT (NIA + offset);
781 NULLIFY_NEXT_INSTRUCTION ();
786 000000,20.CODE,001101:SPECIAL:32::BREAK
797 /* Check for some break instruction which are reserved for use by the simulator. */
798 unsigned int break_code = instruction_0 & HALT_INSTRUCTION_MASK;
799 if (break_code == (HALT_INSTRUCTION & HALT_INSTRUCTION_MASK) ||
800 break_code == (HALT_INSTRUCTION2 & HALT_INSTRUCTION_MASK))
802 sim_engine_halt (SD, CPU, NULL, cia,
803 sim_exited, (unsigned int)(A0 & 0xFFFFFFFF));
805 else if (break_code == (BREAKPOINT_INSTRUCTION & HALT_INSTRUCTION_MASK) ||
806 break_code == (BREAKPOINT_INSTRUCTION2 & HALT_INSTRUCTION_MASK))
808 if (STATE & simDELAYSLOT)
809 PC = cia - 4; /* reference the branch instruction */
812 SignalException(BreakPoint, instruction_0);
817 /* If we get this far, we're not an instruction reserved by the sim. Raise
819 SignalException(BreakPoint, instruction_0);
825 000000,5.RS,5.RT,5.RD,00000,101100:SPECIAL:64::DADD
826 "dadd r<RD>, r<RS>, r<RT>"
833 check_u64 (SD_, instruction_0);
834 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
836 ALU64_BEGIN (GPR[RS]);
838 ALU64_END (GPR[RD]); /* This checks for overflow. */
840 TRACE_ALU_RESULT (GPR[RD]);
845 011000,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDI
846 "daddi r<RT>, r<RS>, <IMMEDIATE>"
853 check_u64 (SD_, instruction_0);
854 TRACE_ALU_INPUT2 (GPR[RS], EXTEND16 (IMMEDIATE));
856 ALU64_BEGIN (GPR[RS]);
857 ALU64_ADD (EXTEND16 (IMMEDIATE));
858 ALU64_END (GPR[RT]); /* This checks for overflow. */
860 TRACE_ALU_RESULT (GPR[RT]);
865 :function:::void:do_daddiu:int rs, int rt, unsigned16 immediate
867 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
868 GPR[rt] = GPR[rs] + EXTEND16 (immediate);
869 TRACE_ALU_RESULT (GPR[rt]);
872 011001,5.RS,5.RT,16.IMMEDIATE:NORMAL:64::DADDIU
873 "daddiu r<RT>, r<RS>, <IMMEDIATE>"
880 check_u64 (SD_, instruction_0);
881 do_daddiu (SD_, RS, RT, IMMEDIATE);
886 :function:::void:do_daddu:int rs, int rt, int rd
888 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
889 GPR[rd] = GPR[rs] + GPR[rt];
890 TRACE_ALU_RESULT (GPR[rd]);
893 000000,5.RS,5.RT,5.RD,00000,101101:SPECIAL:64::DADDU
894 "daddu r<RD>, r<RS>, r<RT>"
901 check_u64 (SD_, instruction_0);
902 do_daddu (SD_, RS, RT, RD);
907 :function:::void:do_ddiv:int rs, int rt
909 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
910 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
912 signed64 n = GPR[rs];
913 signed64 d = GPR[rt];
918 lo = SIGNED64 (0x8000000000000000);
921 else if (d == -1 && n == SIGNED64 (0x8000000000000000))
923 lo = SIGNED64 (0x8000000000000000);
934 TRACE_ALU_RESULT2 (HI, LO);
937 000000,5.RS,5.RT,0000000000,011110:SPECIAL:64::DDIV
945 check_u64 (SD_, instruction_0);
946 do_ddiv (SD_, RS, RT);
951 :function:::void:do_ddivu:int rs, int rt
953 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
954 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
956 unsigned64 n = GPR[rs];
957 unsigned64 d = GPR[rt];
962 lo = SIGNED64 (0x8000000000000000);
973 TRACE_ALU_RESULT2 (HI, LO);
976 000000,5.RS,5.RT,0000000000,011111:SPECIAL:64::DDIVU
984 check_u64 (SD_, instruction_0);
985 do_ddivu (SD_, RS, RT);
990 :function:::void:do_div:int rs, int rt
992 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
993 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
995 signed32 n = GPR[rs];
996 signed32 d = GPR[rt];
999 LO = EXTEND32 (0x80000000);
1002 else if (n == SIGNED32 (0x80000000) && d == -1)
1004 LO = EXTEND32 (0x80000000);
1009 LO = EXTEND32 (n / d);
1010 HI = EXTEND32 (n % d);
1013 TRACE_ALU_RESULT2 (HI, LO);
1016 000000,5.RS,5.RT,0000000000,011010:SPECIAL:32::DIV
1027 do_div (SD_, RS, RT);
1032 :function:::void:do_divu:int rs, int rt
1034 check_div_hilo (SD_, HIHISTORY, LOHISTORY);
1035 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1037 unsigned32 n = GPR[rs];
1038 unsigned32 d = GPR[rt];
1041 LO = EXTEND32 (0x80000000);
1046 LO = EXTEND32 (n / d);
1047 HI = EXTEND32 (n % d);
1050 TRACE_ALU_RESULT2 (HI, LO);
1053 000000,5.RS,5.RT,0000000000,011011:SPECIAL:32::DIVU
1064 do_divu (SD_, RS, RT);
1069 :function:::void:do_dmultx:int rs, int rt, int rd, int signed_p
1079 unsigned64 op1 = GPR[rs];
1080 unsigned64 op2 = GPR[rt];
1081 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1082 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1083 /* make signed multiply unsigned */
1098 /* multiply out the 4 sub products */
1099 m00 = ((unsigned64) VL4_8 (op1) * (unsigned64) VL4_8 (op2));
1100 m10 = ((unsigned64) VH4_8 (op1) * (unsigned64) VL4_8 (op2));
1101 m01 = ((unsigned64) VL4_8 (op1) * (unsigned64) VH4_8 (op2));
1102 m11 = ((unsigned64) VH4_8 (op1) * (unsigned64) VH4_8 (op2));
1103 /* add the products */
1104 mid = ((unsigned64) VH4_8 (m00)
1105 + (unsigned64) VL4_8 (m10)
1106 + (unsigned64) VL4_8 (m01));
1107 lo = U8_4 (mid, m00);
1109 + (unsigned64) VH4_8 (mid)
1110 + (unsigned64) VH4_8 (m01)
1111 + (unsigned64) VH4_8 (m10));
1121 /* save the result HI/LO (and a gpr) */
1126 TRACE_ALU_RESULT2 (HI, LO);
1129 :function:::void:do_dmult:int rs, int rt, int rd
1131 do_dmultx (SD_, rs, rt, rd, 1);
1134 000000,5.RS,5.RT,0000000000,011100:SPECIAL:64::DMULT
1135 "dmult r<RS>, r<RT>"
1141 check_u64 (SD_, instruction_0);
1142 do_dmult (SD_, RS, RT, 0);
1145 000000,5.RS,5.RT,5.RD,00000,011100:SPECIAL:64::DMULT
1146 "dmult r<RS>, r<RT>":RD == 0
1147 "dmult r<RD>, r<RS>, r<RT>"
1150 check_u64 (SD_, instruction_0);
1151 do_dmult (SD_, RS, RT, RD);
1156 :function:::void:do_dmultu:int rs, int rt, int rd
1158 do_dmultx (SD_, rs, rt, rd, 0);
1161 000000,5.RS,5.RT,0000000000,011101:SPECIAL:64::DMULTU
1162 "dmultu r<RS>, r<RT>"
1168 check_u64 (SD_, instruction_0);
1169 do_dmultu (SD_, RS, RT, 0);
1172 000000,5.RS,5.RT,5.RD,00000,011101:SPECIAL:64::DMULTU
1173 "dmultu r<RD>, r<RS>, r<RT>":RD == 0
1174 "dmultu r<RS>, r<RT>"
1177 check_u64 (SD_, instruction_0);
1178 do_dmultu (SD_, RS, RT, RD);
1181 :function:::void:do_dsll:int rt, int rd, int shift
1183 TRACE_ALU_INPUT2 (GPR[rt], shift);
1184 GPR[rd] = GPR[rt] << shift;
1185 TRACE_ALU_RESULT (GPR[rd]);
1188 000000,00000,5.RT,5.RD,5.SHIFT,111000:SPECIAL:64::DSLL
1189 "dsll r<RD>, r<RT>, <SHIFT>"
1196 check_u64 (SD_, instruction_0);
1197 do_dsll (SD_, RT, RD, SHIFT);
1201 000000,00000,5.RT,5.RD,5.SHIFT,111100:SPECIAL:64::DSLL32
1202 "dsll32 r<RD>, r<RT>, <SHIFT>"
1210 check_u64 (SD_, instruction_0);
1211 TRACE_ALU_INPUT2 (GPR[RT], s);
1212 GPR[RD] = GPR[RT] << s;
1213 TRACE_ALU_RESULT (GPR[RD]);
1216 :function:::void:do_dsllv:int rs, int rt, int rd
1218 int s = MASKED64 (GPR[rs], 5, 0);
1219 TRACE_ALU_INPUT2 (GPR[rt], s);
1220 GPR[rd] = GPR[rt] << s;
1221 TRACE_ALU_RESULT (GPR[rd]);
1224 000000,5.RS,5.RT,5.RD,00000,010100:SPECIAL:64::DSLLV
1225 "dsllv r<RD>, r<RT>, r<RS>"
1232 check_u64 (SD_, instruction_0);
1233 do_dsllv (SD_, RS, RT, RD);
1236 :function:::void:do_dsra:int rt, int rd, int shift
1238 TRACE_ALU_INPUT2 (GPR[rt], shift);
1239 GPR[rd] = ((signed64) GPR[rt]) >> shift;
1240 TRACE_ALU_RESULT (GPR[rd]);
1244 000000,00000,5.RT,5.RD,5.SHIFT,111011:SPECIAL:64::DSRA
1245 "dsra r<RD>, r<RT>, <SHIFT>"
1252 check_u64 (SD_, instruction_0);
1253 do_dsra (SD_, RT, RD, SHIFT);
1257 000000,00000,5.RT,5.RD,5.SHIFT,111111:SPECIAL:64::DSRA32
1258 "dsra32 r<RD>, r<RT>, <SHIFT>"
1266 check_u64 (SD_, instruction_0);
1267 TRACE_ALU_INPUT2 (GPR[RT], s);
1268 GPR[RD] = ((signed64) GPR[RT]) >> s;
1269 TRACE_ALU_RESULT (GPR[RD]);
1273 :function:::void:do_dsrav:int rs, int rt, int rd
1275 int s = MASKED64 (GPR[rs], 5, 0);
1276 TRACE_ALU_INPUT2 (GPR[rt], s);
1277 GPR[rd] = ((signed64) GPR[rt]) >> s;
1278 TRACE_ALU_RESULT (GPR[rd]);
1281 000000,5.RS,5.RT,5.RD,00000,010111:SPECIAL:64::DSRAV
1282 "dsrav r<RD>, r<RT>, r<RS>"
1289 check_u64 (SD_, instruction_0);
1290 do_dsrav (SD_, RS, RT, RD);
1293 :function:::void:do_dsrl:int rt, int rd, int shift
1295 TRACE_ALU_INPUT2 (GPR[rt], shift);
1296 GPR[rd] = (unsigned64) GPR[rt] >> shift;
1297 TRACE_ALU_RESULT (GPR[rd]);
1301 000000,00000,5.RT,5.RD,5.SHIFT,111010:SPECIAL:64::DSRL
1302 "dsrl r<RD>, r<RT>, <SHIFT>"
1309 check_u64 (SD_, instruction_0);
1310 do_dsrl (SD_, RT, RD, SHIFT);
1314 000000,00000,5.RT,5.RD,5.SHIFT,111110:SPECIAL:64::DSRL32
1315 "dsrl32 r<RD>, r<RT>, <SHIFT>"
1323 check_u64 (SD_, instruction_0);
1324 TRACE_ALU_INPUT2 (GPR[RT], s);
1325 GPR[RD] = (unsigned64) GPR[RT] >> s;
1326 TRACE_ALU_RESULT (GPR[RD]);
1330 :function:::void:do_dsrlv:int rs, int rt, int rd
1332 int s = MASKED64 (GPR[rs], 5, 0);
1333 TRACE_ALU_INPUT2 (GPR[rt], s);
1334 GPR[rd] = (unsigned64) GPR[rt] >> s;
1335 TRACE_ALU_RESULT (GPR[rd]);
1340 000000,5.RS,5.RT,5.RD,00000,010110:SPECIAL:64::DSRLV
1341 "dsrlv r<RD>, r<RT>, r<RS>"
1348 check_u64 (SD_, instruction_0);
1349 do_dsrlv (SD_, RS, RT, RD);
1353 000000,5.RS,5.RT,5.RD,00000,101110:SPECIAL:64::DSUB
1354 "dsub r<RD>, r<RS>, r<RT>"
1361 check_u64 (SD_, instruction_0);
1362 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
1364 ALU64_BEGIN (GPR[RS]);
1365 ALU64_SUB (GPR[RT]);
1366 ALU64_END (GPR[RD]); /* This checks for overflow. */
1368 TRACE_ALU_RESULT (GPR[RD]);
1372 :function:::void:do_dsubu:int rs, int rt, int rd
1374 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1375 GPR[rd] = GPR[rs] - GPR[rt];
1376 TRACE_ALU_RESULT (GPR[rd]);
1379 000000,5.RS,5.RT,5.RD,00000,101111:SPECIAL:64::DSUBU
1380 "dsubu r<RD>, r<RS>, r<RT>"
1387 check_u64 (SD_, instruction_0);
1388 do_dsubu (SD_, RS, RT, RD);
1392 000010,26.INSTR_INDEX:NORMAL:32::J
1403 /* NOTE: The region used is that of the delay slot NIA and NOT the
1404 current instruction */
1405 address_word region = (NIA & MASK (63, 28));
1406 DELAY_SLOT (region | (INSTR_INDEX << 2));
1410 000011,26.INSTR_INDEX:NORMAL:32::JAL
1421 /* NOTE: The region used is that of the delay slot and NOT the
1422 current instruction */
1423 address_word region = (NIA & MASK (63, 28));
1425 DELAY_SLOT (region | (INSTR_INDEX << 2));
1428 000000,5.RS,00000,5.RD,00000,001001:SPECIAL:32::JALR
1429 "jalr r<RS>":RD == 31
1440 address_word temp = GPR[RS];
1446 000000,5.RS,000000000000000,001000:SPECIAL:32::JR
1457 DELAY_SLOT (GPR[RS]);
1461 :function:::unsigned_word:do_load:unsigned access, address_word base, address_word offset
1463 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1464 address_word reverseendian = (ReverseEndian ? (mask ^ access) : 0);
1465 address_word bigendiancpu = (BigEndianCPU ? (mask ^ access) : 0);
1472 vaddr = base + offset;
1473 if ((vaddr & access) != 0)
1475 SIM_CORE_SIGNAL (SD, STATE_CPU (SD, 0), cia, read_map, access+1, vaddr, read_transfer, sim_core_unaligned_signal);
1477 AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
1478 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
1479 LoadMemory (&memval, NULL, uncached, access, paddr, vaddr, isDATA, isREAL);
1480 byte = ((vaddr & mask) ^ bigendiancpu);
1481 return (memval >> (8 * byte));
1484 :function:::unsigned_word:do_load_left:unsigned access, address_word base, address_word offset, unsigned_word rt
1486 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1487 address_word reverseendian = (ReverseEndian ? -1 : 0);
1488 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
1497 unsigned_word lhs_mask;
1500 vaddr = base + offset;
1501 AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
1502 paddr = (paddr ^ (reverseendian & mask));
1503 if (BigEndianMem == 0)
1504 paddr = paddr & ~access;
1506 /* compute where within the word/mem we are */
1507 byte = ((vaddr ^ bigendiancpu) & access); /* 0..access */
1508 word = ((vaddr ^ bigendiancpu) & (mask & ~access)) / (access + 1); /* 0..1 */
1509 nr_lhs_bits = 8 * byte + 8;
1510 nr_rhs_bits = 8 * access - 8 * byte;
1511 /* nr_lhs_bits + nr_rhs_bits == 8 * (accesss + 1) */
1513 /* fprintf (stderr, "l[wd]l: 0x%08lx%08lx 0x%08lx%08lx %d:%d %d+%d\n",
1514 (long) ((unsigned64) vaddr >> 32), (long) vaddr,
1515 (long) ((unsigned64) paddr >> 32), (long) paddr,
1516 word, byte, nr_lhs_bits, nr_rhs_bits); */
1518 LoadMemory (&memval, NULL, uncached, byte, paddr, vaddr, isDATA, isREAL);
1521 /* GPR{31..32-NR_LHS_BITS} = memval{NR_LHS_BITS-1..0} */
1522 temp = (memval << nr_rhs_bits);
1526 /* GPR{31..32-NR_LHS_BITS = memval{32+NR_LHS_BITS..32} */
1527 temp = (memval >> nr_lhs_bits);
1529 lhs_mask = LSMASK (nr_lhs_bits + nr_rhs_bits - 1, nr_rhs_bits);
1530 rt = (rt & ~lhs_mask) | (temp & lhs_mask);
1532 /* fprintf (stderr, "l[wd]l: 0x%08lx%08lx -> 0x%08lx%08lx & 0x%08lx%08lx -> 0x%08lx%08lx\n",
1533 (long) ((unsigned64) memval >> 32), (long) memval,
1534 (long) ((unsigned64) temp >> 32), (long) temp,
1535 (long) ((unsigned64) lhs_mask >> 32), (long) lhs_mask,
1536 (long) (rt >> 32), (long) rt); */
1540 :function:::unsigned_word:do_load_right:unsigned access, address_word base, address_word offset, unsigned_word rt
1542 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
1543 address_word reverseendian = (ReverseEndian ? -1 : 0);
1544 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
1551 vaddr = base + offset;
1552 AddressTranslation (vaddr, isDATA, isLOAD, &paddr, &uncached, isTARGET, isREAL);
1553 /* NOTE: SPEC is wrong, has `BigEndianMem == 0' not `BigEndianMem != 0' */
1554 paddr = (paddr ^ (reverseendian & mask));
1555 if (BigEndianMem != 0)
1556 paddr = paddr & ~access;
1557 byte = ((vaddr & mask) ^ (bigendiancpu & mask));
1558 /* NOTE: SPEC is wrong, had `byte' not `access - byte'. See SW. */
1559 LoadMemory (&memval, NULL, uncached, access - (access & byte), paddr, vaddr, isDATA, isREAL);
1560 /* printf ("lr: 0x%08lx %d@0x%08lx 0x%08lx\n",
1561 (long) paddr, byte, (long) paddr, (long) memval); */
1563 unsigned_word screen = LSMASK (8 * (access - (byte & access) + 1) - 1, 0);
1565 rt |= (memval >> (8 * byte)) & screen;
1571 100000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LB
1572 "lb r<RT>, <OFFSET>(r<BASE>)"
1582 GPR[RT] = EXTEND8 (do_load (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET)));
1586 100100,5.BASE,5.RT,16.OFFSET:NORMAL:32::LBU
1587 "lbu r<RT>, <OFFSET>(r<BASE>)"
1597 GPR[RT] = do_load (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET));
1601 110111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LD
1602 "ld r<RT>, <OFFSET>(r<BASE>)"
1609 check_u64 (SD_, instruction_0);
1610 GPR[RT] = EXTEND64 (do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
1614 1101,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDCz
1615 "ldc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1624 COP_LD (ZZ, RT, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
1630 011010,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDL
1631 "ldl r<RT>, <OFFSET>(r<BASE>)"
1638 check_u64 (SD_, instruction_0);
1639 GPR[RT] = do_load_left (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1643 011011,5.BASE,5.RT,16.OFFSET:NORMAL:64::LDR
1644 "ldr r<RT>, <OFFSET>(r<BASE>)"
1651 check_u64 (SD_, instruction_0);
1652 GPR[RT] = do_load_right (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
1656 100001,5.BASE,5.RT,16.OFFSET:NORMAL:32::LH
1657 "lh r<RT>, <OFFSET>(r<BASE>)"
1667 GPR[RT] = EXTEND16 (do_load (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET)));
1671 100101,5.BASE,5.RT,16.OFFSET:NORMAL:32::LHU
1672 "lhu r<RT>, <OFFSET>(r<BASE>)"
1682 GPR[RT] = do_load (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET));
1686 110000,5.BASE,5.RT,16.OFFSET:NORMAL:32::LL
1687 "ll r<RT>, <OFFSET>(r<BASE>)"
1695 unsigned32 instruction = instruction_0;
1696 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1697 int destreg = ((instruction >> 16) & 0x0000001F);
1698 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1700 address_word vaddr = ((unsigned64)op1 + offset);
1703 if ((vaddr & 3) != 0)
1705 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, read_transfer, sim_core_unaligned_signal);
1709 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1711 unsigned64 memval = 0;
1712 unsigned64 memval1 = 0;
1713 unsigned64 mask = 0x7;
1714 unsigned int shift = 2;
1715 unsigned int reverse = (ReverseEndian ? (mask >> shift) : 0);
1716 unsigned int bigend = (BigEndianCPU ? (mask >> shift) : 0);
1718 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (reverse << shift)));
1719 LoadMemory(&memval,&memval1,uncached,AccessLength_WORD,paddr,vaddr,isDATA,isREAL);
1720 byte = ((vaddr & mask) ^ (bigend << shift));
1721 GPR[destreg] = (SIGNEXTEND(((memval >> (8 * byte)) & 0xFFFFFFFF),32));
1729 110100,5.BASE,5.RT,16.OFFSET:NORMAL:64::LLD
1730 "lld r<RT>, <OFFSET>(r<BASE>)"
1737 unsigned32 instruction = instruction_0;
1738 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
1739 int destreg = ((instruction >> 16) & 0x0000001F);
1740 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
1741 check_u64 (SD_, instruction_0);
1743 address_word vaddr = ((unsigned64)op1 + offset);
1746 if ((vaddr & 7) != 0)
1748 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 8, vaddr, read_transfer, sim_core_unaligned_signal);
1752 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
1754 unsigned64 memval = 0;
1755 unsigned64 memval1 = 0;
1756 LoadMemory(&memval,&memval1,uncached,AccessLength_DOUBLEWORD,paddr,vaddr,isDATA,isREAL);
1757 GPR[destreg] = memval;
1765 001111,00000,5.RT,16.IMMEDIATE:NORMAL:32::LUI
1766 "lui r<RT>, <IMMEDIATE>"
1776 TRACE_ALU_INPUT1 (IMMEDIATE);
1777 GPR[RT] = EXTEND32 (IMMEDIATE << 16);
1778 TRACE_ALU_RESULT (GPR[RT]);
1782 100011,5.BASE,5.RT,16.OFFSET:NORMAL:32::LW
1783 "lw r<RT>, <OFFSET>(r<BASE>)"
1793 GPR[RT] = EXTEND32 (do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
1797 1100,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWCz
1798 "lwc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
1808 COP_LW (ZZ, RT, do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
1812 100010,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWL
1813 "lwl r<RT>, <OFFSET>(r<BASE>)"
1823 GPR[RT] = EXTEND32 (do_load_left (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]));
1827 100110,5.BASE,5.RT,16.OFFSET:NORMAL:32::LWR
1828 "lwr r<RT>, <OFFSET>(r<BASE>)"
1838 GPR[RT] = EXTEND32 (do_load_right (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]));
1842 100111,5.BASE,5.RT,16.OFFSET:NORMAL:64::LWU
1843 "lwu r<RT>, <OFFSET>(r<BASE>)"
1850 check_u64 (SD_, instruction_0);
1851 GPR[RT] = do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET));
1855 :function:::void:do_mfhi:int rd
1857 check_mf_hilo (SD_, HIHISTORY, LOHISTORY);
1858 TRACE_ALU_INPUT1 (HI);
1860 TRACE_ALU_RESULT (GPR[rd]);
1863 000000,0000000000,5.RD,00000,010000:SPECIAL:32::MFHI
1879 :function:::void:do_mflo:int rd
1881 check_mf_hilo (SD_, LOHISTORY, HIHISTORY);
1882 TRACE_ALU_INPUT1 (LO);
1884 TRACE_ALU_RESULT (GPR[rd]);
1887 000000,0000000000,5.RD,00000,010010:SPECIAL:32::MFLO
1903 000000,5.RS,5.RT,5.RD,00000,001011:SPECIAL:32::MOVN
1904 "movn r<RD>, r<RS>, r<RT>"
1915 000000,5.RS,5.RT,5.RD,00000,001010:SPECIAL:32::MOVZ
1916 "movz r<RD>, r<RS>, r<RT>"
1927 000000,5.RS,000000000000000,010001:SPECIAL:32::MTHI
1938 check_mt_hilo (SD_, HIHISTORY);
1944 000000,5.RS,000000000000000,010011:SPECIAL:32::MTLO
1955 check_mt_hilo (SD_, LOHISTORY);
1961 :function:::void:do_mult:int rs, int rt, int rd
1964 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
1965 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
1966 prod = (((signed64)(signed32) GPR[rs])
1967 * ((signed64)(signed32) GPR[rt]));
1968 LO = EXTEND32 (VL4_8 (prod));
1969 HI = EXTEND32 (VH4_8 (prod));
1972 TRACE_ALU_RESULT2 (HI, LO);
1975 000000,5.RS,5.RT,0000000000,011000:SPECIAL:32::MULT
1984 do_mult (SD_, RS, RT, 0);
1988 000000,5.RS,5.RT,5.RD,00000,011000:SPECIAL:32::MULT
1989 "mult r<RS>, r<RT>":RD == 0
1990 "mult r<RD>, r<RS>, r<RT>"
1994 do_mult (SD_, RS, RT, RD);
1998 :function:::void:do_multu:int rs, int rt, int rd
2001 check_mult_hilo (SD_, HIHISTORY, LOHISTORY);
2002 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2003 prod = (((unsigned64)(unsigned32) GPR[rs])
2004 * ((unsigned64)(unsigned32) GPR[rt]));
2005 LO = EXTEND32 (VL4_8 (prod));
2006 HI = EXTEND32 (VH4_8 (prod));
2009 TRACE_ALU_RESULT2 (HI, LO);
2012 000000,5.RS,5.RT,0000000000,011001:SPECIAL:32::MULTU
2013 "multu r<RS>, r<RT>"
2021 do_multu (SD_, RS, RT, 0);
2024 000000,5.RS,5.RT,5.RD,00000,011001:SPECIAL:32::MULTU
2025 "multu r<RS>, r<RT>":RD == 0
2026 "multu r<RD>, r<RS>, r<RT>"
2030 do_multu (SD_, RS, RT, RD);
2034 :function:::void:do_nor:int rs, int rt, int rd
2036 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2037 GPR[rd] = ~ (GPR[rs] | GPR[rt]);
2038 TRACE_ALU_RESULT (GPR[rd]);
2041 000000,5.RS,5.RT,5.RD,00000,100111:SPECIAL:32::NOR
2042 "nor r<RD>, r<RS>, r<RT>"
2052 do_nor (SD_, RS, RT, RD);
2056 :function:::void:do_or:int rs, int rt, int rd
2058 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2059 GPR[rd] = (GPR[rs] | GPR[rt]);
2060 TRACE_ALU_RESULT (GPR[rd]);
2063 000000,5.RS,5.RT,5.RD,00000,100101:SPECIAL:32::OR
2064 "or r<RD>, r<RS>, r<RT>"
2074 do_or (SD_, RS, RT, RD);
2079 :function:::void:do_ori:int rs, int rt, unsigned immediate
2081 TRACE_ALU_INPUT2 (GPR[rs], immediate);
2082 GPR[rt] = (GPR[rs] | immediate);
2083 TRACE_ALU_RESULT (GPR[rt]);
2086 001101,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::ORI
2087 "ori r<RT>, r<RS>, <IMMEDIATE>"
2097 do_ori (SD_, RS, RT, IMMEDIATE);
2101 110011,5.BASE,5.HINT,16.OFFSET:NORMAL:32::PREF
2102 "pref <HINT>, <OFFSET>(r<BASE>)"
2107 unsigned32 instruction = instruction_0;
2108 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2109 int hint = ((instruction >> 16) & 0x0000001F);
2110 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2112 address_word vaddr = ((unsigned64)op1 + offset);
2116 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
2117 Prefetch(uncached,paddr,vaddr,isDATA,hint);
2123 :function:::void:do_store:unsigned access, address_word base, address_word offset, unsigned_word word
2125 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
2126 address_word reverseendian = (ReverseEndian ? (mask ^ access) : 0);
2127 address_word bigendiancpu = (BigEndianCPU ? (mask ^ access) : 0);
2134 vaddr = base + offset;
2135 if ((vaddr & access) != 0)
2137 SIM_CORE_SIGNAL (SD, STATE_CPU(SD, 0), cia, read_map, access+1, vaddr, write_transfer, sim_core_unaligned_signal);
2139 AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
2140 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
2141 byte = ((vaddr & mask) ^ bigendiancpu);
2142 memval = (word << (8 * byte));
2143 StoreMemory (uncached, access, memval, 0, paddr, vaddr, isREAL);
2146 :function:::void:do_store_left:unsigned access, address_word base, address_word offset, unsigned_word rt
2148 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
2149 address_word reverseendian = (ReverseEndian ? -1 : 0);
2150 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
2160 vaddr = base + offset;
2161 AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
2162 paddr = (paddr ^ (reverseendian & mask));
2163 if (BigEndianMem == 0)
2164 paddr = paddr & ~access;
2166 /* compute where within the word/mem we are */
2167 byte = ((vaddr ^ bigendiancpu) & access); /* 0..access */
2168 word = ((vaddr ^ bigendiancpu) & (mask & ~access)) / (access + 1); /* 0..1 */
2169 nr_lhs_bits = 8 * byte + 8;
2170 nr_rhs_bits = 8 * access - 8 * byte;
2171 /* nr_lhs_bits + nr_rhs_bits == 8 * (accesss + 1) */
2172 /* fprintf (stderr, "s[wd]l: 0x%08lx%08lx 0x%08lx%08lx %d:%d %d+%d\n",
2173 (long) ((unsigned64) vaddr >> 32), (long) vaddr,
2174 (long) ((unsigned64) paddr >> 32), (long) paddr,
2175 word, byte, nr_lhs_bits, nr_rhs_bits); */
2179 memval = (rt >> nr_rhs_bits);
2183 memval = (rt << nr_lhs_bits);
2185 /* fprintf (stderr, "s[wd]l: 0x%08lx%08lx -> 0x%08lx%08lx\n",
2186 (long) ((unsigned64) rt >> 32), (long) rt,
2187 (long) ((unsigned64) memval >> 32), (long) memval); */
2188 StoreMemory (uncached, byte, memval, 0, paddr, vaddr, isREAL);
2191 :function:::void:do_store_right:unsigned access, address_word base, address_word offset, unsigned_word rt
2193 address_word mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
2194 address_word reverseendian = (ReverseEndian ? -1 : 0);
2195 address_word bigendiancpu = (BigEndianCPU ? -1 : 0);
2202 vaddr = base + offset;
2203 AddressTranslation (vaddr, isDATA, isSTORE, &paddr, &uncached, isTARGET, isREAL);
2204 paddr = (paddr ^ (reverseendian & mask));
2205 if (BigEndianMem != 0)
2207 byte = ((vaddr & mask) ^ (bigendiancpu & mask));
2208 memval = (rt << (byte * 8));
2209 StoreMemory (uncached, access - (access & byte), memval, 0, paddr, vaddr, isREAL);
2213 101000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SB
2214 "sb r<RT>, <OFFSET>(r<BASE>)"
2224 do_store (SD_, AccessLength_BYTE, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2228 111000,5.BASE,5.RT,16.OFFSET:NORMAL:32::SC
2229 "sc r<RT>, <OFFSET>(r<BASE>)"
2237 unsigned32 instruction = instruction_0;
2238 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2239 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2240 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2242 address_word vaddr = ((unsigned64)op1 + offset);
2245 if ((vaddr & 3) != 0)
2247 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, write_transfer, sim_core_unaligned_signal);
2251 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2253 unsigned64 memval = 0;
2254 unsigned64 memval1 = 0;
2255 unsigned64 mask = 0x7;
2257 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
2258 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
2259 memval = ((unsigned64) op2 << (8 * byte));
2262 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
2264 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
2271 111100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SCD
2272 "scd r<RT>, <OFFSET>(r<BASE>)"
2279 unsigned32 instruction = instruction_0;
2280 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
2281 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
2282 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
2283 check_u64 (SD_, instruction_0);
2285 address_word vaddr = ((unsigned64)op1 + offset);
2288 if ((vaddr & 7) != 0)
2290 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 8, vaddr, write_transfer, sim_core_unaligned_signal);
2294 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
2296 unsigned64 memval = 0;
2297 unsigned64 memval1 = 0;
2301 StoreMemory(uncached,AccessLength_DOUBLEWORD,memval,memval1,paddr,vaddr,isREAL);
2303 GPR[(instruction >> 16) & 0x0000001F] = LLBIT;
2310 111111,5.BASE,5.RT,16.OFFSET:NORMAL:64::SD
2311 "sd r<RT>, <OFFSET>(r<BASE>)"
2318 check_u64 (SD_, instruction_0);
2319 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2323 1111,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDCz
2324 "sdc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2332 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (ZZ, RT));
2336 101100,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDL
2337 "sdl r<RT>, <OFFSET>(r<BASE>)"
2344 check_u64 (SD_, instruction_0);
2345 do_store_left (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2349 101101,5.BASE,5.RT,16.OFFSET:NORMAL:64::SDR
2350 "sdr r<RT>, <OFFSET>(r<BASE>)"
2357 check_u64 (SD_, instruction_0);
2358 do_store_right (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2362 101001,5.BASE,5.RT,16.OFFSET:NORMAL:32::SH
2363 "sh r<RT>, <OFFSET>(r<BASE>)"
2373 do_store (SD_, AccessLength_HALFWORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2377 :function:::void:do_sll:int rt, int rd, int shift
2379 unsigned32 temp = (GPR[rt] << shift);
2380 TRACE_ALU_INPUT2 (GPR[rt], shift);
2381 GPR[rd] = EXTEND32 (temp);
2382 TRACE_ALU_RESULT (GPR[rd]);
2385 000000,00000,5.RT,5.RD,5.SHIFT,000000:SPECIAL:32::SLL
2386 "nop":RD == 0 && RT == 0 && SHIFT == 0
2387 "sll r<RD>, r<RT>, <SHIFT>"
2397 /* Skip shift for NOP, so that there won't be lots of extraneous
2399 if (RD != 0 || RT != 0 || SHIFT != 0)
2400 do_sll (SD_, RT, RD, SHIFT);
2404 :function:::void:do_sllv:int rs, int rt, int rd
2406 int s = MASKED (GPR[rs], 4, 0);
2407 unsigned32 temp = (GPR[rt] << s);
2408 TRACE_ALU_INPUT2 (GPR[rt], s);
2409 GPR[rd] = EXTEND32 (temp);
2410 TRACE_ALU_RESULT (GPR[rd]);
2413 000000,5.RS,5.RT,5.RD,00000,000100:SPECIAL:32::SLLV
2414 "sllv r<RD>, r<RT>, r<RS>"
2424 do_sllv (SD_, RS, RT, RD);
2428 :function:::void:do_slt:int rs, int rt, int rd
2430 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2431 GPR[rd] = ((signed_word) GPR[rs] < (signed_word) GPR[rt]);
2432 TRACE_ALU_RESULT (GPR[rd]);
2435 000000,5.RS,5.RT,5.RD,00000,101010:SPECIAL:32::SLT
2436 "slt r<RD>, r<RS>, r<RT>"
2446 do_slt (SD_, RS, RT, RD);
2450 :function:::void:do_slti:int rs, int rt, unsigned16 immediate
2452 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
2453 GPR[rt] = ((signed_word) GPR[rs] < (signed_word) EXTEND16 (immediate));
2454 TRACE_ALU_RESULT (GPR[rt]);
2457 001010,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTI
2458 "slti r<RT>, r<RS>, <IMMEDIATE>"
2468 do_slti (SD_, RS, RT, IMMEDIATE);
2472 :function:::void:do_sltiu:int rs, int rt, unsigned16 immediate
2474 TRACE_ALU_INPUT2 (GPR[rs], EXTEND16 (immediate));
2475 GPR[rt] = ((unsigned_word) GPR[rs] < (unsigned_word) EXTEND16 (immediate));
2476 TRACE_ALU_RESULT (GPR[rt]);
2479 001011,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::SLTIU
2480 "sltiu r<RT>, r<RS>, <IMMEDIATE>"
2490 do_sltiu (SD_, RS, RT, IMMEDIATE);
2495 :function:::void:do_sltu:int rs, int rt, int rd
2497 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2498 GPR[rd] = ((unsigned_word) GPR[rs] < (unsigned_word) GPR[rt]);
2499 TRACE_ALU_RESULT (GPR[rd]);
2502 000000,5.RS,5.RT,5.RD,00000,101011:SPECIAL:32::SLTU
2503 "sltu r<RD>, r<RS>, r<RT>"
2513 do_sltu (SD_, RS, RT, RD);
2517 :function:::void:do_sra:int rt, int rd, int shift
2519 signed32 temp = (signed32) GPR[rt] >> shift;
2520 TRACE_ALU_INPUT2 (GPR[rt], shift);
2521 GPR[rd] = EXTEND32 (temp);
2522 TRACE_ALU_RESULT (GPR[rd]);
2525 000000,00000,5.RT,5.RD,5.SHIFT,000011:SPECIAL:32::SRA
2526 "sra r<RD>, r<RT>, <SHIFT>"
2536 do_sra (SD_, RT, RD, SHIFT);
2541 :function:::void:do_srav:int rs, int rt, int rd
2543 int s = MASKED (GPR[rs], 4, 0);
2544 signed32 temp = (signed32) GPR[rt] >> s;
2545 TRACE_ALU_INPUT2 (GPR[rt], s);
2546 GPR[rd] = EXTEND32 (temp);
2547 TRACE_ALU_RESULT (GPR[rd]);
2550 000000,5.RS,5.RT,5.RD,00000,000111:SPECIAL:32::SRAV
2551 "srav r<RD>, r<RT>, r<RS>"
2561 do_srav (SD_, RS, RT, RD);
2566 :function:::void:do_srl:int rt, int rd, int shift
2568 unsigned32 temp = (unsigned32) GPR[rt] >> shift;
2569 TRACE_ALU_INPUT2 (GPR[rt], shift);
2570 GPR[rd] = EXTEND32 (temp);
2571 TRACE_ALU_RESULT (GPR[rd]);
2574 000000,00000,5.RT,5.RD,5.SHIFT,000010:SPECIAL:32::SRL
2575 "srl r<RD>, r<RT>, <SHIFT>"
2585 do_srl (SD_, RT, RD, SHIFT);
2589 :function:::void:do_srlv:int rs, int rt, int rd
2591 int s = MASKED (GPR[rs], 4, 0);
2592 unsigned32 temp = (unsigned32) GPR[rt] >> s;
2593 TRACE_ALU_INPUT2 (GPR[rt], s);
2594 GPR[rd] = EXTEND32 (temp);
2595 TRACE_ALU_RESULT (GPR[rd]);
2598 000000,5.RS,5.RT,5.RD,00000,000110:SPECIAL:32::SRLV
2599 "srlv r<RD>, r<RT>, r<RS>"
2609 do_srlv (SD_, RS, RT, RD);
2613 000000,5.RS,5.RT,5.RD,00000,100010:SPECIAL:32::SUB
2614 "sub r<RD>, r<RS>, r<RT>"
2624 TRACE_ALU_INPUT2 (GPR[RS], GPR[RT]);
2626 ALU32_BEGIN (GPR[RS]);
2627 ALU32_SUB (GPR[RT]);
2628 ALU32_END (GPR[RD]); /* This checks for overflow. */
2630 TRACE_ALU_RESULT (GPR[RD]);
2634 :function:::void:do_subu:int rs, int rt, int rd
2636 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2637 GPR[rd] = EXTEND32 (GPR[rs] - GPR[rt]);
2638 TRACE_ALU_RESULT (GPR[rd]);
2641 000000,5.RS,5.RT,5.RD,00000,100011:SPECIAL:32::SUBU
2642 "subu r<RD>, r<RS>, r<RT>"
2652 do_subu (SD_, RS, RT, RD);
2656 101011,5.BASE,5.RT,16.OFFSET:NORMAL:32::SW
2657 "sw r<RT>, <OFFSET>(r<BASE>)"
2667 do_store (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2671 1110,ZZ!0!1!3,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWCz
2672 "swc<ZZ> r<RT>, <OFFSET>(r<BASE>)"
2682 do_store (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), COP_SW (ZZ, RT));
2686 101010,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWL
2687 "swl r<RT>, <OFFSET>(r<BASE>)"
2697 do_store_left (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2701 101110,5.BASE,5.RT,16.OFFSET:NORMAL:32::SWR
2702 "swr r<RT>, <OFFSET>(r<BASE>)"
2712 do_store_right (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET), GPR[RT]);
2716 000000,000000000000000,5.STYPE,001111:SPECIAL:32::SYNC
2727 SyncOperation (STYPE);
2731 000000,20.CODE,001100:SPECIAL:32::SYSCALL
2742 SignalException(SystemCall, instruction_0);
2746 000000,5.RS,5.RT,10.CODE,110100:SPECIAL:32::TEQ
2755 if ((signed_word) GPR[RS] == (signed_word) GPR[RT])
2756 SignalException(Trap, instruction_0);
2760 000001,5.RS,01100,16.IMMEDIATE:REGIMM:32::TEQI
2761 "teqi r<RS>, <IMMEDIATE>"
2769 if ((signed_word) GPR[RS] == (signed_word) EXTEND16 (IMMEDIATE))
2770 SignalException(Trap, instruction_0);
2774 000000,5.RS,5.RT,10.CODE,110000:SPECIAL:32::TGE
2783 if ((signed_word) GPR[RS] >= (signed_word) GPR[RT])
2784 SignalException(Trap, instruction_0);
2788 000001,5.RS,01000,16.IMMEDIATE:REGIMM:32::TGEI
2789 "tgei r<RS>, <IMMEDIATE>"
2797 if ((signed_word) GPR[RS] >= (signed_word) EXTEND16 (IMMEDIATE))
2798 SignalException(Trap, instruction_0);
2802 000001,5.RS,01001,16.IMMEDIATE:REGIMM:32::TGEIU
2803 "tgeiu r<RS>, <IMMEDIATE>"
2811 if ((unsigned_word) GPR[RS] >= (unsigned_word) EXTEND16 (IMMEDIATE))
2812 SignalException(Trap, instruction_0);
2816 000000,5.RS,5.RT,10.CODE,110001:SPECIAL:32::TGEU
2825 if ((unsigned_word) GPR[RS] >= (unsigned_word) GPR[RT])
2826 SignalException(Trap, instruction_0);
2830 000000,5.RS,5.RT,10.CODE,110010:SPECIAL:32::TLT
2839 if ((signed_word) GPR[RS] < (signed_word) GPR[RT])
2840 SignalException(Trap, instruction_0);
2844 000001,5.RS,01010,16.IMMEDIATE:REGIMM:32::TLTI
2845 "tlti r<RS>, <IMMEDIATE>"
2853 if ((signed_word) GPR[RS] < (signed_word) EXTEND16 (IMMEDIATE))
2854 SignalException(Trap, instruction_0);
2858 000001,5.RS,01011,16.IMMEDIATE:REGIMM:32::TLTIU
2859 "tltiu r<RS>, <IMMEDIATE>"
2867 if ((unsigned_word) GPR[RS] < (unsigned_word) EXTEND16 (IMMEDIATE))
2868 SignalException(Trap, instruction_0);
2872 000000,5.RS,5.RT,10.CODE,110011:SPECIAL:32::TLTU
2881 if ((unsigned_word) GPR[RS] < (unsigned_word) GPR[RT])
2882 SignalException(Trap, instruction_0);
2886 000000,5.RS,5.RT,10.CODE,110110:SPECIAL:32::TNE
2895 if ((signed_word) GPR[RS] != (signed_word) GPR[RT])
2896 SignalException(Trap, instruction_0);
2900 000001,5.RS,01110,16.IMMEDIATE:REGIMM:32::TNEI
2901 "tne r<RS>, <IMMEDIATE>"
2909 if ((signed_word) GPR[RS] != (signed_word) EXTEND16 (IMMEDIATE))
2910 SignalException(Trap, instruction_0);
2914 :function:::void:do_xor:int rs, int rt, int rd
2916 TRACE_ALU_INPUT2 (GPR[rs], GPR[rt]);
2917 GPR[rd] = GPR[rs] ^ GPR[rt];
2918 TRACE_ALU_RESULT (GPR[rd]);
2921 000000,5.RS,5.RT,5.RD,00000,100110:SPECIAL:32::XOR
2922 "xor r<RD>, r<RS>, r<RT>"
2932 do_xor (SD_, RS, RT, RD);
2936 :function:::void:do_xori:int rs, int rt, unsigned16 immediate
2938 TRACE_ALU_INPUT2 (GPR[rs], immediate);
2939 GPR[rt] = GPR[rs] ^ immediate;
2940 TRACE_ALU_RESULT (GPR[rt]);
2943 001110,5.RS,5.RT,16.IMMEDIATE:NORMAL:32::XORI
2944 "xori r<RT>, r<RS>, <IMMEDIATE>"
2954 do_xori (SD_, RS, RT, IMMEDIATE);
2959 // MIPS Architecture:
2961 // FPU Instruction Set (COP1 & COP1X)
2969 case fmt_single: return "s";
2970 case fmt_double: return "d";
2971 case fmt_word: return "w";
2972 case fmt_long: return "l";
2973 default: return "?";
2983 default: return "?";
3003 :%s::::COND:int cond
3007 case 00: return "f";
3008 case 01: return "un";
3009 case 02: return "eq";
3010 case 03: return "ueq";
3011 case 04: return "olt";
3012 case 05: return "ult";
3013 case 06: return "ole";
3014 case 07: return "ule";
3015 case 010: return "sf";
3016 case 011: return "ngle";
3017 case 012: return "seq";
3018 case 013: return "ngl";
3019 case 014: return "lt";
3020 case 015: return "nge";
3021 case 016: return "le";
3022 case 017: return "ngt";
3023 default: return "?";
3029 // Check that the FPU is currently usable, and signal a CoProcessorUnusable
3030 // exception if not.
3033 :function:::void:check_fpu:
3043 #if 0 /* XXX FIXME: For now, never treat the FPU as disabled. */
3044 if (! COP_Usable (1))
3045 SignalExceptionCoProcessorUnusable (1);
3050 010001,10,3.FMT,00000,5.FS,5.FD,000101:COP1:32,f::ABS.fmt
3051 "abs.%s<FMT> f<FD>, f<FS>"
3061 unsigned32 instruction = instruction_0;
3062 int destreg = ((instruction >> 6) & 0x0000001F);
3063 int fs = ((instruction >> 11) & 0x0000001F);
3064 int format = ((instruction >> 21) & 0x00000007);
3067 if ((format != fmt_single) && (format != fmt_double))
3068 SignalException(ReservedInstruction,instruction);
3070 StoreFPR(destreg,format,AbsoluteValue(ValueFPR(fs,format),format));
3076 010001,10,3.FMT,5.FT,5.FS,5.FD,000000:COP1:32,f::ADD.fmt
3077 "add.%s<FMT> f<FD>, f<FS>, f<FT>"
3087 unsigned32 instruction = instruction_0;
3088 int destreg = ((instruction >> 6) & 0x0000001F);
3089 int fs = ((instruction >> 11) & 0x0000001F);
3090 int ft = ((instruction >> 16) & 0x0000001F);
3091 int format = ((instruction >> 21) & 0x00000007);
3094 if ((format != fmt_single) && (format != fmt_double))
3095 SignalException(ReservedInstruction, instruction);
3097 StoreFPR(destreg,format,Add(ValueFPR(fs,format),ValueFPR(ft,format),format));
3108 010001,01000,3.0,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1a
3109 "bc1%s<TF>%s<ND> <OFFSET>"
3115 check_branch_bug ();
3116 TRACE_BRANCH_INPUT (PREVCOC1());
3117 if (PREVCOC1() == TF)
3119 address_word dest = NIA + (EXTEND16 (OFFSET) << 2);
3120 TRACE_BRANCH_RESULT (dest);
3121 mark_branch_bug (dest);
3126 TRACE_BRANCH_RESULT (0);
3127 NULLIFY_NEXT_INSTRUCTION ();
3131 TRACE_BRANCH_RESULT (NIA);
3135 010001,01000,3.CC,1.ND,1.TF,16.OFFSET:COP1S:32,f::BC1b
3136 "bc1%s<TF>%s<ND> <OFFSET>":CC == 0
3137 "bc1%s<TF>%s<ND> <CC>, <OFFSET>"
3145 check_branch_bug ();
3146 if (GETFCC(CC) == TF)
3148 address_word dest = NIA + (EXTEND16 (OFFSET) << 2);
3149 mark_branch_bug (dest);
3154 NULLIFY_NEXT_INSTRUCTION ();
3167 :function:::void:do_c_cond_fmt:int fmt, int ft, int fs, int cc, int cond, instruction_word insn
3169 if ((fmt != fmt_single) && (fmt != fmt_double))
3170 SignalException (ReservedInstruction, insn);
3177 unsigned64 ofs = ValueFPR (fs, fmt);
3178 unsigned64 oft = ValueFPR (ft, fmt);
3179 if (NaN (ofs, fmt) || NaN (oft, fmt))
3181 if (FCSR & FP_ENABLE (IO))
3183 FCSR |= FP_CAUSE (IO);
3184 SignalExceptionFPE ();
3192 less = Less (ofs, oft, fmt);
3193 equal = Equal (ofs, oft, fmt);
3196 condition = (((cond & (1 << 2)) && less)
3197 || ((cond & (1 << 1)) && equal)
3198 || ((cond & (1 << 0)) && unordered));
3199 SETFCC (cc, condition);
3203 010001,10,3.FMT,5.FT,5.FS,3.0,00,11,4.COND:COP1:32,f::C.cond.fmta
3204 "c.%s<COND>.%s<FMT> f<FS>, f<FT>"
3210 do_c_cond_fmt (SD_, FMT, FT, FS, 0, COND, instruction_0);
3213 010001,10,3.FMT,5.FT,5.FS,3.CC,00,11,4.COND:COP1:32,f::C.cond.fmtb
3214 "c.%s<COND>.%s<FMT> f<FS>, f<FT>":CC == 0
3215 "c.%s<COND>.%s<FMT> <CC>, f<FS>, f<FT>"
3223 do_c_cond_fmt (SD_, FMT, FT, FS, CC, COND, instruction_0);
3227 010001,10,3.FMT,00000,5.FS,5.FD,001010:COP1:64,f::CEIL.L.fmt
3228 "ceil.l.%s<FMT> f<FD>, f<FS>"
3236 unsigned32 instruction = instruction_0;
3237 int destreg = ((instruction >> 6) & 0x0000001F);
3238 int fs = ((instruction >> 11) & 0x0000001F);
3239 int format = ((instruction >> 21) & 0x00000007);
3242 if ((format != fmt_single) && (format != fmt_double))
3243 SignalException(ReservedInstruction,instruction);
3245 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_long));
3250 010001,10,3.FMT,00000,5.FS,5.FD,001110:COP1:32,f::CEIL.W
3259 unsigned32 instruction = instruction_0;
3260 int destreg = ((instruction >> 6) & 0x0000001F);
3261 int fs = ((instruction >> 11) & 0x0000001F);
3262 int format = ((instruction >> 21) & 0x00000007);
3265 if ((format != fmt_single) && (format != fmt_double))
3266 SignalException(ReservedInstruction,instruction);
3268 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOPINF,ValueFPR(fs,format),format,fmt_word));
3275 010001,00,X,10,5.RT,5.FS,00000000000:COP1Sa:32,f::CxC1
3276 "c%s<X>c1 r<RT>, f<FS>"
3285 PENDING_FILL(FCR0IDX,VL4_8(GPR[RT]));
3287 PENDING_FILL(FCR31IDX,VL4_8(GPR[RT]));
3289 PENDING_SCHED(FCSR, FCR31 & (1<<23), 1, 23);
3292 { /* control from */
3294 PENDING_FILL(RT,SIGNEXTEND(FCR0,32));
3296 PENDING_FILL(RT,SIGNEXTEND(FCR31,32));
3300 010001,00,X,10,5.RT,5.FS,00000000000:COP1Sb:32,f::CxC1
3301 "c%s<X>c1 r<RT>, f<FS>"
3312 TRACE_ALU_INPUT1 (GPR[RT]);
3315 FCR0 = VL4_8(GPR[RT]);
3316 TRACE_ALU_RESULT (FCR0);
3320 FCR31 = VL4_8(GPR[RT]);
3321 SETFCC(0,((FCR31 & (1 << 23)) ? 1 : 0));
3322 TRACE_ALU_RESULT (FCR31);
3326 TRACE_ALU_RESULT0 ();
3331 { /* control from */
3334 TRACE_ALU_INPUT1 (FCR0);
3335 GPR[RT] = SIGNEXTEND (FCR0, 32);
3339 TRACE_ALU_INPUT1 (FCR31);
3340 GPR[RT] = SIGNEXTEND (FCR31, 32);
3342 TRACE_ALU_RESULT (GPR[RT]);
3349 // FIXME: Does not correctly differentiate between mips*
3351 010001,10,3.FMT,00000,5.FS,5.FD,100001:COP1:32,f::CVT.D.fmt
3352 "cvt.d.%s<FMT> f<FD>, f<FS>"
3362 unsigned32 instruction = instruction_0;
3363 int destreg = ((instruction >> 6) & 0x0000001F);
3364 int fs = ((instruction >> 11) & 0x0000001F);
3365 int format = ((instruction >> 21) & 0x00000007);
3368 if ((format == fmt_double) | 0)
3369 SignalException(ReservedInstruction,instruction);
3371 StoreFPR(destreg,fmt_double,Convert(GETRM(),ValueFPR(fs,format),format,fmt_double));
3376 010001,10,3.FMT,00000,5.FS,5.FD,100101:COP1:64,f::CVT.L.fmt
3377 "cvt.l.%s<FMT> f<FD>, f<FS>"
3385 unsigned32 instruction = instruction_0;
3386 int destreg = ((instruction >> 6) & 0x0000001F);
3387 int fs = ((instruction >> 11) & 0x0000001F);
3388 int format = ((instruction >> 21) & 0x00000007);
3391 if ((format == fmt_long) | ((format == fmt_long) || (format == fmt_word)))
3392 SignalException(ReservedInstruction,instruction);
3394 StoreFPR(destreg,fmt_long,Convert(GETRM(),ValueFPR(fs,format),format,fmt_long));
3400 // FIXME: Does not correctly differentiate between mips*
3402 010001,10,3.FMT,00000,5.FS,5.FD,100000:COP1:32,f::CVT.S.fmt
3403 "cvt.s.%s<FMT> f<FD>, f<FS>"
3413 unsigned32 instruction = instruction_0;
3414 int destreg = ((instruction >> 6) & 0x0000001F);
3415 int fs = ((instruction >> 11) & 0x0000001F);
3416 int format = ((instruction >> 21) & 0x00000007);
3419 if ((format == fmt_single) | 0)
3420 SignalException(ReservedInstruction,instruction);
3422 StoreFPR(destreg,fmt_single,Convert(GETRM(),ValueFPR(fs,format),format,fmt_single));
3427 010001,10,3.FMT,00000,5.FS,5.FD,100100:COP1:32,f::CVT.W.fmt
3428 "cvt.w.%s<FMT> f<FD>, f<FS>"
3438 unsigned32 instruction = instruction_0;
3439 int destreg = ((instruction >> 6) & 0x0000001F);
3440 int fs = ((instruction >> 11) & 0x0000001F);
3441 int format = ((instruction >> 21) & 0x00000007);
3444 if ((format == fmt_word) | ((format == fmt_long) || (format == fmt_word)))
3445 SignalException(ReservedInstruction,instruction);
3447 StoreFPR(destreg,fmt_word,Convert(GETRM(),ValueFPR(fs,format),format,fmt_word));
3452 010001,10,3.FMT,5.FT,5.FS,5.FD,000011:COP1:32,f::DIV.fmt
3453 "div.%s<FMT> f<FD>, f<FS>, f<FT>"
3463 unsigned32 instruction = instruction_0;
3464 int destreg = ((instruction >> 6) & 0x0000001F);
3465 int fs = ((instruction >> 11) & 0x0000001F);
3466 int ft = ((instruction >> 16) & 0x0000001F);
3467 int format = ((instruction >> 21) & 0x00000007);
3470 if ((format != fmt_single) && (format != fmt_double))
3471 SignalException(ReservedInstruction,instruction);
3473 StoreFPR(destreg,format,Divide(ValueFPR(fs,format),ValueFPR(ft,format),format));
3480 010001,00,X,01,5.RT,5.FS,00000000000:COP1Sa:64,f::DMxC1
3481 "dm%s<X>c1 r<RT>, f<FS>"
3485 check_u64 (SD_, instruction_0);
3488 if (SizeFGR() == 64)
3489 PENDING_FILL((FS + FGRIDX),GPR[RT]);
3490 else if ((FS & 0x1) == 0)
3492 PENDING_FILL(((FS + 1) + FGRIDX),VH4_8(GPR[RT]));
3493 PENDING_FILL((FS + FGRIDX),VL4_8(GPR[RT]));
3498 if (SizeFGR() == 64)
3499 PENDING_FILL(RT,FGR[FS]);
3500 else if ((FS & 0x1) == 0)
3501 PENDING_FILL(RT,(SET64HI(FGR[FS+1]) | FGR[FS]));
3504 if (STATE_VERBOSE_P(SD))
3506 "Warning: PC 0x%lx: semantic_DMxC1_COP1Sa 32-bit use of odd FPR number\n",
3508 PENDING_FILL(RT,SET64HI(0xDEADC0DE) | 0xBAD0BAD0);
3512 010001,00,X,01,5.RT,5.FS,00000000000:COP1Sb:64,f::DMxC1
3513 "dm%s<X>c1 r<RT>, f<FS>"
3521 check_u64 (SD_, instruction_0);
3524 if (SizeFGR() == 64)
3525 StoreFPR (FS, fmt_uninterpreted_64, GPR[RT]);
3526 else if ((FS & 0x1) == 0)
3527 StoreFPR (FS, fmt_uninterpreted_64, SET64HI (FGR[FS+1]) | FGR[FS]);
3531 if (SizeFGR() == 64)
3533 else if ((FS & 0x1) == 0)
3534 GPR[RT] = SET64HI (FGR[FS+1]) | FGR[FS];
3537 if (STATE_VERBOSE_P(SD))
3539 "Warning: PC 0x%lx: DMxC1 32-bit use of odd FPR number\n",
3541 GPR[RT] = SET64HI (0xDEADC0DE) | 0xBAD0BAD0;
3547 010001,10,3.FMT,00000,5.FS,5.FD,001011:COP1:64,f::FLOOR.L.fmt
3548 "floor.l.%s<FMT> f<FD>, f<FS>"
3556 unsigned32 instruction = instruction_0;
3557 int destreg = ((instruction >> 6) & 0x0000001F);
3558 int fs = ((instruction >> 11) & 0x0000001F);
3559 int format = ((instruction >> 21) & 0x00000007);
3562 if ((format != fmt_single) && (format != fmt_double))
3563 SignalException(ReservedInstruction,instruction);
3565 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_long));
3570 010001,10,3.FMT,00000,5.FS,5.FD,001111:COP1:32,f::FLOOR.W.fmt
3571 "floor.w.%s<FMT> f<FD>, f<FS>"
3580 unsigned32 instruction = instruction_0;
3581 int destreg = ((instruction >> 6) & 0x0000001F);
3582 int fs = ((instruction >> 11) & 0x0000001F);
3583 int format = ((instruction >> 21) & 0x00000007);
3586 if ((format != fmt_single) && (format != fmt_double))
3587 SignalException(ReservedInstruction,instruction);
3589 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOMINF,ValueFPR(fs,format),format,fmt_word));
3594 110101,5.BASE,5.FT,16.OFFSET:COP1:32,f::LDC1
3595 "ldc1 f<FT>, <OFFSET>(r<BASE>)"
3605 COP_LD (1, FT, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET)));
3609 010011,5.BASE,5.INDEX,5.0,5.FD,000001:COP1X:64,f::LDXC1
3610 "ldxc1 f<FD>, r<INDEX>(r<BASE>)"
3616 check_u64 (SD_, instruction_0);
3617 COP_LD (1, FD, do_load (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX]));
3622 110001,5.BASE,5.FT,16.OFFSET:COP1:32,f::LWC1
3623 "lwc1 f<FT>, <OFFSET>(r<BASE>)"
3634 COP_LW (1, FT, do_load (SD_, AccessLength_WORD, GPR[BASE], EXTEND16 (OFFSET)));
3638 010011,5.BASE,5.INDEX,5.0,5.FD,000000:COP1X:64,f::LWXC1
3639 "lwxc1 f<FD>, r<INDEX>(r<BASE>)"
3645 check_u64 (SD_, instruction_0);
3646 COP_LW (1, FD, do_load (SD_, AccessLength_WORD, GPR[BASE], GPR[INDEX]));
3652 // FIXME: Not correct for mips*
3654 010011,5.FR,5.FT,5.FS,5.FD,100,001:COP1X:32,f::MADD.D
3655 "madd.d f<FD>, f<FR>, f<FS>, f<FT>"
3660 unsigned32 instruction = instruction_0;
3661 int destreg = ((instruction >> 6) & 0x0000001F);
3662 int fs = ((instruction >> 11) & 0x0000001F);
3663 int ft = ((instruction >> 16) & 0x0000001F);
3664 int fr = ((instruction >> 21) & 0x0000001F);
3667 StoreFPR(destreg,fmt_double,Add(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
3672 010011,5.FR,5.FT,5.FS,5.FD,100,000:COP1X:32,f::MADD.S
3673 "madd.s f<FD>, f<FR>, f<FS>, f<FT>"
3678 unsigned32 instruction = instruction_0;
3679 int destreg = ((instruction >> 6) & 0x0000001F);
3680 int fs = ((instruction >> 11) & 0x0000001F);
3681 int ft = ((instruction >> 16) & 0x0000001F);
3682 int fr = ((instruction >> 21) & 0x0000001F);
3685 StoreFPR(destreg,fmt_single,Add(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
3692 010001,00,X,00,5.RT,5.FS,00000000000:COP1Sa:32,f::MxC1
3693 "m%s<X>c1 r<RT>, f<FS>"
3701 if (SizeFGR() == 64)
3703 if (STATE_VERBOSE_P(SD))
3705 "Warning: PC 0x%lx: MTC1 not DMTC1 with 64 bit regs\n",
3707 PENDING_FILL ((FS + FGRIDX), (SET64HI(0xDEADC0DE) | VL4_8(GPR[RT])));
3710 PENDING_FILL ((FS + FGRIDX), VL4_8(GPR[RT]));
3713 PENDING_FILL (RT, SIGNEXTEND(FGR[FS],32));
3715 010001,00,X,00,5.RT,5.FS,00000000000:COP1Sb:32,f::MxC1
3716 "m%s<X>c1 r<RT>, f<FS>"
3727 StoreFPR (FS, fmt_uninterpreted_32, VL4_8 (GPR[RT]));
3729 GPR[RT] = SIGNEXTEND(FGR[FS],32);
3733 010001,10,3.FMT,00000,5.FS,5.FD,000110:COP1:32,f::MOV.fmt
3734 "mov.%s<FMT> f<FD>, f<FS>"
3744 unsigned32 instruction = instruction_0;
3745 int destreg = ((instruction >> 6) & 0x0000001F);
3746 int fs = ((instruction >> 11) & 0x0000001F);
3747 int format = ((instruction >> 21) & 0x00000007);
3750 StoreFPR(destreg,format,ValueFPR(fs,format));
3757 000000,5.RS,3.CC,0,1.TF,5.RD,00000,000001:SPECIAL:32,f::MOVtf
3758 "mov%s<TF> r<RD>, r<RS>, <CC>"
3764 if (GETFCC(CC) == TF)
3771 010001,10,3.FMT,3.CC,0,1.TF,5.FS,5.FD,010001:COP1:32,f::MOVtf.fmt
3772 "mov%s<TF>.%s<FMT> f<FD>, f<FS>, <CC>"
3777 unsigned32 instruction = instruction_0;
3778 int format = ((instruction >> 21) & 0x00000007);
3781 if (GETFCC(CC) == TF)
3782 StoreFPR (FD, format, ValueFPR (FS, format));
3784 StoreFPR (FD, format, ValueFPR (FD, format));
3789 010001,10,3.FMT,5.RT,5.FS,5.FD,010011:COP1:32,f::MOVN.fmt
3790 "movn.%s<FMT> f<FD>, f<FS>, r<RT>"
3797 StoreFPR (FD, FMT, ValueFPR (FS, FMT));
3799 StoreFPR (FD, FMT, ValueFPR (FD, FMT));
3806 // MOVT.fmt see MOVtf.fmt
3810 010001,10,3.FMT,5.RT,5.FS,5.FD,010010:COP1:32,f::MOVZ.fmt
3811 "movz.%s<FMT> f<FD>, f<FS>, r<RT>"
3818 StoreFPR (FD, FMT, ValueFPR (FS, FMT));
3820 StoreFPR (FD, FMT, ValueFPR (FD, FMT));
3825 010011,5.FR,5.FT,5.FS,5.FD,101,001:COP1X:32,f::MSUB.D
3826 "msub.d f<FD>, f<FR>, f<FS>, f<FT>"
3831 unsigned32 instruction = instruction_0;
3832 int destreg = ((instruction >> 6) & 0x0000001F);
3833 int fs = ((instruction >> 11) & 0x0000001F);
3834 int ft = ((instruction >> 16) & 0x0000001F);
3835 int fr = ((instruction >> 21) & 0x0000001F);
3838 StoreFPR(destreg,fmt_double,Sub(Multiply(ValueFPR(fs,fmt_double),ValueFPR(ft,fmt_double),fmt_double),ValueFPR(fr,fmt_double),fmt_double));
3844 010011,5.FR,5.FT,5.FS,5.FD,101000:COP1X:32,f::MSUB.S
3845 "msub.s f<FD>, f<FR>, f<FS>, f<FT>"
3850 unsigned32 instruction = instruction_0;
3851 int destreg = ((instruction >> 6) & 0x0000001F);
3852 int fs = ((instruction >> 11) & 0x0000001F);
3853 int ft = ((instruction >> 16) & 0x0000001F);
3854 int fr = ((instruction >> 21) & 0x0000001F);
3857 StoreFPR(destreg,fmt_single,Sub(Multiply(ValueFPR(fs,fmt_single),ValueFPR(ft,fmt_single),fmt_single),ValueFPR(fr,fmt_single),fmt_single));
3865 010001,10,3.FMT,5.FT,5.FS,5.FD,000010:COP1:32,f::MUL.fmt
3866 "mul.%s<FMT> f<FD>, f<FS>, f<FT>"
3876 unsigned32 instruction = instruction_0;
3877 int destreg = ((instruction >> 6) & 0x0000001F);
3878 int fs = ((instruction >> 11) & 0x0000001F);
3879 int ft = ((instruction >> 16) & 0x0000001F);
3880 int format = ((instruction >> 21) & 0x00000007);
3883 if ((format != fmt_single) && (format != fmt_double))
3884 SignalException(ReservedInstruction,instruction);
3886 StoreFPR(destreg,format,Multiply(ValueFPR(fs,format),ValueFPR(ft,format),format));
3891 010001,10,3.FMT,00000,5.FS,5.FD,000111:COP1:32,f::NEG.fmt
3892 "neg.%s<FMT> f<FD>, f<FS>"
3902 unsigned32 instruction = instruction_0;
3903 int destreg = ((instruction >> 6) & 0x0000001F);
3904 int fs = ((instruction >> 11) & 0x0000001F);
3905 int format = ((instruction >> 21) & 0x00000007);
3908 if ((format != fmt_single) && (format != fmt_double))
3909 SignalException(ReservedInstruction,instruction);
3911 StoreFPR(destreg,format,Negate(ValueFPR(fs,format),format));
3917 010011,5.FR,5.FT,5.FS,5.FD,110001:COP1X:32,f::NMADD.D
3918 "nmadd.d f<FD>, f<FR>, f<FS>, f<FT>"
3923 unsigned32 instruction = instruction_0;
3924 int destreg = ((instruction >> 6) & 0x0000001F);
3925 int fs = ((instruction >> 11) & 0x0000001F);
3926 int ft = ((instruction >> 16) & 0x0000001F);
3927 int fr = ((instruction >> 21) & 0x0000001F);
3930 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));
3936 010011,5.FR,5.FT,5.FS,5.FD,110000:COP1X:32,f::NMADD.S
3937 "nmadd.s f<FD>, f<FR>, f<FS>, f<FT>"
3942 unsigned32 instruction = instruction_0;
3943 int destreg = ((instruction >> 6) & 0x0000001F);
3944 int fs = ((instruction >> 11) & 0x0000001F);
3945 int ft = ((instruction >> 16) & 0x0000001F);
3946 int fr = ((instruction >> 21) & 0x0000001F);
3949 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));
3955 010011,5.FR,5.FT,5.FS,5.FD,111001:COP1X:32,f::NMSUB.D
3956 "nmsub.d f<FD>, f<FR>, f<FS>, f<FT>"
3961 unsigned32 instruction = instruction_0;
3962 int destreg = ((instruction >> 6) & 0x0000001F);
3963 int fs = ((instruction >> 11) & 0x0000001F);
3964 int ft = ((instruction >> 16) & 0x0000001F);
3965 int fr = ((instruction >> 21) & 0x0000001F);
3968 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));
3974 010011,5.FR,5.FT,5.FS,5.FD,111000:COP1X:32,f::NMSUB.S
3975 "nmsub.s f<FD>, f<FR>, f<FS>, f<FT>"
3980 unsigned32 instruction = instruction_0;
3981 int destreg = ((instruction >> 6) & 0x0000001F);
3982 int fs = ((instruction >> 11) & 0x0000001F);
3983 int ft = ((instruction >> 16) & 0x0000001F);
3984 int fr = ((instruction >> 21) & 0x0000001F);
3987 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));
3992 010011,5.BASE,5.INDEX,5.HINT,00000,001111:COP1X:64::PREFX
3993 "prefx <HINT>, r<INDEX>(r<BASE>)"
3998 unsigned32 instruction = instruction_0;
3999 int fs = ((instruction >> 11) & 0x0000001F);
4000 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4001 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4003 address_word vaddr = ((unsigned64)op1 + (unsigned64)op2);
4006 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4007 Prefetch(uncached,paddr,vaddr,isDATA,fs);
4011 010001,10,3.FMT,00000,5.FS,5.FD,010101:COP1:32,f::RECIP.fmt
4012 "recip.%s<FMT> f<FD>, f<FS>"
4017 unsigned32 instruction = instruction_0;
4018 int destreg = ((instruction >> 6) & 0x0000001F);
4019 int fs = ((instruction >> 11) & 0x0000001F);
4020 int format = ((instruction >> 21) & 0x00000007);
4023 if ((format != fmt_single) && (format != fmt_double))
4024 SignalException(ReservedInstruction,instruction);
4026 StoreFPR(destreg,format,Recip(ValueFPR(fs,format),format));
4031 010001,10,3.FMT,00000,5.FS,5.FD,001000:COP1:64,f::ROUND.L.fmt
4032 "round.l.%s<FMT> f<FD>, f<FS>"
4040 unsigned32 instruction = instruction_0;
4041 int destreg = ((instruction >> 6) & 0x0000001F);
4042 int fs = ((instruction >> 11) & 0x0000001F);
4043 int format = ((instruction >> 21) & 0x00000007);
4046 if ((format != fmt_single) && (format != fmt_double))
4047 SignalException(ReservedInstruction,instruction);
4049 StoreFPR(destreg,fmt_long,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_long));
4054 010001,10,3.FMT,00000,5.FS,5.FD,001100:COP1:32,f::ROUND.W.fmt
4055 "round.w.%s<FMT> f<FD>, f<FS>"
4064 unsigned32 instruction = instruction_0;
4065 int destreg = ((instruction >> 6) & 0x0000001F);
4066 int fs = ((instruction >> 11) & 0x0000001F);
4067 int format = ((instruction >> 21) & 0x00000007);
4070 if ((format != fmt_single) && (format != fmt_double))
4071 SignalException(ReservedInstruction,instruction);
4073 StoreFPR(destreg,fmt_word,Convert(FP_RM_NEAREST,ValueFPR(fs,format),format,fmt_word));
4078 010001,10,3.FMT,00000,5.FS,5.FD,010110:COP1:32,f::RSQRT.fmt
4081 "rsqrt.%s<FMT> f<FD>, f<FS>"
4084 unsigned32 instruction = instruction_0;
4085 int destreg = ((instruction >> 6) & 0x0000001F);
4086 int fs = ((instruction >> 11) & 0x0000001F);
4087 int format = ((instruction >> 21) & 0x00000007);
4090 if ((format != fmt_single) && (format != fmt_double))
4091 SignalException(ReservedInstruction,instruction);
4093 StoreFPR(destreg,format,Recip(SquareRoot(ValueFPR(fs,format),format),format));
4098 111101,5.BASE,5.FT,16.OFFSET:COP1:32,f::SDC1
4099 "sdc1 f<FT>, <OFFSET>(r<BASE>)"
4109 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], EXTEND16 (OFFSET), COP_SD (1, FT));
4113 010011,5.BASE,5.INDEX,5.FS,00000001001:COP1X:64,f::SDXC1
4114 "sdxc1 f<FS>, r<INDEX>(r<BASE>)"
4120 check_u64 (SD_, instruction_0);
4121 do_store (SD_, AccessLength_DOUBLEWORD, GPR[BASE], GPR[INDEX], COP_SD (1, FS));
4125 010001,10,3.FMT,00000,5.FS,5.FD,000100:COP1:32,f::SQRT.fmt
4126 "sqrt.%s<FMT> f<FD>, f<FS>"
4135 unsigned32 instruction = instruction_0;
4136 int destreg = ((instruction >> 6) & 0x0000001F);
4137 int fs = ((instruction >> 11) & 0x0000001F);
4138 int format = ((instruction >> 21) & 0x00000007);
4141 if ((format != fmt_single) && (format != fmt_double))
4142 SignalException(ReservedInstruction,instruction);
4144 StoreFPR(destreg,format,(SquareRoot(ValueFPR(fs,format),format)));
4149 010001,10,3.FMT,5.FT,5.FS,5.FD,000001:COP1:32,f::SUB.fmt
4150 "sub.%s<FMT> f<FD>, f<FS>, f<FT>"
4160 unsigned32 instruction = instruction_0;
4161 int destreg = ((instruction >> 6) & 0x0000001F);
4162 int fs = ((instruction >> 11) & 0x0000001F);
4163 int ft = ((instruction >> 16) & 0x0000001F);
4164 int format = ((instruction >> 21) & 0x00000007);
4167 if ((format != fmt_single) && (format != fmt_double))
4168 SignalException(ReservedInstruction,instruction);
4170 StoreFPR(destreg,format,Sub(ValueFPR(fs,format),ValueFPR(ft,format),format));
4176 111001,5.BASE,5.FT,16.OFFSET:COP1:32,f::SWC1
4177 "swc1 f<FT>, <OFFSET>(r<BASE>)"
4187 unsigned32 instruction = instruction_0;
4188 signed_word offset = EXTEND16 (OFFSET);
4189 int destreg UNUSED = ((instruction >> 16) & 0x0000001F);
4190 signed_word op1 UNUSED = GPR[((instruction >> 21) & 0x0000001F)];
4193 address_word vaddr = ((uword64)op1 + offset);
4196 if ((vaddr & 3) != 0)
4198 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, AccessLength_WORD+1, vaddr, write_transfer, sim_core_unaligned_signal);
4202 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
4205 uword64 memval1 = 0;
4206 uword64 mask = (WITH_TARGET_WORD_BITSIZE == 64 ? 0x7 : 0x3);
4207 address_word reverseendian = (ReverseEndian ?(mask ^ AccessLength_WORD): 0);
4208 address_word bigendiancpu = (BigEndianCPU ?(mask ^ AccessLength_WORD): 0);
4210 paddr = ((paddr & ~mask) | ((paddr & mask) ^ reverseendian));
4211 byte = ((vaddr & mask) ^ bigendiancpu);
4212 memval = (((uword64)COP_SW(((instruction >> 26) & 0x3),destreg)) << (8 * byte));
4213 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
4220 010011,5.BASE,5.INDEX,5.FS,00000,001000:COP1X:32,f::SWXC1
4221 "swxc1 f<FS>, r<INDEX>(r<BASE>)"
4226 unsigned32 instruction = instruction_0;
4227 int fs = ((instruction >> 11) & 0x0000001F);
4228 signed_word op2 = GPR[((instruction >> 16) & 0x0000001F)];
4229 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4231 check_u64 (SD_, instruction_0);
4233 address_word vaddr = ((unsigned64)op1 + op2);
4236 if ((vaddr & 3) != 0)
4238 SIM_CORE_SIGNAL (SD, CPU, cia, read_map, 4, vaddr, write_transfer, sim_core_unaligned_signal);
4242 if (AddressTranslation(vaddr,isDATA,isSTORE,&paddr,&uncached,isTARGET,isREAL))
4244 unsigned64 memval = 0;
4245 unsigned64 memval1 = 0;
4246 unsigned64 mask = 0x7;
4248 paddr = ((paddr & ~mask) | ((paddr & mask) ^ (ReverseEndian << 2)));
4249 byte = ((vaddr & mask) ^ (BigEndianCPU << 2));
4250 memval = (((unsigned64)COP_SW(1,fs)) << (8 * byte));
4252 StoreMemory(uncached,AccessLength_WORD,memval,memval1,paddr,vaddr,isREAL);
4260 010001,10,3.FMT,00000,5.FS,5.FD,001001:COP1:64,f::TRUNC.L.fmt
4261 "trunc.l.%s<FMT> f<FD>, f<FS>"
4269 unsigned32 instruction = instruction_0;
4270 int destreg = ((instruction >> 6) & 0x0000001F);
4271 int fs = ((instruction >> 11) & 0x0000001F);
4272 int format = ((instruction >> 21) & 0x00000007);
4275 if ((format != fmt_single) && (format != fmt_double))
4276 SignalException(ReservedInstruction,instruction);
4278 StoreFPR(destreg,fmt_long,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_long));
4283 010001,10,3.FMT,00000,5.FS,5.FD,001101:COP1:32,f::TRUNC.W
4284 "trunc.w.%s<FMT> f<FD>, f<FS>"
4293 unsigned32 instruction = instruction_0;
4294 int destreg = ((instruction >> 6) & 0x0000001F);
4295 int fs = ((instruction >> 11) & 0x0000001F);
4296 int format = ((instruction >> 21) & 0x00000007);
4299 if ((format != fmt_single) && (format != fmt_double))
4300 SignalException(ReservedInstruction,instruction);
4302 StoreFPR(destreg,fmt_word,Convert(FP_RM_TOZERO,ValueFPR(fs,format),format,fmt_word));
4308 // MIPS Architecture:
4310 // System Control Instruction Set (COP0)
4314 010000,01000,00000,16.OFFSET:COP0:32::BC0F
4324 010000,01000,00000,16.OFFSET:COP0:32::BC0F
4326 // stub needed for eCos as tx39 hardware bug workaround
4333 010000,01000,00010,16.OFFSET:COP0:32::BC0FL
4344 010000,01000,00001,16.OFFSET:COP0:32::BC0T
4354 010000,01000,00011,16.OFFSET:COP0:32::BC0TL
4365 101111,5.BASE,5.OP,16.OFFSET:NORMAL:32::CACHE
4366 "cache <OP>, <OFFSET>(r<BASE>)"
4374 unsigned32 instruction = instruction_0;
4375 signed_word offset = SIGNEXTEND((signed_word)((instruction >> 0) & 0x0000FFFF),16);
4376 int hint = ((instruction >> 16) & 0x0000001F);
4377 signed_word op1 = GPR[((instruction >> 21) & 0x0000001F)];
4379 address_word vaddr = (op1 + offset);
4382 if (AddressTranslation(vaddr,isDATA,isLOAD,&paddr,&uncached,isTARGET,isREAL))
4383 CacheOp(hint,vaddr,paddr,instruction);
4388 010000,1,0000000000000000000,111001:COP0:32::DI
4399 010000,00001,5.RT,5.RD,00000000000:COP0:64::DMFC0
4400 "dmfc0 r<RT>, r<RD>"
4405 check_u64 (SD_, instruction_0);
4406 DecodeCoproc (instruction_0);
4410 010000,00101,5.RT,5.RD,00000000000:COP0:64::DMTC0
4411 "dmtc0 r<RT>, r<RD>"
4416 check_u64 (SD_, instruction_0);
4417 DecodeCoproc (instruction_0);
4421 010000,1,0000000000000000000,111000:COP0:32::EI
4432 010000,1,0000000000000000000,011000:COP0:32::ERET
4440 if (SR & status_ERL)
4442 /* Oops, not yet available */
4443 sim_io_printf (SD, "Warning: ERET when SR[ERL] set not supported");
4455 010000,00000,5.RT,5.RD,00000,6.REGX:COP0:32::MFC0
4456 "mfc0 r<RT>, r<RD> # <REGX>"
4466 TRACE_ALU_INPUT0 ();
4467 DecodeCoproc (instruction_0);
4468 TRACE_ALU_RESULT (GPR[RT]);
4471 010000,00100,5.RT,5.RD,00000,6.REGX:COP0:32::MTC0
4472 "mtc0 r<RT>, r<RD> # <REGX>"
4482 DecodeCoproc (instruction_0);
4486 010000,1,0000000000000000000,010000:COP0:32::RFE
4497 DecodeCoproc (instruction_0);
4501 0100,ZZ!0!1!3,5.COP_FUN0!8,5.COP_FUN1,16.COP_FUN2:NORMAL:32::COPz
4502 "cop<ZZ> <COP_FUN0><COP_FUN1><COP_FUN2>"
4511 DecodeCoproc (instruction_0);
4516 010000,1,0000000000000000000,001000:COP0:32::TLBP
4527 010000,1,0000000000000000000,000001:COP0:32::TLBR
4538 010000,1,0000000000000000000,000010:COP0:32::TLBWI
4549 010000,1,0000000000000000000,000110:COP0:32::TLBWR