From c589e8f6efd706ae0e1900dd21019a6a17bad1a8 Mon Sep 17 00:00:00 2001 From: Matthew Berry Date: Sat, 24 Oct 2020 01:22:03 -0700 Subject: [PATCH] fix thumb long branch link weird sign logic --- src/crab/thumb/long_branch_link.cr | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/crab/thumb/long_branch_link.cr b/src/crab/thumb/long_branch_link.cr index beb9d90..03a7857 100644 --- a/src/crab/thumb/long_branch_link.cr +++ b/src/crab/thumb/long_branch_link.cr @@ -3,12 +3,13 @@ module THUMB second_instr = bit?(instr, 11) offset = bits(instr, 0..10) if second_instr - @r[14] &+= (offset << 1) - @r[15], @r[14] = @r[14], @r[15] - 1 + temp = @r[15] &- 2 + @r[15] = @r[14] &+ (offset << 1) + @r[14] = temp | 1 clear_pipeline else - offset = (offset << 5).to_i16! >> 5 # todo make this just bit math - @r[14] = @r[15] &+ (offset << 12) + offset = (offset << 5).to_i16! >> 5 + @r[14] = @r[15] &+ (offset.to_u32 << 12) end end end