fixed the SetImplementation with new register instructions

This commit is contained in:
Torsten Ruger
2014-10-03 11:07:18 +03:00
parent 38a286942e
commit 1af66567fb
5 changed files with 53 additions and 6 deletions

View File

@ -21,7 +21,7 @@ end
module Register
# This implements setting of the various slot variables the vm defines.
# Basic mem moves, but have to shuffle the type nibbles
# Basic mem moves, but have to shuffle the type nibbles (TODO!)
class SetImplementation
def run block
@ -33,11 +33,11 @@ module Register
tmp = RegisterReference.new(Virtual::Message::TMP_REG)
# for constants we have to "move" the constants value
if( code.from.is_a? Virtual::Constant)
move1 = RegisterMachine.instance.mov( tmp , code.from )
move1 = LoadConstant.new( tmp , code.from )
else # while otherwise we "load"
move1 = RegisterMachine.instance.ldr( tmp , code.from.reg , code.from.index )
move1 = GetSlot.new( tmp , code.from.reg , code.from.index )
end
move2 = RegisterMachine.instance.str( tmp , to , code.to.index )
move2 = SetSlot.new( tmp , to , code.to.index )
block.replace(code , [move1,move2] )
end
end