From 4470c5b393817a93854472354d76911cfc9abe6f Mon Sep 17 00:00:00 2001 From: Mitchell Johnson Date: Sun, 4 Sep 2022 19:16:21 -0400 Subject: Fix negative unconditional 16-bit thumb branches Sign extension shift had an off-by-one error so the sign bit was not being properly extended. --- src/armv7/thumb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/armv7') diff --git a/src/armv7/thumb.rs b/src/armv7/thumb.rs index baa2352..2e960b1 100644 --- a/src/armv7/thumb.rs +++ b/src/armv7/thumb.rs @@ -4174,7 +4174,7 @@ pub fn decode_into::Address, ::Word>>(d // v4T inst.opcode = Opcode::B; let imm = instr2[0..11].load::(); - let imm = ((imm as i32) << 20) >> 20; + let imm = ((imm as i32) << 21) >> 21; inst.operands = [ Operand::BranchThumbOffset(imm), Operand::Nothing, -- cgit v1.1