Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C++
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Variations across compilers==== Different C++ compilers implement inline assembly in distinct ways. * GCC ([[GNU Compiler Collection]]) and [[Clang]]:<ref>{{Cite web |title=Extended Asm (Using the GNU Compiler Collection) |url=https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html |website=GCC Online Documentation |publisher=GNU Project |access-date=1 April 2025}}</ref> Use the GCC extended inline assembly syntax. Using <syntaxhighlight lang="C++" inline>__asm__</syntaxhighlight> keyword instead of <syntaxhighlight lang="C++" inline>asm</syntaxhighlight> when writing code that can be compiled with <syntaxhighlight lang="C++" inline>-ansi</syntaxhighlight> and <syntaxhighlight lang="C++" inline>-std</syntaxhighlight> options, which allows specifying input/output operands and clobbered registers. This approach is widely adopted, including by Intel<ref name="IntelInlineAssembly">Intel Corporation. "[https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-9/inline-assembly.html Inline Assembly]". ''Intel® C++ Compiler Classic Developer Guide and Reference'', Version 2021.9. Retrieved 1 April 2025.</ref> and IBM<ref name="IBMInlineAssembly">IBM. "[https://www.ibm.com/docs/en/xl-c-aix/13.1.3?topic=statements-inline-assembly-extension Inline assembly statements (IBM extension)]". ''IBM Documentation''. Retrieved 1 April 2025.</ref> compilers. * MSVC ([[Microsoft Visual C++]]): The inline assembler is built into the compiler. Previously supported inline assembly via the <syntaxhighlight lang="C++" inline>__asm</syntaxhighlight> keyword, but this support has been removed in 64-bit mode, requiring separate .asm modules instead.<ref>{{Cite web |title=Inline Assembler Overview |url=https://learn.microsoft.com/en-us/cpp/assembler/inline/inline-assembler-overview?view=msvc-170 |website=Microsoft Learn |publisher=Microsoft |access-date=1 April 2025}}</ref> * TI ARM Clang and Embedded Compilers:<ref>{{Cite web |title=Interfacing C and C++ With Assembly Language |url=https://software-dl.ti.com/codegen/docs/tiarmclang/compiler_tools_user_guide/compiler_manual/runtime_environment/interfacing-c-and-c-with-assembly-language-stdz0544217.html#interfacing-c-and-c-with-assembly-language |website=Texas Instruments |publisher=Texas Instruments Incorporated |date=23 February 2025 |access-date=1 April 2025}}</ref> Some embedded system compilers, like Texas Instruments' TI Arm Clang, allow inline assembly but impose stricter rules to avoid conflicts with register conventions and calling conventions.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)