delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/02/18:33:04

Date: Tue, 03 Jun 1997 10:29:21 -0700
From: Bill Currie <billc AT blackmagic DOT tait DOT co DOT nz>
Subject: Re: big endian class
To: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Cc: djgpp AT delorie DOT com
Reply-to: billc AT blackmagic DOT tait DOT co DOT nz
Message-id: <33945471.6B4A@blackmagic.tait.co.nz>
Organization: Tait Electronics NZ
MIME-version: 1.0
References: <199706021721 DOT AA028672063 AT typhoon DOT rose DOT hp DOT com>

Andrew Crabtree wrote:
> Even thats more than necessary.  From Intels action code for
> bswap
> 
> dst = (rotate_left(src 8) & 0x00FF00FF)
>       + (rotate_left(src 24) & 0xFF00FF00)

Hmm, I wander what that will optimise to on a 386.

Thanks for the code, it looks good (and I would never have though of
it).

> Of course, you need a bitwise rotate operator, which C doesn't have.
> Inline asm should work though.

Not quite true, gcc will optimise (x<<8)|(x>>24) to (assuming eax is
used for x) roll $8,%eax.

Bill
-- 
Leave others their otherness.

- Raw text -


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