Class: ECUTools::Instruction
- Inherits:
-
Object
- Object
- ECUTools::Instruction
- Defined in:
- lib/instruction.rb
Instance Method Summary collapse
- #address ⇒ Object
- #assembly ⇒ Object
- #assembly=(value) ⇒ Object
- #binary ⇒ Object
- #bytes ⇒ Object
- #comments ⇒ Object
- #data ⇒ Object
- #data=(val) ⇒ Object
-
#initialize(address, bytes, assembly) ⇒ Instruction
constructor
A new instance of Instruction.
- #to_s ⇒ Object
Constructor Details
#initialize(address, bytes, assembly) ⇒ Instruction
Returns a new instance of Instruction.
4 5 6 7 8 9 10 |
# File 'lib/instruction.rb', line 4 def initialize(address, bytes, assembly) @address = address @bytes = bytes @assembly = assembly @comments = [] @data = !(/unknown/.match(assembly).nil?) end |
Instance Method Details
#address ⇒ Object
19 20 21 |
# File 'lib/instruction.rb', line 19 def address @address end |
#assembly ⇒ Object
31 32 33 |
# File 'lib/instruction.rb', line 31 def assembly @assembly end |
#assembly=(value) ⇒ Object
35 36 37 38 |
# File 'lib/instruction.rb', line 35 def assembly=(value) @assembly = value # TODO: Update bytes based on assembly instructions end |
#binary ⇒ Object
40 41 42 |
# File 'lib/instruction.rb', line 40 def binary @bytes.join.to_a.pack("H*") end |
#bytes ⇒ Object
44 45 46 |
# File 'lib/instruction.rb', line 44 def bytes @bytes end |
#comments ⇒ Object
48 49 50 |
# File 'lib/instruction.rb', line 48 def comments @comments end |
#data ⇒ Object
23 24 25 |
# File 'lib/instruction.rb', line 23 def data @data end |
#data=(val) ⇒ Object
27 28 29 |
# File 'lib/instruction.rb', line 27 def data=(val) @data=val end |
#to_s ⇒ Object
12 13 14 15 16 17 |
# File 'lib/instruction.rb', line 12 def to_s s = "0x#{@address}:\t#{@bytes.join(' ')}" s << "\t#{@assembly}" if (!data) s << "\t; #{@comments.join(', ')}" if @comments.length > 0 s end |