class Vm::Instructions::MemoryAccessOperations::StaticOperation
Attributes
index[R]
object_name[R]
Public Class Methods
new(object_name, index)
click to toggle source
# File lib/hackasm/vm/instructions/memory_access_operations/static_operation.rb, line 8 def initialize(object_name, index) @index = index @object_name = object_name end
segments()
click to toggle source
# File lib/hackasm/vm/instructions/memory_access_operations/static_operation.rb, line 37 def self.segments %w[static] end
Public Instance Methods
to_asm()
click to toggle source
# File lib/hackasm/vm/instructions/memory_access_operations/static_operation.rb, line 13 def to_asm if operation == "push" %Q{ @#{object_name}.#{index} D=M @SP A=M M=D @SP M=M+1 }.strip else %Q{ @SP M=M-1 @SP A=M D=M @#{object_name}.#{index} M=D }.strip end end