thumb add offset to stack pointer

This commit is contained in:
Matthew Berry 2020-10-03 00:10:58 -07:00
parent 7228a50427
commit f1058e3450
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,11 @@
module THUMB
def thumb_add_offset_to_stack_pointer(instr : Word) : Nil
sign = bit?(instr, 7)
offset = bits(instr, 0..6)
if sign # negative
@r[13] &-= (offset << 2)
else # positive
@r[13] &+= (offset << 2)
end
end
end

View file

@ -19,7 +19,7 @@ module THUMB
elsif idx & 0b11110110 == 0b10110100
lut[idx] = ->thumb_push_pop_registers(Word)
elsif idx & 0b11111111 == 0b10110000
# add offset to stack pointer
lut[idx] = ->thumb_add_offset_to_stack_pointer(Word)
elsif idx & 0b11110000 == 0b10100000
# load address
elsif idx & 0b11110000 == 0b10010000