3 ms·
Inline assembly isn't standard C or C++ though?
by mehrdadn 9y ago
Inline assembly isn't standard C or C++ though?
- mbel 9y agoBut still can be (and is) used to implement some features from the standard library.
- pjmlp 9y agoIt is pseudo standard in C++. Meaning ANSI C does not refer at all to inline Assembly, from its point of view it does not exist. ANSI C++ on other hand, specifies the asm keyword and that it should enable a compiler specific way to write inline Assembly. But yeah, neither of them actually specifies how it should look.
- foldr 9y agoThere have always been library features in the C and C++ standards that can't be implemented using standard C or C++. setjmp and longjmp would be the obvious examples.
- FrankHB 9y agoIt isn't. Quoted from the C++ standard: "the asm declaration is conditionally-supported; its meaning is implementation-defined". ISO C does not differ much in conformance (the asm keyword is common extension listed in annex J). There exists implementation without inline assembly support, e.g. MSVC x64. There are alternative keywords used in practice (e.g. `__asm` or `__asm__ __volatile__`). Actually the contents are not supposed to be assembly language in all cases when it is supported, as I know there exists implementation with JavaScript as the "assembly" (Cheerp). Even the implementation supports "genuine" assembly, it varies in syntax, e.g. for x86, Intel (MSVC), AT&T (Clang), or both (GCC) ? So no, you can't expect it too much, if you have to.