Class: Ronin::Code::ASM::MemoryOperand
- Inherits:
-
Struct
- Object
- Struct
- Ronin::Code::ASM::MemoryOperand
- Defined in:
- lib/ronin/code/asm/memory_operand.rb
Overview
Represents a Memory Operand.
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#index ⇒ Object
Returns the value of attribute index.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#+(offset) ⇒ MemoryOperand
Adds to the offset of the Memory Operand.
-
#-(offset) ⇒ MemoryOperand
Subtracts from the offset of the Memory Operand.
-
#initialize(base = nil, offset = 0, index = nil, scale = 1, width = nil) ⇒ MemoryOperand
constructor
Creates a new Memory Operand.
Constructor Details
#initialize(base = nil, offset = 0, index = nil, scale = 1, width = nil) ⇒ MemoryOperand
Creates a new Memory Operand.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 54 def initialize(base=nil,offset=0,index=nil,scale=1,width=nil) unless (base.nil? || base.kind_of?(Register)) raise(TypeError,"base must be a Register or nil") end unless offset.kind_of?(Integer) raise(TypeError,"offset must be an Integer") end unless (index.nil? || index.kind_of?(Register)) raise(TypeError,"index must be a Register or nil") end unless scale.kind_of?(Integer) raise(TypeError,"scale must be an Integer") end if base width ||= base.width end super(base,offset,index,scale,width) end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base
31 32 33 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 31 def base @base end |
#index ⇒ Object
Returns the value of attribute index
31 32 33 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 31 def index @index end |
#offset ⇒ Object
Returns the value of attribute offset
31 32 33 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 31 def offset @offset end |
#scale ⇒ Object
Returns the value of attribute scale
31 32 33 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 31 def scale @scale end |
#width ⇒ Object
Returns the value of attribute width
31 32 33 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 31 def width @width end |
Instance Method Details
#+(offset) ⇒ MemoryOperand
Adds to the offset of the Memory Operand.
87 88 89 90 91 92 93 94 95 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 87 def +(offset) MemoryOperand.new( self.base, self.offset + offset, self.index, self.scale, self.width ) end |
#-(offset) ⇒ MemoryOperand
Subtracts from the offset of the Memory Operand.
106 107 108 109 110 111 112 113 114 |
# File 'lib/ronin/code/asm/memory_operand.rb', line 106 def -(offset) MemoryOperand.new( self.base, self.offset - offset, self.index, self.scale, self.width ) end |