Path: utzoo!attcan!uunet!husc6!rutgers!deimos!uxc!uxc.cso.uiuc.edu!m.cs.uiuc.edu!wsmith From: wsmith@m.cs.uiuc.edu Newsgroups: comp.arch Subject: Re: Leading zero and pop count Message-ID: <3300039@m.cs.uiuc.edu> Date: 19 Nov 88 18:11:00 GMT References: <10882@hall.cray.com> Lines: 23 Nf-ID: #R:hall.cray.com:10882:m.cs.uiuc.edu:3300039:000:646 Nf-From: m.cs.uiuc.edu!wsmith Nov 19 12:11:00 1988 >One thing that is difficult to do in software (counter examples are welcomed >please!) and easy to do in hardware is to reverse a bit stream. What exactly to you mean by bit stream? If you mean a single word, it is very easy. If it is more than a word the same trick may be used on a larger scale: (This is actually Pete Madany's code on loan.) union WC { unsigned int w; unsigned char c[4]; } in, out; out.c[3] = table[in.c[0]]; out.c[2] = table[in.c[1]]; out.c[1] = table[in.c[2]]; out.c[0] = table[in.c[3]]; The 256 byte array, table, begins { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0 ... } Bill Smith wsmith@cs.uiuc.edu uiucdcs!wsmith