-
Assembly language in C
I was reading an article on assembly language in wikipedia and was a little suprised to read this line.
>>Relatively low-level languages, such as C, often provide special syntax to
>>embed assembly language directly in the source code.
Any ideas how to do that? Is it compiler specific?
-
-
It is compiler specific, but that's a pretty good explanation above. Another common syntax is
(IIRC that's what Borland compilers use)
-
As stated, it is compiler specific, so each compiler (that supports inline assembler at all) will have it's own variant.
MS Visual Studio uses the format.
--
Mats
-
So if im using code blocks on linux, which im pretty sure uses gcc, the format would be asm("")?
-
Yup, and that would work in windows using gcc too [as long as the assembler itself doesn't rely on unportable constructs - e.g. calling system calls or functions that aren't present on the other architecture]. And if you want to be ANSI compatible use __asm__.
--
Mats