2014-05-16 22:08:03 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestMemory < MiniTest::Test
|
|
|
|
include ArmHelper
|
|
|
|
|
|
|
|
def test_ldr
|
2014-06-01 20:20:44 +02:00
|
|
|
code = @machine.ldr :r0, :r0
|
2014-05-16 22:08:03 +02:00
|
|
|
assert_code code, :ldr , [0x00,0x00,0x90,0xe5] #e5 90 00 00
|
|
|
|
end
|
2014-06-01 20:20:44 +02:00
|
|
|
def test_ldr_const_offset
|
|
|
|
code = @machine.ldr :r0, :r0 , 4
|
2014-05-16 22:08:03 +02:00
|
|
|
assert_code code, :ldr , [0x04,0x00,0x90,0xe5] #e5 90 00 04
|
|
|
|
end
|
2014-06-01 20:20:44 +02:00
|
|
|
def test_ldr_reg_offset
|
|
|
|
code = @machine.ldr :r0, :r1 , :r2
|
|
|
|
assert_code code, :ldr , [0x02,0x00,0x91,0xe6] #e6 91 00 02
|
|
|
|
end
|
2014-05-16 22:08:03 +02:00
|
|
|
def test_ldrb
|
2014-06-01 20:20:44 +02:00
|
|
|
code = @machine.ldrb :r0, :r0
|
2014-05-16 22:08:03 +02:00
|
|
|
assert_code code, :ldrb , [0x00,0x00,0xd0,0xe5] #e5 d0 00 00
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_str
|
2014-06-01 20:20:44 +02:00
|
|
|
code = @machine.str :r0, :r1
|
2014-05-16 22:08:03 +02:00
|
|
|
assert_code code, :str , [0x00,0x00,0x81,0xe5] #e5 81 00 00
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_strb_add
|
2014-06-01 20:20:44 +02:00
|
|
|
code = @machine.strb :r0, :r1 , 1 , flaggie: 1
|
2014-05-16 22:08:03 +02:00
|
|
|
assert_code code, :strb , [0x01,0x00,0xc1,0xe4] #e4 c1 00 01
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_strb
|
2014-06-01 20:20:44 +02:00
|
|
|
code = @machine.strb :r0, :r0
|
2014-05-16 22:08:03 +02:00
|
|
|
assert_code code, :strb , [0x00,0x00,0xc0,0xe5] #e5 c0 00 00
|
|
|
|
end
|
|
|
|
end
|