class YASM::Command

Provides an interface for invoking the ‘yasm` utility.

## Examples

Assemble a binary file:

YASM::Command.run(syntax: :gas, file: 'hello_world.S', output: 'hello_world.o')

Assemble amd64 assembly, in GAS syntax, into an ELF64 file with debugging information:

YASM::Command.run do |yasm|
  yasm.target = :amd64

  yasm.syntax = :gas
  yasm.file   = 'hello_world.S'

  yasm.output        = 'hello_world.o'
  yasm.output_format = :elf64
  yasm.debug_format  = :stabs
end

## ‘yasm` options:

@since 0.3.0

@api public

Constants

TARGETS

The known YASM targets

Public Instance Methods

target() click to toggle source

Determines which target was set.

@return [:x86, :amd64, :lc3b, nil]

The target name or `nil` if no target has been set.
# File lib/yasm/command.rb, line 240
def target
  if arch && machine
    TARGETS.key(arch: arch.to_sym, machine: machine.to_sym)
  end
end
target=(name) click to toggle source

Sets that target.

@param [:x86, :amd64, :lc3b] name

The target name.

@return [Symbol]

The set target.

@raise [ArgumentError]

An unknown target name was given.
# File lib/yasm/command.rb, line 258
def target=(name)
  target = TARGETS.fetch(name.to_sym) do
    raise(ArgumentError,"unknown YASM target: #{name.inspect}")
  end

  self.arch    = target[:arch]
  self.machine = target[:machine]
  return name
end