mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
thumb push/pop registers
This commit is contained in:
parent
cf310896b1
commit
f230348f75
2 changed files with 34 additions and 1 deletions
33
src/crab/thumb/push_pop_registers.cr
Normal file
33
src/crab/thumb/push_pop_registers.cr
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue