Clang-14 compilation of User space c code leads to below build error.
{{
core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
:1:2384: note: instantiated into assembly here
.core.c:1274:2: error: invalid operand for instruction
“Init_entry:”
^
…
}}
The exact line of code that triggered error is as given below.
{{
scan_break_old( scanner, ctx) //prototype of function…please ignore exact name.
{
int ret = 0; asm(
“Init_entry:” —> Error triggered here.
“sub $64, %rsp;”
“push %r12;”
“push %r13;”
…
“or %r15, %rcx;”
“jmp Save_Exit_entry;”
);
return ret;
}
Any input why inline assembler code execution failing with above build error?
Seems the small piece of code is executed successfully in my system too with clang-14.0.6 compiler.
Let me attach full piece of code that is throwing error as i mentioned in my first comment and of course observed it in compiler explorer when i try to execute full piece of code.
It seems the diagnose info failed to locate the right position due to no line ending in the whole assembly. The true ill assembly is movzx which should be replaced by movzbq or movzwq.
Thank you for your input. That means ‘movzx’ is not recognized by clang compiler
where as confusion prevails in choosing between ‘movzbq’ or movzwq’ for operation between operands.? if register data length is byte size, then ‘movzbq’ should be used otherwise ‘movzwq’?
In movzx (%r10), %r13, the width of the memory location is ambiguous. There are two possible variants with a 64-bit destination: movzbq (1 byte memory location), or movzwq (2 byte memory location). (If the memory operand is 4 bytes, you would use a “mov” instead.) The GNU assembler will assume you meant movzbq, but clang requires explicitly specifying which one you mean.