mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-19 10:26:44 +01:00
thumb move shifted register (- carry flag)
diverges from armwrestler here bc of carry flag
This commit is contained in:
parent
eb5d932579
commit
55589ea0b0
2 changed files with 18 additions and 1 deletions
17
src/crab/thumb/move_shifted_register.cr
Normal file
17
src/crab/thumb/move_shifted_register.cr
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
module THUMB
|
||||||
|
def thumb_move_shifted_register(instr : Word) : Nil
|
||||||
|
# todo carry flags (currently first divergence on armwrestler)
|
||||||
|
op = bits(instr, 11..12)
|
||||||
|
offset = bits(instr, 6..10)
|
||||||
|
rs = bits(instr, 3..5)
|
||||||
|
rd = bits(instr, 0..2)
|
||||||
|
@r[rd] = case op
|
||||||
|
when 0b00 then @r[rs] << offset
|
||||||
|
when 0b01 then @r[rs] >> offset
|
||||||
|
when 0b10 then @r[rs] // (2 ** offset)
|
||||||
|
else raise "Invalid shifted register op: #{op}"
|
||||||
|
end
|
||||||
|
@cpsr.zero = @r[rd] == 0
|
||||||
|
@cpsr.negative = bit?(@r[rd], 31)
|
||||||
|
end
|
||||||
|
end
|
|
@ -43,7 +43,7 @@ module THUMB
|
||||||
elsif idx & 0b11111100 == 0b00011000
|
elsif idx & 0b11111100 == 0b00011000
|
||||||
# add/subtract
|
# add/subtract
|
||||||
elsif idx & 0b11100000 == 0b00000000
|
elsif idx & 0b11100000 == 0b00000000
|
||||||
# move shifted register
|
lut[idx] = ->thumb_move_shifted_register(Word)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
lut
|
lut
|
||||||
|
|
Loading…
Reference in a new issue