diff --git a/lib/parfait/space.rb b/lib/parfait/space.rb index 80d2096c..67e7c36e 100644 --- a/lib/parfait/space.rb +++ b/lib/parfait/space.rb @@ -38,7 +38,7 @@ module Parfait add_type(cl.instance_type) end 101.times { @integers = Integer.new(0,@integers) } - 10.times { @addresses = ReturnAddress.new(0,@addresses) } + 200.times { @addresses = ReturnAddress.new(0,@addresses) } message = Message.new(nil) 50.times do @messages = Message.new message @@ -69,9 +69,6 @@ module Parfait # hand out a return address for use as constant the address is added def get_address - 10.times do # 10 for whole pages - @next_address = ReturnAddress.new(0,@next_address) - end unless @next_address.next_integer addr = @next_address @next_address = @next_address.next_integer addr diff --git a/lib/risc/interpreter.rb b/lib/risc/interpreter.rb index a1069353..2e67dec1 100644 --- a/lib/risc/interpreter.rb +++ b/lib/risc/interpreter.rb @@ -21,7 +21,7 @@ module Risc attr_reader :stdout, :state , :flags # somewhat like the lags on a cpu, hash sym => bool (zero .. . ) #start in state :stopped and set registers to unknown - def initialize() + def initialize( linker ) @stdout , @clock , @pc , @state = "", 0 , 0 , :stopped @registers = {} @flags = { :zero => false , :plus => false , @@ -29,11 +29,12 @@ module Risc (0...12).each do |reg| set_register "r#{reg}".to_sym , "r#{reg}:unknown" end + @linker = linker end - def start_machine + def start_program initialize - init = Risc.machine.cpu_init + init = @linker.cpu_init set_state(:running) set_pc( Position.get(init).at ) end diff --git a/lib/risc/linker.rb b/lib/risc/linker.rb index a3e0eccc..6b8d053e 100644 --- a/lib/risc/linker.rb +++ b/lib/risc/linker.rb @@ -25,7 +25,7 @@ module Risc @cpu_init = cpu_init_init end - attr_reader :constants + attr_reader :constants , :cpu_init attr_reader :platform , :assemblers # machine keeps a list of all objects and their positions. @@ -104,7 +104,6 @@ module Risc def prerun assemblers.each do |asm| - puts "method #{asm.method.name}" asm.instructions.each {|i| i.precheck } end end diff --git a/test/parfait/test_space.rb b/test/parfait/test_space.rb index 8b2a27ab..0d61a8fe 100644 --- a/test/parfait/test_space.rb +++ b/test/parfait/test_space.rb @@ -104,7 +104,7 @@ module Parfait count += 1 addr = addr.next_integer end - assert_equal 10, count + assert_equal 200, count end def test_messages diff --git a/test/risc/test_collector.rb b/test/risc/test_collector.rb index 0a15ffbd..d67e1f84 100644 --- a/test/risc/test_collector.rb +++ b/test/risc/test_collector.rb @@ -6,7 +6,7 @@ module Risc def setup Parfait.boot! Risc.boot! - @linker = Linker.new + @linker = Mom::MomCompiler.new.translate(:arm) end def test_simple_collect diff --git a/test/risc/test_linker.rb b/test/risc/test_linker.rb index 87919466..62660cab 100644 --- a/test/risc/test_linker.rb +++ b/test/risc/test_linker.rb @@ -39,13 +39,13 @@ module Risc @linker.create_binary end def test_pos_cpu - assert_equal 0 , Position.get(@machine.cpu_init).at + assert_equal 0 , Position.get(@linker.cpu_init).at end def test_cpu_at - assert_equal "0x6034" , Position.get(@machine.cpu_init.first).to_s + assert_equal "0x624c" , Position.get(@linker.cpu_init.first).to_s end def test_cpu_label - assert_equal Position , Position.get(@machine.cpu_init.first).class + assert_equal Position , Position.get(@linker.cpu_init.first).class end def test_first_binary_jump bin = Parfait.object_space.get_init.binary @@ -56,7 +56,7 @@ module Risc assert 0 != bin.get_word(0) , "index 0 is 0 #{bin.inspect}" end def test_positions_set - @machine.object_positions.each do |obj,position| + @linker.object_positions.each do |obj,position| assert position.valid? , "#{position} , #{obj.object_id.to_s(16)}" end end