From 41ddb26c6f8a8fc8ee4c782f48c56bae55cd3f6c Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Thu, 1 Jul 2010 20:00:33 +0000 Subject: [PATCH] Fixed save/restore of x87 regs --- bochs/cpu/sse_move.cc | 9 ++++++--- bochs/cpu/xsave.cc | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bochs/cpu/sse_move.cc b/bochs/cpu/sse_move.cc index 0a37f7f8e..ac4111f81 100644 --- a/bochs/cpu/sse_move.cc +++ b/bochs/cpu/sse_move.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: sse_move.cc,v 1.117 2010-04-08 17:35:32 sshwarts Exp $ +// $Id: sse_move.cc,v 1.118 2010-07-01 20:00:33 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2003-2009 Stanislav Shwartsman @@ -238,7 +238,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::FXSAVE(bxInstruction_c *i) /* store i387 register file */ for(index=0; index < 8; index++) { - const floatx80 &fp = BX_FPU_REG(index); + const floatx80 &fp = BX_READ_FPU_REG(index); xmm.xmm64u(0) = fp.fraction; xmm.xmm64u(1) = 0; @@ -344,7 +344,10 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::FXRSTOR(bxInstruction_c *i) floatx80 reg; reg.fraction = read_virtual_qword(i->seg(), eaddr+index*16+32); reg.exp = read_virtual_word (i->seg(), eaddr+index*16+40); - BX_FPU_REG(index) = reg; + + // update tag only if it is not empty + BX_WRITE_FPU_REGISTER_AND_TAG(reg, + IS_TAG_EMPTY(index) ? FPU_Tag_Empty : FPU_tagof(reg), index); } BX_CPU_THIS_PTR the_i387.twd = unpack_FPU_TW(tag_byte); diff --git a/bochs/cpu/xsave.cc b/bochs/cpu/xsave.cc index 3f568b00f..b2abd3d9a 100755 --- a/bochs/cpu/xsave.cc +++ b/bochs/cpu/xsave.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: xsave.cc,v 1.26 2010-03-14 15:51:27 sshwarts Exp $ +// $Id: xsave.cc,v 1.27 2010-07-01 20:00:33 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (c) 2008-2009 Stanislav Shwartsman @@ -117,7 +117,7 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XSAVE(bxInstruction_c *i) /* store i387 register file */ for(index=0; index < 8; index++) { - const floatx80 &fp = BX_FPU_REG(index); + const floatx80 &fp = BX_READ_FPU_REG(index); xmm.xmm64u(0) = fp.fraction; xmm.xmm64u(1) = 0; @@ -241,7 +241,10 @@ void BX_CPP_AttrRegparmN(1) BX_CPU_C::XRSTOR(bxInstruction_c *i) floatx80 reg; reg.fraction = read_virtual_qword(i->seg(), eaddr+index*16+32); reg.exp = read_virtual_word (i->seg(), eaddr+index*16+40); - BX_FPU_REG(index) = reg; + + // update tag only if it is not empty + BX_WRITE_FPU_REGISTER_AND_TAG(reg, + IS_TAG_EMPTY(index) ? FPU_Tag_Empty : FPU_tagof(reg), index); } /* Restore floating point tag word - see desription for FXRSTOR instruction */