fix thumb long branch link weird sign logic

This commit is contained in:
Matthew Berry 2020-10-24 01:22:03 -07:00
parent a5ebfd603c
commit c589e8f6ef

View file

@ -3,12 +3,13 @@ module THUMB
second_instr = bit?(instr, 11) second_instr = bit?(instr, 11)
offset = bits(instr, 0..10) offset = bits(instr, 0..10)
if second_instr if second_instr
@r[14] &+= (offset << 1) temp = @r[15] &- 2
@r[15], @r[14] = @r[14], @r[15] - 1 @r[15] = @r[14] &+ (offset << 1)
@r[14] = temp | 1
clear_pipeline clear_pipeline
else else
offset = (offset << 5).to_i16! >> 5 # todo make this just bit math offset = (offset << 5).to_i16! >> 5
@r[14] = @r[15] &+ (offset << 12) @r[14] = @r[15] &+ (offset.to_u32 << 12)
end end
end end
end end