Package ghidra.app.plugin.assembler
Class Assemblers
- java.lang.Object
-
- ghidra.app.plugin.assembler.Assemblers
-
public final class Assemblers extends java.lang.Object
The primary class for obtaining anAssembler
for a Ghidra-supported language. The general flow is: First, obtain an assembler for a language or program. Second, call itsAssembler#assemble(Address, String)
and related methods to perform assembly. More advanced uses pass aAssemblySelector
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 Summary
Constructors Constructor Description Assemblers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Assembler
getAssembler(Language lang)
Get an assembler for the given language.static Assembler
getAssembler(Language lang, AssemblySelector selector)
Get an assembler for the given language.static Assembler
getAssembler(Program program)
Get an assembler for the given program.static Assembler
getAssembler(Program program, AssemblySelector selector)
Get an assembler for the given program.protected static AssemblerBuilder
getBuilderForLang(Language lang)
Get a builder for the given language, possibly using a cached one.
-
-
-
Method Detail
-
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 manyprogram
- 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 manylang
- 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(Program, AssemblySelector)
-
getAssembler
public static Assembler getAssembler(Language lang)
Get an assembler for the given language.- Parameters:
lang
- the language- Returns:
- a suitable assembler
- See Also:
getAssembler(Language, AssemblySelector)
-
-