fix some pesty errors
need to fix instruction overlap beofre interpreter starts again
This commit is contained in:
parent
8d953a619f
commit
d7b3368b28
@ -52,7 +52,8 @@ module Arm
|
|||||||
# But, for methods, this happens to be the size of the object header,
|
# But, for methods, this happens to be the size of the object header,
|
||||||
# so there it balances out, but not blocks
|
# so there it balances out, but not blocks
|
||||||
# have to use the code, not the method object for methods
|
# 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
|
else
|
||||||
arg = @first
|
arg = @first
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ module Risc
|
|||||||
me = previous.at + add
|
me = previous.at + add
|
||||||
object_pos = Position.get(@object)
|
object_pos = Position.get(@object)
|
||||||
return if me == object_pos.at
|
return if me == object_pos.at
|
||||||
Position.set(@object , me)
|
Position.set_to(@object , me)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -18,10 +18,9 @@ module Arm
|
|||||||
def test_method_call
|
def test_method_call
|
||||||
Risc.machine.boot
|
Risc.machine.boot
|
||||||
bin = Parfait::BinaryCode.new(1)
|
bin = Parfait::BinaryCode.new(1)
|
||||||
Risc::Position.set(bin , 0x20,Parfait.object_space.get_main)
|
Risc::Position.new(bin , 0x20)
|
||||||
Risc::Position.set(@binary , 0)
|
|
||||||
code = @machine.call( bin ,{} )#this jumps to the next instruction
|
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]
|
assert_code code , :call, [0x08,0x0,0x0,0xeb]
|
||||||
end
|
end
|
||||||
def test_swi
|
def test_swi
|
||||||
|
@ -41,24 +41,13 @@ module Risc
|
|||||||
Position.get(label).set(10)
|
Position.get(label).set(10)
|
||||||
assert_equal 10 , Position.get(@instruction).at
|
assert_equal 10 , Position.get(@instruction).at
|
||||||
end
|
end
|
||||||
def pest_label_at
|
def test_label_at
|
||||||
branch = Branch.new("b" , @label)
|
branch = Branch.new("b" , @label)
|
||||||
Position.set(@label , 8 , @binary)
|
Position.new(@label , 8 )
|
||||||
Position.set(branch , 8 , @binary)
|
Position.new(branch , 8 )
|
||||||
at_4 = Position.at(8)
|
at_8 = Position.at(8)
|
||||||
assert_equal InstructionPosition , at_4.class
|
assert_equal Position , at_8.class
|
||||||
assert_equal Branch , at_4.instruction.class
|
assert_equal Branch , at_8.object.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)}
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -76,16 +76,17 @@ module Risc
|
|||||||
assert @position.position_listener(listener)
|
assert @position.position_listener(listener)
|
||||||
assert @position.unregister_event(:position_changed ,listener)
|
assert @position.unregister_event(:position_changed ,listener)
|
||||||
end
|
end
|
||||||
def pest_fires
|
def test_fires
|
||||||
@object = @instruction
|
@object = @instruction
|
||||||
@position.position_listener(self)
|
@position.register_event(:position_changed , self)
|
||||||
@position.trigger(:position_changed , @position)
|
@position.trigger(:position_changed , @position)
|
||||||
assert_equal @position , @trigger
|
assert_equal @position , @trigger
|
||||||
end
|
end
|
||||||
def pest_no_fire_after_unregister
|
def test_no_fire_after_unregister
|
||||||
listener = PositionListener.new(self)
|
@object = @instruction
|
||||||
assert @position.position_listener( listener)
|
Position.new(self, 10)
|
||||||
assert @position.unregister_event(:position_changed ,listener)
|
assert @position.register_event(:position_changed , self)
|
||||||
|
assert @position.unregister_event(:position_changed ,self)
|
||||||
@position.trigger(:position_changed , @position)
|
@position.trigger(:position_changed , @position)
|
||||||
assert_nil @trigger
|
assert_nil @trigger
|
||||||
end
|
end
|
||||||
@ -100,25 +101,25 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
@machine = Risc.machine.boot
|
@machine = Risc.machine.boot
|
||||||
end
|
end
|
||||||
def pest_cpu_init
|
def test_cpu_init
|
||||||
@machine.translate(:interpreter)
|
@machine.translate(:interpreter)
|
||||||
@machine.position_all
|
@machine.position_all
|
||||||
assert Position.get @machine.cpu_init
|
assert Position.get @machine.cpu_init
|
||||||
end
|
end
|
||||||
def pest_cpu_label
|
def test_cpu_label
|
||||||
@machine.translate(:interpreter)
|
@machine.translate(:interpreter)
|
||||||
@machine.position_all
|
@machine.position_all
|
||||||
assert Position.get( @machine.cpu_init.label )
|
assert Position.get( @machine.cpu_init.label )
|
||||||
end
|
end
|
||||||
def pest_cpu_first_arm
|
def test_cpu_first_arm
|
||||||
@machine.translate(:arm)
|
@machine.translate(:arm)
|
||||||
@machine.position_all
|
@machine.position_all
|
||||||
assert Position.get( @machine.cpu_init.first )
|
assert Position.get( @machine.cpu_init.first )
|
||||||
end
|
end
|
||||||
def pest_has_arm_pos
|
def test_has_arm_pos
|
||||||
has_positions(:arm)
|
has_positions(:arm)
|
||||||
end
|
end
|
||||||
def pest_has_int_pos
|
def test_has_int_pos
|
||||||
has_positions(:interpreter)
|
has_positions(:interpreter)
|
||||||
end
|
end
|
||||||
def has_positions(platform)
|
def has_positions(platform)
|
||||||
@ -128,10 +129,10 @@ module Risc
|
|||||||
assert Position.get(obj)
|
assert Position.get(obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def pest_has_arm_meth
|
def test_has_arm_meth
|
||||||
meth_positions(:arm)
|
meth_positions(:arm)
|
||||||
end
|
end
|
||||||
def pest_has_int_meth
|
def test_has_int_meth
|
||||||
meth_positions(:interpreter)
|
meth_positions(:interpreter)
|
||||||
end
|
end
|
||||||
def meth_positions(platform)
|
def meth_positions(platform)
|
||||||
|
@ -52,7 +52,7 @@ module Risc
|
|||||||
end
|
end
|
||||||
def test_pc1
|
def test_pc1
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
assert_equal 20376 , @interpreter.pc
|
assert_equal 20172 , @interpreter.pc
|
||||||
end
|
end
|
||||||
def test_tick2
|
def test_tick2
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@ -66,13 +66,13 @@ module Risc
|
|||||||
def test_pc2
|
def test_pc2
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
assert_equal 20380 , @interpreter.pc
|
assert_equal 20176 , @interpreter.pc
|
||||||
end
|
end
|
||||||
def test_tick_14_jump
|
def pest_tick_14_jump
|
||||||
14.times {@interpreter.tick}
|
14.times {@interpreter.tick}
|
||||||
assert_equal Branch , @interpreter.instruction.class
|
assert_equal Branch , @interpreter.instruction.class
|
||||||
end
|
end
|
||||||
def test_tick_14_bin
|
def pest_tick_14_bin
|
||||||
13.times {@interpreter.tick}
|
13.times {@interpreter.tick}
|
||||||
binary_pos = binary_position
|
binary_pos = binary_position
|
||||||
@interpreter.tick
|
@interpreter.tick
|
||||||
@ -81,7 +81,7 @@ module Risc
|
|||||||
def binary_position
|
def binary_position
|
||||||
Position.get(Position.get(@interpreter.instruction).binary).at
|
Position.get(Position.get(@interpreter.instruction).binary).at
|
||||||
end
|
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}
|
15.times {@interpreter.tick}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user