class Vm::Instructions::ArithmeticOperations::UnaryOperation

Constants

OPERATION_TO_INSTRUCTION

Attributes

operation[R]

Public Class Methods

new(operation) click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/unary_operation.rb, line 12
def initialize(operation)
  @operation = operation
end
operations() click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/unary_operation.rb, line 28
def self.operations
  OPERATION_TO_INSTRUCTION.keys
end

Public Instance Methods

to_asm() click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/unary_operation.rb, line 16
def to_asm
  %Q{
  @SP
  M=M-1
  @SP
  A=M
  #{OPERATION_TO_INSTRUCTION[operation]}
  @SP
  M=M+1
  }.strip
end