Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KpAQW-00058d-CC for qemu-devel@nongnu.org; Sun, 12 Oct 2008 19:32:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KpAQU-000588-Sc for qemu-devel@nongnu.org; Sun, 12 Oct 2008 19:32:43 -0400 Received: from [199.232.76.173] (port=40998 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KpAQU-000584-Oh for qemu-devel@nongnu.org; Sun, 12 Oct 2008 19:32:42 -0400 Received: from savannah.gnu.org ([199.232.41.3]:32983 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KpAQU-0004dR-Vv for qemu-devel@nongnu.org; Sun, 12 Oct 2008 19:32:43 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KpAQT-0002JA-TL for qemu-devel@nongnu.org; Sun, 12 Oct 2008 23:32:42 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KpAQT-0002J6-Fx for qemu-devel@nongnu.org; Sun, 12 Oct 2008 23:32:41 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sun, 12 Oct 2008 23:32:41 +0000 Subject: [Qemu-devel] [5471] SH4: Fix swap.b 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 Revision: 5471 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5471 Author: aurel32 Date: 2008-10-12 23:32:40 +0000 (Sun, 12 Oct 2008) Log Message: ----------- SH4: Fix swap.b The SH4 manual documents the swap.b instruction as follows: SWAP.B Rm,Rn Rm ?\226?\134?\146 swap lower 2 bytes ?\226?\134?\146 Rn Current QEMU code, in addition to the above, also clears the high 16 bits. The immediate breakage I saw is that htonl function applied to netmask of 255.255.255.0 gives 0, which breaks all networking. (Vladimir Prus) Modified Paths: -------------- trunk/target-sh4/translate.c Modified: trunk/target-sh4/translate.c =================================================================== --- trunk/target-sh4/translate.c 2008-10-12 21:19:57 UTC (rev 5470) +++ trunk/target-sh4/translate.c 2008-10-12 23:32:40 UTC (rev 5471) @@ -683,7 +683,9 @@ return; case 0x6008: /* swap.b Rm,Rn */ { - TCGv high, low; + TCGv highw, high, low; + highw = tcg_temp_new(TCG_TYPE_I32); + tcg_gen_andi_i32(highw, REG(B7_4), 0xffff0000); high = tcg_temp_new(TCG_TYPE_I32); tcg_gen_ext8u_i32(high, REG(B7_4)); tcg_gen_shli_i32(high, high, 8); @@ -691,6 +693,7 @@ tcg_gen_shri_i32(low, REG(B7_4), 8); tcg_gen_ext8u_i32(low, low); tcg_gen_or_i32(REG(B11_8), high, low); + tcg_gen_or_i32(REG(B11_8), REG(B11_8), highw); tcg_temp_free(low); tcg_temp_free(high); }