1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus - interpreter_cop0.def *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2002 Hacktarux *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22 DECLARE_INSTRUCTION(MFC0)
27 DebugMessage(M64MSG_ERROR, "MFC0 instruction reading un-implemented Random register");
32 rrt32 = reg_cop0[PC->f.r.nrd];
38 DECLARE_INSTRUCTION(MTC0)
43 Index = (unsigned int) rrt & 0x8000003F;
44 if ((Index & 0x3F) > 31)
46 DebugMessage(M64MSG_ERROR, "MTC0 instruction writing Index register with TLB index > 31");
53 EntryLo0 = (unsigned int) rrt & 0x3FFFFFFF;
56 EntryLo1 = (unsigned int) rrt & 0x3FFFFFFF;
59 Context = ((unsigned int) rrt & 0xFF800000) | (Context & 0x007FFFF0);
62 PageMask = (unsigned int) rrt & 0x01FFE000;
65 Wired = (unsigned int) rrt;
72 interupt_unsafe_state = 1;
73 if (next_interupt <= Count) gen_interupt();
74 interupt_unsafe_state = 0;
76 translate_event_queue((unsigned int) rrt & 0xFFFFFFFF);
77 Count = (unsigned int) rrt & 0xFFFFFFFF;
81 EntryHi = (unsigned int) rrt & 0xFFFFE0FF;
85 remove_event(COMPARE_INT);
86 add_interupt_event_count(COMPARE_INT, (unsigned int)rrt);
87 Compare = (unsigned int) rrt;
88 Cause = Cause & 0xFFFF7FFF; //Timer interupt is clear
91 if((rrt & 0x04000000) != (Status & 0x04000000))
93 shuffle_fpr_data(Status, (unsigned int) rrt);
94 set_fpr_pointers((unsigned int) rrt);
96 Status = (unsigned int) rrt;
100 interupt_unsafe_state = 1;
101 if (next_interupt <= Count) gen_interupt();
102 interupt_unsafe_state = 0;
108 DebugMessage(M64MSG_ERROR, "MTC0 instruction trying to write Cause register with non-0 value");
111 else Cause = (unsigned int) rrt;
114 EPC = (unsigned int) rrt;
119 Config = (unsigned int) rrt;
122 WatchLo = (unsigned int) rrt & 0xFFFFFFFF;
125 WatchHi = (unsigned int) rrt & 0xFFFFFFFF;
130 TagLo = (unsigned int) rrt & 0x0FFFFFC0;
136 DebugMessage(M64MSG_ERROR, "Unknown MTC0 write: %d", PC->f.r.nrd);