linker and collector test work again
had to give space a fixed number of addresses
This commit is contained in:
parent
4e49c0469c
commit
474cd4b348
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user