Class: Wilson::Address
Overview
Address is a memory address in one of the following example forms:
eax, ebx + ecx, eax + 5, 23545, edx + eax + 2312
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#index ⇒ Object
Returns the value of attribute index.
-
#isAssemblerOffset ⇒ Object
writeonly
FIX.
-
#offset ⇒ Object
Returns the value of attribute offset.
Attributes inherited from Operand
Class Method Summary collapse
Instance Method Summary collapse
-
#+(o) ⇒ Object
TODO: this seems totally and completely wrong.
- #address? ⇒ Boolean
- #bits ⇒ Object
-
#initialize(isAssemblerOffset = nil, bits = nil, id = nil) ⇒ Address
constructor
A new instance of Address.
- #m ⇒ Object
- #offset? ⇒ Boolean
- #push_mod_rm_on(spareRegister, stream) ⇒ Object
Methods inherited from Operand
#instructionFromMessage, #method_missing, on, #operand?
Constructor Details
#initialize(isAssemblerOffset = nil, bits = nil, id = nil) ⇒ Address
Returns a new instance of Address.
858 859 860 861 862 863 864 865 |
# File 'lib/wilson.rb', line 858 def initialize isAssemblerOffset = nil, bits = nil, id = nil super(bits) self.isAssemblerOffset = isAssemblerOffset self.id = id self.index = self.offset = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Wilson::Operand
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
846 847 848 |
# File 'lib/wilson.rb', line 846 def id @id end |
#index ⇒ Object
Returns the value of attribute index.
846 847 848 |
# File 'lib/wilson.rb', line 846 def index @index end |
#isAssemblerOffset=(value) ⇒ Object (writeonly)
FIX
848 849 850 |
# File 'lib/wilson.rb', line 848 def isAssemblerOffset=(value) @isAssemblerOffset = value end |
#offset ⇒ Object
Returns the value of attribute offset.
847 848 849 |
# File 'lib/wilson.rb', line 847 def offset @offset end |
Class Method Details
.on_id_offset(machine, id, offset) ⇒ Object
850 851 852 853 854 855 856 |
# File 'lib/wilson.rb', line 850 def self.on_id_offset machine, id, offset address = self.new address.machine = machine address.id = id address.offset = offset address end |
Instance Method Details
#+(o) ⇒ Object
TODO: this seems totally and completely wrong
880 881 882 883 884 885 886 887 |
# File 'lib/wilson.rb', line 880 def + o # TODO: this seems totally and completely wrong if o.register? then self.index = o else self.offset = o end self end |
#address? ⇒ Boolean
889 890 891 |
# File 'lib/wilson.rb', line 889 def address? true end |
#bits ⇒ Object
867 868 869 |
# File 'lib/wilson.rb', line 867 def bits super || self.machine.bits end |
#m ⇒ Object
927 928 929 |
# File 'lib/wilson.rb', line 927 def m self end |
#offset? ⇒ Boolean
893 894 895 |
# File 'lib/wilson.rb', line 893 def offset? @isAssemblerOffset.nil? ? id.nil? : @isAssemblerOffset end |
#push_mod_rm_on(spareRegister, stream) ⇒ Object
897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
# File 'lib/wilson.rb', line 897 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 |