thumb: Word align PC when jumping to Arm code

Former-commit-id: 55fa28246c45a6bd807c53ce8bf0bb5865d36564
This commit is contained in:
Michel Heily 2019-07-09 01:27:23 +03:00
parent 6ddb136852
commit 0bdf4993ee

View file

@ -114,10 +114,12 @@ impl Core {
insn.rs() insn.rs()
}; };
let addr = self.get_reg(src_reg); let mut addr = self.get_reg(src_reg);
if addr.bit(0) { if addr.bit(0) {
self.cpsr.set_state(CpuState::THUMB); self.cpsr.set_state(CpuState::THUMB);
} else { } else {
// word align when switching to arm state
addr = addr & !0x3;
self.cpsr.set_state(CpuState::ARM); self.cpsr.set_state(CpuState::ARM);
} }