On Tue, Mar 24, 2009 at 1:18 PM, Rodrigo Dominguez <rodd...@hotmail.com> wrote: > H.J, > > Thanks for replying but this doesn't answer my question. Shouldn't __asm__ > generate the right code without using the %b1 trick? The reason I am asking > is I have a 350 line macro which I can't change.
Those macros are wrong. > Is there any documentation about __asm__ default behavior regarding this > issue? Something like an Intel/AMD/AT&T manual explaining this? asm statement is compiler specific. It is documented in gcc manual. You can take a look at *.md in i386 to see how asm statement may be used: [...@gnu-13 i386]$ grep shr i386.md | grep %b shr{q}\t{%b2, %0|%0, %b2}" shr{l}\t{%b2, %0|%0, %b2}" shr{l}\t{%b2, %k0|%k0, %b2}" shr{w}\t{%b2, %0|%0, %b2}" shr{b}\t{%b2, %0|%0, %b2}" shr{b}\t{%b1, %0|%0, %b1}" [...@gnu-13 i386]$ H.J. --- > Thank you, > > Rodrigo > >> -----Original Message----- >> From: H.J. Lu [mailto:hjl.to...@gmail.com] >> Sent: Tuesday, March 24, 2009 2:09 PM >> To: Rodrigo Dominguez >> Cc: gcc@gcc.gnu.org >> Subject: Re: Inline Assembly Error: suffix or operands invalid for >> 'shr' >> >> On Tue, Mar 24, 2009 at 11:02 AM, Rodrigo Dominguez >> <rodd...@hotmail.com> wrote: >> > 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. >> > >> >> Please use >> >> __asm__ ("shrl %b1, %0\n\t" >> : "+r" (a) >> : "c" (-s) >> ); >> >> -- >> H.J. > > -- H.J.