jump was written off the end of binary code, fixed

This commit is contained in:
Torsten Ruger
2018-05-28 11:45:04 +03:00
parent 1c09d4202f
commit be1bc63ff2
10 changed files with 58 additions and 27 deletions

View File

@ -27,13 +27,13 @@ module Risc
end
#even less glue to get that last jump in there.
# So instructions don't run into the BinaryCode object header
# 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 )
@code.set_last( bin )
end
end
end

View File

@ -108,7 +108,7 @@ module Risc
Position.set( first_method.binary , at , first_method)
Position.set( first_method.cpu_instructions, at + Parfait::BinaryCode.offset , first_method.binary)
log.debug "Method #{first_method.name}:#{before.to_s(16)} len: #{(at - before).to_s(16)}"
log.debug "Instructions #{first_method.cpu_instructions.object_id.to_s(16)}:#{(before+12).to_s(16)}"
log.debug "Instructions #{first_method.cpu_instructions.object_id.to_s(16)}:#{(before+Parfait::BinaryCode.offset).to_s(16)}"
at
end

View File

@ -33,8 +33,8 @@ module Risc
end
end
def reset_to(pos , ignored)
super(pos, ignored)
init(pos , ignored)
super(pos, ignored)
Position.log.debug "ResetCode (#{pos.to_s(16)}) #{code}"
end
# insert a jump to the next instruction, at the last instruction

View File

@ -24,7 +24,7 @@ module Risc
end
def init(at, binary)
return if at == 0 and binary.nil?
raise "faux pas" if Position.get(instruction).at < Position.get(binary).at
raise "faux pas" if at < Position.get(binary).at
return unless @instruction.next
@binary = binary
nekst = at + @instruction.byte_length
@ -43,8 +43,8 @@ module Risc
end
def reset_to(pos , binary)
super(pos , binary)
init(pos , binary)
super(pos , binary)
Position.log.debug "ResetInstruction (#{pos.to_s(16)}) #{instruction}"
end
end

View File

@ -162,7 +162,6 @@ module Risc
code.each_word do |word|
@stream.write_unsigned_int_32( word || 0 )
end
write_ref_for( code.get_type )
log.debug "Code16 witten stream 0x#{@stream.length.to_s(16)}"
end
@ -180,7 +179,7 @@ module Risc
write_ref_for( string.get_type ) #ref
@stream.write_signed_int_32( str.length ) #int
@stream.write str
pad_after(str.length + 8 ) # type , length *4 == 12
pad_after(str.length + 8 ) # type , length
log.debug "String (0x#{string.length.to_s(16)}) stream 0x#{@stream.length.to_s(16)}"
end