C++ asm Keyword
Example
Put a processor instruction inside C++ code:
int x = 5;
asm("nop"); // nop is a processor instruction that does nothing
cout << x;
Definition and Usage
The asm keyword lets you write assembly code inside C++ code. Assembly code is low-level code that is written directly for the processor (CPU).
What asm does depends on the compiler and the processor. Some compilers do not support it, and assembly code for one processor does not work on another. This is why this page has no "Try it Yourself" example.
Most programs never need asm. Normal C++ code is easier to read, and it works on all computers.
Related Pages
Read more about compilers in our C++ Get Started Tutorial.