From 88eeb2bf65e8a548647c9fd8386398fa1cbfb670 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Fri, 16 May 2014 23:08:03 +0300 Subject: [PATCH] increment implementation (start) and more splitting --- test/arm/test_all.rb | 2 ++ test/arm/test_arm.rb | 20 -------------------- test/arm/test_memory.rb | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 20 deletions(-) create mode 100644 test/arm/test_memory.rb diff --git a/test/arm/test_all.rb b/test/arm/test_all.rb index 220aaf19..f086bd4a 100644 --- a/test/arm/test_all.rb +++ b/test/arm/test_all.rb @@ -1,2 +1,4 @@ require_relative "test_arm" require_relative "test_logic" +require_relative "test_move" +require_relative "test_memory" diff --git a/test/arm/test_arm.rb b/test/arm/test_arm.rb index e3520c3a..24c1fc6b 100644 --- a/test/arm/test_arm.rb +++ b/test/arm/test_arm.rb @@ -26,18 +26,6 @@ class TestArmAsm < MiniTest::Test code = @machine.cmp :r1 , right: :r2 assert_code code , :cmp , [0x02,0x00,0x51,0xe1] #e1 51 00 02 end - def test_ldr - code = @machine.ldr :r0, right: :r0 - assert_code code, :ldr , [0x00,0x00,0x90,0xe5] #e5 90 00 00 - end - def test_ldr2 - code = @machine.ldr :r0, right: :r0 , :offset => 4 - assert_code code, :ldr , [0x04,0x00,0x90,0xe5] #e5 90 00 04 - end - def test_ldrb - code = @machine.ldrb :r0, right: :r0 - assert_code code, :ldrb , [0x00,0x00,0xd0,0xe5] #e5 d0 00 00 - end def test_push code = @machine.push [:lr] , {} assert_code code , :push , [0x00,0x40,0x2d,0xe9] #e9 2d 40 00 @@ -58,14 +46,6 @@ class TestArmAsm < MiniTest::Test code = @machine.sbc :r3, left: :r4 , right: :r5 assert_code code , :sbc , [0x05,0x30,0xc4,0xe0]#e0 c4 30 05 end - def test_str - code = @machine.str :r0, right: :r0 - assert_code code, :str , [0x00,0x00,0x80,0xe5] #e5 81 00 00 - end - def test_strb - code = @machine.strb :r0, right: :r0 - assert_code code, :strb , [0x00,0x00,0xc0,0xe5] #e5 c0 00 00 - end def test_swi code = @machine.swi 0x05 , {} assert_code code , :swi , [0x05,0x00,0x00,0xef]#ef 00 00 05 diff --git a/test/arm/test_memory.rb b/test/arm/test_memory.rb new file mode 100644 index 00000000..c4f07253 --- /dev/null +++ b/test/arm/test_memory.rb @@ -0,0 +1,33 @@ +require_relative 'helper' + +class TestMemory < MiniTest::Test + include ArmHelper + + def test_ldr + code = @machine.ldr :r0, right: :r0 + assert_code code, :ldr , [0x00,0x00,0x90,0xe5] #e5 90 00 00 + end + def test_ldr2 + code = @machine.ldr :r0, right: :r0 , :offset => 4 + assert_code code, :ldr , [0x04,0x00,0x90,0xe5] #e5 90 00 04 + end + def test_ldrb + code = @machine.ldrb :r0, right: :r0 + assert_code code, :ldrb , [0x00,0x00,0xd0,0xe5] #e5 d0 00 00 + end + + def test_str + code = @machine.str :r0, right: :r1 + assert_code code, :str , [0x00,0x00,0x81,0xe5] #e5 81 00 00 + end + + def test_strb_add + code = @machine.strb :r0, right: :r1 , :offset => 1 , flaggie: 1 + assert_code code, :strb , [0x01,0x00,0xc1,0xe4] #e4 c1 00 01 + end + + def test_strb + code = @machine.strb :r0, right: :r0 + assert_code code, :strb , [0x00,0x00,0xc0,0xe5] #e5 c0 00 00 + end +end