[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [M68K] Fix flags after shift by zero
From: |
Andreas Schwab |
Subject: |
[Qemu-devel] [M68K] Fix flags after shift by zero |
Date: |
Sun, 27 Jul 2008 20:24:30 +0200 |
User-agent: |
Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux) |
When the shift count is zero in a shift insn the carry flag is supposed
to be cleared and the X flag is unaffected.
Andreas.
Index: target-m68k/helper.c
===================================================================
--- target-m68k/helper.c (revision 4923)
+++ target-m68k/helper.c (working copy)
@@ -437,7 +437,7 @@ uint32_t HELPER(shl_cc)(CPUState *env, u
shift &= 63;
if (shift == 0) {
result = val;
- cf = env->cc_src & CCF_C;
+ cf = 0;
} else if (shift < 32) {
result = val << shift;
cf = (val >> (32 - shift)) & 1;
@@ -449,7 +449,8 @@ uint32_t HELPER(shl_cc)(CPUState *env, u
cf = 0;
}
env->cc_src = cf;
- env->cc_x = (cf != 0);
+ if (shift != 0)
+ env->cc_x = cf;
env->cc_dest = result;
return result;
}
@@ -462,7 +463,7 @@ uint32_t HELPER(shr_cc)(CPUState *env, u
shift &= 63;
if (shift == 0) {
result = val;
- cf = env->cc_src & CCF_C;
+ cf = 0;
} else if (shift < 32) {
result = val >> shift;
cf = (val >> (shift - 1)) & 1;
@@ -474,7 +475,8 @@ uint32_t HELPER(shr_cc)(CPUState *env, u
cf = 0;
}
env->cc_src = cf;
- env->cc_x = (cf != 0);
+ if (shift != 0)
+ env->cc_x = cf;
env->cc_dest = result;
return result;
}
@@ -487,7 +489,7 @@ uint32_t HELPER(sar_cc)(CPUState *env, u
shift &= 63;
if (shift == 0) {
result = val;
- cf = (env->cc_src & CCF_C) != 0;
+ cf = 0;
} else if (shift < 32) {
result = (int32_t)val >> shift;
cf = (val >> (shift - 1)) & 1;
@@ -496,7 +498,8 @@ uint32_t HELPER(sar_cc)(CPUState *env, u
cf = val >> 31;
}
env->cc_src = cf;
- env->cc_x = cf;
+ if (shift != 0)
+ env->cc_x = cf;
env->cc_dest = result;
return result;
}
Index: target-m68k/translate.c
===================================================================
--- target-m68k/translate.c (revision 4923)
+++ target-m68k/translate.c (working copy)
@@ -1902,7 +1902,6 @@ DISAS_INSN(shift_im)
if (tmp == 0)
tmp = 8;
shift = gen_im32(tmp);
- /* No need to flush flags becuse we know we will set C flag. */
if (insn & 0x100) {
gen_helper_shl_cc(reg, cpu_env, reg, shift);
} else {
@@ -1922,8 +1921,6 @@ DISAS_INSN(shift_reg)
reg = DREG(insn, 0);
shift = DREG(insn, 9);
- /* Shift by zero leaves C flag unmodified. */
- gen_flush_flags(s);
if (insn & 0x100) {
gen_helper_shl_cc(reg, cpu_env, reg, shift);
} else {
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [M68K] Fix flags after shift by zero,
Andreas Schwab <=