mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-29 20:35:13 +01:00
thumb load/store immediate offset
This commit is contained in:
parent
e7664c5796
commit
21ae86e2ff
2 changed files with 16 additions and 1 deletions
15
src/crab/thumb/load_store_immediate_offset.cr
Normal file
15
src/crab/thumb/load_store_immediate_offset.cr
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue