Patchwork [080/111] m68k: add fcos instruction

login
register
mail settings
Submitter Bryce Lanham
Date Aug. 17, 2011, 8:47 p.m.
Message ID <1313614076-28878-81-git-send-email-blanham@gmail.com>
Download mbox | patch
Permalink /patch/110461/
State New
Headers show

Comments

Bryce Lanham - Aug. 17, 2011, 8:47 p.m.
From: Laurent Vivier <laurent@vivier.eu>

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

Patch

diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index 699f28a..79e6a28 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -1435,6 +1435,21 @@  void HELPER(acos_FP0)(CPUState *env)
     floatx80_to_FP0(env, res);
 }
 
+void HELPER(cos_FP0)(CPUState *env)
+{
+    floatx80 res;
+    long double val;
+
+    res = FP0_to_floatx80(env);
+    val = LDOUBLE(res);
+
+    DBG_FPUH("cos_FP0 %Lg", val);
+    val = cosl(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 c704953..e6465cd 100644
--- a/target-m68k/helpers.h
+++ b/target-m68k/helpers.h
@@ -74,6 +74,7 @@  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(cos_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 0fafa3b..96586ae 100644
--- a/target-m68k/translate.c
+++ b/target-m68k/translate.c
@@ -3688,6 +3688,9 @@  DISAS_INSN(fpu)
     case 0x1c:                       /* facos */
         gen_helper_acos_FP0(cpu_env);
         break;
+    case 0x1d:                       /* fcos */
+        gen_helper_cos_FP0(cpu_env);
+        break;
     case 0x1e:                       /* fgetexp */
         gen_helper_getexp_FP0(cpu_env);
         break;