This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Inline Assembly Error: suffix or operands invalid for 'shr'
- From: "Rodrigo Dominguez" <roddomi at hotmail dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Tue, 24 Mar 2009 14:02:34 -0400
- Subject: Inline Assembly Error: suffix or operands invalid for 'shr'
Hi,
While debugging a problem with Open64, I ran into a similar problem with
GCC. I created the following unit test program:
#include <stdint.h>
int main(void)
{
uint32_t a = 7;
int8_t s = -1;
__asm__ ("shrl %1, %0\n\t"
: "+r" (a)
: "c" (-s)
);
return a;
}
When assembling this program, 'cc1' emits a 'shrl %ecx, %eax' instruction.
The 'shr' instruction can only take an 8-bit register as the first operand.
The emitted instruction should have been 'shrl %cl, %eax'. Therefore, the
compilation fails with a 'suffix or operands invalid for shr' message.
I have 2 questions:
1. AFAIK, by default, __asm__ chooses a register according to the size of
the operand (int8_t in this case). Is this correct? Where can I find
documentation of this?
2. If #1 is true, why does this fail?
Thank you,
Rodrigo