class N65::IncBin

This directive instruction can include a binary file

Public Class Methods

new(filename) click to toggle source

Initialize with filename

# File lib/n65/directives/incbin.rb, line 26
def initialize(filename)
  @filename = filename
end
parse(line) click to toggle source

Try to parse an incbin directive

# File lib/n65/directives/incbin.rb, line 16
def self.parse(line)
  match_data = line.match(/^\.incbin "([^"]+)"$/)
  return nil if match_data.nil?
  filename = match_data[1]
  IncBin.new(filename)
end

Public Instance Methods

exec(assembler) click to toggle source

Execute on the assembler

# File lib/n65/directives/incbin.rb, line 33
def exec(assembler)
  unless File.exists?(@filename)
    fail(FileNotFound, ".incbin can't find #{@filename}")
  end
  data = File.read(@filename).unpack('C*')
  assembler.write_memory(data)
end
to_s() click to toggle source

Display

# File lib/n65/directives/incbin.rb, line 44
def to_s
  ".incbin \"#{@filename}\""
end