4 * Copyright (c) 2003 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #define REG (env->regs[0])
24 #include "op-arm-template.h"
27 #define REG (env->regs[1])
28 #include "op-arm-template.h"
31 #define REG (env->regs[2])
32 #include "op-arm-template.h"
35 #define REG (env->regs[3])
36 #include "op-arm-template.h"
39 #define REG (env->regs[4])
40 #include "op-arm-template.h"
43 #define REG (env->regs[5])
44 #include "op-arm-template.h"
47 #define REG (env->regs[6])
48 #include "op-arm-template.h"
51 #define REG (env->regs[7])
52 #include "op-arm-template.h"
55 #define REG (env->regs[8])
56 #include "op-arm-template.h"
59 #define REG (env->regs[9])
60 #include "op-arm-template.h"
63 #define REG (env->regs[10])
64 #include "op-arm-template.h"
67 #define REG (env->regs[11])
68 #include "op-arm-template.h"
71 #define REG (env->regs[12])
72 #include "op-arm-template.h"
75 #define REG (env->regs[13])
76 #include "op-arm-template.h"
79 #define REG (env->regs[14])
80 #include "op-arm-template.h"
83 #define REG (env->regs[15])
84 #include "op-arm-template.h"
86 void OPPROTO op_movl_T0_0(void)
91 void OPPROTO op_movl_T0_im(void)
96 void OPPROTO op_movl_T1_im(void)
101 void OPPROTO op_movl_T2_im(void)
106 void OPPROTO op_addl_T1_im(void)
111 void OPPROTO op_addl_T1_T2(void)
116 void OPPROTO op_subl_T1_T2(void)
121 void OPPROTO op_addl_T0_T1(void)
126 void OPPROTO op_addl_T0_T1_cc(void)
133 env->VF = (src1 ^ T1 ^ -1) & (src1 ^ T0);
136 void OPPROTO op_adcl_T0_T1(void)
141 void OPPROTO op_adcl_T0_T1_cc(void)
150 env->CF = T0 <= src1;
152 env->VF = (src1 ^ T1 ^ -1) & (src1 ^ T0);
157 #define OPSUB(sub, sbc, res, T0, T1) \
159 void OPPROTO op_ ## sub ## l_T0_T1(void) \
164 void OPPROTO op_ ## sub ## l_T0_T1_cc(void) \
170 env->CF = src1 >= T1; \
171 env->VF = (src1 ^ T1) & (src1 ^ T0); \
175 void OPPROTO op_ ## sbc ## l_T0_T1(void) \
177 res = T0 - T1 + env->CF - 1; \
180 void OPPROTO op_ ## sbc ## l_T0_T1_cc(void) \
186 env->CF = src1 >= T1; \
189 env->CF = src1 > T1; \
191 env->VF = (src1 ^ T1) & (src1 ^ T0); \
197 OPSUB(sub, sbc, T0, T0, T1)
199 OPSUB(rsb, rsc, T0, T1, T0)
201 void OPPROTO op_andl_T0_T1(void)
206 void OPPROTO op_xorl_T0_T1(void)
211 void OPPROTO op_orl_T0_T1(void)
216 void OPPROTO op_bicl_T0_T1(void)
221 void OPPROTO op_notl_T1(void)
226 void OPPROTO op_logic_T0_cc(void)
231 void OPPROTO op_logic_T1_cc(void)
236 #define EIP (env->regs[15])
238 void OPPROTO op_test_eq(void)
241 JUMP_TB(PARAM1, 0, PARAM2);
245 void OPPROTO op_test_ne(void)
248 JUMP_TB(PARAM1, 0, PARAM2);
252 void OPPROTO op_test_cs(void)
255 JUMP_TB(PARAM1, 0, PARAM2);
259 void OPPROTO op_test_cc(void)
262 JUMP_TB(PARAM1, 0, PARAM2);
266 void OPPROTO op_test_mi(void)
268 if ((env->NZF & 0x80000000) != 0)
269 JUMP_TB(PARAM1, 0, PARAM2);
273 void OPPROTO op_test_pl(void)
275 if ((env->NZF & 0x80000000) == 0)
276 JUMP_TB(PARAM1, 0, PARAM2);
280 void OPPROTO op_test_vs(void)
282 if ((env->VF & 0x80000000) != 0)
283 JUMP_TB(PARAM1, 0, PARAM2);
287 void OPPROTO op_test_vc(void)
289 if ((env->VF & 0x80000000) == 0)
290 JUMP_TB(PARAM1, 0, PARAM2);
294 void OPPROTO op_test_hi(void)
296 if (env->CF != 0 && env->NZF != 0)
297 JUMP_TB(PARAM1, 0, PARAM2);
301 void OPPROTO op_test_ls(void)
303 if (env->CF == 0 || env->NZF == 0)
304 JUMP_TB(PARAM1, 0, PARAM2);
308 void OPPROTO op_test_ge(void)
310 if (((env->VF ^ env->NZF) & 0x80000000) == 0)
311 JUMP_TB(PARAM1, 0, PARAM2);
315 void OPPROTO op_test_lt(void)
317 if (((env->VF ^ env->NZF) & 0x80000000) != 0)
318 JUMP_TB(PARAM1, 0, PARAM2);
322 void OPPROTO op_test_gt(void)
324 if (env->NZF != 0 && ((env->VF ^ env->NZF) & 0x80000000) == 0)
325 JUMP_TB(PARAM1, 0, PARAM2);
329 void OPPROTO op_test_le(void)
331 if (env->NZF == 0 || ((env->VF ^ env->NZF) & 0x80000000) != 0)
332 JUMP_TB(PARAM1, 0, PARAM2);
336 void OPPROTO op_jmp(void)
338 JUMP_TB(PARAM1, 1, PARAM2);
341 void OPPROTO op_movl_T0_psr(void)
346 /* NOTE: N = 1 and Z = 1 cannot be stored currently */
347 void OPPROTO op_movl_psr_T0(void)
351 env->CF = (psr >> 29) & 1;
352 env->NZF = (psr & 0xc0000000) ^ 0x40000000;
353 env->VF = (psr << 3) & 0x80000000;
354 /* for user mode we do not update other state info */
357 void OPPROTO op_mul_T0_T1(void)
362 /* 64 bit unsigned mul */
363 void OPPROTO op_mull_T0_T1(void)
371 /* 64 bit signed mul */
372 void OPPROTO op_imull_T0_T1(void)
375 res = (int32_t)T0 * (int32_t)T1;
380 void OPPROTO op_addq_T0_T1(void)
383 res = ((uint64_t)T1 << 32) | T0;
384 res += ((uint64_t)(env->regs[PARAM2]) << 32) | (env->regs[PARAM1]);
389 void OPPROTO op_logicq_cc(void)
391 env->NZF = (T1 & 0x80000000) | ((T0 | T1) != 0);
396 void OPPROTO op_ldub_T0_T1(void)
398 T0 = ldub((void *)T1);
401 void OPPROTO op_ldsb_T0_T1(void)
403 T0 = ldsb((void *)T1);
406 void OPPROTO op_lduw_T0_T1(void)
408 T0 = lduw((void *)T1);
411 void OPPROTO op_ldsw_T0_T1(void)
413 T0 = ldsw((void *)T1);
416 void OPPROTO op_ldl_T0_T1(void)
418 T0 = ldl((void *)T1);
421 void OPPROTO op_stb_T0_T1(void)
426 void OPPROTO op_stw_T0_T1(void)
431 void OPPROTO op_stl_T0_T1(void)
436 void OPPROTO op_swpb_T0_T1(void)
441 tmp = ldub((void *)T1);
447 void OPPROTO op_swpl_T0_T1(void)
452 tmp = ldl((void *)T1);
461 void OPPROTO op_shll_T1_im(void)
466 void OPPROTO op_shrl_T1_im(void)
468 T1 = (uint32_t)T1 >> PARAM1;
471 void OPPROTO op_sarl_T1_im(void)
473 T1 = (int32_t)T1 >> PARAM1;
476 void OPPROTO op_rorl_T1_im(void)
480 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
483 /* T1 based, set C flag */
484 void OPPROTO op_shll_T1_im_cc(void)
486 env->CF = (T1 >> (32 - PARAM1)) & 1;
490 void OPPROTO op_shrl_T1_im_cc(void)
492 env->CF = (T1 >> (PARAM1 - 1)) & 1;
493 T1 = (uint32_t)T1 >> PARAM1;
496 void OPPROTO op_sarl_T1_im_cc(void)
498 env->CF = (T1 >> (PARAM1 - 1)) & 1;
499 T1 = (int32_t)T1 >> PARAM1;
502 void OPPROTO op_rorl_T1_im_cc(void)
506 env->CF = (T1 >> (shift - 1)) & 1;
507 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
511 void OPPROTO op_shll_T2_im(void)
516 void OPPROTO op_shrl_T2_im(void)
518 T2 = (uint32_t)T2 >> PARAM1;
521 void OPPROTO op_sarl_T2_im(void)
523 T2 = (int32_t)T2 >> PARAM1;
526 void OPPROTO op_rorl_T2_im(void)
530 T2 = ((uint32_t)T2 >> shift) | (T2 << (32 - shift));
533 /* T1 based, use T0 as shift count */
535 void OPPROTO op_shll_T1_T0(void)
546 void OPPROTO op_shrl_T1_T0(void)
553 T1 = (uint32_t)T1 >> shift;
557 void OPPROTO op_sarl_T1_T0(void)
563 T1 = (int32_t)T1 >> shift;
566 void OPPROTO op_rorl_T1_T0(void)
571 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
576 /* T1 based, use T0 as shift count and compute CF */
578 void OPPROTO op_shll_T1_T0_cc(void)
588 } else if (shift != 0) {
589 env->CF = (T1 >> (32 - shift)) & 1;
595 void OPPROTO op_shrl_T1_T0_cc(void)
601 env->CF = (T1 >> 31) & 1;
605 } else if (shift != 0) {
606 env->CF = (T1 >> (shift - 1)) & 1;
607 T1 = (uint32_t)T1 >> shift;
612 void OPPROTO op_sarl_T1_T0_cc(void)
617 env->CF = (T1 >> 31) & 1;
618 T1 = (int32_t)T1 >> 31;
620 env->CF = (T1 >> (shift - 1)) & 1;
621 T1 = (int32_t)T1 >> shift;
626 void OPPROTO op_rorl_T1_T0_cc(void)
630 shift = shift1 & 0x1f;
633 env->CF = (T1 >> 31) & 1;
635 env->CF = (T1 >> (shift - 1)) & 1;
636 T1 = ((uint32_t)T1 >> shift) | (T1 << (32 - shift));
643 void OPPROTO op_swi(void)
645 env->exception_index = EXCP_SWI;
649 void OPPROTO op_undef_insn(void)
651 env->exception_index = EXCP_UDEF;
657 spinlock_t global_cpu_lock = SPIN_LOCK_UNLOCKED;
661 spin_lock(&global_cpu_lock);
664 void cpu_unlock(void)
666 spin_unlock(&global_cpu_lock);