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)
|
add_type(cl.instance_type)
|
||||||
end
|
end
|
||||||
101.times { @integers = Integer.new(0,@integers) }
|
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)
|
message = Message.new(nil)
|
||||||
50.times do
|
50.times do
|
||||||
@messages = Message.new message
|
@messages = Message.new message
|
||||||
@ -69,9 +69,6 @@ module Parfait
|
|||||||
|
|
||||||
# hand out a return address for use as constant the address is added
|
# hand out a return address for use as constant the address is added
|
||||||
def get_address
|
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
|
addr = @next_address
|
||||||
@next_address = @next_address.next_integer
|
@next_address = @next_address.next_integer
|
||||||
addr
|
addr
|
||||||
|
@ -21,7 +21,7 @@ module Risc
|
|||||||
attr_reader :stdout, :state , :flags # somewhat like the lags on a cpu, hash sym => bool (zero .. . )
|
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
|
#start in state :stopped and set registers to unknown
|
||||||
def initialize()
|
def initialize( linker )
|
||||||
@stdout , @clock , @pc , @state = "", 0 , 0 , :stopped
|
@stdout , @clock , @pc , @state = "", 0 , 0 , :stopped
|
||||||
@registers = {}
|
@registers = {}
|
||||||
@flags = { :zero => false , :plus => false ,
|
@flags = { :zero => false , :plus => false ,
|
||||||
@ -29,11 +29,12 @@ module Risc
|
|||||||
(0...12).each do |reg|
|
(0...12).each do |reg|
|
||||||
set_register "r#{reg}".to_sym , "r#{reg}:unknown"
|
set_register "r#{reg}".to_sym , "r#{reg}:unknown"
|
||||||
end
|
end
|
||||||
|
@linker = linker
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_machine
|
def start_program
|
||||||
initialize
|
initialize
|
||||||
init = Risc.machine.cpu_init
|
init = @linker.cpu_init
|
||||||
set_state(:running)
|
set_state(:running)
|
||||||
set_pc( Position.get(init).at )
|
set_pc( Position.get(init).at )
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ module Risc
|
|||||||
@cpu_init = cpu_init_init
|
@cpu_init = cpu_init_init
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :constants
|
attr_reader :constants , :cpu_init
|
||||||
attr_reader :platform , :assemblers
|
attr_reader :platform , :assemblers
|
||||||
|
|
||||||
# machine keeps a list of all objects and their positions.
|
# machine keeps a list of all objects and their positions.
|
||||||
@ -104,7 +104,6 @@ module Risc
|
|||||||
|
|
||||||
def prerun
|
def prerun
|
||||||
assemblers.each do |asm|
|
assemblers.each do |asm|
|
||||||
puts "method #{asm.method.name}"
|
|
||||||
asm.instructions.each {|i| i.precheck }
|
asm.instructions.each {|i| i.precheck }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -104,7 +104,7 @@ module Parfait
|
|||||||
count += 1
|
count += 1
|
||||||
addr = addr.next_integer
|
addr = addr.next_integer
|
||||||
end
|
end
|
||||||
assert_equal 10, count
|
assert_equal 200, count
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_messages
|
def test_messages
|
||||||
|
@ -6,7 +6,7 @@ module Risc
|
|||||||
def setup
|
def setup
|
||||||
Parfait.boot!
|
Parfait.boot!
|
||||||
Risc.boot!
|
Risc.boot!
|
||||||
@linker = Linker.new
|
@linker = Mom::MomCompiler.new.translate(:arm)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_simple_collect
|
def test_simple_collect
|
||||||
|
@ -39,13 +39,13 @@ module Risc
|
|||||||
@linker.create_binary
|
@linker.create_binary
|
||||||
end
|
end
|
||||||
def test_pos_cpu
|
def test_pos_cpu
|
||||||
assert_equal 0 , Position.get(@machine.cpu_init).at
|
assert_equal 0 , Position.get(@linker.cpu_init).at
|
||||||
end
|
end
|
||||||
def test_cpu_at
|
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
|
end
|
||||||
def test_cpu_label
|
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
|
end
|
||||||
def test_first_binary_jump
|
def test_first_binary_jump
|
||||||
bin = Parfait.object_space.get_init.binary
|
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}"
|
assert 0 != bin.get_word(0) , "index 0 is 0 #{bin.inspect}"
|
||||||
end
|
end
|
||||||
def test_positions_set
|
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)}"
|
assert position.valid? , "#{position} , #{obj.object_id.to_s(16)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user