root / target-mips / op.c @ 1247c5f7
History | View | Annotate | Download (10.3 kB)
1 | 6af0bf9c | bellard | /*
|
---|---|---|---|
2 | 6af0bf9c | bellard | * MIPS emulation micro-operations for qemu.
|
3 | 6af0bf9c | bellard | *
|
4 | 6af0bf9c | bellard | * Copyright (c) 2004-2005 Jocelyn Mayer
|
5 | 6af0bf9c | bellard | *
|
6 | 6af0bf9c | bellard | * This library is free software; you can redistribute it and/or
|
7 | 6af0bf9c | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 6af0bf9c | bellard | * License as published by the Free Software Foundation; either
|
9 | 6af0bf9c | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 6af0bf9c | bellard | *
|
11 | 6af0bf9c | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 6af0bf9c | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 6af0bf9c | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 6af0bf9c | bellard | * Lesser General Public License for more details.
|
15 | 6af0bf9c | bellard | *
|
16 | 6af0bf9c | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 6af0bf9c | bellard | * License along with this library; if not, write to the Free Software
|
18 | 6af0bf9c | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 6af0bf9c | bellard | */
|
20 | 6af0bf9c | bellard | |
21 | 6af0bf9c | bellard | #include "config.h" |
22 | 6af0bf9c | bellard | #include "exec.h" |
23 | 6af0bf9c | bellard | |
24 | 1b351e52 | bellard | #ifndef CALL_FROM_TB0
|
25 | 1b351e52 | bellard | #define CALL_FROM_TB0(func) func();
|
26 | 1b351e52 | bellard | #endif
|
27 | 1b351e52 | bellard | #ifndef CALL_FROM_TB1
|
28 | 1b351e52 | bellard | #define CALL_FROM_TB1(func, arg0) func(arg0);
|
29 | 1b351e52 | bellard | #endif
|
30 | 1b351e52 | bellard | #ifndef CALL_FROM_TB1_CONST16
|
31 | 1b351e52 | bellard | #define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0);
|
32 | 1b351e52 | bellard | #endif
|
33 | 1b351e52 | bellard | #ifndef CALL_FROM_TB2
|
34 | 1b351e52 | bellard | #define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1);
|
35 | 1b351e52 | bellard | #endif
|
36 | 1b351e52 | bellard | #ifndef CALL_FROM_TB2_CONST16
|
37 | 1b351e52 | bellard | #define CALL_FROM_TB2_CONST16(func, arg0, arg1) \
|
38 | 1b351e52 | bellard | CALL_FROM_TB2(func, arg0, arg1); |
39 | 1b351e52 | bellard | #endif
|
40 | 1b351e52 | bellard | #ifndef CALL_FROM_TB3
|
41 | 1b351e52 | bellard | #define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2);
|
42 | 1b351e52 | bellard | #endif
|
43 | 1b351e52 | bellard | #ifndef CALL_FROM_TB4
|
44 | 1b351e52 | bellard | #define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \
|
45 | 1b351e52 | bellard | func(arg0, arg1, arg2, arg3); |
46 | 1b351e52 | bellard | #endif
|
47 | 1b351e52 | bellard | |
48 | 6af0bf9c | bellard | #define REG 1 |
49 | 6af0bf9c | bellard | #include "op_template.c" |
50 | 6af0bf9c | bellard | #undef REG
|
51 | 6af0bf9c | bellard | #define REG 2 |
52 | 6af0bf9c | bellard | #include "op_template.c" |
53 | 6af0bf9c | bellard | #undef REG
|
54 | 6af0bf9c | bellard | #define REG 3 |
55 | 6af0bf9c | bellard | #include "op_template.c" |
56 | 6af0bf9c | bellard | #undef REG
|
57 | 6af0bf9c | bellard | #define REG 4 |
58 | 6af0bf9c | bellard | #include "op_template.c" |
59 | 6af0bf9c | bellard | #undef REG
|
60 | 6af0bf9c | bellard | #define REG 5 |
61 | 6af0bf9c | bellard | #include "op_template.c" |
62 | 6af0bf9c | bellard | #undef REG
|
63 | 6af0bf9c | bellard | #define REG 6 |
64 | 6af0bf9c | bellard | #include "op_template.c" |
65 | 6af0bf9c | bellard | #undef REG
|
66 | 6af0bf9c | bellard | #define REG 7 |
67 | 6af0bf9c | bellard | #include "op_template.c" |
68 | 6af0bf9c | bellard | #undef REG
|
69 | 6af0bf9c | bellard | #define REG 8 |
70 | 6af0bf9c | bellard | #include "op_template.c" |
71 | 6af0bf9c | bellard | #undef REG
|
72 | 6af0bf9c | bellard | #define REG 9 |
73 | 6af0bf9c | bellard | #include "op_template.c" |
74 | 6af0bf9c | bellard | #undef REG
|
75 | 6af0bf9c | bellard | #define REG 10 |
76 | 6af0bf9c | bellard | #include "op_template.c" |
77 | 6af0bf9c | bellard | #undef REG
|
78 | 6af0bf9c | bellard | #define REG 11 |
79 | 6af0bf9c | bellard | #include "op_template.c" |
80 | 6af0bf9c | bellard | #undef REG
|
81 | 6af0bf9c | bellard | #define REG 12 |
82 | 6af0bf9c | bellard | #include "op_template.c" |
83 | 6af0bf9c | bellard | #undef REG
|
84 | 6af0bf9c | bellard | #define REG 13 |
85 | 6af0bf9c | bellard | #include "op_template.c" |
86 | 6af0bf9c | bellard | #undef REG
|
87 | 6af0bf9c | bellard | #define REG 14 |
88 | 6af0bf9c | bellard | #include "op_template.c" |
89 | 6af0bf9c | bellard | #undef REG
|
90 | 6af0bf9c | bellard | #define REG 15 |
91 | 6af0bf9c | bellard | #include "op_template.c" |
92 | 6af0bf9c | bellard | #undef REG
|
93 | 6af0bf9c | bellard | #define REG 16 |
94 | 6af0bf9c | bellard | #include "op_template.c" |
95 | 6af0bf9c | bellard | #undef REG
|
96 | 6af0bf9c | bellard | #define REG 17 |
97 | 6af0bf9c | bellard | #include "op_template.c" |
98 | 6af0bf9c | bellard | #undef REG
|
99 | 6af0bf9c | bellard | #define REG 18 |
100 | 6af0bf9c | bellard | #include "op_template.c" |
101 | 6af0bf9c | bellard | #undef REG
|
102 | 6af0bf9c | bellard | #define REG 19 |
103 | 6af0bf9c | bellard | #include "op_template.c" |
104 | 6af0bf9c | bellard | #undef REG
|
105 | 6af0bf9c | bellard | #define REG 20 |
106 | 6af0bf9c | bellard | #include "op_template.c" |
107 | 6af0bf9c | bellard | #undef REG
|
108 | 6af0bf9c | bellard | #define REG 21 |
109 | 6af0bf9c | bellard | #include "op_template.c" |
110 | 6af0bf9c | bellard | #undef REG
|
111 | 6af0bf9c | bellard | #define REG 22 |
112 | 6af0bf9c | bellard | #include "op_template.c" |
113 | 6af0bf9c | bellard | #undef REG
|
114 | 6af0bf9c | bellard | #define REG 23 |
115 | 6af0bf9c | bellard | #include "op_template.c" |
116 | 6af0bf9c | bellard | #undef REG
|
117 | 6af0bf9c | bellard | #define REG 24 |
118 | 6af0bf9c | bellard | #include "op_template.c" |
119 | 6af0bf9c | bellard | #undef REG
|
120 | 6af0bf9c | bellard | #define REG 25 |
121 | 6af0bf9c | bellard | #include "op_template.c" |
122 | 6af0bf9c | bellard | #undef REG
|
123 | 6af0bf9c | bellard | #define REG 26 |
124 | 6af0bf9c | bellard | #include "op_template.c" |
125 | 6af0bf9c | bellard | #undef REG
|
126 | 6af0bf9c | bellard | #define REG 27 |
127 | 6af0bf9c | bellard | #include "op_template.c" |
128 | 6af0bf9c | bellard | #undef REG
|
129 | 6af0bf9c | bellard | #define REG 28 |
130 | 6af0bf9c | bellard | #include "op_template.c" |
131 | 6af0bf9c | bellard | #undef REG
|
132 | 6af0bf9c | bellard | #define REG 29 |
133 | 6af0bf9c | bellard | #include "op_template.c" |
134 | 6af0bf9c | bellard | #undef REG
|
135 | 6af0bf9c | bellard | #define REG 30 |
136 | 6af0bf9c | bellard | #include "op_template.c" |
137 | 6af0bf9c | bellard | #undef REG
|
138 | 6af0bf9c | bellard | #define REG 31 |
139 | 6af0bf9c | bellard | #include "op_template.c" |
140 | 6af0bf9c | bellard | #undef REG
|
141 | 6af0bf9c | bellard | |
142 | 6af0bf9c | bellard | #define TN T0
|
143 | 6af0bf9c | bellard | #include "op_template.c" |
144 | 6af0bf9c | bellard | #undef TN
|
145 | 6af0bf9c | bellard | #define TN T1
|
146 | 6af0bf9c | bellard | #include "op_template.c" |
147 | 6af0bf9c | bellard | #undef TN
|
148 | 6af0bf9c | bellard | #define TN T2
|
149 | 6af0bf9c | bellard | #include "op_template.c" |
150 | 6af0bf9c | bellard | #undef TN
|
151 | 6af0bf9c | bellard | |
152 | 6af0bf9c | bellard | void op_dup_T0 (void) |
153 | 6af0bf9c | bellard | { |
154 | 6af0bf9c | bellard | T2 = T0; |
155 | 6af0bf9c | bellard | RETURN(); |
156 | 6af0bf9c | bellard | } |
157 | 6af0bf9c | bellard | |
158 | 6af0bf9c | bellard | void op_load_HI (void) |
159 | 6af0bf9c | bellard | { |
160 | 6af0bf9c | bellard | T0 = env->HI; |
161 | 6af0bf9c | bellard | RETURN(); |
162 | 6af0bf9c | bellard | } |
163 | 6af0bf9c | bellard | |
164 | 6af0bf9c | bellard | void op_store_HI (void) |
165 | 6af0bf9c | bellard | { |
166 | 6af0bf9c | bellard | env->HI = T0; |
167 | 6af0bf9c | bellard | RETURN(); |
168 | 6af0bf9c | bellard | } |
169 | 6af0bf9c | bellard | |
170 | 6af0bf9c | bellard | void op_load_LO (void) |
171 | 6af0bf9c | bellard | { |
172 | 6af0bf9c | bellard | T0 = env->LO; |
173 | 6af0bf9c | bellard | RETURN(); |
174 | 6af0bf9c | bellard | } |
175 | 6af0bf9c | bellard | |
176 | 6af0bf9c | bellard | void op_store_LO (void) |
177 | 6af0bf9c | bellard | { |
178 | 6af0bf9c | bellard | env->LO = T0; |
179 | 6af0bf9c | bellard | RETURN(); |
180 | 6af0bf9c | bellard | } |
181 | 6af0bf9c | bellard | |
182 | 6af0bf9c | bellard | /* Load and store */
|
183 | 6af0bf9c | bellard | #define MEMSUFFIX _raw
|
184 | 6af0bf9c | bellard | #include "op_mem.c" |
185 | 6af0bf9c | bellard | #undef MEMSUFFIX
|
186 | 6af0bf9c | bellard | #if !defined(CONFIG_USER_ONLY)
|
187 | 6af0bf9c | bellard | #define MEMSUFFIX _user
|
188 | 6af0bf9c | bellard | #include "op_mem.c" |
189 | 6af0bf9c | bellard | #undef MEMSUFFIX
|
190 | 6af0bf9c | bellard | |
191 | 6af0bf9c | bellard | #define MEMSUFFIX _kernel
|
192 | 6af0bf9c | bellard | #include "op_mem.c" |
193 | 6af0bf9c | bellard | #undef MEMSUFFIX
|
194 | 6af0bf9c | bellard | #endif
|
195 | 6af0bf9c | bellard | |
196 | 6af0bf9c | bellard | /* Arithmetic */
|
197 | 6af0bf9c | bellard | void op_add (void) |
198 | 6af0bf9c | bellard | { |
199 | 6af0bf9c | bellard | T0 += T1; |
200 | 6af0bf9c | bellard | RETURN(); |
201 | 6af0bf9c | bellard | } |
202 | 6af0bf9c | bellard | |
203 | 6af0bf9c | bellard | void op_addo (void) |
204 | 6af0bf9c | bellard | { |
205 | 6af0bf9c | bellard | target_ulong tmp; |
206 | 6af0bf9c | bellard | |
207 | 6af0bf9c | bellard | tmp = T0; |
208 | 6af0bf9c | bellard | T0 += T1; |
209 | 6af0bf9c | bellard | if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) { |
210 | 4ad40f36 | bellard | CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); |
211 | 6af0bf9c | bellard | } |
212 | 6af0bf9c | bellard | RETURN(); |
213 | 6af0bf9c | bellard | } |
214 | 6af0bf9c | bellard | |
215 | 6af0bf9c | bellard | void op_sub (void) |
216 | 6af0bf9c | bellard | { |
217 | 6af0bf9c | bellard | T0 -= T1; |
218 | 6af0bf9c | bellard | RETURN(); |
219 | 6af0bf9c | bellard | } |
220 | 6af0bf9c | bellard | |
221 | 6af0bf9c | bellard | void op_subo (void) |
222 | 6af0bf9c | bellard | { |
223 | 6af0bf9c | bellard | target_ulong tmp; |
224 | 6af0bf9c | bellard | |
225 | 6af0bf9c | bellard | tmp = T0; |
226 | 6af0bf9c | bellard | T0 = (int32_t)T0 - (int32_t)T1; |
227 | 6af0bf9c | bellard | if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) { |
228 | 4ad40f36 | bellard | CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW); |
229 | 6af0bf9c | bellard | } |
230 | 6af0bf9c | bellard | RETURN(); |
231 | 6af0bf9c | bellard | } |
232 | 6af0bf9c | bellard | |
233 | 6af0bf9c | bellard | void op_mul (void) |
234 | 6af0bf9c | bellard | { |
235 | 6af0bf9c | bellard | T0 = (int32_t)T0 * (int32_t)T1; |
236 | 6af0bf9c | bellard | RETURN(); |
237 | 6af0bf9c | bellard | } |
238 | 6af0bf9c | bellard | |
239 | 6af0bf9c | bellard | void op_div (void) |
240 | 6af0bf9c | bellard | { |
241 | 6af0bf9c | bellard | if (T1 != 0) { |
242 | 6af0bf9c | bellard | env->LO = (int32_t)T0 / (int32_t)T1; |
243 | 6af0bf9c | bellard | env->HI = (int32_t)T0 % (int32_t)T1; |
244 | 6af0bf9c | bellard | } |
245 | 6af0bf9c | bellard | RETURN(); |
246 | 6af0bf9c | bellard | } |
247 | 6af0bf9c | bellard | |
248 | 6af0bf9c | bellard | void op_divu (void) |
249 | 6af0bf9c | bellard | { |
250 | 6af0bf9c | bellard | if (T1 != 0) { |
251 | 6af0bf9c | bellard | env->LO = T0 / T1; |
252 | 6af0bf9c | bellard | env->HI = T0 % T1; |
253 | 6af0bf9c | bellard | } |
254 | 6af0bf9c | bellard | RETURN(); |
255 | 6af0bf9c | bellard | } |
256 | 6af0bf9c | bellard | |
257 | 6af0bf9c | bellard | /* Logical */
|
258 | 6af0bf9c | bellard | void op_and (void) |
259 | 6af0bf9c | bellard | { |
260 | 6af0bf9c | bellard | T0 &= T1; |
261 | 6af0bf9c | bellard | RETURN(); |
262 | 6af0bf9c | bellard | } |
263 | 6af0bf9c | bellard | |
264 | 6af0bf9c | bellard | void op_nor (void) |
265 | 6af0bf9c | bellard | { |
266 | 6af0bf9c | bellard | T0 = ~(T0 | T1); |
267 | 6af0bf9c | bellard | RETURN(); |
268 | 6af0bf9c | bellard | } |
269 | 6af0bf9c | bellard | |
270 | 6af0bf9c | bellard | void op_or (void) |
271 | 6af0bf9c | bellard | { |
272 | 6af0bf9c | bellard | T0 |= T1; |
273 | 6af0bf9c | bellard | RETURN(); |
274 | 6af0bf9c | bellard | } |
275 | 6af0bf9c | bellard | |
276 | 6af0bf9c | bellard | void op_xor (void) |
277 | 6af0bf9c | bellard | { |
278 | 6af0bf9c | bellard | T0 ^= T1; |
279 | 6af0bf9c | bellard | RETURN(); |
280 | 6af0bf9c | bellard | } |
281 | 6af0bf9c | bellard | |
282 | 6af0bf9c | bellard | void op_sll (void) |
283 | 6af0bf9c | bellard | { |
284 | 6af0bf9c | bellard | T0 = T0 << T1; |
285 | 6af0bf9c | bellard | RETURN(); |
286 | 6af0bf9c | bellard | } |
287 | 6af0bf9c | bellard | |
288 | 6af0bf9c | bellard | void op_sra (void) |
289 | 6af0bf9c | bellard | { |
290 | 6af0bf9c | bellard | T0 = (int32_t)T0 >> T1; |
291 | 6af0bf9c | bellard | RETURN(); |
292 | 6af0bf9c | bellard | } |
293 | 6af0bf9c | bellard | |
294 | 6af0bf9c | bellard | void op_srl (void) |
295 | 6af0bf9c | bellard | { |
296 | 6af0bf9c | bellard | T0 = T0 >> T1; |
297 | 6af0bf9c | bellard | RETURN(); |
298 | 6af0bf9c | bellard | } |
299 | 6af0bf9c | bellard | |
300 | 6af0bf9c | bellard | void op_sllv (void) |
301 | 6af0bf9c | bellard | { |
302 | 6af0bf9c | bellard | T0 = T1 << (T0 & 0x1F);
|
303 | 6af0bf9c | bellard | RETURN(); |
304 | 6af0bf9c | bellard | } |
305 | 6af0bf9c | bellard | |
306 | 6af0bf9c | bellard | void op_srav (void) |
307 | 6af0bf9c | bellard | { |
308 | 6af0bf9c | bellard | T0 = (int32_t)T1 >> (T0 & 0x1F);
|
309 | 6af0bf9c | bellard | RETURN(); |
310 | 6af0bf9c | bellard | } |
311 | 6af0bf9c | bellard | |
312 | 6af0bf9c | bellard | void op_srlv (void) |
313 | 6af0bf9c | bellard | { |
314 | 6af0bf9c | bellard | T0 = T1 >> (T0 & 0x1F);
|
315 | 6af0bf9c | bellard | RETURN(); |
316 | 6af0bf9c | bellard | } |
317 | 6af0bf9c | bellard | |
318 | 6af0bf9c | bellard | void op_clo (void) |
319 | 6af0bf9c | bellard | { |
320 | 6af0bf9c | bellard | int n;
|
321 | 6af0bf9c | bellard | |
322 | 6af0bf9c | bellard | if (T0 == (target_ulong)-1) { |
323 | 6af0bf9c | bellard | T0 = 32;
|
324 | 6af0bf9c | bellard | } else {
|
325 | 6af0bf9c | bellard | for (n = 0; n < 32; n++) { |
326 | 6af0bf9c | bellard | if (!(T0 & (1 << 31))) |
327 | 6af0bf9c | bellard | break;
|
328 | 6af0bf9c | bellard | T0 = T0 << 1;
|
329 | 6af0bf9c | bellard | } |
330 | 6af0bf9c | bellard | T0 = n; |
331 | 6af0bf9c | bellard | } |
332 | 6af0bf9c | bellard | RETURN(); |
333 | 6af0bf9c | bellard | } |
334 | 6af0bf9c | bellard | |
335 | 6af0bf9c | bellard | void op_clz (void) |
336 | 6af0bf9c | bellard | { |
337 | 6af0bf9c | bellard | int n;
|
338 | 6af0bf9c | bellard | |
339 | 6af0bf9c | bellard | if (T0 == 0) { |
340 | 6af0bf9c | bellard | T0 = 32;
|
341 | 6af0bf9c | bellard | } else {
|
342 | 6af0bf9c | bellard | for (n = 0; n < 32; n++) { |
343 | 6af0bf9c | bellard | if (T0 & (1 << 31)) |
344 | 6af0bf9c | bellard | break;
|
345 | 6af0bf9c | bellard | T0 = T0 << 1;
|
346 | 6af0bf9c | bellard | } |
347 | 6af0bf9c | bellard | T0 = n; |
348 | 6af0bf9c | bellard | } |
349 | 6af0bf9c | bellard | RETURN(); |
350 | 6af0bf9c | bellard | } |
351 | 6af0bf9c | bellard | |
352 | 6af0bf9c | bellard | /* 64 bits arithmetic */
|
353 | 6af0bf9c | bellard | #if (HOST_LONG_BITS == 64) |
354 | 6af0bf9c | bellard | static inline uint64_t get_HILO (void) |
355 | 6af0bf9c | bellard | { |
356 | 6af0bf9c | bellard | return ((uint64_t)env->HI << 32) | (uint64_t)env->LO; |
357 | 6af0bf9c | bellard | } |
358 | 6af0bf9c | bellard | |
359 | 6af0bf9c | bellard | static inline void set_HILO (uint64_t HILO) |
360 | 6af0bf9c | bellard | { |
361 | 6af0bf9c | bellard | env->LO = HILO & 0xFFFFFFFF;
|
362 | 6af0bf9c | bellard | env->HI = HILO >> 32;
|
363 | 6af0bf9c | bellard | } |
364 | 6af0bf9c | bellard | |
365 | 6af0bf9c | bellard | void op_mult (void) |
366 | 6af0bf9c | bellard | { |
367 | 4ad40f36 | bellard | set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
368 | 6af0bf9c | bellard | RETURN(); |
369 | 6af0bf9c | bellard | } |
370 | 6af0bf9c | bellard | |
371 | 6af0bf9c | bellard | void op_multu (void) |
372 | 6af0bf9c | bellard | { |
373 | 6af0bf9c | bellard | set_HILO((uint64_t)T0 * (uint64_t)T1); |
374 | 6af0bf9c | bellard | RETURN(); |
375 | 6af0bf9c | bellard | } |
376 | 6af0bf9c | bellard | |
377 | 6af0bf9c | bellard | void op_madd (void) |
378 | 6af0bf9c | bellard | { |
379 | 6af0bf9c | bellard | int64_t tmp; |
380 | 6af0bf9c | bellard | |
381 | 4ad40f36 | bellard | tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
382 | 6af0bf9c | bellard | set_HILO((int64_t)get_HILO() + tmp); |
383 | 6af0bf9c | bellard | RETURN(); |
384 | 6af0bf9c | bellard | } |
385 | 6af0bf9c | bellard | |
386 | 6af0bf9c | bellard | void op_maddu (void) |
387 | 6af0bf9c | bellard | { |
388 | 6af0bf9c | bellard | uint64_t tmp; |
389 | 6af0bf9c | bellard | |
390 | 6af0bf9c | bellard | tmp = ((uint64_t)T0 * (uint64_t)T1); |
391 | 6af0bf9c | bellard | set_HILO(get_HILO() + tmp); |
392 | 6af0bf9c | bellard | RETURN(); |
393 | 6af0bf9c | bellard | } |
394 | 6af0bf9c | bellard | |
395 | 6af0bf9c | bellard | void op_msub (void) |
396 | 6af0bf9c | bellard | { |
397 | 6af0bf9c | bellard | int64_t tmp; |
398 | 6af0bf9c | bellard | |
399 | 4ad40f36 | bellard | tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1); |
400 | 6af0bf9c | bellard | set_HILO((int64_t)get_HILO() - tmp); |
401 | 6af0bf9c | bellard | RETURN(); |
402 | 6af0bf9c | bellard | } |
403 | 6af0bf9c | bellard | |
404 | 6af0bf9c | bellard | void op_msubu (void) |
405 | 6af0bf9c | bellard | { |
406 | 6af0bf9c | bellard | uint64_t tmp; |
407 | 6af0bf9c | bellard | |
408 | 6af0bf9c | bellard | tmp = ((uint64_t)T0 * (uint64_t)T1); |
409 | 6af0bf9c | bellard | set_HILO(get_HILO() - tmp); |
410 | 6af0bf9c | bellard | RETURN(); |
411 | 6af0bf9c | bellard | } |
412 | 6af0bf9c | bellard | #else
|
413 | 6af0bf9c | bellard | void op_mult (void) |
414 | 6af0bf9c | bellard | { |
415 | 6af0bf9c | bellard | CALL_FROM_TB0(do_mult); |
416 | 6af0bf9c | bellard | RETURN(); |
417 | 6af0bf9c | bellard | } |
418 | 6af0bf9c | bellard | |
419 | 6af0bf9c | bellard | void op_multu (void) |
420 | 6af0bf9c | bellard | { |
421 | 6af0bf9c | bellard | CALL_FROM_TB0(do_multu); |
422 | 6af0bf9c | bellard | RETURN(); |
423 | 6af0bf9c | bellard | } |
424 | 6af0bf9c | bellard | |
425 | 6af0bf9c | bellard | void op_madd (void) |
426 | 6af0bf9c | bellard | { |
427 | 6af0bf9c | bellard | CALL_FROM_TB0(do_madd); |
428 | 6af0bf9c | bellard | RETURN(); |
429 | 6af0bf9c | bellard | } |
430 | 6af0bf9c | bellard | |
431 | 6af0bf9c | bellard | void op_maddu (void) |
432 | 6af0bf9c | bellard | { |
433 | 6af0bf9c | bellard | CALL_FROM_TB0(do_maddu); |
434 | 6af0bf9c | bellard | RETURN(); |
435 | 6af0bf9c | bellard | } |
436 | 6af0bf9c | bellard | |
437 | 6af0bf9c | bellard | void op_msub (void) |
438 | 6af0bf9c | bellard | { |
439 | 6af0bf9c | bellard | CALL_FROM_TB0(do_msub); |
440 | 6af0bf9c | bellard | RETURN(); |
441 | 6af0bf9c | bellard | } |
442 | 6af0bf9c | bellard | |
443 | 6af0bf9c | bellard | void op_msubu (void) |
444 | 6af0bf9c | bellard | { |
445 | 6af0bf9c | bellard | CALL_FROM_TB0(do_msubu); |
446 | 6af0bf9c | bellard | RETURN(); |
447 | 6af0bf9c | bellard | } |
448 | 6af0bf9c | bellard | #endif
|
449 | 6af0bf9c | bellard | |
450 | 6af0bf9c | bellard | /* Conditional moves */
|
451 | 6af0bf9c | bellard | void op_movn (void) |
452 | 6af0bf9c | bellard | { |
453 | 6af0bf9c | bellard | if (T1 != 0) |
454 | 6af0bf9c | bellard | env->gpr[PARAM1] = T0; |
455 | 6af0bf9c | bellard | RETURN(); |
456 | 6af0bf9c | bellard | } |
457 | 6af0bf9c | bellard | |
458 | 6af0bf9c | bellard | void op_movz (void) |
459 | 6af0bf9c | bellard | { |
460 | 6af0bf9c | bellard | if (T1 == 0) |
461 | 6af0bf9c | bellard | env->gpr[PARAM1] = T0; |
462 | 6af0bf9c | bellard | RETURN(); |
463 | 6af0bf9c | bellard | } |
464 | 6af0bf9c | bellard | |
465 | 6af0bf9c | bellard | /* Tests */
|
466 | 6af0bf9c | bellard | #define OP_COND(name, cond) \
|
467 | 6af0bf9c | bellard | void glue(op_, name) (void) \ |
468 | 6af0bf9c | bellard | { \ |
469 | 6af0bf9c | bellard | if (cond) { \
|
470 | 6af0bf9c | bellard | T0 = 1; \
|
471 | 6af0bf9c | bellard | } else { \
|
472 | 6af0bf9c | bellard | T0 = 0; \
|
473 | 6af0bf9c | bellard | } \ |
474 | 6af0bf9c | bellard | RETURN(); \ |
475 | 6af0bf9c | bellard | } |
476 | 6af0bf9c | bellard | |
477 | 6af0bf9c | bellard | OP_COND(eq, T0 == T1); |
478 | 6af0bf9c | bellard | OP_COND(ne, T0 != T1); |
479 | 6af0bf9c | bellard | OP_COND(ge, (int32_t)T0 >= (int32_t)T1); |
480 | 6af0bf9c | bellard | OP_COND(geu, T0 >= T1); |
481 | 6af0bf9c | bellard | OP_COND(lt, (int32_t)T0 < (int32_t)T1); |
482 | 6af0bf9c | bellard | OP_COND(ltu, T0 < T1); |
483 | 6af0bf9c | bellard | OP_COND(gez, (int32_t)T0 >= 0);
|
484 | 6af0bf9c | bellard | OP_COND(gtz, (int32_t)T0 > 0);
|
485 | 6af0bf9c | bellard | OP_COND(lez, (int32_t)T0 <= 0);
|
486 | 6af0bf9c | bellard | OP_COND(ltz, (int32_t)T0 < 0);
|
487 | 6af0bf9c | bellard | |
488 | 6af0bf9c | bellard | /* Branchs */
|
489 | 6af0bf9c | bellard | //#undef USE_DIRECT_JUMP
|
490 | c53be334 | bellard | |
491 | c53be334 | bellard | void OPPROTO op_goto_tb0(void) |
492 | c53be334 | bellard | { |
493 | c53be334 | bellard | GOTO_TB(op_goto_tb0, PARAM1, 0);
|
494 | c53be334 | bellard | } |
495 | c53be334 | bellard | |
496 | c53be334 | bellard | void OPPROTO op_goto_tb1(void) |
497 | c53be334 | bellard | { |
498 | c53be334 | bellard | GOTO_TB(op_goto_tb1, PARAM1, 1);
|
499 | c53be334 | bellard | } |
500 | 6af0bf9c | bellard | |
501 | 6af0bf9c | bellard | /* Branch to register */
|
502 | 6af0bf9c | bellard | void op_save_breg_target (void) |
503 | 6af0bf9c | bellard | { |
504 | 6af0bf9c | bellard | env->btarget = T2; |
505 | 6af0bf9c | bellard | } |
506 | 6af0bf9c | bellard | |
507 | 6af0bf9c | bellard | void op_restore_breg_target (void) |
508 | 6af0bf9c | bellard | { |
509 | 6af0bf9c | bellard | T2 = env->btarget; |
510 | 6af0bf9c | bellard | } |
511 | 6af0bf9c | bellard | |
512 | 6af0bf9c | bellard | void op_breg (void) |
513 | 6af0bf9c | bellard | { |
514 | 6af0bf9c | bellard | env->PC = T2; |
515 | 6af0bf9c | bellard | RETURN(); |
516 | 6af0bf9c | bellard | } |
517 | 6af0bf9c | bellard | |
518 | 6af0bf9c | bellard | void op_save_btarget (void) |
519 | 6af0bf9c | bellard | { |
520 | 6af0bf9c | bellard | env->btarget = PARAM1; |
521 | 6af0bf9c | bellard | RETURN(); |
522 | 6af0bf9c | bellard | } |
523 | 6af0bf9c | bellard | |
524 | 6af0bf9c | bellard | /* Conditional branch */
|
525 | 6af0bf9c | bellard | void op_set_bcond (void) |
526 | 6af0bf9c | bellard | { |
527 | 6af0bf9c | bellard | T2 = T0; |
528 | 6af0bf9c | bellard | RETURN(); |
529 | 6af0bf9c | bellard | } |
530 | 6af0bf9c | bellard | |
531 | 6af0bf9c | bellard | void op_save_bcond (void) |
532 | 6af0bf9c | bellard | { |
533 | 6af0bf9c | bellard | env->bcond = T2; |
534 | 6af0bf9c | bellard | RETURN(); |
535 | 6af0bf9c | bellard | } |
536 | 6af0bf9c | bellard | |
537 | 6af0bf9c | bellard | void op_restore_bcond (void) |
538 | 6af0bf9c | bellard | { |
539 | 6af0bf9c | bellard | T2 = env->bcond; |
540 | 6af0bf9c | bellard | RETURN(); |
541 | 6af0bf9c | bellard | } |
542 | 6af0bf9c | bellard | |
543 | c53be334 | bellard | void op_jnz_T2 (void) |
544 | 6af0bf9c | bellard | { |
545 | c53be334 | bellard | if (T2)
|
546 | c53be334 | bellard | GOTO_LABEL_PARAM(1);
|
547 | 6af0bf9c | bellard | RETURN(); |
548 | 6af0bf9c | bellard | } |
549 | 6af0bf9c | bellard | |
550 | 6af0bf9c | bellard | /* CP0 functions */
|
551 | 6af0bf9c | bellard | void op_mfc0 (void) |
552 | 6af0bf9c | bellard | { |
553 | 6af0bf9c | bellard | CALL_FROM_TB2(do_mfc0, PARAM1, PARAM2); |
554 | 6af0bf9c | bellard | RETURN(); |
555 | 6af0bf9c | bellard | } |
556 | 6af0bf9c | bellard | |
557 | 6af0bf9c | bellard | void op_mtc0 (void) |
558 | 6af0bf9c | bellard | { |
559 | 6af0bf9c | bellard | CALL_FROM_TB2(do_mtc0, PARAM1, PARAM2); |
560 | 6af0bf9c | bellard | RETURN(); |
561 | 6af0bf9c | bellard | } |
562 | 6af0bf9c | bellard | |
563 | 6af0bf9c | bellard | #if defined(MIPS_USES_R4K_TLB)
|
564 | 6af0bf9c | bellard | void op_tlbwi (void) |
565 | 6af0bf9c | bellard | { |
566 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbwi); |
567 | 6af0bf9c | bellard | RETURN(); |
568 | 6af0bf9c | bellard | } |
569 | 6af0bf9c | bellard | |
570 | 6af0bf9c | bellard | void op_tlbwr (void) |
571 | 6af0bf9c | bellard | { |
572 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbwr); |
573 | 6af0bf9c | bellard | RETURN(); |
574 | 6af0bf9c | bellard | } |
575 | 6af0bf9c | bellard | |
576 | 6af0bf9c | bellard | void op_tlbp (void) |
577 | 6af0bf9c | bellard | { |
578 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbp); |
579 | 6af0bf9c | bellard | RETURN(); |
580 | 6af0bf9c | bellard | } |
581 | 6af0bf9c | bellard | |
582 | 6af0bf9c | bellard | void op_tlbr (void) |
583 | 6af0bf9c | bellard | { |
584 | 6af0bf9c | bellard | CALL_FROM_TB0(do_tlbr); |
585 | 6af0bf9c | bellard | RETURN(); |
586 | 6af0bf9c | bellard | } |
587 | 6af0bf9c | bellard | #endif
|
588 | 6af0bf9c | bellard | |
589 | 6af0bf9c | bellard | /* Specials */
|
590 | 6af0bf9c | bellard | void op_pmon (void) |
591 | 6af0bf9c | bellard | { |
592 | 6af0bf9c | bellard | CALL_FROM_TB1(do_pmon, PARAM1); |
593 | 6af0bf9c | bellard | } |
594 | 6af0bf9c | bellard | |
595 | 6af0bf9c | bellard | void op_trap (void) |
596 | 6af0bf9c | bellard | { |
597 | 6af0bf9c | bellard | if (T0) {
|
598 | 4ad40f36 | bellard | CALL_FROM_TB1(do_raise_exception_direct, EXCP_TRAP); |
599 | 6af0bf9c | bellard | } |
600 | 6af0bf9c | bellard | RETURN(); |
601 | 6af0bf9c | bellard | } |
602 | 6af0bf9c | bellard | |
603 | 4ad40f36 | bellard | void op_debug (void) |
604 | 4ad40f36 | bellard | { |
605 | 4ad40f36 | bellard | CALL_FROM_TB1(do_raise_exception_direct, EXCP_DEBUG); |
606 | 4ad40f36 | bellard | } |
607 | 4ad40f36 | bellard | |
608 | 6af0bf9c | bellard | void op_set_lladdr (void) |
609 | 6af0bf9c | bellard | { |
610 | 6af0bf9c | bellard | env->CP0_LLAddr = T2; |
611 | 6af0bf9c | bellard | } |
612 | 6af0bf9c | bellard | |
613 | 6af0bf9c | bellard | void debug_eret (void); |
614 | 6af0bf9c | bellard | void op_eret (void) |
615 | 6af0bf9c | bellard | { |
616 | 6af0bf9c | bellard | CALL_FROM_TB0(debug_eret); |
617 | 51e11d9e | bellard | if (env->hflags & MIPS_HFLAG_ERL) {
|
618 | 6af0bf9c | bellard | env->PC = env->CP0_ErrorEPC; |
619 | 51e11d9e | bellard | env->hflags &= ~MIPS_HFLAG_ERL; |
620 | 51e11d9e | bellard | } else {
|
621 | 6af0bf9c | bellard | env->PC = env->CP0_EPC; |
622 | 51e11d9e | bellard | env->hflags &= ~MIPS_HFLAG_EXL; |
623 | 51e11d9e | bellard | } |
624 | 6af0bf9c | bellard | env->CP0_LLAddr = 1;
|
625 | 6af0bf9c | bellard | } |
626 | 6af0bf9c | bellard | |
627 | 6af0bf9c | bellard | void op_deret (void) |
628 | 6af0bf9c | bellard | { |
629 | 6af0bf9c | bellard | CALL_FROM_TB0(debug_eret); |
630 | 6af0bf9c | bellard | env->PC = env->CP0_DEPC; |
631 | 6af0bf9c | bellard | } |
632 | 6af0bf9c | bellard | |
633 | 6af0bf9c | bellard | void op_save_state (void) |
634 | 6af0bf9c | bellard | { |
635 | 6af0bf9c | bellard | env->hflags = PARAM1; |
636 | 6af0bf9c | bellard | RETURN(); |
637 | 6af0bf9c | bellard | } |
638 | 6af0bf9c | bellard | |
639 | 6af0bf9c | bellard | void op_save_pc (void) |
640 | 6af0bf9c | bellard | { |
641 | 6af0bf9c | bellard | env->PC = PARAM1; |
642 | 6af0bf9c | bellard | RETURN(); |
643 | 6af0bf9c | bellard | } |
644 | 6af0bf9c | bellard | |
645 | 6af0bf9c | bellard | void op_raise_exception (void) |
646 | 6af0bf9c | bellard | { |
647 | 6af0bf9c | bellard | CALL_FROM_TB1(do_raise_exception, PARAM1); |
648 | 6af0bf9c | bellard | RETURN(); |
649 | 6af0bf9c | bellard | } |
650 | 6af0bf9c | bellard | |
651 | 6af0bf9c | bellard | void op_raise_exception_err (void) |
652 | 6af0bf9c | bellard | { |
653 | 6af0bf9c | bellard | CALL_FROM_TB2(do_raise_exception_err, PARAM1, PARAM2); |
654 | 6af0bf9c | bellard | RETURN(); |
655 | 6af0bf9c | bellard | } |
656 | 6af0bf9c | bellard | |
657 | 6af0bf9c | bellard | void op_exit_tb (void) |
658 | 6af0bf9c | bellard | { |
659 | 6af0bf9c | bellard | EXIT_TB(); |
660 | 6af0bf9c | bellard | } |
661 | 6af0bf9c | bellard | |
662 | 4ad40f36 | bellard | void op_wait (void) |
663 | 4ad40f36 | bellard | { |
664 | 4ad40f36 | bellard | env->halted = 1;
|
665 | 4ad40f36 | bellard | CALL_FROM_TB1(do_raise_exception, EXCP_HLT); |
666 | 4ad40f36 | bellard | } |