Class: Wilson::Register

Inherits:
Operand show all
Defined in:
lib/wilson.rb

Overview

Register is a general X86 register, such as eax, ebx, ecx, edx, etc…

Direct Known Subclasses

MemoryRegister

Instance Attribute Summary collapse

Attributes inherited from Operand

#bits, #machine

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Operand

#instructionFromMessage, #method_missing, on, #operand?

Constructor Details

#initialize(bits = nil, machine = nil, id = nil) ⇒ Register

Returns a new instance of Register.



943
944
945
946
# File 'lib/wilson.rb', line 943

def initialize bits = nil, machine = nil, id = nil
  super(bits, machine)
  self.id = id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wilson::Operand

Instance Attribute Details

#idObject

Returns the value of attribute id.



937
938
939
# File 'lib/wilson.rb', line 937

def id
  @id
end

Class Method Details

.on_id_bits(machine, id, bits) ⇒ Object



939
940
941
# File 'lib/wilson.rb', line 939

def self.on_id_bits machine, id, bits
  self.new bits, machine, id
end

Instance Method Details

#+(offset) ⇒ Object



973
974
975
# File 'lib/wilson.rb', line 973

def + offset
  Address.on_id_offset machine, id, offset
end

#-(offset) ⇒ Object



969
970
971
# File 'lib/wilson.rb', line 969

def - offset
  self + -offset
end

#get(address) ⇒ Object

TODO: test



956
957
958
959
# File 'lib/wilson.rb', line 956

def get address # TODO: test
  self.mov address
  self.mov {self}
end

#mObject



965
966
967
# File 'lib/wilson.rb', line 965

def m
  self + 0
end

#memory_register?Boolean

Returns:

  • (Boolean)


948
949
950
# File 'lib/wilson.rb', line 948

def memory_register?
  false
end

#push_mod_rm_on(spareRegister, stream) ⇒ Object



961
962
963
# File 'lib/wilson.rb', line 961

def push_mod_rm_on spareRegister, stream
  stream << (0b11000000 + id + (spareRegister.id << 3))
end

#register?Boolean

Returns:

  • (Boolean)


952
953
954
# File 'lib/wilson.rb', line 952

def register?
  true
end