The BPOSGE32C offset is a signed value s[14:1], with s[14] stored in
instruction bit 0 (MD01249 rev 0.04, "BPOSGE32C", printed page 88).
The decoder zero-extended it, so backward branches went to the wrong
target.
Reuse the sign-extended offset already computed by the P.BR3A pool.
Fixes: 6d033ca7513d ("target/mips: Add emulation of DSP ASE for nanoMIPS")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
target/mips/tcg/nanomips_translate.c.inc | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/target/mips/tcg/nanomips_translate.c.inc
b/target/mips/tcg/nanomips_translate.c.inc
index 20e96f2ad9be..3e326afd0827 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -4365,13 +4365,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env,
DisasContext *ctx)
break;
case NM_BPOSGE32C:
check_dsp_r3(ctx);
- {
- imm = extract32(ctx->opcode, 1, 13)
- | extract32(ctx->opcode, 0, 1) << 13;
-
- gen_compute_branch_nm(ctx, OPC_BPOSGE32, 4, -1, -2,
- imm << 1);
- }
+ gen_compute_branch_nm(ctx, OPC_BPOSGE32, 4, -1, -2, s);
break;
default:
gen_reserved_instruction(ctx);
--
2.55.0