1
0
mirror of https://github.com/safiire/n65.git synced 2024-06-11 07:29:27 +00:00
n65/lib/n65/directives/ascii.rb
2020-08-30 13:57:46 -07:00

29 lines
516 B
Ruby

# frozen_string_literal: true
require_relative '../instruction_base'
module N65
# This directive to include bytes
class ASCII < InstructionBase
def self.parse(line)
match_data = line.match(/^\.ascii\s+"([^"]+)"$/)
return nil if match_data.nil?
ASCII.new(match_data[1])
end
def initialize(string)
super
@string = string
end
def exec(assembler)
assembler.write_memory(@string.bytes)
end
def to_s
".ascii \"#{@string}\""
end
end
end