I try to compile a program as follow:
unsigned long func(int priority)
{
unsigned long a;
if (a)
__asm__ __volatile__("rep ; stosl"
: /* no outputs */ \
:"a" (0),"c" (1024),"D" (page)
:"ecx");
return a;
}
but meet a error:
a.c:6:3: error: ‘asm’ operand has impossible constraints
__asm__ __volatile__("rep ; stosl"
^~~~~~~
by modifying code and compiling again,I find it is "ecx" which causes error
if I delete it,such as
unsigned long func(int priority)
{
unsigned long a;
if (a)
__asm__ __volatile__("rep ; stosl"
: /* no outputs */ \
:"a" (0),"c" (1024),"D" (page)
);
return a;
}
there is no errors
asm allow syntax such as asm("....":output:input:Clobbers),so why my program meet error?
ps:my gcc is gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0,machine is x86-64