root / target-i386 / op.c @ afc7df11
History | View | Annotate | Download (41.3 kB)
1 | 2c0262af | bellard | /*
|
---|---|---|---|
2 | 2c0262af | bellard | * i386 micro operations
|
3 | 2c0262af | bellard | *
|
4 | 2c0262af | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 2c0262af | bellard | *
|
6 | 2c0262af | bellard | * This library is free software; you can redistribute it and/or
|
7 | 2c0262af | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 2c0262af | bellard | * License as published by the Free Software Foundation; either
|
9 | 2c0262af | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 2c0262af | bellard | *
|
11 | 2c0262af | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 2c0262af | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 2c0262af | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 2c0262af | bellard | * Lesser General Public License for more details.
|
15 | 2c0262af | bellard | *
|
16 | 2c0262af | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 2c0262af | bellard | * License along with this library; if not, write to the Free Software
|
18 | 2c0262af | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 2c0262af | bellard | */
|
20 | f68dd770 | bellard | |
21 | f68dd770 | bellard | #define ASM_SOFTMMU
|
22 | 2c0262af | bellard | #include "exec.h" |
23 | 2c0262af | bellard | |
24 | 2c0262af | bellard | /* n must be a constant to be efficient */
|
25 | 14ce26e7 | bellard | static inline target_long lshift(target_long x, int n) |
26 | 2c0262af | bellard | { |
27 | 2c0262af | bellard | if (n >= 0) |
28 | 2c0262af | bellard | return x << n;
|
29 | 2c0262af | bellard | else
|
30 | 2c0262af | bellard | return x >> (-n);
|
31 | 2c0262af | bellard | } |
32 | 2c0262af | bellard | |
33 | 2c0262af | bellard | /* we define the various pieces of code used by the JIT */
|
34 | 2c0262af | bellard | |
35 | 2c0262af | bellard | #define REG EAX
|
36 | 2c0262af | bellard | #define REGNAME _EAX
|
37 | 2c0262af | bellard | #include "opreg_template.h" |
38 | 2c0262af | bellard | #undef REG
|
39 | 2c0262af | bellard | #undef REGNAME
|
40 | 2c0262af | bellard | |
41 | 2c0262af | bellard | #define REG ECX
|
42 | 2c0262af | bellard | #define REGNAME _ECX
|
43 | 2c0262af | bellard | #include "opreg_template.h" |
44 | 2c0262af | bellard | #undef REG
|
45 | 2c0262af | bellard | #undef REGNAME
|
46 | 2c0262af | bellard | |
47 | 2c0262af | bellard | #define REG EDX
|
48 | 2c0262af | bellard | #define REGNAME _EDX
|
49 | 2c0262af | bellard | #include "opreg_template.h" |
50 | 2c0262af | bellard | #undef REG
|
51 | 2c0262af | bellard | #undef REGNAME
|
52 | 2c0262af | bellard | |
53 | 2c0262af | bellard | #define REG EBX
|
54 | 2c0262af | bellard | #define REGNAME _EBX
|
55 | 2c0262af | bellard | #include "opreg_template.h" |
56 | 2c0262af | bellard | #undef REG
|
57 | 2c0262af | bellard | #undef REGNAME
|
58 | 2c0262af | bellard | |
59 | 2c0262af | bellard | #define REG ESP
|
60 | 2c0262af | bellard | #define REGNAME _ESP
|
61 | 2c0262af | bellard | #include "opreg_template.h" |
62 | 2c0262af | bellard | #undef REG
|
63 | 2c0262af | bellard | #undef REGNAME
|
64 | 2c0262af | bellard | |
65 | 2c0262af | bellard | #define REG EBP
|
66 | 2c0262af | bellard | #define REGNAME _EBP
|
67 | 2c0262af | bellard | #include "opreg_template.h" |
68 | 2c0262af | bellard | #undef REG
|
69 | 2c0262af | bellard | #undef REGNAME
|
70 | 2c0262af | bellard | |
71 | 2c0262af | bellard | #define REG ESI
|
72 | 2c0262af | bellard | #define REGNAME _ESI
|
73 | 2c0262af | bellard | #include "opreg_template.h" |
74 | 2c0262af | bellard | #undef REG
|
75 | 2c0262af | bellard | #undef REGNAME
|
76 | 2c0262af | bellard | |
77 | 2c0262af | bellard | #define REG EDI
|
78 | 2c0262af | bellard | #define REGNAME _EDI
|
79 | 2c0262af | bellard | #include "opreg_template.h" |
80 | 2c0262af | bellard | #undef REG
|
81 | 2c0262af | bellard | #undef REGNAME
|
82 | 2c0262af | bellard | |
83 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
84 | 14ce26e7 | bellard | |
85 | 14ce26e7 | bellard | #define REG (env->regs[8]) |
86 | 14ce26e7 | bellard | #define REGNAME _R8
|
87 | 14ce26e7 | bellard | #include "opreg_template.h" |
88 | 14ce26e7 | bellard | #undef REG
|
89 | 14ce26e7 | bellard | #undef REGNAME
|
90 | 14ce26e7 | bellard | |
91 | 14ce26e7 | bellard | #define REG (env->regs[9]) |
92 | 14ce26e7 | bellard | #define REGNAME _R9
|
93 | 14ce26e7 | bellard | #include "opreg_template.h" |
94 | 14ce26e7 | bellard | #undef REG
|
95 | 14ce26e7 | bellard | #undef REGNAME
|
96 | 14ce26e7 | bellard | |
97 | 14ce26e7 | bellard | #define REG (env->regs[10]) |
98 | 14ce26e7 | bellard | #define REGNAME _R10
|
99 | 14ce26e7 | bellard | #include "opreg_template.h" |
100 | 14ce26e7 | bellard | #undef REG
|
101 | 14ce26e7 | bellard | #undef REGNAME
|
102 | 14ce26e7 | bellard | |
103 | 14ce26e7 | bellard | #define REG (env->regs[11]) |
104 | 14ce26e7 | bellard | #define REGNAME _R11
|
105 | 14ce26e7 | bellard | #include "opreg_template.h" |
106 | 14ce26e7 | bellard | #undef REG
|
107 | 14ce26e7 | bellard | #undef REGNAME
|
108 | 14ce26e7 | bellard | |
109 | 14ce26e7 | bellard | #define REG (env->regs[12]) |
110 | 14ce26e7 | bellard | #define REGNAME _R12
|
111 | 14ce26e7 | bellard | #include "opreg_template.h" |
112 | 14ce26e7 | bellard | #undef REG
|
113 | 14ce26e7 | bellard | #undef REGNAME
|
114 | 14ce26e7 | bellard | |
115 | 14ce26e7 | bellard | #define REG (env->regs[13]) |
116 | 14ce26e7 | bellard | #define REGNAME _R13
|
117 | 14ce26e7 | bellard | #include "opreg_template.h" |
118 | 14ce26e7 | bellard | #undef REG
|
119 | 14ce26e7 | bellard | #undef REGNAME
|
120 | 14ce26e7 | bellard | |
121 | 14ce26e7 | bellard | #define REG (env->regs[14]) |
122 | 14ce26e7 | bellard | #define REGNAME _R14
|
123 | 14ce26e7 | bellard | #include "opreg_template.h" |
124 | 14ce26e7 | bellard | #undef REG
|
125 | 14ce26e7 | bellard | #undef REGNAME
|
126 | 14ce26e7 | bellard | |
127 | 14ce26e7 | bellard | #define REG (env->regs[15]) |
128 | 14ce26e7 | bellard | #define REGNAME _R15
|
129 | 14ce26e7 | bellard | #include "opreg_template.h" |
130 | 14ce26e7 | bellard | #undef REG
|
131 | 14ce26e7 | bellard | #undef REGNAME
|
132 | 14ce26e7 | bellard | |
133 | 14ce26e7 | bellard | #endif
|
134 | 14ce26e7 | bellard | |
135 | 2c0262af | bellard | /* operations with flags */
|
136 | 2c0262af | bellard | |
137 | 2c0262af | bellard | /* update flags with T0 and T1 (add/sub case) */
|
138 | 2c0262af | bellard | void OPPROTO op_update2_cc(void) |
139 | 2c0262af | bellard | { |
140 | 2c0262af | bellard | CC_SRC = T1; |
141 | 2c0262af | bellard | CC_DST = T0; |
142 | 2c0262af | bellard | } |
143 | 2c0262af | bellard | |
144 | 2c0262af | bellard | /* update flags with T0 (logic operation case) */
|
145 | 2c0262af | bellard | void OPPROTO op_update1_cc(void) |
146 | 2c0262af | bellard | { |
147 | 2c0262af | bellard | CC_DST = T0; |
148 | 2c0262af | bellard | } |
149 | 2c0262af | bellard | |
150 | 2c0262af | bellard | void OPPROTO op_update_neg_cc(void) |
151 | 2c0262af | bellard | { |
152 | 2c0262af | bellard | CC_SRC = -T0; |
153 | 2c0262af | bellard | CC_DST = T0; |
154 | 2c0262af | bellard | } |
155 | 2c0262af | bellard | |
156 | 2c0262af | bellard | void OPPROTO op_cmpl_T0_T1_cc(void) |
157 | 2c0262af | bellard | { |
158 | 2c0262af | bellard | CC_SRC = T1; |
159 | 2c0262af | bellard | CC_DST = T0 - T1; |
160 | 2c0262af | bellard | } |
161 | 2c0262af | bellard | |
162 | 2c0262af | bellard | void OPPROTO op_update_inc_cc(void) |
163 | 2c0262af | bellard | { |
164 | 2c0262af | bellard | CC_SRC = cc_table[CC_OP].compute_c(); |
165 | 2c0262af | bellard | CC_DST = T0; |
166 | 2c0262af | bellard | } |
167 | 2c0262af | bellard | |
168 | 2c0262af | bellard | void OPPROTO op_testl_T0_T1_cc(void) |
169 | 2c0262af | bellard | { |
170 | 2c0262af | bellard | CC_DST = T0 & T1; |
171 | 2c0262af | bellard | } |
172 | 2c0262af | bellard | |
173 | 2c0262af | bellard | /* operations without flags */
|
174 | 2c0262af | bellard | |
175 | 2c0262af | bellard | void OPPROTO op_addl_T0_T1(void) |
176 | 2c0262af | bellard | { |
177 | 2c0262af | bellard | T0 += T1; |
178 | 2c0262af | bellard | } |
179 | 2c0262af | bellard | |
180 | 2c0262af | bellard | void OPPROTO op_orl_T0_T1(void) |
181 | 2c0262af | bellard | { |
182 | 2c0262af | bellard | T0 |= T1; |
183 | 2c0262af | bellard | } |
184 | 2c0262af | bellard | |
185 | 2c0262af | bellard | void OPPROTO op_andl_T0_T1(void) |
186 | 2c0262af | bellard | { |
187 | 2c0262af | bellard | T0 &= T1; |
188 | 2c0262af | bellard | } |
189 | 2c0262af | bellard | |
190 | 2c0262af | bellard | void OPPROTO op_subl_T0_T1(void) |
191 | 2c0262af | bellard | { |
192 | 2c0262af | bellard | T0 -= T1; |
193 | 2c0262af | bellard | } |
194 | 2c0262af | bellard | |
195 | 2c0262af | bellard | void OPPROTO op_xorl_T0_T1(void) |
196 | 2c0262af | bellard | { |
197 | 2c0262af | bellard | T0 ^= T1; |
198 | 2c0262af | bellard | } |
199 | 2c0262af | bellard | |
200 | 2c0262af | bellard | void OPPROTO op_negl_T0(void) |
201 | 2c0262af | bellard | { |
202 | 2c0262af | bellard | T0 = -T0; |
203 | 2c0262af | bellard | } |
204 | 2c0262af | bellard | |
205 | 2c0262af | bellard | void OPPROTO op_incl_T0(void) |
206 | 2c0262af | bellard | { |
207 | 2c0262af | bellard | T0++; |
208 | 2c0262af | bellard | } |
209 | 2c0262af | bellard | |
210 | 2c0262af | bellard | void OPPROTO op_decl_T0(void) |
211 | 2c0262af | bellard | { |
212 | 2c0262af | bellard | T0--; |
213 | 2c0262af | bellard | } |
214 | 2c0262af | bellard | |
215 | 2c0262af | bellard | void OPPROTO op_notl_T0(void) |
216 | 2c0262af | bellard | { |
217 | 2c0262af | bellard | T0 = ~T0; |
218 | 2c0262af | bellard | } |
219 | 2c0262af | bellard | |
220 | 2c0262af | bellard | void OPPROTO op_bswapl_T0(void) |
221 | 2c0262af | bellard | { |
222 | 2c0262af | bellard | T0 = bswap32(T0); |
223 | 2c0262af | bellard | } |
224 | 2c0262af | bellard | |
225 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
226 | 14ce26e7 | bellard | void OPPROTO op_bswapq_T0(void) |
227 | 14ce26e7 | bellard | { |
228 | 14ce26e7 | bellard | T0 = bswap64(T0); |
229 | 14ce26e7 | bellard | } |
230 | 14ce26e7 | bellard | #endif
|
231 | 14ce26e7 | bellard | |
232 | 2c0262af | bellard | /* multiply/divide */
|
233 | d36cd60e | bellard | |
234 | d36cd60e | bellard | /* XXX: add eflags optimizations */
|
235 | d36cd60e | bellard | /* XXX: add non P4 style flags */
|
236 | d36cd60e | bellard | |
237 | 2c0262af | bellard | void OPPROTO op_mulb_AL_T0(void) |
238 | 2c0262af | bellard | { |
239 | 2c0262af | bellard | unsigned int res; |
240 | 2c0262af | bellard | res = (uint8_t)EAX * (uint8_t)T0; |
241 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | res;
|
242 | d36cd60e | bellard | CC_DST = res; |
243 | 2c0262af | bellard | CC_SRC = (res & 0xff00);
|
244 | 2c0262af | bellard | } |
245 | 2c0262af | bellard | |
246 | 2c0262af | bellard | void OPPROTO op_imulb_AL_T0(void) |
247 | 2c0262af | bellard | { |
248 | 2c0262af | bellard | int res;
|
249 | 2c0262af | bellard | res = (int8_t)EAX * (int8_t)T0; |
250 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | (res & 0xffff); |
251 | d36cd60e | bellard | CC_DST = res; |
252 | 2c0262af | bellard | CC_SRC = (res != (int8_t)res); |
253 | 2c0262af | bellard | } |
254 | 2c0262af | bellard | |
255 | 2c0262af | bellard | void OPPROTO op_mulw_AX_T0(void) |
256 | 2c0262af | bellard | { |
257 | 2c0262af | bellard | unsigned int res; |
258 | 2c0262af | bellard | res = (uint16_t)EAX * (uint16_t)T0; |
259 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | (res & 0xffff); |
260 | 14ce26e7 | bellard | EDX = (EDX & ~0xffff) | ((res >> 16) & 0xffff); |
261 | d36cd60e | bellard | CC_DST = res; |
262 | 2c0262af | bellard | CC_SRC = res >> 16;
|
263 | 2c0262af | bellard | } |
264 | 2c0262af | bellard | |
265 | 2c0262af | bellard | void OPPROTO op_imulw_AX_T0(void) |
266 | 2c0262af | bellard | { |
267 | 2c0262af | bellard | int res;
|
268 | 2c0262af | bellard | res = (int16_t)EAX * (int16_t)T0; |
269 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | (res & 0xffff); |
270 | 14ce26e7 | bellard | EDX = (EDX & ~0xffff) | ((res >> 16) & 0xffff); |
271 | d36cd60e | bellard | CC_DST = res; |
272 | 2c0262af | bellard | CC_SRC = (res != (int16_t)res); |
273 | 2c0262af | bellard | } |
274 | 2c0262af | bellard | |
275 | 2c0262af | bellard | void OPPROTO op_mull_EAX_T0(void) |
276 | 2c0262af | bellard | { |
277 | 2c0262af | bellard | uint64_t res; |
278 | 2c0262af | bellard | res = (uint64_t)((uint32_t)EAX) * (uint64_t)((uint32_t)T0); |
279 | 14ce26e7 | bellard | EAX = (uint32_t)res; |
280 | 14ce26e7 | bellard | EDX = (uint32_t)(res >> 32);
|
281 | 14ce26e7 | bellard | CC_DST = (uint32_t)res; |
282 | 14ce26e7 | bellard | CC_SRC = (uint32_t)(res >> 32);
|
283 | 2c0262af | bellard | } |
284 | 2c0262af | bellard | |
285 | 2c0262af | bellard | void OPPROTO op_imull_EAX_T0(void) |
286 | 2c0262af | bellard | { |
287 | 2c0262af | bellard | int64_t res; |
288 | 2c0262af | bellard | res = (int64_t)((int32_t)EAX) * (int64_t)((int32_t)T0); |
289 | 2c0262af | bellard | EAX = res; |
290 | 2c0262af | bellard | EDX = res >> 32;
|
291 | d36cd60e | bellard | CC_DST = res; |
292 | 2c0262af | bellard | CC_SRC = (res != (int32_t)res); |
293 | 2c0262af | bellard | } |
294 | 2c0262af | bellard | |
295 | 2c0262af | bellard | void OPPROTO op_imulw_T0_T1(void) |
296 | 2c0262af | bellard | { |
297 | 2c0262af | bellard | int res;
|
298 | 2c0262af | bellard | res = (int16_t)T0 * (int16_t)T1; |
299 | 2c0262af | bellard | T0 = res; |
300 | d36cd60e | bellard | CC_DST = res; |
301 | 2c0262af | bellard | CC_SRC = (res != (int16_t)res); |
302 | 2c0262af | bellard | } |
303 | 2c0262af | bellard | |
304 | 2c0262af | bellard | void OPPROTO op_imull_T0_T1(void) |
305 | 2c0262af | bellard | { |
306 | 2c0262af | bellard | int64_t res; |
307 | 2c0262af | bellard | res = (int64_t)((int32_t)T0) * (int64_t)((int32_t)T1); |
308 | 2c0262af | bellard | T0 = res; |
309 | d36cd60e | bellard | CC_DST = res; |
310 | 2c0262af | bellard | CC_SRC = (res != (int32_t)res); |
311 | 2c0262af | bellard | } |
312 | 2c0262af | bellard | |
313 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
314 | 14ce26e7 | bellard | void OPPROTO op_mulq_EAX_T0(void) |
315 | 14ce26e7 | bellard | { |
316 | 14ce26e7 | bellard | helper_mulq_EAX_T0(); |
317 | 14ce26e7 | bellard | } |
318 | 14ce26e7 | bellard | |
319 | 14ce26e7 | bellard | void OPPROTO op_imulq_EAX_T0(void) |
320 | 14ce26e7 | bellard | { |
321 | 14ce26e7 | bellard | helper_imulq_EAX_T0(); |
322 | 14ce26e7 | bellard | } |
323 | 14ce26e7 | bellard | |
324 | 14ce26e7 | bellard | void OPPROTO op_imulq_T0_T1(void) |
325 | 14ce26e7 | bellard | { |
326 | 14ce26e7 | bellard | helper_imulq_T0_T1(); |
327 | 14ce26e7 | bellard | } |
328 | 14ce26e7 | bellard | #endif
|
329 | 14ce26e7 | bellard | |
330 | 2c0262af | bellard | /* division, flags are undefined */
|
331 | 2c0262af | bellard | /* XXX: add exceptions for overflow */
|
332 | 2c0262af | bellard | |
333 | 2c0262af | bellard | void OPPROTO op_divb_AL_T0(void) |
334 | 2c0262af | bellard | { |
335 | 2c0262af | bellard | unsigned int num, den, q, r; |
336 | 2c0262af | bellard | |
337 | 2c0262af | bellard | num = (EAX & 0xffff);
|
338 | 2c0262af | bellard | den = (T0 & 0xff);
|
339 | 2c0262af | bellard | if (den == 0) { |
340 | 2c0262af | bellard | raise_exception(EXCP00_DIVZ); |
341 | 2c0262af | bellard | } |
342 | 2c0262af | bellard | q = (num / den) & 0xff;
|
343 | 2c0262af | bellard | r = (num % den) & 0xff;
|
344 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | (r << 8) | q; |
345 | 2c0262af | bellard | } |
346 | 2c0262af | bellard | |
347 | 2c0262af | bellard | void OPPROTO op_idivb_AL_T0(void) |
348 | 2c0262af | bellard | { |
349 | 2c0262af | bellard | int num, den, q, r;
|
350 | 2c0262af | bellard | |
351 | 2c0262af | bellard | num = (int16_t)EAX; |
352 | 2c0262af | bellard | den = (int8_t)T0; |
353 | 2c0262af | bellard | if (den == 0) { |
354 | 2c0262af | bellard | raise_exception(EXCP00_DIVZ); |
355 | 2c0262af | bellard | } |
356 | 2c0262af | bellard | q = (num / den) & 0xff;
|
357 | 2c0262af | bellard | r = (num % den) & 0xff;
|
358 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | (r << 8) | q; |
359 | 2c0262af | bellard | } |
360 | 2c0262af | bellard | |
361 | 2c0262af | bellard | void OPPROTO op_divw_AX_T0(void) |
362 | 2c0262af | bellard | { |
363 | 2c0262af | bellard | unsigned int num, den, q, r; |
364 | 2c0262af | bellard | |
365 | 2c0262af | bellard | num = (EAX & 0xffff) | ((EDX & 0xffff) << 16); |
366 | 2c0262af | bellard | den = (T0 & 0xffff);
|
367 | 2c0262af | bellard | if (den == 0) { |
368 | 2c0262af | bellard | raise_exception(EXCP00_DIVZ); |
369 | 2c0262af | bellard | } |
370 | 2c0262af | bellard | q = (num / den) & 0xffff;
|
371 | 2c0262af | bellard | r = (num % den) & 0xffff;
|
372 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | q;
|
373 | 14ce26e7 | bellard | EDX = (EDX & ~0xffff) | r;
|
374 | 2c0262af | bellard | } |
375 | 2c0262af | bellard | |
376 | 2c0262af | bellard | void OPPROTO op_idivw_AX_T0(void) |
377 | 2c0262af | bellard | { |
378 | 2c0262af | bellard | int num, den, q, r;
|
379 | 2c0262af | bellard | |
380 | 2c0262af | bellard | num = (EAX & 0xffff) | ((EDX & 0xffff) << 16); |
381 | 2c0262af | bellard | den = (int16_t)T0; |
382 | 2c0262af | bellard | if (den == 0) { |
383 | 2c0262af | bellard | raise_exception(EXCP00_DIVZ); |
384 | 2c0262af | bellard | } |
385 | 2c0262af | bellard | q = (num / den) & 0xffff;
|
386 | 2c0262af | bellard | r = (num % den) & 0xffff;
|
387 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | q;
|
388 | 14ce26e7 | bellard | EDX = (EDX & ~0xffff) | r;
|
389 | 2c0262af | bellard | } |
390 | 2c0262af | bellard | |
391 | 2c0262af | bellard | void OPPROTO op_divl_EAX_T0(void) |
392 | 2c0262af | bellard | { |
393 | 14ce26e7 | bellard | helper_divl_EAX_T0(); |
394 | 2c0262af | bellard | } |
395 | 2c0262af | bellard | |
396 | 2c0262af | bellard | void OPPROTO op_idivl_EAX_T0(void) |
397 | 2c0262af | bellard | { |
398 | 14ce26e7 | bellard | helper_idivl_EAX_T0(); |
399 | 2c0262af | bellard | } |
400 | 2c0262af | bellard | |
401 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
402 | 14ce26e7 | bellard | void OPPROTO op_divq_EAX_T0(void) |
403 | 14ce26e7 | bellard | { |
404 | 14ce26e7 | bellard | helper_divq_EAX_T0(); |
405 | 14ce26e7 | bellard | } |
406 | 14ce26e7 | bellard | |
407 | 14ce26e7 | bellard | void OPPROTO op_idivq_EAX_T0(void) |
408 | 14ce26e7 | bellard | { |
409 | 14ce26e7 | bellard | helper_idivq_EAX_T0(); |
410 | 14ce26e7 | bellard | } |
411 | 14ce26e7 | bellard | #endif
|
412 | 14ce26e7 | bellard | |
413 | 2c0262af | bellard | /* constant load & misc op */
|
414 | 2c0262af | bellard | |
415 | 14ce26e7 | bellard | /* XXX: consistent names */
|
416 | 14ce26e7 | bellard | void OPPROTO op_movl_T0_imu(void) |
417 | 14ce26e7 | bellard | { |
418 | 14ce26e7 | bellard | T0 = (uint32_t)PARAM1; |
419 | 14ce26e7 | bellard | } |
420 | 14ce26e7 | bellard | |
421 | 2c0262af | bellard | void OPPROTO op_movl_T0_im(void) |
422 | 2c0262af | bellard | { |
423 | 14ce26e7 | bellard | T0 = (int32_t)PARAM1; |
424 | 2c0262af | bellard | } |
425 | 2c0262af | bellard | |
426 | 2c0262af | bellard | void OPPROTO op_addl_T0_im(void) |
427 | 2c0262af | bellard | { |
428 | 2c0262af | bellard | T0 += PARAM1; |
429 | 2c0262af | bellard | } |
430 | 2c0262af | bellard | |
431 | 2c0262af | bellard | void OPPROTO op_andl_T0_ffff(void) |
432 | 2c0262af | bellard | { |
433 | 2c0262af | bellard | T0 = T0 & 0xffff;
|
434 | 2c0262af | bellard | } |
435 | 2c0262af | bellard | |
436 | 2c0262af | bellard | void OPPROTO op_andl_T0_im(void) |
437 | 2c0262af | bellard | { |
438 | 2c0262af | bellard | T0 = T0 & PARAM1; |
439 | 2c0262af | bellard | } |
440 | 2c0262af | bellard | |
441 | 2c0262af | bellard | void OPPROTO op_movl_T0_T1(void) |
442 | 2c0262af | bellard | { |
443 | 2c0262af | bellard | T0 = T1; |
444 | 2c0262af | bellard | } |
445 | 2c0262af | bellard | |
446 | 14ce26e7 | bellard | void OPPROTO op_movl_T1_imu(void) |
447 | 14ce26e7 | bellard | { |
448 | 14ce26e7 | bellard | T1 = (uint32_t)PARAM1; |
449 | 14ce26e7 | bellard | } |
450 | 14ce26e7 | bellard | |
451 | 2c0262af | bellard | void OPPROTO op_movl_T1_im(void) |
452 | 2c0262af | bellard | { |
453 | 14ce26e7 | bellard | T1 = (int32_t)PARAM1; |
454 | 2c0262af | bellard | } |
455 | 2c0262af | bellard | |
456 | 2c0262af | bellard | void OPPROTO op_addl_T1_im(void) |
457 | 2c0262af | bellard | { |
458 | 2c0262af | bellard | T1 += PARAM1; |
459 | 2c0262af | bellard | } |
460 | 2c0262af | bellard | |
461 | 2c0262af | bellard | void OPPROTO op_movl_T1_A0(void) |
462 | 2c0262af | bellard | { |
463 | 2c0262af | bellard | T1 = A0; |
464 | 2c0262af | bellard | } |
465 | 2c0262af | bellard | |
466 | 2c0262af | bellard | void OPPROTO op_movl_A0_im(void) |
467 | 2c0262af | bellard | { |
468 | 14ce26e7 | bellard | A0 = (uint32_t)PARAM1; |
469 | 2c0262af | bellard | } |
470 | 2c0262af | bellard | |
471 | 2c0262af | bellard | void OPPROTO op_addl_A0_im(void) |
472 | 2c0262af | bellard | { |
473 | 14ce26e7 | bellard | A0 = (uint32_t)(A0 + PARAM1); |
474 | 14ce26e7 | bellard | } |
475 | 14ce26e7 | bellard | |
476 | 14ce26e7 | bellard | void OPPROTO op_movl_A0_seg(void) |
477 | 14ce26e7 | bellard | { |
478 | 14ce26e7 | bellard | A0 = (uint32_t)*(target_ulong *)((char *)env + PARAM1);
|
479 | 14ce26e7 | bellard | } |
480 | 14ce26e7 | bellard | |
481 | 14ce26e7 | bellard | void OPPROTO op_addl_A0_seg(void) |
482 | 14ce26e7 | bellard | { |
483 | 14ce26e7 | bellard | A0 = (uint32_t)(A0 + *(target_ulong *)((char *)env + PARAM1));
|
484 | 2c0262af | bellard | } |
485 | 2c0262af | bellard | |
486 | 2c0262af | bellard | void OPPROTO op_addl_A0_AL(void) |
487 | 2c0262af | bellard | { |
488 | 14ce26e7 | bellard | A0 = (uint32_t)(A0 + (EAX & 0xff));
|
489 | 14ce26e7 | bellard | } |
490 | 14ce26e7 | bellard | |
491 | 14ce26e7 | bellard | #ifdef WORDS_BIGENDIAN
|
492 | 14ce26e7 | bellard | typedef union UREG64 { |
493 | 14ce26e7 | bellard | struct { uint16_t v3, v2, v1, v0; } w;
|
494 | 14ce26e7 | bellard | struct { uint32_t v1, v0; } l;
|
495 | 14ce26e7 | bellard | uint64_t q; |
496 | 14ce26e7 | bellard | } UREG64; |
497 | 14ce26e7 | bellard | #else
|
498 | 14ce26e7 | bellard | typedef union UREG64 { |
499 | 14ce26e7 | bellard | struct { uint16_t v0, v1, v2, v3; } w;
|
500 | 14ce26e7 | bellard | struct { uint32_t v0, v1; } l;
|
501 | 14ce26e7 | bellard | uint64_t q; |
502 | 14ce26e7 | bellard | } UREG64; |
503 | 14ce26e7 | bellard | #endif
|
504 | 14ce26e7 | bellard | |
505 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
506 | 14ce26e7 | bellard | |
507 | 14ce26e7 | bellard | #define PARAMQ1 \
|
508 | 14ce26e7 | bellard | ({\ |
509 | 14ce26e7 | bellard | UREG64 __p;\ |
510 | 14ce26e7 | bellard | __p.l.v1 = PARAM1;\ |
511 | 14ce26e7 | bellard | __p.l.v0 = PARAM2;\ |
512 | 14ce26e7 | bellard | __p.q;\ |
513 | 14ce26e7 | bellard | }) |
514 | 14ce26e7 | bellard | |
515 | 14ce26e7 | bellard | void OPPROTO op_movq_T0_im64(void) |
516 | 14ce26e7 | bellard | { |
517 | 14ce26e7 | bellard | T0 = PARAMQ1; |
518 | 2c0262af | bellard | } |
519 | 2c0262af | bellard | |
520 | 1ef38687 | bellard | void OPPROTO op_movq_T1_im64(void) |
521 | 1ef38687 | bellard | { |
522 | 1ef38687 | bellard | T1 = PARAMQ1; |
523 | 1ef38687 | bellard | } |
524 | 1ef38687 | bellard | |
525 | 14ce26e7 | bellard | void OPPROTO op_movq_A0_im(void) |
526 | 14ce26e7 | bellard | { |
527 | 14ce26e7 | bellard | A0 = (int32_t)PARAM1; |
528 | 14ce26e7 | bellard | } |
529 | 14ce26e7 | bellard | |
530 | 14ce26e7 | bellard | void OPPROTO op_movq_A0_im64(void) |
531 | 14ce26e7 | bellard | { |
532 | 14ce26e7 | bellard | A0 = PARAMQ1; |
533 | 14ce26e7 | bellard | } |
534 | 14ce26e7 | bellard | |
535 | 14ce26e7 | bellard | void OPPROTO op_addq_A0_im(void) |
536 | 14ce26e7 | bellard | { |
537 | 14ce26e7 | bellard | A0 = (A0 + (int32_t)PARAM1); |
538 | 14ce26e7 | bellard | } |
539 | 14ce26e7 | bellard | |
540 | 14ce26e7 | bellard | void OPPROTO op_addq_A0_im64(void) |
541 | 14ce26e7 | bellard | { |
542 | 14ce26e7 | bellard | A0 = (A0 + PARAMQ1); |
543 | 14ce26e7 | bellard | } |
544 | 14ce26e7 | bellard | |
545 | 14ce26e7 | bellard | void OPPROTO op_movq_A0_seg(void) |
546 | 14ce26e7 | bellard | { |
547 | 14ce26e7 | bellard | A0 = *(target_ulong *)((char *)env + PARAM1);
|
548 | 14ce26e7 | bellard | } |
549 | 14ce26e7 | bellard | |
550 | 14ce26e7 | bellard | void OPPROTO op_addq_A0_seg(void) |
551 | 14ce26e7 | bellard | { |
552 | 14ce26e7 | bellard | A0 += *(target_ulong *)((char *)env + PARAM1);
|
553 | 14ce26e7 | bellard | } |
554 | 14ce26e7 | bellard | |
555 | 14ce26e7 | bellard | void OPPROTO op_addq_A0_AL(void) |
556 | 14ce26e7 | bellard | { |
557 | 14ce26e7 | bellard | A0 = (A0 + (EAX & 0xff));
|
558 | 14ce26e7 | bellard | } |
559 | 14ce26e7 | bellard | |
560 | 14ce26e7 | bellard | #endif
|
561 | 14ce26e7 | bellard | |
562 | 2c0262af | bellard | void OPPROTO op_andl_A0_ffff(void) |
563 | 2c0262af | bellard | { |
564 | 2c0262af | bellard | A0 = A0 & 0xffff;
|
565 | 2c0262af | bellard | } |
566 | 2c0262af | bellard | |
567 | 2c0262af | bellard | /* memory access */
|
568 | 2c0262af | bellard | |
569 | 61382a50 | bellard | #define MEMSUFFIX _raw
|
570 | 2c0262af | bellard | #include "ops_mem.h" |
571 | 2c0262af | bellard | |
572 | 61382a50 | bellard | #if !defined(CONFIG_USER_ONLY)
|
573 | f68dd770 | bellard | #define MEMSUFFIX _kernel
|
574 | 2c0262af | bellard | #include "ops_mem.h" |
575 | 2c0262af | bellard | |
576 | f68dd770 | bellard | #define MEMSUFFIX _user
|
577 | 2c0262af | bellard | #include "ops_mem.h" |
578 | 61382a50 | bellard | #endif
|
579 | 2c0262af | bellard | |
580 | 14ce26e7 | bellard | /* indirect jump */
|
581 | 2c0262af | bellard | |
582 | 14ce26e7 | bellard | void OPPROTO op_jmp_T0(void) |
583 | 2c0262af | bellard | { |
584 | 14ce26e7 | bellard | EIP = T0; |
585 | 2c0262af | bellard | } |
586 | 2c0262af | bellard | |
587 | 14ce26e7 | bellard | void OPPROTO op_movl_eip_im(void) |
588 | 2c0262af | bellard | { |
589 | 14ce26e7 | bellard | EIP = (uint32_t)PARAM1; |
590 | 2c0262af | bellard | } |
591 | 2c0262af | bellard | |
592 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
593 | 14ce26e7 | bellard | void OPPROTO op_movq_eip_im(void) |
594 | 2c0262af | bellard | { |
595 | 14ce26e7 | bellard | EIP = (int32_t)PARAM1; |
596 | 2c0262af | bellard | } |
597 | 2c0262af | bellard | |
598 | 14ce26e7 | bellard | void OPPROTO op_movq_eip_im64(void) |
599 | 2c0262af | bellard | { |
600 | 14ce26e7 | bellard | EIP = PARAMQ1; |
601 | 2c0262af | bellard | } |
602 | 14ce26e7 | bellard | #endif
|
603 | 2c0262af | bellard | |
604 | 2c0262af | bellard | void OPPROTO op_hlt(void) |
605 | 2c0262af | bellard | { |
606 | acf5feac | bellard | env->hflags &= ~HF_INHIBIT_IRQ_MASK; /* needed if sti is just before */
|
607 | 2c0262af | bellard | env->exception_index = EXCP_HLT; |
608 | 2c0262af | bellard | cpu_loop_exit(); |
609 | 2c0262af | bellard | } |
610 | 2c0262af | bellard | |
611 | 2c0262af | bellard | void OPPROTO op_debug(void) |
612 | 2c0262af | bellard | { |
613 | 2c0262af | bellard | env->exception_index = EXCP_DEBUG; |
614 | 2c0262af | bellard | cpu_loop_exit(); |
615 | 2c0262af | bellard | } |
616 | 2c0262af | bellard | |
617 | 2c0262af | bellard | void OPPROTO op_raise_interrupt(void) |
618 | 2c0262af | bellard | { |
619 | a8ede8ba | bellard | int intno, next_eip_addend;
|
620 | 2c0262af | bellard | intno = PARAM1; |
621 | a8ede8ba | bellard | next_eip_addend = PARAM2; |
622 | a8ede8ba | bellard | raise_interrupt(intno, 1, 0, next_eip_addend); |
623 | 2c0262af | bellard | } |
624 | 2c0262af | bellard | |
625 | 2c0262af | bellard | void OPPROTO op_raise_exception(void) |
626 | 2c0262af | bellard | { |
627 | 2c0262af | bellard | int exception_index;
|
628 | 2c0262af | bellard | exception_index = PARAM1; |
629 | 2c0262af | bellard | raise_exception(exception_index); |
630 | 2c0262af | bellard | } |
631 | 2c0262af | bellard | |
632 | 2c0262af | bellard | void OPPROTO op_into(void) |
633 | 2c0262af | bellard | { |
634 | 2c0262af | bellard | int eflags;
|
635 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
636 | 2c0262af | bellard | if (eflags & CC_O) {
|
637 | 2c0262af | bellard | raise_interrupt(EXCP04_INTO, 1, 0, PARAM1); |
638 | 2c0262af | bellard | } |
639 | 2c0262af | bellard | FORCE_RET(); |
640 | 2c0262af | bellard | } |
641 | 2c0262af | bellard | |
642 | 2c0262af | bellard | void OPPROTO op_cli(void) |
643 | 2c0262af | bellard | { |
644 | 2c0262af | bellard | env->eflags &= ~IF_MASK; |
645 | 2c0262af | bellard | } |
646 | 2c0262af | bellard | |
647 | 2c0262af | bellard | void OPPROTO op_sti(void) |
648 | 2c0262af | bellard | { |
649 | 2c0262af | bellard | env->eflags |= IF_MASK; |
650 | 2c0262af | bellard | } |
651 | 2c0262af | bellard | |
652 | 2c0262af | bellard | void OPPROTO op_set_inhibit_irq(void) |
653 | 2c0262af | bellard | { |
654 | 2c0262af | bellard | env->hflags |= HF_INHIBIT_IRQ_MASK; |
655 | 2c0262af | bellard | } |
656 | 2c0262af | bellard | |
657 | 2c0262af | bellard | void OPPROTO op_reset_inhibit_irq(void) |
658 | 2c0262af | bellard | { |
659 | 2c0262af | bellard | env->hflags &= ~HF_INHIBIT_IRQ_MASK; |
660 | 2c0262af | bellard | } |
661 | 2c0262af | bellard | |
662 | 2c0262af | bellard | #if 0
|
663 | 2c0262af | bellard | /* vm86plus instructions */
|
664 | 2c0262af | bellard | void OPPROTO op_cli_vm(void)
|
665 | 2c0262af | bellard | {
|
666 | 2c0262af | bellard | env->eflags &= ~VIF_MASK;
|
667 | 2c0262af | bellard | }
|
668 | 2c0262af | bellard | |
669 | 2c0262af | bellard | void OPPROTO op_sti_vm(void)
|
670 | 2c0262af | bellard | {
|
671 | 2c0262af | bellard | env->eflags |= VIF_MASK;
|
672 | 2c0262af | bellard | if (env->eflags & VIP_MASK) {
|
673 | 2c0262af | bellard | EIP = PARAM1;
|
674 | 2c0262af | bellard | raise_exception(EXCP0D_GPF);
|
675 | 2c0262af | bellard | }
|
676 | 2c0262af | bellard | FORCE_RET();
|
677 | 2c0262af | bellard | }
|
678 | 2c0262af | bellard | #endif
|
679 | 2c0262af | bellard | |
680 | 2c0262af | bellard | void OPPROTO op_boundw(void) |
681 | 2c0262af | bellard | { |
682 | 2c0262af | bellard | int low, high, v;
|
683 | 14ce26e7 | bellard | low = ldsw(A0); |
684 | 14ce26e7 | bellard | high = ldsw(A0 + 2);
|
685 | 2c0262af | bellard | v = (int16_t)T0; |
686 | 2c0262af | bellard | if (v < low || v > high) {
|
687 | 2c0262af | bellard | raise_exception(EXCP05_BOUND); |
688 | 2c0262af | bellard | } |
689 | 2c0262af | bellard | FORCE_RET(); |
690 | 2c0262af | bellard | } |
691 | 2c0262af | bellard | |
692 | 2c0262af | bellard | void OPPROTO op_boundl(void) |
693 | 2c0262af | bellard | { |
694 | 2c0262af | bellard | int low, high, v;
|
695 | 14ce26e7 | bellard | low = ldl(A0); |
696 | 14ce26e7 | bellard | high = ldl(A0 + 4);
|
697 | 2c0262af | bellard | v = T0; |
698 | 2c0262af | bellard | if (v < low || v > high) {
|
699 | 2c0262af | bellard | raise_exception(EXCP05_BOUND); |
700 | 2c0262af | bellard | } |
701 | 2c0262af | bellard | FORCE_RET(); |
702 | 2c0262af | bellard | } |
703 | 2c0262af | bellard | |
704 | 2c0262af | bellard | void OPPROTO op_cmpxchg8b(void) |
705 | 2c0262af | bellard | { |
706 | 2c0262af | bellard | helper_cmpxchg8b(); |
707 | 2c0262af | bellard | } |
708 | 2c0262af | bellard | |
709 | 2c0262af | bellard | void OPPROTO op_movl_T0_0(void) |
710 | 2c0262af | bellard | { |
711 | 2c0262af | bellard | T0 = 0;
|
712 | 2c0262af | bellard | } |
713 | 2c0262af | bellard | |
714 | 2c0262af | bellard | void OPPROTO op_exit_tb(void) |
715 | 2c0262af | bellard | { |
716 | 2c0262af | bellard | EXIT_TB(); |
717 | 2c0262af | bellard | } |
718 | 2c0262af | bellard | |
719 | 2c0262af | bellard | /* multiple size ops */
|
720 | 2c0262af | bellard | |
721 | 2c0262af | bellard | #define ldul ldl
|
722 | 2c0262af | bellard | |
723 | 2c0262af | bellard | #define SHIFT 0 |
724 | 2c0262af | bellard | #include "ops_template.h" |
725 | 2c0262af | bellard | #undef SHIFT
|
726 | 2c0262af | bellard | |
727 | 2c0262af | bellard | #define SHIFT 1 |
728 | 2c0262af | bellard | #include "ops_template.h" |
729 | 2c0262af | bellard | #undef SHIFT
|
730 | 2c0262af | bellard | |
731 | 2c0262af | bellard | #define SHIFT 2 |
732 | 2c0262af | bellard | #include "ops_template.h" |
733 | 2c0262af | bellard | #undef SHIFT
|
734 | 2c0262af | bellard | |
735 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
736 | 14ce26e7 | bellard | |
737 | 14ce26e7 | bellard | #define SHIFT 3 |
738 | 14ce26e7 | bellard | #include "ops_template.h" |
739 | 14ce26e7 | bellard | #undef SHIFT
|
740 | 14ce26e7 | bellard | |
741 | 14ce26e7 | bellard | #endif
|
742 | 14ce26e7 | bellard | |
743 | 2c0262af | bellard | /* sign extend */
|
744 | 2c0262af | bellard | |
745 | 2c0262af | bellard | void OPPROTO op_movsbl_T0_T0(void) |
746 | 2c0262af | bellard | { |
747 | 2c0262af | bellard | T0 = (int8_t)T0; |
748 | 2c0262af | bellard | } |
749 | 2c0262af | bellard | |
750 | 2c0262af | bellard | void OPPROTO op_movzbl_T0_T0(void) |
751 | 2c0262af | bellard | { |
752 | 2c0262af | bellard | T0 = (uint8_t)T0; |
753 | 2c0262af | bellard | } |
754 | 2c0262af | bellard | |
755 | 2c0262af | bellard | void OPPROTO op_movswl_T0_T0(void) |
756 | 2c0262af | bellard | { |
757 | 2c0262af | bellard | T0 = (int16_t)T0; |
758 | 2c0262af | bellard | } |
759 | 2c0262af | bellard | |
760 | 2c0262af | bellard | void OPPROTO op_movzwl_T0_T0(void) |
761 | 2c0262af | bellard | { |
762 | 2c0262af | bellard | T0 = (uint16_t)T0; |
763 | 2c0262af | bellard | } |
764 | 2c0262af | bellard | |
765 | 2c0262af | bellard | void OPPROTO op_movswl_EAX_AX(void) |
766 | 2c0262af | bellard | { |
767 | 2c0262af | bellard | EAX = (int16_t)EAX; |
768 | 2c0262af | bellard | } |
769 | 2c0262af | bellard | |
770 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
771 | 664e0f19 | bellard | void OPPROTO op_movslq_T0_T0(void) |
772 | 664e0f19 | bellard | { |
773 | 664e0f19 | bellard | T0 = (int32_t)T0; |
774 | 664e0f19 | bellard | } |
775 | 664e0f19 | bellard | |
776 | 14ce26e7 | bellard | void OPPROTO op_movslq_RAX_EAX(void) |
777 | 14ce26e7 | bellard | { |
778 | 14ce26e7 | bellard | EAX = (int32_t)EAX; |
779 | 14ce26e7 | bellard | } |
780 | 14ce26e7 | bellard | #endif
|
781 | 14ce26e7 | bellard | |
782 | 2c0262af | bellard | void OPPROTO op_movsbw_AX_AL(void) |
783 | 2c0262af | bellard | { |
784 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | ((int8_t)EAX & 0xffff); |
785 | 2c0262af | bellard | } |
786 | 2c0262af | bellard | |
787 | 2c0262af | bellard | void OPPROTO op_movslq_EDX_EAX(void) |
788 | 2c0262af | bellard | { |
789 | 2c0262af | bellard | EDX = (int32_t)EAX >> 31;
|
790 | 2c0262af | bellard | } |
791 | 2c0262af | bellard | |
792 | 2c0262af | bellard | void OPPROTO op_movswl_DX_AX(void) |
793 | 2c0262af | bellard | { |
794 | 14ce26e7 | bellard | EDX = (EDX & ~0xffff) | (((int16_t)EAX >> 15) & 0xffff); |
795 | 14ce26e7 | bellard | } |
796 | 14ce26e7 | bellard | |
797 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
798 | 14ce26e7 | bellard | void OPPROTO op_movsqo_RDX_RAX(void) |
799 | 14ce26e7 | bellard | { |
800 | 14ce26e7 | bellard | EDX = (int64_t)EAX >> 63;
|
801 | 2c0262af | bellard | } |
802 | 14ce26e7 | bellard | #endif
|
803 | 2c0262af | bellard | |
804 | 2c0262af | bellard | /* string ops helpers */
|
805 | 2c0262af | bellard | |
806 | 2c0262af | bellard | void OPPROTO op_addl_ESI_T0(void) |
807 | 2c0262af | bellard | { |
808 | 14ce26e7 | bellard | ESI = (uint32_t)(ESI + T0); |
809 | 2c0262af | bellard | } |
810 | 2c0262af | bellard | |
811 | 2c0262af | bellard | void OPPROTO op_addw_ESI_T0(void) |
812 | 2c0262af | bellard | { |
813 | 2c0262af | bellard | ESI = (ESI & ~0xffff) | ((ESI + T0) & 0xffff); |
814 | 2c0262af | bellard | } |
815 | 2c0262af | bellard | |
816 | 2c0262af | bellard | void OPPROTO op_addl_EDI_T0(void) |
817 | 2c0262af | bellard | { |
818 | 14ce26e7 | bellard | EDI = (uint32_t)(EDI + T0); |
819 | 2c0262af | bellard | } |
820 | 2c0262af | bellard | |
821 | 2c0262af | bellard | void OPPROTO op_addw_EDI_T0(void) |
822 | 2c0262af | bellard | { |
823 | 2c0262af | bellard | EDI = (EDI & ~0xffff) | ((EDI + T0) & 0xffff); |
824 | 2c0262af | bellard | } |
825 | 2c0262af | bellard | |
826 | 2c0262af | bellard | void OPPROTO op_decl_ECX(void) |
827 | 2c0262af | bellard | { |
828 | 14ce26e7 | bellard | ECX = (uint32_t)(ECX - 1);
|
829 | 2c0262af | bellard | } |
830 | 2c0262af | bellard | |
831 | 2c0262af | bellard | void OPPROTO op_decw_ECX(void) |
832 | 2c0262af | bellard | { |
833 | 2c0262af | bellard | ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff); |
834 | 2c0262af | bellard | } |
835 | 2c0262af | bellard | |
836 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
837 | 14ce26e7 | bellard | void OPPROTO op_addq_ESI_T0(void) |
838 | 14ce26e7 | bellard | { |
839 | 14ce26e7 | bellard | ESI = (ESI + T0); |
840 | 14ce26e7 | bellard | } |
841 | 14ce26e7 | bellard | |
842 | 14ce26e7 | bellard | void OPPROTO op_addq_EDI_T0(void) |
843 | 14ce26e7 | bellard | { |
844 | 14ce26e7 | bellard | EDI = (EDI + T0); |
845 | 14ce26e7 | bellard | } |
846 | 14ce26e7 | bellard | |
847 | 14ce26e7 | bellard | void OPPROTO op_decq_ECX(void) |
848 | 14ce26e7 | bellard | { |
849 | 14ce26e7 | bellard | ECX--; |
850 | 14ce26e7 | bellard | } |
851 | 14ce26e7 | bellard | #endif
|
852 | 14ce26e7 | bellard | |
853 | f68dd770 | bellard | /* push/pop utils */
|
854 | 2c0262af | bellard | |
855 | f68dd770 | bellard | void op_addl_A0_SS(void) |
856 | 2c0262af | bellard | { |
857 | f68dd770 | bellard | A0 += (long)env->segs[R_SS].base;
|
858 | 2c0262af | bellard | } |
859 | 2c0262af | bellard | |
860 | f68dd770 | bellard | void op_subl_A0_2(void) |
861 | 2c0262af | bellard | { |
862 | 14ce26e7 | bellard | A0 = (uint32_t)(A0 - 2);
|
863 | 2c0262af | bellard | } |
864 | 2c0262af | bellard | |
865 | f68dd770 | bellard | void op_subl_A0_4(void) |
866 | 2c0262af | bellard | { |
867 | 14ce26e7 | bellard | A0 = (uint32_t)(A0 - 4);
|
868 | 2c0262af | bellard | } |
869 | 2c0262af | bellard | |
870 | 2c0262af | bellard | void op_addl_ESP_4(void) |
871 | 2c0262af | bellard | { |
872 | 14ce26e7 | bellard | ESP = (uint32_t)(ESP + 4);
|
873 | 2c0262af | bellard | } |
874 | 2c0262af | bellard | |
875 | 2c0262af | bellard | void op_addl_ESP_2(void) |
876 | 2c0262af | bellard | { |
877 | 14ce26e7 | bellard | ESP = (uint32_t)(ESP + 2);
|
878 | 2c0262af | bellard | } |
879 | 2c0262af | bellard | |
880 | 2c0262af | bellard | void op_addw_ESP_4(void) |
881 | 2c0262af | bellard | { |
882 | 2c0262af | bellard | ESP = (ESP & ~0xffff) | ((ESP + 4) & 0xffff); |
883 | 2c0262af | bellard | } |
884 | 2c0262af | bellard | |
885 | 2c0262af | bellard | void op_addw_ESP_2(void) |
886 | 2c0262af | bellard | { |
887 | 2c0262af | bellard | ESP = (ESP & ~0xffff) | ((ESP + 2) & 0xffff); |
888 | 2c0262af | bellard | } |
889 | 2c0262af | bellard | |
890 | 2c0262af | bellard | void op_addl_ESP_im(void) |
891 | 2c0262af | bellard | { |
892 | 14ce26e7 | bellard | ESP = (uint32_t)(ESP + PARAM1); |
893 | 2c0262af | bellard | } |
894 | 2c0262af | bellard | |
895 | 2c0262af | bellard | void op_addw_ESP_im(void) |
896 | 2c0262af | bellard | { |
897 | 2c0262af | bellard | ESP = (ESP & ~0xffff) | ((ESP + PARAM1) & 0xffff); |
898 | 2c0262af | bellard | } |
899 | 2c0262af | bellard | |
900 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
901 | 14ce26e7 | bellard | void op_subq_A0_8(void) |
902 | 14ce26e7 | bellard | { |
903 | 14ce26e7 | bellard | A0 -= 8;
|
904 | 14ce26e7 | bellard | } |
905 | 14ce26e7 | bellard | |
906 | 14ce26e7 | bellard | void op_addq_ESP_8(void) |
907 | 14ce26e7 | bellard | { |
908 | 14ce26e7 | bellard | ESP += 8;
|
909 | 14ce26e7 | bellard | } |
910 | 14ce26e7 | bellard | |
911 | 14ce26e7 | bellard | void op_addq_ESP_im(void) |
912 | 14ce26e7 | bellard | { |
913 | 14ce26e7 | bellard | ESP += PARAM1; |
914 | 14ce26e7 | bellard | } |
915 | 14ce26e7 | bellard | #endif
|
916 | 14ce26e7 | bellard | |
917 | 2c0262af | bellard | void OPPROTO op_rdtsc(void) |
918 | 2c0262af | bellard | { |
919 | 2c0262af | bellard | helper_rdtsc(); |
920 | 2c0262af | bellard | } |
921 | 2c0262af | bellard | |
922 | 2c0262af | bellard | void OPPROTO op_cpuid(void) |
923 | 2c0262af | bellard | { |
924 | 2c0262af | bellard | helper_cpuid(); |
925 | 2c0262af | bellard | } |
926 | 2c0262af | bellard | |
927 | 61a8c4ec | bellard | void OPPROTO op_enter_level(void) |
928 | 61a8c4ec | bellard | { |
929 | 61a8c4ec | bellard | helper_enter_level(PARAM1, PARAM2); |
930 | 61a8c4ec | bellard | } |
931 | 61a8c4ec | bellard | |
932 | 023fe10d | bellard | void OPPROTO op_sysenter(void) |
933 | 023fe10d | bellard | { |
934 | 023fe10d | bellard | helper_sysenter(); |
935 | 023fe10d | bellard | } |
936 | 023fe10d | bellard | |
937 | 023fe10d | bellard | void OPPROTO op_sysexit(void) |
938 | 023fe10d | bellard | { |
939 | 023fe10d | bellard | helper_sysexit(); |
940 | 023fe10d | bellard | } |
941 | 023fe10d | bellard | |
942 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
943 | 14ce26e7 | bellard | void OPPROTO op_syscall(void) |
944 | 14ce26e7 | bellard | { |
945 | 06c2f506 | bellard | helper_syscall(PARAM1); |
946 | 14ce26e7 | bellard | } |
947 | 14ce26e7 | bellard | |
948 | 14ce26e7 | bellard | void OPPROTO op_sysret(void) |
949 | 14ce26e7 | bellard | { |
950 | 14ce26e7 | bellard | helper_sysret(PARAM1); |
951 | 14ce26e7 | bellard | } |
952 | 14ce26e7 | bellard | #endif
|
953 | 14ce26e7 | bellard | |
954 | 2c0262af | bellard | void OPPROTO op_rdmsr(void) |
955 | 2c0262af | bellard | { |
956 | 2c0262af | bellard | helper_rdmsr(); |
957 | 2c0262af | bellard | } |
958 | 2c0262af | bellard | |
959 | 2c0262af | bellard | void OPPROTO op_wrmsr(void) |
960 | 2c0262af | bellard | { |
961 | 2c0262af | bellard | helper_wrmsr(); |
962 | 2c0262af | bellard | } |
963 | 2c0262af | bellard | |
964 | 2c0262af | bellard | /* bcd */
|
965 | 2c0262af | bellard | |
966 | 2c0262af | bellard | /* XXX: exception */
|
967 | 2c0262af | bellard | void OPPROTO op_aam(void) |
968 | 2c0262af | bellard | { |
969 | 2c0262af | bellard | int base = PARAM1;
|
970 | 2c0262af | bellard | int al, ah;
|
971 | 2c0262af | bellard | al = EAX & 0xff;
|
972 | 2c0262af | bellard | ah = al / base; |
973 | 2c0262af | bellard | al = al % base; |
974 | 2c0262af | bellard | EAX = (EAX & ~0xffff) | al | (ah << 8); |
975 | 2c0262af | bellard | CC_DST = al; |
976 | 2c0262af | bellard | } |
977 | 2c0262af | bellard | |
978 | 2c0262af | bellard | void OPPROTO op_aad(void) |
979 | 2c0262af | bellard | { |
980 | 2c0262af | bellard | int base = PARAM1;
|
981 | 2c0262af | bellard | int al, ah;
|
982 | 2c0262af | bellard | al = EAX & 0xff;
|
983 | 2c0262af | bellard | ah = (EAX >> 8) & 0xff; |
984 | 2c0262af | bellard | al = ((ah * base) + al) & 0xff;
|
985 | 2c0262af | bellard | EAX = (EAX & ~0xffff) | al;
|
986 | 2c0262af | bellard | CC_DST = al; |
987 | 2c0262af | bellard | } |
988 | 2c0262af | bellard | |
989 | 2c0262af | bellard | void OPPROTO op_aaa(void) |
990 | 2c0262af | bellard | { |
991 | 2c0262af | bellard | int icarry;
|
992 | 2c0262af | bellard | int al, ah, af;
|
993 | 2c0262af | bellard | int eflags;
|
994 | 2c0262af | bellard | |
995 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
996 | 2c0262af | bellard | af = eflags & CC_A; |
997 | 2c0262af | bellard | al = EAX & 0xff;
|
998 | 2c0262af | bellard | ah = (EAX >> 8) & 0xff; |
999 | 2c0262af | bellard | |
1000 | 2c0262af | bellard | icarry = (al > 0xf9);
|
1001 | 2c0262af | bellard | if (((al & 0x0f) > 9 ) || af) { |
1002 | 2c0262af | bellard | al = (al + 6) & 0x0f; |
1003 | 2c0262af | bellard | ah = (ah + 1 + icarry) & 0xff; |
1004 | 2c0262af | bellard | eflags |= CC_C | CC_A; |
1005 | 2c0262af | bellard | } else {
|
1006 | 2c0262af | bellard | eflags &= ~(CC_C | CC_A); |
1007 | 2c0262af | bellard | al &= 0x0f;
|
1008 | 2c0262af | bellard | } |
1009 | 2c0262af | bellard | EAX = (EAX & ~0xffff) | al | (ah << 8); |
1010 | 2c0262af | bellard | CC_SRC = eflags; |
1011 | 2c0262af | bellard | } |
1012 | 2c0262af | bellard | |
1013 | 2c0262af | bellard | void OPPROTO op_aas(void) |
1014 | 2c0262af | bellard | { |
1015 | 2c0262af | bellard | int icarry;
|
1016 | 2c0262af | bellard | int al, ah, af;
|
1017 | 2c0262af | bellard | int eflags;
|
1018 | 2c0262af | bellard | |
1019 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1020 | 2c0262af | bellard | af = eflags & CC_A; |
1021 | 2c0262af | bellard | al = EAX & 0xff;
|
1022 | 2c0262af | bellard | ah = (EAX >> 8) & 0xff; |
1023 | 2c0262af | bellard | |
1024 | 2c0262af | bellard | icarry = (al < 6);
|
1025 | 2c0262af | bellard | if (((al & 0x0f) > 9 ) || af) { |
1026 | 2c0262af | bellard | al = (al - 6) & 0x0f; |
1027 | 2c0262af | bellard | ah = (ah - 1 - icarry) & 0xff; |
1028 | 2c0262af | bellard | eflags |= CC_C | CC_A; |
1029 | 2c0262af | bellard | } else {
|
1030 | 2c0262af | bellard | eflags &= ~(CC_C | CC_A); |
1031 | 2c0262af | bellard | al &= 0x0f;
|
1032 | 2c0262af | bellard | } |
1033 | 2c0262af | bellard | EAX = (EAX & ~0xffff) | al | (ah << 8); |
1034 | 2c0262af | bellard | CC_SRC = eflags; |
1035 | 2c0262af | bellard | } |
1036 | 2c0262af | bellard | |
1037 | 2c0262af | bellard | void OPPROTO op_daa(void) |
1038 | 2c0262af | bellard | { |
1039 | 2c0262af | bellard | int al, af, cf;
|
1040 | 2c0262af | bellard | int eflags;
|
1041 | 2c0262af | bellard | |
1042 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1043 | 2c0262af | bellard | cf = eflags & CC_C; |
1044 | 2c0262af | bellard | af = eflags & CC_A; |
1045 | 2c0262af | bellard | al = EAX & 0xff;
|
1046 | 2c0262af | bellard | |
1047 | 2c0262af | bellard | eflags = 0;
|
1048 | 2c0262af | bellard | if (((al & 0x0f) > 9 ) || af) { |
1049 | 2c0262af | bellard | al = (al + 6) & 0xff; |
1050 | 2c0262af | bellard | eflags |= CC_A; |
1051 | 2c0262af | bellard | } |
1052 | 2c0262af | bellard | if ((al > 0x9f) || cf) { |
1053 | 2c0262af | bellard | al = (al + 0x60) & 0xff; |
1054 | 2c0262af | bellard | eflags |= CC_C; |
1055 | 2c0262af | bellard | } |
1056 | 2c0262af | bellard | EAX = (EAX & ~0xff) | al;
|
1057 | 2c0262af | bellard | /* well, speed is not an issue here, so we compute the flags by hand */
|
1058 | 2c0262af | bellard | eflags |= (al == 0) << 6; /* zf */ |
1059 | 2c0262af | bellard | eflags |= parity_table[al]; /* pf */
|
1060 | 2c0262af | bellard | eflags |= (al & 0x80); /* sf */ |
1061 | 2c0262af | bellard | CC_SRC = eflags; |
1062 | 2c0262af | bellard | } |
1063 | 2c0262af | bellard | |
1064 | 2c0262af | bellard | void OPPROTO op_das(void) |
1065 | 2c0262af | bellard | { |
1066 | 2c0262af | bellard | int al, al1, af, cf;
|
1067 | 2c0262af | bellard | int eflags;
|
1068 | 2c0262af | bellard | |
1069 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1070 | 2c0262af | bellard | cf = eflags & CC_C; |
1071 | 2c0262af | bellard | af = eflags & CC_A; |
1072 | 2c0262af | bellard | al = EAX & 0xff;
|
1073 | 2c0262af | bellard | |
1074 | 2c0262af | bellard | eflags = 0;
|
1075 | 2c0262af | bellard | al1 = al; |
1076 | 2c0262af | bellard | if (((al & 0x0f) > 9 ) || af) { |
1077 | 2c0262af | bellard | eflags |= CC_A; |
1078 | 2c0262af | bellard | if (al < 6 || cf) |
1079 | 2c0262af | bellard | eflags |= CC_C; |
1080 | 2c0262af | bellard | al = (al - 6) & 0xff; |
1081 | 2c0262af | bellard | } |
1082 | 2c0262af | bellard | if ((al1 > 0x99) || cf) { |
1083 | 2c0262af | bellard | al = (al - 0x60) & 0xff; |
1084 | 2c0262af | bellard | eflags |= CC_C; |
1085 | 2c0262af | bellard | } |
1086 | 2c0262af | bellard | EAX = (EAX & ~0xff) | al;
|
1087 | 2c0262af | bellard | /* well, speed is not an issue here, so we compute the flags by hand */
|
1088 | 2c0262af | bellard | eflags |= (al == 0) << 6; /* zf */ |
1089 | 2c0262af | bellard | eflags |= parity_table[al]; /* pf */
|
1090 | 2c0262af | bellard | eflags |= (al & 0x80); /* sf */ |
1091 | 2c0262af | bellard | CC_SRC = eflags; |
1092 | 2c0262af | bellard | } |
1093 | 2c0262af | bellard | |
1094 | 2c0262af | bellard | /* segment handling */
|
1095 | 2c0262af | bellard | |
1096 | 2c0262af | bellard | /* never use it with R_CS */
|
1097 | 2c0262af | bellard | void OPPROTO op_movl_seg_T0(void) |
1098 | 2c0262af | bellard | { |
1099 | 3415a4dd | bellard | load_seg(PARAM1, T0); |
1100 | 2c0262af | bellard | } |
1101 | 2c0262af | bellard | |
1102 | 2c0262af | bellard | /* faster VM86 version */
|
1103 | 2c0262af | bellard | void OPPROTO op_movl_seg_T0_vm(void) |
1104 | 2c0262af | bellard | { |
1105 | 2c0262af | bellard | int selector;
|
1106 | 2c0262af | bellard | SegmentCache *sc; |
1107 | 2c0262af | bellard | |
1108 | 2c0262af | bellard | selector = T0 & 0xffff;
|
1109 | 2c0262af | bellard | /* env->segs[] access */
|
1110 | 2c0262af | bellard | sc = (SegmentCache *)((char *)env + PARAM1);
|
1111 | 2c0262af | bellard | sc->selector = selector; |
1112 | 14ce26e7 | bellard | sc->base = (selector << 4);
|
1113 | 2c0262af | bellard | } |
1114 | 2c0262af | bellard | |
1115 | 2c0262af | bellard | void OPPROTO op_movl_T0_seg(void) |
1116 | 2c0262af | bellard | { |
1117 | 2c0262af | bellard | T0 = env->segs[PARAM1].selector; |
1118 | 2c0262af | bellard | } |
1119 | 2c0262af | bellard | |
1120 | 2c0262af | bellard | void OPPROTO op_lsl(void) |
1121 | 2c0262af | bellard | { |
1122 | 2c0262af | bellard | helper_lsl(); |
1123 | 2c0262af | bellard | } |
1124 | 2c0262af | bellard | |
1125 | 2c0262af | bellard | void OPPROTO op_lar(void) |
1126 | 2c0262af | bellard | { |
1127 | 2c0262af | bellard | helper_lar(); |
1128 | 2c0262af | bellard | } |
1129 | 2c0262af | bellard | |
1130 | 3ab493de | bellard | void OPPROTO op_verr(void) |
1131 | 3ab493de | bellard | { |
1132 | 3ab493de | bellard | helper_verr(); |
1133 | 3ab493de | bellard | } |
1134 | 3ab493de | bellard | |
1135 | 3ab493de | bellard | void OPPROTO op_verw(void) |
1136 | 3ab493de | bellard | { |
1137 | 3ab493de | bellard | helper_verw(); |
1138 | 3ab493de | bellard | } |
1139 | 3ab493de | bellard | |
1140 | 3ab493de | bellard | void OPPROTO op_arpl(void) |
1141 | 3ab493de | bellard | { |
1142 | 3ab493de | bellard | if ((T0 & 3) < (T1 & 3)) { |
1143 | 3ab493de | bellard | /* XXX: emulate bug or 0xff3f0000 oring as in bochs ? */
|
1144 | 3ab493de | bellard | T0 = (T0 & ~3) | (T1 & 3); |
1145 | 3ab493de | bellard | T1 = CC_Z; |
1146 | 3ab493de | bellard | } else {
|
1147 | 3ab493de | bellard | T1 = 0;
|
1148 | 3ab493de | bellard | } |
1149 | 3ab493de | bellard | FORCE_RET(); |
1150 | 3ab493de | bellard | } |
1151 | 3ab493de | bellard | |
1152 | 3ab493de | bellard | void OPPROTO op_arpl_update(void) |
1153 | 3ab493de | bellard | { |
1154 | 3ab493de | bellard | int eflags;
|
1155 | 3ab493de | bellard | eflags = cc_table[CC_OP].compute_all(); |
1156 | 3ab493de | bellard | CC_SRC = (eflags & ~CC_Z) | T1; |
1157 | 3ab493de | bellard | } |
1158 | 3ab493de | bellard | |
1159 | 2c0262af | bellard | /* T0: segment, T1:eip */
|
1160 | 2c0262af | bellard | void OPPROTO op_ljmp_protected_T0_T1(void) |
1161 | 2c0262af | bellard | { |
1162 | 08cea4ee | bellard | helper_ljmp_protected_T0_T1(PARAM1); |
1163 | 2c0262af | bellard | } |
1164 | 2c0262af | bellard | |
1165 | 2c0262af | bellard | void OPPROTO op_lcall_real_T0_T1(void) |
1166 | 2c0262af | bellard | { |
1167 | 2c0262af | bellard | helper_lcall_real_T0_T1(PARAM1, PARAM2); |
1168 | 2c0262af | bellard | } |
1169 | 2c0262af | bellard | |
1170 | 2c0262af | bellard | void OPPROTO op_lcall_protected_T0_T1(void) |
1171 | 2c0262af | bellard | { |
1172 | 2c0262af | bellard | helper_lcall_protected_T0_T1(PARAM1, PARAM2); |
1173 | 2c0262af | bellard | } |
1174 | 2c0262af | bellard | |
1175 | 2c0262af | bellard | void OPPROTO op_iret_real(void) |
1176 | 2c0262af | bellard | { |
1177 | 2c0262af | bellard | helper_iret_real(PARAM1); |
1178 | 2c0262af | bellard | } |
1179 | 2c0262af | bellard | |
1180 | 2c0262af | bellard | void OPPROTO op_iret_protected(void) |
1181 | 2c0262af | bellard | { |
1182 | 08cea4ee | bellard | helper_iret_protected(PARAM1, PARAM2); |
1183 | 2c0262af | bellard | } |
1184 | 2c0262af | bellard | |
1185 | 2c0262af | bellard | void OPPROTO op_lret_protected(void) |
1186 | 2c0262af | bellard | { |
1187 | 2c0262af | bellard | helper_lret_protected(PARAM1, PARAM2); |
1188 | 2c0262af | bellard | } |
1189 | 2c0262af | bellard | |
1190 | 2c0262af | bellard | void OPPROTO op_lldt_T0(void) |
1191 | 2c0262af | bellard | { |
1192 | 2c0262af | bellard | helper_lldt_T0(); |
1193 | 2c0262af | bellard | } |
1194 | 2c0262af | bellard | |
1195 | 2c0262af | bellard | void OPPROTO op_ltr_T0(void) |
1196 | 2c0262af | bellard | { |
1197 | 2c0262af | bellard | helper_ltr_T0(); |
1198 | 2c0262af | bellard | } |
1199 | 2c0262af | bellard | |
1200 | 2c0262af | bellard | /* CR registers access */
|
1201 | 2c0262af | bellard | void OPPROTO op_movl_crN_T0(void) |
1202 | 2c0262af | bellard | { |
1203 | 2c0262af | bellard | helper_movl_crN_T0(PARAM1); |
1204 | 2c0262af | bellard | } |
1205 | 2c0262af | bellard | |
1206 | 82e41634 | bellard | #if !defined(CONFIG_USER_ONLY)
|
1207 | 39c61f49 | bellard | void OPPROTO op_movtl_T0_cr8(void) |
1208 | 39c61f49 | bellard | { |
1209 | 39c61f49 | bellard | T0 = cpu_get_apic_tpr(env); |
1210 | 39c61f49 | bellard | } |
1211 | 82e41634 | bellard | #endif
|
1212 | 39c61f49 | bellard | |
1213 | 2c0262af | bellard | /* DR registers access */
|
1214 | 2c0262af | bellard | void OPPROTO op_movl_drN_T0(void) |
1215 | 2c0262af | bellard | { |
1216 | 2c0262af | bellard | helper_movl_drN_T0(PARAM1); |
1217 | 2c0262af | bellard | } |
1218 | 2c0262af | bellard | |
1219 | 2c0262af | bellard | void OPPROTO op_lmsw_T0(void) |
1220 | 2c0262af | bellard | { |
1221 | 710c15a2 | bellard | /* only 4 lower bits of CR0 are modified. PE cannot be set to zero
|
1222 | 710c15a2 | bellard | if already set to one. */
|
1223 | 710c15a2 | bellard | T0 = (env->cr[0] & ~0xe) | (T0 & 0xf); |
1224 | 2c0262af | bellard | helper_movl_crN_T0(0);
|
1225 | 2c0262af | bellard | } |
1226 | 2c0262af | bellard | |
1227 | 2c0262af | bellard | void OPPROTO op_invlpg_A0(void) |
1228 | 2c0262af | bellard | { |
1229 | 2c0262af | bellard | helper_invlpg(A0); |
1230 | 2c0262af | bellard | } |
1231 | 2c0262af | bellard | |
1232 | 2c0262af | bellard | void OPPROTO op_movl_T0_env(void) |
1233 | 2c0262af | bellard | { |
1234 | 2c0262af | bellard | T0 = *(uint32_t *)((char *)env + PARAM1);
|
1235 | 2c0262af | bellard | } |
1236 | 2c0262af | bellard | |
1237 | 2c0262af | bellard | void OPPROTO op_movl_env_T0(void) |
1238 | 2c0262af | bellard | { |
1239 | 2c0262af | bellard | *(uint32_t *)((char *)env + PARAM1) = T0;
|
1240 | 2c0262af | bellard | } |
1241 | 2c0262af | bellard | |
1242 | 2c0262af | bellard | void OPPROTO op_movl_env_T1(void) |
1243 | 2c0262af | bellard | { |
1244 | 2c0262af | bellard | *(uint32_t *)((char *)env + PARAM1) = T1;
|
1245 | 2c0262af | bellard | } |
1246 | 2c0262af | bellard | |
1247 | 14ce26e7 | bellard | void OPPROTO op_movtl_T0_env(void) |
1248 | 14ce26e7 | bellard | { |
1249 | 14ce26e7 | bellard | T0 = *(target_ulong *)((char *)env + PARAM1);
|
1250 | 14ce26e7 | bellard | } |
1251 | 14ce26e7 | bellard | |
1252 | 14ce26e7 | bellard | void OPPROTO op_movtl_env_T0(void) |
1253 | 14ce26e7 | bellard | { |
1254 | 14ce26e7 | bellard | *(target_ulong *)((char *)env + PARAM1) = T0;
|
1255 | 14ce26e7 | bellard | } |
1256 | 14ce26e7 | bellard | |
1257 | 14ce26e7 | bellard | void OPPROTO op_movtl_T1_env(void) |
1258 | 14ce26e7 | bellard | { |
1259 | 14ce26e7 | bellard | T1 = *(target_ulong *)((char *)env + PARAM1);
|
1260 | 14ce26e7 | bellard | } |
1261 | 14ce26e7 | bellard | |
1262 | 14ce26e7 | bellard | void OPPROTO op_movtl_env_T1(void) |
1263 | 14ce26e7 | bellard | { |
1264 | 14ce26e7 | bellard | *(target_ulong *)((char *)env + PARAM1) = T1;
|
1265 | 14ce26e7 | bellard | } |
1266 | 14ce26e7 | bellard | |
1267 | 2c0262af | bellard | void OPPROTO op_clts(void) |
1268 | 2c0262af | bellard | { |
1269 | 2c0262af | bellard | env->cr[0] &= ~CR0_TS_MASK;
|
1270 | 7eee2a50 | bellard | env->hflags &= ~HF_TS_MASK; |
1271 | 2c0262af | bellard | } |
1272 | 2c0262af | bellard | |
1273 | 2c0262af | bellard | /* flags handling */
|
1274 | 2c0262af | bellard | |
1275 | 14ce26e7 | bellard | void OPPROTO op_goto_tb0(void) |
1276 | 2c0262af | bellard | { |
1277 | ae063a68 | bellard | GOTO_TB(op_goto_tb0, PARAM1, 0);
|
1278 | 14ce26e7 | bellard | } |
1279 | 14ce26e7 | bellard | |
1280 | 14ce26e7 | bellard | void OPPROTO op_goto_tb1(void) |
1281 | 14ce26e7 | bellard | { |
1282 | ae063a68 | bellard | GOTO_TB(op_goto_tb1, PARAM1, 1);
|
1283 | 14ce26e7 | bellard | } |
1284 | 14ce26e7 | bellard | |
1285 | 14ce26e7 | bellard | void OPPROTO op_jmp_label(void) |
1286 | 14ce26e7 | bellard | { |
1287 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
1288 | 2c0262af | bellard | } |
1289 | 2c0262af | bellard | |
1290 | 14ce26e7 | bellard | void OPPROTO op_jnz_T0_label(void) |
1291 | 2c0262af | bellard | { |
1292 | 2c0262af | bellard | if (T0)
|
1293 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
1294 | 39c61f49 | bellard | FORCE_RET(); |
1295 | 14ce26e7 | bellard | } |
1296 | 14ce26e7 | bellard | |
1297 | 14ce26e7 | bellard | void OPPROTO op_jz_T0_label(void) |
1298 | 14ce26e7 | bellard | { |
1299 | 14ce26e7 | bellard | if (!T0)
|
1300 | 14ce26e7 | bellard | GOTO_LABEL_PARAM(1);
|
1301 | 39c61f49 | bellard | FORCE_RET(); |
1302 | 2c0262af | bellard | } |
1303 | 2c0262af | bellard | |
1304 | 2c0262af | bellard | /* slow set cases (compute x86 flags) */
|
1305 | 2c0262af | bellard | void OPPROTO op_seto_T0_cc(void) |
1306 | 2c0262af | bellard | { |
1307 | 2c0262af | bellard | int eflags;
|
1308 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1309 | 2c0262af | bellard | T0 = (eflags >> 11) & 1; |
1310 | 2c0262af | bellard | } |
1311 | 2c0262af | bellard | |
1312 | 2c0262af | bellard | void OPPROTO op_setb_T0_cc(void) |
1313 | 2c0262af | bellard | { |
1314 | 2c0262af | bellard | T0 = cc_table[CC_OP].compute_c(); |
1315 | 2c0262af | bellard | } |
1316 | 2c0262af | bellard | |
1317 | 2c0262af | bellard | void OPPROTO op_setz_T0_cc(void) |
1318 | 2c0262af | bellard | { |
1319 | 2c0262af | bellard | int eflags;
|
1320 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1321 | 2c0262af | bellard | T0 = (eflags >> 6) & 1; |
1322 | 2c0262af | bellard | } |
1323 | 2c0262af | bellard | |
1324 | 2c0262af | bellard | void OPPROTO op_setbe_T0_cc(void) |
1325 | 2c0262af | bellard | { |
1326 | 2c0262af | bellard | int eflags;
|
1327 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1328 | 2c0262af | bellard | T0 = (eflags & (CC_Z | CC_C)) != 0;
|
1329 | 2c0262af | bellard | } |
1330 | 2c0262af | bellard | |
1331 | 2c0262af | bellard | void OPPROTO op_sets_T0_cc(void) |
1332 | 2c0262af | bellard | { |
1333 | 2c0262af | bellard | int eflags;
|
1334 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1335 | 2c0262af | bellard | T0 = (eflags >> 7) & 1; |
1336 | 2c0262af | bellard | } |
1337 | 2c0262af | bellard | |
1338 | 2c0262af | bellard | void OPPROTO op_setp_T0_cc(void) |
1339 | 2c0262af | bellard | { |
1340 | 2c0262af | bellard | int eflags;
|
1341 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1342 | 2c0262af | bellard | T0 = (eflags >> 2) & 1; |
1343 | 2c0262af | bellard | } |
1344 | 2c0262af | bellard | |
1345 | 2c0262af | bellard | void OPPROTO op_setl_T0_cc(void) |
1346 | 2c0262af | bellard | { |
1347 | 2c0262af | bellard | int eflags;
|
1348 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1349 | 2c0262af | bellard | T0 = ((eflags ^ (eflags >> 4)) >> 7) & 1; |
1350 | 2c0262af | bellard | } |
1351 | 2c0262af | bellard | |
1352 | 2c0262af | bellard | void OPPROTO op_setle_T0_cc(void) |
1353 | 2c0262af | bellard | { |
1354 | 2c0262af | bellard | int eflags;
|
1355 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1356 | 2c0262af | bellard | T0 = (((eflags ^ (eflags >> 4)) & 0x80) || (eflags & CC_Z)) != 0; |
1357 | 2c0262af | bellard | } |
1358 | 2c0262af | bellard | |
1359 | 2c0262af | bellard | void OPPROTO op_xor_T0_1(void) |
1360 | 2c0262af | bellard | { |
1361 | 2c0262af | bellard | T0 ^= 1;
|
1362 | 2c0262af | bellard | } |
1363 | 2c0262af | bellard | |
1364 | 2c0262af | bellard | void OPPROTO op_set_cc_op(void) |
1365 | 2c0262af | bellard | { |
1366 | 2c0262af | bellard | CC_OP = PARAM1; |
1367 | 2c0262af | bellard | } |
1368 | 2c0262af | bellard | |
1369 | 0b9dc5e4 | bellard | void OPPROTO op_mov_T0_cc(void) |
1370 | 0b9dc5e4 | bellard | { |
1371 | 0b9dc5e4 | bellard | T0 = cc_table[CC_OP].compute_all(); |
1372 | 0b9dc5e4 | bellard | } |
1373 | 0b9dc5e4 | bellard | |
1374 | 4136f33c | bellard | /* XXX: clear VIF/VIP in all ops ? */
|
1375 | 2c0262af | bellard | |
1376 | 2c0262af | bellard | void OPPROTO op_movl_eflags_T0(void) |
1377 | 2c0262af | bellard | { |
1378 | 4b7aba51 | bellard | load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK)); |
1379 | 2c0262af | bellard | } |
1380 | 2c0262af | bellard | |
1381 | 2c0262af | bellard | void OPPROTO op_movw_eflags_T0(void) |
1382 | 2c0262af | bellard | { |
1383 | 4b7aba51 | bellard | load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK) & 0xffff);
|
1384 | 4136f33c | bellard | } |
1385 | 4136f33c | bellard | |
1386 | 4136f33c | bellard | void OPPROTO op_movl_eflags_T0_io(void) |
1387 | 4136f33c | bellard | { |
1388 | 4b7aba51 | bellard | load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK)); |
1389 | 4136f33c | bellard | } |
1390 | 4136f33c | bellard | |
1391 | 4136f33c | bellard | void OPPROTO op_movw_eflags_T0_io(void) |
1392 | 4136f33c | bellard | { |
1393 | 4b7aba51 | bellard | load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK) & 0xffff);
|
1394 | 2c0262af | bellard | } |
1395 | 2c0262af | bellard | |
1396 | 2c0262af | bellard | void OPPROTO op_movl_eflags_T0_cpl0(void) |
1397 | 2c0262af | bellard | { |
1398 | 4b7aba51 | bellard | load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK)); |
1399 | 2c0262af | bellard | } |
1400 | 2c0262af | bellard | |
1401 | 2c0262af | bellard | void OPPROTO op_movw_eflags_T0_cpl0(void) |
1402 | 2c0262af | bellard | { |
1403 | 4b7aba51 | bellard | load_eflags(T0, (TF_MASK | AC_MASK | ID_MASK | NT_MASK | IF_MASK | IOPL_MASK) & 0xffff);
|
1404 | 2c0262af | bellard | } |
1405 | 2c0262af | bellard | |
1406 | 2c0262af | bellard | #if 0
|
1407 | 2c0262af | bellard | /* vm86plus version */
|
1408 | 2c0262af | bellard | void OPPROTO op_movw_eflags_T0_vm(void)
|
1409 | 2c0262af | bellard | {
|
1410 | 2c0262af | bellard | int eflags;
|
1411 | 2c0262af | bellard | eflags = T0;
|
1412 | 2c0262af | bellard | CC_SRC = eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
1413 | 2c0262af | bellard | DF = 1 - (2 * ((eflags >> 10) & 1));
|
1414 | 2c0262af | bellard | /* we also update some system flags as in user mode */
|
1415 | 2c0262af | bellard | env->eflags = (env->eflags & ~(FL_UPDATE_MASK16 | VIF_MASK)) |
|
1416 | 2c0262af | bellard | (eflags & FL_UPDATE_MASK16);
|
1417 | 2c0262af | bellard | if (eflags & IF_MASK) {
|
1418 | 2c0262af | bellard | env->eflags |= VIF_MASK;
|
1419 | 2c0262af | bellard | if (env->eflags & VIP_MASK) {
|
1420 | 2c0262af | bellard | EIP = PARAM1;
|
1421 | 2c0262af | bellard | raise_exception(EXCP0D_GPF);
|
1422 | 2c0262af | bellard | }
|
1423 | 2c0262af | bellard | }
|
1424 | 2c0262af | bellard | FORCE_RET();
|
1425 | 2c0262af | bellard | }
|
1426 | 2c0262af | bellard | |
1427 | 2c0262af | bellard | void OPPROTO op_movl_eflags_T0_vm(void)
|
1428 | 2c0262af | bellard | {
|
1429 | 2c0262af | bellard | int eflags;
|
1430 | 2c0262af | bellard | eflags = T0;
|
1431 | 2c0262af | bellard | CC_SRC = eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
|
1432 | 2c0262af | bellard | DF = 1 - (2 * ((eflags >> 10) & 1));
|
1433 | 2c0262af | bellard | /* we also update some system flags as in user mode */
|
1434 | 2c0262af | bellard | env->eflags = (env->eflags & ~(FL_UPDATE_MASK32 | VIF_MASK)) |
|
1435 | 2c0262af | bellard | (eflags & FL_UPDATE_MASK32);
|
1436 | 2c0262af | bellard | if (eflags & IF_MASK) {
|
1437 | 2c0262af | bellard | env->eflags |= VIF_MASK;
|
1438 | 2c0262af | bellard | if (env->eflags & VIP_MASK) {
|
1439 | 2c0262af | bellard | EIP = PARAM1;
|
1440 | 2c0262af | bellard | raise_exception(EXCP0D_GPF);
|
1441 | 2c0262af | bellard | }
|
1442 | 2c0262af | bellard | }
|
1443 | 2c0262af | bellard | FORCE_RET();
|
1444 | 2c0262af | bellard | }
|
1445 | 2c0262af | bellard | #endif
|
1446 | 2c0262af | bellard | |
1447 | 2c0262af | bellard | /* XXX: compute only O flag */
|
1448 | 2c0262af | bellard | void OPPROTO op_movb_eflags_T0(void) |
1449 | 2c0262af | bellard | { |
1450 | 2c0262af | bellard | int of;
|
1451 | 2c0262af | bellard | of = cc_table[CC_OP].compute_all() & CC_O; |
1452 | 2c0262af | bellard | CC_SRC = (T0 & (CC_S | CC_Z | CC_A | CC_P | CC_C)) | of; |
1453 | 2c0262af | bellard | } |
1454 | 2c0262af | bellard | |
1455 | 2c0262af | bellard | void OPPROTO op_movl_T0_eflags(void) |
1456 | 2c0262af | bellard | { |
1457 | 2c0262af | bellard | int eflags;
|
1458 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1459 | 2c0262af | bellard | eflags |= (DF & DF_MASK); |
1460 | 2c0262af | bellard | eflags |= env->eflags & ~(VM_MASK | RF_MASK); |
1461 | 2c0262af | bellard | T0 = eflags; |
1462 | 2c0262af | bellard | } |
1463 | 2c0262af | bellard | |
1464 | 2c0262af | bellard | /* vm86plus version */
|
1465 | 2c0262af | bellard | #if 0
|
1466 | 2c0262af | bellard | void OPPROTO op_movl_T0_eflags_vm(void)
|
1467 | 2c0262af | bellard | {
|
1468 | 2c0262af | bellard | int eflags;
|
1469 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all();
|
1470 | 2c0262af | bellard | eflags |= (DF & DF_MASK);
|
1471 | 2c0262af | bellard | eflags |= env->eflags & ~(VM_MASK | RF_MASK | IF_MASK);
|
1472 | 2c0262af | bellard | if (env->eflags & VIF_MASK)
|
1473 | 2c0262af | bellard | eflags |= IF_MASK;
|
1474 | 2c0262af | bellard | T0 = eflags;
|
1475 | 2c0262af | bellard | }
|
1476 | 2c0262af | bellard | #endif
|
1477 | 2c0262af | bellard | |
1478 | 2c0262af | bellard | void OPPROTO op_cld(void) |
1479 | 2c0262af | bellard | { |
1480 | 2c0262af | bellard | DF = 1;
|
1481 | 2c0262af | bellard | } |
1482 | 2c0262af | bellard | |
1483 | 2c0262af | bellard | void OPPROTO op_std(void) |
1484 | 2c0262af | bellard | { |
1485 | 2c0262af | bellard | DF = -1;
|
1486 | 2c0262af | bellard | } |
1487 | 2c0262af | bellard | |
1488 | 2c0262af | bellard | void OPPROTO op_clc(void) |
1489 | 2c0262af | bellard | { |
1490 | 2c0262af | bellard | int eflags;
|
1491 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1492 | 2c0262af | bellard | eflags &= ~CC_C; |
1493 | 2c0262af | bellard | CC_SRC = eflags; |
1494 | 2c0262af | bellard | } |
1495 | 2c0262af | bellard | |
1496 | 2c0262af | bellard | void OPPROTO op_stc(void) |
1497 | 2c0262af | bellard | { |
1498 | 2c0262af | bellard | int eflags;
|
1499 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1500 | 2c0262af | bellard | eflags |= CC_C; |
1501 | 2c0262af | bellard | CC_SRC = eflags; |
1502 | 2c0262af | bellard | } |
1503 | 2c0262af | bellard | |
1504 | 2c0262af | bellard | void OPPROTO op_cmc(void) |
1505 | 2c0262af | bellard | { |
1506 | 2c0262af | bellard | int eflags;
|
1507 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1508 | 2c0262af | bellard | eflags ^= CC_C; |
1509 | 2c0262af | bellard | CC_SRC = eflags; |
1510 | 2c0262af | bellard | } |
1511 | 2c0262af | bellard | |
1512 | 2c0262af | bellard | void OPPROTO op_salc(void) |
1513 | 2c0262af | bellard | { |
1514 | 2c0262af | bellard | int cf;
|
1515 | 2c0262af | bellard | cf = cc_table[CC_OP].compute_c(); |
1516 | 2c0262af | bellard | EAX = (EAX & ~0xff) | ((-cf) & 0xff); |
1517 | 2c0262af | bellard | } |
1518 | 2c0262af | bellard | |
1519 | 2c0262af | bellard | static int compute_all_eflags(void) |
1520 | 2c0262af | bellard | { |
1521 | 2c0262af | bellard | return CC_SRC;
|
1522 | 2c0262af | bellard | } |
1523 | 2c0262af | bellard | |
1524 | 2c0262af | bellard | static int compute_c_eflags(void) |
1525 | 2c0262af | bellard | { |
1526 | 2c0262af | bellard | return CC_SRC & CC_C;
|
1527 | 2c0262af | bellard | } |
1528 | 2c0262af | bellard | |
1529 | 2c0262af | bellard | CCTable cc_table[CC_OP_NB] = { |
1530 | 2c0262af | bellard | [CC_OP_DYNAMIC] = { /* should never happen */ },
|
1531 | 2c0262af | bellard | |
1532 | 2c0262af | bellard | [CC_OP_EFLAGS] = { compute_all_eflags, compute_c_eflags }, |
1533 | 2c0262af | bellard | |
1534 | d36cd60e | bellard | [CC_OP_MULB] = { compute_all_mulb, compute_c_mull }, |
1535 | d36cd60e | bellard | [CC_OP_MULW] = { compute_all_mulw, compute_c_mull }, |
1536 | d36cd60e | bellard | [CC_OP_MULL] = { compute_all_mull, compute_c_mull }, |
1537 | 2c0262af | bellard | |
1538 | 2c0262af | bellard | [CC_OP_ADDB] = { compute_all_addb, compute_c_addb }, |
1539 | 2c0262af | bellard | [CC_OP_ADDW] = { compute_all_addw, compute_c_addw }, |
1540 | 2c0262af | bellard | [CC_OP_ADDL] = { compute_all_addl, compute_c_addl }, |
1541 | 2c0262af | bellard | |
1542 | 2c0262af | bellard | [CC_OP_ADCB] = { compute_all_adcb, compute_c_adcb }, |
1543 | 2c0262af | bellard | [CC_OP_ADCW] = { compute_all_adcw, compute_c_adcw }, |
1544 | 2c0262af | bellard | [CC_OP_ADCL] = { compute_all_adcl, compute_c_adcl }, |
1545 | 2c0262af | bellard | |
1546 | 2c0262af | bellard | [CC_OP_SUBB] = { compute_all_subb, compute_c_subb }, |
1547 | 2c0262af | bellard | [CC_OP_SUBW] = { compute_all_subw, compute_c_subw }, |
1548 | 2c0262af | bellard | [CC_OP_SUBL] = { compute_all_subl, compute_c_subl }, |
1549 | 2c0262af | bellard | |
1550 | 2c0262af | bellard | [CC_OP_SBBB] = { compute_all_sbbb, compute_c_sbbb }, |
1551 | 2c0262af | bellard | [CC_OP_SBBW] = { compute_all_sbbw, compute_c_sbbw }, |
1552 | 2c0262af | bellard | [CC_OP_SBBL] = { compute_all_sbbl, compute_c_sbbl }, |
1553 | 2c0262af | bellard | |
1554 | 2c0262af | bellard | [CC_OP_LOGICB] = { compute_all_logicb, compute_c_logicb }, |
1555 | 2c0262af | bellard | [CC_OP_LOGICW] = { compute_all_logicw, compute_c_logicw }, |
1556 | 2c0262af | bellard | [CC_OP_LOGICL] = { compute_all_logicl, compute_c_logicl }, |
1557 | 2c0262af | bellard | |
1558 | 2c0262af | bellard | [CC_OP_INCB] = { compute_all_incb, compute_c_incl }, |
1559 | 2c0262af | bellard | [CC_OP_INCW] = { compute_all_incw, compute_c_incl }, |
1560 | 2c0262af | bellard | [CC_OP_INCL] = { compute_all_incl, compute_c_incl }, |
1561 | 2c0262af | bellard | |
1562 | 2c0262af | bellard | [CC_OP_DECB] = { compute_all_decb, compute_c_incl }, |
1563 | 2c0262af | bellard | [CC_OP_DECW] = { compute_all_decw, compute_c_incl }, |
1564 | 2c0262af | bellard | [CC_OP_DECL] = { compute_all_decl, compute_c_incl }, |
1565 | 2c0262af | bellard | |
1566 | 2c0262af | bellard | [CC_OP_SHLB] = { compute_all_shlb, compute_c_shlb }, |
1567 | 2c0262af | bellard | [CC_OP_SHLW] = { compute_all_shlw, compute_c_shlw }, |
1568 | 2c0262af | bellard | [CC_OP_SHLL] = { compute_all_shll, compute_c_shll }, |
1569 | 2c0262af | bellard | |
1570 | 2c0262af | bellard | [CC_OP_SARB] = { compute_all_sarb, compute_c_sarl }, |
1571 | 2c0262af | bellard | [CC_OP_SARW] = { compute_all_sarw, compute_c_sarl }, |
1572 | 2c0262af | bellard | [CC_OP_SARL] = { compute_all_sarl, compute_c_sarl }, |
1573 | 14ce26e7 | bellard | |
1574 | 14ce26e7 | bellard | #ifdef TARGET_X86_64
|
1575 | 14ce26e7 | bellard | [CC_OP_MULQ] = { compute_all_mulq, compute_c_mull }, |
1576 | 14ce26e7 | bellard | |
1577 | 14ce26e7 | bellard | [CC_OP_ADDQ] = { compute_all_addq, compute_c_addq }, |
1578 | 14ce26e7 | bellard | |
1579 | 14ce26e7 | bellard | [CC_OP_ADCQ] = { compute_all_adcq, compute_c_adcq }, |
1580 | 14ce26e7 | bellard | |
1581 | 14ce26e7 | bellard | [CC_OP_SUBQ] = { compute_all_subq, compute_c_subq }, |
1582 | 14ce26e7 | bellard | |
1583 | 14ce26e7 | bellard | [CC_OP_SBBQ] = { compute_all_sbbq, compute_c_sbbq }, |
1584 | 14ce26e7 | bellard | |
1585 | 14ce26e7 | bellard | [CC_OP_LOGICQ] = { compute_all_logicq, compute_c_logicq }, |
1586 | 14ce26e7 | bellard | |
1587 | 14ce26e7 | bellard | [CC_OP_INCQ] = { compute_all_incq, compute_c_incl }, |
1588 | 14ce26e7 | bellard | |
1589 | 14ce26e7 | bellard | [CC_OP_DECQ] = { compute_all_decq, compute_c_incl }, |
1590 | 14ce26e7 | bellard | |
1591 | 14ce26e7 | bellard | [CC_OP_SHLQ] = { compute_all_shlq, compute_c_shlq }, |
1592 | 14ce26e7 | bellard | |
1593 | 14ce26e7 | bellard | [CC_OP_SARQ] = { compute_all_sarq, compute_c_sarl }, |
1594 | 14ce26e7 | bellard | #endif
|
1595 | 2c0262af | bellard | }; |
1596 | 2c0262af | bellard | |
1597 | 2c0262af | bellard | /* floating point support. Some of the code for complicated x87
|
1598 | 2c0262af | bellard | functions comes from the LGPL'ed x86 emulator found in the Willows
|
1599 | 2c0262af | bellard | TWIN windows emulator. */
|
1600 | 2c0262af | bellard | |
1601 | 2c0262af | bellard | #if defined(__powerpc__)
|
1602 | 2c0262af | bellard | extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble);
|
1603 | 2c0262af | bellard | |
1604 | 2c0262af | bellard | /* correct (but slow) PowerPC rint() (glibc version is incorrect) */
|
1605 | 2c0262af | bellard | double qemu_rint(double x) |
1606 | 2c0262af | bellard | { |
1607 | 2c0262af | bellard | double y = 4503599627370496.0; |
1608 | 2c0262af | bellard | if (fabs(x) >= y)
|
1609 | 2c0262af | bellard | return x;
|
1610 | 2c0262af | bellard | if (x < 0) |
1611 | 2c0262af | bellard | y = -y; |
1612 | 2c0262af | bellard | y = (x + y) - y; |
1613 | 2c0262af | bellard | if (y == 0.0) |
1614 | 2c0262af | bellard | y = copysign(y, x); |
1615 | 2c0262af | bellard | return y;
|
1616 | 2c0262af | bellard | } |
1617 | 2c0262af | bellard | |
1618 | 2c0262af | bellard | #define rint qemu_rint
|
1619 | 2c0262af | bellard | #endif
|
1620 | 2c0262af | bellard | |
1621 | 2c0262af | bellard | /* fp load FT0 */
|
1622 | 2c0262af | bellard | |
1623 | 2c0262af | bellard | void OPPROTO op_flds_FT0_A0(void) |
1624 | 2c0262af | bellard | { |
1625 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1626 | 14ce26e7 | bellard | FP_CONVERT.i32 = ldl(A0); |
1627 | 2c0262af | bellard | FT0 = FP_CONVERT.f; |
1628 | 2c0262af | bellard | #else
|
1629 | 14ce26e7 | bellard | FT0 = ldfl(A0); |
1630 | 2c0262af | bellard | #endif
|
1631 | 2c0262af | bellard | } |
1632 | 2c0262af | bellard | |
1633 | 2c0262af | bellard | void OPPROTO op_fldl_FT0_A0(void) |
1634 | 2c0262af | bellard | { |
1635 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1636 | 14ce26e7 | bellard | FP_CONVERT.i64 = ldq(A0); |
1637 | 2c0262af | bellard | FT0 = FP_CONVERT.d; |
1638 | 2c0262af | bellard | #else
|
1639 | 14ce26e7 | bellard | FT0 = ldfq(A0); |
1640 | 2c0262af | bellard | #endif
|
1641 | 2c0262af | bellard | } |
1642 | 2c0262af | bellard | |
1643 | 2c0262af | bellard | /* helpers are needed to avoid static constant reference. XXX: find a better way */
|
1644 | 2c0262af | bellard | #ifdef USE_INT_TO_FLOAT_HELPERS
|
1645 | 2c0262af | bellard | |
1646 | 2c0262af | bellard | void helper_fild_FT0_A0(void) |
1647 | 2c0262af | bellard | { |
1648 | 14ce26e7 | bellard | FT0 = (CPU86_LDouble)ldsw(A0); |
1649 | 2c0262af | bellard | } |
1650 | 2c0262af | bellard | |
1651 | 2c0262af | bellard | void helper_fildl_FT0_A0(void) |
1652 | 2c0262af | bellard | { |
1653 | 14ce26e7 | bellard | FT0 = (CPU86_LDouble)((int32_t)ldl(A0)); |
1654 | 2c0262af | bellard | } |
1655 | 2c0262af | bellard | |
1656 | 2c0262af | bellard | void helper_fildll_FT0_A0(void) |
1657 | 2c0262af | bellard | { |
1658 | 14ce26e7 | bellard | FT0 = (CPU86_LDouble)((int64_t)ldq(A0)); |
1659 | 2c0262af | bellard | } |
1660 | 2c0262af | bellard | |
1661 | 2c0262af | bellard | void OPPROTO op_fild_FT0_A0(void) |
1662 | 2c0262af | bellard | { |
1663 | 2c0262af | bellard | helper_fild_FT0_A0(); |
1664 | 2c0262af | bellard | } |
1665 | 2c0262af | bellard | |
1666 | 2c0262af | bellard | void OPPROTO op_fildl_FT0_A0(void) |
1667 | 2c0262af | bellard | { |
1668 | 2c0262af | bellard | helper_fildl_FT0_A0(); |
1669 | 2c0262af | bellard | } |
1670 | 2c0262af | bellard | |
1671 | 2c0262af | bellard | void OPPROTO op_fildll_FT0_A0(void) |
1672 | 2c0262af | bellard | { |
1673 | 2c0262af | bellard | helper_fildll_FT0_A0(); |
1674 | 2c0262af | bellard | } |
1675 | 2c0262af | bellard | |
1676 | 2c0262af | bellard | #else
|
1677 | 2c0262af | bellard | |
1678 | 2c0262af | bellard | void OPPROTO op_fild_FT0_A0(void) |
1679 | 2c0262af | bellard | { |
1680 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1681 | 14ce26e7 | bellard | FP_CONVERT.i32 = ldsw(A0); |
1682 | 2c0262af | bellard | FT0 = (CPU86_LDouble)FP_CONVERT.i32; |
1683 | 2c0262af | bellard | #else
|
1684 | 14ce26e7 | bellard | FT0 = (CPU86_LDouble)ldsw(A0); |
1685 | 2c0262af | bellard | #endif
|
1686 | 2c0262af | bellard | } |
1687 | 2c0262af | bellard | |
1688 | 2c0262af | bellard | void OPPROTO op_fildl_FT0_A0(void) |
1689 | 2c0262af | bellard | { |
1690 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1691 | 14ce26e7 | bellard | FP_CONVERT.i32 = (int32_t) ldl(A0); |
1692 | 2c0262af | bellard | FT0 = (CPU86_LDouble)FP_CONVERT.i32; |
1693 | 2c0262af | bellard | #else
|
1694 | 14ce26e7 | bellard | FT0 = (CPU86_LDouble)((int32_t)ldl(A0)); |
1695 | 2c0262af | bellard | #endif
|
1696 | 2c0262af | bellard | } |
1697 | 2c0262af | bellard | |
1698 | 2c0262af | bellard | void OPPROTO op_fildll_FT0_A0(void) |
1699 | 2c0262af | bellard | { |
1700 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1701 | 14ce26e7 | bellard | FP_CONVERT.i64 = (int64_t) ldq(A0); |
1702 | 2c0262af | bellard | FT0 = (CPU86_LDouble)FP_CONVERT.i64; |
1703 | 2c0262af | bellard | #else
|
1704 | 14ce26e7 | bellard | FT0 = (CPU86_LDouble)((int64_t)ldq(A0)); |
1705 | 2c0262af | bellard | #endif
|
1706 | 2c0262af | bellard | } |
1707 | 2c0262af | bellard | #endif
|
1708 | 2c0262af | bellard | |
1709 | 2c0262af | bellard | /* fp load ST0 */
|
1710 | 2c0262af | bellard | |
1711 | 2c0262af | bellard | void OPPROTO op_flds_ST0_A0(void) |
1712 | 2c0262af | bellard | { |
1713 | 2c0262af | bellard | int new_fpstt;
|
1714 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1715 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1716 | 14ce26e7 | bellard | FP_CONVERT.i32 = ldl(A0); |
1717 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = FP_CONVERT.f; |
1718 | 2c0262af | bellard | #else
|
1719 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = ldfl(A0); |
1720 | 2c0262af | bellard | #endif
|
1721 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1722 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1723 | 2c0262af | bellard | } |
1724 | 2c0262af | bellard | |
1725 | 2c0262af | bellard | void OPPROTO op_fldl_ST0_A0(void) |
1726 | 2c0262af | bellard | { |
1727 | 2c0262af | bellard | int new_fpstt;
|
1728 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1729 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1730 | 14ce26e7 | bellard | FP_CONVERT.i64 = ldq(A0); |
1731 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = FP_CONVERT.d; |
1732 | 2c0262af | bellard | #else
|
1733 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = ldfq(A0); |
1734 | 2c0262af | bellard | #endif
|
1735 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1736 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1737 | 2c0262af | bellard | } |
1738 | 2c0262af | bellard | |
1739 | 2c0262af | bellard | void OPPROTO op_fldt_ST0_A0(void) |
1740 | 2c0262af | bellard | { |
1741 | 2c0262af | bellard | helper_fldt_ST0_A0(); |
1742 | 2c0262af | bellard | } |
1743 | 2c0262af | bellard | |
1744 | 2c0262af | bellard | /* helpers are needed to avoid static constant reference. XXX: find a better way */
|
1745 | 2c0262af | bellard | #ifdef USE_INT_TO_FLOAT_HELPERS
|
1746 | 2c0262af | bellard | |
1747 | 2c0262af | bellard | void helper_fild_ST0_A0(void) |
1748 | 2c0262af | bellard | { |
1749 | 2c0262af | bellard | int new_fpstt;
|
1750 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1751 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)ldsw(A0); |
1752 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1753 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1754 | 2c0262af | bellard | } |
1755 | 2c0262af | bellard | |
1756 | 2c0262af | bellard | void helper_fildl_ST0_A0(void) |
1757 | 2c0262af | bellard | { |
1758 | 2c0262af | bellard | int new_fpstt;
|
1759 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1760 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)((int32_t)ldl(A0)); |
1761 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1762 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1763 | 2c0262af | bellard | } |
1764 | 2c0262af | bellard | |
1765 | 2c0262af | bellard | void helper_fildll_ST0_A0(void) |
1766 | 2c0262af | bellard | { |
1767 | 2c0262af | bellard | int new_fpstt;
|
1768 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1769 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)((int64_t)ldq(A0)); |
1770 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1771 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1772 | 2c0262af | bellard | } |
1773 | 2c0262af | bellard | |
1774 | 2c0262af | bellard | void OPPROTO op_fild_ST0_A0(void) |
1775 | 2c0262af | bellard | { |
1776 | 2c0262af | bellard | helper_fild_ST0_A0(); |
1777 | 2c0262af | bellard | } |
1778 | 2c0262af | bellard | |
1779 | 2c0262af | bellard | void OPPROTO op_fildl_ST0_A0(void) |
1780 | 2c0262af | bellard | { |
1781 | 2c0262af | bellard | helper_fildl_ST0_A0(); |
1782 | 2c0262af | bellard | } |
1783 | 2c0262af | bellard | |
1784 | 2c0262af | bellard | void OPPROTO op_fildll_ST0_A0(void) |
1785 | 2c0262af | bellard | { |
1786 | 2c0262af | bellard | helper_fildll_ST0_A0(); |
1787 | 2c0262af | bellard | } |
1788 | 2c0262af | bellard | |
1789 | 2c0262af | bellard | #else
|
1790 | 2c0262af | bellard | |
1791 | 2c0262af | bellard | void OPPROTO op_fild_ST0_A0(void) |
1792 | 2c0262af | bellard | { |
1793 | 2c0262af | bellard | int new_fpstt;
|
1794 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1795 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1796 | 14ce26e7 | bellard | FP_CONVERT.i32 = ldsw(A0); |
1797 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)FP_CONVERT.i32; |
1798 | 2c0262af | bellard | #else
|
1799 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)ldsw(A0); |
1800 | 2c0262af | bellard | #endif
|
1801 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1802 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1803 | 2c0262af | bellard | } |
1804 | 2c0262af | bellard | |
1805 | 2c0262af | bellard | void OPPROTO op_fildl_ST0_A0(void) |
1806 | 2c0262af | bellard | { |
1807 | 2c0262af | bellard | int new_fpstt;
|
1808 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1809 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1810 | 14ce26e7 | bellard | FP_CONVERT.i32 = (int32_t) ldl(A0); |
1811 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)FP_CONVERT.i32; |
1812 | 2c0262af | bellard | #else
|
1813 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)((int32_t)ldl(A0)); |
1814 | 2c0262af | bellard | #endif
|
1815 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1816 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1817 | 2c0262af | bellard | } |
1818 | 2c0262af | bellard | |
1819 | 2c0262af | bellard | void OPPROTO op_fildll_ST0_A0(void) |
1820 | 2c0262af | bellard | { |
1821 | 2c0262af | bellard | int new_fpstt;
|
1822 | 2c0262af | bellard | new_fpstt = (env->fpstt - 1) & 7; |
1823 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1824 | 14ce26e7 | bellard | FP_CONVERT.i64 = (int64_t) ldq(A0); |
1825 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)FP_CONVERT.i64; |
1826 | 2c0262af | bellard | #else
|
1827 | 664e0f19 | bellard | env->fpregs[new_fpstt].d = (CPU86_LDouble)((int64_t)ldq(A0)); |
1828 | 2c0262af | bellard | #endif
|
1829 | 2c0262af | bellard | env->fpstt = new_fpstt; |
1830 | 2c0262af | bellard | env->fptags[new_fpstt] = 0; /* validate stack entry */ |
1831 | 2c0262af | bellard | } |
1832 | 2c0262af | bellard | |
1833 | 2c0262af | bellard | #endif
|
1834 | 2c0262af | bellard | |
1835 | 2c0262af | bellard | /* fp store */
|
1836 | 2c0262af | bellard | |
1837 | 2c0262af | bellard | void OPPROTO op_fsts_ST0_A0(void) |
1838 | 2c0262af | bellard | { |
1839 | 2c0262af | bellard | #ifdef USE_FP_CONVERT
|
1840 | 2c0262af | bellard | FP_CONVERT.f = (float)ST0;
|
1841 | 14ce26e7 | bellard | stfl(A0, FP_CONVERT.f); |
1842 | 2c0262af | bellard | #else
|
1843 | 14ce26e7 | bellard | stfl(A0, (float)ST0);
|
1844 | 2c0262af | bellard | #endif
|
1845 | 2c0262af | bellard | } |
1846 | 2c0262af | bellard | |
1847 | 2c0262af | bellard | void OPPROTO op_fstl_ST0_A0(void) |
1848 | 2c0262af | bellard | { |
1849 | 14ce26e7 | bellard | stfq(A0, (double)ST0);
|
1850 | 2c0262af | bellard | } |
1851 | 2c0262af | bellard | |
1852 | 2c0262af | bellard | void OPPROTO op_fstt_ST0_A0(void) |
1853 | 2c0262af | bellard | { |
1854 | 2c0262af | bellard | helper_fstt_ST0_A0(); |
1855 | 2c0262af | bellard | } |
1856 | 2c0262af | bellard | |
1857 | 2c0262af | bellard | void OPPROTO op_fist_ST0_A0(void) |
1858 | 2c0262af | bellard | { |
1859 | 2c0262af | bellard | #if defined(__sparc__) && !defined(__sparc_v9__)
|
1860 | 2c0262af | bellard | register CPU86_LDouble d asm("o0"); |
1861 | 2c0262af | bellard | #else
|
1862 | 2c0262af | bellard | CPU86_LDouble d; |
1863 | 2c0262af | bellard | #endif
|
1864 | 2c0262af | bellard | int val;
|
1865 | 2c0262af | bellard | |
1866 | 2c0262af | bellard | d = ST0; |
1867 | 2c0262af | bellard | val = lrint(d); |
1868 | 2c0262af | bellard | if (val != (int16_t)val)
|
1869 | 2c0262af | bellard | val = -32768;
|
1870 | 14ce26e7 | bellard | stw(A0, val); |
1871 | 2c0262af | bellard | } |
1872 | 2c0262af | bellard | |
1873 | 2c0262af | bellard | void OPPROTO op_fistl_ST0_A0(void) |
1874 | 2c0262af | bellard | { |
1875 | 2c0262af | bellard | #if defined(__sparc__) && !defined(__sparc_v9__)
|
1876 | 2c0262af | bellard | register CPU86_LDouble d asm("o0"); |
1877 | 2c0262af | bellard | #else
|
1878 | 2c0262af | bellard | CPU86_LDouble d; |
1879 | 2c0262af | bellard | #endif
|
1880 | 2c0262af | bellard | int val;
|
1881 | 2c0262af | bellard | |
1882 | 2c0262af | bellard | d = ST0; |
1883 | 2c0262af | bellard | val = lrint(d); |
1884 | 14ce26e7 | bellard | stl(A0, val); |
1885 | 2c0262af | bellard | } |
1886 | 2c0262af | bellard | |
1887 | 2c0262af | bellard | void OPPROTO op_fistll_ST0_A0(void) |
1888 | 2c0262af | bellard | { |
1889 | 2c0262af | bellard | #if defined(__sparc__) && !defined(__sparc_v9__)
|
1890 | 2c0262af | bellard | register CPU86_LDouble d asm("o0"); |
1891 | 2c0262af | bellard | #else
|
1892 | 2c0262af | bellard | CPU86_LDouble d; |
1893 | 2c0262af | bellard | #endif
|
1894 | 2c0262af | bellard | int64_t val; |
1895 | 2c0262af | bellard | |
1896 | 2c0262af | bellard | d = ST0; |
1897 | 2c0262af | bellard | val = llrint(d); |
1898 | 14ce26e7 | bellard | stq(A0, val); |
1899 | 2c0262af | bellard | } |
1900 | 2c0262af | bellard | |
1901 | 2c0262af | bellard | void OPPROTO op_fbld_ST0_A0(void) |
1902 | 2c0262af | bellard | { |
1903 | 2c0262af | bellard | helper_fbld_ST0_A0(); |
1904 | 2c0262af | bellard | } |
1905 | 2c0262af | bellard | |
1906 | 2c0262af | bellard | void OPPROTO op_fbst_ST0_A0(void) |
1907 | 2c0262af | bellard | { |
1908 | 2c0262af | bellard | helper_fbst_ST0_A0(); |
1909 | 2c0262af | bellard | } |
1910 | 2c0262af | bellard | |
1911 | 2c0262af | bellard | /* FPU move */
|
1912 | 2c0262af | bellard | |
1913 | 2c0262af | bellard | void OPPROTO op_fpush(void) |
1914 | 2c0262af | bellard | { |
1915 | 2c0262af | bellard | fpush(); |
1916 | 2c0262af | bellard | } |
1917 | 2c0262af | bellard | |
1918 | 2c0262af | bellard | void OPPROTO op_fpop(void) |
1919 | 2c0262af | bellard | { |
1920 | 2c0262af | bellard | fpop(); |
1921 | 2c0262af | bellard | } |
1922 | 2c0262af | bellard | |
1923 | 2c0262af | bellard | void OPPROTO op_fdecstp(void) |
1924 | 2c0262af | bellard | { |
1925 | 2c0262af | bellard | env->fpstt = (env->fpstt - 1) & 7; |
1926 | 2c0262af | bellard | env->fpus &= (~0x4700);
|
1927 | 2c0262af | bellard | } |
1928 | 2c0262af | bellard | |
1929 | 2c0262af | bellard | void OPPROTO op_fincstp(void) |
1930 | 2c0262af | bellard | { |
1931 | 2c0262af | bellard | env->fpstt = (env->fpstt + 1) & 7; |
1932 | 2c0262af | bellard | env->fpus &= (~0x4700);
|
1933 | 2c0262af | bellard | } |
1934 | 2c0262af | bellard | |
1935 | 5fef40fb | bellard | void OPPROTO op_ffree_STN(void) |
1936 | 5fef40fb | bellard | { |
1937 | 5fef40fb | bellard | env->fptags[(env->fpstt + PARAM1) & 7] = 1; |
1938 | 5fef40fb | bellard | } |
1939 | 5fef40fb | bellard | |
1940 | 2c0262af | bellard | void OPPROTO op_fmov_ST0_FT0(void) |
1941 | 2c0262af | bellard | { |
1942 | 2c0262af | bellard | ST0 = FT0; |
1943 | 2c0262af | bellard | } |
1944 | 2c0262af | bellard | |
1945 | 2c0262af | bellard | void OPPROTO op_fmov_FT0_STN(void) |
1946 | 2c0262af | bellard | { |
1947 | 2c0262af | bellard | FT0 = ST(PARAM1); |
1948 | 2c0262af | bellard | } |
1949 | 2c0262af | bellard | |
1950 | 2c0262af | bellard | void OPPROTO op_fmov_ST0_STN(void) |
1951 | 2c0262af | bellard | { |
1952 | 2c0262af | bellard | ST0 = ST(PARAM1); |
1953 | 2c0262af | bellard | } |
1954 | 2c0262af | bellard | |
1955 | 2c0262af | bellard | void OPPROTO op_fmov_STN_ST0(void) |
1956 | 2c0262af | bellard | { |
1957 | 2c0262af | bellard | ST(PARAM1) = ST0; |
1958 | 2c0262af | bellard | } |
1959 | 2c0262af | bellard | |
1960 | 2c0262af | bellard | void OPPROTO op_fxchg_ST0_STN(void) |
1961 | 2c0262af | bellard | { |
1962 | 2c0262af | bellard | CPU86_LDouble tmp; |
1963 | 2c0262af | bellard | tmp = ST(PARAM1); |
1964 | 2c0262af | bellard | ST(PARAM1) = ST0; |
1965 | 2c0262af | bellard | ST0 = tmp; |
1966 | 2c0262af | bellard | } |
1967 | 2c0262af | bellard | |
1968 | 2c0262af | bellard | /* FPU operations */
|
1969 | 2c0262af | bellard | |
1970 | 2c0262af | bellard | /* XXX: handle nans */
|
1971 | 2c0262af | bellard | void OPPROTO op_fcom_ST0_FT0(void) |
1972 | 2c0262af | bellard | { |
1973 | 2c0262af | bellard | env->fpus &= (~0x4500); /* (C3,C2,C0) <-- 000 */ |
1974 | 2c0262af | bellard | if (ST0 < FT0)
|
1975 | 2c0262af | bellard | env->fpus |= 0x100; /* (C3,C2,C0) <-- 001 */ |
1976 | 2c0262af | bellard | else if (ST0 == FT0) |
1977 | 2c0262af | bellard | env->fpus |= 0x4000; /* (C3,C2,C0) <-- 100 */ |
1978 | 2c0262af | bellard | FORCE_RET(); |
1979 | 2c0262af | bellard | } |
1980 | 2c0262af | bellard | |
1981 | 2c0262af | bellard | /* XXX: handle nans */
|
1982 | 2c0262af | bellard | void OPPROTO op_fucom_ST0_FT0(void) |
1983 | 2c0262af | bellard | { |
1984 | 2c0262af | bellard | env->fpus &= (~0x4500); /* (C3,C2,C0) <-- 000 */ |
1985 | 2c0262af | bellard | if (ST0 < FT0)
|
1986 | 2c0262af | bellard | env->fpus |= 0x100; /* (C3,C2,C0) <-- 001 */ |
1987 | 2c0262af | bellard | else if (ST0 == FT0) |
1988 | 2c0262af | bellard | env->fpus |= 0x4000; /* (C3,C2,C0) <-- 100 */ |
1989 | 2c0262af | bellard | FORCE_RET(); |
1990 | 2c0262af | bellard | } |
1991 | 2c0262af | bellard | |
1992 | 2c0262af | bellard | /* XXX: handle nans */
|
1993 | 2c0262af | bellard | void OPPROTO op_fcomi_ST0_FT0(void) |
1994 | 2c0262af | bellard | { |
1995 | 2c0262af | bellard | int eflags;
|
1996 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
1997 | 2c0262af | bellard | eflags &= ~(CC_Z | CC_P | CC_C); |
1998 | 2c0262af | bellard | if (ST0 < FT0)
|
1999 | 2c0262af | bellard | eflags |= CC_C; |
2000 | 2c0262af | bellard | else if (ST0 == FT0) |
2001 | 2c0262af | bellard | eflags |= CC_Z; |
2002 | 2c0262af | bellard | CC_SRC = eflags; |
2003 | 2c0262af | bellard | FORCE_RET(); |
2004 | 2c0262af | bellard | } |
2005 | 2c0262af | bellard | |
2006 | 2c0262af | bellard | /* XXX: handle nans */
|
2007 | 2c0262af | bellard | void OPPROTO op_fucomi_ST0_FT0(void) |
2008 | 2c0262af | bellard | { |
2009 | 2c0262af | bellard | int eflags;
|
2010 | 2c0262af | bellard | eflags = cc_table[CC_OP].compute_all(); |
2011 | 2c0262af | bellard | eflags &= ~(CC_Z | CC_P | CC_C); |
2012 | 2c0262af | bellard | if (ST0 < FT0)
|
2013 | 2c0262af | bellard | eflags |= CC_C; |
2014 | 2c0262af | bellard | else if (ST0 == FT0) |
2015 | 2c0262af | bellard | eflags |= CC_Z; |
2016 | 2c0262af | bellard | CC_SRC = eflags; |
2017 | 2c0262af | bellard | FORCE_RET(); |
2018 | 2c0262af | bellard | } |
2019 | 2c0262af | bellard | |
2020 | 80043406 | bellard | void OPPROTO op_fcmov_ST0_STN_T0(void) |
2021 | 80043406 | bellard | { |
2022 | 80043406 | bellard | if (T0) {
|
2023 | 80043406 | bellard | ST0 = ST(PARAM1); |
2024 | 80043406 | bellard | } |
2025 | 80043406 | bellard | FORCE_RET(); |
2026 | 80043406 | bellard | } |
2027 | 80043406 | bellard | |
2028 | 2c0262af | bellard | void OPPROTO op_fadd_ST0_FT0(void) |
2029 | 2c0262af | bellard | { |
2030 | 2c0262af | bellard | ST0 += FT0; |
2031 | 2c0262af | bellard | } |
2032 | 2c0262af | bellard | |
2033 | 2c0262af | bellard | void OPPROTO op_fmul_ST0_FT0(void) |
2034 | 2c0262af | bellard | { |
2035 | 2c0262af | bellard | ST0 *= FT0; |
2036 | 2c0262af | bellard | } |
2037 | 2c0262af | bellard | |
2038 | 2c0262af | bellard | void OPPROTO op_fsub_ST0_FT0(void) |
2039 | 2c0262af | bellard | { |
2040 | 2c0262af | bellard | ST0 -= FT0; |
2041 | 2c0262af | bellard | } |
2042 | 2c0262af | bellard | |
2043 | 2c0262af | bellard | void OPPROTO op_fsubr_ST0_FT0(void) |
2044 | 2c0262af | bellard | { |
2045 | 2c0262af | bellard | ST0 = FT0 - ST0; |
2046 | 2c0262af | bellard | } |
2047 | 2c0262af | bellard | |
2048 | 2c0262af | bellard | void OPPROTO op_fdiv_ST0_FT0(void) |
2049 | 2c0262af | bellard | { |
2050 | 2ee73ac3 | bellard | ST0 = helper_fdiv(ST0, FT0); |
2051 | 2c0262af | bellard | } |
2052 | 2c0262af | bellard | |
2053 | 2c0262af | bellard | void OPPROTO op_fdivr_ST0_FT0(void) |
2054 | 2c0262af | bellard | { |
2055 | 2ee73ac3 | bellard | ST0 = helper_fdiv(FT0, ST0); |
2056 | 2c0262af | bellard | } |
2057 | 2c0262af | bellard | |
2058 | 2c0262af | bellard | /* fp operations between STN and ST0 */
|
2059 | 2c0262af | bellard | |
2060 | 2c0262af | bellard | void OPPROTO op_fadd_STN_ST0(void) |
2061 | 2c0262af | bellard | { |
2062 | 2c0262af | bellard | ST(PARAM1) += ST0; |
2063 | 2c0262af | bellard | } |
2064 | 2c0262af | bellard | |
2065 | 2c0262af | bellard | void OPPROTO op_fmul_STN_ST0(void) |
2066 | 2c0262af | bellard | { |
2067 | 2c0262af | bellard | ST(PARAM1) *= ST0; |
2068 | 2c0262af | bellard | } |
2069 | 2c0262af | bellard | |
2070 | 2c0262af | bellard | void OPPROTO op_fsub_STN_ST0(void) |
2071 | 2c0262af | bellard | { |
2072 | 2c0262af | bellard | ST(PARAM1) -= ST0; |
2073 | 2c0262af | bellard | } |
2074 | 2c0262af | bellard | |
2075 | 2c0262af | bellard | void OPPROTO op_fsubr_STN_ST0(void) |
2076 | 2c0262af | bellard | { |
2077 | 2c0262af | bellard | CPU86_LDouble *p; |
2078 | 2c0262af | bellard | p = &ST(PARAM1); |
2079 | 2c0262af | bellard | *p = ST0 - *p; |
2080 | 2c0262af | bellard | } |
2081 | 2c0262af | bellard | |
2082 | 2c0262af | bellard | void OPPROTO op_fdiv_STN_ST0(void) |
2083 | 2c0262af | bellard | { |
2084 | 2ee73ac3 | bellard | CPU86_LDouble *p; |
2085 | 2ee73ac3 | bellard | p = &ST(PARAM1); |
2086 | 2ee73ac3 | bellard | *p = helper_fdiv(*p, ST0); |
2087 | 2c0262af | bellard | } |
2088 | 2c0262af | bellard | |
2089 | 2c0262af | bellard | void OPPROTO op_fdivr_STN_ST0(void) |
2090 | 2c0262af | bellard | { |
2091 | 2c0262af | bellard | CPU86_LDouble *p; |
2092 | 2c0262af | bellard | p = &ST(PARAM1); |
2093 | 2ee73ac3 | bellard | *p = helper_fdiv(ST0, *p); |
2094 | 2c0262af | bellard | } |
2095 | 2c0262af | bellard | |
2096 | 2c0262af | bellard | /* misc FPU operations */
|
2097 | 2c0262af | bellard | void OPPROTO op_fchs_ST0(void) |
2098 | 2c0262af | bellard | { |
2099 | 2c0262af | bellard | ST0 = -ST0; |
2100 | 2c0262af | bellard | } |
2101 | 2c0262af | bellard | |
2102 | 2c0262af | bellard | void OPPROTO op_fabs_ST0(void) |
2103 | 2c0262af | bellard | { |
2104 | 2c0262af | bellard | ST0 = fabs(ST0); |
2105 | 2c0262af | bellard | } |
2106 | 2c0262af | bellard | |
2107 | 2c0262af | bellard | void OPPROTO op_fxam_ST0(void) |
2108 | 2c0262af | bellard | { |
2109 | 2c0262af | bellard | helper_fxam_ST0(); |
2110 | 2c0262af | bellard | } |
2111 | 2c0262af | bellard | |
2112 | 2c0262af | bellard | void OPPROTO op_fld1_ST0(void) |
2113 | 2c0262af | bellard | { |
2114 | 2c0262af | bellard | ST0 = f15rk[1];
|
2115 | 2c0262af | bellard | } |
2116 | 2c0262af | bellard | |
2117 | 2c0262af | bellard | void OPPROTO op_fldl2t_ST0(void) |
2118 | 2c0262af | bellard | { |
2119 | 2c0262af | bellard | ST0 = f15rk[6];
|
2120 | 2c0262af | bellard | } |
2121 | 2c0262af | bellard | |
2122 | 2c0262af | bellard | void OPPROTO op_fldl2e_ST0(void) |
2123 | 2c0262af | bellard | { |
2124 | 2c0262af | bellard | ST0 = f15rk[5];
|
2125 | 2c0262af | bellard | } |
2126 | 2c0262af | bellard | |
2127 | 2c0262af | bellard | void OPPROTO op_fldpi_ST0(void) |
2128 | 2c0262af | bellard | { |
2129 | 2c0262af | bellard | ST0 = f15rk[2];
|
2130 | 2c0262af | bellard | } |
2131 | 2c0262af | bellard | |
2132 | 2c0262af | bellard | void OPPROTO op_fldlg2_ST0(void) |
2133 | 2c0262af | bellard | { |
2134 | 2c0262af | bellard | ST0 = f15rk[3];
|
2135 | 2c0262af | bellard | } |
2136 | 2c0262af | bellard | |
2137 | 2c0262af | bellard | void OPPROTO op_fldln2_ST0(void) |
2138 | 2c0262af | bellard | { |
2139 | 2c0262af | bellard | ST0 = f15rk[4];
|
2140 | 2c0262af | bellard | } |
2141 | 2c0262af | bellard | |
2142 | 2c0262af | bellard | void OPPROTO op_fldz_ST0(void) |
2143 | 2c0262af | bellard | { |
2144 | 2c0262af | bellard | ST0 = f15rk[0];
|
2145 | 2c0262af | bellard | } |
2146 | 2c0262af | bellard | |
2147 | 2c0262af | bellard | void OPPROTO op_fldz_FT0(void) |
2148 | 2c0262af | bellard | { |
2149 | 6a8c397d | bellard | FT0 = f15rk[0];
|
2150 | 2c0262af | bellard | } |
2151 | 2c0262af | bellard | |
2152 | 2c0262af | bellard | /* associated heplers to reduce generated code length and to simplify
|
2153 | 2c0262af | bellard | relocation (FP constants are usually stored in .rodata section) */
|
2154 | 2c0262af | bellard | |
2155 | 2c0262af | bellard | void OPPROTO op_f2xm1(void) |
2156 | 2c0262af | bellard | { |
2157 | 2c0262af | bellard | helper_f2xm1(); |
2158 | 2c0262af | bellard | } |
2159 | 2c0262af | bellard | |
2160 | 2c0262af | bellard | void OPPROTO op_fyl2x(void) |
2161 | 2c0262af | bellard | { |
2162 | 2c0262af | bellard | helper_fyl2x(); |
2163 | 2c0262af | bellard | } |
2164 | 2c0262af | bellard | |
2165 | 2c0262af | bellard | void OPPROTO op_fptan(void) |
2166 | 2c0262af | bellard | { |
2167 | 2c0262af | bellard | helper_fptan(); |
2168 | 2c0262af | bellard | } |
2169 | 2c0262af | bellard | |
2170 | 2c0262af | bellard | void OPPROTO op_fpatan(void) |
2171 | 2c0262af | bellard | { |
2172 | 2c0262af | bellard | helper_fpatan(); |
2173 | 2c0262af | bellard | } |
2174 | 2c0262af | bellard | |
2175 | 2c0262af | bellard | void OPPROTO op_fxtract(void) |
2176 | 2c0262af | bellard | { |
2177 | 2c0262af | bellard | helper_fxtract(); |
2178 | 2c0262af | bellard | } |
2179 | 2c0262af | bellard | |
2180 | 2c0262af | bellard | void OPPROTO op_fprem1(void) |
2181 | 2c0262af | bellard | { |
2182 | 2c0262af | bellard | helper_fprem1(); |
2183 | 2c0262af | bellard | } |
2184 | 2c0262af | bellard | |
2185 | 2c0262af | bellard | |
2186 | 2c0262af | bellard | void OPPROTO op_fprem(void) |
2187 | 2c0262af | bellard | { |
2188 | 2c0262af | bellard | helper_fprem(); |
2189 | 2c0262af | bellard | } |
2190 | 2c0262af | bellard | |
2191 | 2c0262af | bellard | void OPPROTO op_fyl2xp1(void) |
2192 | 2c0262af | bellard | { |
2193 | 2c0262af | bellard | helper_fyl2xp1(); |
2194 | 2c0262af | bellard | } |
2195 | 2c0262af | bellard | |
2196 | 2c0262af | bellard | void OPPROTO op_fsqrt(void) |
2197 | 2c0262af | bellard | { |
2198 | 2c0262af | bellard | helper_fsqrt(); |
2199 | 2c0262af | bellard | } |
2200 | 2c0262af | bellard | |
2201 | 2c0262af | bellard | void OPPROTO op_fsincos(void) |
2202 | 2c0262af | bellard | { |
2203 | 2c0262af | bellard | helper_fsincos(); |
2204 | 2c0262af | bellard | } |
2205 | 2c0262af | bellard | |
2206 | 2c0262af | bellard | void OPPROTO op_frndint(void) |
2207 | 2c0262af | bellard | { |
2208 | 2c0262af | bellard | helper_frndint(); |
2209 | 2c0262af | bellard | } |
2210 | 2c0262af | bellard | |
2211 | 2c0262af | bellard | void OPPROTO op_fscale(void) |
2212 | 2c0262af | bellard | { |
2213 | 2c0262af | bellard | helper_fscale(); |
2214 | 2c0262af | bellard | } |
2215 | 2c0262af | bellard | |
2216 | 2c0262af | bellard | void OPPROTO op_fsin(void) |
2217 | 2c0262af | bellard | { |
2218 | 2c0262af | bellard | helper_fsin(); |
2219 | 2c0262af | bellard | } |
2220 | 2c0262af | bellard | |
2221 | 2c0262af | bellard | void OPPROTO op_fcos(void) |
2222 | 2c0262af | bellard | { |
2223 | 2c0262af | bellard | helper_fcos(); |
2224 | 2c0262af | bellard | } |
2225 | 2c0262af | bellard | |
2226 | 2c0262af | bellard | void OPPROTO op_fnstsw_A0(void) |
2227 | 2c0262af | bellard | { |
2228 | 2c0262af | bellard | int fpus;
|
2229 | 2c0262af | bellard | fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; |
2230 | 14ce26e7 | bellard | stw(A0, fpus); |
2231 | 2c0262af | bellard | } |
2232 | 2c0262af | bellard | |
2233 | 2c0262af | bellard | void OPPROTO op_fnstsw_EAX(void) |
2234 | 2c0262af | bellard | { |
2235 | 2c0262af | bellard | int fpus;
|
2236 | 2c0262af | bellard | fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; |
2237 | 14ce26e7 | bellard | EAX = (EAX & ~0xffff) | fpus;
|
2238 | 2c0262af | bellard | } |
2239 | 2c0262af | bellard | |
2240 | 2c0262af | bellard | void OPPROTO op_fnstcw_A0(void) |
2241 | 2c0262af | bellard | { |
2242 | 14ce26e7 | bellard | stw(A0, env->fpuc); |
2243 | 2c0262af | bellard | } |
2244 | 2c0262af | bellard | |
2245 | 2c0262af | bellard | void OPPROTO op_fldcw_A0(void) |
2246 | 2c0262af | bellard | { |
2247 | 2c0262af | bellard | int rnd_type;
|
2248 | 14ce26e7 | bellard | env->fpuc = lduw(A0); |
2249 | 2c0262af | bellard | /* set rounding mode */
|
2250 | 2c0262af | bellard | switch(env->fpuc & RC_MASK) {
|
2251 | 2c0262af | bellard | default:
|
2252 | 2c0262af | bellard | case RC_NEAR:
|
2253 | 2c0262af | bellard | rnd_type = FE_TONEAREST; |
2254 | 2c0262af | bellard | break;
|
2255 | 2c0262af | bellard | case RC_DOWN:
|
2256 | 2c0262af | bellard | rnd_type = FE_DOWNWARD; |
2257 | 2c0262af | bellard | break;
|
2258 | 2c0262af | bellard | case RC_UP:
|
2259 | 2c0262af | bellard | rnd_type = FE_UPWARD; |
2260 | 2c0262af | bellard | break;
|
2261 | 2c0262af | bellard | case RC_CHOP:
|
2262 | 2c0262af | bellard | rnd_type = FE_TOWARDZERO; |
2263 | 2c0262af | bellard | break;
|
2264 | 2c0262af | bellard | } |
2265 | 2c0262af | bellard | fesetround(rnd_type); |
2266 | 2c0262af | bellard | } |
2267 | 2c0262af | bellard | |
2268 | 2c0262af | bellard | void OPPROTO op_fclex(void) |
2269 | 2c0262af | bellard | { |
2270 | 2c0262af | bellard | env->fpus &= 0x7f00;
|
2271 | 2c0262af | bellard | } |
2272 | 2c0262af | bellard | |
2273 | 2ee73ac3 | bellard | void OPPROTO op_fwait(void) |
2274 | 2ee73ac3 | bellard | { |
2275 | 2ee73ac3 | bellard | if (env->fpus & FPUS_SE)
|
2276 | 2ee73ac3 | bellard | fpu_raise_exception(); |
2277 | 2ee73ac3 | bellard | FORCE_RET(); |
2278 | 2ee73ac3 | bellard | } |
2279 | 2ee73ac3 | bellard | |
2280 | 2c0262af | bellard | void OPPROTO op_fninit(void) |
2281 | 2c0262af | bellard | { |
2282 | 2c0262af | bellard | env->fpus = 0;
|
2283 | 2c0262af | bellard | env->fpstt = 0;
|
2284 | 2c0262af | bellard | env->fpuc = 0x37f;
|
2285 | 2c0262af | bellard | env->fptags[0] = 1; |
2286 | 2c0262af | bellard | env->fptags[1] = 1; |
2287 | 2c0262af | bellard | env->fptags[2] = 1; |
2288 | 2c0262af | bellard | env->fptags[3] = 1; |
2289 | 2c0262af | bellard | env->fptags[4] = 1; |
2290 | 2c0262af | bellard | env->fptags[5] = 1; |
2291 | 2c0262af | bellard | env->fptags[6] = 1; |
2292 | 2c0262af | bellard | env->fptags[7] = 1; |
2293 | 2c0262af | bellard | } |
2294 | 2c0262af | bellard | |
2295 | 2c0262af | bellard | void OPPROTO op_fnstenv_A0(void) |
2296 | 2c0262af | bellard | { |
2297 | 14ce26e7 | bellard | helper_fstenv(A0, PARAM1); |
2298 | 2c0262af | bellard | } |
2299 | 2c0262af | bellard | |
2300 | 2c0262af | bellard | void OPPROTO op_fldenv_A0(void) |
2301 | 2c0262af | bellard | { |
2302 | 14ce26e7 | bellard | helper_fldenv(A0, PARAM1); |
2303 | 2c0262af | bellard | } |
2304 | 2c0262af | bellard | |
2305 | 2c0262af | bellard | void OPPROTO op_fnsave_A0(void) |
2306 | 2c0262af | bellard | { |
2307 | 14ce26e7 | bellard | helper_fsave(A0, PARAM1); |
2308 | 2c0262af | bellard | } |
2309 | 2c0262af | bellard | |
2310 | 2c0262af | bellard | void OPPROTO op_frstor_A0(void) |
2311 | 2c0262af | bellard | { |
2312 | 14ce26e7 | bellard | helper_frstor(A0, PARAM1); |
2313 | 2c0262af | bellard | } |
2314 | 2c0262af | bellard | |
2315 | 2c0262af | bellard | /* threading support */
|
2316 | 2c0262af | bellard | void OPPROTO op_lock(void) |
2317 | 2c0262af | bellard | { |
2318 | 2c0262af | bellard | cpu_lock(); |
2319 | 2c0262af | bellard | } |
2320 | 2c0262af | bellard | |
2321 | 2c0262af | bellard | void OPPROTO op_unlock(void) |
2322 | 2c0262af | bellard | { |
2323 | 2c0262af | bellard | cpu_unlock(); |
2324 | 2c0262af | bellard | } |
2325 | 2c0262af | bellard | |
2326 | 14ce26e7 | bellard | /* SSE support */
|
2327 | 14ce26e7 | bellard | static inline void memcpy16(void *d, void *s) |
2328 | 14ce26e7 | bellard | { |
2329 | 14ce26e7 | bellard | ((uint32_t *)d)[0] = ((uint32_t *)s)[0]; |
2330 | 14ce26e7 | bellard | ((uint32_t *)d)[1] = ((uint32_t *)s)[1]; |
2331 | 14ce26e7 | bellard | ((uint32_t *)d)[2] = ((uint32_t *)s)[2]; |
2332 | 14ce26e7 | bellard | ((uint32_t *)d)[3] = ((uint32_t *)s)[3]; |
2333 | 14ce26e7 | bellard | } |
2334 | 14ce26e7 | bellard | |
2335 | 14ce26e7 | bellard | void OPPROTO op_movo(void) |
2336 | 14ce26e7 | bellard | { |
2337 | 14ce26e7 | bellard | /* XXX: badly generated code */
|
2338 | 14ce26e7 | bellard | XMMReg *d, *s; |
2339 | 14ce26e7 | bellard | d = (XMMReg *)((char *)env + PARAM1);
|
2340 | 14ce26e7 | bellard | s = (XMMReg *)((char *)env + PARAM2);
|
2341 | 14ce26e7 | bellard | memcpy16(d, s); |
2342 | 14ce26e7 | bellard | } |
2343 | 14ce26e7 | bellard | |
2344 | 664e0f19 | bellard | void OPPROTO op_movq(void) |
2345 | 664e0f19 | bellard | { |
2346 | 664e0f19 | bellard | uint64_t *d, *s; |
2347 | 664e0f19 | bellard | d = (uint64_t *)((char *)env + PARAM1);
|
2348 | 664e0f19 | bellard | s = (uint64_t *)((char *)env + PARAM2);
|
2349 | 664e0f19 | bellard | *d = *s; |
2350 | 664e0f19 | bellard | } |
2351 | 664e0f19 | bellard | |
2352 | 664e0f19 | bellard | void OPPROTO op_movl(void) |
2353 | 664e0f19 | bellard | { |
2354 | 664e0f19 | bellard | uint32_t *d, *s; |
2355 | 664e0f19 | bellard | d = (uint32_t *)((char *)env + PARAM1);
|
2356 | 664e0f19 | bellard | s = (uint32_t *)((char *)env + PARAM2);
|
2357 | 664e0f19 | bellard | *d = *s; |
2358 | 664e0f19 | bellard | } |
2359 | 664e0f19 | bellard | |
2360 | 664e0f19 | bellard | void OPPROTO op_movq_env_0(void) |
2361 | 664e0f19 | bellard | { |
2362 | 664e0f19 | bellard | uint64_t *d; |
2363 | 664e0f19 | bellard | d = (uint64_t *)((char *)env + PARAM1);
|
2364 | 664e0f19 | bellard | *d = 0;
|
2365 | 664e0f19 | bellard | } |
2366 | 664e0f19 | bellard | |
2367 | 14ce26e7 | bellard | void OPPROTO op_fxsave_A0(void) |
2368 | 14ce26e7 | bellard | { |
2369 | 14ce26e7 | bellard | helper_fxsave(A0, PARAM1); |
2370 | 14ce26e7 | bellard | } |
2371 | 14ce26e7 | bellard | |
2372 | 14ce26e7 | bellard | void OPPROTO op_fxrstor_A0(void) |
2373 | 14ce26e7 | bellard | { |
2374 | 14ce26e7 | bellard | helper_fxrstor(A0, PARAM1); |
2375 | 14ce26e7 | bellard | } |
2376 | 664e0f19 | bellard | |
2377 | 664e0f19 | bellard | /* XXX: optimize by storing fptt and fptags in the static cpu state */
|
2378 | 664e0f19 | bellard | void OPPROTO op_enter_mmx(void) |
2379 | 664e0f19 | bellard | { |
2380 | 664e0f19 | bellard | env->fpstt = 0;
|
2381 | 664e0f19 | bellard | *(uint32_t *)(env->fptags) = 0;
|
2382 | 664e0f19 | bellard | *(uint32_t *)(env->fptags + 4) = 0; |
2383 | 664e0f19 | bellard | } |
2384 | 664e0f19 | bellard | |
2385 | 664e0f19 | bellard | void OPPROTO op_emms(void) |
2386 | 664e0f19 | bellard | { |
2387 | 664e0f19 | bellard | /* set to empty state */
|
2388 | 664e0f19 | bellard | *(uint32_t *)(env->fptags) = 0x01010101;
|
2389 | 664e0f19 | bellard | *(uint32_t *)(env->fptags + 4) = 0x01010101; |
2390 | 664e0f19 | bellard | } |
2391 | 664e0f19 | bellard | |
2392 | 664e0f19 | bellard | #define SHIFT 0 |
2393 | 664e0f19 | bellard | #include "ops_sse.h" |
2394 | 664e0f19 | bellard | |
2395 | 664e0f19 | bellard | #define SHIFT 1 |
2396 | 664e0f19 | bellard | #include "ops_sse.h" |