Class: Whitespace::ISA::Readn
- Inherits:
-
Instruction
- Object
- Instruction
- Whitespace::ISA::Readn
- Defined in:
- lib/whitespace/instructions/io/readn.rb
Instance Attribute Summary collapse
-
#console ⇒ Object
readonly
Returns the value of attribute console.
Attributes inherited from Instruction
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(vm, console) ⇒ Readn
constructor
A new instance of Readn.
Constructor Details
#initialize(vm, console) ⇒ Readn
Returns a new instance of Readn.
5 6 7 8 |
# File 'lib/whitespace/instructions/io/readn.rb', line 5 def initialize(vm, console) super(vm) @console = console end |
Instance Attribute Details
#console ⇒ Object (readonly)
Returns the value of attribute console.
3 4 5 |
# File 'lib/whitespace/instructions/io/readn.rb', line 3 def console @console end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 |
# File 'lib/whitespace/instructions/io/readn.rb', line 10 def execute n = console.getn address = vm.vstack.pop vm.memory[address] = n end |