start to debug

This commit is contained in:
Torsten Ruger 2018-03-26 13:43:26 +03:00
parent 865a116f47
commit 633e99466d
3 changed files with 12 additions and 8 deletions

View File

@ -58,7 +58,10 @@ module Risc
at += 8 # thats the padding at += 8 # thats the padding
# want to have the objects first in the executable # want to have the objects first in the executable
@objects.each do | id , objekt| @objects.each do | id , objekt|
next if objekt.is_a? Risc::Label # will get assembled as method.risc_instructions if objekt.is_a? Risc::Label # will get assembled as method.cpu_instructions
Positioned.set_position(objekt,at)
next
end
next if objekt.is_a? Parfait::BinaryCode next if objekt.is_a? Parfait::BinaryCode
Positioned.set_position(objekt,at) Positioned.set_position(objekt,at)
at += objekt.padded_length at += objekt.padded_length
@ -132,10 +135,10 @@ module Risc
# and then plonk that binary data into the method.code array # and then plonk that binary data into the method.code array
def assemble_binary_method method def assemble_binary_method method
stream = StringIO.new stream = StringIO.new
#puts "Method #{method.source.risc_instructions.to_ac}" #puts "Method #{method.source.cpu_instructions.to_ac}"
begin begin
#puts "assemble #{method.source.risc_instructions}" #puts "assemble #{method.source.cpu_instructions}"
method.risc_instructions.assemble_all( stream ) method.cpu_instructions.assemble_all( stream )
rescue => e rescue => e
log.debug "Assembly error #{method.name}\n#{method.to_rxf.to_s[0...2000]}" log.debug "Assembly error #{method.name}\n#{method.to_rxf.to_s[0...2000]}"
raise e raise e
@ -155,7 +158,7 @@ module Risc
stream.rewind stream.rewind
length = stream.length length = stream.length
binary = method.binary binary = method.binary
total_byte_length = method.risc_instructions.total_byte_length total_byte_length = method.cpu_instructions.total_byte_length
log.debug "Assembled code #{method.name} with length #{length}" log.debug "Assembled code #{method.name} with length #{length}"
raise "length error #{binary.char_length} != #{total_byte_length}" if binary.char_length <= total_byte_length raise "length error #{binary.char_length} != #{total_byte_length}" if binary.char_length <= total_byte_length
raise "length error #{length} != #{total_byte_length}" if total_byte_length != length raise "length error #{length} != #{total_byte_length}" if total_byte_length != length

View File

@ -11,7 +11,8 @@ module Positioned
if pos == nil if pos == nil
str = "position accessed but not set, " str = "position accessed but not set, "
str += "#{object.object_id.to_s(16)}\n" str += "#{object.object_id.to_s(16)}\n"
raise str + "for #{object.class} byte_length #{object.byte_length if object.respond_to?(:byte_length)} for #{object.inspect[0...100]}" str += "for #{object.class} byte_length #{object.byte_length if object.respond_to?(:byte_length)} for #{object.inspect[0...100]}"
raise str
end end
pos pos
end end

View File

@ -33,10 +33,10 @@ module Risc
assert @machine.translate_arm assert @machine.translate_arm
assert @assembler.assemble assert @assembler.assemble
end end
def pest_write_space def test_write_space
@assembler = Assembler.new(@machine , Collector.collect_space) @assembler = Assembler.new(@machine , Collector.collect_space)
assert @machine.translate_arm assert @machine.translate_arm
assert @assembler.write_as_string #assert @assembler.write_as_string
end end
end end
end end