2014-08-30 18:40:37 +02:00
|
|
|
require_relative 'arm-helper'
|
|
|
|
|
|
|
|
class TestMoves < MiniTest::Test
|
|
|
|
include ArmHelper
|
|
|
|
|
|
|
|
def test_mov
|
|
|
|
code = @machine.mov :r0, 5
|
|
|
|
assert_code code , :mov , [0x05,0x00,0xa0,0xe3] #e3 a0 10 05
|
|
|
|
end
|
2014-09-18 16:06:30 +02:00
|
|
|
def test_mov_pc
|
|
|
|
code = @machine.mov :pc, 6
|
|
|
|
assert_code code , :mov , [0x06,0xf0,0xa0,0xe3] #e3 a0 f0 06
|
|
|
|
end
|
2014-09-29 19:28:24 +02:00
|
|
|
def test_mov_256
|
|
|
|
code = @machine.mov :r1, 256
|
|
|
|
assert_code code , :mov , [0x01,0x1c,0xa0,0xe3] #e3 a0 1c 01
|
|
|
|
end
|
|
|
|
def test_mov_max_128
|
|
|
|
code = @machine.mov :r1, 128
|
|
|
|
assert_code code , :mov , [0x80,0x10,0xa0,0xe3] #e3 a0 10 80
|
|
|
|
end
|
2014-09-18 16:06:30 +02:00
|
|
|
def test_mov_big
|
|
|
|
code = @machine.mov :r0, 0x222
|
|
|
|
code.set_position(0)
|
|
|
|
begin #TODO use compiler to confirm codes here: this is just what passes
|
|
|
|
assert_code code , :mov , [ 0x02,0x00,0xa0,0xe3 , 0xff,0x04,0x80,0xe2]
|
|
|
|
rescue Register::LinkException
|
|
|
|
retry
|
|
|
|
end
|
|
|
|
end
|
2014-08-30 18:40:37 +02:00
|
|
|
def test_mvn
|
|
|
|
code = @machine.mvn :r1, 5
|
|
|
|
assert_code code , :mvn , [0x05,0x10,0xe0,0xe3] #e3 e0 10 05
|
|
|
|
end
|
|
|
|
end
|