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