delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/02/13:23:43

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199706021721.AA028672063@typhoon.rose.hp.com>
Subject: Re: big endian class
To: keithh AT zetnet DOT co DOT uk (Keith Hull)
Date: Mon, 02 Jun 1997 10:21:02 PDT
Cc: djgpp AT delorie DOT com
In-Reply-To: <1997060116282677565@zetnet.co.uk>; from "Keith Hull" at Jun 1, 97 4:28 pm

> or
> 
>       dummy = (data & 0x000000ff) << 24;
>       dummy = dummy | ((data & 0x0000ff00) << 8);
>       dummy = dummy | ((data & 0x00FF0000) >> 8);
>       dummy = dummy | ((data & 0xFF000000) >> 24);
Even thats more than necessary.  From Intels action code for 
bswap 

dst = (rotate_left(src 8) & 0x00FF00FF)
      + (rotate_left(src 24) & 0xFF00FF00)

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

Andrew

- Raw text -


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