thumb laod address fix word bits selection

This commit is contained in:
Matthew Berry 2020-11-04 22:32:37 -08:00
parent 59769a222c
commit 8ec8645ca2

View file

@ -2,7 +2,7 @@ module THUMB
def thumb_load_address(instr : Word) : Nil def thumb_load_address(instr : Word) : Nil
source = bit?(instr, 11) source = bit?(instr, 11)
rd = bits(instr, 8..10) rd = bits(instr, 8..10)
word = bits(instr, 0..8) word = bits(instr, 0..7)
imm = word << 2 imm = word << 2
# Where the PC is used as the source register (SP = 0), bit 1 of the PC is always read as 0. # Where the PC is used as the source register (SP = 0), bit 1 of the PC is always read as 0.
set_reg(rd, (source ? @r[13] : @r[15] & ~2) &+ imm) set_reg(rd, (source ? @r[13] : @r[15] & ~2) &+ imm)