class Vm::Instructions::ArithmeticOperations::BinaryOperation
Constants
- OPERATION_TO_INSTRUCTION
Attributes
operation[R]
Public Class Methods
new(operation)
click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/binary_operation.rb, line 14 def initialize(operation) @operation = operation end
operations()
click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/binary_operation.rb, line 35 def self.operations OPERATION_TO_INSTRUCTION.keys end
Public Instance Methods
to_asm()
click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/binary_operation.rb, line 18 def to_asm %Q{ @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M #{instruction} @SP M=M+1 }.strip end
Private Instance Methods
instruction()
click to toggle source
# File lib/hackasm/vm/instructions/arithmetic_operations/binary_operation.rb, line 41 def instruction OPERATION_TO_INSTRUCTION[operation] end