- removed support for old-style syntax userbutton shortcuts
[bochs-mirror.git] / fpu / fpu_misc.cc
blobad24a55ae1f36cba6617dce2f3d4bedd1f699eda
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: fpu_misc.cc,v 1.13 2008/04/04 21:05:37 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2003 Stanislav Shwartsman
6 // Written by Stanislav Shwartsman [sshwarts at sourceforge net]
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 /////////////////////////////////////////////////////////////////////////
24 #define NEED_CPU_REG_SHORTCUTS 1
25 #include "bochs.h"
26 #include "cpu/cpu.h"
27 #define LOG_THIS BX_CPU_THIS_PTR
29 #if BX_SUPPORT_FPU
31 #include "softfloatx80.h"
33 /* D9 C8 */
34 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FXCH_STi(bxInstruction_c *i)
36 #if BX_SUPPORT_FPU
37 BX_CPU_THIS_PTR prepareFPU(i);
39 int st0_tag = BX_CPU_THIS_PTR the_i387.FPU_gettagi(0);
40 int sti_tag = BX_CPU_THIS_PTR the_i387.FPU_gettagi(i->rm());
42 floatx80 st0_reg = BX_READ_FPU_REG(0);
43 floatx80 sti_reg = BX_READ_FPU_REG(i->rm());
45 clear_C1();
47 if (st0_tag == FPU_Tag_Empty || sti_tag == FPU_Tag_Empty)
49 BX_CPU_THIS_PTR FPU_exception(FPU_EX_Stack_Underflow);
51 if(BX_CPU_THIS_PTR the_i387.is_IA_masked())
53 /* Masked response */
54 if (st0_tag == FPU_Tag_Empty)
56 st0_reg = floatx80_default_nan;
57 st0_tag = FPU_Tag_Special;
59 if (sti_tag == FPU_Tag_Empty)
61 sti_reg = floatx80_default_nan;
62 sti_tag = FPU_Tag_Special;
65 else return;
68 BX_WRITE_FPU_REGISTER_AND_TAG(st0_reg, st0_tag, i->rm());
69 BX_WRITE_FPU_REGISTER_AND_TAG(sti_reg, sti_tag, 0);
70 #else
71 BX_INFO(("FXCH_STi: required FPU, configure --enable-fpu"));
72 #endif
75 /* D9 E0 */
76 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCHS(bxInstruction_c *i)
78 #if BX_SUPPORT_FPU
79 BX_CPU_THIS_PTR prepareFPU(i);
81 int st0_tag = BX_CPU_THIS_PTR the_i387.FPU_gettagi(0);
82 if (st0_tag == FPU_Tag_Empty)
84 BX_CPU_THIS_PTR FPU_stack_underflow(0);
85 return;
88 clear_C1();
90 floatx80 st0_reg = BX_READ_FPU_REG(0);
91 BX_WRITE_FPU_REGISTER_AND_TAG(floatx80_chs(st0_reg), st0_tag, 0);
92 #else
93 BX_INFO(("FCHS: required FPU, configure --enable-fpu"));
94 #endif
97 /* D9 E1 */
98 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FABS(bxInstruction_c *i)
100 #if BX_SUPPORT_FPU
101 BX_CPU_THIS_PTR prepareFPU(i);
103 int st0_tag = BX_CPU_THIS_PTR the_i387.FPU_gettagi(0);
104 if (st0_tag == FPU_Tag_Empty)
106 BX_CPU_THIS_PTR FPU_stack_underflow(0);
107 return;
110 clear_C1();
112 floatx80 st0_reg = BX_READ_FPU_REG(0);
113 BX_WRITE_FPU_REGISTER_AND_TAG(floatx80_abs(st0_reg), st0_tag, 0);
114 #else
115 BX_INFO(("FABS: required FPU, configure --enable-fpu"));
116 #endif
119 /* D9 F6 */
120 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FDECSTP(bxInstruction_c *i)
122 #if BX_SUPPORT_FPU
123 BX_CPU_THIS_PTR prepareFPU(i);
125 clear_C1();
127 BX_CPU_THIS_PTR the_i387.tos = (BX_CPU_THIS_PTR the_i387.tos-1) & 7;
128 #else
129 BX_INFO(("FDECSTP: required FPU, configure --enable-fpu"));
130 #endif
133 /* D9 F7 */
134 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FINCSTP(bxInstruction_c *i)
136 #if BX_SUPPORT_FPU
137 BX_CPU_THIS_PTR prepareFPU(i);
139 clear_C1();
141 BX_CPU_THIS_PTR the_i387.tos = (BX_CPU_THIS_PTR the_i387.tos+1) & 7;
142 #else
143 BX_INFO(("FINCSTP: required FPU, configure --enable-fpu"));
144 #endif
147 /* DD C0 */
148 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FFREE_STi(bxInstruction_c *i)
150 #if BX_SUPPORT_FPU
151 BX_CPU_THIS_PTR prepareFPU(i);
152 BX_CPU_THIS_PTR the_i387.FPU_settagi(FPU_Tag_Empty, i->rm());
153 #else
154 BX_INFO(("FFREE_STi: required FPU, configure --enable-fpu"));
155 #endif
159 * Free the st(0) register and pop it from the FPU stack.
160 * "Undocumented" by Intel & AMD but mentioned in AMDs Athlon Docs.
163 /* DF C0 */
164 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FFREEP_STi(bxInstruction_c *i)
166 #if BX_SUPPORT_FPU
167 BX_CPU_THIS_PTR prepareFPU(i);
168 BX_CPU_THIS_PTR the_i387.FPU_settagi(FPU_Tag_Empty, i->rm());
169 BX_CPU_THIS_PTR the_i387.FPU_pop();
170 #else
171 BX_INFO(("FFREEP_STi: required FPU, configure --enable-fpu"));
172 #endif
175 #endif