class Directive

Defines basic assembler directives.

Public Class Methods

new(template) click to toggle source
# File directive.rb, line 22
def initialize(template)
  @template = template
end

Public Instance Methods

align(value, fill_with=-1) click to toggle source
# File directive.rb, line 26
def align(value, fill_with=-1)
  factory = @template.template.getDirectiveFactory
  factory.newAlign(value, 2 ** value, fill_with)
end
ascii(text, term, strings) click to toggle source
# File directive.rb, line 97
def ascii(text, term, strings)
  factory = @template.template.getDirectiveFactory
  factory.newStrings(text, term, strings)
end
balign(value, fill_with=-1) click to toggle source
# File directive.rb, line 31
def balign(value, fill_with=-1)
  factory = @template.template.getDirectiveFactory
  factory.newAlignByte(value, fill_with)
end
comment(text) click to toggle source
# File directive.rb, line 70
def comment(text)
  factory = @template.template.getDirectiveFactory
  factory.newComment(text)
end
data(type, values, align) click to toggle source
The following directives are configured via data_config
# File directive.rb, line 79
def data(type, values, align)
  factory = @template.template.getDirectiveFactory
  dataBuilder = factory.getDataValueBuilder type.to_s, align
  values.each do |value|
    if value.is_a?(Float) then
      dataBuilder.addDouble value
    else
      dataBuilder.add value
    end
  end
  dataBuilder.build
end
method_missing(meth, *args, &block) click to toggle source
# File directive.rb, line 104
def method_missing(meth, *args, &block)
  raise "Unknown assembler directive '#{meth}'"
end
option(value) click to toggle source
# File directive.rb, line 60
def option(value)
  factory = @template.template.getDirectiveFactory
  factory.newOption(value)
end
org(origin, is_absolute=false) click to toggle source
# File directive.rb, line 41
def org(origin, is_absolute=false)
  factory = @template.template.getDirectiveFactory
  if origin.is_a?(Integer)
    if is_absolute
      factory.newOriginAbsolute origin # Absolute
    else
      factory.newOrigin origin # Section-Based
    end
  elsif origin.is_a?(Hash)
    delta = get_attribute origin, :delta
    if !delta.is_a?(Integer)
      raise "delta (#{delta}) must be an Integer"
    end
    factory.newOriginRelative delta # Relative
  else
    raise "origin (#{origin}) must be an Integer or a Hash"
  end
end
p2align(value, fill_with=-1) click to toggle source
# File directive.rb, line 36
def p2align(value, fill_with=-1)
  factory = @template.template.getDirectiveFactory
  factory.newAlignPower2(value, 2 ** value, fill_with)
end
space(text, data, length) click to toggle source
# File directive.rb, line 92
def space(text, data, length)
  factory = @template.template.getDirectiveFactory
  factory.newSpace(text, data, length)
end
text(text) click to toggle source
# File directive.rb, line 65
def text(text)
  factory = @template.template.getDirectiveFactory
  factory.newText(text)
end