Core commit. Compile and run on the OpenPandora
[mupen64plus-pandora.git] / source / mupen64plus-core / src / r4300 / x86_64 / gbc.c
CommitLineData
451ab91e 1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus - gbc.c *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2007 Richard Goedeken (Richard42) *
5 * Copyright (C) 2002 Hacktarux *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
21 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22
23#include <stdio.h>
24
25#include "assemble.h"
26#include "interpret.h"
27
28#include "r4300/recomph.h"
29#include "r4300/r4300.h"
30#include "r4300/ops.h"
31
32static void genbc1f_test(void)
33{
34 test_m32rel_imm32((unsigned int*)&FCR31, 0x800000);
35 sete_m8rel((unsigned char *) &branch_taken);
36}
37
38void genbc1f(void)
39{
40#if defined(COUNT_INSTR)
41 inc_m32rel(&instr_count[100]);
42#endif
43#ifdef INTERPRET_BC1F
44 gencallinterp((unsigned long long)cached_interpreter_table.BC1F, 1);
45#else
46 if (((dst->addr & 0xFFF) == 0xFFC &&
47 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
48 {
49 gencallinterp((unsigned long long)cached_interpreter_table.BC1F, 1);
50 return;
51 }
52
53 gencheck_cop1_unusable();
54 genbc1f_test();
55 gendelayslot();
56 gentest();
57#endif
58}
59
60void genbc1f_out(void)
61{
62#if defined(COUNT_INSTR)
63 inc_m32rel(&instr_count[100]);
64#endif
65#ifdef INTERPRET_BC1F_OUT
66 gencallinterp((unsigned long long)cached_interpreter_table.BC1F_OUT, 1);
67#else
68 if (((dst->addr & 0xFFF) == 0xFFC &&
69 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
70 {
71 gencallinterp((unsigned long long)cached_interpreter_table.BC1F_OUT, 1);
72 return;
73 }
74
75 gencheck_cop1_unusable();
76 genbc1f_test();
77 gendelayslot();
78 gentest_out();
79#endif
80}
81
82void genbc1f_idle(void)
83{
84#ifdef INTERPRET_BC1F_IDLE
85 gencallinterp((unsigned long long)cached_interpreter_table.BC1F_IDLE, 1);
86#else
87 if (((dst->addr & 0xFFF) == 0xFFC &&
88 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
89 {
90 gencallinterp((unsigned long long)cached_interpreter_table.BC1F_IDLE, 1);
91 return;
92 }
93
94 gencheck_cop1_unusable();
95 genbc1f_test();
96 gentest_idle();
97 genbc1f();
98#endif
99}
100
101static void genbc1t_test(void)
102{
103 test_m32rel_imm32((unsigned int*)&FCR31, 0x800000);
104 setne_m8rel((unsigned char *) &branch_taken);
105}
106
107void genbc1t(void)
108{
109#if defined(COUNT_INSTR)
110 inc_m32rel(&instr_count[101]);
111#endif
112#ifdef INTERPRET_BC1T
113 gencallinterp((unsigned long long)cached_interpreter_table.BC1T, 1);
114#else
115 if (((dst->addr & 0xFFF) == 0xFFC &&
116 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
117 {
118 gencallinterp((unsigned long long)cached_interpreter_table.BC1T, 1);
119 return;
120 }
121
122 gencheck_cop1_unusable();
123 genbc1t_test();
124 gendelayslot();
125 gentest();
126#endif
127}
128
129void genbc1t_out(void)
130{
131#if defined(COUNT_INSTR)
132 inc_m32rel(&instr_count[101]);
133#endif
134#ifdef INTERPRET_BC1T_OUT
135 gencallinterp((unsigned long long)cached_interpreter_table.BC1T_OUT, 1);
136#else
137 if (((dst->addr & 0xFFF) == 0xFFC &&
138 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
139 {
140 gencallinterp((unsigned long long)cached_interpreter_table.BC1T_OUT, 1);
141 return;
142 }
143
144 gencheck_cop1_unusable();
145 genbc1t_test();
146 gendelayslot();
147 gentest_out();
148#endif
149}
150
151void genbc1t_idle(void)
152{
153#ifdef INTERPRET_BC1T_IDLE
154 gencallinterp((unsigned long long)cached_interpreter_table.BC1T_IDLE, 1);
155#else
156 if (((dst->addr & 0xFFF) == 0xFFC &&
157 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
158 {
159 gencallinterp((unsigned long long)cached_interpreter_table.BC1T_IDLE, 1);
160 return;
161 }
162
163 gencheck_cop1_unusable();
164 genbc1t_test();
165 gentest_idle();
166 genbc1t();
167#endif
168}
169
170void genbc1fl(void)
171{
172#if defined(COUNT_INSTR)
173 inc_m32rel(&instr_count[102]);
174#endif
175#ifdef INTERPRET_BC1FL
176 gencallinterp((unsigned long long)cached_interpreter_table.BC1FL, 1);
177#else
178 if (((dst->addr & 0xFFF) == 0xFFC &&
179 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
180 {
181 gencallinterp((unsigned long long)cached_interpreter_table.BC1FL, 1);
182 return;
183 }
184
185 gencheck_cop1_unusable();
186 genbc1f_test();
187 free_all_registers();
188 gentestl();
189#endif
190}
191
192void genbc1fl_out(void)
193{
194#if defined(COUNT_INSTR)
195 inc_m32rel(&instr_count[102]);
196#endif
197#ifdef INTERPRET_BC1FL_OUT
198 gencallinterp((unsigned long long)cached_interpreter_table.BC1FL_OUT, 1);
199#else
200 if (((dst->addr & 0xFFF) == 0xFFC &&
201 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
202 {
203 gencallinterp((unsigned long long)cached_interpreter_table.BC1FL_OUT, 1);
204 return;
205 }
206
207 gencheck_cop1_unusable();
208 genbc1f_test();
209 free_all_registers();
210 gentestl_out();
211#endif
212}
213
214void genbc1fl_idle(void)
215{
216#ifdef INTERPRET_BC1FL_IDLE
217 gencallinterp((unsigned long long)cached_interpreter_table.BC1FL_IDLE, 1);
218#else
219 if (((dst->addr & 0xFFF) == 0xFFC &&
220 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
221 {
222 gencallinterp((unsigned long long)cached_interpreter_table.BC1FL_IDLE, 1);
223 return;
224 }
225
226 gencheck_cop1_unusable();
227 genbc1f_test();
228 gentest_idle();
229 genbc1fl();
230#endif
231}
232
233void genbc1tl(void)
234{
235#if defined(COUNT_INSTR)
236 inc_m32rel(&instr_count[103]);
237#endif
238#ifdef INTERPRET_BC1TL
239 gencallinterp((unsigned long long)cached_interpreter_table.BC1TL, 1);
240#else
241 if (((dst->addr & 0xFFF) == 0xFFC &&
242 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
243 {
244 gencallinterp((unsigned long long)cached_interpreter_table.BC1TL, 1);
245 return;
246 }
247
248 gencheck_cop1_unusable();
249 genbc1t_test();
250 free_all_registers();
251 gentestl();
252#endif
253}
254
255void genbc1tl_out(void)
256{
257#if defined(COUNT_INSTR)
258 inc_m32rel(&instr_count[103]);
259#endif
260#ifdef INTERPRET_BC1TL_OUT
261 gencallinterp((unsigned long long)cached_interpreter_table.BC1TL_OUT, 1);
262#else
263 if (((dst->addr & 0xFFF) == 0xFFC &&
264 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
265 {
266 gencallinterp((unsigned long long)cached_interpreter_table.BC1TL_OUT, 1);
267 return;
268 }
269
270 gencheck_cop1_unusable();
271 genbc1t_test();
272 free_all_registers();
273 gentestl_out();
274#endif
275}
276
277void genbc1tl_idle(void)
278{
279#ifdef INTERPRET_BC1TL_IDLE
280 gencallinterp((unsigned long long)cached_interpreter_table.BC1TL_IDLE, 1);
281#else
282 if (((dst->addr & 0xFFF) == 0xFFC &&
283 (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)
284 {
285 gencallinterp((unsigned long long)cached_interpreter_table.BC1TL_IDLE, 1);
286 return;
287 }
288
289 gencheck_cop1_unusable();
290 genbc1t_test();
291 gentest_idle();
292 genbc1tl();
293#endif
294}
295