I want to move a 64-bit unsigned integer to a register using inline asm. What happens is a constant that extends the sign if it actually matches 32 bits.
Here is my code:
#include "stdint.h" uint64_t foo() { uint64_t x; asm ("movq %1, %0" : "=q" (x) : "i" (0x00000000faceffff) ); return x; }
Now clang -S code.c creates the following assembly:
#APP movq $-87097345, %rax
The same goes for gcc. Same thing for movabsq instead of movq . The same goes for the "p" restriction instead of the "i" .
I get the result that I expect if the constant is greater than 32 bits.
source share