using new register instructions

This commit is contained in:
Torsten Ruger
2014-10-04 12:52:28 +03:00
parent e3c3840bc6
commit 4f7fefb0ab
3 changed files with 10 additions and 11 deletions

View File

@ -4,17 +4,16 @@ module Register
block.codes.dup.each do |code|
next unless code.is_a? Virtual::MethodReturn
new_codes = []
machine = RegisterMachine.instance
slot = Virtual::Slot
# move the current message to new_message
new_codes << machine.mov( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER )
new_codes << RegisterTransfer.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER )
# and restore the message from saved value in new_message
new_codes << machine.ldr( slot::MESSAGE_REGISTER ,slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_CALLER )
new_codes << GetSlot.new( slot::MESSAGE_REGISTER , slot::NEW_MESSAGE_REGISTER , slot::MESSAGE_CALLER )
# "roll out" self and frame into their registers
new_codes << machine.ldr( slot::SELF_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_SELF )
new_codes << machine.ldr( slot::FRAME_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_FRAME )
new_codes << GetSlot.new( slot::SELF_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_SELF )
new_codes << GetSlot.new( slot::FRAME_REGISTER ,slot::MESSAGE_REGISTER , slot::MESSAGE_FRAME )
#load the return address into pc, affecting return. (other cpus have commands for this, but not arm)
new_codes << machine.ldr( :pc ,slot::MESSAGE_REGISTER , slot::MESSAGE_RETURN_ADDRESS )
new_codes << FunctionReturn.new( slot::MESSAGE_REGISTER , slot::MESSAGE_RETURN_ADDRESS )
block.replace(code , new_codes )
end
end