thumb long branch

This commit is contained in:
Matthew Berry 2020-09-27 20:06:47 -07:00
parent 99bdf3ec86
commit 3471a8b34c
2 changed files with 14 additions and 1 deletions

View file

@ -0,0 +1,13 @@
module THUMB
def thumb_long_branch_link(instr : Word) : Nil
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
clear_pipeline
else
@r[14] = (offset << 12) + @r[15]
end
end
end

View file

@ -7,7 +7,7 @@ module THUMB
lut = Slice(Proc(Word, Nil)).new 256, ->thumb_unimplemented(Word) lut = Slice(Proc(Word, Nil)).new 256, ->thumb_unimplemented(Word)
256.times do |idx| 256.times do |idx|
if idx & 0b11110000 == 0b11110000 if idx & 0b11110000 == 0b11110000
# long branch with link lut[idx] = ->thumb_long_branch_link(Word)
elsif idx & 0b11111000 == 0b11100000 elsif idx & 0b11111000 == 0b11100000
# unconditional branch # unconditional branch
elsif idx & 0b11111111 == 0b11011111 elsif idx & 0b11111111 == 0b11011111