DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Enhanced asm facility

Using asm macros

The enhanced asm facility allows you to define constructs that behave syntactically like static C functions. Each asm macro has one definition and zero or more uses per source file. The definition must appear in the same file with the uses (or be #included), and the same asm macro may be defined multiply (and differently) in several files.

The asm macro definition declares a return type for the macro code, specifies patterns for the formal parameters, and provides bodies of code to expand when the patterns match. When it encounters an asm macro call, the compiler replaces uses of the formal parameters by its idea of the assembly language locations of the actual arguments as it expands the code body. This constitutes an important difference between C functions and asm macros. An asm macro can therefore have the effect of changing the value of its arguments, whereas a C function can only change a copy of its argument values.

The uses of an asm macro look exactly like normal C function calls. They may be used in expressions and they may return values. The arguments to an asm macro may be arbitrary expressions, except that they may not contain uses of the same or other asm macros.

When the argument to an asm macro is a function name or structure, the compiler generates code to compute a pointer to the structure or function, and the resulting pointer is used as the actual argument of the macro.


Next topic: Definition
Previous topic: Use

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003