asm

Applies to C Applies to C++

Purpose

Controls the interpretation of and subsequent generation of code for an asm statement.

Syntax

Applies to C The default is -qasm=gcc, independent of the language level. Specifying -qasm without a suboption is equivalent to specifying the default.

        .-asm=gcc-.
>>- -q--+-asm-----+--+------+----------------------------------><
        '-noasm---'  '-=gcc-'
 
 

Applies to C++ The default is also-qasm=gcc, independent of the language level.

        .-asm=gcc-.
>>- -q--+-asm-----+--+--------------+--------------------------><
        '-noasm---'  '-=-+-gcc----+-'
                         '-stdcpp-'
 
 

Notes

The -qasm option and its negative form control whether or not code is emitted for an asm statement. The positive form of the option directs the compiler to generate code for asm statements in the source code. The suboptions specify the syntax used to interpret the content of the asm statement. For example, specifying -qasm=gcc instructs the compiler to recognize the extended gcc syntax and semantics for asm statements.

Applies to C The token asm is not a C language keyword. Therefore, at language levels stdc89 and stdc99, which enforce strict compliance to the C89 and C99 standards, respectively, the option -qkeyword=asm must also be specified to compile source that generates assembly code. At all other language levels, the token asm is treated as a keyword unless the option -qnokeyword=asm is in effect. In C, the XL-specific variants __asm and __asm__ are keywords at all language levels and cannot be disabled.

Applies to C++ The tokens asm, __asm, and __asm__ are keywords at all language levels. Suboptions of -qnokeyword=token can be used to disable each of these reserved words individually.

Predefined macros

Whenever asm is treated as a keyword, the compiler predefines one of the following mutually exclusive macros, depending on the assembly language syntax specified. If assembler code is generated, the macro has the value 1; otherwise, 0.

__IBM_GCC_ASM
__IBM_STDCPP_ASM (C++ only)

Informational messages

When the option -qinfo=eff is also in effect, the compiler emits an informational message if no code is generated for an asm statement.

Whenever an asm statement is recognized as a valid language feature, the option -qinfo=por instructs the compiler to report it in an informational message. At C language levels stdc89 or stdc99, the option -qkeyword=asm must also be in effect.

Example

The following code snippet shows a simple use of the -qasm compiler option:

int a, b, c;
int main() {
    asm("add %0, %1, %2" : "=r"(a) : "r"(b), "r"(c) );
}

Related references

IBM Copyright 2003