Class: Haxor::Vm::Stack
Instance Attribute Summary
Attributes inherited from Subsystem
Instance Method Summary collapse
Methods inherited from Subsystem
Instance Method Details
#pop(addr) ⇒ Object
16 17 18 19 |
# File 'lib/haxor/vm/stack.rb', line 16 def pop(addr) value = pop_value @vm.subsystem(:mem).write addr, value end |
#pop_value ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/haxor/vm/stack.rb', line 21 def pop_value sp = @vm.subsystem(:cpu).reg Vm::Cpu::Core::REG_STACK value = @vm.subsystem(:mem).read sp sp += Consts::WORD_SIZE @vm.subsystem(:cpu).reg Vm::Cpu::Core::REG_STACK, sp value end |
#push(addr) ⇒ Object
4 5 6 7 |
# File 'lib/haxor/vm/stack.rb', line 4 def push(addr) value = @vm.subsystem(:mem).read addr push_value value end |
#push_value(value) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/haxor/vm/stack.rb', line 9 def push_value(value) sp = @vm.subsystem(:cpu).reg Vm::Cpu::Core::REG_STACK sp -= Consts::WORD_SIZE @vm.subsystem(:cpu).reg Vm::Cpu::Core::REG_STACK, sp @vm.subsystem(:mem).write sp, value end |