1 /////////////////////////////////////////////////////////////////////////
2 // $Id: fpu_cmov.cc 14160 2021-02-21 09:25:33Z vruppert $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2012-2018 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.
12 //
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.
17 //
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 /////////////////////////////////////////////////////////////////////////
23
24 #define NEED_CPU_REG_SHORTCUTS 1
25 #include "bochs.h"
26 #include "cpu/cpu.h"
27 #define LOG_THIS BX_CPU_THIS_PTR
28
29 #if BX_SUPPORT_FPU
30
FCMOVB_ST0_STj(bxInstruction_c * i)31 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVB_ST0_STj(bxInstruction_c *i)
32 {
33 BX_CPU_THIS_PTR prepareFPU(i);
34 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
35
36 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
37 FPU_stack_underflow(i, 0);
38 }
39 else {
40 if (get_CF())
41 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
42 }
43
44 BX_NEXT_INSTR(i);
45 }
46
FCMOVBE_ST0_STj(bxInstruction_c * i)47 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVBE_ST0_STj(bxInstruction_c *i)
48 {
49 BX_CPU_THIS_PTR prepareFPU(i);
50 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
51
52 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
53 FPU_stack_underflow(i, 0);
54 }
55 else {
56 if (get_CF() || get_ZF())
57 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
58 }
59
60 BX_NEXT_INSTR(i);
61 }
62
FCMOVE_ST0_STj(bxInstruction_c * i)63 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVE_ST0_STj(bxInstruction_c *i)
64 {
65 BX_CPU_THIS_PTR prepareFPU(i);
66 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
67
68 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
69 FPU_stack_underflow(i, 0);
70 }
71 else {
72 if (get_ZF())
73 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
74 }
75
76 BX_NEXT_INSTR(i);
77 }
78
FCMOVNB_ST0_STj(bxInstruction_c * i)79 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVNB_ST0_STj(bxInstruction_c *i)
80 {
81 BX_CPU_THIS_PTR prepareFPU(i);
82 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
83
84 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
85 FPU_stack_underflow(i, 0);
86 }
87 else {
88 if (! get_CF())
89 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
90 }
91
92 BX_NEXT_INSTR(i);
93 }
94
FCMOVNBE_ST0_STj(bxInstruction_c * i)95 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVNBE_ST0_STj(bxInstruction_c *i)
96 {
97 BX_CPU_THIS_PTR prepareFPU(i);
98 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
99
100 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
101 FPU_stack_underflow(i, 0);
102 }
103 else {
104 if (! get_CF() && ! get_ZF())
105 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
106 }
107
108 BX_NEXT_INSTR(i);
109 }
110
FCMOVNE_ST0_STj(bxInstruction_c * i)111 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVNE_ST0_STj(bxInstruction_c *i)
112 {
113 BX_CPU_THIS_PTR prepareFPU(i);
114 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
115
116 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
117 FPU_stack_underflow(i, 0);
118 }
119 else {
120 if (! get_ZF())
121 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
122 }
123
124 BX_NEXT_INSTR(i);
125 }
126
FCMOVNU_ST0_STj(bxInstruction_c * i)127 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVNU_ST0_STj(bxInstruction_c *i)
128 {
129 BX_CPU_THIS_PTR prepareFPU(i);
130 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
131
132 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
133 FPU_stack_underflow(i, 0);
134 }
135 else {
136 if (! get_PF())
137 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
138 }
139
140 BX_NEXT_INSTR(i);
141 }
142
FCMOVU_ST0_STj(bxInstruction_c * i)143 void BX_CPP_AttrRegparmN(1) BX_CPU_C::FCMOVU_ST0_STj(bxInstruction_c *i)
144 {
145 BX_CPU_THIS_PTR prepareFPU(i);
146 BX_CPU_THIS_PTR FPU_update_last_instruction(i);
147
148 if (IS_TAG_EMPTY(0) || IS_TAG_EMPTY(i->src())) {
149 FPU_stack_underflow(i, 0);
150 }
151 else {
152 if (get_PF())
153 BX_WRITE_FPU_REG(BX_READ_FPU_REG(i->src()), 0);
154 }
155
156 BX_NEXT_INSTR(i);
157 }
158
159 #endif
160