fcml  1.1.3
Classes | Typedefs | Functions
fcml_lag_assembler.h File Reference

Experimental multiline load-and-go assembler implementation. More...

#include "fcml_symbols.h"
#include "fcml_assembler.h"

Go to the source code of this file.

Classes

struct  fcml_st_lag_assembler_result
 Result holder for load-and-go assembler. More...
 
struct  fcml_st_lag_assembler_context
 Load-and-go assembler runtime context. More...
 

Typedefs

typedef struct fcml_st_lag_assembler_result fcml_st_lag_assembler_result
 Result holder for load-and-go assembler. More...
 
typedef struct fcml_st_lag_assembler_context fcml_st_lag_assembler_context
 Load-and-go assembler runtime context. More...
 

Functions

LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_lag_assemble (fcml_st_lag_assembler_context *context, const fcml_string *source_code, fcml_st_lag_assembler_result *result)
 Multipass load-and-go assembler. More...
 
LIB_EXPORT void LIB_CALL fcml_fn_lag_assembler_result_prepare (fcml_st_lag_assembler_result *result)
 Prepares reusable result holder for assembler. More...
 
LIB_EXPORT void LIB_CALL fcml_fn_lag_assembler_result_free (fcml_st_lag_assembler_result *result)
 Cleans result holder. More...
 

Detailed Description

Experimental multiline load-and-go assembler implementation.

Typedef Documentation

Load-and-go assembler runtime context.

Result holder for load-and-go assembler.

Function Documentation

LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_lag_assemble ( fcml_st_lag_assembler_context context,
const fcml_string *  source_code,
fcml_st_lag_assembler_result result 
)

Multipass load-and-go assembler.

Assembles all instructions given in the NULL terminated source_code array of strings. Every instruction has to be represented as one string in the source array. Like every multipass assembler implementation it passes through the source code multiple times in order to generate optimal code. Assembler also supports symbols that can be provided using symbol table available in the context. Context should be initialized the same way as in case of one line assembler. The only difference here is the symbol table itself which can be initialized using fcml_fn_symbol_table_alloc() function. Symbols can be also declared directly in the source code and accessed through the same symbols table when processing is done (Only if you provide valid symbol table through the context). Reusable result holder has to be prepared using fcml_fn_lag_assembler_result_prepare() function. As long as the context and the result holder are not shared across multiple calls function is thread safe.

Parameters
contextAssembler context.
source_codeNULL terminated array of the instructions.
resultReusable result holder.
Returns
Error code or FCML_CEH_GEC_NO_ERROR.
Warning
This is an experimental implementation and it still needs some testing.
See also
fcml_fn_lag_assembler_result_prepare
fcml_fn_symbol_table_alloc
LIB_EXPORT void LIB_CALL fcml_fn_lag_assembler_result_free ( fcml_st_lag_assembler_result result)

Cleans result holder.

Frees all memory blocks allocated by the assembler and held inside the result holder (Instructions, errors etc.). Notice that result holder itself is not freed and can be even safety reused after call to this function. In fact this function is also called internally by assembler in order to clean result holder before reusing it.

Parameters
resultResult holder to clean.
LIB_EXPORT void LIB_CALL fcml_fn_lag_assembler_result_prepare ( fcml_st_lag_assembler_result result)

Prepares reusable result holder for assembler.

Every instance of fcml_st_lag_assembler_result structure is reusable from the assembler's point of view, so it has to be prepared in the right way in order to allow assembler to reuse it correctly. It is up to the library user to allocate space for the holder itself. This function is only responsible for cleaning the structure correctly and preparing it for first assembling process. Notice that assembler has to clean the result holder at the beginning so you can not pass an uninitialized memory block because it can even cause a crash due to illegal memory access.

Parameters
resultResult holder instance to be prepared.