diff --git a/lib/register/enter_implementation.rb b/lib/register/enter_implementation.rb index 222f55d2..fd5a4c9f 100644 --- a/lib/register/enter_implementation.rb +++ b/lib/register/enter_implementation.rb @@ -6,11 +6,9 @@ module Register next unless code.is_a? Virtual::MethodEnter # save return register and create a new frame to = RegisterReference.new(:r0) # message base - tmp = RegisterReference.new(:r5) # tmp pc = RegisterReference.new(:pc) - move1 = RegisterMachine.instance.ldr( tmp , pc ) - move2 = RegisterMachine.instance.ldr( tmp , to , 3 ) #TODO 3 == return reg, needs constant / layout - block.replace(code , [move1,move2] ) + move1 = RegisterMachine.instance.str( pc , to , Virtual::Message::RETURN ) + block.replace(code , [move1] ) end end end diff --git a/lib/register/return_implementation.rb b/lib/register/return_implementation.rb index f6b4895c..0d0ae037 100644 --- a/lib/register/return_implementation.rb +++ b/lib/register/return_implementation.rb @@ -3,12 +3,11 @@ module Register def run block block.codes.dup.each do |code| next unless code.is_a? Virtual::MethodReturn - to = RegisterReference.new(:r0) - tmp = RegisterReference.new(:r5) + #load the return address into pc, affecting return. (other cpus have commands for this, but not arm) + message = RegisterReference.new(:r0) pc = RegisterReference.new(:pc) - move1 = RegisterMachine.instance.ldr( to , tmp , 3 ) #TODO 3 == return reg, needs constant / layout - move2 = RegisterMachine.instance.ldr( pc , tmp ) - block.replace(code , [move1,move2] ) + move1 = RegisterMachine.instance.ldr( pc ,message , Virtual::Message::RETURN ) + block.replace(code , [move1] ) end end end diff --git a/lib/virtual/message.rb b/lib/virtual/message.rb index fecb1fe7..b911e351 100644 --- a/lib/virtual/message.rb +++ b/lib/virtual/message.rb @@ -20,6 +20,10 @@ module Virtual # During compilation Message and frame objects are created to do type analysis class Message + RETURN = 2 + EXCEPTION = 3 + SELF = 4 + def initialize me , normal , exceptional @me = me @next_normal = normal