loading label must translate the labels too
(psst: like arm translator already did. duh)
This commit is contained in:
@ -5,7 +5,7 @@ module Risc
|
||||
# second argument is the register the constant is loaded into
|
||||
|
||||
class LoadConstant < Instruction
|
||||
def initialize source , constant , register
|
||||
def initialize( source , constant , register)
|
||||
super(source)
|
||||
@register = register
|
||||
@constant = constant
|
||||
@ -33,6 +33,6 @@ module Risc
|
||||
end
|
||||
end
|
||||
def self.load_constant( source , constant , register )
|
||||
LoadConstant.new source , constant , register
|
||||
LoadConstant.new( source , constant , register )
|
||||
end
|
||||
end
|
||||
|
@ -216,7 +216,7 @@ module Risc
|
||||
meth = @instruction.method
|
||||
at = Position.get(meth.binary).at
|
||||
log.debug "Call to #{meth.name} at:#{at}"
|
||||
set_pc(at + BinaryCode.offset)
|
||||
set_pc(at + Parfait::BinaryCode.offset)
|
||||
#set_instruction @instruction.method.risc_instructions
|
||||
false
|
||||
end
|
||||
@ -224,9 +224,8 @@ module Risc
|
||||
def execute_FunctionReturn
|
||||
link = get_register( @instruction.register )
|
||||
log.debug "Return to #{link}"
|
||||
@instruction = link
|
||||
# we jump back to the call instruction. so it is as if the call never happened and we continue
|
||||
true
|
||||
set_pc Position.get(link).at
|
||||
false
|
||||
end
|
||||
|
||||
def execute_Syscall
|
||||
|
@ -34,10 +34,14 @@ module Risc
|
||||
case code
|
||||
when Branch
|
||||
ret = code.class.new(code.source , code.label.to_cpu(self))
|
||||
when LoadConstant
|
||||
const = code.constant
|
||||
const = const.to_cpu(self) if const.is_a?(Label)
|
||||
ret = LoadConstant.new(code.source , const , code.register)
|
||||
else
|
||||
ret = code.dup
|
||||
ret.nil_next
|
||||
end
|
||||
ret.nil_next
|
||||
ret
|
||||
end
|
||||
end
|
||||
|
@ -34,14 +34,13 @@ module Risc
|
||||
platform = platform.to_s.capitalize
|
||||
@platform = Platform.for(platform)
|
||||
@translated = true
|
||||
methods = Parfait.object_space.get_all_methods
|
||||
translate_methods( methods , @platform.translator )
|
||||
translate_methods( @platform.translator )
|
||||
@cpu_init = risc_init.to_cpu(@platform.translator)
|
||||
end
|
||||
|
||||
# go through all methods and translate them to cpu, given the translator
|
||||
def translate_methods(methods , translator)
|
||||
methods.each do |method|
|
||||
def translate_methods(translator)
|
||||
Parfait.object_space.get_all_methods.each do |method|
|
||||
log.debug "Translate method #{method.name}"
|
||||
method.translate_cpu(translator)
|
||||
end
|
||||
@ -90,7 +89,6 @@ module Risc
|
||||
before = at
|
||||
Position.set(objekt,at)
|
||||
at += objekt.padded_length
|
||||
log.debug "PADDED #{objekt.padded_length}"
|
||||
log.debug "Object #{objekt.class}:#{before.to_s(16)} len: #{(at - before).to_s(16)}"
|
||||
end
|
||||
at
|
||||
|
@ -109,7 +109,7 @@ module Risc
|
||||
end
|
||||
|
||||
# return a new builder that uses this compiler
|
||||
# must specify weather to add code automatically to compiler
|
||||
# must specify whether to add code automatically to compiler
|
||||
# second arg is the source for which to build, either method or mom::instruction
|
||||
def builder( auto_add , source)
|
||||
Builder.new(self , auto_add , source)
|
||||
|
Reference in New Issue
Block a user