| 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 2 | * Mupen64plus - gbc.c * |
| 3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
| 4 | * Copyright (C) 2002 Hacktarux * |
| 5 | * * |
| 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. * |
| 10 | * * |
| 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. * |
| 15 | * * |
| 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 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 21 | |
| 22 | #include <stdio.h> |
| 23 | |
| 24 | #include "assemble.h" |
| 25 | #include "interpret.h" |
| 26 | |
| 27 | #include "r4300/recomph.h" |
| 28 | #include "r4300/r4300.h" |
| 29 | #include "r4300/ops.h" |
| 30 | |
| 31 | static void genbc1f_test(void) |
| 32 | { |
| 33 | test_m32_imm32((unsigned int*)&FCR31, 0x800000); |
| 34 | jne_rj(12); |
| 35 | mov_m32_imm32((unsigned int*)(&branch_taken), 1); // 10 |
| 36 | jmp_imm_short(10); // 2 |
| 37 | mov_m32_imm32((unsigned int*)(&branch_taken), 0); // 10 |
| 38 | } |
| 39 | |
| 40 | void genbc1f(void) |
| 41 | { |
| 42 | #ifdef INTERPRET_BC1F |
| 43 | gencallinterp((unsigned int)cached_interpreter_table.BC1F, 1); |
| 44 | #else |
| 45 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 46 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 47 | { |
| 48 | gencallinterp((unsigned int)cached_interpreter_table.BC1F, 1); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | gencheck_cop1_unusable(); |
| 53 | genbc1f_test(); |
| 54 | gendelayslot(); |
| 55 | gentest(); |
| 56 | #endif |
| 57 | } |
| 58 | |
| 59 | void genbc1f_out(void) |
| 60 | { |
| 61 | #ifdef INTERPRET_BC1F_OUT |
| 62 | gencallinterp((unsigned int)cached_interpreter_table.BC1F_OUT, 1); |
| 63 | #else |
| 64 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 65 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 66 | { |
| 67 | gencallinterp((unsigned int)cached_interpreter_table.BC1F_OUT, 1); |
| 68 | return; |
| 69 | } |
| 70 | |
| 71 | gencheck_cop1_unusable(); |
| 72 | genbc1f_test(); |
| 73 | gendelayslot(); |
| 74 | gentest_out(); |
| 75 | #endif |
| 76 | } |
| 77 | |
| 78 | void genbc1f_idle(void) |
| 79 | { |
| 80 | #ifdef INTERPRET_BC1F_IDLE |
| 81 | gencallinterp((unsigned int)cached_interpreter_table.BC1F_IDLE, 1); |
| 82 | #else |
| 83 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 84 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 85 | { |
| 86 | gencallinterp((unsigned int)cached_interpreter_table.BC1F_IDLE, 1); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | gencheck_cop1_unusable(); |
| 91 | genbc1f_test(); |
| 92 | gentest_idle(); |
| 93 | genbc1f(); |
| 94 | #endif |
| 95 | } |
| 96 | |
| 97 | static void genbc1t_test(void) |
| 98 | { |
| 99 | test_m32_imm32((unsigned int*)&FCR31, 0x800000); |
| 100 | je_rj(12); |
| 101 | mov_m32_imm32((unsigned int*)(&branch_taken), 1); // 10 |
| 102 | jmp_imm_short(10); // 2 |
| 103 | mov_m32_imm32((unsigned int*)(&branch_taken), 0); // 10 |
| 104 | } |
| 105 | |
| 106 | void genbc1t(void) |
| 107 | { |
| 108 | #ifdef INTERPRET_BC1T |
| 109 | gencallinterp((unsigned int)cached_interpreter_table.BC1T, 1); |
| 110 | #else |
| 111 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 112 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 113 | { |
| 114 | gencallinterp((unsigned int)cached_interpreter_table.BC1T, 1); |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | gencheck_cop1_unusable(); |
| 119 | genbc1t_test(); |
| 120 | gendelayslot(); |
| 121 | gentest(); |
| 122 | #endif |
| 123 | } |
| 124 | |
| 125 | void genbc1t_out(void) |
| 126 | { |
| 127 | #ifdef INTERPRET_BC1T_OUT |
| 128 | gencallinterp((unsigned int)cached_interpreter_table.BC1T_OUT, 1); |
| 129 | #else |
| 130 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 131 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 132 | { |
| 133 | gencallinterp((unsigned int)cached_interpreter_table.BC1T_OUT, 1); |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | gencheck_cop1_unusable(); |
| 138 | genbc1t_test(); |
| 139 | gendelayslot(); |
| 140 | gentest_out(); |
| 141 | #endif |
| 142 | } |
| 143 | |
| 144 | void genbc1t_idle(void) |
| 145 | { |
| 146 | #ifdef INTERPRET_BC1T_IDLE |
| 147 | gencallinterp((unsigned int)cached_interpreter_table.BC1T_IDLE, 1); |
| 148 | #else |
| 149 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 150 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 151 | { |
| 152 | gencallinterp((unsigned int)cached_interpreter_table.BC1T_IDLE, 1); |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | gencheck_cop1_unusable(); |
| 157 | genbc1t_test(); |
| 158 | gentest_idle(); |
| 159 | genbc1t(); |
| 160 | #endif |
| 161 | } |
| 162 | |
| 163 | void genbc1fl(void) |
| 164 | { |
| 165 | #ifdef INTERPRET_BC1FL |
| 166 | gencallinterp((unsigned int)cached_interpreter_table.BC1FL, 1); |
| 167 | #else |
| 168 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 169 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 170 | { |
| 171 | gencallinterp((unsigned int)cached_interpreter_table.BC1FL, 1); |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | gencheck_cop1_unusable(); |
| 176 | genbc1f_test(); |
| 177 | free_all_registers(); |
| 178 | gentestl(); |
| 179 | #endif |
| 180 | } |
| 181 | |
| 182 | void genbc1fl_out(void) |
| 183 | { |
| 184 | #ifdef INTERPRET_BC1FL_OUT |
| 185 | gencallinterp((unsigned int)cached_interpreter_table.BC1FL_OUT, 1); |
| 186 | #else |
| 187 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 188 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 189 | { |
| 190 | gencallinterp((unsigned int)cached_interpreter_table.BC1FL_OUT, 1); |
| 191 | return; |
| 192 | } |
| 193 | |
| 194 | gencheck_cop1_unusable(); |
| 195 | genbc1f_test(); |
| 196 | free_all_registers(); |
| 197 | gentestl_out(); |
| 198 | #endif |
| 199 | } |
| 200 | |
| 201 | void genbc1fl_idle(void) |
| 202 | { |
| 203 | #ifdef INTERPRET_BC1FL_IDLE |
| 204 | gencallinterp((unsigned int)cached_interpreter_table.BC1FL_IDLE, 1); |
| 205 | #else |
| 206 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 207 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 208 | { |
| 209 | gencallinterp((unsigned int)cached_interpreter_table.BC1FL_IDLE, 1); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | gencheck_cop1_unusable(); |
| 214 | genbc1f_test(); |
| 215 | gentest_idle(); |
| 216 | genbc1fl(); |
| 217 | #endif |
| 218 | } |
| 219 | |
| 220 | void genbc1tl(void) |
| 221 | { |
| 222 | #ifdef INTERPRET_BC1TL |
| 223 | gencallinterp((unsigned int)cached_interpreter_table.BC1TL, 1); |
| 224 | #else |
| 225 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 226 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 227 | { |
| 228 | gencallinterp((unsigned int)cached_interpreter_table.BC1TL, 1); |
| 229 | return; |
| 230 | } |
| 231 | |
| 232 | gencheck_cop1_unusable(); |
| 233 | genbc1t_test(); |
| 234 | free_all_registers(); |
| 235 | gentestl(); |
| 236 | #endif |
| 237 | } |
| 238 | |
| 239 | void genbc1tl_out(void) |
| 240 | { |
| 241 | #ifdef INTERPRET_BC1TL_OUT |
| 242 | gencallinterp((unsigned int)cached_interpreter_table.BC1TL_OUT, 1); |
| 243 | #else |
| 244 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 245 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 246 | { |
| 247 | gencallinterp((unsigned int)cached_interpreter_table.BC1TL_OUT, 1); |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | gencheck_cop1_unusable(); |
| 252 | genbc1t_test(); |
| 253 | free_all_registers(); |
| 254 | gentestl_out(); |
| 255 | #endif |
| 256 | } |
| 257 | |
| 258 | void genbc1tl_idle(void) |
| 259 | { |
| 260 | #ifdef INTERPRET_BC1TL_IDLE |
| 261 | gencallinterp((unsigned int)cached_interpreter_table.BC1TL_IDLE, 1); |
| 262 | #else |
| 263 | if (((dst->addr & 0xFFF) == 0xFFC && |
| 264 | (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) |
| 265 | { |
| 266 | gencallinterp((unsigned int)cached_interpreter_table.BC1TL_IDLE, 1); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | gencheck_cop1_unusable(); |
| 271 | genbc1t_test(); |
| 272 | gentest_idle(); |
| 273 | genbc1tl(); |
| 274 | #endif |
| 275 | } |
| 276 | |