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