2014-05-19 10:27:20 +02:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestStack < MiniTest::Test
|
|
|
|
include ArmHelper
|
|
|
|
|
|
|
|
def test_push
|
|
|
|
code = @machine.push [:lr]
|
|
|
|
assert_code code , :push , [0x00,0x40,0x2d,0xe9] #e9 2d 40 00
|
|
|
|
end
|
2014-05-23 14:08:47 +02:00
|
|
|
def test_push_three
|
|
|
|
code = @machine.push [:r0,:r1,:lr]
|
|
|
|
assert_code code , :push , [0x03,0x40,0x2d,0xe9] #e9 2d 40 03
|
|
|
|
end
|
|
|
|
def test_push_no_link
|
|
|
|
code = @machine.push [:r0,:r1,:r2 ,:r3,:r4,:r5]
|
|
|
|
assert_code code , :push , [0x3f,0x00,0x2d,0xe9] #e9 2d 00 3f
|
|
|
|
end
|
2014-05-19 10:27:20 +02:00
|
|
|
def test_pop
|
|
|
|
code = @machine.pop [:pc]
|
|
|
|
assert_code code , :pop , [0x00,0x80,0xbd,0xe8] #e8 bd 80 00
|
|
|
|
end
|
2014-05-23 14:08:47 +02:00
|
|
|
def test_pop_three
|
|
|
|
code = @machine.pop [:r0,:r1,:pc]
|
|
|
|
assert_code code , :pop , [0x03,0x80,0xbd,0xe8] #e8 bd 80 03
|
|
|
|
end
|
|
|
|
def test_pop_no_pc
|
|
|
|
code = @machine.pop [:r0,:r1,:r2 ,:r3,:r4,:r5]
|
|
|
|
assert_code code , :pop , [0x3f,0x00,0xbd,0xe8] #e8 bd 00 3f
|
|
|
|
end
|
|
|
|
|
2014-05-19 10:27:20 +02:00
|
|
|
end
|