From 5ddc96718b57e54c21b4a47e5b9af7b77b264f55 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 7 Nov 2015 21:59:39 +0200 Subject: [PATCH] slight call logic modification simplification, new model is such that the upon start the method: has a message in r0, works on it and returns to the return address. Everything else is up to the caller --- lib/register/instructions/function_call.rb | 4 ++++ lib/soml/compiler.rb | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/register/instructions/function_call.rb b/lib/register/instructions/function_call.rb index 2a174d9e..d86d6c64 100644 --- a/lib/register/instructions/function_call.rb +++ b/lib/register/instructions/function_call.rb @@ -26,5 +26,9 @@ module Register # do the register call compiler.add_code FunctionCall.new( source , callee ) compiler.add_code return_label + # move the current message to new_message + compiler.add_code Register::RegisterTransfer.new(source, Register.message_reg , Register.new_message_reg ) + # and restore the message from saved value in new_message + compiler.add_code Register.get_slot(source , :new_message , :caller , :message ) end end diff --git a/lib/soml/compiler.rb b/lib/soml/compiler.rb index 45635829..70132112 100644 --- a/lib/soml/compiler.rb +++ b/lib/soml/compiler.rb @@ -86,12 +86,8 @@ module Soml @method.instructions = Register::Label.new(source, "#{method.for_class.name}.#{method.name}") @current = enter = method.instructions add_code Register::Label.new( source, "return") - # move the current message to new_message - add_code Register::RegisterTransfer.new(source, Register.message_reg , Register.new_message_reg ) - # and restore the message from saved value in new_message - add_code Register.get_slot("_init_method_",:new_message , :caller , :message ) #load the return address into pc, affecting return. (other cpus have commands for this, but not arm) - add_code Register::FunctionReturn.new( source , Register.new_message_reg , Register.resolve_index(:message , :return_address) ) + add_code Register::FunctionReturn.new( source , Register.message_reg , Register.resolve_index(:message , :return_address) ) @current = enter self end