thumb multiple load store

This commit is contained in:
Matthew Berry 2020-09-27 23:33:13 -07:00
parent ac7e3bbe72
commit d62bfecacf
2 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,24 @@
module THUMB
def thumb_multiple_load_store(instr : Word) : Nil
load_from_memory = bit?(instr, 11)
rb = bits(instr, 8..10)
list = bits(instr, 0..7)
address = @r[rb]
if load_from_memory # ldmia
8.times do |idx|
if bit?(list, idx)
@r[idx] = @gba.bus.read_word(address)
address &+= 4
end
end
else # stmia
8.times do |idx|
if bit?(list, idx)
@gba.bus[address] = @r[idx]
address &+= 4
end
end
end
@r[rb] = address
end
end

View file

@ -15,7 +15,7 @@ module THUMB
elsif idx & 0b11110000 == 0b11010000 elsif idx & 0b11110000 == 0b11010000
lut[idx] = ->thumb_conditional_branch(Word) lut[idx] = ->thumb_conditional_branch(Word)
elsif idx & 0b11110000 == 0b11000000 elsif idx & 0b11110000 == 0b11000000
# multiple load/store lut[idx] = ->thumb_multiple_load_store(Word)
elsif idx & 0b11110110 == 0b10110100 elsif idx & 0b11110110 == 0b10110100
# push/pop registers # push/pop registers
elsif idx & 0b11111111 == 0b10110000 elsif idx & 0b11111111 == 0b10110000