fix label loading in arm

was still loading the integer address
instead of the return address's address
Hello World working
This commit is contained in:
Torsten Ruger 2018-06-19 17:35:00 +03:00
parent 956c2ebe54
commit db459fcd3d
4 changed files with 6 additions and 3 deletions

View File

@ -91,6 +91,7 @@ module Arm
if( @left.is_a?(Parfait::Object) or @left.is_a?(Risc::Label) or if( @left.is_a?(Parfait::Object) or @left.is_a?(Risc::Label) or
(@left.is_a?(Symbol) and !Risc::RiscValue.look_like_reg(@left))) (@left.is_a?(Symbol) and !Risc::RiscValue.look_like_reg(@left)))
left = @left left = @left
left = left.address if left.is_a?(Risc::Label)
# do pc relative addressing with the difference to the instuction # do pc relative addressing with the difference to the instuction
# 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute) # 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute)
right = Risc::Position.get(left) - 8 right = Risc::Position.get(left) - 8

View File

@ -147,7 +147,7 @@ module Risc
end end
def self.set?(object) def self.set?(object)
self.positions.has_key?(object) self.positions[object]
end end
# get a position from the cache (object -> position) # get a position from the cache (object -> position)

View File

@ -90,7 +90,9 @@ module Arm
end end
def label( pos = 0x22 + 8) def label( pos = 0x22 + 8)
label = Risc::Label.new("some" , "Label" , FakeAddress.new(pos)) addr = FakeAddress.new(pos)
Risc::Position.new(addr).set(pos)
label = Risc::Label.new("some" , "Label" , addr)
Risc::Position.create(label).set(pos) Risc::Position.create(label).set(pos)
#Risc::Position.set(l , pos , @binary) #Risc::Position.set(l , pos , @binary)
label label

View File

@ -12,7 +12,7 @@ class HelloTest < MiniTest::Test
end end
def test_string_put def test_string_put
@input = "return 'Hello'.putstring" @input = "return 'Hello World!\n'.putstring"
check check
end end
end end