diff --git a/src/arm7tdmi/thumb/display.rs b/src/arm7tdmi/thumb/display.rs index 6eb40d4..2d9dcf3 100644 --- a/src/arm7tdmi/thumb/display.rs +++ b/src/arm7tdmi/thumb/display.rs @@ -164,8 +164,8 @@ impl ThumbInstruction { "b{cond}\t{addr:#x}", cond = self.cond(), addr = { - let offset = self.offset8() as i8 as i32; - (self.pc as i32).wrapping_add(offset) as Addr + let offset = ((self.offset8() as i8) << 1) as i32; + (self.pc as i32 + 4).wrapping_add(offset) as Addr } ) } diff --git a/src/arm7tdmi/thumb/exec.rs b/src/arm7tdmi/thumb/exec.rs index fbca6d8..41961b7 100644 --- a/src/arm7tdmi/thumb/exec.rs +++ b/src/arm7tdmi/thumb/exec.rs @@ -247,8 +247,8 @@ impl Core { if !self.check_arm_cond(insn.cond()) { Ok(CpuPipelineAction::IncPC) } else { - let offset = insn.offset8() as i8 as i32; - self.pc = (insn.pc as i32).wrapping_add(offset) as u32; + let offset = ((insn.offset8() as i8) << 1) as i32; + self.pc = (self.pc as i32).wrapping_add(offset) as u32; Ok(CpuPipelineAction::Flush) } }