Class: Haxor::Vm::Cpu::Unit::Transfer

Inherits:
Base
  • Object
show all
Defined in:
lib/haxor/vm/cpu/unit/transfer.rb

Constant Summary collapse

OP_MOV =

0x60

0x60
OP_PUSH =

mov a, b

0x61
OP_POP =

push a

0x62

Instance Attribute Summary

Attributes inherited from Base

#vm

Instance Method Summary collapse

Methods inherited from Base

#bind_opcode, #dereference, #fetch_cell, #next_cell, #operand, #operands, #replace_cell

Instance Method Details

#op_mov ⇒ Object



18
19
20
21
22
# File 'lib/haxor/vm/cpu/unit/transfer.rb', line 18

def op_mov
  a, b = operands
  v = @vm.subsystem(:mem).read b
  @vm.subsystem(:mem).write a, v
end

#op_pop ⇒ Object



29
30
31
32
# File 'lib/haxor/vm/cpu/unit/transfer.rb', line 29

def op_pop
  a = operand
  @vm.subsystem(:stack).pop a
end

#op_push ⇒ Object



24
25
26
27
# File 'lib/haxor/vm/cpu/unit/transfer.rb', line 24

def op_push
  a = operand
  @vm.subsystem(:stack).push a
end

#register ⇒ Object

0x7f



12
13
14
15
16
# File 'lib/haxor/vm/cpu/unit/transfer.rb', line 12

def register
  bind_opcode OP_MOV,     :op_mov
  bind_opcode OP_PUSH,    :op_push
  bind_opcode OP_POP,     :op_pop
end