Newsgroups: comp.arch
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: HW v. SW (was RISC v. CISC --more misconceptions)
Message-ID: <1988Nov8.175129.9534@utzoo.uucp>
Organization: U of Toronto Zoology
References: <156@gloom.UUCP> <18931@apple.Apple.COM> <40@sopwith.UUCP> <998@l.cc.purdue.edu> <1622@scolex> <866@cernvax.UUCP>
Date: Tue, 8 Nov 88 17:51:29 GMT

In article <866@cernvax.UUCP> hjm@cernvax.UUCP (Hubert Matthews) writes:
>The INMOS T800 has an instruction bitrevword, which turns a
>little-endian word into a big-endian word...
>In software, it takes quite some time.  In hardware it takes just over 
>1 microsecond on a 30MHz part.  There is also a bitrevnbits which
>reverses the bottom n bits in a byte and it takes n+4 cycles at 30MHz.
>Again, not very quick in software.

Don't be quite so quick to assume that things like this are impossibly
slow in software.  If you're willing to invest some memory in it, most
bit manipulations can be done *much* more quickly by table lookup than
by "doing it the hard way".  Bitrevnbits is mask, add, memory access,
and or; could be as little as 4 (not n+4) cycles on a 29000, for example.
Skip the or if you're only interested in those bits; skip the mask if
you've got them isolated in a register in the first place.  And you can
do any mapping, not just a reversal.

(This admittedly does not apply to bitrevword unless you're willing to
use a biiiiig table! :-))
-- 
The Earth is our mother.        |    Henry Spencer at U of Toronto Zoology
Our nine months are up.         |uunet!attcan!utzoo!henry henry@zoo.toronto.edu
