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

David R. Conrad (drc@adni.net)
Wed, 7 Oct 1998 05:58:05 -0400 (EDT)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 5 Oct 1998, Marcus Watts wrote:

> Some compilers actually know how to generate rotate instructions.
> Gnu cc 2.6.2 for i386 will produce a rotate instruction for this
> code:

2.6.2 is pretty old. Did you mean 2.7.2?

> subr(j)
> unsigned long j;
> {
> return (j<<5 | (j >> (32-5)));
> }
> (It's not very smart about this. Changing | to + breaks this.
> Also, it doesn't know how to generate a rotate by a variable
> amount, which is a shame because this really helps rc6.)

I tried some variations on this with gcc from egcs-1.1b:

  return (j<<5 | (j >> (32-5))); /* yup, works */
  return (j<<5 + (j >> (32-5))); /* nope, still breaks with + */
  return (j<<i | (j >> (32-i))); /* works by variable amt */
  return (j<<i + (j >> (32-i))); /* nope, breaks with + */

By "works" I mean that a "roll" instruction was emitted, whereas by breaks
I mean that a couple of shifts were emitted. (This is on an i386
architecture, in case that isn't obvious from the context. (Actually a
pentium 166 non-MMX box running Linux 2.1.123.))

This version of GCC identified itself as:

.ident "GCC: (GNU) egcs-2.91.57 19980901 (egcs-1.1 release)"

So apparently they have fixed the inability to do rotates by a variable
number of bits, but they haven't addressed the issue of addition vs. or.

David R. Conrad <drc@adni.net>

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/AwUBNhs7R4POYu8Zk+GuEQK+SACeJsjUVzBUXZrHeaQiUP7P9A6ufOQAoJYU
IYPimNCc6121J+p9ajiCL34d
=ndkh
-----END PGP SIGNATURE-----


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