void OPPROTO op_test_eq(void)
{
if (env->NZF == 0)
- JUMP_TB(op_test_eq, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);;
FORCE_RET();
}
void OPPROTO op_test_ne(void)
{
if (env->NZF != 0)
- JUMP_TB(op_test_ne, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);;
FORCE_RET();
}
void OPPROTO op_test_cs(void)
{
if (env->CF != 0)
- JUMP_TB(op_test_cs, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_cc(void)
{
if (env->CF == 0)
- JUMP_TB(op_test_cc, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_mi(void)
{
if ((env->NZF & 0x80000000) != 0)
- JUMP_TB(op_test_mi, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_pl(void)
{
if ((env->NZF & 0x80000000) == 0)
- JUMP_TB(op_test_pl, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_vs(void)
{
if ((env->VF & 0x80000000) != 0)
- JUMP_TB(op_test_vs, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_vc(void)
{
if ((env->VF & 0x80000000) == 0)
- JUMP_TB(op_test_vc, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_hi(void)
{
if (env->CF != 0 && env->NZF != 0)
- JUMP_TB(op_test_hi, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_ls(void)
{
if (env->CF == 0 || env->NZF == 0)
- JUMP_TB(op_test_ls, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_ge(void)
{
if (((env->VF ^ env->NZF) & 0x80000000) == 0)
- JUMP_TB(op_test_ge, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_lt(void)
{
if (((env->VF ^ env->NZF) & 0x80000000) != 0)
- JUMP_TB(op_test_lt, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_gt(void)
{
if (env->NZF != 0 && ((env->VF ^ env->NZF) & 0x80000000) == 0)
- JUMP_TB(op_test_gt, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
void OPPROTO op_test_le(void)
{
if (env->NZF == 0 || ((env->VF ^ env->NZF) & 0x80000000) != 0)
- JUMP_TB(op_test_le, PARAM1, 0, PARAM2);
+ GOTO_LABEL_PARAM(1);
FORCE_RET();
}
-void OPPROTO op_jmp(void)
+void OPPROTO op_jmp0(void)
{
- JUMP_TB(op_jmp, PARAM1, 1, PARAM2);
+ JUMP_TB(op_jmp0, PARAM1, 0, PARAM2);
+}
+
+void OPPROTO op_jmp1(void)
+{
+ JUMP_TB(op_jmp1, PARAM1, 1, PARAM2);
}
void OPPROTO op_exit_tb(void)
FORCE_RET();
}
+void OPPROTO op_double_T1_saturate(void)
+{
+ int32_t val;
+
+ val = T1;
+ if (val >= 0x40000000) {
+ T1 = 0x7fffffff;
+ env->QF = 1;
+ } else if (val <= (int32_t)0xc0000000) {
+ T1 = 0x80000000;
+ env->QF = 1;
+ } else {
+ T1 = val << 1;
+ }
+ FORCE_RET();
+}
+
/* thumb shift by immediate */
void OPPROTO op_shll_T0_im_thumb(void)
{
shift = PARAM1;
if (shift == 0) {
- env->CF = 0;
+ env->CF = ((uint32_t)shift) >> 31;
T0 = 0;
} else {
env->CF = (T0 >> (shift - 1)) & 1;
T0 = T0 >> shift;
}
+ env->NZF = T0;
FORCE_RET();
}
cpu_loop_exit();
}
+void OPPROTO op_debug(void)
+{
+ env->exception_index = EXCP_DEBUG;
+ cpu_loop_exit();
+}
+
/* VFP support. We follow the convention used for VFP instrunctions:
Single precition routines have a "s" suffix, double precision a
"d" suffix. */
#define VFP_OP(name, p) void OPPROTO op_vfp_##name##p(void)
-#define VFP_BINOP(name, op) \
+#define VFP_BINOP(name) \
VFP_OP(name, s) \
{ \
- FT0s = FT0s op FT1s; \
+ FT0s = float32_ ## name (FT0s, FT1s, &env->vfp.fp_status); \
} \
VFP_OP(name, d) \
{ \
- FT0d = FT0d op FT1d; \
+ FT0d = float64_ ## name (FT0d, FT1d, &env->vfp.fp_status); \
}
-VFP_BINOP(add, +)
-VFP_BINOP(sub, -)
-VFP_BINOP(mul, *)
-VFP_BINOP(div, /)
+VFP_BINOP(add)
+VFP_BINOP(sub)
+VFP_BINOP(mul)
+VFP_BINOP(div)
#undef VFP_BINOP
#define VFP_HELPER(name) \
without looking at the rest of the value. */
VFP_OP(neg, s)
{
- FT0s = -FT0s;
+ FT0s = float32_chs(FT0s);
}
VFP_OP(neg, d)
{
- FT0d = -FT0d;
+ FT0d = float64_chs(FT0d);
}
VFP_OP(F1_ld0, s)
{
- FT1s = 0.0f;
+ union {
+ uint32_t i;
+ float32 s;
+ } v;
+ v.i = 0;
+ FT1s = v.s;
}
VFP_OP(F1_ld0, d)
{
- FT1d = 0.0;
+ union {
+ uint64_t i;
+ float64 d;
+ } v;
+ v.i = 0;
+ FT1d = v.d;
}
/* Helper routines to perform bitwise copies between float and int. */
-static inline float vfp_itos(uint32_t i)
+static inline float32 vfp_itos(uint32_t i)
{
union {
uint32_t i;
- float s;
+ float32 s;
} v;
v.i = i;
return v.s;
}
-static inline uint32_t vfp_stoi(float s)
+static inline uint32_t vfp_stoi(float32 s)
{
union {
uint32_t i;
- float s;
+ float32 s;
} v;
v.s = s;
/* Integer to float conversion. */
VFP_OP(uito, s)
{
- FT0s = (float)(uint32_t)vfp_stoi(FT0s);
+ FT0s = uint32_to_float32(vfp_stoi(FT0s), &env->vfp.fp_status);
}
VFP_OP(uito, d)
{
- FT0d = (double)(uint32_t)vfp_stoi(FT0s);
+ FT0d = uint32_to_float64(vfp_stoi(FT0s), &env->vfp.fp_status);
}
VFP_OP(sito, s)
{
- FT0s = (float)(int32_t)vfp_stoi(FT0s);
+ FT0s = int32_to_float32(vfp_stoi(FT0s), &env->vfp.fp_status);
}
VFP_OP(sito, d)
{
- FT0d = (double)(int32_t)vfp_stoi(FT0s);
+ FT0d = int32_to_float64(vfp_stoi(FT0s), &env->vfp.fp_status);
}
/* Float to integer conversion. */
VFP_OP(toui, s)
{
- FT0s = vfp_itos((uint32_t)FT0s);
+ FT0s = vfp_itos(float32_to_uint32(FT0s, &env->vfp.fp_status));
}
VFP_OP(toui, d)
{
- FT0s = vfp_itos((uint32_t)FT0d);
+ FT0s = vfp_itos(float64_to_uint32(FT0d, &env->vfp.fp_status));
}
VFP_OP(tosi, s)
{
- FT0s = vfp_itos((int32_t)FT0s);
+ FT0s = vfp_itos(float32_to_int32(FT0s, &env->vfp.fp_status));
}
VFP_OP(tosi, d)
{
- FT0s = vfp_itos((int32_t)FT0d);
+ FT0s = vfp_itos(float64_to_int32(FT0d, &env->vfp.fp_status));
}
/* TODO: Set rounding mode properly. */
VFP_OP(touiz, s)
{
- FT0s = vfp_itos((uint32_t)FT0s);
+ FT0s = vfp_itos(float32_to_uint32_round_to_zero(FT0s, &env->vfp.fp_status));
}
VFP_OP(touiz, d)
{
- FT0s = vfp_itos((uint32_t)FT0d);
+ FT0s = vfp_itos(float64_to_uint32_round_to_zero(FT0d, &env->vfp.fp_status));
}
VFP_OP(tosiz, s)
{
- FT0s = vfp_itos((int32_t)FT0s);
+ FT0s = vfp_itos(float32_to_int32_round_to_zero(FT0s, &env->vfp.fp_status));
}
VFP_OP(tosiz, d)
{
- FT0s = vfp_itos((int32_t)FT0d);
+ FT0s = vfp_itos(float64_to_int32_round_to_zero(FT0d, &env->vfp.fp_status));
}
/* floating point conversion */
VFP_OP(fcvtd, s)
{
- FT0d = (double)FT0s;
+ FT0d = float32_to_float64(FT0s, &env->vfp.fp_status);
}
VFP_OP(fcvts, d)
{
- FT0s = (float)FT0d;
+ FT0s = float64_to_float32(FT0d, &env->vfp.fp_status);
}
/* Get and Put values from registers. */
VFP_OP(getreg_F0, d)
{
- FT0d = *(double *)((char *) env + PARAM1);
+ FT0d = *(float64 *)((char *) env + PARAM1);
}
VFP_OP(getreg_F0, s)
{
- FT0s = *(float *)((char *) env + PARAM1);
+ FT0s = *(float32 *)((char *) env + PARAM1);
}
VFP_OP(getreg_F1, d)
{
- FT1d = *(double *)((char *) env + PARAM1);
+ FT1d = *(float64 *)((char *) env + PARAM1);
}
VFP_OP(getreg_F1, s)
{
- FT1s = *(float *)((char *) env + PARAM1);
+ FT1s = *(float32 *)((char *) env + PARAM1);
}
VFP_OP(setreg_F0, d)
{
- *(double *)((char *) env + PARAM1) = FT0d;
+ *(float64 *)((char *) env + PARAM1) = FT0d;
}
VFP_OP(setreg_F0, s)
{
- *(float *)((char *) env + PARAM1) = FT0s;
-}
-
-VFP_OP(foobar, d)
-{
- FT0d = env->vfp.regs.s[3];
+ *(float32 *)((char *) env + PARAM1) = FT0s;
}
void OPPROTO op_vfp_movl_T0_fpscr(void)