From 1b31d7c8352d07811da995b3ad418498b95ac5bf Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 24 Sep 2003 19:46:36 +0000 Subject: [PATCH] changes fcom flags. applied changes from c2wood to the cvs (modified them to match) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1268 --- src/fpu/fpu_instructions.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/fpu/fpu_instructions.h b/src/fpu/fpu_instructions.h index 9ff1e54c..70df617a 100644 --- a/src/fpu/fpu_instructions.h +++ b/src/fpu/fpu_instructions.h @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: fpu_instructions.h,v 1.12 2003-09-24 19:46:36 qbix79 Exp $ */ static void FPU_FINIT(void) { @@ -156,16 +157,16 @@ static void FPU_FST(Bitu st, Bitu other){ static void FPU_FCOM(Bitu st, Bitu other){ if((fpu.tags[st] != TAG_Valid) || (fpu.tags[other] != TAG_Valid)){ - FPU_SET_C3(1);FPU_SET_C2(1);FPU_SET_C1(1);FPU_SET_C0(1);return; + FPU_SET_C3(1);FPU_SET_C1(1);FPU_SET_C0(1);return; } if(fpu.regs[st].d == fpu.regs[other].d){ - FPU_SET_C3(1);FPU_SET_C2(0);FPU_SET_C1(0);FPU_SET_C0(0);return; + FPU_SET_C3(1);FPU_SET_C1(0);FPU_SET_C0(0);return; } if(fpu.regs[st].d < fpu.regs[other].d){ - FPU_SET_C3(0);FPU_SET_C2(0);FPU_SET_C1(0);FPU_SET_C0(1);return; + FPU_SET_C3(0);FPU_SET_C1(0);FPU_SET_C0(1);return; } // st > other - FPU_SET_C3(0);FPU_SET_C2(0);FPU_SET_C1(0);FPU_SET_C0(0);return; + FPU_SET_C3(0);FPU_SET_C1(0);FPU_SET_C0(0);return; } static void FPU_FUCOM(Bitu st, Bitu other){ @@ -175,8 +176,10 @@ static void FPU_FUCOM(Bitu st, Bitu other){ static double FROUND(double in){ switch(fpu.round){ - case ROUND_Nearest: - return((in-floor(in)>=0.5)?(floor(in)+1):(floor(in))); + case ROUND_Nearest: + if (in-floor(in)>0.5) return (floor(in)+1); + else if (in-floor(in)<0.5) return (floor(in)); + else return (((static_cast(floor(in)))&1)!=0)?(floor(in)+1):(floor(in)); break; case ROUND_Down: return (floor(in)); @@ -197,9 +200,13 @@ static void FPU_FPREM(void){ Real64 valtop = fpu.regs[TOP].d; Real64 valdiv = fpu.regs[ST(1)].d; Real64 res = floor(valtop/valdiv); + Bit64s ressaved = static_cast(res); res=valtop - res*valdiv; fpu.regs[TOP].d = res; - FPU_SET_C3(0);FPU_SET_C2(0);FPU_SET_C1(0);FPU_SET_C0(0); + FPU_SET_C3(static_cast(ressaved&4)); + FPU_SET_C2(static_cast(ressaved&2)); + FPU_SET_C1(static_cast(ressaved&1)); + FPU_SET_C0(0); } static void FPU_FXAM(void){