Werner Koch (wk@isil.d.shuttle.de)
Sun, 4 Oct 1998 14:34:41 +0200
Steven Cooper <scoop@insight.cas.mcmaster.ca> writes:
> Can someone tell me how best to write a C function (that can be "inlined")
> that invokes the appropriate assembly language instruction??
#if defined(__GNUC__) && defined(__i386__)
static inline u32
rol(int n, u32 x)
{
__asm__("roll %%cl,%0"
:"=r" (x)
:"0" (x),"c" (n));
return x;
}
#else
#define rol(n,x) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif
> The platform I am working on is Sun/64-bit/Ultra/Unix/Solaris 2.6
I have no Sparc or Alpha manuals here, so I can't tell the insn for
these CPUs (but if you have figured it out I'd be glad so have them
too).
> In particular, how do you invoke an assembley language instruction
> and cause it to operate on the appropriate registers that correspond
> to specific local variables in your C program???
It is easy with gcc ("info gcc"), it is also described somewhere in
the Watcom-C manuals. Dunno about other compilers.
Werner
The following archive was created by hippie-mail 7.98617-22 on Sat Apr 10 1999 - 01:15:19