first working test (hurray) that checks a mov instruction
This commit is contained in:
parent
2e6b90b12e
commit
e47b1dcadd
@ -1,7 +1,33 @@
|
|||||||
require 'helper'
|
require_relative 'helper'
|
||||||
|
require "asm/arm/code_generator"
|
||||||
|
|
||||||
class TestCrystal < MiniTest::Unit::TestCase
|
# try to test that the generation of basic instructions works
|
||||||
def test_something_for_real
|
class TestAsm < MiniTest::Test
|
||||||
flunk "hey buddy, you should probably rename this file and start testing for real"
|
def setup
|
||||||
|
@generator = Asm::Arm::CodeGenerator.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_mov
|
||||||
|
m = @generator.instance_eval { mov r0, 5 }.first
|
||||||
|
assert_equal :mov , m.opcode
|
||||||
|
binary = @generator.assemble
|
||||||
|
assert_equal 4 , binary.length
|
||||||
|
should = [5,0,160,227]
|
||||||
|
index = 0
|
||||||
|
binary.each_byte do |byte |
|
||||||
|
assert_equal byte , should[index]
|
||||||
|
index += 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def saved_other
|
||||||
|
@generator.instance_eval do
|
||||||
|
mov r0, 5
|
||||||
|
loop_start = label
|
||||||
|
loop_start.set!
|
||||||
|
subs r0, r0, 1
|
||||||
|
bne loop_start
|
||||||
|
bx lr
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user