Class: Haxor::Vm::Cpu::Unit::Logical
- Defined in:
- lib/haxor/vm/cpu/unit/logical.rb
Constant Summary collapse
- OP_AND =
0x40
0x40- OP_NEG =
and a, b
0x41- OP_NOT =
neg a
0x42- OP_OR =
not a
0x43- OP_XOR =
or a, b
0x44
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #op_and ⇒ Object
- #op_neg ⇒ Object
- #op_not ⇒ Object
- #op_or ⇒ Object
- #op_xor ⇒ Object
-
#register ⇒ Object
0x5f.
Methods inherited from Base
#bind_opcode, #dereference, #fetch_cell, #next_cell, #operand, #operands, #replace_cell
Instance Method Details
#op_and ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/haxor/vm/cpu/unit/logical.rb', line 22 def op_and a, b = operands av = @vm.subsystem(:mem).read a bv = @vm.subsystem(:mem).read b v = av & bv @vm.subsystem(:mem).write a, v end |
#op_neg ⇒ Object
30 31 32 33 34 |
# File 'lib/haxor/vm/cpu/unit/logical.rb', line 30 def op_neg a = operand av = @vm.subsystem(:mem).read a @vm.subsystem(:mem).write a, -av end |
#op_not ⇒ Object
36 37 38 39 40 |
# File 'lib/haxor/vm/cpu/unit/logical.rb', line 36 def op_not a = operand av = @vm.subsystem(:mem).read a @vm.subsystem(:mem).write a, ~av end |
#op_or ⇒ Object
42 43 44 45 46 47 |
# File 'lib/haxor/vm/cpu/unit/logical.rb', line 42 def op_or a, b = operands av = @vm.subsystem(:mem).read a bv = @vm.subsystem(:mem).read b @vm.subsystem(:mem).write a, (av | bv) end |
#op_xor ⇒ Object
49 50 51 52 53 54 |
# File 'lib/haxor/vm/cpu/unit/logical.rb', line 49 def op_xor a, b = operands av = @vm.subsystem(:mem).read a bv = @vm.subsystem(:mem).read b @vm.subsystem(:mem).write a, (av ^ bv) end |