trying to fix the darn jump over object header
This commit is contained in:
parent
8d8cc4b016
commit
ddd408e245
@ -26,4 +26,14 @@ module Risc
|
||||
end
|
||||
end
|
||||
|
||||
#even less glue to get that last jump in there.
|
||||
# So instructions don't run into the BinaryCode object header
|
||||
class JumpWriter
|
||||
def initialize( code )
|
||||
@code = code
|
||||
end
|
||||
def write_unsigned_int_32( bin )
|
||||
@code.set_word( 14 , bin )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -18,10 +18,12 @@ module Risc
|
||||
@method = method
|
||||
raise "Method nil" unless method
|
||||
end
|
||||
def init(at)
|
||||
def init(at , method)
|
||||
raise "No no" unless method.name == @method.name
|
||||
next_pos = at + code.padded_length
|
||||
if code.next
|
||||
Position.set(code.next , next_pos, method)
|
||||
set_jump(at)
|
||||
else
|
||||
next_meth = next_method
|
||||
return unless next_meth
|
||||
@ -30,11 +32,22 @@ module Risc
|
||||
Position.set( next_meth.cpu_instructions, next_cpu_pos , next_meth.binary)
|
||||
end
|
||||
end
|
||||
def reset_to(pos)
|
||||
init(pos)
|
||||
super(pos)
|
||||
def reset_to(pos , ignored)
|
||||
super(pos, ignored)
|
||||
init(pos , ignored)
|
||||
Position.log.debug "ResetCode (#{pos.to_s(16)}) #{code}"
|
||||
end
|
||||
# insert a jump to the next instruction, at the last instruction
|
||||
# thus hopping over the object header
|
||||
def set_jump(at)
|
||||
jump = Branch.new("BinaryCode #{at.to_s(16)}" , code.next)
|
||||
translator = Risc.machine.platform.translator
|
||||
cpu_jump = translator.translate(jump)
|
||||
pos = at + code.padded_length - cpu_jump.byte_length
|
||||
Position.set( cpu_jump , pos , code)
|
||||
cpu_jump.assemble(JumpWriter.new(code))
|
||||
end
|
||||
|
||||
def next_method
|
||||
next_m = @method.next_method
|
||||
return next_m if next_m
|
||||
|
@ -22,14 +22,15 @@ module Risc
|
||||
@instruction = instruction
|
||||
@binary = binary
|
||||
end
|
||||
def init(at)
|
||||
def init(at, binary)
|
||||
return if at == 0 and binary.nil?
|
||||
return unless @instruction.next
|
||||
@binary = binary
|
||||
nekst = at + @instruction.byte_length
|
||||
diff = nekst - Position.get(@binary).at
|
||||
Position.log.debug "Diff: #{diff.to_s(16)} , next #{nekst.to_s(16)} , binary #{Position.get(@binary)}"
|
||||
raise "Invalid position #{diff.to_s(16)} , next #{nekst.to_s(16)} #{self}" if diff < 8
|
||||
if( (diff % @binary.padded_length ) == 0 )
|
||||
if( (diff % (@binary.padded_length - @instruction.byte_length)) == 0 )
|
||||
@binary.extend_one unless @binary.next
|
||||
@binary = @binary.next
|
||||
raise "end of line " unless @binary
|
||||
@ -39,9 +40,9 @@ module Risc
|
||||
Position.set(@instruction.next, nekst , @binary)
|
||||
end
|
||||
|
||||
def reset_to(pos)
|
||||
init(pos)
|
||||
super(pos)
|
||||
def reset_to(pos , binary)
|
||||
super(pos , binary)
|
||||
init(pos , binary)
|
||||
Position.log.debug "ResetInstruction (#{pos.to_s(16)}) #{instruction}"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user