Class: Vm::Instructions::MemoryAccessOperations::ConstantOperation
- Inherits:
-
Object
- Object
- Vm::Instructions::MemoryAccessOperations::ConstantOperation
- Defined in:
- lib/hackasm/vm/instructions/memory_access_operations/constant_operation.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(index) ⇒ ConstantOperation
constructor
A new instance of ConstantOperation.
- #to_asm ⇒ Object
Constructor Details
#initialize(index) ⇒ ConstantOperation
Returns a new instance of ConstantOperation.
8 9 10 |
# File 'lib/hackasm/vm/instructions/memory_access_operations/constant_operation.rb', line 8 def initialize(index) @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/hackasm/vm/instructions/memory_access_operations/constant_operation.rb', line 6 def index @index end |
Class Method Details
.segments ⇒ Object
24 25 26 |
# File 'lib/hackasm/vm/instructions/memory_access_operations/constant_operation.rb', line 24 def self.segments %w[constant] end |
Instance Method Details
#to_asm ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/hackasm/vm/instructions/memory_access_operations/constant_operation.rb', line 12 def to_asm %Q{ @#{index} D=A @SP A=M M=D @SP M=M+1 }.strip end |