write adjusted address

and rename integer to address in label
1k hurray
This commit is contained in:
Torsten Ruger
2018-05-31 00:07:58 +03:00
parent e39e96f646
commit 67100a3ef8
10 changed files with 36 additions and 23 deletions

View File

@ -91,7 +91,7 @@ module Arm
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 = @left
left = @left.integer if left.is_a?(Risc::Label)
left = @left.address if left.is_a?(Risc::Label)
# do pc relative addressing with the difference to the instuction
# 8 is for the funny pipeline adjustment (ie pointing to fetch and not execute)
right = Risc::Position.get(left) - Risc::Position.get(self) - 8

View File

@ -13,7 +13,7 @@ module Arm
end
def translate_Label( code )
Risc.label( code.source , code.name , code.integer)
Risc.label( code.source , code.name , code.address)
end
# arm indexes are

View File

@ -7,7 +7,7 @@ module Risc
# So branches and Labels are pairs, fan out, fan in
#
# For a return, the address (position) of the label has to be loaded.
# So a Label carries the Integer constant that holds the address (it's own
# So a Label carries the ReturnAddress constant that holds the address (it's own
# position, again see positioning code).
# But currently the label is used in the Risc abstraction layer, and in the
# arm/interpreter layer. The integer is only used in the lower layer, but needs
@ -15,13 +15,13 @@ module Risc
class Label < Instruction
# See class description. also factory method Risc.label below
def initialize( source , name , int , nekst = nil)
def initialize( source , name , addr , nekst = nil)
super(source , nekst)
@name = name
@integer = int
raise "Not int #{int}" unless int.is_a?(Parfait::Integer)
@address = addr
raise "Not address #{addr}" unless addr.is_a?(Parfait::ReturnAddress)
end
attr_reader :name , :integer
attr_reader :name , :address
def to_cpu(translator)
@cpu_label ||= super
@ -65,9 +65,7 @@ module Risc
# An integer is plucked from object_space abd added to the machine constant pool
# if none was given
def self.label( source , name , position = nil , nekst = nil)
unless position
position = Risc.machine.get_address
end
position = Risc.machine.get_address unless position
Label.new( source , name , position, nekst )
end
end

View File

@ -141,7 +141,7 @@ module Risc
def execute_LoadConstant
to = @instruction.register
value = @instruction.constant
value = value.integer if value.is_a?(Label)
value = value.address if value.is_a?(Label)
set_register( to , value )
true
end

View File

@ -24,7 +24,7 @@ module Risc
end
def init(at, binary)
@binary = binary
instruction.integer.set_value(at) if instruction.is_a?(Label)
instruction.address.set_value(at) if instruction.is_a?(Label)
return if at == 0 and binary.nil?
raise "faux pas" if at < Position.get(binary).at
return unless @instruction.next

View File

@ -90,13 +90,15 @@ module Risc
when Parfait::Word, Symbol
write_String obj
when Parfait::BinaryCode
write_BinaryCode obj
write_BinaryCode( obj )
when Parfait::ReturnAddress
write_return_address( obj )
when Parfait::Integer
write_integer obj
write_integer( obj )
when Parfait::Data4
write_data4 obj
write_data4( obj )
else
write_object obj
write_object( obj )
end
end
@ -145,6 +147,14 @@ module Risc
written
end
def write_return_address( addr )
write_ref_for( addr.get_type )
write_ref_for( addr.next_integer )
write_ref_for( addr.value + @machine.platform.loaded_at )
write_ref_for( 0 )
log.debug "Integer witten stream 0x#{@stream.length.to_s(16)}"
end
def write_integer( int )
write_ref_for( int.get_type )
write_ref_for( int.next_integer )