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;
75 translate_event_queue((unsigned int) rrt & 0xFFFFFFFF);
76 Count = (unsigned int) rrt & 0xFFFFFFFF;
79 EntryHi = (unsigned int) rrt & 0xFFFFE0FF;
83 remove_event(COMPARE_INT);
84 add_interupt_event_count(COMPARE_INT, (unsigned int)rrt);
85 Compare = (unsigned int) rrt;
86 Cause = Cause & 0xFFFF7FFF; //Timer interupt is clear
89 if((rrt & 0x04000000) != (Status & 0x04000000))
91 shuffle_fpr_data(Status, (unsigned int) rrt);
92 set_fpr_pointers((unsigned int) rrt);
94 Status = (unsigned int) rrt;
98 interupt_unsafe_state = 1;
99 if (next_interupt <= Count) gen_interupt();
100 interupt_unsafe_state = 0;
106 DebugMessage(M64MSG_ERROR, "MTC0 instruction trying to write Cause register with non-0 value");
109 else Cause = (unsigned int) rrt;
112 EPC = (unsigned int) rrt;
117 Config = (unsigned int) rrt;
120 WatchLo = (unsigned int) rrt & 0xFFFFFFFF;
123 WatchHi = (unsigned int) rrt & 0xFFFFFFFF;
128 TagLo = (unsigned int) rrt & 0x0FFFFFC0;
134 DebugMessage(M64MSG_ERROR, "Unknown MTC0 write: %d", PC->f.r.nrd);