From 90edebbe82a36e2b4f8c6b3d997d2c2bf1f1c4f7 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Mon, 29 Jul 2019 01:55:16 +0300 Subject: [PATCH] Align to halfword for thumb branch long instructions Former-commit-id: f75e4baf003dcb7c535db3692383cc95575dfd81 --- src/core/arm7tdmi/thumb/exec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/arm7tdmi/thumb/exec.rs b/src/core/arm7tdmi/thumb/exec.rs index d066e1b..8502be4 100644 --- a/src/core/arm7tdmi/thumb/exec.rs +++ b/src/core/arm7tdmi/thumb/exec.rs @@ -411,7 +411,7 @@ impl Core { if insn.flag(ThumbInstruction::FLAG_LOW_OFFSET) { off = off << 1; let next_pc = (self.pc - 2) | 1; - self.pc = (self.gpr[REG_LR] as i32).wrapping_add(off) as u32; + self.pc = ((self.gpr[REG_LR] & !1) as i32).wrapping_add(off) as u32; self.gpr[REG_LR] = next_pc; self.flush_pipeline();