fix word writes, fix register list in thumb push/pop, fix thumb push/pop stack pointer decrement

This commit is contained in:
Matthew Berry 2020-09-30 22:01:55 -07:00
parent 27b0a4e4ce
commit 4194dfb6fd
2 changed files with 6 additions and 6 deletions

View file

@ -46,9 +46,9 @@ class Bus
def []=(index : Int, value : Word) : Nil
log "write #{hex_str index.to_u32} -> #{hex_str value}"
self[index] = 0xFF_u8 & (value >> 24)
self[index] = 0xFF_u8 & (value >> 16)
self[index] = 0xFF_u8 & (value >> 8)
self[index + 3] = 0xFF_u8 & (value >> 24)
self[index + 2] = 0xFF_u8 & (value >> 16)
self[index + 1] = 0xFF_u8 & (value >> 8)
self[index] = 0xFF_u8 & value
end
end

View file

@ -2,7 +2,7 @@ module THUMB
def thumb_push_pop_registers(instr : Word) : Nil
pop = bit?(instr, 11)
pclr = bit?(instr, 8)
list = bits(instr, 0..8)
list = bits(instr, 0..7)
address = @r[13]
if pop
8.times do |idx|
@ -18,13 +18,13 @@ module THUMB
end
else
if pclr
@gba.bus[address] = @r[14]
address &-= 4
@gba.bus[address] = @r[14]
end
7.downto(0).each do |idx|
if bit?(list, idx)
@gba.bus[address] = @r[idx]
address &-= 4
@gba.bus[address] = @r[idx]
end
end
end