[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] XaAES sources for FreeMiNT 1.16.3



Vincent Rivière <vincent.riviere@freesbee.fr> writes:

> Andreas Schwab a écrit :
>>> - assembler instructions with no equivalent in C: rol
>>
>> Actually, gcc can generate optimal code for a rotate operation if the
>> expression is written carefully.
>
> Examples welcome.

unsigned int rotate (unsigned int a, int n)
{
  return (a << n) | (a >> (sizeof (a) * 8 - n));
}

(It's more difficult for smaller integer types unless the count is
constant.)

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."