From 863838a4a47b59bdabe19b97bcdd0893a2edf79c Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Mon, 8 Jul 2019 00:57:18 +0300 Subject: [PATCH] Force R15 alignment via cpu.set_reg I've encounted many bugs with instructions that write PC but don't align it. Former-commit-id: b6a234564729f83c0b5e8adfa293227299aad4ac --- src/arm7tdmi/cpu.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arm7tdmi/cpu.rs b/src/arm7tdmi/cpu.rs index c21a965..6d46620 100644 --- a/src/arm7tdmi/cpu.rs +++ b/src/arm7tdmi/cpu.rs @@ -116,7 +116,7 @@ impl Core { pub fn set_reg(&mut self, reg_num: usize, val: u32) { match reg_num { 0...14 => self.gpr[reg_num] = val, - 15 => self.pc = val, + 15 => self.pc = val & !1, _ => panic!("invalid register"), } }