thumb load/store immediate offset

This commit is contained in:
Matthew Berry 2020-09-28 22:46:28 -07:00
parent e7664c5796
commit 21ae86e2ff
2 changed files with 16 additions and 1 deletions

View file

@ -0,0 +1,15 @@
module THUMB
def thumb_load_store_immediate_offset(instr : Word) : Nil
byte_quantity_and_load = bits(instr, 11..12)
offset = bits(instr, 6..10)
rb = bits(instr, 3..5)
rd = bits(instr, 0..2)
imm = offset << 2
case byte_quantity_and_load
when 0b00 then @gba.bus[@r[rb] + imm] = @r[rd]
when 0b01 then @r[rd] = @gba.bus.read_word(@r[rb] + imm)
when 0b10 then @gba.bus[@r[rb] + imm] = @r[rd].to_u8!
when 0b11 then @r[rd] = @gba.bus[@r[rb] + imm].to_u32
end
end
end

View file

@ -27,7 +27,7 @@ module THUMB
elsif idx & 0b11110000 == 0b10000000
# load/store halfword
elsif idx & 0b11100000 == 0b01100000
# load/store with immediate offset
lut[idx] = ->thumb_load_store_immediate_offset(Word)
elsif idx & 0b11110010 == 0b01010010
# load/store sign-extended byte/halfword
elsif idx & 0b11110010 == 0b01010000