fix frame indexes

This commit is contained in:
Torsten Ruger 2015-06-28 10:50:47 +03:00
parent ef42abe611
commit a00a49ecdb
4 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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