aboutsummaryrefslogtreecommitdiff
path: root/op-i386.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-07-01 15:07:14 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-07-01 15:07:14 +0000
commitc39d5b78f62b0bdc10b9371c33e754ee1ba50f73 (patch)
treeb05c0c4467b85182e6b928eb69d6da691dfc8f43 /op-i386.c
parent4d40895f2c30354c48ad9181e366e8d738f9b4d7 (diff)
make FPU load exception safe
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@305 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'op-i386.c')
-rw-r--r--op-i386.c64
1 files changed, 50 insertions, 14 deletions
diff --git a/op-i386.c b/op-i386.c
index a7e057bddc..ee951b1da9 100644
--- a/op-i386.c
+++ b/op-i386.c
@@ -1406,28 +1406,40 @@ void OPPROTO op_fildll_FT0_A0(void)
void OPPROTO op_flds_ST0_A0(void)
{
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
#ifdef USE_FP_CONVERT
FP_CONVERT.i32 = ldl((void *)A0);
- ST0 = FP_CONVERT.f;
+ env->fpregs[new_fpstt] = FP_CONVERT.f;
#else
- ST0 = ldfl((void *)A0);
+ env->fpregs[new_fpstt] = ldfl((void *)A0);
#endif
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
void OPPROTO op_fldl_ST0_A0(void)
{
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
#ifdef USE_FP_CONVERT
FP_CONVERT.i64 = ldq((void *)A0);
- ST0 = FP_CONVERT.d;
+ env->fpregs[new_fpstt] = FP_CONVERT.d;
#else
- ST0 = ldfq((void *)A0);
+ env->fpregs[new_fpstt] = ldfq((void *)A0);
#endif
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
#ifdef USE_X86LDOUBLE
void OPPROTO op_fldt_ST0_A0(void)
{
- ST0 = *(long double *)A0;
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
+ env->fpregs[new_fpstt] = *(long double *)A0;
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
#else
void OPPROTO op_fldt_ST0_A0(void)
@@ -1441,17 +1453,29 @@ void OPPROTO op_fldt_ST0_A0(void)
void helper_fild_ST0_A0(void)
{
- ST0 = (CPU86_LDouble)ldsw((void *)A0);
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
+ env->fpregs[new_fpstt] = (CPU86_LDouble)ldsw((void *)A0);
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
void helper_fildl_ST0_A0(void)
{
- ST0 = (CPU86_LDouble)((int32_t)ldl((void *)A0));
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
+ env->fpregs[new_fpstt] = (CPU86_LDouble)((int32_t)ldl((void *)A0));
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
void helper_fildll_ST0_A0(void)
{
- ST0 = (CPU86_LDouble)((int64_t)ldq((void *)A0));
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
+ env->fpregs[new_fpstt] = (CPU86_LDouble)((int64_t)ldq((void *)A0));
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
void OPPROTO op_fild_ST0_A0(void)
@@ -1473,32 +1497,44 @@ void OPPROTO op_fildll_ST0_A0(void)
void OPPROTO op_fild_ST0_A0(void)
{
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
#ifdef USE_FP_CONVERT
FP_CONVERT.i32 = ldsw((void *)A0);
- ST0 = (CPU86_LDouble)FP_CONVERT.i32;
+ env->fpregs[new_fpstt] = (CPU86_LDouble)FP_CONVERT.i32;
#else
- ST0 = (CPU86_LDouble)ldsw((void *)A0);
+ env->fpregs[new_fpstt] = (CPU86_LDouble)ldsw((void *)A0);
#endif
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
void OPPROTO op_fildl_ST0_A0(void)
{
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
#ifdef USE_FP_CONVERT
FP_CONVERT.i32 = (int32_t) ldl((void *)A0);
- ST0 = (CPU86_LDouble)FP_CONVERT.i32;
+ env->fpregs[new_fpstt] = (CPU86_LDouble)FP_CONVERT.i32;
#else
- ST0 = (CPU86_LDouble)((int32_t)ldl((void *)A0));
+ env->fpregs[new_fpstt] = (CPU86_LDouble)((int32_t)ldl((void *)A0));
#endif
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
void OPPROTO op_fildll_ST0_A0(void)
{
+ int new_fpstt;
+ new_fpstt = (env->fpstt - 1) & 7;
#ifdef USE_FP_CONVERT
FP_CONVERT.i64 = (int64_t) ldq((void *)A0);
- ST0 = (CPU86_LDouble)FP_CONVERT.i64;
+ env->fpregs[new_fpstt] = (CPU86_LDouble)FP_CONVERT.i64;
#else
- ST0 = (CPU86_LDouble)((int64_t)ldq((void *)A0));
+ env->fpregs[new_fpstt] = (CPU86_LDouble)((int64_t)ldq((void *)A0));
#endif
+ env->fpstt = new_fpstt;
+ env->fptags[new_fpstt] = 0; /* validate stack entry */
}
#endif