Fix wrong calculation of conditional branch offset in Thumb mode
Former-commit-id: 4cc28b13b19b2bf45e2b0e34d9a9dc0f83f82b01
This commit is contained in:
parent
37117257a6
commit
0c50209735
|
@ -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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue