mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-15 03:40:56 +01:00
thumb stm correct direction, handle empty list case
This commit is contained in:
parent
9ad6086baf
commit
ec08f0ee21
1 changed files with 21 additions and 12 deletions
|
@ -4,6 +4,7 @@ module THUMB
|
|||
rb = bits(instr, 8..10)
|
||||
list = bits(instr, 0..7)
|
||||
address = @r[rb]
|
||||
unless list == 0
|
||||
if load # ldmia
|
||||
8.times do |idx|
|
||||
if bit?(list, idx)
|
||||
|
@ -12,7 +13,7 @@ module THUMB
|
|||
end
|
||||
end
|
||||
else # stmia
|
||||
7.downto(0).each do |idx|
|
||||
8.times do |idx|
|
||||
if bit?(list, idx)
|
||||
@gba.bus[address] = @r[idx]
|
||||
address &+= 4
|
||||
|
@ -20,5 +21,13 @@ module THUMB
|
|||
end
|
||||
end
|
||||
set_reg(rb, address)
|
||||
else # https://github.com/jsmolka/gba-suite/blob/0e32e15c6241e6dc20851563ba88f4656ac50936/thumb/memory.asm#L459
|
||||
if load
|
||||
set_reg(15, @gba.bus.read_word(address))
|
||||
else
|
||||
@gba.bus[address] = @r[15] &+ 2
|
||||
end
|
||||
set_reg(rb, address &+ 0x40)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue