mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
thumb high register branch
This commit is contained in:
parent
3ad9f6d8df
commit
e7664c5796
2 changed files with 27 additions and 1 deletions
26
src/crab/thumb/hi_reg_branch_exchange.cr
Normal file
26
src/crab/thumb/hi_reg_branch_exchange.cr
Normal file
|
@ -0,0 +1,26 @@
|
|||
module THUMB
|
||||
def thumb_high_reg_branch_exchange(instr : Word) : Nil
|
||||
op = bits(instr, 8..9)
|
||||
h1 = bit?(instr, 7)
|
||||
h2 = bit?(instr, 6)
|
||||
rs = bits(instr, 3..5)
|
||||
rd = bits(instr, 0..2)
|
||||
|
||||
rd += 8 if h1
|
||||
rs += 8 if h2
|
||||
|
||||
case op
|
||||
when 0b00 then @r[rd] &+= @r[rs]
|
||||
when 0b01 then sub(@r[rd], @r[rs], true)
|
||||
when 0b10 then @r[rd] = @r[rs]
|
||||
when 0b11
|
||||
if bit?(@r[rs], 0)
|
||||
@r[15] = @r[rs] & ~1
|
||||
else
|
||||
@cpsr.thumb = false
|
||||
@r[15] = @r[rs] & ~3
|
||||
end
|
||||
end
|
||||
clear_pipeline
|
||||
end
|
||||
end
|
|
@ -35,7 +35,7 @@ module THUMB
|
|||
elsif idx & 0b11111000 == 0b01001000
|
||||
lut[idx] = ->thumb_pc_relative_load(Word)
|
||||
elsif idx & 0b11111100 == 0b01000100
|
||||
# hi register operations / branch exchange
|
||||
lut[idx] = ->thumb_high_reg_branch_exchange(Word)
|
||||
elsif idx & 0b11111100 == 0b01000000
|
||||
lut[idx] = ->thumb_alu_operations(Word)
|
||||
elsif idx & 0b11100000 == 0b00100000
|
||||
|
|
Loading…
Add table
Reference in a new issue