2014-10-04 11:51:08 +02:00
|
|
|
module Register
|
|
|
|
|
2015-06-21 20:00:16 +02:00
|
|
|
# transfer the constents of one register to another.
|
|
|
|
# possibly called move in some cpus
|
2014-10-04 11:51:08 +02:00
|
|
|
|
2015-06-21 20:00:16 +02:00
|
|
|
# There are other instructions to move data from / to memory, namely GetSlot and SetSlot
|
|
|
|
|
|
|
|
# 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
|
2015-06-27 19:09:21 +02:00
|
|
|
#
|
|
|
|
|
2014-10-04 11:51:08 +02:00
|
|
|
class RegisterTransfer < Instruction
|
2015-06-27 19:09:21 +02:00
|
|
|
# initialize with from and to registers.
|
|
|
|
# First argument from
|
2015-10-14 12:48:42 +02:00
|
|
|
# second argument to
|
2015-06-27 19:09:21 +02:00
|
|
|
#
|
2015-07-24 12:23:56 +02:00
|
|
|
# Note: this may be reversed from some assembler notations (also arm)
|
2015-07-27 11:13:39 +02:00
|
|
|
def initialize source , from , to
|
|
|
|
super(source)
|
2015-10-15 08:32:47 +02:00
|
|
|
@from = from
|
|
|
|
@to = to
|
|
|
|
raise "Fix me #{from}" unless from.is_a? RegisterValue
|
|
|
|
raise "Fix me #{to}" unless to.is_a? RegisterValue
|
2014-10-04 11:51:08 +02:00
|
|
|
end
|
|
|
|
attr_reader :from, :to
|
2015-07-24 12:23:56 +02:00
|
|
|
|
|
|
|
def to_s
|
2015-07-25 08:30:58 +02:00
|
|
|
"RegisterTransfer: #{from} -> #{to}"
|
2015-07-24 12:23:56 +02:00
|
|
|
end
|
2015-11-21 13:17:54 +01:00
|
|
|
end
|
|
|
|
def self.transfer source , from , to
|
|
|
|
RegisterTransfer.new source , from , to
|
2014-10-04 11:51:08 +02:00
|
|
|
end
|
2015-06-21 20:00:16 +02:00
|
|
|
end
|