aboutsummaryrefslogtreecommitdiff
path: root/target-m68k/helper.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@twiddle.net>2015-08-14 07:59:17 -0700
committerLaurent Vivier <laurent@vivier.eu>2016-10-25 20:54:47 +0200
commit99c514485b1d7922c4ca1ed767fd45525de4701f (patch)
tree0c7c7b24892bd625a4a883b859f953957001fd8e /target-m68k/helper.c
parent8e394ccabdb1e439aab092de6b9d2f26432e962f (diff)
target-m68k: Some fixes to SR and flags management
Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'target-m68k/helper.c')
-rw-r--r--target-m68k/helper.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index d9ea830c67..1a54e6678b 100644
--- a/target-m68k/helper.c
+++ b/target-m68k/helper.c
@@ -132,7 +132,7 @@ void m68k_cpu_init_gdb(M68kCPU *cpu)
/* TODO: Add [E]MAC registers. */
}
-uint32_t cpu_m68k_flush_flags(CPUM68KState *env, int op)
+static uint32_t cpu_m68k_flush_flags(CPUM68KState *env, int op)
{
int flags;
uint32_t src;
@@ -272,6 +272,18 @@ set_x:
return flags;
}
+uint32_t cpu_m68k_get_ccr(CPUM68KState *env)
+{
+ return cpu_m68k_flush_flags(env, env->cc_op) | env->cc_x * CCF_X;
+}
+
+void cpu_m68k_set_ccr(CPUM68KState *env, uint32_t val)
+{
+ env->cc_op = CC_OP_FLAGS;
+ env->cc_dest = val & 0xf;
+ env->cc_x = (val & CCF_X ? 1 : 0);
+}
+
void HELPER(movec)(CPUM68KState *env, uint32_t reg, uint32_t val)
{
M68kCPU *cpu = m68k_env_get_cpu(env);
@@ -466,7 +478,8 @@ uint32_t HELPER(addx_cc)(CPUM68KState *env, uint32_t op1, uint32_t op2)
void HELPER(set_sr)(CPUM68KState *env, uint32_t val)
{
- env->sr = val & 0xffff;
+ env->sr = val & 0xffe0;
+ cpu_m68k_set_ccr(env, val);
m68k_switch_sp(env);
}