Class: Haxor::Token::Cmd

Inherits:
Base
  • Object
show all
Defined in:
lib/haxor/token/cmd.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#absolute_addr

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Cmd

Returns a new instance of Cmd.



12
13
14
15
16
17
18
19
20
# File 'lib/haxor/token/cmd.rb', line 12

def initialize
  @cmd   = 0
  @flags = 0
  @reg1  = 0
  @reg2  = 0
  @reg3  = 0
  @imm   = 0
  @opts  = []
end

Instance Attribute Details

#cmd ⇒ Object

Returns the value of attribute cmd.



4
5
6
# File 'lib/haxor/token/cmd.rb', line 4

def cmd
  @cmd
end

#flags ⇒ Object

Returns the value of attribute flags.



5
6
7
# File 'lib/haxor/token/cmd.rb', line 5

def flags
  @flags
end

#imm ⇒ Object

Returns the value of attribute imm.



9
10
11
# File 'lib/haxor/token/cmd.rb', line 9

def imm
  @imm
end

#opts ⇒ Object

Returns the value of attribute opts.



10
11
12
# File 'lib/haxor/token/cmd.rb', line 10

def opts
  @opts
end

#reg1 ⇒ Object

Returns the value of attribute reg1.



6
7
8
# File 'lib/haxor/token/cmd.rb', line 6

def reg1
  @reg1
end

#reg2 ⇒ Object

Returns the value of attribute reg2.



7
8
9
# File 'lib/haxor/token/cmd.rb', line 7

def reg2
  @reg2
end

#reg3 ⇒ Object

Returns the value of attribute reg3.



8
9
10
# File 'lib/haxor/token/cmd.rb', line 8

def reg3
  @reg3
end

Instance Method Details

#size ⇒ Object



22
23
24
# File 'lib/haxor/token/cmd.rb', line 22

def size
  Consts::WORD_SIZE
end

#to_bytecode ⇒ Object



26
27
28
29
# File 'lib/haxor/token/cmd.rb', line 26

def to_bytecode
  data = Utils.encode_opcode @cmd, @flags, @reg1, @reg2, @reg3, @imm
  [data].pack Consts::WORD_UNPACK
end

#to_s ⇒ Object



31
32
33
# File 'lib/haxor/token/cmd.rb', line 31

def to_s
  "CMD code:[0x#{@cmd.to_s(16)}], flags:[#{@flags.to_s(2)}], regs:[#{@reg1}, #{@reg2}, #{@reg3}], imm:[#{@imm}], opts:#{@opts}"
end