root / target-cris / op.c @ 4fa551d7
History | View | Annotate | Download (21 kB)
1 | 4fa551d7 | ths | /*
|
---|---|---|---|
2 | 4fa551d7 | ths | * CRIS emulation micro-operations for qemu.
|
3 | 4fa551d7 | ths | *
|
4 | 4fa551d7 | ths | * Copyright (c) 2007 Edgar E. Iglesias, Axis Communications AB.
|
5 | 4fa551d7 | ths | *
|
6 | 4fa551d7 | ths | * This library is free software; you can redistribute it and/or
|
7 | 4fa551d7 | ths | * modify it under the terms of the GNU Lesser General Public
|
8 | 4fa551d7 | ths | * License as published by the Free Software Foundation; either
|
9 | 4fa551d7 | ths | * version 2 of the License, or (at your option) any later version.
|
10 | 4fa551d7 | ths | *
|
11 | 4fa551d7 | ths | * This library is distributed in the hope that it will be useful,
|
12 | 4fa551d7 | ths | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4fa551d7 | ths | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4fa551d7 | ths | * Lesser General Public License for more details.
|
15 | 4fa551d7 | ths | *
|
16 | 4fa551d7 | ths | * You should have received a copy of the GNU Lesser General Public
|
17 | 4fa551d7 | ths | * License along with this library; if not, write to the Free Software
|
18 | 4fa551d7 | ths | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 4fa551d7 | ths | */
|
20 | 4fa551d7 | ths | #include "exec.h" |
21 | 4fa551d7 | ths | |
22 | 4fa551d7 | ths | #define REGNAME r0
|
23 | 4fa551d7 | ths | #define REG (env->regs[0]) |
24 | 4fa551d7 | ths | #include "op_template.h" |
25 | 4fa551d7 | ths | |
26 | 4fa551d7 | ths | #define REGNAME r1
|
27 | 4fa551d7 | ths | #define REG (env->regs[1]) |
28 | 4fa551d7 | ths | #include "op_template.h" |
29 | 4fa551d7 | ths | |
30 | 4fa551d7 | ths | #define REGNAME r2
|
31 | 4fa551d7 | ths | #define REG (env->regs[2]) |
32 | 4fa551d7 | ths | #include "op_template.h" |
33 | 4fa551d7 | ths | |
34 | 4fa551d7 | ths | #define REGNAME r3
|
35 | 4fa551d7 | ths | #define REG (env->regs[3]) |
36 | 4fa551d7 | ths | #include "op_template.h" |
37 | 4fa551d7 | ths | |
38 | 4fa551d7 | ths | #define REGNAME r4
|
39 | 4fa551d7 | ths | #define REG (env->regs[4]) |
40 | 4fa551d7 | ths | #include "op_template.h" |
41 | 4fa551d7 | ths | |
42 | 4fa551d7 | ths | #define REGNAME r5
|
43 | 4fa551d7 | ths | #define REG (env->regs[5]) |
44 | 4fa551d7 | ths | #include "op_template.h" |
45 | 4fa551d7 | ths | |
46 | 4fa551d7 | ths | #define REGNAME r6
|
47 | 4fa551d7 | ths | #define REG (env->regs[6]) |
48 | 4fa551d7 | ths | #include "op_template.h" |
49 | 4fa551d7 | ths | |
50 | 4fa551d7 | ths | #define REGNAME r7
|
51 | 4fa551d7 | ths | #define REG (env->regs[7]) |
52 | 4fa551d7 | ths | #include "op_template.h" |
53 | 4fa551d7 | ths | |
54 | 4fa551d7 | ths | #define REGNAME r8
|
55 | 4fa551d7 | ths | #define REG (env->regs[8]) |
56 | 4fa551d7 | ths | #include "op_template.h" |
57 | 4fa551d7 | ths | |
58 | 4fa551d7 | ths | #define REGNAME r9
|
59 | 4fa551d7 | ths | #define REG (env->regs[9]) |
60 | 4fa551d7 | ths | #include "op_template.h" |
61 | 4fa551d7 | ths | |
62 | 4fa551d7 | ths | #define REGNAME r10
|
63 | 4fa551d7 | ths | #define REG (env->regs[10]) |
64 | 4fa551d7 | ths | #include "op_template.h" |
65 | 4fa551d7 | ths | |
66 | 4fa551d7 | ths | #define REGNAME r11
|
67 | 4fa551d7 | ths | #define REG (env->regs[11]) |
68 | 4fa551d7 | ths | #include "op_template.h" |
69 | 4fa551d7 | ths | |
70 | 4fa551d7 | ths | #define REGNAME r12
|
71 | 4fa551d7 | ths | #define REG (env->regs[12]) |
72 | 4fa551d7 | ths | #include "op_template.h" |
73 | 4fa551d7 | ths | |
74 | 4fa551d7 | ths | #define REGNAME r13
|
75 | 4fa551d7 | ths | #define REG (env->regs[13]) |
76 | 4fa551d7 | ths | #include "op_template.h" |
77 | 4fa551d7 | ths | |
78 | 4fa551d7 | ths | #define REGNAME r14
|
79 | 4fa551d7 | ths | #define REG (env->regs[14]) |
80 | 4fa551d7 | ths | #include "op_template.h" |
81 | 4fa551d7 | ths | |
82 | 4fa551d7 | ths | #define REGNAME r15
|
83 | 4fa551d7 | ths | #define REG (env->regs[15]) |
84 | 4fa551d7 | ths | #include "op_template.h" |
85 | 4fa551d7 | ths | |
86 | 4fa551d7 | ths | |
87 | 4fa551d7 | ths | #define REGNAME p0
|
88 | 4fa551d7 | ths | #define REG (env->pregs[0]) |
89 | 4fa551d7 | ths | #include "op_template.h" |
90 | 4fa551d7 | ths | |
91 | 4fa551d7 | ths | #define REGNAME p1
|
92 | 4fa551d7 | ths | #define REG (env->pregs[1]) |
93 | 4fa551d7 | ths | #include "op_template.h" |
94 | 4fa551d7 | ths | |
95 | 4fa551d7 | ths | #define REGNAME p2
|
96 | 4fa551d7 | ths | #define REG (env->pregs[2]) |
97 | 4fa551d7 | ths | #include "op_template.h" |
98 | 4fa551d7 | ths | |
99 | 4fa551d7 | ths | #define REGNAME p3
|
100 | 4fa551d7 | ths | #define REG (env->pregs[3]) |
101 | 4fa551d7 | ths | #include "op_template.h" |
102 | 4fa551d7 | ths | |
103 | 4fa551d7 | ths | #define REGNAME p4
|
104 | 4fa551d7 | ths | #define REG (env->pregs[4]) |
105 | 4fa551d7 | ths | #include "op_template.h" |
106 | 4fa551d7 | ths | |
107 | 4fa551d7 | ths | #define REGNAME p5
|
108 | 4fa551d7 | ths | #define REG (env->pregs[5]) |
109 | 4fa551d7 | ths | #include "op_template.h" |
110 | 4fa551d7 | ths | |
111 | 4fa551d7 | ths | #define REGNAME p6
|
112 | 4fa551d7 | ths | #define REG (env->pregs[6]) |
113 | 4fa551d7 | ths | #include "op_template.h" |
114 | 4fa551d7 | ths | |
115 | 4fa551d7 | ths | #define REGNAME p7
|
116 | 4fa551d7 | ths | #define REG (env->pregs[7]) |
117 | 4fa551d7 | ths | #include "op_template.h" |
118 | 4fa551d7 | ths | |
119 | 4fa551d7 | ths | #define REGNAME p8
|
120 | 4fa551d7 | ths | #define REG (env->pregs[8]) |
121 | 4fa551d7 | ths | #include "op_template.h" |
122 | 4fa551d7 | ths | |
123 | 4fa551d7 | ths | #define REGNAME p9
|
124 | 4fa551d7 | ths | #define REG (env->pregs[9]) |
125 | 4fa551d7 | ths | #include "op_template.h" |
126 | 4fa551d7 | ths | |
127 | 4fa551d7 | ths | #define REGNAME p10
|
128 | 4fa551d7 | ths | #define REG (env->pregs[10]) |
129 | 4fa551d7 | ths | #include "op_template.h" |
130 | 4fa551d7 | ths | |
131 | 4fa551d7 | ths | #define REGNAME p11
|
132 | 4fa551d7 | ths | #define REG (env->pregs[11]) |
133 | 4fa551d7 | ths | #include "op_template.h" |
134 | 4fa551d7 | ths | |
135 | 4fa551d7 | ths | #define REGNAME p12
|
136 | 4fa551d7 | ths | #define REG (env->pregs[12]) |
137 | 4fa551d7 | ths | #include "op_template.h" |
138 | 4fa551d7 | ths | |
139 | 4fa551d7 | ths | #define REGNAME p13
|
140 | 4fa551d7 | ths | #define REG (env->pregs[13]) |
141 | 4fa551d7 | ths | #include "op_template.h" |
142 | 4fa551d7 | ths | |
143 | 4fa551d7 | ths | #define REGNAME p14
|
144 | 4fa551d7 | ths | #define REG (env->pregs[14]) |
145 | 4fa551d7 | ths | #include "op_template.h" |
146 | 4fa551d7 | ths | |
147 | 4fa551d7 | ths | #define REGNAME p15
|
148 | 4fa551d7 | ths | #define REG (env->pregs[15]) |
149 | 4fa551d7 | ths | #include "op_template.h" |
150 | 4fa551d7 | ths | |
151 | 4fa551d7 | ths | /* Microcode. */
|
152 | 4fa551d7 | ths | |
153 | 4fa551d7 | ths | void OPPROTO op_exit_tb (void) |
154 | 4fa551d7 | ths | { |
155 | 4fa551d7 | ths | EXIT_TB(); |
156 | 4fa551d7 | ths | } |
157 | 4fa551d7 | ths | |
158 | 4fa551d7 | ths | void OPPROTO op_goto_tb0 (void) |
159 | 4fa551d7 | ths | { |
160 | 4fa551d7 | ths | GOTO_TB(op_goto_tb0, PARAM1, 0);
|
161 | 4fa551d7 | ths | RETURN(); |
162 | 4fa551d7 | ths | } |
163 | 4fa551d7 | ths | |
164 | 4fa551d7 | ths | void OPPROTO op_goto_tb1 (void) |
165 | 4fa551d7 | ths | { |
166 | 4fa551d7 | ths | GOTO_TB(op_goto_tb1, PARAM1, 1);
|
167 | 4fa551d7 | ths | RETURN(); |
168 | 4fa551d7 | ths | } |
169 | 4fa551d7 | ths | |
170 | 4fa551d7 | ths | void OPPROTO op_break_im(void) |
171 | 4fa551d7 | ths | { |
172 | 4fa551d7 | ths | env->trapnr = PARAM1; |
173 | 4fa551d7 | ths | env->exception_index = EXCP_BREAK; |
174 | 4fa551d7 | ths | cpu_loop_exit(); |
175 | 4fa551d7 | ths | } |
176 | 4fa551d7 | ths | |
177 | 4fa551d7 | ths | void OPPROTO op_debug(void) |
178 | 4fa551d7 | ths | { |
179 | 4fa551d7 | ths | env->exception_index = EXCP_DEBUG; |
180 | 4fa551d7 | ths | cpu_loop_exit(); |
181 | 4fa551d7 | ths | } |
182 | 4fa551d7 | ths | |
183 | 4fa551d7 | ths | void OPPROTO op_exec_insn(void) |
184 | 4fa551d7 | ths | { |
185 | 4fa551d7 | ths | env->stats.exec_insns++; |
186 | 4fa551d7 | ths | RETURN(); |
187 | 4fa551d7 | ths | } |
188 | 4fa551d7 | ths | void OPPROTO op_exec_load(void) |
189 | 4fa551d7 | ths | { |
190 | 4fa551d7 | ths | env->stats.exec_loads++; |
191 | 4fa551d7 | ths | RETURN(); |
192 | 4fa551d7 | ths | } |
193 | 4fa551d7 | ths | void OPPROTO op_exec_store(void) |
194 | 4fa551d7 | ths | { |
195 | 4fa551d7 | ths | env->stats.exec_stores++; |
196 | 4fa551d7 | ths | RETURN(); |
197 | 4fa551d7 | ths | } |
198 | 4fa551d7 | ths | |
199 | 4fa551d7 | ths | void OPPROTO op_ccs_lshift (void) |
200 | 4fa551d7 | ths | { |
201 | 4fa551d7 | ths | uint32_t ccs; |
202 | 4fa551d7 | ths | |
203 | 4fa551d7 | ths | /* Apply the ccs shift. */
|
204 | 4fa551d7 | ths | ccs = env->pregs[SR_CCS]; |
205 | 4fa551d7 | ths | ccs = (ccs & 0xc0000000) | ((ccs << 12) >> 2); |
206 | 4fa551d7 | ths | env->pregs[SR_CCS] = ccs; |
207 | 4fa551d7 | ths | } |
208 | 4fa551d7 | ths | void OPPROTO op_ccs_rshift (void) |
209 | 4fa551d7 | ths | { |
210 | 4fa551d7 | ths | uint32_t ccs; |
211 | 4fa551d7 | ths | |
212 | 4fa551d7 | ths | /* Apply the ccs shift. */
|
213 | 4fa551d7 | ths | ccs = env->pregs[SR_CCS]; |
214 | 4fa551d7 | ths | ccs = (ccs & 0xc0000000) | (ccs >> 10); |
215 | 4fa551d7 | ths | env->pregs[SR_CCS] = ccs; |
216 | 4fa551d7 | ths | } |
217 | 4fa551d7 | ths | |
218 | 4fa551d7 | ths | void OPPROTO op_setf (void) |
219 | 4fa551d7 | ths | { |
220 | 4fa551d7 | ths | env->pregs[SR_CCS] |= PARAM1; |
221 | 4fa551d7 | ths | RETURN(); |
222 | 4fa551d7 | ths | } |
223 | 4fa551d7 | ths | |
224 | 4fa551d7 | ths | void OPPROTO op_clrf (void) |
225 | 4fa551d7 | ths | { |
226 | 4fa551d7 | ths | env->pregs[SR_CCS] &= ~PARAM1; |
227 | 4fa551d7 | ths | RETURN(); |
228 | 4fa551d7 | ths | } |
229 | 4fa551d7 | ths | |
230 | 4fa551d7 | ths | void OPPROTO op_movl_debug1_T0 (void) |
231 | 4fa551d7 | ths | { |
232 | 4fa551d7 | ths | env->debug1 = T0; |
233 | 4fa551d7 | ths | RETURN(); |
234 | 4fa551d7 | ths | } |
235 | 4fa551d7 | ths | |
236 | 4fa551d7 | ths | void OPPROTO op_movl_debug2_T0 (void) |
237 | 4fa551d7 | ths | { |
238 | 4fa551d7 | ths | env->debug2 = T0; |
239 | 4fa551d7 | ths | RETURN(); |
240 | 4fa551d7 | ths | } |
241 | 4fa551d7 | ths | |
242 | 4fa551d7 | ths | void OPPROTO op_movl_debug3_T0 (void) |
243 | 4fa551d7 | ths | { |
244 | 4fa551d7 | ths | env->debug3 = T0; |
245 | 4fa551d7 | ths | RETURN(); |
246 | 4fa551d7 | ths | } |
247 | 4fa551d7 | ths | void OPPROTO op_movl_debug1_T1 (void) |
248 | 4fa551d7 | ths | { |
249 | 4fa551d7 | ths | env->debug1 = T1; |
250 | 4fa551d7 | ths | RETURN(); |
251 | 4fa551d7 | ths | } |
252 | 4fa551d7 | ths | |
253 | 4fa551d7 | ths | void OPPROTO op_movl_debug2_T1 (void) |
254 | 4fa551d7 | ths | { |
255 | 4fa551d7 | ths | env->debug2 = T1; |
256 | 4fa551d7 | ths | RETURN(); |
257 | 4fa551d7 | ths | } |
258 | 4fa551d7 | ths | |
259 | 4fa551d7 | ths | void OPPROTO op_movl_debug3_T1 (void) |
260 | 4fa551d7 | ths | { |
261 | 4fa551d7 | ths | env->debug3 = T1; |
262 | 4fa551d7 | ths | RETURN(); |
263 | 4fa551d7 | ths | } |
264 | 4fa551d7 | ths | void OPPROTO op_movl_debug3_im (void) |
265 | 4fa551d7 | ths | { |
266 | 4fa551d7 | ths | env->debug3 = PARAM1; |
267 | 4fa551d7 | ths | RETURN(); |
268 | 4fa551d7 | ths | } |
269 | 4fa551d7 | ths | void OPPROTO op_movl_T0_flags (void) |
270 | 4fa551d7 | ths | { |
271 | 4fa551d7 | ths | T0 = env->pregs[SR_CCS]; |
272 | 4fa551d7 | ths | RETURN(); |
273 | 4fa551d7 | ths | } |
274 | 4fa551d7 | ths | void OPPROTO op_movl_flags_T0 (void) |
275 | 4fa551d7 | ths | { |
276 | 4fa551d7 | ths | env->pregs[SR_CCS] = T0; |
277 | 4fa551d7 | ths | RETURN(); |
278 | 4fa551d7 | ths | } |
279 | 4fa551d7 | ths | |
280 | 4fa551d7 | ths | void OPPROTO op_movl_sreg_T0 (void) |
281 | 4fa551d7 | ths | { |
282 | 4fa551d7 | ths | env->sregs[env->pregs[SR_SRS]][PARAM1] = T0; |
283 | 4fa551d7 | ths | RETURN(); |
284 | 4fa551d7 | ths | } |
285 | 4fa551d7 | ths | |
286 | 4fa551d7 | ths | void OPPROTO op_movl_tlb_lo_T0 (void) |
287 | 4fa551d7 | ths | { |
288 | 4fa551d7 | ths | int srs;
|
289 | 4fa551d7 | ths | srs = env->pregs[SR_SRS]; |
290 | 4fa551d7 | ths | if (srs == 1 || srs == 2) |
291 | 4fa551d7 | ths | { |
292 | 4fa551d7 | ths | int set;
|
293 | 4fa551d7 | ths | int idx;
|
294 | 4fa551d7 | ths | uint32_t lo, hi; |
295 | 4fa551d7 | ths | |
296 | 4fa551d7 | ths | idx = set = env->sregs[SFR_RW_MM_TLB_SEL]; |
297 | 4fa551d7 | ths | set >>= 4;
|
298 | 4fa551d7 | ths | set &= 3;
|
299 | 4fa551d7 | ths | |
300 | 4fa551d7 | ths | idx &= 31;
|
301 | 4fa551d7 | ths | /* We've just made a write to tlb_lo. */
|
302 | 4fa551d7 | ths | lo = env->sregs[SFR_RW_MM_TLB_LO]; |
303 | 4fa551d7 | ths | hi = env->sregs[SFR_RW_MM_TLB_HI]; |
304 | 4fa551d7 | ths | env->tlbsets[srs - 1][set][idx].lo = lo;
|
305 | 4fa551d7 | ths | env->tlbsets[srs - 1][set][idx].hi = hi;
|
306 | 4fa551d7 | ths | } |
307 | 4fa551d7 | ths | |
308 | 4fa551d7 | ths | RETURN(); |
309 | 4fa551d7 | ths | } |
310 | 4fa551d7 | ths | |
311 | 4fa551d7 | ths | void OPPROTO op_movl_T0_sreg (void) |
312 | 4fa551d7 | ths | { |
313 | 4fa551d7 | ths | T0 = env->sregs[env->pregs[SR_SRS]][PARAM1]; |
314 | 4fa551d7 | ths | RETURN(); |
315 | 4fa551d7 | ths | } |
316 | 4fa551d7 | ths | |
317 | 4fa551d7 | ths | void OPPROTO op_update_cc (void) |
318 | 4fa551d7 | ths | { |
319 | 4fa551d7 | ths | env->cc_op = PARAM1; |
320 | 4fa551d7 | ths | env->cc_dest = PARAM2; |
321 | 4fa551d7 | ths | env->cc_src = PARAM3; |
322 | 4fa551d7 | ths | RETURN(); |
323 | 4fa551d7 | ths | } |
324 | 4fa551d7 | ths | |
325 | 4fa551d7 | ths | void OPPROTO op_update_cc_op (void) |
326 | 4fa551d7 | ths | { |
327 | 4fa551d7 | ths | env->cc_op = PARAM1; |
328 | 4fa551d7 | ths | RETURN(); |
329 | 4fa551d7 | ths | } |
330 | 4fa551d7 | ths | |
331 | 4fa551d7 | ths | void OPPROTO op_update_cc_mask (void) |
332 | 4fa551d7 | ths | { |
333 | 4fa551d7 | ths | env->cc_mask = PARAM1; |
334 | 4fa551d7 | ths | RETURN(); |
335 | 4fa551d7 | ths | } |
336 | 4fa551d7 | ths | |
337 | 4fa551d7 | ths | void OPPROTO op_update_cc_dest_T0 (void) |
338 | 4fa551d7 | ths | { |
339 | 4fa551d7 | ths | env->cc_dest = T0; |
340 | 4fa551d7 | ths | RETURN(); |
341 | 4fa551d7 | ths | } |
342 | 4fa551d7 | ths | |
343 | 4fa551d7 | ths | void OPPROTO op_update_cc_result_T0 (void) |
344 | 4fa551d7 | ths | { |
345 | 4fa551d7 | ths | env->cc_result = T0; |
346 | 4fa551d7 | ths | RETURN(); |
347 | 4fa551d7 | ths | } |
348 | 4fa551d7 | ths | |
349 | 4fa551d7 | ths | void OPPROTO op_update_cc_size_im (void) |
350 | 4fa551d7 | ths | { |
351 | 4fa551d7 | ths | env->cc_size = PARAM1; |
352 | 4fa551d7 | ths | RETURN(); |
353 | 4fa551d7 | ths | } |
354 | 4fa551d7 | ths | |
355 | 4fa551d7 | ths | void OPPROTO op_update_cc_src_T1 (void) |
356 | 4fa551d7 | ths | { |
357 | 4fa551d7 | ths | env->cc_src = T1; |
358 | 4fa551d7 | ths | RETURN(); |
359 | 4fa551d7 | ths | } |
360 | 4fa551d7 | ths | void OPPROTO op_update_cc_x (void) |
361 | 4fa551d7 | ths | { |
362 | 4fa551d7 | ths | env->cc_x_live = PARAM1; |
363 | 4fa551d7 | ths | env->cc_x = PARAM2; |
364 | 4fa551d7 | ths | RETURN(); |
365 | 4fa551d7 | ths | } |
366 | 4fa551d7 | ths | |
367 | 4fa551d7 | ths | /* FIXME: is this allowed? */
|
368 | 4fa551d7 | ths | extern inline void evaluate_flags_writeback(uint32_t flags) |
369 | 4fa551d7 | ths | { |
370 | 4fa551d7 | ths | int x;
|
371 | 4fa551d7 | ths | |
372 | 4fa551d7 | ths | /* Extended arithmetics, leave the z flag alone. */
|
373 | 4fa551d7 | ths | env->debug3 = env->pregs[SR_CCS]; |
374 | 4fa551d7 | ths | |
375 | 4fa551d7 | ths | if (env->cc_x_live)
|
376 | 4fa551d7 | ths | x = env->cc_x; |
377 | 4fa551d7 | ths | else
|
378 | 4fa551d7 | ths | x = env->pregs[SR_CCS] & X_FLAG; |
379 | 4fa551d7 | ths | |
380 | 4fa551d7 | ths | if ((x || env->cc_op == CC_OP_ADDC)
|
381 | 4fa551d7 | ths | && flags & Z_FLAG) |
382 | 4fa551d7 | ths | env->cc_mask &= ~Z_FLAG; |
383 | 4fa551d7 | ths | |
384 | 4fa551d7 | ths | /* all insn clear the x-flag except setf or clrf. */
|
385 | 4fa551d7 | ths | env->pregs[SR_CCS] &= ~(env->cc_mask | X_FLAG); |
386 | 4fa551d7 | ths | flags &= env->cc_mask; |
387 | 4fa551d7 | ths | env->pregs[SR_CCS] |= flags; |
388 | 4fa551d7 | ths | RETURN(); |
389 | 4fa551d7 | ths | } |
390 | 4fa551d7 | ths | |
391 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags_muls(void) |
392 | 4fa551d7 | ths | { |
393 | 4fa551d7 | ths | uint32_t src; |
394 | 4fa551d7 | ths | uint32_t dst; |
395 | 4fa551d7 | ths | uint32_t res; |
396 | 4fa551d7 | ths | uint32_t flags = 0;
|
397 | 4fa551d7 | ths | /* were gonna have to redo the muls. */
|
398 | 4fa551d7 | ths | int64_t tmp, t0 ,t1; |
399 | 4fa551d7 | ths | int32_t mof; |
400 | 4fa551d7 | ths | int dneg;
|
401 | 4fa551d7 | ths | |
402 | 4fa551d7 | ths | src = env->cc_src; |
403 | 4fa551d7 | ths | dst = env->cc_dest; |
404 | 4fa551d7 | ths | res = env->cc_result; |
405 | 4fa551d7 | ths | |
406 | 4fa551d7 | ths | |
407 | 4fa551d7 | ths | /* cast into signed values to make GCC sign extend. */
|
408 | 4fa551d7 | ths | t0 = (int32_t)src; |
409 | 4fa551d7 | ths | t1 = (int32_t)dst; |
410 | 4fa551d7 | ths | dneg = ((int32_t)res) < 0;
|
411 | 4fa551d7 | ths | |
412 | 4fa551d7 | ths | tmp = t0 * t1; |
413 | 4fa551d7 | ths | mof = tmp >> 32;
|
414 | 4fa551d7 | ths | if (tmp == 0) |
415 | 4fa551d7 | ths | flags |= Z_FLAG; |
416 | 4fa551d7 | ths | else if (tmp < 0) |
417 | 4fa551d7 | ths | flags |= N_FLAG; |
418 | 4fa551d7 | ths | if ((dneg && mof != -1) |
419 | 4fa551d7 | ths | || (!dneg && mof != 0))
|
420 | 4fa551d7 | ths | flags |= V_FLAG; |
421 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
422 | 4fa551d7 | ths | RETURN(); |
423 | 4fa551d7 | ths | } |
424 | 4fa551d7 | ths | |
425 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags_mulu(void) |
426 | 4fa551d7 | ths | { |
427 | 4fa551d7 | ths | uint32_t src; |
428 | 4fa551d7 | ths | uint32_t dst; |
429 | 4fa551d7 | ths | uint32_t res; |
430 | 4fa551d7 | ths | uint32_t flags = 0;
|
431 | 4fa551d7 | ths | /* were gonna have to redo the muls. */
|
432 | 4fa551d7 | ths | uint64_t tmp, t0 ,t1; |
433 | 4fa551d7 | ths | uint32_t mof; |
434 | 4fa551d7 | ths | |
435 | 4fa551d7 | ths | src = env->cc_src; |
436 | 4fa551d7 | ths | dst = env->cc_dest; |
437 | 4fa551d7 | ths | res = env->cc_result; |
438 | 4fa551d7 | ths | |
439 | 4fa551d7 | ths | |
440 | 4fa551d7 | ths | /* cast into signed values to make GCC sign extend. */
|
441 | 4fa551d7 | ths | t0 = src; |
442 | 4fa551d7 | ths | t1 = dst; |
443 | 4fa551d7 | ths | |
444 | 4fa551d7 | ths | tmp = t0 * t1; |
445 | 4fa551d7 | ths | mof = tmp >> 32;
|
446 | 4fa551d7 | ths | if (tmp == 0) |
447 | 4fa551d7 | ths | flags |= Z_FLAG; |
448 | 4fa551d7 | ths | else if (tmp >> 63) |
449 | 4fa551d7 | ths | flags |= N_FLAG; |
450 | 4fa551d7 | ths | if (mof)
|
451 | 4fa551d7 | ths | flags |= V_FLAG; |
452 | 4fa551d7 | ths | |
453 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
454 | 4fa551d7 | ths | RETURN(); |
455 | 4fa551d7 | ths | } |
456 | 4fa551d7 | ths | |
457 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags_mcp(void) |
458 | 4fa551d7 | ths | { |
459 | 4fa551d7 | ths | uint32_t src; |
460 | 4fa551d7 | ths | uint32_t dst; |
461 | 4fa551d7 | ths | uint32_t res; |
462 | 4fa551d7 | ths | uint32_t flags = 0;
|
463 | 4fa551d7 | ths | |
464 | 4fa551d7 | ths | src = env->cc_src; |
465 | 4fa551d7 | ths | dst = env->cc_dest; |
466 | 4fa551d7 | ths | res = env->cc_result; |
467 | 4fa551d7 | ths | |
468 | 4fa551d7 | ths | if ((res & 0x80000000L) != 0L) |
469 | 4fa551d7 | ths | { |
470 | 4fa551d7 | ths | flags |= N_FLAG; |
471 | 4fa551d7 | ths | if (((src & 0x80000000L) == 0L) |
472 | 4fa551d7 | ths | && ((dst & 0x80000000L) == 0L)) |
473 | 4fa551d7 | ths | { |
474 | 4fa551d7 | ths | flags |= V_FLAG; |
475 | 4fa551d7 | ths | } |
476 | 4fa551d7 | ths | else if (((src & 0x80000000L) != 0L) && |
477 | 4fa551d7 | ths | ((dst & 0x80000000L) != 0L)) |
478 | 4fa551d7 | ths | { |
479 | 4fa551d7 | ths | flags |= R_FLAG; |
480 | 4fa551d7 | ths | } |
481 | 4fa551d7 | ths | } |
482 | 4fa551d7 | ths | else
|
483 | 4fa551d7 | ths | { |
484 | 4fa551d7 | ths | if (res == 0L) |
485 | 4fa551d7 | ths | flags |= Z_FLAG; |
486 | 4fa551d7 | ths | if (((src & 0x80000000L) != 0L) |
487 | 4fa551d7 | ths | && ((dst & 0x80000000L) != 0L)) |
488 | 4fa551d7 | ths | flags |= V_FLAG; |
489 | 4fa551d7 | ths | if ((dst & 0x80000000L) != 0L |
490 | 4fa551d7 | ths | || (src & 0x80000000L) != 0L) |
491 | 4fa551d7 | ths | flags |= R_FLAG; |
492 | 4fa551d7 | ths | } |
493 | 4fa551d7 | ths | |
494 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
495 | 4fa551d7 | ths | RETURN(); |
496 | 4fa551d7 | ths | } |
497 | 4fa551d7 | ths | |
498 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags_alu_4(void) |
499 | 4fa551d7 | ths | { |
500 | 4fa551d7 | ths | uint32_t src; |
501 | 4fa551d7 | ths | uint32_t dst; |
502 | 4fa551d7 | ths | uint32_t res; |
503 | 4fa551d7 | ths | uint32_t flags = 0;
|
504 | 4fa551d7 | ths | |
505 | 4fa551d7 | ths | src = env->cc_src; |
506 | 4fa551d7 | ths | dst = env->cc_dest; |
507 | 4fa551d7 | ths | res = env->cc_result; |
508 | 4fa551d7 | ths | |
509 | 4fa551d7 | ths | if ((res & 0x80000000L) != 0L) |
510 | 4fa551d7 | ths | { |
511 | 4fa551d7 | ths | flags |= N_FLAG; |
512 | 4fa551d7 | ths | if (((src & 0x80000000L) == 0L) |
513 | 4fa551d7 | ths | && ((dst & 0x80000000L) == 0L)) |
514 | 4fa551d7 | ths | { |
515 | 4fa551d7 | ths | flags |= V_FLAG; |
516 | 4fa551d7 | ths | } |
517 | 4fa551d7 | ths | else if (((src & 0x80000000L) != 0L) && |
518 | 4fa551d7 | ths | ((dst & 0x80000000L) != 0L)) |
519 | 4fa551d7 | ths | { |
520 | 4fa551d7 | ths | flags |= C_FLAG; |
521 | 4fa551d7 | ths | } |
522 | 4fa551d7 | ths | } |
523 | 4fa551d7 | ths | else
|
524 | 4fa551d7 | ths | { |
525 | 4fa551d7 | ths | if (res == 0L) |
526 | 4fa551d7 | ths | flags |= Z_FLAG; |
527 | 4fa551d7 | ths | if (((src & 0x80000000L) != 0L) |
528 | 4fa551d7 | ths | && ((dst & 0x80000000L) != 0L)) |
529 | 4fa551d7 | ths | flags |= V_FLAG; |
530 | 4fa551d7 | ths | if ((dst & 0x80000000L) != 0L |
531 | 4fa551d7 | ths | || (src & 0x80000000L) != 0L) |
532 | 4fa551d7 | ths | flags |= C_FLAG; |
533 | 4fa551d7 | ths | } |
534 | 4fa551d7 | ths | |
535 | 4fa551d7 | ths | if (env->cc_op == CC_OP_SUB
|
536 | 4fa551d7 | ths | || env->cc_op == CC_OP_CMP) { |
537 | 4fa551d7 | ths | flags ^= C_FLAG; |
538 | 4fa551d7 | ths | } |
539 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
540 | 4fa551d7 | ths | RETURN(); |
541 | 4fa551d7 | ths | } |
542 | 4fa551d7 | ths | |
543 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags_move_4 (void) |
544 | 4fa551d7 | ths | { |
545 | 4fa551d7 | ths | uint32_t src; |
546 | 4fa551d7 | ths | uint32_t res; |
547 | 4fa551d7 | ths | uint32_t flags = 0;
|
548 | 4fa551d7 | ths | |
549 | 4fa551d7 | ths | src = env->cc_src; |
550 | 4fa551d7 | ths | res = env->cc_result; |
551 | 4fa551d7 | ths | |
552 | 4fa551d7 | ths | if ((int32_t)res < 0) |
553 | 4fa551d7 | ths | flags |= N_FLAG; |
554 | 4fa551d7 | ths | else if (res == 0L) |
555 | 4fa551d7 | ths | flags |= Z_FLAG; |
556 | 4fa551d7 | ths | |
557 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
558 | 4fa551d7 | ths | RETURN(); |
559 | 4fa551d7 | ths | } |
560 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags_move_2 (void) |
561 | 4fa551d7 | ths | { |
562 | 4fa551d7 | ths | uint32_t src; |
563 | 4fa551d7 | ths | uint32_t flags = 0;
|
564 | 4fa551d7 | ths | uint16_t res; |
565 | 4fa551d7 | ths | |
566 | 4fa551d7 | ths | src = env->cc_src; |
567 | 4fa551d7 | ths | res = env->cc_result; |
568 | 4fa551d7 | ths | |
569 | 4fa551d7 | ths | if ((int16_t)res < 0L) |
570 | 4fa551d7 | ths | flags |= N_FLAG; |
571 | 4fa551d7 | ths | else if (res == 0) |
572 | 4fa551d7 | ths | flags |= Z_FLAG; |
573 | 4fa551d7 | ths | |
574 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
575 | 4fa551d7 | ths | RETURN(); |
576 | 4fa551d7 | ths | } |
577 | 4fa551d7 | ths | |
578 | 4fa551d7 | ths | /* TODO: This is expensive. We could split things up and only evaluate part of
|
579 | 4fa551d7 | ths | CCR on a need to know basis. For now, we simply re-evaluate everything. */
|
580 | 4fa551d7 | ths | void OPPROTO op_evaluate_flags (void) |
581 | 4fa551d7 | ths | { |
582 | 4fa551d7 | ths | uint32_t src; |
583 | 4fa551d7 | ths | uint32_t dst; |
584 | 4fa551d7 | ths | uint32_t res; |
585 | 4fa551d7 | ths | uint32_t flags = 0;
|
586 | 4fa551d7 | ths | |
587 | 4fa551d7 | ths | src = env->cc_src; |
588 | 4fa551d7 | ths | dst = env->cc_dest; |
589 | 4fa551d7 | ths | res = env->cc_result; |
590 | 4fa551d7 | ths | |
591 | 4fa551d7 | ths | |
592 | 4fa551d7 | ths | /* Now, evaluate the flags. This stuff is based on
|
593 | 4fa551d7 | ths | Per Zander's CRISv10 simulator. */
|
594 | 4fa551d7 | ths | switch (env->cc_size)
|
595 | 4fa551d7 | ths | { |
596 | 4fa551d7 | ths | case 1: |
597 | 4fa551d7 | ths | if ((res & 0x80L) != 0L) |
598 | 4fa551d7 | ths | { |
599 | 4fa551d7 | ths | flags |= N_FLAG; |
600 | 4fa551d7 | ths | if (((src & 0x80L) == 0L) |
601 | 4fa551d7 | ths | && ((dst & 0x80L) == 0L)) |
602 | 4fa551d7 | ths | { |
603 | 4fa551d7 | ths | flags |= V_FLAG; |
604 | 4fa551d7 | ths | } |
605 | 4fa551d7 | ths | else if (((src & 0x80L) != 0L) |
606 | 4fa551d7 | ths | && ((dst & 0x80L) != 0L)) |
607 | 4fa551d7 | ths | { |
608 | 4fa551d7 | ths | flags |= C_FLAG; |
609 | 4fa551d7 | ths | } |
610 | 4fa551d7 | ths | } |
611 | 4fa551d7 | ths | else
|
612 | 4fa551d7 | ths | { |
613 | 4fa551d7 | ths | if ((res & 0xFFL) == 0L) |
614 | 4fa551d7 | ths | { |
615 | 4fa551d7 | ths | flags |= Z_FLAG; |
616 | 4fa551d7 | ths | } |
617 | 4fa551d7 | ths | if (((src & 0x80L) != 0L) |
618 | 4fa551d7 | ths | && ((dst & 0x80L) != 0L)) |
619 | 4fa551d7 | ths | { |
620 | 4fa551d7 | ths | flags |= V_FLAG; |
621 | 4fa551d7 | ths | } |
622 | 4fa551d7 | ths | if ((dst & 0x80L) != 0L |
623 | 4fa551d7 | ths | || (src & 0x80L) != 0L) |
624 | 4fa551d7 | ths | { |
625 | 4fa551d7 | ths | flags |= C_FLAG; |
626 | 4fa551d7 | ths | } |
627 | 4fa551d7 | ths | } |
628 | 4fa551d7 | ths | break;
|
629 | 4fa551d7 | ths | case 2: |
630 | 4fa551d7 | ths | if ((res & 0x8000L) != 0L) |
631 | 4fa551d7 | ths | { |
632 | 4fa551d7 | ths | flags |= N_FLAG; |
633 | 4fa551d7 | ths | if (((src & 0x8000L) == 0L) |
634 | 4fa551d7 | ths | && ((dst & 0x8000L) == 0L)) |
635 | 4fa551d7 | ths | { |
636 | 4fa551d7 | ths | flags |= V_FLAG; |
637 | 4fa551d7 | ths | } |
638 | 4fa551d7 | ths | else if (((src & 0x8000L) != 0L) |
639 | 4fa551d7 | ths | && ((dst & 0x8000L) != 0L)) |
640 | 4fa551d7 | ths | { |
641 | 4fa551d7 | ths | flags |= C_FLAG; |
642 | 4fa551d7 | ths | } |
643 | 4fa551d7 | ths | } |
644 | 4fa551d7 | ths | else
|
645 | 4fa551d7 | ths | { |
646 | 4fa551d7 | ths | if ((res & 0xFFFFL) == 0L) |
647 | 4fa551d7 | ths | { |
648 | 4fa551d7 | ths | flags |= Z_FLAG; |
649 | 4fa551d7 | ths | } |
650 | 4fa551d7 | ths | if (((src & 0x8000L) != 0L) |
651 | 4fa551d7 | ths | && ((dst & 0x8000L) != 0L)) |
652 | 4fa551d7 | ths | { |
653 | 4fa551d7 | ths | flags |= V_FLAG; |
654 | 4fa551d7 | ths | } |
655 | 4fa551d7 | ths | if ((dst & 0x8000L) != 0L |
656 | 4fa551d7 | ths | || (src & 0x8000L) != 0L) |
657 | 4fa551d7 | ths | { |
658 | 4fa551d7 | ths | flags |= C_FLAG; |
659 | 4fa551d7 | ths | } |
660 | 4fa551d7 | ths | } |
661 | 4fa551d7 | ths | break;
|
662 | 4fa551d7 | ths | case 4: |
663 | 4fa551d7 | ths | if ((res & 0x80000000L) != 0L) |
664 | 4fa551d7 | ths | { |
665 | 4fa551d7 | ths | flags |= N_FLAG; |
666 | 4fa551d7 | ths | if (((src & 0x80000000L) == 0L) |
667 | 4fa551d7 | ths | && ((dst & 0x80000000L) == 0L)) |
668 | 4fa551d7 | ths | { |
669 | 4fa551d7 | ths | flags |= V_FLAG; |
670 | 4fa551d7 | ths | } |
671 | 4fa551d7 | ths | else if (((src & 0x80000000L) != 0L) && |
672 | 4fa551d7 | ths | ((dst & 0x80000000L) != 0L)) |
673 | 4fa551d7 | ths | { |
674 | 4fa551d7 | ths | flags |= C_FLAG; |
675 | 4fa551d7 | ths | } |
676 | 4fa551d7 | ths | } |
677 | 4fa551d7 | ths | else
|
678 | 4fa551d7 | ths | { |
679 | 4fa551d7 | ths | if (res == 0L) |
680 | 4fa551d7 | ths | flags |= Z_FLAG; |
681 | 4fa551d7 | ths | if (((src & 0x80000000L) != 0L) |
682 | 4fa551d7 | ths | && ((dst & 0x80000000L) != 0L)) |
683 | 4fa551d7 | ths | flags |= V_FLAG; |
684 | 4fa551d7 | ths | if ((dst & 0x80000000L) != 0L |
685 | 4fa551d7 | ths | || (src & 0x80000000L) != 0L) |
686 | 4fa551d7 | ths | flags |= C_FLAG; |
687 | 4fa551d7 | ths | } |
688 | 4fa551d7 | ths | break;
|
689 | 4fa551d7 | ths | default:
|
690 | 4fa551d7 | ths | break;
|
691 | 4fa551d7 | ths | } |
692 | 4fa551d7 | ths | |
693 | 4fa551d7 | ths | if (env->cc_op == CC_OP_SUB
|
694 | 4fa551d7 | ths | || env->cc_op == CC_OP_CMP) { |
695 | 4fa551d7 | ths | flags ^= C_FLAG; |
696 | 4fa551d7 | ths | } |
697 | 4fa551d7 | ths | evaluate_flags_writeback(flags); |
698 | 4fa551d7 | ths | RETURN(); |
699 | 4fa551d7 | ths | } |
700 | 4fa551d7 | ths | |
701 | 4fa551d7 | ths | void OPPROTO op_extb_T0_T0 (void) |
702 | 4fa551d7 | ths | { |
703 | 4fa551d7 | ths | T0 = ((int8_t)T0); |
704 | 4fa551d7 | ths | RETURN(); |
705 | 4fa551d7 | ths | } |
706 | 4fa551d7 | ths | void OPPROTO op_extb_T1_T0 (void) |
707 | 4fa551d7 | ths | { |
708 | 4fa551d7 | ths | T1 = ((int8_t)T0); |
709 | 4fa551d7 | ths | RETURN(); |
710 | 4fa551d7 | ths | } |
711 | 4fa551d7 | ths | void OPPROTO op_extb_T1_T1 (void) |
712 | 4fa551d7 | ths | { |
713 | 4fa551d7 | ths | T1 = ((int8_t)T1); |
714 | 4fa551d7 | ths | RETURN(); |
715 | 4fa551d7 | ths | } |
716 | 4fa551d7 | ths | void OPPROTO op_zextb_T0_T0 (void) |
717 | 4fa551d7 | ths | { |
718 | 4fa551d7 | ths | T0 = ((uint8_t)T0); |
719 | 4fa551d7 | ths | RETURN(); |
720 | 4fa551d7 | ths | } |
721 | 4fa551d7 | ths | void OPPROTO op_zextb_T1_T0 (void) |
722 | 4fa551d7 | ths | { |
723 | 4fa551d7 | ths | T1 = ((uint8_t)T0); |
724 | 4fa551d7 | ths | RETURN(); |
725 | 4fa551d7 | ths | } |
726 | 4fa551d7 | ths | void OPPROTO op_zextb_T1_T1 (void) |
727 | 4fa551d7 | ths | { |
728 | 4fa551d7 | ths | T1 = ((uint8_t)T1); |
729 | 4fa551d7 | ths | RETURN(); |
730 | 4fa551d7 | ths | } |
731 | 4fa551d7 | ths | void OPPROTO op_extw_T0_T0 (void) |
732 | 4fa551d7 | ths | { |
733 | 4fa551d7 | ths | T0 = ((int16_t)T0); |
734 | 4fa551d7 | ths | RETURN(); |
735 | 4fa551d7 | ths | } |
736 | 4fa551d7 | ths | void OPPROTO op_extw_T1_T0 (void) |
737 | 4fa551d7 | ths | { |
738 | 4fa551d7 | ths | T1 = ((int16_t)T0); |
739 | 4fa551d7 | ths | RETURN(); |
740 | 4fa551d7 | ths | } |
741 | 4fa551d7 | ths | void OPPROTO op_extw_T1_T1 (void) |
742 | 4fa551d7 | ths | { |
743 | 4fa551d7 | ths | T1 = ((int16_t)T1); |
744 | 4fa551d7 | ths | RETURN(); |
745 | 4fa551d7 | ths | } |
746 | 4fa551d7 | ths | |
747 | 4fa551d7 | ths | void OPPROTO op_zextw_T0_T0 (void) |
748 | 4fa551d7 | ths | { |
749 | 4fa551d7 | ths | T0 = ((uint16_t)T0); |
750 | 4fa551d7 | ths | RETURN(); |
751 | 4fa551d7 | ths | } |
752 | 4fa551d7 | ths | void OPPROTO op_zextw_T1_T0 (void) |
753 | 4fa551d7 | ths | { |
754 | 4fa551d7 | ths | T1 = ((uint16_t)T0); |
755 | 4fa551d7 | ths | RETURN(); |
756 | 4fa551d7 | ths | } |
757 | 4fa551d7 | ths | |
758 | 4fa551d7 | ths | void OPPROTO op_zextw_T1_T1 (void) |
759 | 4fa551d7 | ths | { |
760 | 4fa551d7 | ths | T1 = ((uint16_t)T1); |
761 | 4fa551d7 | ths | RETURN(); |
762 | 4fa551d7 | ths | } |
763 | 4fa551d7 | ths | |
764 | 4fa551d7 | ths | void OPPROTO op_movl_T0_im (void) |
765 | 4fa551d7 | ths | { |
766 | 4fa551d7 | ths | T0 = PARAM1; |
767 | 4fa551d7 | ths | RETURN(); |
768 | 4fa551d7 | ths | } |
769 | 4fa551d7 | ths | void OPPROTO op_movl_T1_im (void) |
770 | 4fa551d7 | ths | { |
771 | 4fa551d7 | ths | T1 = PARAM1; |
772 | 4fa551d7 | ths | RETURN(); |
773 | 4fa551d7 | ths | } |
774 | 4fa551d7 | ths | |
775 | 4fa551d7 | ths | void OPPROTO op_addl_T0_im (void) |
776 | 4fa551d7 | ths | { |
777 | 4fa551d7 | ths | T0 += PARAM1; |
778 | 4fa551d7 | ths | RETURN(); |
779 | 4fa551d7 | ths | } |
780 | 4fa551d7 | ths | |
781 | 4fa551d7 | ths | void OPPROTO op_addl_T1_im (void) |
782 | 4fa551d7 | ths | { |
783 | 4fa551d7 | ths | T1 += PARAM1; |
784 | 4fa551d7 | ths | RETURN(); |
785 | 4fa551d7 | ths | |
786 | 4fa551d7 | ths | } |
787 | 4fa551d7 | ths | void OPPROTO op_subl_T0_im (void) |
788 | 4fa551d7 | ths | { |
789 | 4fa551d7 | ths | T0 -= PARAM1; |
790 | 4fa551d7 | ths | RETURN(); |
791 | 4fa551d7 | ths | } |
792 | 4fa551d7 | ths | |
793 | 4fa551d7 | ths | void OPPROTO op_addxl_T0_C (void) |
794 | 4fa551d7 | ths | { |
795 | 4fa551d7 | ths | if (env->pregs[SR_CCS] & X_FLAG)
|
796 | 4fa551d7 | ths | T0 += !!(env->pregs[SR_CCS] & C_FLAG); |
797 | 4fa551d7 | ths | RETURN(); |
798 | 4fa551d7 | ths | } |
799 | 4fa551d7 | ths | void OPPROTO op_subxl_T0_C (void) |
800 | 4fa551d7 | ths | { |
801 | 4fa551d7 | ths | if (env->pregs[SR_CCS] & X_FLAG)
|
802 | 4fa551d7 | ths | T0 -= !!(env->pregs[SR_CCS] & C_FLAG); |
803 | 4fa551d7 | ths | RETURN(); |
804 | 4fa551d7 | ths | } |
805 | 4fa551d7 | ths | void OPPROTO op_addl_T0_C (void) |
806 | 4fa551d7 | ths | { |
807 | 4fa551d7 | ths | T0 += !!(env->pregs[SR_CCS] & C_FLAG); |
808 | 4fa551d7 | ths | RETURN(); |
809 | 4fa551d7 | ths | } |
810 | 4fa551d7 | ths | void OPPROTO op_addl_T0_R (void) |
811 | 4fa551d7 | ths | { |
812 | 4fa551d7 | ths | T0 += !!(env->pregs[SR_CCS] & R_FLAG); |
813 | 4fa551d7 | ths | RETURN(); |
814 | 4fa551d7 | ths | } |
815 | 4fa551d7 | ths | |
816 | 4fa551d7 | ths | void OPPROTO op_clr_R (void) |
817 | 4fa551d7 | ths | { |
818 | 4fa551d7 | ths | env->pregs[SR_CCS] &= ~R_FLAG; |
819 | 4fa551d7 | ths | RETURN(); |
820 | 4fa551d7 | ths | } |
821 | 4fa551d7 | ths | |
822 | 4fa551d7 | ths | |
823 | 4fa551d7 | ths | void OPPROTO op_andl_T0_im (void) |
824 | 4fa551d7 | ths | { |
825 | 4fa551d7 | ths | T0 &= PARAM1; |
826 | 4fa551d7 | ths | RETURN(); |
827 | 4fa551d7 | ths | } |
828 | 4fa551d7 | ths | |
829 | 4fa551d7 | ths | void OPPROTO op_andl_T1_im (void) |
830 | 4fa551d7 | ths | { |
831 | 4fa551d7 | ths | T1 &= PARAM1; |
832 | 4fa551d7 | ths | RETURN(); |
833 | 4fa551d7 | ths | } |
834 | 4fa551d7 | ths | |
835 | 4fa551d7 | ths | void OPPROTO op_movl_T0_T1 (void) |
836 | 4fa551d7 | ths | { |
837 | 4fa551d7 | ths | T0 = T1; |
838 | 4fa551d7 | ths | RETURN(); |
839 | 4fa551d7 | ths | } |
840 | 4fa551d7 | ths | |
841 | 4fa551d7 | ths | void OPPROTO op_swp_T0_T1 (void) |
842 | 4fa551d7 | ths | { |
843 | 4fa551d7 | ths | T0 ^= T1; |
844 | 4fa551d7 | ths | T1 ^= T0; |
845 | 4fa551d7 | ths | T0 ^= T1; |
846 | 4fa551d7 | ths | RETURN(); |
847 | 4fa551d7 | ths | } |
848 | 4fa551d7 | ths | |
849 | 4fa551d7 | ths | void OPPROTO op_movl_T1_T0 (void) |
850 | 4fa551d7 | ths | { |
851 | 4fa551d7 | ths | T1 = T0; |
852 | 4fa551d7 | ths | RETURN(); |
853 | 4fa551d7 | ths | } |
854 | 4fa551d7 | ths | |
855 | 4fa551d7 | ths | void OPPROTO op_movl_pc_T0 (void) |
856 | 4fa551d7 | ths | { |
857 | 4fa551d7 | ths | env->pc = T0; |
858 | 4fa551d7 | ths | RETURN(); |
859 | 4fa551d7 | ths | } |
860 | 4fa551d7 | ths | |
861 | 4fa551d7 | ths | void OPPROTO op_movl_T0_0 (void) |
862 | 4fa551d7 | ths | { |
863 | 4fa551d7 | ths | T0 = 0;
|
864 | 4fa551d7 | ths | RETURN(); |
865 | 4fa551d7 | ths | } |
866 | 4fa551d7 | ths | |
867 | 4fa551d7 | ths | void OPPROTO op_addl_T0_T1 (void) |
868 | 4fa551d7 | ths | { |
869 | 4fa551d7 | ths | T0 += T1; |
870 | 4fa551d7 | ths | RETURN(); |
871 | 4fa551d7 | ths | } |
872 | 4fa551d7 | ths | |
873 | 4fa551d7 | ths | void OPPROTO op_subl_T0_T1 (void) |
874 | 4fa551d7 | ths | { |
875 | 4fa551d7 | ths | T0 -= T1; |
876 | 4fa551d7 | ths | RETURN(); |
877 | 4fa551d7 | ths | } |
878 | 4fa551d7 | ths | |
879 | 4fa551d7 | ths | void OPPROTO op_absl_T1_T1 (void) |
880 | 4fa551d7 | ths | { |
881 | 4fa551d7 | ths | int32_t st = T1; |
882 | 4fa551d7 | ths | |
883 | 4fa551d7 | ths | T1 = st < 0 ? -st : st;
|
884 | 4fa551d7 | ths | RETURN(); |
885 | 4fa551d7 | ths | } |
886 | 4fa551d7 | ths | |
887 | 4fa551d7 | ths | void OPPROTO op_muls_T0_T1 (void) |
888 | 4fa551d7 | ths | { |
889 | 4fa551d7 | ths | int64_t tmp, t0 ,t1; |
890 | 4fa551d7 | ths | |
891 | 4fa551d7 | ths | /* cast into signed values to make GCC sign extend these babies. */
|
892 | 4fa551d7 | ths | t0 = (int32_t)T0; |
893 | 4fa551d7 | ths | t1 = (int32_t)T1; |
894 | 4fa551d7 | ths | |
895 | 4fa551d7 | ths | tmp = t0 * t1; |
896 | 4fa551d7 | ths | T0 = tmp & 0xffffffff;
|
897 | 4fa551d7 | ths | env->pregs[REG_MOF] = tmp >> 32;
|
898 | 4fa551d7 | ths | RETURN(); |
899 | 4fa551d7 | ths | } |
900 | 4fa551d7 | ths | |
901 | 4fa551d7 | ths | void OPPROTO op_mulu_T0_T1 (void) |
902 | 4fa551d7 | ths | { |
903 | 4fa551d7 | ths | uint64_t tmp, t0 ,t1; |
904 | 4fa551d7 | ths | t0 = T0; |
905 | 4fa551d7 | ths | t1 = T1; |
906 | 4fa551d7 | ths | |
907 | 4fa551d7 | ths | tmp = t0 * t1; |
908 | 4fa551d7 | ths | T0 = tmp & 0xffffffff;
|
909 | 4fa551d7 | ths | env->pregs[REG_MOF] = tmp >> 32;
|
910 | 4fa551d7 | ths | RETURN(); |
911 | 4fa551d7 | ths | } |
912 | 4fa551d7 | ths | |
913 | 4fa551d7 | ths | void OPPROTO op_dstep_T0_T1 (void) |
914 | 4fa551d7 | ths | { |
915 | 4fa551d7 | ths | T0 <<= 1;
|
916 | 4fa551d7 | ths | if (T0 >= T1)
|
917 | 4fa551d7 | ths | T0 -= T1; |
918 | 4fa551d7 | ths | RETURN(); |
919 | 4fa551d7 | ths | } |
920 | 4fa551d7 | ths | |
921 | 4fa551d7 | ths | void OPPROTO op_orl_T0_T1 (void) |
922 | 4fa551d7 | ths | { |
923 | 4fa551d7 | ths | T0 |= T1; |
924 | 4fa551d7 | ths | RETURN(); |
925 | 4fa551d7 | ths | } |
926 | 4fa551d7 | ths | |
927 | 4fa551d7 | ths | void OPPROTO op_andl_T0_T1 (void) |
928 | 4fa551d7 | ths | { |
929 | 4fa551d7 | ths | T0 &= T1; |
930 | 4fa551d7 | ths | RETURN(); |
931 | 4fa551d7 | ths | } |
932 | 4fa551d7 | ths | |
933 | 4fa551d7 | ths | void OPPROTO op_xorl_T0_T1 (void) |
934 | 4fa551d7 | ths | { |
935 | 4fa551d7 | ths | T0 ^= T1; |
936 | 4fa551d7 | ths | RETURN(); |
937 | 4fa551d7 | ths | } |
938 | 4fa551d7 | ths | |
939 | 4fa551d7 | ths | void OPPROTO op_lsll_T0_T1 (void) |
940 | 4fa551d7 | ths | { |
941 | 4fa551d7 | ths | int s = T1;
|
942 | 4fa551d7 | ths | if (s > 31) |
943 | 4fa551d7 | ths | T0 = 0;
|
944 | 4fa551d7 | ths | else
|
945 | 4fa551d7 | ths | T0 <<= s; |
946 | 4fa551d7 | ths | RETURN(); |
947 | 4fa551d7 | ths | } |
948 | 4fa551d7 | ths | |
949 | 4fa551d7 | ths | void OPPROTO op_lsll_T0_im (void) |
950 | 4fa551d7 | ths | { |
951 | 4fa551d7 | ths | T0 <<= PARAM1; |
952 | 4fa551d7 | ths | RETURN(); |
953 | 4fa551d7 | ths | } |
954 | 4fa551d7 | ths | |
955 | 4fa551d7 | ths | void OPPROTO op_lsrl_T0_T1 (void) |
956 | 4fa551d7 | ths | { |
957 | 4fa551d7 | ths | int s = T1;
|
958 | 4fa551d7 | ths | if (s > 31) |
959 | 4fa551d7 | ths | T0 = 0;
|
960 | 4fa551d7 | ths | else
|
961 | 4fa551d7 | ths | T0 >>= s; |
962 | 4fa551d7 | ths | RETURN(); |
963 | 4fa551d7 | ths | } |
964 | 4fa551d7 | ths | |
965 | 4fa551d7 | ths | /* Rely on GCC emitting an arithmetic shift for signed right shifts. */
|
966 | 4fa551d7 | ths | void OPPROTO op_asrl_T0_T1 (void) |
967 | 4fa551d7 | ths | { |
968 | 4fa551d7 | ths | int s = T1;
|
969 | 4fa551d7 | ths | if (s > 31) |
970 | 4fa551d7 | ths | T0 = T0 & 0x80000000 ? -1 : 0; |
971 | 4fa551d7 | ths | else
|
972 | 4fa551d7 | ths | T0 = (int32_t)T0 >> s; |
973 | 4fa551d7 | ths | RETURN(); |
974 | 4fa551d7 | ths | } |
975 | 4fa551d7 | ths | |
976 | 4fa551d7 | ths | void OPPROTO op_btst_T0_T1 (void) |
977 | 4fa551d7 | ths | { |
978 | 4fa551d7 | ths | /* FIXME: clean this up. */
|
979 | 4fa551d7 | ths | |
980 | 4fa551d7 | ths | /* des ref:
|
981 | 4fa551d7 | ths | The N flag is set according to the selected bit in the dest reg.
|
982 | 4fa551d7 | ths | The Z flag is set if the selected bit and all bits to the right are
|
983 | 4fa551d7 | ths | zero.
|
984 | 4fa551d7 | ths | The destination reg is not affected.*/
|
985 | 4fa551d7 | ths | unsigned int fz, sbit, bset, mask, masked_t0; |
986 | 4fa551d7 | ths | |
987 | 4fa551d7 | ths | sbit = T1 & 31;
|
988 | 4fa551d7 | ths | bset = !!(T0 & (1 << sbit));
|
989 | 4fa551d7 | ths | mask = sbit == 31 ? -1 : (1 << (sbit + 1)) - 1; |
990 | 4fa551d7 | ths | masked_t0 = T0 & mask; |
991 | 4fa551d7 | ths | fz = !(masked_t0 | bset); |
992 | 4fa551d7 | ths | /* Set the N and Z flags accordingly. */
|
993 | 4fa551d7 | ths | T0 = (bset << 3) | (fz << 2); |
994 | 4fa551d7 | ths | RETURN(); |
995 | 4fa551d7 | ths | } |
996 | 4fa551d7 | ths | |
997 | 4fa551d7 | ths | void OPPROTO op_bound_T0_T1 (void) |
998 | 4fa551d7 | ths | { |
999 | 4fa551d7 | ths | if (T0 > T1)
|
1000 | 4fa551d7 | ths | T0 = T1; |
1001 | 4fa551d7 | ths | RETURN(); |
1002 | 4fa551d7 | ths | } |
1003 | 4fa551d7 | ths | |
1004 | 4fa551d7 | ths | void OPPROTO op_lz_T0_T1 (void) |
1005 | 4fa551d7 | ths | { |
1006 | 4fa551d7 | ths | if (T1 == 0) |
1007 | 4fa551d7 | ths | T0 = 32;
|
1008 | 4fa551d7 | ths | else
|
1009 | 4fa551d7 | ths | T0 = __builtin_clz(T1); |
1010 | 4fa551d7 | ths | RETURN(); |
1011 | 4fa551d7 | ths | } |
1012 | 4fa551d7 | ths | |
1013 | 4fa551d7 | ths | void OPPROTO op_negl_T0_T1 (void) |
1014 | 4fa551d7 | ths | { |
1015 | 4fa551d7 | ths | T0 = -T1; |
1016 | 4fa551d7 | ths | RETURN(); |
1017 | 4fa551d7 | ths | } |
1018 | 4fa551d7 | ths | |
1019 | 4fa551d7 | ths | void OPPROTO op_negl_T1_T1 (void) |
1020 | 4fa551d7 | ths | { |
1021 | 4fa551d7 | ths | T1 = -T1; |
1022 | 4fa551d7 | ths | RETURN(); |
1023 | 4fa551d7 | ths | } |
1024 | 4fa551d7 | ths | |
1025 | 4fa551d7 | ths | void OPPROTO op_not_T0_T0 (void) |
1026 | 4fa551d7 | ths | { |
1027 | 4fa551d7 | ths | T0 = ~(T0); |
1028 | 4fa551d7 | ths | RETURN(); |
1029 | 4fa551d7 | ths | } |
1030 | 4fa551d7 | ths | void OPPROTO op_not_T1_T1 (void) |
1031 | 4fa551d7 | ths | { |
1032 | 4fa551d7 | ths | T1 = ~(T1); |
1033 | 4fa551d7 | ths | RETURN(); |
1034 | 4fa551d7 | ths | } |
1035 | 4fa551d7 | ths | |
1036 | 4fa551d7 | ths | void OPPROTO op_swapw_T0_T0 (void) |
1037 | 4fa551d7 | ths | { |
1038 | 4fa551d7 | ths | T0 = (T0 << 16) | ((T0 >> 16)); |
1039 | 4fa551d7 | ths | RETURN(); |
1040 | 4fa551d7 | ths | } |
1041 | 4fa551d7 | ths | |
1042 | 4fa551d7 | ths | void OPPROTO op_swapb_T0_T0 (void) |
1043 | 4fa551d7 | ths | { |
1044 | 4fa551d7 | ths | T0 = ((T0 << 8) & 0xff00ff00) | ((T0 >> 8) & 0x00ff00ff); |
1045 | 4fa551d7 | ths | RETURN(); |
1046 | 4fa551d7 | ths | } |
1047 | 4fa551d7 | ths | |
1048 | 4fa551d7 | ths | void OPPROTO op_swapr_T0_T0 (void) |
1049 | 4fa551d7 | ths | { |
1050 | 4fa551d7 | ths | T0 = (((T0 << 7) & 0x80808080) | |
1051 | 4fa551d7 | ths | ((T0 << 5) & 0x40404040) | |
1052 | 4fa551d7 | ths | ((T0 << 3) & 0x20202020) | |
1053 | 4fa551d7 | ths | ((T0 << 1) & 0x10101010) | |
1054 | 4fa551d7 | ths | ((T0 >> 1) & 0x08080808) | |
1055 | 4fa551d7 | ths | ((T0 >> 3) & 0x04040404) | |
1056 | 4fa551d7 | ths | ((T0 >> 5) & 0x02020202) | |
1057 | 4fa551d7 | ths | ((T0 >> 7) & 0x01010101)); |
1058 | 4fa551d7 | ths | RETURN(); |
1059 | 4fa551d7 | ths | } |
1060 | 4fa551d7 | ths | |
1061 | 4fa551d7 | ths | void OPPROTO op_tst_cc_eq (void) { |
1062 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1063 | 4fa551d7 | ths | int z_set;
|
1064 | 4fa551d7 | ths | |
1065 | 4fa551d7 | ths | z_set = !!(flags & Z_FLAG); |
1066 | 4fa551d7 | ths | T0 = z_set; |
1067 | 4fa551d7 | ths | RETURN(); |
1068 | 4fa551d7 | ths | } |
1069 | 4fa551d7 | ths | |
1070 | 4fa551d7 | ths | void OPPROTO op_tst_cc_eq_fast (void) { |
1071 | 4fa551d7 | ths | T0 = !(env->cc_result); |
1072 | 4fa551d7 | ths | RETURN(); |
1073 | 4fa551d7 | ths | } |
1074 | 4fa551d7 | ths | |
1075 | 4fa551d7 | ths | void OPPROTO op_tst_cc_ne (void) { |
1076 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1077 | 4fa551d7 | ths | int z_set;
|
1078 | 4fa551d7 | ths | |
1079 | 4fa551d7 | ths | z_set = !!(flags & Z_FLAG); |
1080 | 4fa551d7 | ths | T0 = !z_set; |
1081 | 4fa551d7 | ths | RETURN(); |
1082 | 4fa551d7 | ths | } |
1083 | 4fa551d7 | ths | void OPPROTO op_tst_cc_ne_fast (void) { |
1084 | 4fa551d7 | ths | T0 = !!(env->cc_result); |
1085 | 4fa551d7 | ths | RETURN(); |
1086 | 4fa551d7 | ths | } |
1087 | 4fa551d7 | ths | |
1088 | 4fa551d7 | ths | void OPPROTO op_tst_cc_cc (void) { |
1089 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1090 | 4fa551d7 | ths | int c_set;
|
1091 | 4fa551d7 | ths | |
1092 | 4fa551d7 | ths | c_set = !!(flags & C_FLAG); |
1093 | 4fa551d7 | ths | T0 = !c_set; |
1094 | 4fa551d7 | ths | RETURN(); |
1095 | 4fa551d7 | ths | } |
1096 | 4fa551d7 | ths | void OPPROTO op_tst_cc_cs (void) { |
1097 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1098 | 4fa551d7 | ths | int c_set;
|
1099 | 4fa551d7 | ths | |
1100 | 4fa551d7 | ths | c_set = !!(flags & C_FLAG); |
1101 | 4fa551d7 | ths | T0 = c_set; |
1102 | 4fa551d7 | ths | RETURN(); |
1103 | 4fa551d7 | ths | } |
1104 | 4fa551d7 | ths | |
1105 | 4fa551d7 | ths | void OPPROTO op_tst_cc_vc (void) { |
1106 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1107 | 4fa551d7 | ths | int v_set;
|
1108 | 4fa551d7 | ths | |
1109 | 4fa551d7 | ths | v_set = !!(flags & V_FLAG); |
1110 | 4fa551d7 | ths | T0 = !v_set; |
1111 | 4fa551d7 | ths | RETURN(); |
1112 | 4fa551d7 | ths | } |
1113 | 4fa551d7 | ths | void OPPROTO op_tst_cc_vs (void) { |
1114 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1115 | 4fa551d7 | ths | int v_set;
|
1116 | 4fa551d7 | ths | |
1117 | 4fa551d7 | ths | v_set = !!(flags & V_FLAG); |
1118 | 4fa551d7 | ths | T0 = v_set; |
1119 | 4fa551d7 | ths | RETURN(); |
1120 | 4fa551d7 | ths | } |
1121 | 4fa551d7 | ths | void OPPROTO op_tst_cc_pl (void) { |
1122 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1123 | 4fa551d7 | ths | int n_set;
|
1124 | 4fa551d7 | ths | |
1125 | 4fa551d7 | ths | n_set = !!(flags & N_FLAG); |
1126 | 4fa551d7 | ths | T0 = !n_set; |
1127 | 4fa551d7 | ths | RETURN(); |
1128 | 4fa551d7 | ths | } |
1129 | 4fa551d7 | ths | void OPPROTO op_tst_cc_pl_fast (void) { |
1130 | 4fa551d7 | ths | T0 = ((int32_t)env->cc_result) >= 0;
|
1131 | 4fa551d7 | ths | RETURN(); |
1132 | 4fa551d7 | ths | } |
1133 | 4fa551d7 | ths | |
1134 | 4fa551d7 | ths | void OPPROTO op_tst_cc_mi (void) { |
1135 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1136 | 4fa551d7 | ths | int n_set;
|
1137 | 4fa551d7 | ths | |
1138 | 4fa551d7 | ths | n_set = !!(flags & N_FLAG); |
1139 | 4fa551d7 | ths | T0 = n_set; |
1140 | 4fa551d7 | ths | RETURN(); |
1141 | 4fa551d7 | ths | } |
1142 | 4fa551d7 | ths | void OPPROTO op_tst_cc_mi_fast (void) { |
1143 | 4fa551d7 | ths | T0 = ((int32_t)env->cc_result) < 0;
|
1144 | 4fa551d7 | ths | RETURN(); |
1145 | 4fa551d7 | ths | } |
1146 | 4fa551d7 | ths | |
1147 | 4fa551d7 | ths | void OPPROTO op_tst_cc_ls (void) { |
1148 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1149 | 4fa551d7 | ths | int c_set;
|
1150 | 4fa551d7 | ths | int z_set;
|
1151 | 4fa551d7 | ths | |
1152 | 4fa551d7 | ths | c_set = !!(flags & C_FLAG); |
1153 | 4fa551d7 | ths | z_set = !!(flags & Z_FLAG); |
1154 | 4fa551d7 | ths | T0 = c_set || z_set; |
1155 | 4fa551d7 | ths | RETURN(); |
1156 | 4fa551d7 | ths | } |
1157 | 4fa551d7 | ths | void OPPROTO op_tst_cc_hi (void) { |
1158 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1159 | 4fa551d7 | ths | int z_set;
|
1160 | 4fa551d7 | ths | int c_set;
|
1161 | 4fa551d7 | ths | |
1162 | 4fa551d7 | ths | z_set = !!(flags & Z_FLAG); |
1163 | 4fa551d7 | ths | c_set = !!(flags & C_FLAG); |
1164 | 4fa551d7 | ths | T0 = !c_set && !z_set; |
1165 | 4fa551d7 | ths | RETURN(); |
1166 | 4fa551d7 | ths | |
1167 | 4fa551d7 | ths | } |
1168 | 4fa551d7 | ths | |
1169 | 4fa551d7 | ths | void OPPROTO op_tst_cc_ge (void) { |
1170 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1171 | 4fa551d7 | ths | int n_set;
|
1172 | 4fa551d7 | ths | int v_set;
|
1173 | 4fa551d7 | ths | |
1174 | 4fa551d7 | ths | n_set = !!(flags & N_FLAG); |
1175 | 4fa551d7 | ths | v_set = !!(flags & V_FLAG); |
1176 | 4fa551d7 | ths | T0 = (n_set && v_set) || (!n_set && !v_set); |
1177 | 4fa551d7 | ths | RETURN(); |
1178 | 4fa551d7 | ths | } |
1179 | 4fa551d7 | ths | |
1180 | 4fa551d7 | ths | void OPPROTO op_tst_cc_ge_fast (void) { |
1181 | 4fa551d7 | ths | T0 = ((int32_t)env->cc_src < (int32_t)env->cc_dest); |
1182 | 4fa551d7 | ths | RETURN(); |
1183 | 4fa551d7 | ths | } |
1184 | 4fa551d7 | ths | |
1185 | 4fa551d7 | ths | void OPPROTO op_tst_cc_lt (void) { |
1186 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1187 | 4fa551d7 | ths | int n_set;
|
1188 | 4fa551d7 | ths | int v_set;
|
1189 | 4fa551d7 | ths | |
1190 | 4fa551d7 | ths | n_set = !!(flags & N_FLAG); |
1191 | 4fa551d7 | ths | v_set = !!(flags & V_FLAG); |
1192 | 4fa551d7 | ths | T0 = (n_set && !v_set) || (!n_set && v_set); |
1193 | 4fa551d7 | ths | RETURN(); |
1194 | 4fa551d7 | ths | } |
1195 | 4fa551d7 | ths | |
1196 | 4fa551d7 | ths | void OPPROTO op_tst_cc_gt (void) { |
1197 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1198 | 4fa551d7 | ths | int n_set;
|
1199 | 4fa551d7 | ths | int v_set;
|
1200 | 4fa551d7 | ths | int z_set;
|
1201 | 4fa551d7 | ths | |
1202 | 4fa551d7 | ths | n_set = !!(flags & N_FLAG); |
1203 | 4fa551d7 | ths | v_set = !!(flags & V_FLAG); |
1204 | 4fa551d7 | ths | z_set = !!(flags & Z_FLAG); |
1205 | 4fa551d7 | ths | T0 = (n_set && v_set && !z_set) |
1206 | 4fa551d7 | ths | || (!n_set && !v_set && !z_set); |
1207 | 4fa551d7 | ths | RETURN(); |
1208 | 4fa551d7 | ths | } |
1209 | 4fa551d7 | ths | |
1210 | 4fa551d7 | ths | void OPPROTO op_tst_cc_le (void) { |
1211 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1212 | 4fa551d7 | ths | int n_set;
|
1213 | 4fa551d7 | ths | int v_set;
|
1214 | 4fa551d7 | ths | int z_set;
|
1215 | 4fa551d7 | ths | |
1216 | 4fa551d7 | ths | n_set = !!(flags & N_FLAG); |
1217 | 4fa551d7 | ths | v_set = !!(flags & V_FLAG); |
1218 | 4fa551d7 | ths | z_set = !!(flags & Z_FLAG); |
1219 | 4fa551d7 | ths | T0 = z_set || (n_set && !v_set) || (!n_set && v_set); |
1220 | 4fa551d7 | ths | RETURN(); |
1221 | 4fa551d7 | ths | } |
1222 | 4fa551d7 | ths | |
1223 | 4fa551d7 | ths | void OPPROTO op_tst_cc_p (void) { |
1224 | 4fa551d7 | ths | uint32_t flags = env->pregs[SR_CCS]; |
1225 | 4fa551d7 | ths | int p_set;
|
1226 | 4fa551d7 | ths | |
1227 | 4fa551d7 | ths | p_set = !!(flags & P_FLAG); |
1228 | 4fa551d7 | ths | T0 = p_set; |
1229 | 4fa551d7 | ths | RETURN(); |
1230 | 4fa551d7 | ths | } |
1231 | 4fa551d7 | ths | |
1232 | 4fa551d7 | ths | /* Evaluate the if the branch should be taken or not. Needs to be done in
|
1233 | 4fa551d7 | ths | the original sequence. The acutal branch is rescheduled to right after the
|
1234 | 4fa551d7 | ths | delay-slot. */
|
1235 | 4fa551d7 | ths | void OPPROTO op_evaluate_bcc (void) |
1236 | 4fa551d7 | ths | { |
1237 | 4fa551d7 | ths | env->btaken = T0; |
1238 | 4fa551d7 | ths | RETURN(); |
1239 | 4fa551d7 | ths | } |
1240 | 4fa551d7 | ths | |
1241 | 4fa551d7 | ths | /* this one is used on every alu op, optimize it!. */
|
1242 | 4fa551d7 | ths | void OPPROTO op_goto_if_not_x (void) |
1243 | 4fa551d7 | ths | { |
1244 | 4fa551d7 | ths | if (env->pregs[SR_CCS] & X_FLAG)
|
1245 | 4fa551d7 | ths | GOTO_LABEL_PARAM(1);
|
1246 | 4fa551d7 | ths | RETURN(); |
1247 | 4fa551d7 | ths | } |
1248 | 4fa551d7 | ths | |
1249 | 4fa551d7 | ths | void OPPROTO op_cc_jmp (void) |
1250 | 4fa551d7 | ths | { |
1251 | 4fa551d7 | ths | if (env->btaken)
|
1252 | 4fa551d7 | ths | env->pc = PARAM1; |
1253 | 4fa551d7 | ths | else
|
1254 | 4fa551d7 | ths | env->pc = PARAM2; |
1255 | 4fa551d7 | ths | RETURN(); |
1256 | 4fa551d7 | ths | } |
1257 | 4fa551d7 | ths | |
1258 | 4fa551d7 | ths | void OPPROTO op_cc_ngoto (void) |
1259 | 4fa551d7 | ths | { |
1260 | 4fa551d7 | ths | if (!env->btaken)
|
1261 | 4fa551d7 | ths | GOTO_LABEL_PARAM(1);
|
1262 | 4fa551d7 | ths | RETURN(); |
1263 | 4fa551d7 | ths | } |
1264 | 4fa551d7 | ths | |
1265 | 4fa551d7 | ths | void OPPROTO op_movl_btarget_T0 (void) |
1266 | 4fa551d7 | ths | { |
1267 | 4fa551d7 | ths | env->btarget = T0; |
1268 | 4fa551d7 | ths | RETURN(); |
1269 | 4fa551d7 | ths | } |
1270 | 4fa551d7 | ths | |
1271 | 4fa551d7 | ths | void OPPROTO op_jmp (void) |
1272 | 4fa551d7 | ths | { |
1273 | 4fa551d7 | ths | env->pc = env->btarget; |
1274 | 4fa551d7 | ths | RETURN(); |
1275 | 4fa551d7 | ths | } |
1276 | 4fa551d7 | ths | |
1277 | 4fa551d7 | ths | /* Load and store */
|
1278 | 4fa551d7 | ths | #define MEMSUFFIX _raw
|
1279 | 4fa551d7 | ths | #include "op_mem.c" |
1280 | 4fa551d7 | ths | #undef MEMSUFFIX
|
1281 | 4fa551d7 | ths | #if !defined(CONFIG_USER_ONLY)
|
1282 | 4fa551d7 | ths | #define MEMSUFFIX _user
|
1283 | 4fa551d7 | ths | #include "op_mem.c" |
1284 | 4fa551d7 | ths | #undef MEMSUFFIX
|
1285 | 4fa551d7 | ths | |
1286 | 4fa551d7 | ths | #define MEMSUFFIX _kernel
|
1287 | 4fa551d7 | ths | #include "op_mem.c" |
1288 | 4fa551d7 | ths | #undef MEMSUFFIX
|
1289 | 4fa551d7 | ths | #endif |