fasmcpp  0.1
Public Member Functions | List of all members
fasmcpp::Assembly Class Reference

Contains assembly code and its bytecode and predefinitions. More...

#include <fasmcpp.h>

Public Member Functions

 Assembly ()
 Constructs an empty, but valid instance.
 
 Assembly (const char *code)
 Constructs an instance and sets the code to be built.
 
 Assembly (const Assembly &)=delete
 
 Assembly (Assembly &&)
 
Assembly & operator= (const Assembly &)=delete
 
Assembly & operator= (Assembly &&)
 
void setAssembler (Assembler *assembler)
 Assigns an Assembler.
 
Assembler * getAssembler () const
 Returns the assigned Assembler.
 
bool assemble ()
 Builds the code using Flat Assembler. More...
 
int64_t run (bool preserveRegisters=true) const
 
const char * getErrors () const
 Returns a string containing any errors found during the build process.
 
const char * getMessages () const
 Returns user messages displayed by using the display directive.
 
void addPredefinition (const char *name, const char *value)
 Adds a predefinition. More...
 
void addPredefinition (const char *name, const void *value)
 Adds a pointer predefinition. More...
 
void clearPredefinitions ()
 Removes all previously added predefinitions.
 
const char * getOutput ()
 Returns a pointer to the output of the assembler.
 
size_t getOutputSize ()
 Returns the size of the output of the assembler.
 

Detailed Description

Contains assembly code and its bytecode and predefinitions.

Member Function Documentation

◆ addPredefinition() [1/2]

void fasmcpp::Assembly::addPredefinition ( const char *  name,
const char *  value 
)

Adds a predefinition.

Adding a predefinition through this method is equivalent to adding name=value to the assembly code

Parameters
nameName of the definition (maximum length is 255 characters)
valueValue of the definition
Exceptions
std::invalid_argumentif name is too long

◆ addPredefinition() [2/2]

void fasmcpp::Assembly::addPredefinition ( const char *  name,
const void *  value 
)

Adds a pointer predefinition.

Prefer this for defining pointers. Equivalent to addPredefinition(name, std::to_string(reinterpret_cast<uintptr_t>(value)).c_str()).

Parameters
nameName of the definition (maximum length is 255 characters)
valueValue of the definition
Exceptions
std::invalid_argumentif name is too long

◆ assemble()

bool fasmcpp::Assembly::assemble ( )

Builds the code using Flat Assembler.

Exceptions
std::invalid_argumentif there is no valid Assembler bound. See setAssembler().
std::runtime_erroron x64 platforms if out of predefinitions memory.
Returns
true if successful and false if failed.

◆ run()

int64_t fasmcpp::Assembly::run ( bool  preserveRegisters = true) const

Runs the code previously built by assemble()

Parameters
preserveRegistersIf true, fasmcpp backs up all non-volatile registers
Returns
Return code set from assembly depending on the call convention.
Exceptions
std::runtime_errorif an error occurred while assembling.
std::logic_errorif assemble() has not been called.

The documentation for this class was generated from the following file: