Class: Whitespace::ISA::Readc
- Inherits:
-
Instruction
- Object
- Instruction
- Whitespace::ISA::Readc
- Defined in:
- lib/whitespace/instructions/io/readc.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) ⇒ Readc
constructor
A new instance of Readc.
Constructor Details
#initialize(vm, console) ⇒ Readc
Returns a new instance of Readc.
5 6 7 8 |
# File 'lib/whitespace/instructions/io/readc.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/readc.rb', line 3 def console @console end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 |
# File 'lib/whitespace/instructions/io/readc.rb', line 10 def execute ch = console.getc address = vm.vstack.pop vm.memory[address] = ch.ord end |