next up previous
Next: Non-Standard Language Constructs of Up: The XASM External Language Previous: External C-functions

Embedding XASM-programs in C-applications

If the XASM-part of a system should provide services for a C-based application, the main asm and all sub-asms of it can be called from the C-code. In this case, the XASM-compiler must be invoked with a special option that prevents the generation of the ``main''-function.

Before any of the asms can be invoked, the XASM-part must be initialized. For this purpose, the generated C-code defines the function ``asm_main'' as follows:



\begin{asmbox}
\mbox{\tt int asm\_main(int argc, char **argv);}
\end{asmbox}


The arguments to this function are given as strings which are parsed and transformed to corresponding ``ASMOBJs''. The actual invocation of the main asm can be made using the C-function ``run_mainasm'':


\begin{asmbox}
\mbox{\tt ASMOBJ run\_mainasm();}
\end{asmbox}

This kind of embedding is actually used in the implementation of the XASM-compiler itself: the static semantics check is carried out by an algorithm specified in XASM.

A number of external C-functions are already integrated into the runtime system. For example, external functions to communicate using UNIX-Sockets, string manipulation functions, file access functions etc. .



Philipp Kutter 2002-03-18