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.



1019
1020
1021
1022
# File 'lib/wilson.rb', line 1019

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.



1013
1014
1015
# File 'lib/wilson.rb', line 1013

def id
  @id
end

Class Method Details

.on_id_bits(machine, id, bits) ⇒ Object



1015
1016
1017
# File 'lib/wilson.rb', line 1015

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

Instance Method Details

#+(offset) ⇒ Object



1049
1050
1051
# File 'lib/wilson.rb', line 1049

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

#-(offset) ⇒ Object



1045
1046
1047
# File 'lib/wilson.rb', line 1045

def - offset
  self + -offset
end

#get(address) ⇒ Object

TODO: test



1032
1033
1034
1035
# File 'lib/wilson.rb', line 1032

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

#mObject



1041
1042
1043
# File 'lib/wilson.rb', line 1041

def m
  self + 0
end

#memory_register?Boolean

Returns:

  • (Boolean)


1024
1025
1026
# File 'lib/wilson.rb', line 1024

def memory_register?
  false
end

#push_mod_rm_on(spareRegister, stream) ⇒ Object



1037
1038
1039
# File 'lib/wilson.rb', line 1037

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

#register?Boolean

Returns:

  • (Boolean)


1028
1029
1030
# File 'lib/wilson.rb', line 1028

def register?
  true
end