make the instructions jump over the BinaryCode end

This commit is contained in:
Torsten Ruger
2018-06-07 19:27:44 +03:00
parent 2d218bbc48
commit 5815d32bde
5 changed files with 38 additions and 18 deletions

View File

@ -5,7 +5,7 @@ module Risc
def setup
Risc.machine.boot
@binary = Parfait::BinaryCode.new(1)
@bin_pos = Position.new(@binary,0)
@bin_pos = CodeListener.init(@binary,0)
@instruction = DummyInstruction.new
13.times {@instruction.last.insert(DummyInstruction.new) }
@position = InstructionListener.init(@instruction , @binary)
@ -28,5 +28,10 @@ module Risc
@instruction.insert DummyInstruction.new
assert_equal 76 , Position.get(@instruction.last).at
end
def test_pushes_after_insert
@instruction.insert DummyInstruction.new
@position.set(12)
assert_equal 80 , Position.get(@instruction.last).at
end
end
end

View File

@ -28,6 +28,12 @@ module Risc
pos = @pos.set(10)
assert_equal 10 , pos
end
def test_object_class_test
assert_equal :object , @pos.object_class
end
def test_object_class_instr
assert_equal :instruction , Position.new(Label.new("hi","ho",FakeAddress.new(1)),4).object_class
end
def test_at
pos = Position.at(5)
assert_equal 5 , pos.at