rubyx/lib/register/instructions/register_transfer.rb
Torsten Ruger 35adf9a5e6 rename set_slot
set_slot was clear about the target, but not the source.
Better with reg_to_slot (and soon it’s inverse slot_to_reg)
2016-12-25 18:02:39 +02:00

36 lines
980 B
Ruby

module Register
# transfer the constents of one register to another.
# possibly called move in some cpus
# There are other instructions to move data from / to memory, namely GetSlot and RegToSlot
# Get/Set Slot move data around in vm objects, but transfer moves the objects (in the machine)
#
# Also it is used for moving temorary data
#
class RegisterTransfer < Instruction
# initialize with from and to registers.
# First argument from
# second argument to
#
# Note: this may be reversed from some assembler notations (also arm)
def initialize source , from , to
super(source)
@from = from
@to = to
raise "Fix me #{from}" unless from.is_a? RegisterValue
raise "Fix me #{to}" unless to.is_a? RegisterValue
end
attr_reader :from, :to
def to_s
"RegisterTransfer: #{from} -> #{to}"
end
end
def self.transfer source , from , to
RegisterTransfer.new source , from , to
end
end