diff --git a/lib/arm/instructions/move_instruction.rb b/lib/arm/instructions/move_instruction.rb index 4eda03e8..f442faa2 100644 --- a/lib/arm/instructions/move_instruction.rb +++ b/lib/arm/instructions/move_instruction.rb @@ -18,6 +18,9 @@ module Arm @immediate = 0 @rn = :r0 # register zero = zero bit pattern @extra = nil + if @rn.is_a?(Numeric) and !@rn.fits_u8? and !calculate_u8_with_rr(@rn) + @extra = 1 + end end attr_accessor :to , :from diff --git a/lib/register/assembler.rb b/lib/register/assembler.rb index aa6b37bb..6f721818 100644 --- a/lib/register/assembler.rb +++ b/lib/register/assembler.rb @@ -105,8 +105,8 @@ module Register method.info.blocks.each do |block| block.codes.each do |code| begin - code.assemble( stream ) - rescue => e + code.assemble( stream ) + rescue => e puts "Method error #{method.name}\n#{Sof.write(method.info.blocks).to_s[0...2000]}" puts Sof.write(code) raise e @@ -118,7 +118,7 @@ module Register stream.rewind #puts "Assembled #{method.name} with length #{stream.length}" raise "length error #{method.code.length} != #{method.info.byte_length}" if method.code.length != method.info.byte_length - raise "length error #{stream.length} != #{method.info.byte_length}" if method.info.byte_length - stream.length > 32 + raise "length error #{stream.length} != #{method.info.byte_length}" if method.info.byte_length - stream.length > 6 stream.each_byte do |b| method.code.set_char(index , b ) index = index + 1 diff --git a/lib/virtual/compiled_method_info.rb b/lib/virtual/compiled_method_info.rb index 4c4dbc9f..0065eca8 100644 --- a/lib/virtual/compiled_method_info.rb +++ b/lib/virtual/compiled_method_info.rb @@ -136,7 +136,7 @@ module Virtual end def byte_length - @blocks.inject(0) { |c , block| c += block.byte_length } + 8 + @blocks.inject(0) { |c , block| c += block.byte_length } + 4 end # position of the function is the position of the entry block, is where we call diff --git a/test/virtual/test_padding.rb b/test/virtual/test_padding.rb index 77f5936c..d7182c4a 100644 --- a/test/virtual/test_padding.rb +++ b/test/virtual/test_padding.rb @@ -14,24 +14,32 @@ class TestPadding < MiniTest::Test assert_equal 32 , @pad.padded(p) , "Expecting 32 for #{p}" end end - def test_large + def test_medium [26,40,53,56].each do |p| assert_equal 64 , @pad.padded(p) , "Expecting 64 for #{p}" end end +def test_large + [58,88].each do |p| + assert_equal 96 , @pad.padded(p) , "Expecting 96 for #{p}" + end +end end class TestPositioning < MiniTest::Test def test_list1 list = Virtual.new_list([1]) + list.set_layout( Parfait::Layout.new Object) assert_equal 32 , list.word_length end def test_list5 list = Virtual.new_list([1,2,3,4,5]) + list.set_layout( Parfait::Layout.new Object) assert_equal 32 , list.word_length end def test_layout layout = Parfait::Layout.new Object + layout.set_layout( Parfait::Layout.new Object) layout.push 5 assert_equal 32 , layout.word_length end