2014-04-14 21:53:29 +03:00
|
|
|
require_relative 'helper'
|
2014-04-14 15:58:59 +03:00
|
|
|
|
2014-05-19 11:27:20 +03:00
|
|
|
class TestControl < MiniTest::Test
|
2014-05-16 17:30:26 +03:00
|
|
|
include ArmHelper
|
2014-04-14 21:53:29 +03:00
|
|
|
|
2014-04-19 19:34:04 +03:00
|
|
|
def test_b
|
|
|
|
# the address is what an assembler calculates (a signed number for the amount of instructions),
|
|
|
|
# ie the relative (to pc) address -8 (pipeline) /4 so save space
|
|
|
|
# so the cpu adds the value*4 and starts loading that (load, decode, execute)
|
2014-05-18 12:34:53 +03:00
|
|
|
code = @machine.b -4 #this jumps to the next instruction
|
2014-04-19 19:34:04 +03:00
|
|
|
assert_code code , :b , [0xff,0xff,0xff,0xea] #ea ff ff fe
|
|
|
|
end
|
2014-05-14 10:47:30 +03:00
|
|
|
def test_call #see comment above. bx not implemented (as it means into thumb, and no thumb here)
|
2014-05-15 19:41:51 +03:00
|
|
|
code = @machine.call -4 ,{} #this jumps to the next instruction
|
2014-05-14 10:47:30 +03:00
|
|
|
assert_code code , :call, [0xff,0xff,0xff,0xeb] #ea ff ff fe
|
2014-04-19 19:34:04 +03:00
|
|
|
end
|
2014-04-18 15:49:23 +03:00
|
|
|
def test_swi
|
2014-05-18 11:11:26 +03:00
|
|
|
code = @machine.swi 0x05
|
2014-04-18 15:49:23 +03:00
|
|
|
assert_code code , :swi , [0x05,0x00,0x00,0xef]#ef 00 00 05
|
2014-04-17 20:24:37 +03:00
|
|
|
end
|
2014-04-14 15:58:59 +03:00
|
|
|
end
|