I’m trying to rewrite my C code to Zig.
But this part with the inline assembler causes problems.
...
asm volatile(
"movq $0,-%c0(%%rsp)"
::
"i"(sizeof(CalleeRegs) + sizeof(ScratchRegs) + sizeof(uint64_t))
);
...
To compile it I used GCC, which supports the use of the c
prefix, which removes the dollar sign before the operand. As far as I know, the Zig compiler uses clang as a frontend for compiling C\C++ and apparently the inline assembler too. Clang does not support such a prefix and does not have a similar alternative.
At the moment, my Zig code looks like this:
...
asm volatile(
"movq $0,-%[size](%%rsp)"
::[size]"i"(size)
);
...
And it does not work:
error: error: <inline asm>:1:2: expected relocatable expression
movq $0,-$136(%rsp)
^
I tried to use the Intel syntax (.intel_syntax
), but it seems that it does not support the use of operands for the inline assembler.
Maybe someone has encountered a similar problem and knows a solution, I will be very grateful for any help.