target-m68k: initialize FPU registers
authorLaurent Vivier <laurent@vivier.eu>
Tue, 20 Jun 2017 20:51:17 +0000 (22:51 +0200)
committerLaurent Vivier <laurent@vivier.eu>
Wed, 21 Jun 2017 20:09:45 +0000 (22:09 +0200)
on reset, set FP registers to NaN and control registers to 0

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-Id: <20170620205121.26515-3-laurent@vivier.eu>

target/m68k/cpu.c

index f06892271f9c5d76e62d999b3bfb37cf639f0434..f2e031fbe0103f0126a6bee09a4f0a7d189aeba3 100644 (file)
@@ -49,6 +49,8 @@ static void m68k_cpu_reset(CPUState *s)
     M68kCPU *cpu = M68K_CPU(s);
     M68kCPUClass *mcc = M68K_CPU_GET_CLASS(cpu);
     CPUM68KState *env = &cpu->env;
+    float64 nan = float64_default_nan(NULL);
+    int i;
 
     mcc->parent_reset(s);
 
@@ -57,7 +59,12 @@ static void m68k_cpu_reset(CPUState *s)
     env->sr = 0x2700;
 #endif
     m68k_switch_sp(env);
-    /* ??? FP regs should be initialized to NaN.  */
+    for (i = 0; i < 8; i++) {
+        env->fregs[i] = nan;
+    }
+    env->fpcr = 0;
+    env->fpsr = 0;
+
     cpu_m68k_set_ccr(env, 0);
     /* TODO: We should set PC from the interrupt vector.  */
     env->pc = 0;