fixed that darn method address bug

This commit is contained in:
Torsten Ruger 2015-07-01 09:47:10 +03:00
parent 9541712af8
commit 047c77e186
5 changed files with 6 additions and 9 deletions

View File

@ -44,7 +44,6 @@ module Arm
# so there it balances out, but not blocks
# have to use the code, not the mthod object for methods
diff = arg.code.position - self.position
diff -= 4 if diff > 0 # hmm, stil having troubles with this one. but it works :-)
end
arg = diff
end

View File

@ -48,6 +48,7 @@ module Arm
#TODO this is copied from MoveInstruction, should rework
unless @extra
@extra = 1
puts "RELINK L at #{self.position.to_s(16)}"
raise ::Register::LinkException.new("cannot fit numeric literal argument in operand #{right.inspect}")
end
# now we can do the actual breaking of instruction, by splitting the operand
@ -87,7 +88,7 @@ module Arm
val << by
end
def word_length
def byte_length
@extra ? 8 : 4
end

View File

@ -18,9 +18,6 @@ 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
@ -31,7 +28,7 @@ module Arm
# alas, full transparency is not achieved as we only know when to use 2 instruction once we
# know where the other object is, and that position is only set after code positions have been
# determined (in link) and so see below in assemble
def word_length
def byte_length
@extra ? 8 : 4
end
@ -65,6 +62,7 @@ module Arm
# then on subsequent assemblies we can assemble
unless @extra
@extra = 1
puts "RELINK M at #{self.position.to_s(16)}"
raise ::Register::LinkException.new("cannot fit numeric literal argument in operand #{right.inspect}")
end
# now we can do the actual breaking of instruction, by splitting the operand

View File

@ -60,7 +60,6 @@ module Register
begin
return try_write
rescue LinkException
puts "RELINK"
# knowing that we fix the problem, we hope to get away with retry.
return try_write
end
@ -123,7 +122,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 > 6
raise "length error #{stream.length} != #{method.info.byte_length}" if method.info.byte_length != stream.length
stream.each_byte do |b|
method.code.set_char(index , b )
index = index + 1

View File

@ -137,7 +137,7 @@ module Virtual
end
def byte_length
@blocks.inject(0) { |c , block| c += block.byte_length } + 4
@blocks.inject(0) { |c , block| c += block.byte_length }
end
# position of the function is the position of the entry block, is where we call