comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Bit manipulation
Date: Sun, 12 Nov 2000 06:40:25 GMT
Date: 2000-11-12T06:40:25+00:00	[thread overview]
Message-ID: <tXqP5.414419$i5.7067378@news1.frmt1.sfba.home.com> (raw)
In-Reply-To: 3A0E3116.83AEC906@acm.org

>I take it you want the resulting bit pattern to be the reverse of the
>original bit pattern.
>...
>The fastest but most space-consuming solution would use a look-up table.
Swap parts and use a lookup table to swap bits within those parts, eg:
  type Bytes is mod 256;
  type Reversibles is array(1 .. 4) of Bytes;
  Xlate : constant array(Bytes) of Bytes :=
    (16#00000000#,16#10000000#,16#01000000#,16#11000000#,
     16#00100000#,16#10100000#,16#01100000#,16#11100000#,
     16#00010000#,16#10010000#,16#01010000#,16#11010000#,
     16#00110000#,16#10110000#,16#01110000#,16#11110000#,
     16#00001000#,16#10001000#,16#01001000#,16#11001000#,
     16#00101000#,16#10101000#,16#01101000#,16#11101000#,
     16#00011000#,16#10011000#,16#01011000#,16#11011000#,
     16#00111000#,16#10111000#,16#01111000#,16#11111000#,
     16#00000100#,16#10000100#,16#01000100#,16#11000100#,
     16#00100100#,16#10100100#,16#01100100#,16#11100100#,
     16#00010100#,16#10010100#,16#01010100#,16#11010100#,
     16#00110100#,16#10110100#,16#01110100#,16#11110100#,
     16#00001100#,16#10001100#,16#01001100#,16#11001100#,
     16#00101100#,16#10101100#,16#01101100#,16#11101100#,
     16#00011100#,16#10011100#,16#01011100#,16#11011100#,
     16#00111100#,16#10111100#,16#01111100#,16#11111100#,
     16#00000010#,16#10000010#,16#01000010#,16#11000010#,
     16#00100010#,16#10100010#,16#01100010#,16#11100010#,
     16#00010010#,16#10010010#,16#01010010#,16#11010010#,
     16#00110010#,16#10110010#,16#01110010#,16#11110010#,
     16#00001010#,16#10001010#,16#01001010#,16#11001010#,
     16#00101010#,16#10101010#,16#01101010#,16#11101010#,
     16#00011010#,16#10011010#,16#01011010#,16#11011010#,
     16#00111010#,16#10111010#,16#01111010#,16#11111010#,
     16#00000110#,16#10000110#,16#01000110#,16#11000110#,
     16#00100110#,16#10100110#,16#01100110#,16#11100110#,
     16#00010110#,16#10010110#,16#01010110#,16#11010110#,
     16#00110110#,16#10110110#,16#01110110#,16#11110110#,
     16#00001110#,16#10001110#,16#01001110#,16#11001110#,
     16#00101110#,16#10101110#,16#01101110#,16#11101110#,
     16#00011110#,16#10011110#,16#01011110#,16#11011110#,
     16#00111110#,16#10111110#,16#01111110#,16#11111110#,
     16#00000001#,16#10000001#,16#01000001#,16#11000001#,
     16#00100001#,16#10100001#,16#01100001#,16#11100001#,
     16#00010001#,16#10010001#,16#01010001#,16#11010001#,
     16#00110001#,16#10110001#,16#01110001#,16#11110001#,
     16#00001001#,16#10001001#,16#01001001#,16#11001001#,
     16#00101001#,16#10101001#,16#01101001#,16#11101001#,
     16#00011001#,16#10011001#,16#01011001#,16#11011001#,
     16#00111001#,16#10111001#,16#01111001#,16#11111001#,
     16#00000101#,16#10000101#,16#01000101#,16#11000101#,
     16#00100101#,16#10100101#,16#01100101#,16#11100101#,
     16#00010101#,16#10010101#,16#01010101#,16#11010101#,
     16#00110101#,16#10110101#,16#01110101#,16#11110101#,
     16#00001101#,16#10001101#,16#01001101#,16#11001101#,
     16#00101101#,16#10101101#,16#01101101#,16#11101101#,
     16#00011101#,16#10011101#,16#01011101#,16#11011101#,
     16#00111101#,16#10111101#,16#01111101#,16#11111101#,
     16#00000011#,16#10000011#,16#01000011#,16#11000011#,
     16#00100011#,16#10100011#,16#01100011#,16#11100011#,
     16#00010011#,16#10010011#,16#01010011#,16#11010011#,
     16#00110011#,16#10110011#,16#01110011#,16#11110011#,
     16#00001011#,16#10001011#,16#01001011#,16#11001011#,
     16#00101011#,16#10101011#,16#01101011#,16#11101011#,
     16#00011011#,16#10011011#,16#01011011#,16#11011011#,
     16#00111011#,16#10111011#,16#01111011#,16#11111011#,
     16#00000111#,16#10000111#,16#01000111#,16#11000111#,
     16#00100111#,16#10100111#,16#01100111#,16#11100111#,
     16#00010111#,16#10010111#,16#01010111#,16#11010111#,
     16#00110111#,16#10110111#,16#01110111#,16#11110111#,
     16#00001111#,16#10001111#,16#01001111#,16#11001111#,
     16#00101111#,16#10101111#,16#01101111#,16#11101111#,
     16#00011111#,16#10011111#,16#01011111#,16#11011111#,
     16#00111111#,16#10111111#,16#01111111#,16#11111111#);

  function Swap (X : REVERSIBLES) return REVERSIBLES is
  begin
    return (Xlate(X(4)), Xlate(X(3)), Xlate(X(2)), Xlate(X(1)));
  end Swap;



  parent reply	other threads:[~2000-11-12  6:40 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-07  0:00 Bit manipulation Sandro Binetti
2000-11-07  0:00 ` gdemont
2000-11-08  7:22   ` Sandro Binetti
2000-11-07  0:00 ` Larry Kilgallen
2000-11-07  0:00   ` John English
2000-11-08  0:00   ` gdemont
2000-11-08  0:00     ` Robert Dewar
2000-11-08  0:00       ` gdemont
2000-11-08  0:00         ` Larry Kilgallen
2000-11-09  4:50           ` Robert Dewar
2000-11-10  0:00             ` Lao Xiao Hai
2000-11-09  4:47         ` Robert Dewar
2000-11-09  0:00           ` gdemont
2000-11-08  0:00       ` Sandro Binetti
2000-11-08  0:00         ` Dale Stanbrough
2000-11-09  0:00           ` Sandro Binetti
2000-11-09  0:00             ` gdemont
2000-11-09  0:00             ` Ken Garlington
2000-11-10  0:00             ` Scott Ingram
2000-11-08  0:00         ` gdemont
2000-11-09  4:00           ` Ken Garlington
2000-11-09  0:00             ` Larry Kilgallen
2000-11-09  0:00               ` Ken Garlington
2000-11-08  0:00         ` Nicolas Brunot
2000-11-09  3:59         ` Ken Garlington
2000-11-09  4:52         ` Robert Dewar
2000-11-11  0:00       ` Redryder
2000-11-11  0:00         ` Jeff Carter
2000-11-11  0:00           ` Redryder
2000-11-12  2:07             ` Ken Garlington
2000-11-12  5:56             ` Jeff Carter
2000-11-12  0:00               ` Robert Dewar
2000-11-12  0:00                 ` tmoran
2000-11-13  0:00                   ` Robert Dewar
2000-11-14  0:00                     ` Marc A. Criley
2000-11-13  0:54                   ` Ken Garlington
2000-11-12  6:40               ` tmoran [this message]
2000-11-13  0:00         ` Lutz Donnerhacke
2000-11-13  0:00           ` Robert Dewar
2000-11-13  0:00             ` Lutz Donnerhacke
2000-11-13  0:00               ` Robert Dewar
2000-11-13  0:00                 ` Lutz Donnerhacke
2000-11-13  0:00           ` Robert Dewar
2000-11-13  0:00             ` Lutz Donnerhacke
2000-11-13  0:00               ` Robert Dewar
2000-11-13  0:00                 ` Lutz Donnerhacke
2000-11-13  0:00                   ` Pat Rogers
2000-11-13  0:00                     ` Brian Rogoff
2000-11-13  0:00                       ` F. Britt Snodgrass
2000-11-15  0:00                         ` Lutz Donnerhacke
2000-11-13  0:00                       ` Pat Rogers
2000-11-14  0:00                       ` Georg Bauhaus
2000-11-15  0:00                         ` Lutz Donnerhacke
2000-11-14  0:00                   ` Martin Dowie
2000-11-15  0:00                     ` Lutz Donnerhacke
2000-11-20  0:00                 ` Randy Brukardt
2000-11-21  0:00                   ` Lutz Donnerhacke
2000-11-21  0:00                     ` Stephen Leake
2000-11-22  0:00                       ` Lutz Donnerhacke
2000-11-08  7:18   ` Sandro Binetti
2000-11-10  7:24 ` Thank you all for your contribution ! Sandro Binetti
  -- strict thread matches above, loose matches on Subject: below --
2005-02-07 12:37 Bit manipulation Maurizio
2005-02-07 13:20 ` Martin Krischik
2005-02-07 15:32 ` Martin Dowie
2005-02-07 18:04   ` Martin Krischik
2005-02-08  0:32 ` Randy Brukardt
2005-02-08  3:11 ` Steve
2005-02-08 18:51   ` tmoran
1999-04-04  0:00 bit manipulation Jack Chow
1999-04-04  0:00 ` Matthew Heaney
1999-04-05  0:00 ` dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox