Re: D
On Tue, 15 Jul 2003, Paul Hsieh wrote:[color=blue]
>
> In article <bf0hot$r78$1@e lf.eng.bsdi.com >, nospam@elf.eng. bsdi.com says...[color=green]
> > Paul Hsieh <qed@pobox.co m> writes:[color=darkred]
> > >If I want a platform specific rotate then I'll just write:
> > >
> > >int rot(int,char);
> > >#pragma aux rot = "rol eax, cl" parm [eax] [cl] value [eax];
> > >
> > >thank you very much.[/color]
> >
> > But this does not work at all -- I wanted a 24-bit rotate![/color][/color]
More likely 28. ;-)
[color=blue][color=green]
> > Seriously, has no one yet noticed that "rotate" is inherently a
> > three-input operation? We have the bit mask to rotate, the number
> > of bits in that bit mask, and the number of bits by which the rotate
> > should happen.
> >
> > Of course, all this "rotate" stuff is a red herring; the *correct*
> > primitive is "funnel shift", which is a *four*-input operation
> > (left side, right side, number of bits in each side, and position
> > of selector). Rotation is obtained by making the left and right
> > sides identical, and barrel-shifting is obtained by making one of
> > "left side" or "right side" all-zero-bits.[/color]
>
> Your ill attempt at humor is [a non sequitur].[/color]
Not really humor. More like a technical description of the semantics
of the family of operations you've been calling "shift" and "rotate."
It's perfectly true that x86-style fixed-width rotate instructions
are fairly useless, compared to the "funnel shift" operation Chris
describes. Of course, with more than two inputs it's hard to make
this operation a primitive "operator" in C; that's why you don't want
to think about it. I still haven't figured out why you really *want*
a (or several) "rotate operator(s)" when an inline function is just
as fast, and can take the multiple inputs it needs to do the job right,
plus specializations for values of 'n' or 'b' that are easy to do
on whatever architecture you're targeting.
[color=blue]
> Ordinary rotates happen a lot.[/color]
Define "ordinary." Do you perhaps mean "32-bit rotates, with the
right-hand operator truncated modulo 32 and stored in the CL register"?
(--Now, that *was* an ill attempt at humor.)
[color=blue]
> Name me one feistel crypto algorithm that *DOESN'T* use a rotate. DES,
> BlowFish, MD5, they *all* use rotate.[/color]
Blowfish does not use a rotate.
DES uses a 28-bit rotate.
MD5 actually does use a 32-bit rotate. Congrats!
[I am not a cryptography expert.]
-Arthur
On Tue, 15 Jul 2003, Paul Hsieh wrote:[color=blue]
>
> In article <bf0hot$r78$1@e lf.eng.bsdi.com >, nospam@elf.eng. bsdi.com says...[color=green]
> > Paul Hsieh <qed@pobox.co m> writes:[color=darkred]
> > >If I want a platform specific rotate then I'll just write:
> > >
> > >int rot(int,char);
> > >#pragma aux rot = "rol eax, cl" parm [eax] [cl] value [eax];
> > >
> > >thank you very much.[/color]
> >
> > But this does not work at all -- I wanted a 24-bit rotate![/color][/color]
More likely 28. ;-)
[color=blue][color=green]
> > Seriously, has no one yet noticed that "rotate" is inherently a
> > three-input operation? We have the bit mask to rotate, the number
> > of bits in that bit mask, and the number of bits by which the rotate
> > should happen.
> >
> > Of course, all this "rotate" stuff is a red herring; the *correct*
> > primitive is "funnel shift", which is a *four*-input operation
> > (left side, right side, number of bits in each side, and position
> > of selector). Rotation is obtained by making the left and right
> > sides identical, and barrel-shifting is obtained by making one of
> > "left side" or "right side" all-zero-bits.[/color]
>
> Your ill attempt at humor is [a non sequitur].[/color]
Not really humor. More like a technical description of the semantics
of the family of operations you've been calling "shift" and "rotate."
It's perfectly true that x86-style fixed-width rotate instructions
are fairly useless, compared to the "funnel shift" operation Chris
describes. Of course, with more than two inputs it's hard to make
this operation a primitive "operator" in C; that's why you don't want
to think about it. I still haven't figured out why you really *want*
a (or several) "rotate operator(s)" when an inline function is just
as fast, and can take the multiple inputs it needs to do the job right,
plus specializations for values of 'n' or 'b' that are easy to do
on whatever architecture you're targeting.
[color=blue]
> Ordinary rotates happen a lot.[/color]
Define "ordinary." Do you perhaps mean "32-bit rotates, with the
right-hand operator truncated modulo 32 and stored in the CL register"?
(--Now, that *was* an ill attempt at humor.)
[color=blue]
> Name me one feistel crypto algorithm that *DOESN'T* use a rotate. DES,
> BlowFish, MD5, they *all* use rotate.[/color]
Blowfish does not use a rotate.
DES uses a 28-bit rotate.
MD5 actually does use a 32-bit rotate. Congrats!
[I am not a cryptography expert.]
-Arthur
Comment