Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNDAn-00054M-2n for qemu-devel@nongnu.org; Sun, 27 Jul 2008 16:48:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNDAl-00053A-8c for qemu-devel@nongnu.org; Sun, 27 Jul 2008 16:48:56 -0400 Received: from [199.232.76.173] (port=44217 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNDAk-00052y-V3 for qemu-devel@nongnu.org; Sun, 27 Jul 2008 16:48:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:32904) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KNDAk-0007rx-Ll for qemu-devel@nongnu.org; Sun, 27 Jul 2008 16:48:55 -0400 Received: from Relay2.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id C4BBE45F0B for ; Sun, 27 Jul 2008 20:24:30 +0200 (CEST) From: Andreas Schwab Date: Sun, 27 Jul 2008 20:24:30 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [M68K] Fix flags after shift by zero Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 &=3D 63; if (shift =3D=3D 0) { result =3D val; - cf =3D env->cc_src & CCF_C; + cf =3D 0; } else if (shift < 32) { result =3D val << shift; cf =3D (val >> (32 - shift)) & 1; @@ -449,7 +449,8 @@ uint32_t HELPER(shl_cc)(CPUState *env, u cf =3D 0; } env->cc_src =3D cf; - env->cc_x =3D (cf !=3D 0); + if (shift !=3D 0) + env->cc_x =3D cf; env->cc_dest =3D result; return result; } @@ -462,7 +463,7 @@ uint32_t HELPER(shr_cc)(CPUState *env, u shift &=3D 63; if (shift =3D=3D 0) { result =3D val; - cf =3D env->cc_src & CCF_C; + cf =3D 0; } else if (shift < 32) { result =3D val >> shift; cf =3D (val >> (shift - 1)) & 1; @@ -474,7 +475,8 @@ uint32_t HELPER(shr_cc)(CPUState *env, u cf =3D 0; } env->cc_src =3D cf; - env->cc_x =3D (cf !=3D 0); + if (shift !=3D 0) + env->cc_x =3D cf; env->cc_dest =3D result; return result; } @@ -487,7 +489,7 @@ uint32_t HELPER(sar_cc)(CPUState *env, u shift &=3D 63; if (shift =3D=3D 0) { result =3D val; - cf =3D (env->cc_src & CCF_C) !=3D 0; + cf =3D 0; } else if (shift < 32) { result =3D (int32_t)val >> shift; cf =3D (val >> (shift - 1)) & 1; @@ -496,7 +498,8 @@ uint32_t HELPER(sar_cc)(CPUState *env, u cf =3D val >> 31; } env->cc_src =3D cf; - env->cc_x =3D cf; + if (shift !=3D 0) + env->cc_x =3D cf; env->cc_dest =3D result; return result; } Index: target-m68k/translate.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- target-m68k/translate.c (revision 4923) +++ target-m68k/translate.c (working copy) @@ -1902,7 +1902,6 @@ DISAS_INSN(shift_im) if (tmp =3D=3D 0) tmp =3D 8; shift =3D 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) =20 reg =3D DREG(insn, 0); shift =3D 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 { --=20 Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra=DFe 5, 90409 N=FCrnberg, Germany PGP key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED= 5 "And now for something completely different."