Class: Ronin::Code::ASM::Instruction

Inherits:
Struct
  • Object
show all
Defined in:
lib/ronin/code/asm/instruction.rb

Overview

Represents an instruction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, operands) ⇒ Instruction

Initializes the instruction.

Parameters:

  • name (Symbol)

    The instruction name.

  • operands (Array<MemoryOperand, Register, Symbol, Integer>)

    Operands for the instruction.



40
41
42
43
44
45
46
47
48
49
# File 'lib/ronin/code/asm/instruction.rb', line 40

def initialize(name,operands)
  operands = operands.map do |value|
    case value
    when Integer, nil then ImmediateOperand.new(value)
    else                   value
    end
  end

  super(name,operands)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



29
30
31
# File 'lib/ronin/code/asm/instruction.rb', line 29

def name
  @name
end

#operandsObject

Returns the value of attribute operands

Returns:

  • (Object)

    the current value of operands



29
30
31
# File 'lib/ronin/code/asm/instruction.rb', line 29

def operands
  @operands
end

Instance Method Details

#widthInteger?

The word size of the instruction.

Returns:

  • (Integer, nil)

    The word size in bytes.



57
58
59
60
61
# File 'lib/ronin/code/asm/instruction.rb', line 57

def width
  self.operands.map { |op|
    op.width if op.respond_to?(:width)
  }.compact.max
end