rubyx/lib/risc/instructions/reg_to_slot.rb

28 lines
925 B
Ruby
Raw Normal View History

module Risc
# RegToSlot moves data into memory from a register.
# SlotToReg moves data into a register from memory.
# Both use a base memory (a register)
# This is because that is what cpu's can do. In programming terms this would be accessing
# an element in an array, in the case of RegToSlot setting the register in the array.
2018-03-21 11:18:04 +01:00
# btw: to move data between registers, use Transfer
class RegToSlot < Setter
end
# Produce a RegToSlot instruction.
# From and to are registers or symbols that can be transformed to a register by resolve_to_register
# (which are precisely the symbols :message or :new_message. or a register)
2016-12-28 17:16:39 +01:00
# index resolves with resolve_to_index.
2018-03-14 13:09:49 +01:00
def self.reg_to_slot( source , from_reg , to , index )
from = resolve_to_register from_reg
2016-12-28 17:16:39 +01:00
index = resolve_to_index( to , index)
to = resolve_to_register to
RegToSlot.new( source, from , to , index)
end
end