diff --git a/lib/risc/position/instruction_position.rb b/lib/risc/position/instruction_position.rb index 2b06d7da..14611b6d 100644 --- a/lib/risc/position/instruction_position.rb +++ b/lib/risc/position/instruction_position.rb @@ -24,6 +24,7 @@ module Risc end def init(at, binary) @binary = binary + instruction.integer.set_value(at) if instruction.is_a?(Label) return if at == 0 and binary.nil? raise "faux pas" if at < Position.get(binary).at return unless @instruction.next diff --git a/test/risc/position/test_instruction_position.rb b/test/risc/position/test_instruction_position.rb index 3140094d..8081111b 100644 --- a/test/risc/position/test_instruction_position.rb +++ b/test/risc/position/test_instruction_position.rb @@ -14,6 +14,15 @@ module Risc pos = Position.set( @label , 8 , @binary) assert_equal InstructionPosition , pos.class end + def test_label_set_int + Position.set( @label , 8 , @binary) + assert_equal 8 , @label.integer.value + end + def test_label_reset_int + Position.set( @label , 8 , @binary) + Position.set( @label , 18 , @binary) + assert_equal 18 , @label.integer.value + end def test_ins_propagates @label.set_next Arm::ArmMachine.b( @label) Position.set( @label , 8 , @binary)