more work on large moves, including the notion of linking again

This commit is contained in:
Torsten Ruger
2014-09-17 17:00:19 +03:00
parent 4af93493fb
commit 49b6b99ab9
5 changed files with 45 additions and 47 deletions

View File

@ -1,5 +1,6 @@
module Register
class LinkException < Exception
end
# Assmble the object space into a binary.
# Link first to get positions, then assemble
# link and assemble functions for each class are close to each other, so to get them the same.
@ -36,20 +37,25 @@ module Register
end
def assemble
link
@stream = StringIO.new
mid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
puts "function found #{main.name}"
initial_jump = RegisterMachine.instance.b( main )
initial_jump.set_position( 0)
initial_jump.assemble( @stream )
@objects.each_value do |objekt|
next unless objekt.is_a? Virtual::CompiledMethod
assemble_object( objekt )
end
@objects.each_value do | objekt|
next if objekt.is_a? Virtual::CompiledMethod
assemble_object( objekt )
begin
link
@stream = StringIO.new
mid , main = @objects.find{|k,objekt| objekt.is_a?(Virtual::CompiledMethod) and (objekt.name == :__init__ )}
puts "function found #{main.name}"
initial_jump = RegisterMachine.instance.b( main )
initial_jump.set_position( 0)
initial_jump.assemble( @stream )
@objects.each_value do |objekt|
next unless objekt.is_a? Virtual::CompiledMethod
assemble_object( objekt )
end
@objects.each_value do | objekt|
next if objekt.is_a? Virtual::CompiledMethod
assemble_object( objekt )
end
rescue LinkException => e
puts "coought #{e}"
retry
end
puts "Assembled #{@stream.length.to_s(16)}"
return @stream.string

View File

@ -1,4 +1,3 @@
require_relative "code"
module Register
# The register machine model is close to current hardware and has following instruction classes