mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-05 11:01:33 +01:00
thumb load/store halfword, add halfword type, add halfword write
This commit is contained in:
parent
b830b97687
commit
1d148c3ea7
4 changed files with 22 additions and 1 deletions
|
@ -54,6 +54,12 @@ class Bus
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def []=(index : Int, value : HalfWord) : Nil
|
||||||
|
log "write #{hex_str index.to_u32} -> #{hex_str value}"
|
||||||
|
self[index + 1] = 0xFF_u8 & (value >> 8)
|
||||||
|
self[index] = 0xFF_u8 & value
|
||||||
|
end
|
||||||
|
|
||||||
def []=(index : Int, value : Word) : Nil
|
def []=(index : Int, value : Word) : Nil
|
||||||
log "write #{hex_str index.to_u32} -> #{hex_str value}"
|
log "write #{hex_str index.to_u32} -> #{hex_str value}"
|
||||||
self[index + 3] = 0xFF_u8 & (value >> 24)
|
self[index + 3] = 0xFF_u8 & (value >> 24)
|
||||||
|
|
14
src/crab/thumb/load_store_halfword.cr
Normal file
14
src/crab/thumb/load_store_halfword.cr
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
module THUMB
|
||||||
|
def thumb_load_store_halfword(instr : Word) : Nil
|
||||||
|
load = bit?(instr, 11)
|
||||||
|
offset = bits(instr, 6..10)
|
||||||
|
rb = bits(instr, 3..5)
|
||||||
|
rd = bits(instr, 0..2)
|
||||||
|
address = @r[rb] + (offset << 1)
|
||||||
|
if load
|
||||||
|
@r[rd] = @gba.bus.read_half(address)
|
||||||
|
else
|
||||||
|
@gba.bus[address] = @r[rd].to_u16!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -25,7 +25,7 @@ module THUMB
|
||||||
elsif idx & 0b11110000 == 0b10010000
|
elsif idx & 0b11110000 == 0b10010000
|
||||||
# sp-relative load/store
|
# sp-relative load/store
|
||||||
elsif idx & 0b11110000 == 0b10000000
|
elsif idx & 0b11110000 == 0b10000000
|
||||||
# load/store halfword
|
lut[idx] = -> thumb_load_store_halfword(Word)
|
||||||
elsif idx & 0b11100000 == 0b01100000
|
elsif idx & 0b11100000 == 0b01100000
|
||||||
lut[idx] = ->thumb_load_store_immediate_offset(Word)
|
lut[idx] = ->thumb_load_store_immediate_offset(Word)
|
||||||
elsif idx & 0b11110010 == 0b01010010
|
elsif idx & 0b11110010 == 0b01010010
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
alias Byte = UInt8
|
alias Byte = UInt8
|
||||||
|
alias HalfWord = UInt16
|
||||||
alias Word = UInt32
|
alias Word = UInt32
|
||||||
alias Words = Slice(UInt32)
|
alias Words = Slice(UInt32)
|
||||||
|
|
Loading…
Reference in a new issue