From c69e3264c3553697077f88571829face4e673100 Mon Sep 17 00:00:00 2001 From: aurel32 Date: Sun, 12 Oct 2008 23:32:40 +0000 Subject: [PATCH] SH4: Fix swap.b MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The SH4 manual documents the swap.b instruction as follows: SWAP.B Rm,Rn Rm → swap lower 2 bytes → 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) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5471 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-sh4/translate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target-sh4/translate.c b/target-sh4/translate.c index 91821a18ae..ced761f2a5 100644 --- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -683,7 +683,9 @@ void _decode_opc(DisasContext * ctx) 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 @@ void _decode_opc(DisasContext * ctx) 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); } -- 2.11.0