This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: asm inline
- From: Ian Lance Taylor <iant at google dot com>
- To: Sergey Ivanov <icegood1980 at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 24 Jul 2012 15:07:17 -0700
- Subject: Re: asm inline
- References: <CAJCbrz4jB9dabALkYn9Z0jHhDx5JYxNkZNyimy+ReCskG79hMg@mail.gmail.com> <CAJCbrz7YSngGYeu+vZGL1N8esr1XbU0xpAV6XL03QqSn=32www@mail.gmail.com>
On Tue, Jul 24, 2012 at 2:31 PM, Sergey Ivanov <icegood1980@gmail.com> wrote:
> Have code:
> #define MoveIntArrayToRight(IntCnt, LastSrcPos) \
> __asm__ __volatile__ \
> ( \
> "std\n\t" \
> "movl 4(%%esi), %%edi\n\t" \
> "rep\n\tmovsl\n\t" \
> "cld\n\t" \
> : \
> :"S" (LastSrcPos), "c" (IntCnt) \
> : "%ecx", "%esi", "%edi" , "cc", "memory" \
> )
>
> why compiler says
> "error: can’t find a register in class ‘CREG’ while reloading ‘asm’"
Because you said that IntCnt has a constaint "c", which means it must
be in %ecx, and you've also said that the asm clobbers %ecx, meaning
that no values can be placed in it. The asm is unsatisfiable and the
compiler simply crashes.
Ian