From b00484d130552c871cde1ccb60bfa794502444d0 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 12 Oct 2004 16:19:45 +0000 Subject: [PATCH] basic FXTRACT support Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2021 --- src/fpu/fpu.cpp | 5 ++++- src/fpu/fpu_instructions.h | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/fpu/fpu.cpp b/src/fpu/fpu.cpp index bce87f7e..0d5d154f 100644 --- a/src/fpu/fpu.cpp +++ b/src/fpu/fpu.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: fpu.cpp,v 1.22 2004-09-08 08:46:37 qbix79 Exp $ */ +/* $Id: fpu.cpp,v 1.23 2004-10-12 16:19:45 qbix79 Exp $ */ #include "dosbox.h" #if C_FPU @@ -354,6 +354,9 @@ void FPU_ESC1_Normal(Bitu rm) { case 0x03: /* FPATAN */ FPU_FPATAN(); break; + case 0x04: /* FXTRACT */ + FPU_FXTRACT(); + break; default: LOG(LOG_FPU,LOG_WARN)("ESC 1:Unhandled group %X subfunction %X",group,sub); break; diff --git a/src/fpu/fpu_instructions.h b/src/fpu/fpu_instructions.h index ff7dc091..a810cebd 100644 --- a/src/fpu/fpu_instructions.h +++ b/src/fpu/fpu_instructions.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: fpu_instructions.h,v 1.21 2004-09-09 18:36:50 qbix79 Exp $ */ +/* $Id: fpu_instructions.h,v 1.22 2004-10-12 16:19:45 qbix79 Exp $ */ static void FPU_FINIT(void) { @@ -392,3 +392,14 @@ static void FPU_FSTOR(PhysPt addr){ } } +static void FPU_FXTRACT(void) { + // function stores real bias in st and + // pushes the significant number onto the stack + // if double ever uses a different base please correct this function + + FPU_Reg test = fpu.regs[TOP]; + Bit64s exp80 = test.ll&LONGTYPE(0x7ff0000000000000); + Bit64s exp80final = (exp80>>52) - BIAS64; + Real64 mant = test.d / (pow(2.0,static_cast(exp80final))); + FPU_PUSH(mant); +}