From 0bdf4993ee5d65acab54e6fce51f4d211109879c Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Tue, 9 Jul 2019 01:27:23 +0300 Subject: [PATCH] thumb: Word align PC when jumping to Arm code Former-commit-id: 55fa28246c45a6bd807c53ce8bf0bb5865d36564 --- src/arm7tdmi/thumb/exec.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arm7tdmi/thumb/exec.rs b/src/arm7tdmi/thumb/exec.rs index a5c66b0..7d9bcc7 100644 --- a/src/arm7tdmi/thumb/exec.rs +++ b/src/arm7tdmi/thumb/exec.rs @@ -114,10 +114,12 @@ impl Core { insn.rs() }; - let addr = self.get_reg(src_reg); + let mut addr = self.get_reg(src_reg); if addr.bit(0) { self.cpsr.set_state(CpuState::THUMB); } else { + // word align when switching to arm state + addr = addr & !0x3; self.cpsr.set_state(CpuState::ARM); }