2016-12-14 12:43:13 +01:00
|
|
|
require_relative 'helper'
|
|
|
|
|
2017-01-03 21:37:55 +01:00
|
|
|
module Arm
|
|
|
|
class TestMoves < MiniTest::Test
|
|
|
|
include ArmHelper
|
2016-12-14 12:43:13 +01:00
|
|
|
|
2017-01-03 21:37:55 +01:00
|
|
|
def test_mov
|
|
|
|
code = @machine.mov :r1, 5
|
|
|
|
assert_code code , :mov , [0x05,0x10,0xb0,0xe3] #e3 b0 10 05
|
|
|
|
end
|
|
|
|
def test_mov_pc
|
|
|
|
code = @machine.mov :pc, 5
|
2018-05-31 13:03:25 +02:00
|
|
|
assert_code code , :mov , [0x05,0xf0,0xa0,0xe3] #e3 a0 f0 06
|
|
|
|
end
|
|
|
|
def test_mov_pc_r1
|
|
|
|
code = @machine.mov :pc, :r1
|
|
|
|
assert_code code , :mov , [0x01,0xf0,0xa0,0xe1] #e1 a0 f0 01
|
2017-01-03 21:37:55 +01:00
|
|
|
end
|
|
|
|
def test_mov_max_128
|
|
|
|
code = @machine.mov :r1, 128
|
|
|
|
assert_code code , :mov , [0x80,0x10,0xb0,0xe3] #e3 b0 10 80
|
|
|
|
end
|
|
|
|
def test_mov_256
|
|
|
|
code = @machine.mov :r1, 256
|
|
|
|
assert_code code , :mov , [0x01,0x1c,0xb0,0xe3] #e3 b0 1c 01
|
|
|
|
end
|
|
|
|
def test_mov_big
|
|
|
|
code = @machine.mov :r0, 0x222 # is not 8 bit and can't be rotated by the arm system in one instruction
|
2018-06-07 18:27:44 +02:00
|
|
|
Risc::Position.new(code,0)
|
2018-05-08 19:22:04 +02:00
|
|
|
# mov 512(0x200) = e3 a0 0c 02 add 34(0x22) = e2 90 00 22
|
|
|
|
assert_code code , :mov , [ 0x02,0x0c,0xb0,0xe3]
|
2018-04-03 13:46:07 +02:00
|
|
|
assert_code code.next , :add , [ 0x22,0x00,0x90,0xe2]
|
2017-01-03 21:37:55 +01:00
|
|
|
end
|
|
|
|
def test_mvn
|
|
|
|
code = @machine.mvn :r1, 5
|
|
|
|
assert_code code , :mvn , [0x05,0x10,0xf0,0xe3] #e3 f0 10 05
|
2016-12-14 12:43:13 +01:00
|
|
|
end
|
|
|
|
|
2017-01-03 21:37:55 +01:00
|
|
|
def test_shiftr1
|
2017-01-19 08:02:29 +01:00
|
|
|
code = @machine.mov :r1, :r2 , :shift_asr => Risc::RiscValue.new(:r3 , :Integer)
|
2017-01-03 21:37:55 +01:00
|
|
|
assert_code code , :mov , [0x52,0x13,0xb0,0xe1] #e1 b0 13 52
|
|
|
|
end
|
|
|
|
def test_shiftr2
|
2017-01-19 08:02:29 +01:00
|
|
|
code = @machine.mov :r2, :r3 , :shift_asr => Risc::RiscValue.new(:r4 , :Integer)
|
2017-01-03 21:37:55 +01:00
|
|
|
assert_code code , :mov , [0x53,0x24,0xb0,0xe1] #e1 b0 24 53
|
|
|
|
end
|
|
|
|
def test_shiftr3
|
2017-01-19 08:02:29 +01:00
|
|
|
code = @machine.mov :r3, :r4 , :shift_asr => Risc::RiscValue.new(:r5 , :Integer)
|
2017-01-03 21:37:55 +01:00
|
|
|
assert_code code , :mov , [0x54,0x35,0xb0,0xe1] #e1 b0 35 54
|
|
|
|
end
|
2016-12-14 12:43:13 +01:00
|
|
|
|
2017-01-03 21:37:55 +01:00
|
|
|
def test_shiftl1
|
2017-01-19 08:02:29 +01:00
|
|
|
code = @machine.mov :r1, :r2 , :shift_lsr => Risc::RiscValue.new(:r3 , :Integer)
|
2017-01-03 21:37:55 +01:00
|
|
|
assert_code code , :mov , [0x32,0x13,0xb0,0xe1] #e1 b0 13 32
|
|
|
|
end
|
|
|
|
def test_shiftl2
|
2017-01-19 08:02:29 +01:00
|
|
|
code = @machine.mov :r2, :r3 , :shift_lsr => Risc::RiscValue.new(:r4 , :Integer)
|
2017-01-03 21:37:55 +01:00
|
|
|
assert_code code , :mov , [0x33,0x24,0xb0,0xe1] #e1 b0 24 33
|
|
|
|
end
|
|
|
|
def test_shiftl3
|
2017-01-19 08:02:29 +01:00
|
|
|
code = @machine.mov :r3, :r4 , :shift_lsr => Risc::RiscValue.new(:r5 , :Integer)
|
2017-01-03 21:37:55 +01:00
|
|
|
assert_code code , :mov , [0x34,0x35,0xb0,0xe1] #e1 b0 35 34
|
|
|
|
end
|
2016-12-14 12:43:13 +01:00
|
|
|
|
2017-01-03 21:37:55 +01:00
|
|
|
end
|
2016-12-14 12:43:13 +01:00
|
|
|
end
|