Re: how to inline "ROR/ROL" asm instructions in C ?? (help wanted)

New Message Reply About this list Date view Thread view Subject view Author view

Ge' Weijers (ge@Progressive-Systems.Com)
Thu, 8 Oct 1998 12:49:54 -0400 (EDT)


On Sun, 4 Oct 1998, Werner Koch wrote:

> #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

I use

    __asm__ ("roll %2,%0" : "=r"(x) : "0" (x) , "ic" ((unsigned char)n));

to get an inlined literal rotation count if it happens to be a
constant. A minor addition.

Ge'

-
Ge' Weijers Voice: (614)326 4600
Progressive Systems, Inc. FAX: (614)326 4601
2000 West Henderson Rd. Suite 400, Columbus OH 43220


New Message Reply About this list Date view Thread view Subject view Author view

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

The following archive was created by hippie-mail 7.98617-22 on Sat Apr 10 1999 - 01:15:20