Mail Archives: djgpp/1999/03/25/17:34:29
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 -