2014-10-03 10:07:18 +02:00
|
|
|
module Register
|
|
|
|
# load a constant into a register
|
|
|
|
#
|
2015-06-25 15:31:09 +02:00
|
|
|
# first is the actual constant, either immediate register or object reference (from the space)
|
|
|
|
# second argument is the register the constant is loaded into
|
2015-05-31 16:54:36 +02:00
|
|
|
|
2014-10-03 10:07:18 +02:00
|
|
|
class LoadConstant < Instruction
|
2015-06-25 15:31:09 +02:00
|
|
|
def initialize constant , register
|
|
|
|
@register = register
|
2014-10-03 10:07:18 +02:00
|
|
|
@constant = constant
|
|
|
|
end
|
2015-06-25 15:31:09 +02:00
|
|
|
attr_accessor :register , :constant
|
2015-07-24 12:23:56 +02:00
|
|
|
|
|
|
|
def to_s
|
2015-07-25 08:30:58 +02:00
|
|
|
"LoadConstant: #{register} <- #{constant}"
|
2015-07-24 12:23:56 +02:00
|
|
|
end
|
|
|
|
|
2014-10-03 10:07:18 +02:00
|
|
|
end
|
|
|
|
end
|