pass binary that arm instruction belongs to in
at least to first. repositioning and stuff next
This commit is contained in:
parent
415df49199
commit
e89c4d1ce1
@ -23,11 +23,12 @@ module Arm
|
|||||||
|
|
||||||
def insert(instruction)
|
def insert(instruction)
|
||||||
super
|
super
|
||||||
@next.set_position( Risc::Position.position(self) + self.byte_length , 0) #FIXME
|
my_pos = Risc::Position.position(self)
|
||||||
|
@next.set_position( my_pos + self.byte_length , 0 , my_pos.binary)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_position( position , count )
|
def set_position( position , count , extra = nil)
|
||||||
Risc::Position.set_position(self,position)
|
Risc::Position.set_position(self,position , extra)
|
||||||
position += byte_length
|
position += byte_length
|
||||||
if self.next
|
if self.next
|
||||||
count += 1 #assumes 4 byte instructions, as does the whole setup
|
count += 1 #assumes 4 byte instructions, as does the whole setup
|
||||||
@ -35,7 +36,7 @@ module Arm
|
|||||||
count = 0
|
count = 0
|
||||||
position += 12 # 12=3*4 , 3 for marker,type,next words to jump over
|
position += 12 # 12=3*4 , 3 for marker,type,next words to jump over
|
||||||
end
|
end
|
||||||
self.next.set_position( position , count )
|
self.next.set_position( position , count , extra)
|
||||||
else
|
else
|
||||||
position
|
position
|
||||||
end
|
end
|
||||||
|
@ -45,9 +45,9 @@ module Risc
|
|||||||
end
|
end
|
||||||
|
|
||||||
# labels have the same position as their next
|
# labels have the same position as their next
|
||||||
def set_position( position , count = 0)
|
def set_position( position , count = 0 , extra = nil)
|
||||||
Position.set_position(self,position)
|
Position.set_position(self,position , extra)
|
||||||
self.next.set_position(position,count) if self.next
|
self.next.set_position(position,count,extra) if self.next
|
||||||
end
|
end
|
||||||
|
|
||||||
# shame we need this, just for logging
|
# shame we need this, just for logging
|
||||||
|
@ -78,7 +78,7 @@ module Risc
|
|||||||
translate_arm unless @translated
|
translate_arm unless @translated
|
||||||
#need the initial jump at 0 and then functions
|
#need the initial jump at 0 and then functions
|
||||||
Position.set_position(binary_init,0)
|
Position.set_position(binary_init,0)
|
||||||
cpu_init.set_position( 12 ,0)
|
cpu_init.set_position( 12 ,0 , binary_init)
|
||||||
@code_start = position_objects( binary_init.padded_length )
|
@code_start = position_objects( binary_init.padded_length )
|
||||||
# and then everything code
|
# and then everything code
|
||||||
position_code
|
position_code
|
||||||
@ -110,7 +110,7 @@ module Risc
|
|||||||
at = @code_start
|
at = @code_start
|
||||||
objects.each do |id , method|
|
objects.each do |id , method|
|
||||||
next unless method.is_a? Parfait::TypedMethod
|
next unless method.is_a? Parfait::TypedMethod
|
||||||
method.cpu_instructions.set_position( at + 12)
|
method.cpu_instructions.set_position( at + 12 , 0 , method.binary)
|
||||||
before = at
|
before = at
|
||||||
nekst = method.binary
|
nekst = method.binary
|
||||||
while(nekst)
|
while(nekst)
|
||||||
|
@ -36,12 +36,14 @@ module Risc
|
|||||||
"0x#{@at.to_s(16)}"
|
"0x#{@at.to_s(16)}"
|
||||||
end
|
end
|
||||||
def reset_to(pos)
|
def reset_to(pos)
|
||||||
|
return false if pos == at
|
||||||
if((at - pos).abs > 1000)
|
if((at - pos).abs > 1000)
|
||||||
raise "position set too far off #{pos}!=#{at} for #{object}:#{object.class}"
|
raise "position set too far off #{pos}!=#{at} for #{object}:#{object.class}"
|
||||||
end
|
end
|
||||||
@at = pos
|
@at = pos
|
||||||
self
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.positions
|
def self.positions
|
||||||
@positions
|
@positions
|
||||||
end
|
end
|
||||||
@ -62,7 +64,10 @@ module Risc
|
|||||||
# in measures (of 32)
|
# in measures (of 32)
|
||||||
#puts "Setting #{pos} for #{self.class}"
|
#puts "Setting #{pos} for #{self.class}"
|
||||||
old = Position.positions[object]
|
old = Position.positions[object]
|
||||||
return old.reset_to(pos) if old != nil
|
if old != nil
|
||||||
|
old.reset_to(pos)
|
||||||
|
return old
|
||||||
|
end
|
||||||
self.positions[object] = for_at( object , pos , extra)
|
self.positions[object] = for_at( object , pos , extra)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -71,7 +76,7 @@ module Risc
|
|||||||
when Parfait::BinaryCode
|
when Parfait::BinaryCode
|
||||||
BPosition.new(object,at , extra)
|
BPosition.new(object,at , extra)
|
||||||
when Arm::Instruction , Risc::Label
|
when Arm::Instruction , Risc::Label
|
||||||
IPosition.new(object,at)
|
IPosition.new(object,at , extra)
|
||||||
else
|
else
|
||||||
Position.new(at)
|
Position.new(at)
|
||||||
end
|
end
|
||||||
@ -79,11 +84,22 @@ module Risc
|
|||||||
end
|
end
|
||||||
# handle event propagation
|
# handle event propagation
|
||||||
class IPosition < Position
|
class IPosition < Position
|
||||||
attr_reader :instruction
|
attr_reader :instruction , :binary
|
||||||
def initialize(instruction, pos)
|
def initialize(instruction, pos , binary)
|
||||||
|
raise "not set " unless binary
|
||||||
super(pos)
|
super(pos)
|
||||||
@instruction = instruction
|
@instruction = instruction
|
||||||
|
@binary = binary
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reset_to(pos)
|
||||||
|
changed = super(pos)
|
||||||
|
puts "Reset (#{changed}) #{instruction}"
|
||||||
|
return unless changed
|
||||||
|
return unless instruction.next
|
||||||
|
instruction.next.set_position( pos + instruction.byte_length , 0)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
class BPosition < Position
|
class BPosition < Position
|
||||||
attr_reader :code , :method
|
attr_reader :code , :method
|
||||||
|
Loading…
Reference in New Issue
Block a user