Does anyone know how I can get rid of the following assembler warning?
Code is x86, 32 bit:
int test (int x)
{
int y;
// do a bit-rotate by 8 on the lower word. leave upper word intact.
asm ("rorw $8, %0\n\t": "=q"(y) :"0"(x));
return y;
}
If I compile it I get the following (very valid) warning:
Warning: using `%ax' instead of `%eax' due to `w' suffix
What I'm looking for is a way to tell the compiler/assembler that I want to access the lower 16 bit sub-register of %0. Accessing the byte sub-registers (in this case AL and AH) would be nice to know as well.
I've already choosen the "q" modifier, so the compiler is forced to use EAX, EBX, ECX or EDX. I've made sure the compiler has to picks a register that has sub-registers.
I know that I can force the asm-code to use a specific register (and it's sub-registers), but I want to leave the register-allocation job up to the compiler.