Class: Ronin::Code::ASM::Register

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

Overview

Represents a Register.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, width, general = false) ⇒ Register

Initializes a register.

Parameters:

  • name (Symbol)

    The register name.

  • width (Integer)

    The width of the register.

  • general (Boolean) (defaults to: false)

    Specifies whether the register is a General Purpose Register (GPR).



43
44
45
# File 'lib/ronin/code/asm/register.rb', line 43

def initialize(name,width,general=false)
  super(name,width,general)
end

Instance Attribute Details

#generalObject

Returns the value of attribute general

Returns:

  • (Object)

    the current value of general



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

def general
  @general
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



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

def name
  @name
end

#widthObject

Returns the value of attribute width

Returns:

  • (Object)

    the current value of width



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

def width
  @width
end

Instance Method Details

#*(scale) ⇒ MemoryOperand

Multiples the value within the register.

Parameters:

  • scale (Integer)

    The scale to multiply the value within register by.

Returns:



96
97
98
# File 'lib/ronin/code/asm/register.rb', line 96

def *(scale)
  MemoryOperand.new(nil,0,self,scale)
end

#+(offset) ⇒ MemoryOperand

Adds an offset to the value within the register and dereferences the address.

Parameters:

Returns:

Raises:



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ronin/code/asm/register.rb', line 60

def +(offset)
  case offset
  when MemoryOperand
    MemoryOperand.new(self,offset.offset,offset.index,offset.scale)
  when Register
    MemoryOperand.new(self,0,offset)
  when Integer
    MemoryOperand.new(self,offset)
  else
    raise(TypeError,"offset was not an MemoryOperand, Register or Integer")
  end
end

#-(offset) ⇒ MemoryOperand

Subtracts from the value within the register and dereferences the address.

Parameters:

  • offset (Integer)

    The value to subtract from the value of the register.

Returns:



83
84
85
# File 'lib/ronin/code/asm/register.rb', line 83

def -(offset)
  MemoryOperand.new(self,-offset)
end

#to_sString

Returns The register's name.

Returns:

  • (String)

    The register's name.



104
105
106
# File 'lib/ronin/code/asm/register.rb', line 104

def to_s
  self.name.to_s
end