mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-17 06:11:52 +01:00
thumb multiple load store
This commit is contained in:
parent
ac7e3bbe72
commit
d62bfecacf
2 changed files with 25 additions and 1 deletions
24
src/crab/thumb/multiple_load_store.cr
Normal file
24
src/crab/thumb/multiple_load_store.cr
Normal 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
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue