mirror of
https://github.com/mattrberry/crab.git
synced 2025-02-02 07:57:58 +01:00
thumb long branch
This commit is contained in:
parent
99bdf3ec86
commit
3471a8b34c
2 changed files with 14 additions and 1 deletions
13
src/crab/thumb/long_branch_link.cr
Normal file
13
src/crab/thumb/long_branch_link.cr
Normal 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
|
|
@ -7,7 +7,7 @@ module THUMB
|
|||
lut = Slice(Proc(Word, Nil)).new 256, ->thumb_unimplemented(Word)
|
||||
256.times do |idx|
|
||||
if idx & 0b11110000 == 0b11110000
|
||||
# long branch with link
|
||||
lut[idx] = ->thumb_long_branch_link(Word)
|
||||
elsif idx & 0b11111000 == 0b11100000
|
||||
# unconditional branch
|
||||
elsif idx & 0b11111111 == 0b11011111
|
||||
|
|
Loading…
Add table
Reference in a new issue