When I use Mac to compile the intel inline assembly, it gives me error. Some one can help me?
Asked
Active
Viewed 476 times
0
-
#include
int main(void){ unsigned int x,y; x=42; y=24; asm volatile("add %0 %1": "=r"(x) :"r" (y) : "cc"); printf("Hello world\n",x); } – KYRA Luo Aug 06 '22 at 15:56 -
1: Post code as text, not images. 2: Add the compiler output. `I get an error` is _not enough information_, we actually do need to _see_ the error message to understand the problem. – tkausl Aug 06 '22 at 15:59
-
1Judging from the error, clang doesn't seem to support `-masm=intel`? It substituted `%eax` for example. – Jester Aug 06 '22 at 16:00
-
3You're missing a comma between the operands. – prl Aug 06 '22 at 16:25
-
1@Jester: Only very recent clang acts like GCC in having `-masm=intel` handle `asm()` statements as Intel syntax. [Can I use Intel syntax of x86 assembly with GCC?](https://stackoverflow.com/q/9347909) says clang 14 and later. – Peter Cordes Aug 06 '22 at 22:17
-
[What is the "purpose" of commas in intel syntax?](https://stackoverflow.com/q/62101792) is only answered in comments, but it's why x86 asm needs commas between operands. – Peter Cordes Aug 06 '22 at 22:27