From: Laurent Vivier <laur...@vivier.eu>

Signed-off-by: Laurent Vivier <laur...@vivier.eu>
---
 target-m68k/helper.c    |   29 ++++++++++++++++++++++++-----
 target-m68k/helpers.h   |    1 +
 target-m68k/translate.c |    3 +++
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index cccae97..bba4ae3 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -28,10 +28,15 @@
 #include "gdbstub.h"
 
 #include "helpers.h"
+#include <math.h>
 
 #if 0
 #define DBG_FPUH(...) do { fprintf(stderr, "0x%08x: ", env->pc); 
fprintf(stderr, __VA_ARGS__); } while(0)
 #define DBG_FPU(...) do { fprintf(stderr, __VA_ARGS__); } while(0)
+#else
+#define DBG_FPUH(...)
+#define DBG_FPU(...)
+#endif
 static inline float FLOAT(float32 x)
 {
     return *(float *)&x;
@@ -44,11 +49,10 @@ static inline long double LDOUBLE(floatx80 x)
 {
     return *(long double *)&x;
 }
-#else
-#define DBG_FPUH(...)
-#define DBG_FPU(...)
-#define LDOUBLE(x)
-#endif
+static inline floatx80 FLOATx80(long double x)
+{
+    return *(floatx80 *)&x;
+}
 
 #define SIGNBIT (1u << 31)
 
@@ -1386,6 +1390,21 @@ void HELPER(chs_FP0)(CPUState *env)
     floatx80_to_FP0(env, res);
 }
 
+void HELPER(acos_FP0)(CPUState *env)
+{
+    floatx80 res;
+    long double val;
+
+    res = FP0_to_floatx80(env);
+    val = LDOUBLE(res);
+
+    DBG_FPUH("acos_FP0 %Lg", val);
+    val = acosl(val);
+    DBG_FPU(" = %Lg", val);
+    res = FLOATx80(val);
+    floatx80_to_FP0(env, res);
+}
+
 void HELPER(getexp_FP0)(CPUState *env)
 {
     int32_t exp;
diff --git a/target-m68k/helpers.h b/target-m68k/helpers.h
index 184ceef..1a375c0 100644
--- a/target-m68k/helpers.h
+++ b/target-m68k/helpers.h
@@ -71,6 +71,7 @@ DEF_HELPER_1(ln_FP0, void, env)
 DEF_HELPER_1(log10_FP0, void, env)
 DEF_HELPER_1(abs_FP0, void, env)
 DEF_HELPER_1(chs_FP0, void, env)
+DEF_HELPER_1(acos_FP0, void, env)
 DEF_HELPER_1(getexp_FP0, void, env)
 DEF_HELPER_1(scale_FP0_FP1, void, env)
 DEF_HELPER_1(add_FP0_FP1, void, env)
diff --git a/target-m68k/translate.c b/target-m68k/translate.c
index 4f73bf8..ece5de3 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -3679,6 +3679,9 @@ DISAS_INSN(fpu)
     case 0x1a: case 0x5a: case 0x5e: /* fneg */
         gen_helper_chs_FP0(cpu_env);
         break;
+    case 0x1c:                       /* facos */
+        gen_helper_acos_FP0(cpu_env);
+        break;
     case 0x1e:                       /* fgetexp */
         gen_helper_getexp_FP0(cpu_env);
         break;
-- 
1.7.2.3


Reply via email to