Class Assemblers

java.lang.Object
ghidra.app.plugin.assembler.Assemblers

public final class Assemblers extends Object
The primary class for obtaining an Assembler for a Ghidra-supported language.

The general flow is: First, obtain an assembler for a language or program. Second, call its GenericAssembler.assemble(Address, String...) and related methods to perform assembly. More advanced uses pass a AssemblySelector to control certain aspects of assembly instruction selection, and to obtain advanced diagnostics, like detailed errors and code completion.

 Assembler asm = Assemblers.getAssembler(currentProgram);
 asm.assemble(currentAddress, "ADD ...");
 
  • Constructor Details

    • Assemblers

      public Assemblers()
  • Method Details

    • getBuilderForLang

      protected static AssemblerBuilder getBuilderForLang(Language lang)
      Get a builder for the given language, possibly using a cached one.
      Parameters:
      lang - the language
      Returns:
      the builder for that language, if successful
    • getAssembler

      public static Assembler getAssembler(Program program, AssemblySelector selector)
      Get an assembler for the given program.

      Provides an assembler suitable for the program's language, and bound to the program. Calls to its Assembler#assemble() function will cause modifications to the bound program. If this is the first time an assembler for the program's language has been requested, this function may take some time to build the assembler.

      Parameters:
      selector - a method to select a single result from many
      program - the program for which an assembler is requested
      Returns:
      the assembler bound to the given program
    • getAssembler

      public static Assembler getAssembler(Language lang, AssemblySelector selector)
      Get an assembler for the given language.

      Provides a suitable assembler for the given language. Only calls to its Assembler#assembleLine() method are valid. If this is the first time a language has been requested, this function may take some time to build the assembler. Otherwise, it returns a cached assembler.

      Parameters:
      selector - a method to select a single result from many
      lang - the language for which an assembler is requested
      Returns:
      the assembler for the given language
    • getAssembler

      public static Assembler getAssembler(Program program)
      Get an assembler for the given program.
      Parameters:
      program - the program
      Returns:
      a suitable assembler
      See Also:
    • getAssembler

      public static Assembler getAssembler(Language lang)
      Get an assembler for the given language.
      Parameters:
      lang - the language
      Returns:
      a suitable assembler
      See Also: