Path: blob/master/libmupen64plus/mupen64plus-core/src/r4300/x86/gbc.c
2 views
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *1* Mupen64plus - gbc.c *2* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *3* Copyright (C) 2002 Hacktarux *4* *5* This program is free software; you can redistribute it and/or modify *6* it under the terms of the GNU General Public License as published by *7* the Free Software Foundation; either version 2 of the License, or *8* (at your option) any later version. *9* *10* This program is distributed in the hope that it will be useful, *11* but WITHOUT ANY WARRANTY; without even the implied warranty of *12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *13* GNU General Public License for more details. *14* *15* You should have received a copy of the GNU General Public License *16* along with this program; if not, write to the *17* Free Software Foundation, Inc., *18* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *19* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */2021#include <stdio.h>2223#include "assemble.h"24#include "interpret.h"2526#include "r4300/recomph.h"27#include "r4300/r4300.h"28#include "r4300/ops.h"2930static void genbc1f_test(void)31{32test_m32_imm32((unsigned int*)&FCR31, 0x800000);33jne_rj(12);34mov_m32_imm32((unsigned int*)(&branch_taken), 1); // 1035jmp_imm_short(10); // 236mov_m32_imm32((unsigned int*)(&branch_taken), 0); // 1037}3839void genbc1f(void)40{41#ifdef INTERPRET_BC1F42gencallinterp((unsigned int)cached_interpreter_table.BC1F, 1);43#else44if (((dst->addr & 0xFFF) == 0xFFC &&45(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)46{47gencallinterp((unsigned int)cached_interpreter_table.BC1F, 1);48return;49}5051gencheck_cop1_unusable();52genbc1f_test();53gendelayslot();54gentest();55#endif56}5758void genbc1f_out(void)59{60#ifdef INTERPRET_BC1F_OUT61gencallinterp((unsigned int)cached_interpreter_table.BC1F_OUT, 1);62#else63if (((dst->addr & 0xFFF) == 0xFFC &&64(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)65{66gencallinterp((unsigned int)cached_interpreter_table.BC1F_OUT, 1);67return;68}6970gencheck_cop1_unusable();71genbc1f_test();72gendelayslot();73gentest_out();74#endif75}7677void genbc1f_idle(void)78{79#ifdef INTERPRET_BC1F_IDLE80gencallinterp((unsigned int)cached_interpreter_table.BC1F_IDLE, 1);81#else82if (((dst->addr & 0xFFF) == 0xFFC &&83(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)84{85gencallinterp((unsigned int)cached_interpreter_table.BC1F_IDLE, 1);86return;87}8889gencheck_cop1_unusable();90genbc1f_test();91gentest_idle();92genbc1f();93#endif94}9596static void genbc1t_test(void)97{98test_m32_imm32((unsigned int*)&FCR31, 0x800000);99je_rj(12);100mov_m32_imm32((unsigned int*)(&branch_taken), 1); // 10101jmp_imm_short(10); // 2102mov_m32_imm32((unsigned int*)(&branch_taken), 0); // 10103}104105void genbc1t(void)106{107#ifdef INTERPRET_BC1T108gencallinterp((unsigned int)cached_interpreter_table.BC1T, 1);109#else110if (((dst->addr & 0xFFF) == 0xFFC &&111(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)112{113gencallinterp((unsigned int)cached_interpreter_table.BC1T, 1);114return;115}116117gencheck_cop1_unusable();118genbc1t_test();119gendelayslot();120gentest();121#endif122}123124void genbc1t_out(void)125{126#ifdef INTERPRET_BC1T_OUT127gencallinterp((unsigned int)cached_interpreter_table.BC1T_OUT, 1);128#else129if (((dst->addr & 0xFFF) == 0xFFC &&130(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)131{132gencallinterp((unsigned int)cached_interpreter_table.BC1T_OUT, 1);133return;134}135136gencheck_cop1_unusable();137genbc1t_test();138gendelayslot();139gentest_out();140#endif141}142143void genbc1t_idle(void)144{145#ifdef INTERPRET_BC1T_IDLE146gencallinterp((unsigned int)cached_interpreter_table.BC1T_IDLE, 1);147#else148if (((dst->addr & 0xFFF) == 0xFFC &&149(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)150{151gencallinterp((unsigned int)cached_interpreter_table.BC1T_IDLE, 1);152return;153}154155gencheck_cop1_unusable();156genbc1t_test();157gentest_idle();158genbc1t();159#endif160}161162void genbc1fl(void)163{164#ifdef INTERPRET_BC1FL165gencallinterp((unsigned int)cached_interpreter_table.BC1FL, 1);166#else167if (((dst->addr & 0xFFF) == 0xFFC &&168(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)169{170gencallinterp((unsigned int)cached_interpreter_table.BC1FL, 1);171return;172}173174gencheck_cop1_unusable();175genbc1f_test();176free_all_registers();177gentestl();178#endif179}180181void genbc1fl_out(void)182{183#ifdef INTERPRET_BC1FL_OUT184gencallinterp((unsigned int)cached_interpreter_table.BC1FL_OUT, 1);185#else186if (((dst->addr & 0xFFF) == 0xFFC &&187(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)188{189gencallinterp((unsigned int)cached_interpreter_table.BC1FL_OUT, 1);190return;191}192193gencheck_cop1_unusable();194genbc1f_test();195free_all_registers();196gentestl_out();197#endif198}199200void genbc1fl_idle(void)201{202#ifdef INTERPRET_BC1FL_IDLE203gencallinterp((unsigned int)cached_interpreter_table.BC1FL_IDLE, 1);204#else205if (((dst->addr & 0xFFF) == 0xFFC &&206(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)207{208gencallinterp((unsigned int)cached_interpreter_table.BC1FL_IDLE, 1);209return;210}211212gencheck_cop1_unusable();213genbc1f_test();214gentest_idle();215genbc1fl();216#endif217}218219void genbc1tl(void)220{221#ifdef INTERPRET_BC1TL222gencallinterp((unsigned int)cached_interpreter_table.BC1TL, 1);223#else224if (((dst->addr & 0xFFF) == 0xFFC &&225(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)226{227gencallinterp((unsigned int)cached_interpreter_table.BC1TL, 1);228return;229}230231gencheck_cop1_unusable();232genbc1t_test();233free_all_registers();234gentestl();235#endif236}237238void genbc1tl_out(void)239{240#ifdef INTERPRET_BC1TL_OUT241gencallinterp((unsigned int)cached_interpreter_table.BC1TL_OUT, 1);242#else243if (((dst->addr & 0xFFF) == 0xFFC &&244(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)245{246gencallinterp((unsigned int)cached_interpreter_table.BC1TL_OUT, 1);247return;248}249250gencheck_cop1_unusable();251genbc1t_test();252free_all_registers();253gentestl_out();254#endif255}256257void genbc1tl_idle(void)258{259#ifdef INTERPRET_BC1TL_IDLE260gencallinterp((unsigned int)cached_interpreter_table.BC1TL_IDLE, 1);261#else262if (((dst->addr & 0xFFF) == 0xFFC &&263(dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump)264{265gencallinterp((unsigned int)cached_interpreter_table.BC1TL_IDLE, 1);266return;267}268269gencheck_cop1_unusable();270genbc1t_test();271gentest_idle();272genbc1tl();273#endif274}275276277278