Statistics
| Branch: | Revision:

root / target-mips / op.c @ 60445285

History | View | Annotate | Download (58.2 kB)

1 6af0bf9c bellard
/*
2 6af0bf9c bellard
 *  MIPS emulation micro-operations for qemu.
3 5fafdf24 ths
 *
4 6af0bf9c bellard
 *  Copyright (c) 2004-2005 Jocelyn Mayer
5 6ea83fed bellard
 *  Copyright (c) 2006 Marius Groeger (FPU operations)
6 93b12ccc ths
 *  Copyright (c) 2007 Thiemo Seufer (64-bit FPU support)
7 6af0bf9c bellard
 *
8 6af0bf9c bellard
 * This library is free software; you can redistribute it and/or
9 6af0bf9c bellard
 * modify it under the terms of the GNU Lesser General Public
10 6af0bf9c bellard
 * License as published by the Free Software Foundation; either
11 6af0bf9c bellard
 * version 2 of the License, or (at your option) any later version.
12 6af0bf9c bellard
 *
13 6af0bf9c bellard
 * This library is distributed in the hope that it will be useful,
14 6af0bf9c bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 6af0bf9c bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 6af0bf9c bellard
 * Lesser General Public License for more details.
17 6af0bf9c bellard
 *
18 6af0bf9c bellard
 * You should have received a copy of the GNU Lesser General Public
19 6af0bf9c bellard
 * License along with this library; if not, write to the Free Software
20 6af0bf9c bellard
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 6af0bf9c bellard
 */
22 6af0bf9c bellard
23 6af0bf9c bellard
#include "config.h"
24 6af0bf9c bellard
#include "exec.h"
25 6af0bf9c bellard
26 1b351e52 bellard
#ifndef CALL_FROM_TB0
27 5a5012ec ths
#define CALL_FROM_TB0(func) func()
28 1b351e52 bellard
#endif
29 1b351e52 bellard
#ifndef CALL_FROM_TB1
30 5a5012ec ths
#define CALL_FROM_TB1(func, arg0) func(arg0)
31 1b351e52 bellard
#endif
32 1b351e52 bellard
#ifndef CALL_FROM_TB1_CONST16
33 5a5012ec ths
#define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0)
34 1b351e52 bellard
#endif
35 1b351e52 bellard
#ifndef CALL_FROM_TB2
36 5a5012ec ths
#define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1)
37 1b351e52 bellard
#endif
38 1b351e52 bellard
#ifndef CALL_FROM_TB2_CONST16
39 1b351e52 bellard
#define CALL_FROM_TB2_CONST16(func, arg0, arg1)     \
40 5a5012ec ths
        CALL_FROM_TB2(func, arg0, arg1)
41 1b351e52 bellard
#endif
42 1b351e52 bellard
#ifndef CALL_FROM_TB3
43 5a5012ec ths
#define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2)
44 1b351e52 bellard
#endif
45 1b351e52 bellard
#ifndef CALL_FROM_TB4
46 1b351e52 bellard
#define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \
47 5a5012ec ths
        func(arg0, arg1, arg2, arg3)
48 1b351e52 bellard
#endif
49 1b351e52 bellard
50 6af0bf9c bellard
#define REG 1
51 6af0bf9c bellard
#include "op_template.c"
52 6af0bf9c bellard
#undef REG
53 6af0bf9c bellard
#define REG 2
54 6af0bf9c bellard
#include "op_template.c"
55 6af0bf9c bellard
#undef REG
56 6af0bf9c bellard
#define REG 3
57 6af0bf9c bellard
#include "op_template.c"
58 6af0bf9c bellard
#undef REG
59 6af0bf9c bellard
#define REG 4
60 6af0bf9c bellard
#include "op_template.c"
61 6af0bf9c bellard
#undef REG
62 6af0bf9c bellard
#define REG 5
63 6af0bf9c bellard
#include "op_template.c"
64 6af0bf9c bellard
#undef REG
65 6af0bf9c bellard
#define REG 6
66 6af0bf9c bellard
#include "op_template.c"
67 6af0bf9c bellard
#undef REG
68 6af0bf9c bellard
#define REG 7
69 6af0bf9c bellard
#include "op_template.c"
70 6af0bf9c bellard
#undef REG
71 6af0bf9c bellard
#define REG 8
72 6af0bf9c bellard
#include "op_template.c"
73 6af0bf9c bellard
#undef REG
74 6af0bf9c bellard
#define REG 9
75 6af0bf9c bellard
#include "op_template.c"
76 6af0bf9c bellard
#undef REG
77 6af0bf9c bellard
#define REG 10
78 6af0bf9c bellard
#include "op_template.c"
79 6af0bf9c bellard
#undef REG
80 6af0bf9c bellard
#define REG 11
81 6af0bf9c bellard
#include "op_template.c"
82 6af0bf9c bellard
#undef REG
83 6af0bf9c bellard
#define REG 12
84 6af0bf9c bellard
#include "op_template.c"
85 6af0bf9c bellard
#undef REG
86 6af0bf9c bellard
#define REG 13
87 6af0bf9c bellard
#include "op_template.c"
88 6af0bf9c bellard
#undef REG
89 6af0bf9c bellard
#define REG 14
90 6af0bf9c bellard
#include "op_template.c"
91 6af0bf9c bellard
#undef REG
92 6af0bf9c bellard
#define REG 15
93 6af0bf9c bellard
#include "op_template.c"
94 6af0bf9c bellard
#undef REG
95 6af0bf9c bellard
#define REG 16
96 6af0bf9c bellard
#include "op_template.c"
97 6af0bf9c bellard
#undef REG
98 6af0bf9c bellard
#define REG 17
99 6af0bf9c bellard
#include "op_template.c"
100 6af0bf9c bellard
#undef REG
101 6af0bf9c bellard
#define REG 18
102 6af0bf9c bellard
#include "op_template.c"
103 6af0bf9c bellard
#undef REG
104 6af0bf9c bellard
#define REG 19
105 6af0bf9c bellard
#include "op_template.c"
106 6af0bf9c bellard
#undef REG
107 6af0bf9c bellard
#define REG 20
108 6af0bf9c bellard
#include "op_template.c"
109 6af0bf9c bellard
#undef REG
110 6af0bf9c bellard
#define REG 21
111 6af0bf9c bellard
#include "op_template.c"
112 6af0bf9c bellard
#undef REG
113 6af0bf9c bellard
#define REG 22
114 6af0bf9c bellard
#include "op_template.c"
115 6af0bf9c bellard
#undef REG
116 6af0bf9c bellard
#define REG 23
117 6af0bf9c bellard
#include "op_template.c"
118 6af0bf9c bellard
#undef REG
119 6af0bf9c bellard
#define REG 24
120 6af0bf9c bellard
#include "op_template.c"
121 6af0bf9c bellard
#undef REG
122 6af0bf9c bellard
#define REG 25
123 6af0bf9c bellard
#include "op_template.c"
124 6af0bf9c bellard
#undef REG
125 6af0bf9c bellard
#define REG 26
126 6af0bf9c bellard
#include "op_template.c"
127 6af0bf9c bellard
#undef REG
128 6af0bf9c bellard
#define REG 27
129 6af0bf9c bellard
#include "op_template.c"
130 6af0bf9c bellard
#undef REG
131 6af0bf9c bellard
#define REG 28
132 6af0bf9c bellard
#include "op_template.c"
133 6af0bf9c bellard
#undef REG
134 6af0bf9c bellard
#define REG 29
135 6af0bf9c bellard
#include "op_template.c"
136 6af0bf9c bellard
#undef REG
137 6af0bf9c bellard
#define REG 30
138 6af0bf9c bellard
#include "op_template.c"
139 6af0bf9c bellard
#undef REG
140 6af0bf9c bellard
#define REG 31
141 6af0bf9c bellard
#include "op_template.c"
142 6af0bf9c bellard
#undef REG
143 6af0bf9c bellard
144 c570fd16 ths
#define TN
145 6af0bf9c bellard
#include "op_template.c"
146 6af0bf9c bellard
#undef TN
147 6af0bf9c bellard
148 5a5012ec ths
#define FREG 0
149 6ea83fed bellard
#include "fop_template.c"
150 5a5012ec ths
#undef FREG
151 5a5012ec ths
#define FREG 1
152 6ea83fed bellard
#include "fop_template.c"
153 5a5012ec ths
#undef FREG
154 5a5012ec ths
#define FREG 2
155 6ea83fed bellard
#include "fop_template.c"
156 5a5012ec ths
#undef FREG
157 5a5012ec ths
#define FREG 3
158 6ea83fed bellard
#include "fop_template.c"
159 5a5012ec ths
#undef FREG
160 5a5012ec ths
#define FREG 4
161 6ea83fed bellard
#include "fop_template.c"
162 5a5012ec ths
#undef FREG
163 5a5012ec ths
#define FREG 5
164 6ea83fed bellard
#include "fop_template.c"
165 5a5012ec ths
#undef FREG
166 5a5012ec ths
#define FREG 6
167 6ea83fed bellard
#include "fop_template.c"
168 5a5012ec ths
#undef FREG
169 5a5012ec ths
#define FREG 7
170 6ea83fed bellard
#include "fop_template.c"
171 5a5012ec ths
#undef FREG
172 5a5012ec ths
#define FREG 8
173 6ea83fed bellard
#include "fop_template.c"
174 5a5012ec ths
#undef FREG
175 5a5012ec ths
#define FREG 9
176 6ea83fed bellard
#include "fop_template.c"
177 5a5012ec ths
#undef FREG
178 5a5012ec ths
#define FREG 10
179 6ea83fed bellard
#include "fop_template.c"
180 5a5012ec ths
#undef FREG
181 5a5012ec ths
#define FREG 11
182 6ea83fed bellard
#include "fop_template.c"
183 5a5012ec ths
#undef FREG
184 5a5012ec ths
#define FREG 12
185 6ea83fed bellard
#include "fop_template.c"
186 5a5012ec ths
#undef FREG
187 5a5012ec ths
#define FREG 13
188 6ea83fed bellard
#include "fop_template.c"
189 5a5012ec ths
#undef FREG
190 5a5012ec ths
#define FREG 14
191 6ea83fed bellard
#include "fop_template.c"
192 5a5012ec ths
#undef FREG
193 5a5012ec ths
#define FREG 15
194 6ea83fed bellard
#include "fop_template.c"
195 5a5012ec ths
#undef FREG
196 5a5012ec ths
#define FREG 16
197 6ea83fed bellard
#include "fop_template.c"
198 5a5012ec ths
#undef FREG
199 5a5012ec ths
#define FREG 17
200 6ea83fed bellard
#include "fop_template.c"
201 5a5012ec ths
#undef FREG
202 5a5012ec ths
#define FREG 18
203 6ea83fed bellard
#include "fop_template.c"
204 5a5012ec ths
#undef FREG
205 5a5012ec ths
#define FREG 19
206 6ea83fed bellard
#include "fop_template.c"
207 5a5012ec ths
#undef FREG
208 5a5012ec ths
#define FREG 20
209 6ea83fed bellard
#include "fop_template.c"
210 5a5012ec ths
#undef FREG
211 5a5012ec ths
#define FREG 21
212 6ea83fed bellard
#include "fop_template.c"
213 5a5012ec ths
#undef FREG
214 5a5012ec ths
#define FREG 22
215 6ea83fed bellard
#include "fop_template.c"
216 5a5012ec ths
#undef FREG
217 5a5012ec ths
#define FREG 23
218 6ea83fed bellard
#include "fop_template.c"
219 5a5012ec ths
#undef FREG
220 5a5012ec ths
#define FREG 24
221 6ea83fed bellard
#include "fop_template.c"
222 5a5012ec ths
#undef FREG
223 5a5012ec ths
#define FREG 25
224 6ea83fed bellard
#include "fop_template.c"
225 5a5012ec ths
#undef FREG
226 5a5012ec ths
#define FREG 26
227 6ea83fed bellard
#include "fop_template.c"
228 5a5012ec ths
#undef FREG
229 5a5012ec ths
#define FREG 27
230 6ea83fed bellard
#include "fop_template.c"
231 5a5012ec ths
#undef FREG
232 5a5012ec ths
#define FREG 28
233 6ea83fed bellard
#include "fop_template.c"
234 5a5012ec ths
#undef FREG
235 5a5012ec ths
#define FREG 29
236 6ea83fed bellard
#include "fop_template.c"
237 5a5012ec ths
#undef FREG
238 5a5012ec ths
#define FREG 30
239 6ea83fed bellard
#include "fop_template.c"
240 5a5012ec ths
#undef FREG
241 5a5012ec ths
#define FREG 31
242 6ea83fed bellard
#include "fop_template.c"
243 5a5012ec ths
#undef FREG
244 6ea83fed bellard
245 6ea83fed bellard
#define FTN
246 6ea83fed bellard
#include "fop_template.c"
247 6ea83fed bellard
#undef FTN
248 6ea83fed bellard
249 6af0bf9c bellard
void op_dup_T0 (void)
250 6af0bf9c bellard
{
251 6af0bf9c bellard
    T2 = T0;
252 6af0bf9c bellard
    RETURN();
253 6af0bf9c bellard
}
254 6af0bf9c bellard
255 6af0bf9c bellard
void op_load_HI (void)
256 6af0bf9c bellard
{
257 ead9360e ths
    T0 = env->HI[PARAM1][env->current_tc];
258 6af0bf9c bellard
    RETURN();
259 6af0bf9c bellard
}
260 6af0bf9c bellard
261 6af0bf9c bellard
void op_store_HI (void)
262 6af0bf9c bellard
{
263 ead9360e ths
    env->HI[PARAM1][env->current_tc] = T0;
264 6af0bf9c bellard
    RETURN();
265 6af0bf9c bellard
}
266 6af0bf9c bellard
267 6af0bf9c bellard
void op_load_LO (void)
268 6af0bf9c bellard
{
269 ead9360e ths
    T0 = env->LO[PARAM1][env->current_tc];
270 6af0bf9c bellard
    RETURN();
271 6af0bf9c bellard
}
272 6af0bf9c bellard
273 6af0bf9c bellard
void op_store_LO (void)
274 6af0bf9c bellard
{
275 ead9360e ths
    env->LO[PARAM1][env->current_tc] = T0;
276 6af0bf9c bellard
    RETURN();
277 6af0bf9c bellard
}
278 6af0bf9c bellard
279 6af0bf9c bellard
/* Load and store */
280 6af0bf9c bellard
#define MEMSUFFIX _raw
281 6af0bf9c bellard
#include "op_mem.c"
282 6af0bf9c bellard
#undef MEMSUFFIX
283 6af0bf9c bellard
#if !defined(CONFIG_USER_ONLY)
284 6af0bf9c bellard
#define MEMSUFFIX _user
285 6af0bf9c bellard
#include "op_mem.c"
286 6af0bf9c bellard
#undef MEMSUFFIX
287 6af0bf9c bellard
288 6af0bf9c bellard
#define MEMSUFFIX _kernel
289 6af0bf9c bellard
#include "op_mem.c"
290 6af0bf9c bellard
#undef MEMSUFFIX
291 6af0bf9c bellard
#endif
292 6af0bf9c bellard
293 a6763a58 ths
/* Addresses computation */
294 a6763a58 ths
void op_addr_add (void)
295 a6763a58 ths
{
296 a6763a58 ths
/* For compatibility with 32-bit code, data reference in user mode
297 a6763a58 ths
   with Status_UX = 0 should be casted to 32-bit and sign extended.
298 a6763a58 ths
   See the MIPS64 PRA manual, section 4.10. */
299 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
300 996ba2cc ths
    if ((env->hflags & MIPS_HFLAG_UM) &&
301 a6763a58 ths
        !(env->CP0_Status & (1 << CP0St_UX)))
302 a6763a58 ths
        T0 = (int64_t)(int32_t)(T0 + T1);
303 a6763a58 ths
    else
304 a6763a58 ths
#endif
305 a6763a58 ths
        T0 += T1;
306 a6763a58 ths
    RETURN();
307 a6763a58 ths
}
308 a6763a58 ths
309 6af0bf9c bellard
/* Arithmetic */
310 6af0bf9c bellard
void op_add (void)
311 6af0bf9c bellard
{
312 5dc4b744 ths
    T0 = (int32_t)((int32_t)T0 + (int32_t)T1);
313 6af0bf9c bellard
    RETURN();
314 6af0bf9c bellard
}
315 6af0bf9c bellard
316 6af0bf9c bellard
void op_addo (void)
317 6af0bf9c bellard
{
318 6af0bf9c bellard
    target_ulong tmp;
319 6af0bf9c bellard
320 c570fd16 ths
    tmp = (int32_t)T0;
321 c570fd16 ths
    T0 = (int32_t)T0 + (int32_t)T1;
322 76e050c2 bellard
    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
323 c570fd16 ths
        /* operands of same sign, result different sign */
324 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
325 6af0bf9c bellard
    }
326 5dc4b744 ths
    T0 = (int32_t)T0;
327 6af0bf9c bellard
    RETURN();
328 6af0bf9c bellard
}
329 6af0bf9c bellard
330 6af0bf9c bellard
void op_sub (void)
331 6af0bf9c bellard
{
332 5dc4b744 ths
    T0 = (int32_t)((int32_t)T0 - (int32_t)T1);
333 6af0bf9c bellard
    RETURN();
334 6af0bf9c bellard
}
335 6af0bf9c bellard
336 6af0bf9c bellard
void op_subo (void)
337 6af0bf9c bellard
{
338 6af0bf9c bellard
    target_ulong tmp;
339 6af0bf9c bellard
340 c570fd16 ths
    tmp = (int32_t)T0;
341 6af0bf9c bellard
    T0 = (int32_t)T0 - (int32_t)T1;
342 76e050c2 bellard
    if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {
343 c570fd16 ths
        /* operands of different sign, first operand and result different sign */
344 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
345 6af0bf9c bellard
    }
346 5dc4b744 ths
    T0 = (int32_t)T0;
347 6af0bf9c bellard
    RETURN();
348 6af0bf9c bellard
}
349 6af0bf9c bellard
350 6af0bf9c bellard
void op_mul (void)
351 6af0bf9c bellard
{
352 5dc4b744 ths
    T0 = (int32_t)((int32_t)T0 * (int32_t)T1);
353 6af0bf9c bellard
    RETURN();
354 6af0bf9c bellard
}
355 6af0bf9c bellard
356 80c27194 ths
#if HOST_LONG_BITS < 64
357 80c27194 ths
void op_div (void)
358 80c27194 ths
{
359 80c27194 ths
    CALL_FROM_TB0(do_div);
360 80c27194 ths
    RETURN();
361 80c27194 ths
}
362 80c27194 ths
#else
363 6af0bf9c bellard
void op_div (void)
364 6af0bf9c bellard
{
365 6af0bf9c bellard
    if (T1 != 0) {
366 ead9360e ths
        env->LO[0][env->current_tc] = (int32_t)((int64_t)(int32_t)T0 / (int32_t)T1);
367 ead9360e ths
        env->HI[0][env->current_tc] = (int32_t)((int64_t)(int32_t)T0 % (int32_t)T1);
368 6af0bf9c bellard
    }
369 6af0bf9c bellard
    RETURN();
370 6af0bf9c bellard
}
371 80c27194 ths
#endif
372 6af0bf9c bellard
373 6af0bf9c bellard
void op_divu (void)
374 6af0bf9c bellard
{
375 6af0bf9c bellard
    if (T1 != 0) {
376 ead9360e ths
        env->LO[0][env->current_tc] = (int32_t)((uint32_t)T0 / (uint32_t)T1);
377 ead9360e ths
        env->HI[0][env->current_tc] = (int32_t)((uint32_t)T0 % (uint32_t)T1);
378 c570fd16 ths
    }
379 c570fd16 ths
    RETURN();
380 c570fd16 ths
}
381 c570fd16 ths
382 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
383 c570fd16 ths
/* Arithmetic */
384 c570fd16 ths
void op_dadd (void)
385 c570fd16 ths
{
386 c570fd16 ths
    T0 += T1;
387 c570fd16 ths
    RETURN();
388 c570fd16 ths
}
389 c570fd16 ths
390 c570fd16 ths
void op_daddo (void)
391 c570fd16 ths
{
392 c570fd16 ths
    target_long tmp;
393 c570fd16 ths
394 c570fd16 ths
    tmp = T0;
395 c570fd16 ths
    T0 += T1;
396 c570fd16 ths
    if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 63) {
397 c570fd16 ths
        /* operands of same sign, result different sign */
398 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
399 c570fd16 ths
    }
400 c570fd16 ths
    RETURN();
401 c570fd16 ths
}
402 c570fd16 ths
403 c570fd16 ths
void op_dsub (void)
404 c570fd16 ths
{
405 c570fd16 ths
    T0 -= T1;
406 c570fd16 ths
    RETURN();
407 c570fd16 ths
}
408 c570fd16 ths
409 c570fd16 ths
void op_dsubo (void)
410 c570fd16 ths
{
411 c570fd16 ths
    target_long tmp;
412 c570fd16 ths
413 c570fd16 ths
    tmp = T0;
414 c570fd16 ths
    T0 = (int64_t)T0 - (int64_t)T1;
415 c570fd16 ths
    if (((tmp ^ T1) & (tmp ^ T0)) >> 63) {
416 c570fd16 ths
        /* operands of different sign, first operand and result different sign */
417 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
418 c570fd16 ths
    }
419 c570fd16 ths
    RETURN();
420 c570fd16 ths
}
421 c570fd16 ths
422 c570fd16 ths
void op_dmul (void)
423 c570fd16 ths
{
424 c570fd16 ths
    T0 = (int64_t)T0 * (int64_t)T1;
425 c570fd16 ths
    RETURN();
426 c570fd16 ths
}
427 c570fd16 ths
428 c570fd16 ths
/* Those might call libgcc functions.  */
429 c570fd16 ths
void op_ddiv (void)
430 c570fd16 ths
{
431 c570fd16 ths
    do_ddiv();
432 c570fd16 ths
    RETURN();
433 c570fd16 ths
}
434 c570fd16 ths
435 80c27194 ths
#if TARGET_LONG_BITS > HOST_LONG_BITS
436 c570fd16 ths
void op_ddivu (void)
437 c570fd16 ths
{
438 c570fd16 ths
    do_ddivu();
439 c570fd16 ths
    RETURN();
440 c570fd16 ths
}
441 c570fd16 ths
#else
442 c570fd16 ths
void op_ddivu (void)
443 c570fd16 ths
{
444 c570fd16 ths
    if (T1 != 0) {
445 ead9360e ths
        env->LO[0][env->current_tc] = T0 / T1;
446 ead9360e ths
        env->HI[0][env->current_tc] = T0 % T1;
447 6af0bf9c bellard
    }
448 6af0bf9c bellard
    RETURN();
449 6af0bf9c bellard
}
450 c570fd16 ths
#endif
451 540635ba ths
#endif /* TARGET_MIPSN32 || TARGET_MIPS64 */
452 6af0bf9c bellard
453 6af0bf9c bellard
/* Logical */
454 6af0bf9c bellard
void op_and (void)
455 6af0bf9c bellard
{
456 6af0bf9c bellard
    T0 &= T1;
457 6af0bf9c bellard
    RETURN();
458 6af0bf9c bellard
}
459 6af0bf9c bellard
460 6af0bf9c bellard
void op_nor (void)
461 6af0bf9c bellard
{
462 6af0bf9c bellard
    T0 = ~(T0 | T1);
463 6af0bf9c bellard
    RETURN();
464 6af0bf9c bellard
}
465 6af0bf9c bellard
466 6af0bf9c bellard
void op_or (void)
467 6af0bf9c bellard
{
468 6af0bf9c bellard
    T0 |= T1;
469 6af0bf9c bellard
    RETURN();
470 6af0bf9c bellard
}
471 6af0bf9c bellard
472 6af0bf9c bellard
void op_xor (void)
473 6af0bf9c bellard
{
474 6af0bf9c bellard
    T0 ^= T1;
475 6af0bf9c bellard
    RETURN();
476 6af0bf9c bellard
}
477 6af0bf9c bellard
478 6af0bf9c bellard
void op_sll (void)
479 6af0bf9c bellard
{
480 5a63bcb2 ths
    T0 = (int32_t)((uint32_t)T0 << T1);
481 6af0bf9c bellard
    RETURN();
482 6af0bf9c bellard
}
483 6af0bf9c bellard
484 6af0bf9c bellard
void op_sra (void)
485 6af0bf9c bellard
{
486 5a63bcb2 ths
    T0 = (int32_t)((int32_t)T0 >> T1);
487 6af0bf9c bellard
    RETURN();
488 6af0bf9c bellard
}
489 6af0bf9c bellard
490 6af0bf9c bellard
void op_srl (void)
491 6af0bf9c bellard
{
492 5a63bcb2 ths
    T0 = (int32_t)((uint32_t)T0 >> T1);
493 6af0bf9c bellard
    RETURN();
494 6af0bf9c bellard
}
495 6af0bf9c bellard
496 7a387fff ths
void op_rotr (void)
497 7a387fff ths
{
498 7a387fff ths
    target_ulong tmp;
499 7a387fff ths
500 7a387fff ths
    if (T1) {
501 5a63bcb2 ths
       tmp = (int32_t)((uint32_t)T0 << (0x20 - T1));
502 5a63bcb2 ths
       T0 = (int32_t)((uint32_t)T0 >> T1) | tmp;
503 5a63bcb2 ths
    }
504 7a387fff ths
    RETURN();
505 7a387fff ths
}
506 7a387fff ths
507 6af0bf9c bellard
void op_sllv (void)
508 6af0bf9c bellard
{
509 5dc4b744 ths
    T0 = (int32_t)((uint32_t)T1 << ((uint32_t)T0 & 0x1F));
510 6af0bf9c bellard
    RETURN();
511 6af0bf9c bellard
}
512 6af0bf9c bellard
513 6af0bf9c bellard
void op_srav (void)
514 6af0bf9c bellard
{
515 5dc4b744 ths
    T0 = (int32_t)((int32_t)T1 >> (T0 & 0x1F));
516 6af0bf9c bellard
    RETURN();
517 6af0bf9c bellard
}
518 6af0bf9c bellard
519 6af0bf9c bellard
void op_srlv (void)
520 6af0bf9c bellard
{
521 5dc4b744 ths
    T0 = (int32_t)((uint32_t)T1 >> (T0 & 0x1F));
522 6af0bf9c bellard
    RETURN();
523 6af0bf9c bellard
}
524 6af0bf9c bellard
525 7a387fff ths
void op_rotrv (void)
526 7a387fff ths
{
527 7a387fff ths
    target_ulong tmp;
528 7a387fff ths
529 7a387fff ths
    T0 &= 0x1F;
530 7a387fff ths
    if (T0) {
531 5dc4b744 ths
       tmp = (int32_t)((uint32_t)T1 << (0x20 - T0));
532 5dc4b744 ths
       T0 = (int32_t)((uint32_t)T1 >> T0) | tmp;
533 7a387fff ths
    } else
534 7a387fff ths
       T0 = T1;
535 7a387fff ths
    RETURN();
536 7a387fff ths
}
537 7a387fff ths
538 6af0bf9c bellard
void op_clo (void)
539 6af0bf9c bellard
{
540 6af0bf9c bellard
    int n;
541 6af0bf9c bellard
542 c570fd16 ths
    if (T0 == ~((target_ulong)0)) {
543 6af0bf9c bellard
        T0 = 32;
544 6af0bf9c bellard
    } else {
545 6af0bf9c bellard
        for (n = 0; n < 32; n++) {
546 9278480e ths
            if (!(((int32_t)T0) & (1 << 31)))
547 6af0bf9c bellard
                break;
548 9278480e ths
            T0 <<= 1;
549 6af0bf9c bellard
        }
550 6af0bf9c bellard
        T0 = n;
551 6af0bf9c bellard
    }
552 6af0bf9c bellard
    RETURN();
553 6af0bf9c bellard
}
554 6af0bf9c bellard
555 6af0bf9c bellard
void op_clz (void)
556 6af0bf9c bellard
{
557 6af0bf9c bellard
    int n;
558 6af0bf9c bellard
559 6af0bf9c bellard
    if (T0 == 0) {
560 6af0bf9c bellard
        T0 = 32;
561 6af0bf9c bellard
    } else {
562 6af0bf9c bellard
        for (n = 0; n < 32; n++) {
563 6af0bf9c bellard
            if (T0 & (1 << 31))
564 6af0bf9c bellard
                break;
565 9278480e ths
            T0 <<= 1;
566 6af0bf9c bellard
        }
567 6af0bf9c bellard
        T0 = n;
568 6af0bf9c bellard
    }
569 6af0bf9c bellard
    RETURN();
570 6af0bf9c bellard
}
571 6af0bf9c bellard
572 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
573 c570fd16 ths
574 c570fd16 ths
#if TARGET_LONG_BITS > HOST_LONG_BITS
575 c570fd16 ths
/* Those might call libgcc functions.  */
576 c570fd16 ths
void op_dsll (void)
577 6af0bf9c bellard
{
578 c570fd16 ths
    CALL_FROM_TB0(do_dsll);
579 c570fd16 ths
    RETURN();
580 6af0bf9c bellard
}
581 6af0bf9c bellard
582 c570fd16 ths
void op_dsll32 (void)
583 6af0bf9c bellard
{
584 c570fd16 ths
    CALL_FROM_TB0(do_dsll32);
585 c570fd16 ths
    RETURN();
586 6af0bf9c bellard
}
587 6af0bf9c bellard
588 c570fd16 ths
void op_dsra (void)
589 6af0bf9c bellard
{
590 c570fd16 ths
    CALL_FROM_TB0(do_dsra);
591 6af0bf9c bellard
    RETURN();
592 6af0bf9c bellard
}
593 6af0bf9c bellard
594 c570fd16 ths
void op_dsra32 (void)
595 6af0bf9c bellard
{
596 c570fd16 ths
    CALL_FROM_TB0(do_dsra32);
597 6af0bf9c bellard
    RETURN();
598 6af0bf9c bellard
}
599 6af0bf9c bellard
600 c570fd16 ths
void op_dsrl (void)
601 6af0bf9c bellard
{
602 c570fd16 ths
    CALL_FROM_TB0(do_dsrl);
603 c570fd16 ths
    RETURN();
604 c570fd16 ths
}
605 6af0bf9c bellard
606 c570fd16 ths
void op_dsrl32 (void)
607 c570fd16 ths
{
608 c570fd16 ths
    CALL_FROM_TB0(do_dsrl32);
609 6af0bf9c bellard
    RETURN();
610 6af0bf9c bellard
}
611 6af0bf9c bellard
612 c570fd16 ths
void op_drotr (void)
613 6af0bf9c bellard
{
614 c570fd16 ths
    CALL_FROM_TB0(do_drotr);
615 c570fd16 ths
    RETURN();
616 c570fd16 ths
}
617 6af0bf9c bellard
618 c570fd16 ths
void op_drotr32 (void)
619 c570fd16 ths
{
620 c570fd16 ths
    CALL_FROM_TB0(do_drotr32);
621 6af0bf9c bellard
    RETURN();
622 6af0bf9c bellard
}
623 6af0bf9c bellard
624 c570fd16 ths
void op_dsllv (void)
625 6af0bf9c bellard
{
626 c570fd16 ths
    CALL_FROM_TB0(do_dsllv);
627 c570fd16 ths
    RETURN();
628 c570fd16 ths
}
629 6af0bf9c bellard
630 c570fd16 ths
void op_dsrav (void)
631 c570fd16 ths
{
632 c570fd16 ths
    CALL_FROM_TB0(do_dsrav);
633 6af0bf9c bellard
    RETURN();
634 6af0bf9c bellard
}
635 6af0bf9c bellard
636 c570fd16 ths
void op_dsrlv (void)
637 6af0bf9c bellard
{
638 c570fd16 ths
    CALL_FROM_TB0(do_dsrlv);
639 c570fd16 ths
    RETURN();
640 c570fd16 ths
}
641 6af0bf9c bellard
642 c570fd16 ths
void op_drotrv (void)
643 c570fd16 ths
{
644 c570fd16 ths
    CALL_FROM_TB0(do_drotrv);
645 6af0bf9c bellard
    RETURN();
646 6af0bf9c bellard
}
647 c570fd16 ths
648 c570fd16 ths
#else /* TARGET_LONG_BITS > HOST_LONG_BITS */
649 c570fd16 ths
650 c570fd16 ths
void op_dsll (void)
651 c570fd16 ths
{
652 c570fd16 ths
    T0 = T0 << T1;
653 c570fd16 ths
    RETURN();
654 c570fd16 ths
}
655 c570fd16 ths
656 c570fd16 ths
void op_dsll32 (void)
657 c570fd16 ths
{
658 c570fd16 ths
    T0 = T0 << (T1 + 32);
659 c570fd16 ths
    RETURN();
660 c570fd16 ths
}
661 c570fd16 ths
662 c570fd16 ths
void op_dsra (void)
663 c570fd16 ths
{
664 c570fd16 ths
    T0 = (int64_t)T0 >> T1;
665 c570fd16 ths
    RETURN();
666 c570fd16 ths
}
667 c570fd16 ths
668 c570fd16 ths
void op_dsra32 (void)
669 c570fd16 ths
{
670 c570fd16 ths
    T0 = (int64_t)T0 >> (T1 + 32);
671 c570fd16 ths
    RETURN();
672 c570fd16 ths
}
673 c570fd16 ths
674 c570fd16 ths
void op_dsrl (void)
675 c570fd16 ths
{
676 c570fd16 ths
    T0 = T0 >> T1;
677 c570fd16 ths
    RETURN();
678 c570fd16 ths
}
679 c570fd16 ths
680 c570fd16 ths
void op_dsrl32 (void)
681 c570fd16 ths
{
682 c570fd16 ths
    T0 = T0 >> (T1 + 32);
683 c570fd16 ths
    RETURN();
684 c570fd16 ths
}
685 c570fd16 ths
686 c570fd16 ths
void op_drotr (void)
687 c570fd16 ths
{
688 c570fd16 ths
    target_ulong tmp;
689 c570fd16 ths
690 c570fd16 ths
    if (T1) {
691 c570fd16 ths
       tmp = T0 << (0x40 - T1);
692 c570fd16 ths
       T0 = (T0 >> T1) | tmp;
693 5a63bcb2 ths
    }
694 c570fd16 ths
    RETURN();
695 c570fd16 ths
}
696 c570fd16 ths
697 c570fd16 ths
void op_drotr32 (void)
698 c570fd16 ths
{
699 c570fd16 ths
    target_ulong tmp;
700 c570fd16 ths
701 c570fd16 ths
    if (T1) {
702 c570fd16 ths
       tmp = T0 << (0x40 - (32 + T1));
703 c570fd16 ths
       T0 = (T0 >> (32 + T1)) | tmp;
704 5a63bcb2 ths
    }
705 c570fd16 ths
    RETURN();
706 c570fd16 ths
}
707 c570fd16 ths
708 c570fd16 ths
void op_dsllv (void)
709 c570fd16 ths
{
710 c570fd16 ths
    T0 = T1 << (T0 & 0x3F);
711 c570fd16 ths
    RETURN();
712 c570fd16 ths
}
713 c570fd16 ths
714 c570fd16 ths
void op_dsrav (void)
715 c570fd16 ths
{
716 c570fd16 ths
    T0 = (int64_t)T1 >> (T0 & 0x3F);
717 c570fd16 ths
    RETURN();
718 c570fd16 ths
}
719 c570fd16 ths
720 c570fd16 ths
void op_dsrlv (void)
721 c570fd16 ths
{
722 c570fd16 ths
    T0 = T1 >> (T0 & 0x3F);
723 c570fd16 ths
    RETURN();
724 c570fd16 ths
}
725 c570fd16 ths
726 c570fd16 ths
void op_drotrv (void)
727 c570fd16 ths
{
728 c570fd16 ths
    target_ulong tmp;
729 c570fd16 ths
730 c570fd16 ths
    T0 &= 0x3F;
731 c570fd16 ths
    if (T0) {
732 c570fd16 ths
       tmp = T1 << (0x40 - T0);
733 c570fd16 ths
       T0 = (T1 >> T0) | tmp;
734 c570fd16 ths
    } else
735 c570fd16 ths
       T0 = T1;
736 c570fd16 ths
    RETURN();
737 c570fd16 ths
}
738 c570fd16 ths
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
739 c570fd16 ths
740 c570fd16 ths
void op_dclo (void)
741 c570fd16 ths
{
742 c570fd16 ths
    int n;
743 c570fd16 ths
744 c570fd16 ths
    if (T0 == ~((target_ulong)0)) {
745 c570fd16 ths
        T0 = 64;
746 c570fd16 ths
    } else {
747 c570fd16 ths
        for (n = 0; n < 64; n++) {
748 c570fd16 ths
            if (!(T0 & (1ULL << 63)))
749 c570fd16 ths
                break;
750 9278480e ths
            T0 <<= 1;
751 c570fd16 ths
        }
752 c570fd16 ths
        T0 = n;
753 c570fd16 ths
    }
754 c570fd16 ths
    RETURN();
755 c570fd16 ths
}
756 c570fd16 ths
757 c570fd16 ths
void op_dclz (void)
758 c570fd16 ths
{
759 c570fd16 ths
    int n;
760 c570fd16 ths
761 c570fd16 ths
    if (T0 == 0) {
762 c570fd16 ths
        T0 = 64;
763 c570fd16 ths
    } else {
764 c570fd16 ths
        for (n = 0; n < 64; n++) {
765 c570fd16 ths
            if (T0 & (1ULL << 63))
766 c570fd16 ths
                break;
767 9278480e ths
            T0 <<= 1;
768 c570fd16 ths
        }
769 c570fd16 ths
        T0 = n;
770 c570fd16 ths
    }
771 c570fd16 ths
    RETURN();
772 c570fd16 ths
}
773 540635ba ths
#endif /* TARGET_MIPSN32 || TARGET_MIPS64 */
774 c570fd16 ths
775 c570fd16 ths
/* 64 bits arithmetic */
776 c570fd16 ths
#if TARGET_LONG_BITS > HOST_LONG_BITS
777 6af0bf9c bellard
void op_mult (void)
778 6af0bf9c bellard
{
779 6af0bf9c bellard
    CALL_FROM_TB0(do_mult);
780 6af0bf9c bellard
    RETURN();
781 6af0bf9c bellard
}
782 6af0bf9c bellard
783 6af0bf9c bellard
void op_multu (void)
784 6af0bf9c bellard
{
785 6af0bf9c bellard
    CALL_FROM_TB0(do_multu);
786 6af0bf9c bellard
    RETURN();
787 6af0bf9c bellard
}
788 6af0bf9c bellard
789 6af0bf9c bellard
void op_madd (void)
790 6af0bf9c bellard
{
791 6af0bf9c bellard
    CALL_FROM_TB0(do_madd);
792 6af0bf9c bellard
    RETURN();
793 6af0bf9c bellard
}
794 6af0bf9c bellard
795 6af0bf9c bellard
void op_maddu (void)
796 6af0bf9c bellard
{
797 6af0bf9c bellard
    CALL_FROM_TB0(do_maddu);
798 6af0bf9c bellard
    RETURN();
799 6af0bf9c bellard
}
800 6af0bf9c bellard
801 6af0bf9c bellard
void op_msub (void)
802 6af0bf9c bellard
{
803 6af0bf9c bellard
    CALL_FROM_TB0(do_msub);
804 6af0bf9c bellard
    RETURN();
805 6af0bf9c bellard
}
806 6af0bf9c bellard
807 6af0bf9c bellard
void op_msubu (void)
808 6af0bf9c bellard
{
809 6af0bf9c bellard
    CALL_FROM_TB0(do_msubu);
810 6af0bf9c bellard
    RETURN();
811 6af0bf9c bellard
}
812 c570fd16 ths
813 c570fd16 ths
#else /* TARGET_LONG_BITS > HOST_LONG_BITS */
814 c570fd16 ths
815 aa343735 ths
static always_inline uint64_t get_HILO (void)
816 c570fd16 ths
{
817 ead9360e ths
    return ((uint64_t)env->HI[0][env->current_tc] << 32) |
818 ead9360e ths
            ((uint64_t)(uint32_t)env->LO[0][env->current_tc]);
819 c570fd16 ths
}
820 c570fd16 ths
821 aa343735 ths
static always_inline void set_HILO (uint64_t HILO)
822 c570fd16 ths
{
823 ead9360e ths
    env->LO[0][env->current_tc] = (int32_t)(HILO & 0xFFFFFFFF);
824 ead9360e ths
    env->HI[0][env->current_tc] = (int32_t)(HILO >> 32);
825 c570fd16 ths
}
826 c570fd16 ths
827 c570fd16 ths
void op_mult (void)
828 c570fd16 ths
{
829 c570fd16 ths
    set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
830 c570fd16 ths
    RETURN();
831 c570fd16 ths
}
832 c570fd16 ths
833 c570fd16 ths
void op_multu (void)
834 c570fd16 ths
{
835 c570fd16 ths
    set_HILO((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
836 c570fd16 ths
    RETURN();
837 c570fd16 ths
}
838 c570fd16 ths
839 c570fd16 ths
void op_madd (void)
840 c570fd16 ths
{
841 c570fd16 ths
    int64_t tmp;
842 c570fd16 ths
843 c570fd16 ths
    tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
844 c570fd16 ths
    set_HILO((int64_t)get_HILO() + tmp);
845 c570fd16 ths
    RETURN();
846 c570fd16 ths
}
847 c570fd16 ths
848 c570fd16 ths
void op_maddu (void)
849 c570fd16 ths
{
850 c570fd16 ths
    uint64_t tmp;
851 c570fd16 ths
852 c570fd16 ths
    tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
853 c570fd16 ths
    set_HILO(get_HILO() + tmp);
854 c570fd16 ths
    RETURN();
855 c570fd16 ths
}
856 c570fd16 ths
857 c570fd16 ths
void op_msub (void)
858 c570fd16 ths
{
859 c570fd16 ths
    int64_t tmp;
860 c570fd16 ths
861 c570fd16 ths
    tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
862 c570fd16 ths
    set_HILO((int64_t)get_HILO() - tmp);
863 c570fd16 ths
    RETURN();
864 c570fd16 ths
}
865 c570fd16 ths
866 c570fd16 ths
void op_msubu (void)
867 c570fd16 ths
{
868 c570fd16 ths
    uint64_t tmp;
869 c570fd16 ths
870 c570fd16 ths
    tmp = ((uint64_t)(uint32_t)T0 * (uint64_t)(uint32_t)T1);
871 c570fd16 ths
    set_HILO(get_HILO() - tmp);
872 c570fd16 ths
    RETURN();
873 c570fd16 ths
}
874 c570fd16 ths
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
875 c570fd16 ths
876 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
877 c570fd16 ths
void op_dmult (void)
878 c570fd16 ths
{
879 ead9360e ths
    CALL_FROM_TB4(muls64, &(env->HI[0][env->current_tc]), &(env->LO[0][env->current_tc]), T0, T1);
880 c570fd16 ths
    RETURN();
881 c570fd16 ths
}
882 c570fd16 ths
883 c570fd16 ths
void op_dmultu (void)
884 c570fd16 ths
{
885 ead9360e ths
    CALL_FROM_TB4(mulu64, &(env->HI[0][env->current_tc]), &(env->LO[0][env->current_tc]), T0, T1);
886 c570fd16 ths
    RETURN();
887 c570fd16 ths
}
888 6af0bf9c bellard
#endif
889 6af0bf9c bellard
890 6af0bf9c bellard
/* Conditional moves */
891 6af0bf9c bellard
void op_movn (void)
892 6af0bf9c bellard
{
893 6af0bf9c bellard
    if (T1 != 0)
894 ead9360e ths
        env->gpr[PARAM1][env->current_tc] = T0;
895 6af0bf9c bellard
    RETURN();
896 6af0bf9c bellard
}
897 6af0bf9c bellard
898 6af0bf9c bellard
void op_movz (void)
899 6af0bf9c bellard
{
900 6af0bf9c bellard
    if (T1 == 0)
901 ead9360e ths
        env->gpr[PARAM1][env->current_tc] = T0;
902 6af0bf9c bellard
    RETURN();
903 6af0bf9c bellard
}
904 6af0bf9c bellard
905 7a387fff ths
void op_movf (void)
906 7a387fff ths
{
907 ead9360e ths
    if (!(env->fpu->fcr31 & PARAM1))
908 5a5012ec ths
        T0 = T1;
909 7a387fff ths
    RETURN();
910 7a387fff ths
}
911 7a387fff ths
912 7a387fff ths
void op_movt (void)
913 7a387fff ths
{
914 ead9360e ths
    if (env->fpu->fcr31 & PARAM1)
915 5a5012ec ths
        T0 = T1;
916 7a387fff ths
    RETURN();
917 7a387fff ths
}
918 7a387fff ths
919 6af0bf9c bellard
/* Tests */
920 6af0bf9c bellard
#define OP_COND(name, cond) \
921 6af0bf9c bellard
void glue(op_, name) (void) \
922 6af0bf9c bellard
{                           \
923 6af0bf9c bellard
    if (cond) {             \
924 6af0bf9c bellard
        T0 = 1;             \
925 6af0bf9c bellard
    } else {                \
926 6af0bf9c bellard
        T0 = 0;             \
927 6af0bf9c bellard
    }                       \
928 6af0bf9c bellard
    RETURN();               \
929 6af0bf9c bellard
}
930 6af0bf9c bellard
931 6af0bf9c bellard
OP_COND(eq, T0 == T1);
932 6af0bf9c bellard
OP_COND(ne, T0 != T1);
933 f469b9db ths
OP_COND(ge, (target_long)T0 >= (target_long)T1);
934 6af0bf9c bellard
OP_COND(geu, T0 >= T1);
935 f469b9db ths
OP_COND(lt, (target_long)T0 < (target_long)T1);
936 6af0bf9c bellard
OP_COND(ltu, T0 < T1);
937 f469b9db ths
OP_COND(gez, (target_long)T0 >= 0);
938 f469b9db ths
OP_COND(gtz, (target_long)T0 > 0);
939 f469b9db ths
OP_COND(lez, (target_long)T0 <= 0);
940 f469b9db ths
OP_COND(ltz, (target_long)T0 < 0);
941 6af0bf9c bellard
942 7a387fff ths
/* Branches */
943 c53be334 bellard
void OPPROTO op_goto_tb0(void)
944 c53be334 bellard
{
945 c53be334 bellard
    GOTO_TB(op_goto_tb0, PARAM1, 0);
946 7a387fff ths
    RETURN();
947 c53be334 bellard
}
948 c53be334 bellard
949 c53be334 bellard
void OPPROTO op_goto_tb1(void)
950 c53be334 bellard
{
951 c53be334 bellard
    GOTO_TB(op_goto_tb1, PARAM1, 1);
952 7a387fff ths
    RETURN();
953 c53be334 bellard
}
954 6af0bf9c bellard
955 6af0bf9c bellard
/* Branch to register */
956 6af0bf9c bellard
void op_save_breg_target (void)
957 6af0bf9c bellard
{
958 6af0bf9c bellard
    env->btarget = T2;
959 7a387fff ths
    RETURN();
960 6af0bf9c bellard
}
961 6af0bf9c bellard
962 6af0bf9c bellard
void op_restore_breg_target (void)
963 6af0bf9c bellard
{
964 6af0bf9c bellard
    T2 = env->btarget;
965 7a387fff ths
    RETURN();
966 6af0bf9c bellard
}
967 6af0bf9c bellard
968 6af0bf9c bellard
void op_breg (void)
969 6af0bf9c bellard
{
970 ead9360e ths
    env->PC[env->current_tc] = T2;
971 6af0bf9c bellard
    RETURN();
972 6af0bf9c bellard
}
973 6af0bf9c bellard
974 6af0bf9c bellard
void op_save_btarget (void)
975 6af0bf9c bellard
{
976 6af0bf9c bellard
    env->btarget = PARAM1;
977 6af0bf9c bellard
    RETURN();
978 6af0bf9c bellard
}
979 6af0bf9c bellard
980 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
981 9b9e4393 ths
void op_save_btarget64 (void)
982 9b9e4393 ths
{
983 9b9e4393 ths
    env->btarget = ((uint64_t)PARAM1 << 32) | (uint32_t)PARAM2;
984 9b9e4393 ths
    RETURN();
985 9b9e4393 ths
}
986 9b9e4393 ths
#endif
987 9b9e4393 ths
988 6af0bf9c bellard
/* Conditional branch */
989 6af0bf9c bellard
void op_set_bcond (void)
990 6af0bf9c bellard
{
991 6af0bf9c bellard
    T2 = T0;
992 6af0bf9c bellard
    RETURN();
993 6af0bf9c bellard
}
994 6af0bf9c bellard
995 6af0bf9c bellard
void op_save_bcond (void)
996 6af0bf9c bellard
{
997 6af0bf9c bellard
    env->bcond = T2;
998 6af0bf9c bellard
    RETURN();
999 6af0bf9c bellard
}
1000 6af0bf9c bellard
1001 6af0bf9c bellard
void op_restore_bcond (void)
1002 6af0bf9c bellard
{
1003 6af0bf9c bellard
    T2 = env->bcond;
1004 6af0bf9c bellard
    RETURN();
1005 6af0bf9c bellard
}
1006 6af0bf9c bellard
1007 c53be334 bellard
void op_jnz_T2 (void)
1008 6af0bf9c bellard
{
1009 c53be334 bellard
    if (T2)
1010 c53be334 bellard
        GOTO_LABEL_PARAM(1);
1011 6af0bf9c bellard
    RETURN();
1012 6af0bf9c bellard
}
1013 6af0bf9c bellard
1014 6af0bf9c bellard
/* CP0 functions */
1015 873eb012 ths
void op_mfc0_index (void)
1016 6af0bf9c bellard
{
1017 9c2149c8 ths
    T0 = env->CP0_Index;
1018 873eb012 ths
    RETURN();
1019 873eb012 ths
}
1020 873eb012 ths
1021 ead9360e ths
void op_mfc0_mvpcontrol (void)
1022 ead9360e ths
{
1023 ead9360e ths
    T0 = env->mvp->CP0_MVPControl;
1024 ead9360e ths
    RETURN();
1025 ead9360e ths
}
1026 ead9360e ths
1027 ead9360e ths
void op_mfc0_mvpconf0 (void)
1028 ead9360e ths
{
1029 ead9360e ths
    T0 = env->mvp->CP0_MVPConf0;
1030 ead9360e ths
    RETURN();
1031 ead9360e ths
}
1032 ead9360e ths
1033 ead9360e ths
void op_mfc0_mvpconf1 (void)
1034 ead9360e ths
{
1035 ead9360e ths
    T0 = env->mvp->CP0_MVPConf1;
1036 ead9360e ths
    RETURN();
1037 ead9360e ths
}
1038 ead9360e ths
1039 873eb012 ths
void op_mfc0_random (void)
1040 873eb012 ths
{
1041 873eb012 ths
    CALL_FROM_TB0(do_mfc0_random);
1042 873eb012 ths
    RETURN();
1043 873eb012 ths
}
1044 873eb012 ths
1045 ead9360e ths
void op_mfc0_vpecontrol (void)
1046 ead9360e ths
{
1047 ead9360e ths
    T0 = env->CP0_VPEControl;
1048 ead9360e ths
    RETURN();
1049 ead9360e ths
}
1050 ead9360e ths
1051 ead9360e ths
void op_mfc0_vpeconf0 (void)
1052 ead9360e ths
{
1053 ead9360e ths
    T0 = env->CP0_VPEConf0;
1054 ead9360e ths
    RETURN();
1055 ead9360e ths
}
1056 ead9360e ths
1057 ead9360e ths
void op_mfc0_vpeconf1 (void)
1058 ead9360e ths
{
1059 ead9360e ths
    T0 = env->CP0_VPEConf1;
1060 ead9360e ths
    RETURN();
1061 ead9360e ths
}
1062 ead9360e ths
1063 ead9360e ths
void op_mfc0_yqmask (void)
1064 ead9360e ths
{
1065 ead9360e ths
    T0 = env->CP0_YQMask;
1066 ead9360e ths
    RETURN();
1067 ead9360e ths
}
1068 ead9360e ths
1069 ead9360e ths
void op_mfc0_vpeschedule (void)
1070 ead9360e ths
{
1071 ead9360e ths
    T0 = env->CP0_VPESchedule;
1072 ead9360e ths
    RETURN();
1073 ead9360e ths
}
1074 ead9360e ths
1075 ead9360e ths
void op_mfc0_vpeschefback (void)
1076 ead9360e ths
{
1077 ead9360e ths
    T0 = env->CP0_VPEScheFBack;
1078 ead9360e ths
    RETURN();
1079 ead9360e ths
}
1080 ead9360e ths
1081 ead9360e ths
void op_mfc0_vpeopt (void)
1082 ead9360e ths
{
1083 ead9360e ths
    T0 = env->CP0_VPEOpt;
1084 ead9360e ths
    RETURN();
1085 ead9360e ths
}
1086 ead9360e ths
1087 873eb012 ths
void op_mfc0_entrylo0 (void)
1088 873eb012 ths
{
1089 9c2149c8 ths
    T0 = (int32_t)env->CP0_EntryLo0;
1090 873eb012 ths
    RETURN();
1091 873eb012 ths
}
1092 873eb012 ths
1093 ead9360e ths
void op_mfc0_tcstatus (void)
1094 ead9360e ths
{
1095 ead9360e ths
    T0 = env->CP0_TCStatus[env->current_tc];
1096 ead9360e ths
    RETURN();
1097 ead9360e ths
}
1098 ead9360e ths
1099 ead9360e ths
void op_mftc0_tcstatus(void)
1100 ead9360e ths
{
1101 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1102 ead9360e ths
1103 ead9360e ths
    T0 = env->CP0_TCStatus[other_tc];
1104 ead9360e ths
    RETURN();
1105 ead9360e ths
}
1106 ead9360e ths
1107 ead9360e ths
void op_mfc0_tcbind (void)
1108 ead9360e ths
{
1109 ead9360e ths
    T0 = env->CP0_TCBind[env->current_tc];
1110 ead9360e ths
    RETURN();
1111 ead9360e ths
}
1112 ead9360e ths
1113 ead9360e ths
void op_mftc0_tcbind(void)
1114 ead9360e ths
{
1115 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1116 ead9360e ths
1117 ead9360e ths
    T0 = env->CP0_TCBind[other_tc];
1118 ead9360e ths
    RETURN();
1119 ead9360e ths
}
1120 ead9360e ths
1121 ead9360e ths
void op_mfc0_tcrestart (void)
1122 ead9360e ths
{
1123 ead9360e ths
    T0 = env->PC[env->current_tc];
1124 ead9360e ths
    RETURN();
1125 ead9360e ths
}
1126 ead9360e ths
1127 ead9360e ths
void op_mftc0_tcrestart(void)
1128 ead9360e ths
{
1129 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1130 ead9360e ths
1131 ead9360e ths
    T0 = env->PC[other_tc];
1132 ead9360e ths
    RETURN();
1133 ead9360e ths
}
1134 ead9360e ths
1135 ead9360e ths
void op_mfc0_tchalt (void)
1136 ead9360e ths
{
1137 ead9360e ths
    T0 = env->CP0_TCHalt[env->current_tc];
1138 ead9360e ths
    RETURN();
1139 ead9360e ths
}
1140 ead9360e ths
1141 ead9360e ths
void op_mftc0_tchalt(void)
1142 ead9360e ths
{
1143 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1144 ead9360e ths
1145 ead9360e ths
    T0 = env->CP0_TCHalt[other_tc];
1146 ead9360e ths
    RETURN();
1147 ead9360e ths
}
1148 ead9360e ths
1149 ead9360e ths
void op_mfc0_tccontext (void)
1150 ead9360e ths
{
1151 ead9360e ths
    T0 = env->CP0_TCContext[env->current_tc];
1152 ead9360e ths
    RETURN();
1153 ead9360e ths
}
1154 ead9360e ths
1155 ead9360e ths
void op_mftc0_tccontext(void)
1156 ead9360e ths
{
1157 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1158 ead9360e ths
1159 ead9360e ths
    T0 = env->CP0_TCContext[other_tc];
1160 ead9360e ths
    RETURN();
1161 ead9360e ths
}
1162 ead9360e ths
1163 ead9360e ths
void op_mfc0_tcschedule (void)
1164 ead9360e ths
{
1165 ead9360e ths
    T0 = env->CP0_TCSchedule[env->current_tc];
1166 ead9360e ths
    RETURN();
1167 ead9360e ths
}
1168 ead9360e ths
1169 ead9360e ths
void op_mftc0_tcschedule(void)
1170 ead9360e ths
{
1171 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1172 ead9360e ths
1173 ead9360e ths
    T0 = env->CP0_TCSchedule[other_tc];
1174 ead9360e ths
    RETURN();
1175 ead9360e ths
}
1176 ead9360e ths
1177 ead9360e ths
void op_mfc0_tcschefback (void)
1178 ead9360e ths
{
1179 ead9360e ths
    T0 = env->CP0_TCScheFBack[env->current_tc];
1180 ead9360e ths
    RETURN();
1181 ead9360e ths
}
1182 ead9360e ths
1183 ead9360e ths
void op_mftc0_tcschefback(void)
1184 ead9360e ths
{
1185 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1186 ead9360e ths
1187 ead9360e ths
    T0 = env->CP0_TCScheFBack[other_tc];
1188 ead9360e ths
    RETURN();
1189 ead9360e ths
}
1190 ead9360e ths
1191 873eb012 ths
void op_mfc0_entrylo1 (void)
1192 873eb012 ths
{
1193 9c2149c8 ths
    T0 = (int32_t)env->CP0_EntryLo1;
1194 873eb012 ths
    RETURN();
1195 873eb012 ths
}
1196 873eb012 ths
1197 873eb012 ths
void op_mfc0_context (void)
1198 873eb012 ths
{
1199 9c2149c8 ths
    T0 = (int32_t)env->CP0_Context;
1200 873eb012 ths
    RETURN();
1201 873eb012 ths
}
1202 873eb012 ths
1203 873eb012 ths
void op_mfc0_pagemask (void)
1204 873eb012 ths
{
1205 9c2149c8 ths
    T0 = env->CP0_PageMask;
1206 873eb012 ths
    RETURN();
1207 873eb012 ths
}
1208 873eb012 ths
1209 7a387fff ths
void op_mfc0_pagegrain (void)
1210 7a387fff ths
{
1211 9c2149c8 ths
    T0 = env->CP0_PageGrain;
1212 7a387fff ths
    RETURN();
1213 7a387fff ths
}
1214 7a387fff ths
1215 873eb012 ths
void op_mfc0_wired (void)
1216 873eb012 ths
{
1217 9c2149c8 ths
    T0 = env->CP0_Wired;
1218 873eb012 ths
    RETURN();
1219 873eb012 ths
}
1220 873eb012 ths
1221 ead9360e ths
void op_mfc0_srsconf0 (void)
1222 ead9360e ths
{
1223 ead9360e ths
    T0 = env->CP0_SRSConf0;
1224 ead9360e ths
    RETURN();
1225 ead9360e ths
}
1226 ead9360e ths
1227 ead9360e ths
void op_mfc0_srsconf1 (void)
1228 ead9360e ths
{
1229 ead9360e ths
    T0 = env->CP0_SRSConf1;
1230 ead9360e ths
    RETURN();
1231 ead9360e ths
}
1232 ead9360e ths
1233 ead9360e ths
void op_mfc0_srsconf2 (void)
1234 ead9360e ths
{
1235 ead9360e ths
    T0 = env->CP0_SRSConf2;
1236 ead9360e ths
    RETURN();
1237 ead9360e ths
}
1238 ead9360e ths
1239 ead9360e ths
void op_mfc0_srsconf3 (void)
1240 ead9360e ths
{
1241 ead9360e ths
    T0 = env->CP0_SRSConf3;
1242 ead9360e ths
    RETURN();
1243 ead9360e ths
}
1244 ead9360e ths
1245 ead9360e ths
void op_mfc0_srsconf4 (void)
1246 ead9360e ths
{
1247 ead9360e ths
    T0 = env->CP0_SRSConf4;
1248 ead9360e ths
    RETURN();
1249 ead9360e ths
}
1250 ead9360e ths
1251 7a387fff ths
void op_mfc0_hwrena (void)
1252 7a387fff ths
{
1253 9c2149c8 ths
    T0 = env->CP0_HWREna;
1254 7a387fff ths
    RETURN();
1255 7a387fff ths
}
1256 7a387fff ths
1257 873eb012 ths
void op_mfc0_badvaddr (void)
1258 873eb012 ths
{
1259 9c2149c8 ths
    T0 = (int32_t)env->CP0_BadVAddr;
1260 873eb012 ths
    RETURN();
1261 873eb012 ths
}
1262 873eb012 ths
1263 873eb012 ths
void op_mfc0_count (void)
1264 873eb012 ths
{
1265 873eb012 ths
    CALL_FROM_TB0(do_mfc0_count);
1266 873eb012 ths
    RETURN();
1267 873eb012 ths
}
1268 873eb012 ths
1269 873eb012 ths
void op_mfc0_entryhi (void)
1270 873eb012 ths
{
1271 9c2149c8 ths
    T0 = (int32_t)env->CP0_EntryHi;
1272 873eb012 ths
    RETURN();
1273 873eb012 ths
}
1274 873eb012 ths
1275 ead9360e ths
void op_mftc0_entryhi(void)
1276 ead9360e ths
{
1277 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1278 ead9360e ths
1279 ead9360e ths
    T0 = (env->CP0_EntryHi & ~0xff) | (env->CP0_TCStatus[other_tc] & 0xff);
1280 ead9360e ths
    RETURN();
1281 ead9360e ths
}
1282 ead9360e ths
1283 873eb012 ths
void op_mfc0_compare (void)
1284 873eb012 ths
{
1285 9c2149c8 ths
    T0 = env->CP0_Compare;
1286 873eb012 ths
    RETURN();
1287 873eb012 ths
}
1288 873eb012 ths
1289 873eb012 ths
void op_mfc0_status (void)
1290 873eb012 ths
{
1291 9c2149c8 ths
    T0 = env->CP0_Status;
1292 873eb012 ths
    RETURN();
1293 873eb012 ths
}
1294 873eb012 ths
1295 ead9360e ths
void op_mftc0_status(void)
1296 ead9360e ths
{
1297 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1298 ead9360e ths
    uint32_t tcstatus = env->CP0_TCStatus[other_tc];
1299 ead9360e ths
1300 ead9360e ths
    T0 = env->CP0_Status & ~0xf1000018;
1301 ead9360e ths
    T0 |= tcstatus & (0xf << CP0TCSt_TCU0);
1302 ead9360e ths
    T0 |= (tcstatus & (1 << CP0TCSt_TMX)) >> (CP0TCSt_TMX - CP0St_MX);
1303 ead9360e ths
    T0 |= (tcstatus & (0x3 << CP0TCSt_TKSU)) >> (CP0TCSt_TKSU - CP0St_R0);
1304 ead9360e ths
    RETURN();
1305 ead9360e ths
}
1306 ead9360e ths
1307 7a387fff ths
void op_mfc0_intctl (void)
1308 7a387fff ths
{
1309 9c2149c8 ths
    T0 = env->CP0_IntCtl;
1310 7a387fff ths
    RETURN();
1311 7a387fff ths
}
1312 7a387fff ths
1313 7a387fff ths
void op_mfc0_srsctl (void)
1314 7a387fff ths
{
1315 9c2149c8 ths
    T0 = env->CP0_SRSCtl;
1316 9c2149c8 ths
    RETURN();
1317 9c2149c8 ths
}
1318 9c2149c8 ths
1319 9c2149c8 ths
void op_mfc0_srsmap (void)
1320 9c2149c8 ths
{
1321 9c2149c8 ths
    T0 = env->CP0_SRSMap;
1322 7a387fff ths
    RETURN();
1323 7a387fff ths
}
1324 7a387fff ths
1325 873eb012 ths
void op_mfc0_cause (void)
1326 873eb012 ths
{
1327 9c2149c8 ths
    T0 = env->CP0_Cause;
1328 873eb012 ths
    RETURN();
1329 873eb012 ths
}
1330 873eb012 ths
1331 873eb012 ths
void op_mfc0_epc (void)
1332 873eb012 ths
{
1333 9c2149c8 ths
    T0 = (int32_t)env->CP0_EPC;
1334 873eb012 ths
    RETURN();
1335 873eb012 ths
}
1336 873eb012 ths
1337 873eb012 ths
void op_mfc0_prid (void)
1338 873eb012 ths
{
1339 9c2149c8 ths
    T0 = env->CP0_PRid;
1340 873eb012 ths
    RETURN();
1341 873eb012 ths
}
1342 873eb012 ths
1343 7a387fff ths
void op_mfc0_ebase (void)
1344 7a387fff ths
{
1345 b29a0341 ths
    T0 = env->CP0_EBase;
1346 7a387fff ths
    RETURN();
1347 7a387fff ths
}
1348 7a387fff ths
1349 873eb012 ths
void op_mfc0_config0 (void)
1350 873eb012 ths
{
1351 9c2149c8 ths
    T0 = env->CP0_Config0;
1352 873eb012 ths
    RETURN();
1353 873eb012 ths
}
1354 873eb012 ths
1355 873eb012 ths
void op_mfc0_config1 (void)
1356 873eb012 ths
{
1357 9c2149c8 ths
    T0 = env->CP0_Config1;
1358 873eb012 ths
    RETURN();
1359 873eb012 ths
}
1360 873eb012 ths
1361 7a387fff ths
void op_mfc0_config2 (void)
1362 7a387fff ths
{
1363 9c2149c8 ths
    T0 = env->CP0_Config2;
1364 7a387fff ths
    RETURN();
1365 7a387fff ths
}
1366 7a387fff ths
1367 7a387fff ths
void op_mfc0_config3 (void)
1368 7a387fff ths
{
1369 9c2149c8 ths
    T0 = env->CP0_Config3;
1370 7a387fff ths
    RETURN();
1371 7a387fff ths
}
1372 7a387fff ths
1373 e397ee33 ths
void op_mfc0_config6 (void)
1374 e397ee33 ths
{
1375 e397ee33 ths
    T0 = env->CP0_Config6;
1376 e397ee33 ths
    RETURN();
1377 e397ee33 ths
}
1378 e397ee33 ths
1379 e397ee33 ths
void op_mfc0_config7 (void)
1380 e397ee33 ths
{
1381 e397ee33 ths
    T0 = env->CP0_Config7;
1382 e397ee33 ths
    RETURN();
1383 e397ee33 ths
}
1384 e397ee33 ths
1385 873eb012 ths
void op_mfc0_lladdr (void)
1386 873eb012 ths
{
1387 9c2149c8 ths
    T0 = (int32_t)env->CP0_LLAddr >> 4;
1388 873eb012 ths
    RETURN();
1389 873eb012 ths
}
1390 873eb012 ths
1391 fd88b6ab ths
void op_mfc0_watchlo (void)
1392 873eb012 ths
{
1393 fd88b6ab ths
    T0 = (int32_t)env->CP0_WatchLo[PARAM1];
1394 873eb012 ths
    RETURN();
1395 873eb012 ths
}
1396 873eb012 ths
1397 fd88b6ab ths
void op_mfc0_watchhi (void)
1398 873eb012 ths
{
1399 fd88b6ab ths
    T0 = env->CP0_WatchHi[PARAM1];
1400 873eb012 ths
    RETURN();
1401 873eb012 ths
}
1402 873eb012 ths
1403 7a387fff ths
void op_mfc0_xcontext (void)
1404 7a387fff ths
{
1405 9c2149c8 ths
    T0 = (int32_t)env->CP0_XContext;
1406 7a387fff ths
    RETURN();
1407 7a387fff ths
}
1408 7a387fff ths
1409 7a387fff ths
void op_mfc0_framemask (void)
1410 7a387fff ths
{
1411 7a387fff ths
    T0 = env->CP0_Framemask;
1412 7a387fff ths
    RETURN();
1413 7a387fff ths
}
1414 7a387fff ths
1415 873eb012 ths
void op_mfc0_debug (void)
1416 873eb012 ths
{
1417 9c2149c8 ths
    T0 = env->CP0_Debug;
1418 873eb012 ths
    if (env->hflags & MIPS_HFLAG_DM)
1419 873eb012 ths
        T0 |= 1 << CP0DB_DM;
1420 873eb012 ths
    RETURN();
1421 873eb012 ths
}
1422 873eb012 ths
1423 ead9360e ths
void op_mftc0_debug(void)
1424 ead9360e ths
{
1425 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1426 ead9360e ths
1427 ead9360e ths
    /* XXX: Might be wrong, check with EJTAG spec. */
1428 ead9360e ths
    T0 = (env->CP0_Debug & ~((1 << CP0DB_SSt) | (1 << CP0DB_Halt))) |
1429 ead9360e ths
         (env->CP0_Debug_tcstatus[other_tc] &
1430 ead9360e ths
          ((1 << CP0DB_SSt) | (1 << CP0DB_Halt)));
1431 ead9360e ths
    RETURN();
1432 ead9360e ths
}
1433 ead9360e ths
1434 873eb012 ths
void op_mfc0_depc (void)
1435 873eb012 ths
{
1436 9c2149c8 ths
    T0 = (int32_t)env->CP0_DEPC;
1437 873eb012 ths
    RETURN();
1438 873eb012 ths
}
1439 873eb012 ths
1440 7a387fff ths
void op_mfc0_performance0 (void)
1441 7a387fff ths
{
1442 9c2149c8 ths
    T0 = env->CP0_Performance0;
1443 7a387fff ths
    RETURN();
1444 7a387fff ths
}
1445 7a387fff ths
1446 873eb012 ths
void op_mfc0_taglo (void)
1447 873eb012 ths
{
1448 9c2149c8 ths
    T0 = env->CP0_TagLo;
1449 873eb012 ths
    RETURN();
1450 873eb012 ths
}
1451 873eb012 ths
1452 873eb012 ths
void op_mfc0_datalo (void)
1453 873eb012 ths
{
1454 9c2149c8 ths
    T0 = env->CP0_DataLo;
1455 873eb012 ths
    RETURN();
1456 873eb012 ths
}
1457 873eb012 ths
1458 7a387fff ths
void op_mfc0_taghi (void)
1459 7a387fff ths
{
1460 9c2149c8 ths
    T0 = env->CP0_TagHi;
1461 7a387fff ths
    RETURN();
1462 7a387fff ths
}
1463 7a387fff ths
1464 7a387fff ths
void op_mfc0_datahi (void)
1465 7a387fff ths
{
1466 9c2149c8 ths
    T0 = env->CP0_DataHi;
1467 7a387fff ths
    RETURN();
1468 7a387fff ths
}
1469 7a387fff ths
1470 873eb012 ths
void op_mfc0_errorepc (void)
1471 873eb012 ths
{
1472 9c2149c8 ths
    T0 = (int32_t)env->CP0_ErrorEPC;
1473 873eb012 ths
    RETURN();
1474 873eb012 ths
}
1475 873eb012 ths
1476 873eb012 ths
void op_mfc0_desave (void)
1477 873eb012 ths
{
1478 9c2149c8 ths
    T0 = env->CP0_DESAVE;
1479 6af0bf9c bellard
    RETURN();
1480 6af0bf9c bellard
}
1481 6af0bf9c bellard
1482 8c0fdd85 ths
void op_mtc0_index (void)
1483 6af0bf9c bellard
{
1484 60445285 ths
    int num = 1;
1485 60445285 ths
    unsigned int tmp = env->tlb->nb_tlb;
1486 60445285 ths
1487 60445285 ths
    do {
1488 60445285 ths
        tmp >>= 1;
1489 60445285 ths
        num <<= 1;
1490 60445285 ths
    } while (tmp);
1491 60445285 ths
    env->CP0_Index = (env->CP0_Index & 0x80000000) | (T0 & (num - 1));
1492 ead9360e ths
    RETURN();
1493 ead9360e ths
}
1494 ead9360e ths
1495 ead9360e ths
void op_mtc0_mvpcontrol (void)
1496 ead9360e ths
{
1497 ead9360e ths
    uint32_t mask = 0;
1498 ead9360e ths
    uint32_t newval;
1499 ead9360e ths
1500 ead9360e ths
    if (env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP))
1501 ead9360e ths
        mask |= (1 << CP0MVPCo_CPA) | (1 << CP0MVPCo_VPC) |
1502 ead9360e ths
                (1 << CP0MVPCo_EVP);
1503 ead9360e ths
    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
1504 ead9360e ths
        mask |= (1 << CP0MVPCo_STLB);
1505 ead9360e ths
    newval = (env->mvp->CP0_MVPControl & ~mask) | (T0 & mask);
1506 ead9360e ths
1507 ead9360e ths
    // TODO: Enable/disable shared TLB, enable/disable VPEs.
1508 ead9360e ths
1509 ead9360e ths
    env->mvp->CP0_MVPControl = newval;
1510 ead9360e ths
    RETURN();
1511 ead9360e ths
}
1512 ead9360e ths
1513 ead9360e ths
void op_mtc0_vpecontrol (void)
1514 ead9360e ths
{
1515 ead9360e ths
    uint32_t mask;
1516 ead9360e ths
    uint32_t newval;
1517 ead9360e ths
1518 ead9360e ths
    mask = (1 << CP0VPECo_YSI) | (1 << CP0VPECo_GSI) |
1519 ead9360e ths
           (1 << CP0VPECo_TE) | (0xff << CP0VPECo_TargTC);
1520 ead9360e ths
    newval = (env->CP0_VPEControl & ~mask) | (T0 & mask);
1521 ead9360e ths
1522 ead9360e ths
    /* Yield scheduler intercept not implemented. */
1523 ead9360e ths
    /* Gating storage scheduler intercept not implemented. */
1524 ead9360e ths
1525 ead9360e ths
    // TODO: Enable/disable TCs.
1526 ead9360e ths
1527 ead9360e ths
    env->CP0_VPEControl = newval;
1528 ead9360e ths
    RETURN();
1529 ead9360e ths
}
1530 ead9360e ths
1531 ead9360e ths
void op_mtc0_vpeconf0 (void)
1532 ead9360e ths
{
1533 ead9360e ths
    uint32_t mask = 0;
1534 ead9360e ths
    uint32_t newval;
1535 ead9360e ths
1536 ead9360e ths
    if (env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP)) {
1537 ead9360e ths
        if (env->CP0_VPEConf0 & (1 << CP0VPEC0_VPA))
1538 ead9360e ths
            mask |= (0xff << CP0VPEC0_XTC);
1539 ead9360e ths
        mask |= (1 << CP0VPEC0_MVP) | (1 << CP0VPEC0_VPA);
1540 ead9360e ths
    }
1541 ead9360e ths
    newval = (env->CP0_VPEConf0 & ~mask) | (T0 & mask);
1542 ead9360e ths
1543 ead9360e ths
    // TODO: TC exclusive handling due to ERL/EXL.
1544 ead9360e ths
1545 ead9360e ths
    env->CP0_VPEConf0 = newval;
1546 ead9360e ths
    RETURN();
1547 ead9360e ths
}
1548 ead9360e ths
1549 ead9360e ths
void op_mtc0_vpeconf1 (void)
1550 ead9360e ths
{
1551 ead9360e ths
    uint32_t mask = 0;
1552 ead9360e ths
    uint32_t newval;
1553 ead9360e ths
1554 ead9360e ths
    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
1555 ead9360e ths
        mask |= (0xff << CP0VPEC1_NCX) | (0xff << CP0VPEC1_NCP2) |
1556 ead9360e ths
                (0xff << CP0VPEC1_NCP1);
1557 ead9360e ths
    newval = (env->CP0_VPEConf1 & ~mask) | (T0 & mask);
1558 ead9360e ths
1559 ead9360e ths
    /* UDI not implemented. */
1560 ead9360e ths
    /* CP2 not implemented. */
1561 ead9360e ths
1562 ead9360e ths
    // TODO: Handle FPU (CP1) binding.
1563 ead9360e ths
1564 ead9360e ths
    env->CP0_VPEConf1 = newval;
1565 ead9360e ths
    RETURN();
1566 ead9360e ths
}
1567 ead9360e ths
1568 ead9360e ths
void op_mtc0_yqmask (void)
1569 ead9360e ths
{
1570 ead9360e ths
    /* Yield qualifier inputs not implemented. */
1571 ead9360e ths
    env->CP0_YQMask = 0x00000000;
1572 ead9360e ths
    RETURN();
1573 ead9360e ths
}
1574 ead9360e ths
1575 ead9360e ths
void op_mtc0_vpeschedule (void)
1576 ead9360e ths
{
1577 ead9360e ths
    env->CP0_VPESchedule = T0;
1578 ead9360e ths
    RETURN();
1579 ead9360e ths
}
1580 ead9360e ths
1581 ead9360e ths
void op_mtc0_vpeschefback (void)
1582 ead9360e ths
{
1583 ead9360e ths
    env->CP0_VPEScheFBack = T0;
1584 ead9360e ths
    RETURN();
1585 ead9360e ths
}
1586 ead9360e ths
1587 ead9360e ths
void op_mtc0_vpeopt (void)
1588 ead9360e ths
{
1589 ead9360e ths
    env->CP0_VPEOpt = T0 & 0x0000ffff;
1590 8c0fdd85 ths
    RETURN();
1591 8c0fdd85 ths
}
1592 8c0fdd85 ths
1593 8c0fdd85 ths
void op_mtc0_entrylo0 (void)
1594 8c0fdd85 ths
{
1595 7a387fff ths
    /* Large physaddr not implemented */
1596 7a387fff ths
    /* 1k pages not implemented */
1597 f1b0aa5d ths
    env->CP0_EntryLo0 = T0 & 0x3FFFFFFF;
1598 8c0fdd85 ths
    RETURN();
1599 8c0fdd85 ths
}
1600 8c0fdd85 ths
1601 ead9360e ths
void op_mtc0_tcstatus (void)
1602 ead9360e ths
{
1603 ead9360e ths
    uint32_t mask = env->CP0_TCStatus_rw_bitmask;
1604 ead9360e ths
    uint32_t newval;
1605 ead9360e ths
1606 ead9360e ths
    newval = (env->CP0_TCStatus[env->current_tc] & ~mask) | (T0 & mask);
1607 ead9360e ths
1608 ead9360e ths
    // TODO: Sync with CP0_Status.
1609 ead9360e ths
1610 ead9360e ths
    env->CP0_TCStatus[env->current_tc] = newval;
1611 ead9360e ths
    RETURN();
1612 ead9360e ths
}
1613 ead9360e ths
1614 ead9360e ths
void op_mttc0_tcstatus (void)
1615 ead9360e ths
{
1616 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1617 ead9360e ths
1618 ead9360e ths
    // TODO: Sync with CP0_Status.
1619 ead9360e ths
1620 ead9360e ths
    env->CP0_TCStatus[other_tc] = T0;
1621 ead9360e ths
    RETURN();
1622 ead9360e ths
}
1623 ead9360e ths
1624 ead9360e ths
void op_mtc0_tcbind (void)
1625 ead9360e ths
{
1626 ead9360e ths
    uint32_t mask = (1 << CP0TCBd_TBE);
1627 ead9360e ths
    uint32_t newval;
1628 ead9360e ths
1629 ead9360e ths
    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
1630 ead9360e ths
        mask |= (1 << CP0TCBd_CurVPE);
1631 ead9360e ths
    newval = (env->CP0_TCBind[env->current_tc] & ~mask) | (T0 & mask);
1632 ead9360e ths
    env->CP0_TCBind[env->current_tc] = newval;
1633 ead9360e ths
    RETURN();
1634 ead9360e ths
}
1635 ead9360e ths
1636 ead9360e ths
void op_mttc0_tcbind (void)
1637 ead9360e ths
{
1638 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1639 ead9360e ths
    uint32_t mask = (1 << CP0TCBd_TBE);
1640 ead9360e ths
    uint32_t newval;
1641 ead9360e ths
1642 ead9360e ths
    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
1643 ead9360e ths
        mask |= (1 << CP0TCBd_CurVPE);
1644 ead9360e ths
    newval = (env->CP0_TCBind[other_tc] & ~mask) | (T0 & mask);
1645 ead9360e ths
    env->CP0_TCBind[other_tc] = newval;
1646 ead9360e ths
    RETURN();
1647 ead9360e ths
}
1648 ead9360e ths
1649 ead9360e ths
void op_mtc0_tcrestart (void)
1650 ead9360e ths
{
1651 ead9360e ths
    env->PC[env->current_tc] = T0;
1652 ead9360e ths
    env->CP0_TCStatus[env->current_tc] &= ~(1 << CP0TCSt_TDS);
1653 ead9360e ths
    env->CP0_LLAddr = 0ULL;
1654 ead9360e ths
    /* MIPS16 not implemented. */
1655 ead9360e ths
    RETURN();
1656 ead9360e ths
}
1657 ead9360e ths
1658 ead9360e ths
void op_mttc0_tcrestart (void)
1659 ead9360e ths
{
1660 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1661 ead9360e ths
1662 ead9360e ths
    env->PC[other_tc] = T0;
1663 ead9360e ths
    env->CP0_TCStatus[other_tc] &= ~(1 << CP0TCSt_TDS);
1664 ead9360e ths
    env->CP0_LLAddr = 0ULL;
1665 ead9360e ths
    /* MIPS16 not implemented. */
1666 ead9360e ths
    RETURN();
1667 ead9360e ths
}
1668 ead9360e ths
1669 ead9360e ths
void op_mtc0_tchalt (void)
1670 ead9360e ths
{
1671 ead9360e ths
    env->CP0_TCHalt[env->current_tc] = T0 & 0x1;
1672 ead9360e ths
1673 ead9360e ths
    // TODO: Halt TC / Restart (if allocated+active) TC.
1674 ead9360e ths
1675 ead9360e ths
    RETURN();
1676 ead9360e ths
}
1677 ead9360e ths
1678 ead9360e ths
void op_mttc0_tchalt (void)
1679 ead9360e ths
{
1680 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1681 ead9360e ths
1682 ead9360e ths
    // TODO: Halt TC / Restart (if allocated+active) TC.
1683 ead9360e ths
1684 ead9360e ths
    env->CP0_TCHalt[other_tc] = T0;
1685 ead9360e ths
    RETURN();
1686 ead9360e ths
}
1687 ead9360e ths
1688 ead9360e ths
void op_mtc0_tccontext (void)
1689 ead9360e ths
{
1690 ead9360e ths
    env->CP0_TCContext[env->current_tc] = T0;
1691 ead9360e ths
    RETURN();
1692 ead9360e ths
}
1693 ead9360e ths
1694 ead9360e ths
void op_mttc0_tccontext (void)
1695 ead9360e ths
{
1696 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1697 ead9360e ths
1698 ead9360e ths
    env->CP0_TCContext[other_tc] = T0;
1699 ead9360e ths
    RETURN();
1700 ead9360e ths
}
1701 ead9360e ths
1702 ead9360e ths
void op_mtc0_tcschedule (void)
1703 ead9360e ths
{
1704 ead9360e ths
    env->CP0_TCSchedule[env->current_tc] = T0;
1705 ead9360e ths
    RETURN();
1706 ead9360e ths
}
1707 ead9360e ths
1708 ead9360e ths
void op_mttc0_tcschedule (void)
1709 ead9360e ths
{
1710 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1711 ead9360e ths
1712 ead9360e ths
    env->CP0_TCSchedule[other_tc] = T0;
1713 ead9360e ths
    RETURN();
1714 ead9360e ths
}
1715 ead9360e ths
1716 ead9360e ths
void op_mtc0_tcschefback (void)
1717 ead9360e ths
{
1718 ead9360e ths
    env->CP0_TCScheFBack[env->current_tc] = T0;
1719 ead9360e ths
    RETURN();
1720 ead9360e ths
}
1721 ead9360e ths
1722 ead9360e ths
void op_mttc0_tcschefback (void)
1723 ead9360e ths
{
1724 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1725 ead9360e ths
1726 ead9360e ths
    env->CP0_TCScheFBack[other_tc] = T0;
1727 ead9360e ths
    RETURN();
1728 ead9360e ths
}
1729 ead9360e ths
1730 8c0fdd85 ths
void op_mtc0_entrylo1 (void)
1731 8c0fdd85 ths
{
1732 7a387fff ths
    /* Large physaddr not implemented */
1733 7a387fff ths
    /* 1k pages not implemented */
1734 f1b0aa5d ths
    env->CP0_EntryLo1 = T0 & 0x3FFFFFFF;
1735 8c0fdd85 ths
    RETURN();
1736 8c0fdd85 ths
}
1737 8c0fdd85 ths
1738 8c0fdd85 ths
void op_mtc0_context (void)
1739 8c0fdd85 ths
{
1740 534ce69f ths
    env->CP0_Context = (env->CP0_Context & 0x007FFFFF) | (T0 & ~0x007FFFFF);
1741 8c0fdd85 ths
    RETURN();
1742 8c0fdd85 ths
}
1743 8c0fdd85 ths
1744 8c0fdd85 ths
void op_mtc0_pagemask (void)
1745 8c0fdd85 ths
{
1746 7a387fff ths
    /* 1k pages not implemented */
1747 f2e9ebef ths
    env->CP0_PageMask = T0 & (0x1FFFFFFF & (TARGET_PAGE_MASK << 1));
1748 7a387fff ths
    RETURN();
1749 7a387fff ths
}
1750 7a387fff ths
1751 7a387fff ths
void op_mtc0_pagegrain (void)
1752 7a387fff ths
{
1753 7a387fff ths
    /* SmartMIPS not implemented */
1754 7a387fff ths
    /* Large physaddr not implemented */
1755 7a387fff ths
    /* 1k pages not implemented */
1756 7a387fff ths
    env->CP0_PageGrain = 0;
1757 8c0fdd85 ths
    RETURN();
1758 8c0fdd85 ths
}
1759 8c0fdd85 ths
1760 8c0fdd85 ths
void op_mtc0_wired (void)
1761 8c0fdd85 ths
{
1762 ead9360e ths
    env->CP0_Wired = T0 % env->tlb->nb_tlb;
1763 ead9360e ths
    RETURN();
1764 ead9360e ths
}
1765 ead9360e ths
1766 ead9360e ths
void op_mtc0_srsconf0 (void)
1767 ead9360e ths
{
1768 ead9360e ths
    env->CP0_SRSConf0 |= T0 & env->CP0_SRSConf0_rw_bitmask;
1769 ead9360e ths
    RETURN();
1770 ead9360e ths
}
1771 ead9360e ths
1772 ead9360e ths
void op_mtc0_srsconf1 (void)
1773 ead9360e ths
{
1774 ead9360e ths
    env->CP0_SRSConf1 |= T0 & env->CP0_SRSConf1_rw_bitmask;
1775 ead9360e ths
    RETURN();
1776 ead9360e ths
}
1777 ead9360e ths
1778 ead9360e ths
void op_mtc0_srsconf2 (void)
1779 ead9360e ths
{
1780 ead9360e ths
    env->CP0_SRSConf2 |= T0 & env->CP0_SRSConf2_rw_bitmask;
1781 ead9360e ths
    RETURN();
1782 ead9360e ths
}
1783 ead9360e ths
1784 ead9360e ths
void op_mtc0_srsconf3 (void)
1785 ead9360e ths
{
1786 ead9360e ths
    env->CP0_SRSConf3 |= T0 & env->CP0_SRSConf3_rw_bitmask;
1787 ead9360e ths
    RETURN();
1788 ead9360e ths
}
1789 ead9360e ths
1790 ead9360e ths
void op_mtc0_srsconf4 (void)
1791 ead9360e ths
{
1792 ead9360e ths
    env->CP0_SRSConf4 |= T0 & env->CP0_SRSConf4_rw_bitmask;
1793 7a387fff ths
    RETURN();
1794 7a387fff ths
}
1795 7a387fff ths
1796 7a387fff ths
void op_mtc0_hwrena (void)
1797 7a387fff ths
{
1798 7a387fff ths
    env->CP0_HWREna = T0 & 0x0000000F;
1799 8c0fdd85 ths
    RETURN();
1800 8c0fdd85 ths
}
1801 8c0fdd85 ths
1802 8c0fdd85 ths
void op_mtc0_count (void)
1803 8c0fdd85 ths
{
1804 8c0fdd85 ths
    CALL_FROM_TB2(cpu_mips_store_count, env, T0);
1805 8c0fdd85 ths
    RETURN();
1806 8c0fdd85 ths
}
1807 8c0fdd85 ths
1808 8c0fdd85 ths
void op_mtc0_entryhi (void)
1809 8c0fdd85 ths
{
1810 0feef828 ths
    target_ulong old, val;
1811 8c0fdd85 ths
1812 7a387fff ths
    /* 1k pages not implemented */
1813 100ce988 ths
    val = T0 & ((TARGET_PAGE_MASK << 1) | 0xFF);
1814 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
1815 e034e2c3 ths
    val &= env->SEGMask;
1816 100ce988 ths
#endif
1817 8c0fdd85 ths
    old = env->CP0_EntryHi;
1818 8c0fdd85 ths
    env->CP0_EntryHi = val;
1819 ead9360e ths
    if (env->CP0_Config3 & (1 << CP0C3_MT)) {
1820 ead9360e ths
        uint32_t tcst = env->CP0_TCStatus[env->current_tc] & ~0xff;
1821 ead9360e ths
        env->CP0_TCStatus[env->current_tc] = tcst | (val & 0xff);
1822 ead9360e ths
    }
1823 8c0fdd85 ths
    /* If the ASID changes, flush qemu's TLB.  */
1824 8c0fdd85 ths
    if ((old & 0xFF) != (val & 0xFF))
1825 8c0fdd85 ths
        CALL_FROM_TB2(cpu_mips_tlb_flush, env, 1);
1826 8c0fdd85 ths
    RETURN();
1827 8c0fdd85 ths
}
1828 8c0fdd85 ths
1829 ead9360e ths
void op_mttc0_entryhi(void)
1830 ead9360e ths
{
1831 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1832 ead9360e ths
1833 ead9360e ths
    env->CP0_EntryHi = (env->CP0_EntryHi & 0xff) | (T0 & ~0xff);
1834 ead9360e ths
    env->CP0_TCStatus[other_tc] = (env->CP0_TCStatus[other_tc] & ~0xff) | (T0 & 0xff);
1835 ead9360e ths
    RETURN();
1836 ead9360e ths
}
1837 ead9360e ths
1838 8c0fdd85 ths
void op_mtc0_compare (void)
1839 8c0fdd85 ths
{
1840 8c0fdd85 ths
    CALL_FROM_TB2(cpu_mips_store_compare, env, T0);
1841 8c0fdd85 ths
    RETURN();
1842 8c0fdd85 ths
}
1843 8c0fdd85 ths
1844 8c0fdd85 ths
void op_mtc0_status (void)
1845 8c0fdd85 ths
{
1846 4de9b249 ths
    uint32_t val, old;
1847 ead9360e ths
    uint32_t mask = env->CP0_Status_rw_bitmask;
1848 8c0fdd85 ths
1849 f1b0aa5d ths
    val = T0 & mask;
1850 8c0fdd85 ths
    old = env->CP0_Status;
1851 5a5012ec ths
    env->CP0_Status = (env->CP0_Status & ~mask) | val;
1852 08fa4bab ths
    CALL_FROM_TB1(compute_hflags, env);
1853 f41c52f1 ths
    if (loglevel & CPU_LOG_EXEC)
1854 f41c52f1 ths
        CALL_FROM_TB2(do_mtc0_status_debug, old, val);
1855 4de9b249 ths
    CALL_FROM_TB1(cpu_mips_update_irq, env);
1856 8c0fdd85 ths
    RETURN();
1857 8c0fdd85 ths
}
1858 8c0fdd85 ths
1859 ead9360e ths
void op_mttc0_status(void)
1860 ead9360e ths
{
1861 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1862 ead9360e ths
    uint32_t tcstatus = env->CP0_TCStatus[other_tc];
1863 ead9360e ths
1864 ead9360e ths
    env->CP0_Status = T0 & ~0xf1000018;
1865 ead9360e ths
    tcstatus = (tcstatus & ~(0xf << CP0TCSt_TCU0)) | (T0 & (0xf << CP0St_CU0));
1866 ead9360e ths
    tcstatus = (tcstatus & ~(1 << CP0TCSt_TMX)) | ((T0 & (1 << CP0St_MX)) << (CP0TCSt_TMX - CP0St_MX));
1867 ead9360e ths
    tcstatus = (tcstatus & ~(0x3 << CP0TCSt_TKSU)) | ((T0 & (0x3 << CP0St_R0)) << (CP0TCSt_TKSU - CP0St_R0));
1868 ead9360e ths
    env->CP0_TCStatus[other_tc] = tcstatus;
1869 ead9360e ths
    RETURN();
1870 ead9360e ths
}
1871 ead9360e ths
1872 7a387fff ths
void op_mtc0_intctl (void)
1873 7a387fff ths
{
1874 42532189 ths
    /* vectored interrupts not implemented, no performance counters. */
1875 42532189 ths
    env->CP0_IntCtl = (env->CP0_IntCtl & ~0x000002e0) | (T0 & 0x000002e0);
1876 7a387fff ths
    RETURN();
1877 7a387fff ths
}
1878 7a387fff ths
1879 7a387fff ths
void op_mtc0_srsctl (void)
1880 7a387fff ths
{
1881 ead9360e ths
    uint32_t mask = (0xf << CP0SRSCtl_ESS) | (0xf << CP0SRSCtl_PSS);
1882 ead9360e ths
    env->CP0_SRSCtl = (env->CP0_SRSCtl & ~mask) | (T0 & mask);
1883 7a387fff ths
    RETURN();
1884 7a387fff ths
}
1885 7a387fff ths
1886 9c2149c8 ths
void op_mtc0_srsmap (void)
1887 9c2149c8 ths
{
1888 ead9360e ths
    env->CP0_SRSMap = T0;
1889 9c2149c8 ths
    RETURN();
1890 9c2149c8 ths
}
1891 9c2149c8 ths
1892 8c0fdd85 ths
void op_mtc0_cause (void)
1893 8c0fdd85 ths
{
1894 39d51eb8 ths
    uint32_t mask = 0x00C00300;
1895 42532189 ths
    uint32_t old = env->CP0_Cause;
1896 39d51eb8 ths
1897 e189e748 ths
    if (env->insn_flags & ISA_MIPS32R2)
1898 39d51eb8 ths
        mask |= 1 << CP0Ca_DC;
1899 39d51eb8 ths
1900 e58c8ba5 ths
    env->CP0_Cause = (env->CP0_Cause & ~mask) | (T0 & mask);
1901 8c0fdd85 ths
1902 42532189 ths
    if ((old ^ env->CP0_Cause) & (1 << CP0Ca_DC)) {
1903 42532189 ths
        if (env->CP0_Cause & (1 << CP0Ca_DC))
1904 42532189 ths
            CALL_FROM_TB1(cpu_mips_stop_count, env);
1905 42532189 ths
        else
1906 42532189 ths
            CALL_FROM_TB1(cpu_mips_start_count, env);
1907 42532189 ths
    }
1908 42532189 ths
1909 4de9b249 ths
    /* Handle the software interrupt as an hardware one, as they
1910 4de9b249 ths
       are very similar */
1911 4de9b249 ths
    if (T0 & CP0Ca_IP_mask) {
1912 4de9b249 ths
        CALL_FROM_TB1(cpu_mips_update_irq, env);
1913 8c0fdd85 ths
    }
1914 8c0fdd85 ths
    RETURN();
1915 8c0fdd85 ths
}
1916 8c0fdd85 ths
1917 8c0fdd85 ths
void op_mtc0_epc (void)
1918 8c0fdd85 ths
{
1919 f1b0aa5d ths
    env->CP0_EPC = T0;
1920 8c0fdd85 ths
    RETURN();
1921 8c0fdd85 ths
}
1922 8c0fdd85 ths
1923 7a387fff ths
void op_mtc0_ebase (void)
1924 7a387fff ths
{
1925 7a387fff ths
    /* vectored interrupts not implemented */
1926 7a387fff ths
    /* Multi-CPU not implemented */
1927 b29a0341 ths
    env->CP0_EBase = 0x80000000 | (T0 & 0x3FFFF000);
1928 7a387fff ths
    RETURN();
1929 7a387fff ths
}
1930 7a387fff ths
1931 8c0fdd85 ths
void op_mtc0_config0 (void)
1932 8c0fdd85 ths
{
1933 7bfd934a ths
    env->CP0_Config0 = (env->CP0_Config0 & 0x81FFFFF8) | (T0 & 0x00000007);
1934 8c0fdd85 ths
    RETURN();
1935 8c0fdd85 ths
}
1936 8c0fdd85 ths
1937 7a387fff ths
void op_mtc0_config2 (void)
1938 7a387fff ths
{
1939 7a387fff ths
    /* tertiary/secondary caches not implemented */
1940 7a387fff ths
    env->CP0_Config2 = (env->CP0_Config2 & 0x8FFF0FFF);
1941 7a387fff ths
    RETURN();
1942 7a387fff ths
}
1943 7a387fff ths
1944 fd88b6ab ths
void op_mtc0_watchlo (void)
1945 8c0fdd85 ths
{
1946 4e7a4a4e ths
    /* Watch exceptions for instructions, data loads, data stores
1947 4e7a4a4e ths
       not implemented. */
1948 fd88b6ab ths
    env->CP0_WatchLo[PARAM1] = (T0 & ~0x7);
1949 8c0fdd85 ths
    RETURN();
1950 8c0fdd85 ths
}
1951 8c0fdd85 ths
1952 fd88b6ab ths
void op_mtc0_watchhi (void)
1953 8c0fdd85 ths
{
1954 fd88b6ab ths
    env->CP0_WatchHi[PARAM1] = (T0 & 0x40FF0FF8);
1955 fd88b6ab ths
    env->CP0_WatchHi[PARAM1] &= ~(env->CP0_WatchHi[PARAM1] & T0 & 0x7);
1956 8c0fdd85 ths
    RETURN();
1957 8c0fdd85 ths
}
1958 8c0fdd85 ths
1959 ead9360e ths
void op_mtc0_xcontext (void)
1960 ead9360e ths
{
1961 ead9360e ths
    target_ulong mask = (1ULL << (env->SEGBITS - 7)) - 1;
1962 ead9360e ths
    env->CP0_XContext = (env->CP0_XContext & mask) | (T0 & ~mask);
1963 ead9360e ths
    RETURN();
1964 ead9360e ths
}
1965 ead9360e ths
1966 7a387fff ths
void op_mtc0_framemask (void)
1967 7a387fff ths
{
1968 7a387fff ths
    env->CP0_Framemask = T0; /* XXX */
1969 7a387fff ths
    RETURN();
1970 7a387fff ths
}
1971 7a387fff ths
1972 8c0fdd85 ths
void op_mtc0_debug (void)
1973 8c0fdd85 ths
{
1974 8c0fdd85 ths
    env->CP0_Debug = (env->CP0_Debug & 0x8C03FC1F) | (T0 & 0x13300120);
1975 8c0fdd85 ths
    if (T0 & (1 << CP0DB_DM))
1976 8c0fdd85 ths
        env->hflags |= MIPS_HFLAG_DM;
1977 8c0fdd85 ths
    else
1978 8c0fdd85 ths
        env->hflags &= ~MIPS_HFLAG_DM;
1979 8c0fdd85 ths
    RETURN();
1980 8c0fdd85 ths
}
1981 8c0fdd85 ths
1982 ead9360e ths
void op_mttc0_debug(void)
1983 ead9360e ths
{
1984 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1985 ead9360e ths
1986 ead9360e ths
    /* XXX: Might be wrong, check with EJTAG spec. */
1987 ead9360e ths
    env->CP0_Debug_tcstatus[other_tc] = T0 & ((1 << CP0DB_SSt) | (1 << CP0DB_Halt));
1988 ead9360e ths
    env->CP0_Debug = (env->CP0_Debug & ((1 << CP0DB_SSt) | (1 << CP0DB_Halt))) |
1989 ead9360e ths
                     (T0 & ~((1 << CP0DB_SSt) | (1 << CP0DB_Halt)));
1990 ead9360e ths
    RETURN();
1991 ead9360e ths
}
1992 ead9360e ths
1993 8c0fdd85 ths
void op_mtc0_depc (void)
1994 8c0fdd85 ths
{
1995 f1b0aa5d ths
    env->CP0_DEPC = T0;
1996 8c0fdd85 ths
    RETURN();
1997 8c0fdd85 ths
}
1998 8c0fdd85 ths
1999 7a387fff ths
void op_mtc0_performance0 (void)
2000 7a387fff ths
{
2001 7a387fff ths
    env->CP0_Performance0 = T0; /* XXX */
2002 7a387fff ths
    RETURN();
2003 7a387fff ths
}
2004 7a387fff ths
2005 8c0fdd85 ths
void op_mtc0_taglo (void)
2006 8c0fdd85 ths
{
2007 9c2149c8 ths
    env->CP0_TagLo = T0 & 0xFFFFFCF6;
2008 8c0fdd85 ths
    RETURN();
2009 8c0fdd85 ths
}
2010 8c0fdd85 ths
2011 7a387fff ths
void op_mtc0_datalo (void)
2012 7a387fff ths
{
2013 7a387fff ths
    env->CP0_DataLo = T0; /* XXX */
2014 7a387fff ths
    RETURN();
2015 7a387fff ths
}
2016 7a387fff ths
2017 7a387fff ths
void op_mtc0_taghi (void)
2018 7a387fff ths
{
2019 7a387fff ths
    env->CP0_TagHi = T0; /* XXX */
2020 7a387fff ths
    RETURN();
2021 7a387fff ths
}
2022 7a387fff ths
2023 7a387fff ths
void op_mtc0_datahi (void)
2024 7a387fff ths
{
2025 7a387fff ths
    env->CP0_DataHi = T0; /* XXX */
2026 7a387fff ths
    RETURN();
2027 7a387fff ths
}
2028 7a387fff ths
2029 8c0fdd85 ths
void op_mtc0_errorepc (void)
2030 8c0fdd85 ths
{
2031 f1b0aa5d ths
    env->CP0_ErrorEPC = T0;
2032 8c0fdd85 ths
    RETURN();
2033 8c0fdd85 ths
}
2034 8c0fdd85 ths
2035 8c0fdd85 ths
void op_mtc0_desave (void)
2036 8c0fdd85 ths
{
2037 8c0fdd85 ths
    env->CP0_DESAVE = T0;
2038 6af0bf9c bellard
    RETURN();
2039 6af0bf9c bellard
}
2040 6af0bf9c bellard
2041 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
2042 ead9360e ths
void op_dmfc0_yqmask (void)
2043 f1b0aa5d ths
{
2044 ead9360e ths
    T0 = env->CP0_YQMask;
2045 ead9360e ths
    RETURN();
2046 ead9360e ths
}
2047 ead9360e ths
2048 ead9360e ths
void op_dmfc0_vpeschedule (void)
2049 ead9360e ths
{
2050 ead9360e ths
    T0 = env->CP0_VPESchedule;
2051 ead9360e ths
    RETURN();
2052 ead9360e ths
}
2053 ead9360e ths
2054 ead9360e ths
void op_dmfc0_vpeschefback (void)
2055 ead9360e ths
{
2056 ead9360e ths
    T0 = env->CP0_VPEScheFBack;
2057 f1b0aa5d ths
    RETURN();
2058 f1b0aa5d ths
}
2059 f1b0aa5d ths
2060 9c2149c8 ths
void op_dmfc0_entrylo0 (void)
2061 9c2149c8 ths
{
2062 9c2149c8 ths
    T0 = env->CP0_EntryLo0;
2063 9c2149c8 ths
    RETURN();
2064 9c2149c8 ths
}
2065 9c2149c8 ths
2066 ead9360e ths
void op_dmfc0_tcrestart (void)
2067 ead9360e ths
{
2068 ead9360e ths
    T0 = env->PC[env->current_tc];
2069 ead9360e ths
    RETURN();
2070 ead9360e ths
}
2071 ead9360e ths
2072 ead9360e ths
void op_dmfc0_tchalt (void)
2073 ead9360e ths
{
2074 ead9360e ths
    T0 = env->CP0_TCHalt[env->current_tc];
2075 ead9360e ths
    RETURN();
2076 ead9360e ths
}
2077 ead9360e ths
2078 ead9360e ths
void op_dmfc0_tccontext (void)
2079 ead9360e ths
{
2080 ead9360e ths
    T0 = env->CP0_TCContext[env->current_tc];
2081 ead9360e ths
    RETURN();
2082 ead9360e ths
}
2083 ead9360e ths
2084 ead9360e ths
void op_dmfc0_tcschedule (void)
2085 ead9360e ths
{
2086 ead9360e ths
    T0 = env->CP0_TCSchedule[env->current_tc];
2087 ead9360e ths
    RETURN();
2088 ead9360e ths
}
2089 ead9360e ths
2090 ead9360e ths
void op_dmfc0_tcschefback (void)
2091 ead9360e ths
{
2092 ead9360e ths
    T0 = env->CP0_TCScheFBack[env->current_tc];
2093 ead9360e ths
    RETURN();
2094 ead9360e ths
}
2095 ead9360e ths
2096 9c2149c8 ths
void op_dmfc0_entrylo1 (void)
2097 9c2149c8 ths
{
2098 9c2149c8 ths
    T0 = env->CP0_EntryLo1;
2099 9c2149c8 ths
    RETURN();
2100 9c2149c8 ths
}
2101 9c2149c8 ths
2102 9c2149c8 ths
void op_dmfc0_context (void)
2103 9c2149c8 ths
{
2104 9c2149c8 ths
    T0 = env->CP0_Context;
2105 9c2149c8 ths
    RETURN();
2106 9c2149c8 ths
}
2107 9c2149c8 ths
2108 9c2149c8 ths
void op_dmfc0_badvaddr (void)
2109 9c2149c8 ths
{
2110 9c2149c8 ths
    T0 = env->CP0_BadVAddr;
2111 9c2149c8 ths
    RETURN();
2112 9c2149c8 ths
}
2113 9c2149c8 ths
2114 9c2149c8 ths
void op_dmfc0_entryhi (void)
2115 9c2149c8 ths
{
2116 9c2149c8 ths
    T0 = env->CP0_EntryHi;
2117 9c2149c8 ths
    RETURN();
2118 9c2149c8 ths
}
2119 9c2149c8 ths
2120 9c2149c8 ths
void op_dmfc0_epc (void)
2121 9c2149c8 ths
{
2122 9c2149c8 ths
    T0 = env->CP0_EPC;
2123 9c2149c8 ths
    RETURN();
2124 9c2149c8 ths
}
2125 9c2149c8 ths
2126 9c2149c8 ths
void op_dmfc0_lladdr (void)
2127 9c2149c8 ths
{
2128 9c2149c8 ths
    T0 = env->CP0_LLAddr >> 4;
2129 9c2149c8 ths
    RETURN();
2130 9c2149c8 ths
}
2131 9c2149c8 ths
2132 fd88b6ab ths
void op_dmfc0_watchlo (void)
2133 9c2149c8 ths
{
2134 fd88b6ab ths
    T0 = env->CP0_WatchLo[PARAM1];
2135 9c2149c8 ths
    RETURN();
2136 9c2149c8 ths
}
2137 9c2149c8 ths
2138 9c2149c8 ths
void op_dmfc0_xcontext (void)
2139 9c2149c8 ths
{
2140 9c2149c8 ths
    T0 = env->CP0_XContext;
2141 9c2149c8 ths
    RETURN();
2142 9c2149c8 ths
}
2143 9c2149c8 ths
2144 9c2149c8 ths
void op_dmfc0_depc (void)
2145 9c2149c8 ths
{
2146 9c2149c8 ths
    T0 = env->CP0_DEPC;
2147 9c2149c8 ths
    RETURN();
2148 9c2149c8 ths
}
2149 9c2149c8 ths
2150 9c2149c8 ths
void op_dmfc0_errorepc (void)
2151 9c2149c8 ths
{
2152 9c2149c8 ths
    T0 = env->CP0_ErrorEPC;
2153 9c2149c8 ths
    RETURN();
2154 9c2149c8 ths
}
2155 540635ba ths
#endif /* TARGET_MIPSN32 || TARGET_MIPS64 */
2156 9c2149c8 ths
2157 ead9360e ths
/* MIPS MT functions */
2158 ead9360e ths
void op_mftgpr(void)
2159 ead9360e ths
{
2160 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2161 ead9360e ths
2162 ead9360e ths
    T0 = env->gpr[PARAM1][other_tc];
2163 ead9360e ths
    RETURN();
2164 ead9360e ths
}
2165 ead9360e ths
2166 ead9360e ths
void op_mftlo(void)
2167 ead9360e ths
{
2168 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2169 ead9360e ths
2170 ead9360e ths
    T0 = env->LO[PARAM1][other_tc];
2171 ead9360e ths
    RETURN();
2172 ead9360e ths
}
2173 ead9360e ths
2174 ead9360e ths
void op_mfthi(void)
2175 ead9360e ths
{
2176 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2177 ead9360e ths
2178 ead9360e ths
    T0 = env->HI[PARAM1][other_tc];
2179 ead9360e ths
    RETURN();
2180 ead9360e ths
}
2181 ead9360e ths
2182 ead9360e ths
void op_mftacx(void)
2183 ead9360e ths
{
2184 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2185 ead9360e ths
2186 ead9360e ths
    T0 = env->ACX[PARAM1][other_tc];
2187 ead9360e ths
    RETURN();
2188 ead9360e ths
}
2189 ead9360e ths
2190 ead9360e ths
void op_mftdsp(void)
2191 ead9360e ths
{
2192 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2193 ead9360e ths
2194 ead9360e ths
    T0 = env->DSPControl[other_tc];
2195 ead9360e ths
    RETURN();
2196 ead9360e ths
}
2197 ead9360e ths
2198 ead9360e ths
void op_mttgpr(void)
2199 ead9360e ths
{
2200 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2201 ead9360e ths
2202 ead9360e ths
    T0 = env->gpr[PARAM1][other_tc];
2203 ead9360e ths
    RETURN();
2204 ead9360e ths
}
2205 ead9360e ths
2206 ead9360e ths
void op_mttlo(void)
2207 ead9360e ths
{
2208 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2209 ead9360e ths
2210 ead9360e ths
    T0 = env->LO[PARAM1][other_tc];
2211 ead9360e ths
    RETURN();
2212 ead9360e ths
}
2213 ead9360e ths
2214 ead9360e ths
void op_mtthi(void)
2215 ead9360e ths
{
2216 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2217 ead9360e ths
2218 ead9360e ths
    T0 = env->HI[PARAM1][other_tc];
2219 ead9360e ths
    RETURN();
2220 ead9360e ths
}
2221 ead9360e ths
2222 ead9360e ths
void op_mttacx(void)
2223 ead9360e ths
{
2224 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2225 ead9360e ths
2226 ead9360e ths
    T0 = env->ACX[PARAM1][other_tc];
2227 ead9360e ths
    RETURN();
2228 ead9360e ths
}
2229 ead9360e ths
2230 ead9360e ths
void op_mttdsp(void)
2231 ead9360e ths
{
2232 ead9360e ths
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
2233 ead9360e ths
2234 ead9360e ths
    T0 = env->DSPControl[other_tc];
2235 ead9360e ths
    RETURN();
2236 ead9360e ths
}
2237 ead9360e ths
2238 ead9360e ths
2239 ead9360e ths
void op_dmt(void)
2240 ead9360e ths
{
2241 ead9360e ths
    // TODO
2242 ead9360e ths
    T0 = 0;
2243 ead9360e ths
    // rt = T0
2244 ead9360e ths
    RETURN();
2245 ead9360e ths
}
2246 ead9360e ths
2247 ead9360e ths
void op_emt(void)
2248 ead9360e ths
{
2249 ead9360e ths
    // TODO
2250 ead9360e ths
    T0 = 0;
2251 ead9360e ths
    // rt = T0
2252 ead9360e ths
    RETURN();
2253 ead9360e ths
}
2254 ead9360e ths
2255 ead9360e ths
void op_dvpe(void)
2256 ead9360e ths
{
2257 ead9360e ths
    // TODO
2258 ead9360e ths
    T0 = 0;
2259 ead9360e ths
    // rt = T0
2260 ead9360e ths
    RETURN();
2261 ead9360e ths
}
2262 ead9360e ths
2263 ead9360e ths
void op_evpe(void)
2264 ead9360e ths
{
2265 ead9360e ths
    // TODO
2266 ead9360e ths
    T0 = 0;
2267 ead9360e ths
    // rt = T0
2268 ead9360e ths
    RETURN();
2269 ead9360e ths
}
2270 ead9360e ths
2271 ead9360e ths
void op_fork(void)
2272 ead9360e ths
{
2273 ead9360e ths
    // T0 = rt, T1 = rs
2274 ead9360e ths
    T0 = 0;
2275 ead9360e ths
    // TODO: store to TC register
2276 ead9360e ths
    RETURN();
2277 ead9360e ths
}
2278 ead9360e ths
2279 ead9360e ths
void op_yield(void)
2280 ead9360e ths
{
2281 ead9360e ths
    if (T0 < 0) {
2282 ead9360e ths
        /* No scheduling policy implemented. */
2283 ead9360e ths
        if (T0 != -2) {
2284 ead9360e ths
            if (env->CP0_VPEControl & (1 << CP0VPECo_YSI) &&
2285 ead9360e ths
                env->CP0_TCStatus[env->current_tc] & (1 << CP0TCSt_DT)) {
2286 ead9360e ths
                env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT);
2287 ead9360e ths
                env->CP0_VPEControl |= 4 << CP0VPECo_EXCPT;
2288 ead9360e ths
                CALL_FROM_TB1(do_raise_exception, EXCP_THREAD);
2289 ead9360e ths
            }
2290 ead9360e ths
        }
2291 ead9360e ths
    } else if (T0 == 0) {
2292 ead9360e ths
        if (0 /* TODO: TC underflow */) {
2293 ead9360e ths
            env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT);
2294 ead9360e ths
            CALL_FROM_TB1(do_raise_exception, EXCP_THREAD);
2295 ead9360e ths
        } else {
2296 ead9360e ths
            // TODO: Deallocate TC
2297 ead9360e ths
        }
2298 ead9360e ths
    } else if (T0 > 0) {
2299 ead9360e ths
        /* Yield qualifier inputs not implemented. */
2300 ead9360e ths
        env->CP0_VPEControl &= ~(0x7 << CP0VPECo_EXCPT);
2301 ead9360e ths
        env->CP0_VPEControl |= 2 << CP0VPECo_EXCPT;
2302 ead9360e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_THREAD);
2303 ead9360e ths
    }
2304 ead9360e ths
    T0 = env->CP0_YQMask;
2305 ead9360e ths
    RETURN();
2306 ead9360e ths
}
2307 ead9360e ths
2308 5a5012ec ths
/* CP1 functions */
2309 6ea83fed bellard
#if 0
2310 6ea83fed bellard
# define DEBUG_FPU_STATE() CALL_FROM_TB1(dump_fpu, env)
2311 6ea83fed bellard
#else
2312 6ea83fed bellard
# define DEBUG_FPU_STATE() do { } while(0)
2313 6ea83fed bellard
#endif
2314 6ea83fed bellard
2315 5a5012ec ths
void op_cfc1 (void)
2316 5a5012ec ths
{
2317 ead9360e ths
    CALL_FROM_TB1(do_cfc1, PARAM1);
2318 5a5012ec ths
    DEBUG_FPU_STATE();
2319 5a5012ec ths
    RETURN();
2320 5a5012ec ths
}
2321 5a5012ec ths
2322 5a5012ec ths
void op_ctc1 (void)
2323 5a5012ec ths
{
2324 ead9360e ths
    CALL_FROM_TB1(do_ctc1, PARAM1);
2325 6ea83fed bellard
    DEBUG_FPU_STATE();
2326 6ea83fed bellard
    RETURN();
2327 6ea83fed bellard
}
2328 6ea83fed bellard
2329 6ea83fed bellard
void op_mfc1 (void)
2330 6ea83fed bellard
{
2331 6ea83fed bellard
    T0 = WT0;
2332 6ea83fed bellard
    DEBUG_FPU_STATE();
2333 6ea83fed bellard
    RETURN();
2334 6ea83fed bellard
}
2335 6ea83fed bellard
2336 6ea83fed bellard
void op_mtc1 (void)
2337 6ea83fed bellard
{
2338 6ea83fed bellard
    WT0 = T0;
2339 6ea83fed bellard
    DEBUG_FPU_STATE();
2340 6ea83fed bellard
    RETURN();
2341 6ea83fed bellard
}
2342 6ea83fed bellard
2343 5a5012ec ths
void op_dmfc1 (void)
2344 5a5012ec ths
{
2345 5a5012ec ths
    T0 = DT0;
2346 5a5012ec ths
    DEBUG_FPU_STATE();
2347 5a5012ec ths
    RETURN();
2348 5a5012ec ths
}
2349 5a5012ec ths
2350 5a5012ec ths
void op_dmtc1 (void)
2351 5a5012ec ths
{
2352 5a5012ec ths
    DT0 = T0;
2353 5a5012ec ths
    DEBUG_FPU_STATE();
2354 5a5012ec ths
    RETURN();
2355 5a5012ec ths
}
2356 5a5012ec ths
2357 5a5012ec ths
void op_mfhc1 (void)
2358 5a5012ec ths
{
2359 5a5012ec ths
    T0 = WTH0;
2360 5a5012ec ths
    DEBUG_FPU_STATE();
2361 5a5012ec ths
    RETURN();
2362 5a5012ec ths
}
2363 5a5012ec ths
2364 5a5012ec ths
void op_mthc1 (void)
2365 5a5012ec ths
{
2366 5a5012ec ths
    WTH0 = T0;
2367 5a5012ec ths
    DEBUG_FPU_STATE();
2368 5a5012ec ths
    RETURN();
2369 5a5012ec ths
}
2370 5a5012ec ths
2371 6ea83fed bellard
/* Float support.
2372 6ea83fed bellard
   Single precition routines have a "s" suffix, double precision a
2373 5a5012ec ths
   "d" suffix, 32bit integer "w", 64bit integer "l", paired singe "ps",
2374 5a5012ec ths
   paired single lowwer "pl", paired single upper "pu".  */
2375 6ea83fed bellard
2376 6ea83fed bellard
#define FLOAT_OP(name, p) void OPPROTO op_float_##name##_##p(void)
2377 6ea83fed bellard
2378 dd016883 bellard
FLOAT_OP(cvtd, s)
2379 dd016883 bellard
{
2380 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtd_s);
2381 dd016883 bellard
    DEBUG_FPU_STATE();
2382 dd016883 bellard
    RETURN();
2383 dd016883 bellard
}
2384 6ea83fed bellard
FLOAT_OP(cvtd, w)
2385 6ea83fed bellard
{
2386 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtd_w);
2387 5a5012ec ths
    DEBUG_FPU_STATE();
2388 5a5012ec ths
    RETURN();
2389 5a5012ec ths
}
2390 5a5012ec ths
FLOAT_OP(cvtd, l)
2391 5a5012ec ths
{
2392 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtd_l);
2393 5a5012ec ths
    DEBUG_FPU_STATE();
2394 5a5012ec ths
    RETURN();
2395 5a5012ec ths
}
2396 5a5012ec ths
FLOAT_OP(cvtl, d)
2397 5a5012ec ths
{
2398 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtl_d);
2399 5a5012ec ths
    DEBUG_FPU_STATE();
2400 5a5012ec ths
    RETURN();
2401 5a5012ec ths
}
2402 5a5012ec ths
FLOAT_OP(cvtl, s)
2403 5a5012ec ths
{
2404 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtl_s);
2405 5a5012ec ths
    DEBUG_FPU_STATE();
2406 5a5012ec ths
    RETURN();
2407 5a5012ec ths
}
2408 5a5012ec ths
FLOAT_OP(cvtps, s)
2409 5a5012ec ths
{
2410 5a5012ec ths
    WT2 = WT0;
2411 5a5012ec ths
    WTH2 = WT1;
2412 5a5012ec ths
    DEBUG_FPU_STATE();
2413 5a5012ec ths
    RETURN();
2414 5a5012ec ths
}
2415 5a5012ec ths
FLOAT_OP(cvtps, pw)
2416 5a5012ec ths
{
2417 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtps_pw);
2418 5a5012ec ths
    DEBUG_FPU_STATE();
2419 5a5012ec ths
    RETURN();
2420 5a5012ec ths
}
2421 5a5012ec ths
FLOAT_OP(cvtpw, ps)
2422 5a5012ec ths
{
2423 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtpw_ps);
2424 6ea83fed bellard
    DEBUG_FPU_STATE();
2425 6ea83fed bellard
    RETURN();
2426 6ea83fed bellard
}
2427 dd016883 bellard
FLOAT_OP(cvts, d)
2428 dd016883 bellard
{
2429 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvts_d);
2430 dd016883 bellard
    DEBUG_FPU_STATE();
2431 dd016883 bellard
    RETURN();
2432 dd016883 bellard
}
2433 6ea83fed bellard
FLOAT_OP(cvts, w)
2434 6ea83fed bellard
{
2435 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvts_w);
2436 5a5012ec ths
    DEBUG_FPU_STATE();
2437 5a5012ec ths
    RETURN();
2438 5a5012ec ths
}
2439 5a5012ec ths
FLOAT_OP(cvts, l)
2440 5a5012ec ths
{
2441 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvts_l);
2442 5a5012ec ths
    DEBUG_FPU_STATE();
2443 5a5012ec ths
    RETURN();
2444 5a5012ec ths
}
2445 5a5012ec ths
FLOAT_OP(cvts, pl)
2446 5a5012ec ths
{
2447 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvts_pl);
2448 5a5012ec ths
    DEBUG_FPU_STATE();
2449 5a5012ec ths
    RETURN();
2450 5a5012ec ths
}
2451 5a5012ec ths
FLOAT_OP(cvts, pu)
2452 5a5012ec ths
{
2453 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvts_pu);
2454 6ea83fed bellard
    DEBUG_FPU_STATE();
2455 6ea83fed bellard
    RETURN();
2456 6ea83fed bellard
}
2457 6ea83fed bellard
FLOAT_OP(cvtw, s)
2458 6ea83fed bellard
{
2459 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtw_s);
2460 6ea83fed bellard
    DEBUG_FPU_STATE();
2461 6ea83fed bellard
    RETURN();
2462 6ea83fed bellard
}
2463 6ea83fed bellard
FLOAT_OP(cvtw, d)
2464 6ea83fed bellard
{
2465 fd4a04eb ths
    CALL_FROM_TB0(do_float_cvtw_d);
2466 5a5012ec ths
    DEBUG_FPU_STATE();
2467 5a5012ec ths
    RETURN();
2468 5a5012ec ths
}
2469 5a5012ec ths
2470 5a5012ec ths
FLOAT_OP(pll, ps)
2471 5a5012ec ths
{
2472 5a5012ec ths
    DT2 = ((uint64_t)WT0 << 32) | WT1;
2473 5a5012ec ths
    DEBUG_FPU_STATE();
2474 5a5012ec ths
    RETURN();
2475 5a5012ec ths
}
2476 5a5012ec ths
FLOAT_OP(plu, ps)
2477 5a5012ec ths
{
2478 5a5012ec ths
    DT2 = ((uint64_t)WT0 << 32) | WTH1;
2479 5a5012ec ths
    DEBUG_FPU_STATE();
2480 5a5012ec ths
    RETURN();
2481 5a5012ec ths
}
2482 5a5012ec ths
FLOAT_OP(pul, ps)
2483 5a5012ec ths
{
2484 5a5012ec ths
    DT2 = ((uint64_t)WTH0 << 32) | WT1;
2485 5a5012ec ths
    DEBUG_FPU_STATE();
2486 5a5012ec ths
    RETURN();
2487 5a5012ec ths
}
2488 5a5012ec ths
FLOAT_OP(puu, ps)
2489 5a5012ec ths
{
2490 5a5012ec ths
    DT2 = ((uint64_t)WTH0 << 32) | WTH1;
2491 6ea83fed bellard
    DEBUG_FPU_STATE();
2492 6ea83fed bellard
    RETURN();
2493 6ea83fed bellard
}
2494 6ea83fed bellard
2495 fd4a04eb ths
#define FLOAT_ROUNDOP(op, ttype, stype)                    \
2496 fd4a04eb ths
FLOAT_OP(op ## ttype, stype)                               \
2497 fd4a04eb ths
{                                                          \
2498 fd4a04eb ths
    CALL_FROM_TB0(do_float_ ## op ## ttype ## _ ## stype); \
2499 fd4a04eb ths
    DEBUG_FPU_STATE();                                     \
2500 fd4a04eb ths
    RETURN();                                              \
2501 6ea83fed bellard
}
2502 6ea83fed bellard
2503 fd4a04eb ths
FLOAT_ROUNDOP(round, l, d)
2504 fd4a04eb ths
FLOAT_ROUNDOP(round, l, s)
2505 fd4a04eb ths
FLOAT_ROUNDOP(round, w, d)
2506 fd4a04eb ths
FLOAT_ROUNDOP(round, w, s)
2507 6ea83fed bellard
2508 fd4a04eb ths
FLOAT_ROUNDOP(trunc, l, d)
2509 fd4a04eb ths
FLOAT_ROUNDOP(trunc, l, s)
2510 fd4a04eb ths
FLOAT_ROUNDOP(trunc, w, d)
2511 fd4a04eb ths
FLOAT_ROUNDOP(trunc, w, s)
2512 6ea83fed bellard
2513 fd4a04eb ths
FLOAT_ROUNDOP(ceil, l, d)
2514 fd4a04eb ths
FLOAT_ROUNDOP(ceil, l, s)
2515 fd4a04eb ths
FLOAT_ROUNDOP(ceil, w, d)
2516 fd4a04eb ths
FLOAT_ROUNDOP(ceil, w, s)
2517 fd4a04eb ths
2518 fd4a04eb ths
FLOAT_ROUNDOP(floor, l, d)
2519 fd4a04eb ths
FLOAT_ROUNDOP(floor, l, s)
2520 fd4a04eb ths
FLOAT_ROUNDOP(floor, w, d)
2521 fd4a04eb ths
FLOAT_ROUNDOP(floor, w, s)
2522 fd4a04eb ths
#undef FLOAR_ROUNDOP
2523 6ea83fed bellard
2524 5a5012ec ths
FLOAT_OP(movf, d)
2525 5a5012ec ths
{
2526 ead9360e ths
    if (!(env->fpu->fcr31 & PARAM1))
2527 5a5012ec ths
        DT2 = DT0;
2528 5a5012ec ths
    DEBUG_FPU_STATE();
2529 5a5012ec ths
    RETURN();
2530 5a5012ec ths
}
2531 5a5012ec ths
FLOAT_OP(movf, s)
2532 5a5012ec ths
{
2533 ead9360e ths
    if (!(env->fpu->fcr31 & PARAM1))
2534 5a5012ec ths
        WT2 = WT0;
2535 5a5012ec ths
    DEBUG_FPU_STATE();
2536 5a5012ec ths
    RETURN();
2537 5a5012ec ths
}
2538 5a5012ec ths
FLOAT_OP(movf, ps)
2539 5a5012ec ths
{
2540 ead9360e ths
    if (!(env->fpu->fcr31 & PARAM1)) {
2541 5a5012ec ths
        WT2 = WT0;
2542 5a5012ec ths
        WTH2 = WTH0;
2543 5a5012ec ths
    }
2544 5a5012ec ths
    DEBUG_FPU_STATE();
2545 5a5012ec ths
    RETURN();
2546 5a5012ec ths
}
2547 5a5012ec ths
FLOAT_OP(movt, d)
2548 5a5012ec ths
{
2549 ead9360e ths
    if (env->fpu->fcr31 & PARAM1)
2550 5a5012ec ths
        DT2 = DT0;
2551 5a5012ec ths
    DEBUG_FPU_STATE();
2552 5a5012ec ths
    RETURN();
2553 5a5012ec ths
}
2554 5a5012ec ths
FLOAT_OP(movt, s)
2555 5a5012ec ths
{
2556 ead9360e ths
    if (env->fpu->fcr31 & PARAM1)
2557 5a5012ec ths
        WT2 = WT0;
2558 5a5012ec ths
    DEBUG_FPU_STATE();
2559 5a5012ec ths
    RETURN();
2560 5a5012ec ths
}
2561 5a5012ec ths
FLOAT_OP(movt, ps)
2562 5a5012ec ths
{
2563 ead9360e ths
    if (env->fpu->fcr31 & PARAM1) {
2564 5a5012ec ths
        WT2 = WT0;
2565 5a5012ec ths
        WTH2 = WTH0;
2566 5a5012ec ths
    }
2567 5a5012ec ths
    DEBUG_FPU_STATE();
2568 5a5012ec ths
    RETURN();
2569 5a5012ec ths
}
2570 5a5012ec ths
FLOAT_OP(movz, d)
2571 5a5012ec ths
{
2572 5a5012ec ths
    if (!T0)
2573 5a5012ec ths
        DT2 = DT0;
2574 5a5012ec ths
    DEBUG_FPU_STATE();
2575 5a5012ec ths
    RETURN();
2576 5a5012ec ths
}
2577 5a5012ec ths
FLOAT_OP(movz, s)
2578 5a5012ec ths
{
2579 5a5012ec ths
    if (!T0)
2580 5a5012ec ths
        WT2 = WT0;
2581 5a5012ec ths
    DEBUG_FPU_STATE();
2582 5a5012ec ths
    RETURN();
2583 5a5012ec ths
}
2584 5a5012ec ths
FLOAT_OP(movz, ps)
2585 5a5012ec ths
{
2586 5a5012ec ths
    if (!T0) {
2587 5a5012ec ths
        WT2 = WT0;
2588 5a5012ec ths
        WTH2 = WTH0;
2589 5a5012ec ths
    }
2590 5a5012ec ths
    DEBUG_FPU_STATE();
2591 5a5012ec ths
    RETURN();
2592 5a5012ec ths
}
2593 5a5012ec ths
FLOAT_OP(movn, d)
2594 5a5012ec ths
{
2595 5a5012ec ths
    if (T0)
2596 5a5012ec ths
        DT2 = DT0;
2597 5a5012ec ths
    DEBUG_FPU_STATE();
2598 5a5012ec ths
    RETURN();
2599 5a5012ec ths
}
2600 5a5012ec ths
FLOAT_OP(movn, s)
2601 5a5012ec ths
{
2602 5a5012ec ths
    if (T0)
2603 5a5012ec ths
        WT2 = WT0;
2604 5a5012ec ths
    DEBUG_FPU_STATE();
2605 5a5012ec ths
    RETURN();
2606 5a5012ec ths
}
2607 5a5012ec ths
FLOAT_OP(movn, ps)
2608 5a5012ec ths
{
2609 5a5012ec ths
    if (T0) {
2610 5a5012ec ths
        WT2 = WT0;
2611 5a5012ec ths
        WTH2 = WTH0;
2612 5a5012ec ths
    }
2613 5a5012ec ths
    DEBUG_FPU_STATE();
2614 5a5012ec ths
    RETURN();
2615 5a5012ec ths
}
2616 5a5012ec ths
2617 57fa1fb3 ths
/* operations calling helpers, for s, d and ps */
2618 57fa1fb3 ths
#define FLOAT_HOP(name) \
2619 6ea83fed bellard
FLOAT_OP(name, d)         \
2620 6ea83fed bellard
{                         \
2621 fd4a04eb ths
    CALL_FROM_TB0(do_float_ ## name ## _d);  \
2622 6ea83fed bellard
    DEBUG_FPU_STATE();    \
2623 fbcc6828 ths
    RETURN();             \
2624 6ea83fed bellard
}                         \
2625 6ea83fed bellard
FLOAT_OP(name, s)         \
2626 6ea83fed bellard
{                         \
2627 fd4a04eb ths
    CALL_FROM_TB0(do_float_ ## name ## _s);  \
2628 5a5012ec ths
    DEBUG_FPU_STATE();    \
2629 fbcc6828 ths
    RETURN();             \
2630 5a5012ec ths
}                         \
2631 5a5012ec ths
FLOAT_OP(name, ps)        \
2632 5a5012ec ths
{                         \
2633 fd4a04eb ths
    CALL_FROM_TB0(do_float_ ## name ## _ps); \
2634 6ea83fed bellard
    DEBUG_FPU_STATE();    \
2635 fbcc6828 ths
    RETURN();             \
2636 6ea83fed bellard
}
2637 57fa1fb3 ths
FLOAT_HOP(add)
2638 57fa1fb3 ths
FLOAT_HOP(sub)
2639 57fa1fb3 ths
FLOAT_HOP(mul)
2640 57fa1fb3 ths
FLOAT_HOP(div)
2641 57fa1fb3 ths
FLOAT_HOP(recip2)
2642 57fa1fb3 ths
FLOAT_HOP(rsqrt2)
2643 57fa1fb3 ths
FLOAT_HOP(rsqrt1)
2644 57fa1fb3 ths
FLOAT_HOP(recip1)
2645 57fa1fb3 ths
#undef FLOAT_HOP
2646 57fa1fb3 ths
2647 57fa1fb3 ths
/* operations calling helpers, for s and d */
2648 57fa1fb3 ths
#define FLOAT_HOP(name)   \
2649 57fa1fb3 ths
FLOAT_OP(name, d)         \
2650 57fa1fb3 ths
{                         \
2651 57fa1fb3 ths
    CALL_FROM_TB0(do_float_ ## name ## _d);  \
2652 57fa1fb3 ths
    DEBUG_FPU_STATE();    \
2653 57fa1fb3 ths
    RETURN();             \
2654 57fa1fb3 ths
}                         \
2655 57fa1fb3 ths
FLOAT_OP(name, s)         \
2656 57fa1fb3 ths
{                         \
2657 57fa1fb3 ths
    CALL_FROM_TB0(do_float_ ## name ## _s);  \
2658 57fa1fb3 ths
    DEBUG_FPU_STATE();    \
2659 57fa1fb3 ths
    RETURN();             \
2660 57fa1fb3 ths
}
2661 57fa1fb3 ths
FLOAT_HOP(rsqrt)
2662 57fa1fb3 ths
FLOAT_HOP(recip)
2663 57fa1fb3 ths
#undef FLOAT_HOP
2664 6ea83fed bellard
2665 57fa1fb3 ths
/* operations calling helpers, for ps */
2666 57fa1fb3 ths
#define FLOAT_HOP(name)   \
2667 57fa1fb3 ths
FLOAT_OP(name, ps)        \
2668 57fa1fb3 ths
{                         \
2669 57fa1fb3 ths
    CALL_FROM_TB0(do_float_ ## name ## _ps); \
2670 57fa1fb3 ths
    DEBUG_FPU_STATE();    \
2671 57fa1fb3 ths
    RETURN();             \
2672 fbcc6828 ths
}
2673 57fa1fb3 ths
FLOAT_HOP(addr)
2674 57fa1fb3 ths
FLOAT_HOP(mulr)
2675 57fa1fb3 ths
#undef FLOAT_HOP
2676 fbcc6828 ths
2677 5a5012ec ths
/* ternary operations */
2678 5a5012ec ths
#define FLOAT_TERNOP(name1, name2) \
2679 5a5012ec ths
FLOAT_OP(name1 ## name2, d)        \
2680 5a5012ec ths
{                                  \
2681 ead9360e ths
    FDT0 = float64_ ## name1 (FDT0, FDT1, &env->fpu->fp_status);    \
2682 ead9360e ths
    FDT2 = float64_ ## name2 (FDT0, FDT2, &env->fpu->fp_status);    \
2683 5a5012ec ths
    DEBUG_FPU_STATE();             \
2684 fbcc6828 ths
    RETURN();                      \
2685 5a5012ec ths
}                                  \
2686 5a5012ec ths
FLOAT_OP(name1 ## name2, s)        \
2687 5a5012ec ths
{                                  \
2688 ead9360e ths
    FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status);    \
2689 ead9360e ths
    FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status);    \
2690 5a5012ec ths
    DEBUG_FPU_STATE();             \
2691 fbcc6828 ths
    RETURN();                      \
2692 5a5012ec ths
}                                  \
2693 5a5012ec ths
FLOAT_OP(name1 ## name2, ps)       \
2694 5a5012ec ths
{                                  \
2695 ead9360e ths
    FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status);    \
2696 ead9360e ths
    FSTH0 = float32_ ## name1 (FSTH0, FSTH1, &env->fpu->fp_status); \
2697 ead9360e ths
    FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status);    \
2698 ead9360e ths
    FSTH2 = float32_ ## name2 (FSTH0, FSTH2, &env->fpu->fp_status); \
2699 5a5012ec ths
    DEBUG_FPU_STATE();             \
2700 fbcc6828 ths
    RETURN();                      \
2701 5a5012ec ths
}
2702 5a5012ec ths
FLOAT_TERNOP(mul, add)
2703 5a5012ec ths
FLOAT_TERNOP(mul, sub)
2704 5a5012ec ths
#undef FLOAT_TERNOP
2705 5a5012ec ths
2706 fbcc6828 ths
/* negated ternary operations */
2707 fbcc6828 ths
#define FLOAT_NTERNOP(name1, name2) \
2708 fbcc6828 ths
FLOAT_OP(n ## name1 ## name2, d)    \
2709 fbcc6828 ths
{                                   \
2710 ead9360e ths
    FDT0 = float64_ ## name1 (FDT0, FDT1, &env->fpu->fp_status);    \
2711 ead9360e ths
    FDT2 = float64_ ## name2 (FDT0, FDT2, &env->fpu->fp_status);    \
2712 fbcc6828 ths
    FDT2 ^= 1ULL << 63;             \
2713 fbcc6828 ths
    DEBUG_FPU_STATE();              \
2714 fbcc6828 ths
    RETURN();                       \
2715 fbcc6828 ths
}                                   \
2716 fbcc6828 ths
FLOAT_OP(n ## name1 ## name2, s)    \
2717 fbcc6828 ths
{                                   \
2718 ead9360e ths
    FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status);    \
2719 ead9360e ths
    FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status);    \
2720 fbcc6828 ths
    FST2 ^= 1 << 31;                \
2721 fbcc6828 ths
    DEBUG_FPU_STATE();              \
2722 fbcc6828 ths
    RETURN();                       \
2723 fbcc6828 ths
}                                   \
2724 fbcc6828 ths
FLOAT_OP(n ## name1 ## name2, ps)   \
2725 fbcc6828 ths
{                                   \
2726 ead9360e ths
    FST0 = float32_ ## name1 (FST0, FST1, &env->fpu->fp_status);    \
2727 ead9360e ths
    FSTH0 = float32_ ## name1 (FSTH0, FSTH1, &env->fpu->fp_status); \
2728 ead9360e ths
    FST2 = float32_ ## name2 (FST0, FST2, &env->fpu->fp_status);    \
2729 ead9360e ths
    FSTH2 = float32_ ## name2 (FSTH0, FSTH2, &env->fpu->fp_status); \
2730 fbcc6828 ths
    FST2 ^= 1 << 31;                \
2731 fbcc6828 ths
    FSTH2 ^= 1 << 31;               \
2732 fbcc6828 ths
    DEBUG_FPU_STATE();              \
2733 fbcc6828 ths
    RETURN();                       \
2734 fbcc6828 ths
}
2735 fbcc6828 ths
FLOAT_NTERNOP(mul, add)
2736 fbcc6828 ths
FLOAT_NTERNOP(mul, sub)
2737 fbcc6828 ths
#undef FLOAT_NTERNOP
2738 fbcc6828 ths
2739 6ea83fed bellard
/* unary operations, modifying fp status  */
2740 6ea83fed bellard
#define FLOAT_UNOP(name)  \
2741 6ea83fed bellard
FLOAT_OP(name, d)         \
2742 6ea83fed bellard
{                         \
2743 ead9360e ths
    FDT2 = float64_ ## name(FDT0, &env->fpu->fp_status);   \
2744 6ea83fed bellard
    DEBUG_FPU_STATE();    \
2745 fbcc6828 ths
    RETURN();                      \
2746 6ea83fed bellard
}                         \
2747 6ea83fed bellard
FLOAT_OP(name, s)         \
2748 6ea83fed bellard
{                         \
2749 ead9360e ths
    FST2 = float32_ ## name(FST0, &env->fpu->fp_status);   \
2750 6ea83fed bellard
    DEBUG_FPU_STATE();    \
2751 57fa1fb3 ths
    RETURN();             \
2752 6ea83fed bellard
}
2753 6ea83fed bellard
FLOAT_UNOP(sqrt)
2754 6ea83fed bellard
#undef FLOAT_UNOP
2755 6ea83fed bellard
2756 6ea83fed bellard
/* unary operations, not modifying fp status  */
2757 6ea83fed bellard
#define FLOAT_UNOP(name)  \
2758 6ea83fed bellard
FLOAT_OP(name, d)         \
2759 6ea83fed bellard
{                         \
2760 6ea83fed bellard
    FDT2 = float64_ ## name(FDT0);   \
2761 6ea83fed bellard
    DEBUG_FPU_STATE();    \
2762 fbcc6828 ths
    RETURN();             \
2763 6ea83fed bellard
}                         \
2764 6ea83fed bellard
FLOAT_OP(name, s)         \
2765 6ea83fed bellard
{                         \
2766 6ea83fed bellard
    FST2 = float32_ ## name(FST0);   \
2767 6ea83fed bellard
    DEBUG_FPU_STATE();    \
2768 fbcc6828 ths
    RETURN();             \
2769 5a5012ec ths
}                         \
2770 5a5012ec ths
FLOAT_OP(name, ps)        \
2771 5a5012ec ths
{                         \
2772 5a5012ec ths
    FST2 = float32_ ## name(FST0);   \
2773 5a5012ec ths
    FSTH2 = float32_ ## name(FSTH0); \
2774 5a5012ec ths
    DEBUG_FPU_STATE();    \
2775 fbcc6828 ths
    RETURN();             \
2776 6ea83fed bellard
}
2777 6ea83fed bellard
FLOAT_UNOP(abs)
2778 6ea83fed bellard
FLOAT_UNOP(chs)
2779 6ea83fed bellard
#undef FLOAT_UNOP
2780 6ea83fed bellard
2781 6ea83fed bellard
FLOAT_OP(mov, d)
2782 6ea83fed bellard
{
2783 6ea83fed bellard
    FDT2 = FDT0;
2784 6ea83fed bellard
    DEBUG_FPU_STATE();
2785 6ea83fed bellard
    RETURN();
2786 6ea83fed bellard
}
2787 6ea83fed bellard
FLOAT_OP(mov, s)
2788 6ea83fed bellard
{
2789 6ea83fed bellard
    FST2 = FST0;
2790 6ea83fed bellard
    DEBUG_FPU_STATE();
2791 6ea83fed bellard
    RETURN();
2792 6ea83fed bellard
}
2793 5a5012ec ths
FLOAT_OP(mov, ps)
2794 5a5012ec ths
{
2795 5a5012ec ths
    FST2 = FST0;
2796 5a5012ec ths
    FSTH2 = FSTH0;
2797 5a5012ec ths
    DEBUG_FPU_STATE();
2798 5a5012ec ths
    RETURN();
2799 5a5012ec ths
}
2800 5a5012ec ths
FLOAT_OP(alnv, ps)
2801 5a5012ec ths
{
2802 5a5012ec ths
    switch (T0 & 0x7) {
2803 5a5012ec ths
    case 0:
2804 5a5012ec ths
        FST2 = FST0;
2805 5a5012ec ths
        FSTH2 = FSTH0;
2806 5a5012ec ths
        break;
2807 5a5012ec ths
    case 4:
2808 5a5012ec ths
#ifdef TARGET_WORDS_BIGENDIAN
2809 5a5012ec ths
        FSTH2 = FST0;
2810 5a5012ec ths
        FST2 = FSTH1;
2811 5a5012ec ths
#else
2812 5a5012ec ths
        FSTH2 = FST1;
2813 5a5012ec ths
        FST2 = FSTH0;
2814 5a5012ec ths
#endif
2815 5a5012ec ths
        break;
2816 5a5012ec ths
    default: /* unpredictable */
2817 5a5012ec ths
        break;
2818 5a5012ec ths
    }
2819 5a5012ec ths
    DEBUG_FPU_STATE();
2820 5a5012ec ths
    RETURN();
2821 5a5012ec ths
}
2822 6ea83fed bellard
2823 6ea83fed bellard
#ifdef CONFIG_SOFTFLOAT
2824 6ea83fed bellard
#define clear_invalid() do {                                \
2825 ead9360e ths
    int flags = get_float_exception_flags(&env->fpu->fp_status); \
2826 6ea83fed bellard
    flags &= ~float_flag_invalid;                           \
2827 ead9360e ths
    set_float_exception_flags(flags, &env->fpu->fp_status);      \
2828 6ea83fed bellard
} while(0)
2829 6ea83fed bellard
#else
2830 6ea83fed bellard
#define clear_invalid() do { } while(0)
2831 6ea83fed bellard
#endif
2832 6ea83fed bellard
2833 6ea83fed bellard
extern void dump_fpu_s(CPUState *env);
2834 6ea83fed bellard
2835 fd4a04eb ths
#define CMP_OP(fmt, op)                                \
2836 fd4a04eb ths
void OPPROTO op_cmp ## _ ## fmt ## _ ## op(void)       \
2837 fd4a04eb ths
{                                                      \
2838 fd4a04eb ths
    CALL_FROM_TB1(do_cmp ## _ ## fmt ## _ ## op, PARAM1); \
2839 fd4a04eb ths
    DEBUG_FPU_STATE();                                 \
2840 fd4a04eb ths
    RETURN();                                          \
2841 fd4a04eb ths
}                                                      \
2842 fd4a04eb ths
void OPPROTO op_cmpabs ## _ ## fmt ## _ ## op(void)    \
2843 fd4a04eb ths
{                                                      \
2844 fd4a04eb ths
    CALL_FROM_TB1(do_cmpabs ## _ ## fmt ## _ ## op, PARAM1); \
2845 fd4a04eb ths
    DEBUG_FPU_STATE();                                 \
2846 fd4a04eb ths
    RETURN();                                          \
2847 fd4a04eb ths
}
2848 fd4a04eb ths
#define CMP_OPS(op)   \
2849 fd4a04eb ths
CMP_OP(d, op)         \
2850 fd4a04eb ths
CMP_OP(s, op)         \
2851 fd4a04eb ths
CMP_OP(ps, op)
2852 fd4a04eb ths
2853 fd4a04eb ths
CMP_OPS(f)
2854 fd4a04eb ths
CMP_OPS(un)
2855 fd4a04eb ths
CMP_OPS(eq)
2856 fd4a04eb ths
CMP_OPS(ueq)
2857 fd4a04eb ths
CMP_OPS(olt)
2858 fd4a04eb ths
CMP_OPS(ult)
2859 fd4a04eb ths
CMP_OPS(ole)
2860 fd4a04eb ths
CMP_OPS(ule)
2861 fd4a04eb ths
CMP_OPS(sf)
2862 fd4a04eb ths
CMP_OPS(ngle)
2863 fd4a04eb ths
CMP_OPS(seq)
2864 fd4a04eb ths
CMP_OPS(ngl)
2865 fd4a04eb ths
CMP_OPS(lt)
2866 fd4a04eb ths
CMP_OPS(nge)
2867 fd4a04eb ths
CMP_OPS(le)
2868 fd4a04eb ths
CMP_OPS(ngt)
2869 fd4a04eb ths
#undef CMP_OPS
2870 fd4a04eb ths
#undef CMP_OP
2871 6ea83fed bellard
2872 6ea83fed bellard
void op_bc1f (void)
2873 6ea83fed bellard
{
2874 ead9360e ths
    T0 = !!(~GET_FP_COND(env->fpu) & (0x1 << PARAM1));
2875 5a5012ec ths
    DEBUG_FPU_STATE();
2876 5a5012ec ths
    RETURN();
2877 5a5012ec ths
}
2878 fd4a04eb ths
void op_bc1any2f (void)
2879 5a5012ec ths
{
2880 ead9360e ths
    T0 = !!(~GET_FP_COND(env->fpu) & (0x3 << PARAM1));
2881 5a5012ec ths
    DEBUG_FPU_STATE();
2882 5a5012ec ths
    RETURN();
2883 5a5012ec ths
}
2884 fd4a04eb ths
void op_bc1any4f (void)
2885 5a5012ec ths
{
2886 ead9360e ths
    T0 = !!(~GET_FP_COND(env->fpu) & (0xf << PARAM1));
2887 6ea83fed bellard
    DEBUG_FPU_STATE();
2888 6ea83fed bellard
    RETURN();
2889 6ea83fed bellard
}
2890 6ea83fed bellard
2891 6ea83fed bellard
void op_bc1t (void)
2892 6ea83fed bellard
{
2893 ead9360e ths
    T0 = !!(GET_FP_COND(env->fpu) & (0x1 << PARAM1));
2894 5a5012ec ths
    DEBUG_FPU_STATE();
2895 5a5012ec ths
    RETURN();
2896 5a5012ec ths
}
2897 fd4a04eb ths
void op_bc1any2t (void)
2898 5a5012ec ths
{
2899 ead9360e ths
    T0 = !!(GET_FP_COND(env->fpu) & (0x3 << PARAM1));
2900 5a5012ec ths
    DEBUG_FPU_STATE();
2901 5a5012ec ths
    RETURN();
2902 5a5012ec ths
}
2903 fd4a04eb ths
void op_bc1any4t (void)
2904 5a5012ec ths
{
2905 ead9360e ths
    T0 = !!(GET_FP_COND(env->fpu) & (0xf << PARAM1));
2906 6ea83fed bellard
    DEBUG_FPU_STATE();
2907 6ea83fed bellard
    RETURN();
2908 6ea83fed bellard
}
2909 6ea83fed bellard
2910 6af0bf9c bellard
void op_tlbwi (void)
2911 6af0bf9c bellard
{
2912 ead9360e ths
    CALL_FROM_TB0(env->tlb->do_tlbwi);
2913 6af0bf9c bellard
    RETURN();
2914 6af0bf9c bellard
}
2915 6af0bf9c bellard
2916 6af0bf9c bellard
void op_tlbwr (void)
2917 6af0bf9c bellard
{
2918 ead9360e ths
    CALL_FROM_TB0(env->tlb->do_tlbwr);
2919 6af0bf9c bellard
    RETURN();
2920 6af0bf9c bellard
}
2921 6af0bf9c bellard
2922 6af0bf9c bellard
void op_tlbp (void)
2923 6af0bf9c bellard
{
2924 ead9360e ths
    CALL_FROM_TB0(env->tlb->do_tlbp);
2925 6af0bf9c bellard
    RETURN();
2926 6af0bf9c bellard
}
2927 6af0bf9c bellard
2928 6af0bf9c bellard
void op_tlbr (void)
2929 6af0bf9c bellard
{
2930 ead9360e ths
    CALL_FROM_TB0(env->tlb->do_tlbr);
2931 6af0bf9c bellard
    RETURN();
2932 6af0bf9c bellard
}
2933 6af0bf9c bellard
2934 6af0bf9c bellard
/* Specials */
2935 6f5b89a0 ths
#if defined (CONFIG_USER_ONLY)
2936 6f5b89a0 ths
void op_tls_value (void)
2937 6f5b89a0 ths
{
2938 5a5012ec ths
    T0 = env->tls_value;
2939 6f5b89a0 ths
}
2940 6f5b89a0 ths
#endif
2941 6f5b89a0 ths
2942 6af0bf9c bellard
void op_pmon (void)
2943 6af0bf9c bellard
{
2944 6af0bf9c bellard
    CALL_FROM_TB1(do_pmon, PARAM1);
2945 7a387fff ths
    RETURN();
2946 7a387fff ths
}
2947 7a387fff ths
2948 7a387fff ths
void op_di (void)
2949 7a387fff ths
{
2950 7a387fff ths
    T0 = env->CP0_Status;
2951 4de9b249 ths
    env->CP0_Status = T0 & ~(1 << CP0St_IE);
2952 4de9b249 ths
    CALL_FROM_TB1(cpu_mips_update_irq, env);
2953 7a387fff ths
    RETURN();
2954 7a387fff ths
}
2955 7a387fff ths
2956 7a387fff ths
void op_ei (void)
2957 7a387fff ths
{
2958 7a387fff ths
    T0 = env->CP0_Status;
2959 4de9b249 ths
    env->CP0_Status = T0 | (1 << CP0St_IE);
2960 4de9b249 ths
    CALL_FROM_TB1(cpu_mips_update_irq, env);
2961 7a387fff ths
    RETURN();
2962 6af0bf9c bellard
}
2963 6af0bf9c bellard
2964 6af0bf9c bellard
void op_trap (void)
2965 6af0bf9c bellard
{
2966 6af0bf9c bellard
    if (T0) {
2967 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_TRAP);
2968 6af0bf9c bellard
    }
2969 6af0bf9c bellard
    RETURN();
2970 6af0bf9c bellard
}
2971 6af0bf9c bellard
2972 4ad40f36 bellard
void op_debug (void)
2973 4ad40f36 bellard
{
2974 7a387fff ths
    CALL_FROM_TB1(do_raise_exception, EXCP_DEBUG);
2975 7a387fff ths
    RETURN();
2976 4ad40f36 bellard
}
2977 4ad40f36 bellard
2978 6af0bf9c bellard
void op_set_lladdr (void)
2979 6af0bf9c bellard
{
2980 6af0bf9c bellard
    env->CP0_LLAddr = T2;
2981 7a387fff ths
    RETURN();
2982 6af0bf9c bellard
}
2983 6af0bf9c bellard
2984 f41c52f1 ths
void debug_pre_eret (void);
2985 f41c52f1 ths
void debug_post_eret (void);
2986 6af0bf9c bellard
void op_eret (void)
2987 6af0bf9c bellard
{
2988 f41c52f1 ths
    if (loglevel & CPU_LOG_EXEC)
2989 f41c52f1 ths
        CALL_FROM_TB0(debug_pre_eret);
2990 24c7b0e3 ths
    if (env->CP0_Status & (1 << CP0St_ERL)) {
2991 ead9360e ths
        env->PC[env->current_tc] = env->CP0_ErrorEPC;
2992 24c7b0e3 ths
        env->CP0_Status &= ~(1 << CP0St_ERL);
2993 51e11d9e bellard
    } else {
2994 ead9360e ths
        env->PC[env->current_tc] = env->CP0_EPC;
2995 24c7b0e3 ths
        env->CP0_Status &= ~(1 << CP0St_EXL);
2996 51e11d9e bellard
    }
2997 08fa4bab ths
    CALL_FROM_TB1(compute_hflags, env);
2998 f41c52f1 ths
    if (loglevel & CPU_LOG_EXEC)
2999 f41c52f1 ths
        CALL_FROM_TB0(debug_post_eret);
3000 6af0bf9c bellard
    env->CP0_LLAddr = 1;
3001 7a387fff ths
    RETURN();
3002 6af0bf9c bellard
}
3003 6af0bf9c bellard
3004 6af0bf9c bellard
void op_deret (void)
3005 6af0bf9c bellard
{
3006 f41c52f1 ths
    if (loglevel & CPU_LOG_EXEC)
3007 f41c52f1 ths
        CALL_FROM_TB0(debug_pre_eret);
3008 ead9360e ths
    env->PC[env->current_tc] = env->CP0_DEPC;
3009 08fa4bab ths
    env->hflags &= MIPS_HFLAG_DM;
3010 08fa4bab ths
    CALL_FROM_TB1(compute_hflags, env);
3011 f41c52f1 ths
    if (loglevel & CPU_LOG_EXEC)
3012 f41c52f1 ths
        CALL_FROM_TB0(debug_post_eret);
3013 24c7b0e3 ths
    env->CP0_LLAddr = 1;
3014 7a387fff ths
    RETURN();
3015 7a387fff ths
}
3016 7a387fff ths
3017 7a387fff ths
void op_rdhwr_cpunum(void)
3018 7a387fff ths
{
3019 387a8fe5 ths
    if ((env->hflags & MIPS_HFLAG_CP0) ||
3020 387a8fe5 ths
        (env->CP0_HWREna & (1 << 0)))
3021 1579a72e ths
        T0 = env->CP0_EBase & 0x3ff;
3022 7a387fff ths
    else
3023 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
3024 7a387fff ths
    RETURN();
3025 7a387fff ths
}
3026 7a387fff ths
3027 7a387fff ths
void op_rdhwr_synci_step(void)
3028 7a387fff ths
{
3029 387a8fe5 ths
    if ((env->hflags & MIPS_HFLAG_CP0) ||
3030 387a8fe5 ths
        (env->CP0_HWREna & (1 << 1)))
3031 1579a72e ths
        T0 = env->SYNCI_Step;
3032 7a387fff ths
    else
3033 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
3034 7a387fff ths
    RETURN();
3035 7a387fff ths
}
3036 7a387fff ths
3037 7a387fff ths
void op_rdhwr_cc(void)
3038 7a387fff ths
{
3039 387a8fe5 ths
    if ((env->hflags & MIPS_HFLAG_CP0) ||
3040 387a8fe5 ths
        (env->CP0_HWREna & (1 << 2)))
3041 1579a72e ths
        T0 = env->CP0_Count;
3042 7a387fff ths
    else
3043 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
3044 7a387fff ths
    RETURN();
3045 7a387fff ths
}
3046 7a387fff ths
3047 7a387fff ths
void op_rdhwr_ccres(void)
3048 7a387fff ths
{
3049 387a8fe5 ths
    if ((env->hflags & MIPS_HFLAG_CP0) ||
3050 387a8fe5 ths
        (env->CP0_HWREna & (1 << 3)))
3051 1579a72e ths
        T0 = env->CCRes;
3052 7a387fff ths
    else
3053 1579a72e ths
        CALL_FROM_TB1(do_raise_exception, EXCP_RI);
3054 1579a72e ths
    RETURN();
3055 1579a72e ths
}
3056 1579a72e ths
3057 6af0bf9c bellard
void op_save_state (void)
3058 6af0bf9c bellard
{
3059 6af0bf9c bellard
    env->hflags = PARAM1;
3060 6af0bf9c bellard
    RETURN();
3061 6af0bf9c bellard
}
3062 6af0bf9c bellard
3063 6af0bf9c bellard
void op_save_pc (void)
3064 6af0bf9c bellard
{
3065 ead9360e ths
    env->PC[env->current_tc] = PARAM1;
3066 6af0bf9c bellard
    RETURN();
3067 6af0bf9c bellard
}
3068 6af0bf9c bellard
3069 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
3070 9b9e4393 ths
void op_save_pc64 (void)
3071 9b9e4393 ths
{
3072 ead9360e ths
    env->PC[env->current_tc] = ((uint64_t)PARAM1 << 32) | (uint32_t)PARAM2;
3073 9b9e4393 ths
    RETURN();
3074 9b9e4393 ths
}
3075 9b9e4393 ths
#endif
3076 9b9e4393 ths
3077 16c00cb2 ths
void op_interrupt_restart (void)
3078 16c00cb2 ths
{
3079 16c00cb2 ths
    if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
3080 16c00cb2 ths
        !(env->CP0_Status & (1 << CP0St_ERL)) &&
3081 16c00cb2 ths
        !(env->hflags & MIPS_HFLAG_DM) &&
3082 16c00cb2 ths
        (env->CP0_Status & (1 << CP0St_IE)) &&
3083 16c00cb2 ths
        (env->CP0_Status & env->CP0_Cause & CP0Ca_IP_mask)) {
3084 16c00cb2 ths
        env->CP0_Cause &= ~(0x1f << CP0Ca_EC);
3085 16c00cb2 ths
        CALL_FROM_TB1(do_raise_exception, EXCP_EXT_INTERRUPT);
3086 16c00cb2 ths
    }
3087 16c00cb2 ths
    RETURN();
3088 16c00cb2 ths
}
3089 16c00cb2 ths
3090 6af0bf9c bellard
void op_raise_exception (void)
3091 6af0bf9c bellard
{
3092 6af0bf9c bellard
    CALL_FROM_TB1(do_raise_exception, PARAM1);
3093 6af0bf9c bellard
    RETURN();
3094 6af0bf9c bellard
}
3095 6af0bf9c bellard
3096 6af0bf9c bellard
void op_raise_exception_err (void)
3097 6af0bf9c bellard
{
3098 6af0bf9c bellard
    CALL_FROM_TB2(do_raise_exception_err, PARAM1, PARAM2);
3099 6af0bf9c bellard
    RETURN();
3100 6af0bf9c bellard
}
3101 6af0bf9c bellard
3102 6af0bf9c bellard
void op_exit_tb (void)
3103 6af0bf9c bellard
{
3104 6af0bf9c bellard
    EXIT_TB();
3105 7a387fff ths
    RETURN();
3106 6af0bf9c bellard
}
3107 6af0bf9c bellard
3108 4ad40f36 bellard
void op_wait (void)
3109 4ad40f36 bellard
{
3110 4ad40f36 bellard
    env->halted = 1;
3111 4ad40f36 bellard
    CALL_FROM_TB1(do_raise_exception, EXCP_HLT);
3112 7a387fff ths
    RETURN();
3113 7a387fff ths
}
3114 7a387fff ths
3115 7a387fff ths
/* Bitfield operations. */
3116 7a387fff ths
void op_ext(void)
3117 7a387fff ths
{
3118 7a387fff ths
    unsigned int pos = PARAM1;
3119 7a387fff ths
    unsigned int size = PARAM2;
3120 7a387fff ths
3121 f757d6ff ths
    T0 = ((uint32_t)T1 >> pos) & ((size < 32) ? ((1 << size) - 1) : ~0);
3122 7a387fff ths
    RETURN();
3123 7a387fff ths
}
3124 7a387fff ths
3125 7a387fff ths
void op_ins(void)
3126 7a387fff ths
{
3127 7a387fff ths
    unsigned int pos = PARAM1;
3128 7a387fff ths
    unsigned int size = PARAM2;
3129 f757d6ff ths
    target_ulong mask = ((size < 32) ? ((1 << size) - 1) : ~0) << pos;
3130 7a387fff ths
3131 171b31e7 ths
    T0 = (T0 & ~mask) | (((uint32_t)T1 << pos) & mask);
3132 7a387fff ths
    RETURN();
3133 7a387fff ths
}
3134 7a387fff ths
3135 7a387fff ths
void op_wsbh(void)
3136 7a387fff ths
{
3137 7a387fff ths
    T0 = ((T1 << 8) & ~0x00FF00FF) | ((T1 >> 8) & 0x00FF00FF);
3138 7a387fff ths
    RETURN();
3139 7a387fff ths
}
3140 7a387fff ths
3141 540635ba ths
#if defined(TARGET_MIPSN32) || defined(TARGET_MIPS64)
3142 c570fd16 ths
void op_dext(void)
3143 c570fd16 ths
{
3144 c570fd16 ths
    unsigned int pos = PARAM1;
3145 c570fd16 ths
    unsigned int size = PARAM2;
3146 c570fd16 ths
3147 f757d6ff ths
    T0 = (T1 >> pos) & ((size < 32) ? ((1 << size) - 1) : ~0);
3148 c570fd16 ths
    RETURN();
3149 c570fd16 ths
}
3150 c570fd16 ths
3151 c570fd16 ths
void op_dins(void)
3152 c570fd16 ths
{
3153 c570fd16 ths
    unsigned int pos = PARAM1;
3154 c570fd16 ths
    unsigned int size = PARAM2;
3155 f757d6ff ths
    target_ulong mask = ((size < 32) ? ((1 << size) - 1) : ~0) << pos;
3156 c570fd16 ths
3157 171b31e7 ths
    T0 = (T0 & ~mask) | ((T1 << pos) & mask);
3158 c570fd16 ths
    RETURN();
3159 c570fd16 ths
}
3160 c570fd16 ths
3161 7a387fff ths
void op_dsbh(void)
3162 7a387fff ths
{
3163 7a387fff ths
    T0 = ((T1 << 8) & ~0x00FF00FF00FF00FFULL) | ((T1 >> 8) & 0x00FF00FF00FF00FFULL);
3164 7a387fff ths
    RETURN();
3165 7a387fff ths
}
3166 7a387fff ths
3167 7a387fff ths
void op_dshd(void)
3168 7a387fff ths
{
3169 7a387fff ths
    T0 = ((T1 << 16) & ~0x0000FFFF0000FFFFULL) | ((T1 >> 16) & 0x0000FFFF0000FFFFULL);
3170 7a387fff ths
    RETURN();
3171 7a387fff ths
}
3172 c570fd16 ths
#endif
3173 7a387fff ths
3174 7a387fff ths
void op_seb(void)
3175 7a387fff ths
{
3176 7a387fff ths
    T0 = ((T1 & 0xFF) ^ 0x80) - 0x80;
3177 7a387fff ths
    RETURN();
3178 7a387fff ths
}
3179 7a387fff ths
3180 7a387fff ths
void op_seh(void)
3181 7a387fff ths
{
3182 7a387fff ths
    T0 = ((T1 & 0xFFFF) ^ 0x8000) - 0x8000;
3183 7a387fff ths
    RETURN();
3184 4ad40f36 bellard
}