fix some pesty errors

need to fix instruction overlap beofre interpreter starts again
This commit is contained in:
Torsten Ruger 2018-06-05 19:05:12 +03:00
parent 8d953a619f
commit d7b3368b28
6 changed files with 30 additions and 40 deletions

View File

@ -52,7 +52,8 @@ module Arm
# But, for methods, this happens to be the size of the object header,
# so there it balances out, but not blocks
# have to use the code, not the method object for methods
arg = Risc::Position.get(@first) - Risc::Position.get(self)
f_pos = Risc::Position.get(@first)
arg = f_pos - Risc::Position.get(self)
else
arg = @first
end

View File

@ -24,7 +24,7 @@ module Risc
me = previous.at + add
object_pos = Position.get(@object)
return if me == object_pos.at
Position.set(@object , me)
Position.set_to(@object , me)
end
end
end

View File

@ -18,10 +18,9 @@ module Arm
def test_method_call
Risc.machine.boot
bin = Parfait::BinaryCode.new(1)
Risc::Position.set(bin , 0x20,Parfait.object_space.get_main)
Risc::Position.set(@binary , 0)
Risc::Position.new(bin , 0x20)
code = @machine.call( bin ,{} )#this jumps to the next instruction
Risc::Position.set(code , 0, @binary)
Risc::Position.new(code, 0)
assert_code code , :call, [0x08,0x0,0x0,0xeb]
end
def test_swi

View File

@ -41,24 +41,13 @@ module Risc
Position.get(label).set(10)
assert_equal 10 , Position.get(@instruction).at
end
def pest_label_at
def test_label_at
branch = Branch.new("b" , @label)
Position.set(@label , 8 , @binary)
Position.set(branch , 8 , @binary)
at_4 = Position.at(8)
assert_equal InstructionPosition , at_4.class
assert_equal Branch , at_4.instruction.class
end
def pest_label_at_reverse
branch = Branch.new("b" , @label)
Position.set(branch , 8 , @binary)
Position.set(@label , 8 , @binary)
at_4 = Position.at(8)
assert_equal InstructionPosition , at_4.class
assert_equal Branch , at_4.instruction.class
end
def pest_reset_false_type
assert_raises {Position.set(@label , 0 , @binary)}
Position.new(@label , 8 )
Position.new(branch , 8 )
at_8 = Position.at(8)
assert_equal Position , at_8.class
assert_equal Branch , at_8.object.class
end
end
end

View File

@ -76,16 +76,17 @@ module Risc
assert @position.position_listener(listener)
assert @position.unregister_event(:position_changed ,listener)
end
def pest_fires
def test_fires
@object = @instruction
@position.position_listener(self)
@position.register_event(:position_changed , self)
@position.trigger(:position_changed , @position)
assert_equal @position , @trigger
end
def pest_no_fire_after_unregister
listener = PositionListener.new(self)
assert @position.position_listener( listener)
assert @position.unregister_event(:position_changed ,listener)
def test_no_fire_after_unregister
@object = @instruction
Position.new(self, 10)
assert @position.register_event(:position_changed , self)
assert @position.unregister_event(:position_changed ,self)
@position.trigger(:position_changed , @position)
assert_nil @trigger
end
@ -100,25 +101,25 @@ module Risc
def setup
@machine = Risc.machine.boot
end
def pest_cpu_init
def test_cpu_init
@machine.translate(:interpreter)
@machine.position_all
assert Position.get @machine.cpu_init
end
def pest_cpu_label
def test_cpu_label
@machine.translate(:interpreter)
@machine.position_all
assert Position.get( @machine.cpu_init.label )
end
def pest_cpu_first_arm
def test_cpu_first_arm
@machine.translate(:arm)
@machine.position_all
assert Position.get( @machine.cpu_init.first )
end
def pest_has_arm_pos
def test_has_arm_pos
has_positions(:arm)
end
def pest_has_int_pos
def test_has_int_pos
has_positions(:interpreter)
end
def has_positions(platform)
@ -128,10 +129,10 @@ module Risc
assert Position.get(obj)
end
end
def pest_has_arm_meth
def test_has_arm_meth
meth_positions(:arm)
end
def pest_has_int_meth
def test_has_int_meth
meth_positions(:interpreter)
end
def meth_positions(platform)

View File

@ -52,7 +52,7 @@ module Risc
end
def test_pc1
@interpreter.tick
assert_equal 20376 , @interpreter.pc
assert_equal 20172 , @interpreter.pc
end
def test_tick2
@interpreter.tick
@ -66,13 +66,13 @@ module Risc
def test_pc2
@interpreter.tick
@interpreter.tick
assert_equal 20380 , @interpreter.pc
assert_equal 20176 , @interpreter.pc
end
def test_tick_14_jump
def pest_tick_14_jump
14.times {@interpreter.tick}
assert_equal Branch , @interpreter.instruction.class
end
def test_tick_14_bin
def pest_tick_14_bin
13.times {@interpreter.tick}
binary_pos = binary_position
@interpreter.tick
@ -81,7 +81,7 @@ module Risc
def binary_position
Position.get(Position.get(@interpreter.instruction).binary).at
end
def test_tick_15 #more than a binary code worth
def pest_tick_15 #more than a binary code worth
15.times {@interpreter.tick}
end
end