thumb high register branch

This commit is contained in:
Matthew Berry 2020-09-28 22:28:46 -07:00
parent 3ad9f6d8df
commit e7664c5796
2 changed files with 27 additions and 1 deletions

View 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

View file

@ -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