www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/25/17:34:29

Sender: nate AT cartsys DOT com
Message-ID: <36FAB8D8.FCDF7886@cartsys.com>
Date: Thu, 25 Mar 1999 14:29:44 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.2.3 i586)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Inline assembly - rotate left
References: <4125673F DOT 005E129F DOT 00 AT derumg01 DOT cyberlink DOT eds DOT com>
Reply-To: djgpp AT delorie DOT com

david DOT stegbauer AT cz DOT opel DOT com wrote:
> 
> Hi,(I do not need help)
> 
> here is my solution how to do bit rotation via inline assembly.
> So, if this is stupid hint, don't beat my head, nor softly :-)
> 
> #ifdef __DJGPP__
>     #define roll(val,cnt) asm volatile (\
>         "movl %2, %%ecx \n\t" \
>         "roll %%cl, %1" \
>             :"=r" (val) \
>             :"r"(val), "r"(cnt) \
>             :"%ecx")
> #endif /*__DJGPP__*/

> Well, I really tested it on longs only, but this message is
> meant more as hint than I expect you will use it. Also
> I believe this can be done more elegant.

You can dispense with the `mov' by specifying "c" as the constraint for
`cnt'.  This will also allow you not to clobber %ecx, since it's
unchanged by the rol.

And if you want it to act more like a function in the mathematical sense
(where the value is returned), you might use GCC's
statement-as-expression extension.
-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019