asm

suggest change

The asm keyword takes a single operand, which must be a string literal. It has an implementation-defined meaning, but is typically passed to the implementation’s assembler, with the assembler’s output being incorporated into the translation unit.

The asm statement is a declaration, not an expression, so it may appear either at block scope or namespace scope (including global scope). However, since inline assembly cannot be constrained by the rules of the C++ language, before C++20 asm may not appear inside a constexpr function. Since C++20 it may, as long as it is not evaluated during constant evaluation.

Example:

[[noreturn]] void halt_system() {
    asm("hlt");
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents