Commit c69e3264c3553697077f88571829face4e673100
1 parent
f71903d0
SH4: Fix swap.b
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
Showing
1 changed file
with
4 additions
and
1 deletions
target-sh4/translate.c
| ... | ... | @@ -683,7 +683,9 @@ void _decode_opc(DisasContext * ctx) |
| 683 | 683 | return; |
| 684 | 684 | case 0x6008: /* swap.b Rm,Rn */ |
| 685 | 685 | { |
| 686 | - TCGv high, low; | |
| 686 | + TCGv highw, high, low; | |
| 687 | + highw = tcg_temp_new(TCG_TYPE_I32); | |
| 688 | + tcg_gen_andi_i32(highw, REG(B7_4), 0xffff0000); | |
| 687 | 689 | high = tcg_temp_new(TCG_TYPE_I32); |
| 688 | 690 | tcg_gen_ext8u_i32(high, REG(B7_4)); |
| 689 | 691 | tcg_gen_shli_i32(high, high, 8); |
| ... | ... | @@ -691,6 +693,7 @@ void _decode_opc(DisasContext * ctx) |
| 691 | 693 | tcg_gen_shri_i32(low, REG(B7_4), 8); |
| 692 | 694 | tcg_gen_ext8u_i32(low, low); |
| 693 | 695 | tcg_gen_or_i32(REG(B11_8), high, low); |
| 696 | + tcg_gen_or_i32(REG(B11_8), REG(B11_8), highw); | |
| 694 | 697 | tcg_temp_free(low); |
| 695 | 698 | tcg_temp_free(high); |
| 696 | 699 | } | ... | ... |