Class: Haxor::Vm::Cpu::Unit::Various

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

Constant Summary collapse

OP_LEA =

0x80

0x80
OP_NOP =

lea a

0x81
OP_INT =

nop

0x85
OP_SYSCALL =

int a

0x86

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_int ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/haxor/vm/cpu/unit/various.rb', line 29

def op_int
  a = operand

  @vm.subsystem(:stack).push 'ip'

  av = @vm.subsystem(:mem).read a
  ivt = Consts::IVT_ADDR + (av * 8)
  handler = @vm.subsystem(:mem).read ivt
  @vm.subsystem(:mem).write 'ip', handler
end

#op_lea ⇒ Object



20
21
22
23
# File 'lib/haxor/vm/cpu/unit/various.rb', line 20

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

#op_nop ⇒ Object



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

def op_nop
  # intentionally nothing here
end

#op_syscall ⇒ Object



40
41
42
# File 'lib/haxor/vm/cpu/unit/various.rb', line 40

def op_syscall
  @vm.subsystem(:os).syscall
end

#register ⇒ Object

0x9f



13
14
15
16
17
18
# File 'lib/haxor/vm/cpu/unit/various.rb', line 13

def register
  bind_opcode OP_LEA,      :op_lea
  bind_opcode OP_NOP,      :op_nop
  bind_opcode OP_INT,      :op_int
  bind_opcode OP_SYSCALL,  :op_syscall
end