diff --git a/lib/register/instruction.rb b/lib/register/instruction.rb index e1ca77a6..6bfdbc1a 100644 --- a/lib/register/instruction.rb +++ b/lib/register/instruction.rb @@ -26,6 +26,11 @@ module Register raise "abstract called for #{self.class}" end + # wrap symbols into regsiter reference if needed + def wrap_register reg + return reg if reg.is_a? RegisterReference + RegisterReference.new(reg) + end end end diff --git a/lib/register/instructions/register_transfer.rb b/lib/register/instructions/register_transfer.rb index e55386d2..44d4f59b 100644 --- a/lib/register/instructions/register_transfer.rb +++ b/lib/register/instructions/register_transfer.rb @@ -4,8 +4,8 @@ module Register class RegisterTransfer < Instruction def initialize from , to - @from = from - @to = to + @from = wrap_register(from) + @to = wrap_register(to) end attr_reader :from, :to end