Class: N65::ASCII

Inherits:
InstructionBase show all
Defined in:
lib/n65/directives/ascii.rb

Overview

This directive to include bytes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from InstructionBase

#unresolved_symbols?

Constructor Details

#initialize(string) ⇒ ASCII

Initialize with filename



22
23
24
# File 'lib/n65/directives/ascii.rb', line 22

def initialize(string)
  @string = string
end

Class Method Details

.parse(line) ⇒ Object

Try to parse an incbin directive



13
14
15
16
17
# File 'lib/n65/directives/ascii.rb', line 13

def self.parse(line)
  match_data = line.match(/^\.ascii\s+"([^"]+)"$/)
  return nil if match_data.nil?
  ASCII.new(match_data[1])
end

Instance Method Details

#exec(assembler) ⇒ Object

Execute on the assembler



29
30
31
# File 'lib/n65/directives/ascii.rb', line 29

def exec(assembler)
  assembler.write_memory(@string.bytes)
end

#to_sObject

Display



36
37
38
# File 'lib/n65/directives/ascii.rb', line 36

def to_s
  ".ascii \"#{@string}\""
end