early psr transfer implementation

This commit is contained in:
Matthew Berry 2020-09-27 13:51:17 -07:00
parent 4b745a075a
commit 09b8876b73
2 changed files with 28 additions and 0 deletions

View file

@ -69,6 +69,8 @@ module ARM
# multiply long
elsif idx & 0b111111001111 == 0b000000001001
# multiply
elsif idx & 0b110110010000 == 0b000100000000
lut[idx] = ->arm_psr_transfer(Word)
elsif idx & 0b110000000000 == 0b000000000000
lut[idx] = ->arm_data_processing(Word)
else

View file

@ -0,0 +1,26 @@
module ARM
def arm_psr_transfer(instr : Word) : Nil
# todo respect spsr
spsr = bit?(instr, 22)
msr = bit?(instr, 21)
if msr
all = bit?(instr, 16)
if all
rm = bits(instr, 0..3)
@cpsr.value = @r[rm]
else
imm_flag = bit?(instr, 25)
value = if imm_flag
immediate_offset bits(instr, 0..11)
else
rm = bits(instr, 0..3)
@r[rm]
end
@cpsr.value = (@cpsr.value & 0x0FFFFFFF) | (value & 0xF0000000)
end
else
rd = bits(instr, 12..15)
@r[rd] = @cpsr.value
end
end
end