Class Assemblers
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
Constructor Details
-
Assemblers
public Assemblers()
-
-
Method Details
-
getBuilderForLang
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
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:
program
- the program for which an assembler is requestedselector
- a method to select a single result from many- Returns:
- the assembler bound to the given program
-
getAssembler
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:
lang
- the language for which an assembler is requestedselector
- a method to select a single result from many- Returns:
- the assembler for the given language
-
getAssembler
Get an assembler for the given program.- Parameters:
program
- the program- Returns:
- a suitable assembler
- See Also:
-
getAssembler
Get an assembler for the given language.- Parameters:
lang
- the language- Returns:
- a suitable assembler
- See Also:
-