class Address

Address is a memory address in one of the following example forms:

eax, ebx + ecx, eax + 5, 23545, edx + eax + 2312

Attributes

id[RW]
index[RW]
isAssemblerOffset[W]
offset[R]

Public Class Methods

new(isAssemblerOffset = nil, bits = nil, id = nil) click to toggle source
Calls superclass method Operand.new
# File lib/wilson.rb, line 857
def initialize isAssemblerOffset = nil, bits = nil, id = nil
  super(bits)

  self.isAssemblerOffset = isAssemblerOffset
  self.id = id

  self.index = self.offset = nil
end
on_id_offset(machine, id, offset) click to toggle source
# File lib/wilson.rb, line 849
def self.on_id_offset machine, id, offset
  address         = self.new
  address.machine = machine
  address.id      = id
  address.offset  = offset
  address
end

Public Instance Methods

+(o) click to toggle source
# File lib/wilson.rb, line 879
def + o # TODO: this seems totally and completely wrong
  if o.register? then
    self.index = o
  else
    self.offset = o
  end
  self
end
address?() click to toggle source
# File lib/wilson.rb, line 888
def address?
  true
end
bits() click to toggle source
Calls superclass method
# File lib/wilson.rb, line 866
def bits
  super || self.machine.bits
end
m() click to toggle source
# File lib/wilson.rb, line 926
def m
  self
end
offset=(obj) click to toggle source
# File lib/wilson.rb, line 870
def offset= obj
  if obj.register? then
    @offset = 0
    self.index = obj
  else
    @offset = obj
  end
end
offset?() click to toggle source
# File lib/wilson.rb, line 892
def offset?
  @isAssemblerOffset.nil? ? id.nil? : @isAssemblerOffset
end
push_mod_rm_on(spareRegister, stream) click to toggle source
# File lib/wilson.rb, line 896
def push_mod_rm_on spareRegister, stream
  if id.nil? then
    stream << (0b00000101 + (spareRegister.id << 3))
    return stream.push_D(offset)
  end

  modrm = case offset
          when 0 then
            0b00000000
          when 1..255 then
            0b01000000
          else
            0b10000000
          end

  if index.nil? then
    modrm += (spareRegister.id << 3)
  else
    stream << (0b00000100 + (spareRegister.id << 3))
    modrm += (index.id << 3)
  end

  stream << modrm + id

  return self if offset == 0
  return stream.push_B(offset) if offset < 256

  stream.push_D offset
end