Class: C8dasm::Opcode
- Inherits:
-
Object
- Object
- C8dasm::Opcode
- Defined in:
- lib/c8dasm/opcode.rb
Overview
Represents an opcode, in the sense of a disassembly file.
Examples
o = Opcode.new('a21e')
o.line #=> '200:a21e LD I, 21e ;Puts 21e into register I.'
o.opcode #=> 'a21e'
o.assembly #=> 'LD I, 21e'
o.comment #=> 'Puts 21e into register I.'
o.address #=> '200'
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#assembly ⇒ Object
readonly
Returns the value of attribute assembly.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#opcode ⇒ Object
readonly
Returns the value of attribute opcode.
Instance Method Summary collapse
-
#initialize(opcode, address: 0x200) ⇒ Opcode
constructor
Creates a new Opcode instance.
Constructor Details
#initialize(opcode, address: 0x200) ⇒ Opcode
Creates a new Opcode instance.
opcode - The String opcode to represents. address - The Fixnum address of this opcode. Default is 0x200.
20 21 22 23 24 25 26 27 28 |
# File 'lib/c8dasm/opcode.rb', line 20 def initialize(opcode, address: 0x200) @assembly = Assembly.new(opcode).to_s @opcode = opcode @comment = Comment.new(opcode).to_s @address = sprintf("%03x", address) @line = "#@address:#@opcode " + sprintf("%-14s", @assembly) + ";#@comment" end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
30 31 32 |
# File 'lib/c8dasm/opcode.rb', line 30 def address @address end |
#assembly ⇒ Object (readonly)
Returns the value of attribute assembly.
30 31 32 |
# File 'lib/c8dasm/opcode.rb', line 30 def assembly @assembly end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
30 31 32 |
# File 'lib/c8dasm/opcode.rb', line 30 def comment @comment end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
30 31 32 |
# File 'lib/c8dasm/opcode.rb', line 30 def line @line end |
#opcode ⇒ Object (readonly)
Returns the value of attribute opcode.
30 31 32 |
# File 'lib/c8dasm/opcode.rb', line 30 def opcode @opcode end |