Re: c inline assembly

Gedare Bloom <[email protected]> Sun, 19 Feb 2012 11:46:46 -0500
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <CAC82fA3Anm7LRzq8z0HoAeEvy_ck=U9rc49WDddBZHR9f==0XA@mail.gmail.com>
On Sat, Feb 18, 2012 at 1:01 AM, ratheesh kannoth
<[email protected]> wrote:
> I am using gcc on a 32bit  intel machine.  i have defined an inline function.
>
>
> This function is inline .  what all registers needs to pushed and
> poped in the inline assembly so that the functions wont
> disturb the registers in  the function ( in which it is C inlined  ).
>
Use the clobber list:
http://ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html#ss5.3

>
> inline unsigned long hello(unsigned long a)
>
> {
>  int b;
>  asm ("movl %1, %%eax;
>      " movl %1, %%ebx;
>       "movl  %1, %%ecx;
>       "movl  %1, %%esi;
>       "movl  %1, %%edi;
>
>       "movl %%eax, %0;"
>       :"=r"(b)        /* output */
>       :"r"(a)         /* input */
         : "eax","ecx","esi","edi" /* clobber */
>  );
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html