fixing the binary code indexes
AGAIN, that third of all bugs, the off by one
This commit is contained in:
@ -33,8 +33,8 @@ module Risc
|
||||
end
|
||||
end
|
||||
def reset_to(pos , ignored)
|
||||
init(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
|
||||
|
@ -23,28 +23,27 @@ module Risc
|
||||
@binary = binary
|
||||
end
|
||||
def init(at, binary)
|
||||
@binary = binary
|
||||
return if at == 0 and binary.nil?
|
||||
raise "faux pas" if at < Position.get(binary).at
|
||||
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
|
||||
next_binary = @binary
|
||||
if( (diff % (@binary.padded_length - @instruction.byte_length)) == 0 )
|
||||
next_binary.extend_one unless next_binary.next
|
||||
next_binary = next_binary.next
|
||||
raise "end of line " unless next_binary
|
||||
nekst = Position.get(next_binary).at + Parfait::BinaryCode.byte_offset
|
||||
if( (diff % (binary.padded_length - @instruction.byte_length)) == 0 )
|
||||
binary.extend_one unless binary.next
|
||||
binary = binary.next
|
||||
raise "end of line " unless binary
|
||||
nekst = Position.get(binary).at + Parfait::BinaryCode.byte_offset
|
||||
Position.log.debug "Jump to: #{nekst.to_s(16)}"
|
||||
end
|
||||
Position.set(@instruction.next, nekst , next_binary)
|
||||
Position.set(@instruction.next, nekst , binary)
|
||||
end
|
||||
|
||||
def reset_to(pos , binary)
|
||||
init(pos , binary)
|
||||
super(pos , binary)
|
||||
init(pos , binary)
|
||||
Position.log.debug "ResetInstruction (#{pos.to_s(16)}) #{instruction}"
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user