Path: blob/master/libmupen64plus/mupen64plus-core/src/r4300/x86/gcop1.c
2 views
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *1* Mupen64plus - gcop1.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/recomp.h"28#include "r4300/r4300.h"29#include "r4300/ops.h"30#include "r4300/macros.h"3132#include "memory/memory.h"3334void genmfc1(void)35{36#ifdef INTERPRET_MFC137gencallinterp((unsigned int)cached_interpreter_table.MFC1, 0);38#else39gencheck_cop1_unusable();40mov_eax_memoffs32((unsigned int*)(®_cop1_simple[dst->f.r.nrd]));41mov_reg32_preg32(EBX, EAX);42mov_m32_reg32((unsigned int*)dst->f.r.rt, EBX);43sar_reg32_imm8(EBX, 31);44mov_m32_reg32(((unsigned int*)dst->f.r.rt)+1, EBX);45#endif46}4748void gendmfc1(void)49{50#ifdef INTERPRET_DMFC151gencallinterp((unsigned int)cached_interpreter_table.DMFC1, 0);52#else53gencheck_cop1_unusable();54mov_eax_memoffs32((unsigned int*)(®_cop1_double[dst->f.r.nrd]));55mov_reg32_preg32(EBX, EAX);56mov_reg32_preg32pimm32(ECX, EAX, 4);57mov_m32_reg32((unsigned int*)dst->f.r.rt, EBX);58mov_m32_reg32(((unsigned int*)dst->f.r.rt)+1, ECX);59#endif60}6162void gencfc1(void)63{64#ifdef INTERPRET_CFC165gencallinterp((unsigned int)cached_interpreter_table.CFC1, 0);66#else67gencheck_cop1_unusable();68if(dst->f.r.nrd == 31) mov_eax_memoffs32((unsigned int*)&FCR31);69else mov_eax_memoffs32((unsigned int*)&FCR0);70mov_memoffs32_eax((unsigned int*)dst->f.r.rt);71sar_reg32_imm8(EAX, 31);72mov_memoffs32_eax(((unsigned int*)dst->f.r.rt)+1);73#endif74}7576void genmtc1(void)77{78#ifdef INTERPRET_MTC179gencallinterp((unsigned int)cached_interpreter_table.MTC1, 0);80#else81gencheck_cop1_unusable();82mov_eax_memoffs32((unsigned int*)dst->f.r.rt);83mov_reg32_m32(EBX, (unsigned int*)(®_cop1_simple[dst->f.r.nrd]));84mov_preg32_reg32(EBX, EAX);85#endif86}8788void gendmtc1(void)89{90#ifdef INTERPRET_DMTC191gencallinterp((unsigned int)cached_interpreter_table.DMTC1, 0);92#else93gencheck_cop1_unusable();94mov_eax_memoffs32((unsigned int*)dst->f.r.rt);95mov_reg32_m32(EBX, ((unsigned int*)dst->f.r.rt)+1);96mov_reg32_m32(EDX, (unsigned int*)(®_cop1_double[dst->f.r.nrd]));97mov_preg32_reg32(EDX, EAX);98mov_preg32pimm32_reg32(EDX, 4, EBX);99#endif100}101102void genctc1(void)103{104#ifdef INTERPRET_CTC1105gencallinterp((unsigned int)cached_interpreter_table.CTC1, 0);106#else107gencheck_cop1_unusable();108109if (dst->f.r.nrd != 31) return;110mov_eax_memoffs32((unsigned int*)dst->f.r.rt);111mov_memoffs32_eax((unsigned int*)&FCR31);112and_eax_imm32(3);113114cmp_eax_imm32(0);115jne_rj(12);116mov_m32_imm32((unsigned int*)&rounding_mode, 0x33F); // 10117jmp_imm_short(48); // 2118119cmp_eax_imm32(1); // 5120jne_rj(12); // 2121mov_m32_imm32((unsigned int*)&rounding_mode, 0xF3F); // 10122jmp_imm_short(29); // 2123124cmp_eax_imm32(2); // 5125jne_rj(12); // 2126mov_m32_imm32((unsigned int*)&rounding_mode, 0xB3F); // 10127jmp_imm_short(10); // 2128129mov_m32_imm32((unsigned int*)&rounding_mode, 0x73F); // 10130131fldcw_m16((unsigned short*)&rounding_mode);132#endif133}134135136137