thumb push/pop registers

This commit is contained in:
Matthew Berry 2020-09-29 00:17:46 -07:00
parent cf310896b1
commit f230348f75
2 changed files with 34 additions and 1 deletions

View file

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

View file

@ -17,7 +17,7 @@ module THUMB
elsif idx & 0b11110000 == 0b11000000
lut[idx] = ->thumb_multiple_load_store(Word)
elsif idx & 0b11110110 == 0b10110100
# push/pop registers
lut[idx] = ->thumb_push_pop_registers(Word)
elsif idx & 0b11111111 == 0b10110000
# add offset to stack pointer
elsif idx & 0b11110000 == 0b10100000