Sha256: 23e0f89cb52bebd53f59c6f482354d1a32dbab5cd1dc30a1d205d71c86c7ca4f

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

module Haxor
  module Vm
    module Cpu
      module Unit
        class Various < Base
          #            = 0x80
          OP_LEA       = 0x80 # lea a
          OP_NOP       = 0x81 # nop
          OP_INT       = 0x85 # int a
          OP_SYSCALL   = 0x86 # syscall
          #              0x9f

          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

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

          def op_nop
            # intentionally nothing here
          end

          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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
haxor-0.3.0 lib/haxor/vm/cpu/unit/various.rb
haxor-0.2.0 lib/haxor/vm/cpu/unit/various.rb
haxor-0.1.0 lib/haxor/vm/cpu/unit/various.rb