From 633e99466da55406ca64611063b252cf572435d6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 26 Mar 2018 13:43:26 +0300 Subject: [PATCH] start to debug --- lib/risc/assembler.rb | 13 ++++++++----- lib/risc/positioned.rb | 3 ++- test/risc/test_assembler.rb | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/risc/assembler.rb b/lib/risc/assembler.rb index e5f7599c..49bdc2a4 100644 --- a/lib/risc/assembler.rb +++ b/lib/risc/assembler.rb @@ -58,7 +58,10 @@ module Risc at += 8 # thats the padding # want to have the objects first in the executable @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 Positioned.set_position(objekt,at) at += objekt.padded_length @@ -132,10 +135,10 @@ module Risc # and then plonk that binary data into the method.code array def assemble_binary_method method stream = StringIO.new - #puts "Method #{method.source.risc_instructions.to_ac}" + #puts "Method #{method.source.cpu_instructions.to_ac}" begin - #puts "assemble #{method.source.risc_instructions}" - method.risc_instructions.assemble_all( stream ) + #puts "assemble #{method.source.cpu_instructions}" + method.cpu_instructions.assemble_all( stream ) rescue => e log.debug "Assembly error #{method.name}\n#{method.to_rxf.to_s[0...2000]}" raise e @@ -155,7 +158,7 @@ module Risc stream.rewind length = stream.length 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}" 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 diff --git a/lib/risc/positioned.rb b/lib/risc/positioned.rb index 34063db2..2854c622 100644 --- a/lib/risc/positioned.rb +++ b/lib/risc/positioned.rb @@ -11,7 +11,8 @@ module Positioned if pos == nil str = "position accessed but not set, " 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 pos end diff --git a/test/risc/test_assembler.rb b/test/risc/test_assembler.rb index 7b0261e5..f12cb16d 100644 --- a/test/risc/test_assembler.rb +++ b/test/risc/test_assembler.rb @@ -33,10 +33,10 @@ module Risc assert @machine.translate_arm assert @assembler.assemble end - def pest_write_space + def test_write_space @assembler = Assembler.new(@machine , Collector.collect_space) assert @machine.translate_arm - assert @assembler.write_as_string + #assert @assembler.write_as_string end end end