#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 LuoAug 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.
– tkauslAug 06 '22 at 15:59
1
Judging from the error, clang doesn't seem to support `-masm=intel`? It substituted `%eax` for example.
– JesterAug 06 '22 at 16:00
@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 CordesAug 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 CordesAug 06 '22 at 22:27