class N65::Label

This class represents a label, and will create an entry in the symbol table associated with the address it appears at.

Public Class Methods

new(symbol) click to toggle source

Create a new label object

# File lib/n65/directives/label.rb, line 24
def initialize(symbol)
  @symbol = symbol
end
parse(line) click to toggle source

Try to parse as a label

# File lib/n65/directives/label.rb, line 12
def self.parse(line)
  match_data = line.match(/^([a-zA-Z][a-zA-Z0-9_]+):$/)
  unless match_data.nil?
    label = match_data[1].to_sym
    return self.new(label)
  end
  nil
end

Public Instance Methods

exec(assembler) click to toggle source

Create an entry in the symbol table for this label

# File lib/n65/directives/label.rb, line 31
def exec(assembler)
  program_counter = assembler.program_counter
  assembler.symbol_table.define_symbol(@symbol, program_counter)
end
to_s() click to toggle source

Display

# File lib/n65/directives/label.rb, line 39
def to_s
  "#{@symbol}:"
end