Class: N65::IncBin
- Inherits:
-
InstructionBase
- Object
- InstructionBase
- N65::IncBin
- Defined in:
- lib/n65/directives/incbin.rb
Overview
This directive instruction can include a binary file
Defined Under Namespace
Classes: FileNotFound
Class Method Summary collapse
Instance Method Summary collapse
- #exec(assembler) ⇒ Object
-
#initialize(filename) ⇒ IncBin
constructor
A new instance of IncBin.
- #to_s ⇒ Object
Methods inherited from InstructionBase
Constructor Details
#initialize(filename) ⇒ IncBin
Returns a new instance of IncBin.
18 19 20 |
# File 'lib/n65/directives/incbin.rb', line 18 def initialize(filename) @filename = filename end |
Class Method Details
Instance Method Details
#exec(assembler) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/n65/directives/incbin.rb', line 22 def exec(assembler) raise(FileNotFound, ".incbin can't find #{@filename}") unless File.exist?(@filename) data = File.read(@filename).unpack('C*') assembler.write_memory(data) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/n65/directives/incbin.rb', line 29 def to_s ".incbin \"#{@filename}\"" end |