Re: HAKMEM #169

hbaker@netcom.com (Henry Baker)
Tue, 11 Jul 1995 17:58:43 GMT

          From comp.compilers

Related articles
integer mod with constant modulus. rocky@panix.com (R. Bernstein) (1995-06-24)
HAKMEM #169 chase@centerline.com (1995-07-06)
Re: HAKMEM #169 hbaker@netcom.com (1995-07-11)
Re: HAKMEM #169 Tommy.Thorn@irisa.fr (1995-07-15)
| List of all articles for this month |

Newsgroups: comp.compilers
From: hbaker@netcom.com (Henry Baker)
Keywords: history, design, comment
Organization: nil
References: 95-06-047 95-07-065
Date: Tue, 11 Jul 1995 17:58:43 GMT

chase@centerline.com (David Chase) wrote:


> - be wary of untested "great hacks", even when they come from a renowned
> Institute of Technology.


I think that it would be fairer to let HAKMEM speak for itself.


If anyone is interested, the whole HAKMEM is available online at:
ftp://ftp.netcom.com/pub/hb/hbaker/hakmem/hakmem.html


There is also a pointer to the tiff G4 compressed scanned version
of HAKMEM in the html document.


Below is the actual text of HAKMEM 169. I can't find a single mention
of C, RISC, SPARC, ALPHA, POWERPC, Pentium, etc. Go figure.


<h3>ITEM 169 (in order of one-ups-manship: Gosper, Mann, Lenard, [Root and
Mann]):</h3>


To count the ones in a <a href="../pdp-10/pdp-10.html">PDP-6/10</a> word:


<tt><pre>
                LDB B,[014300,,A] ;or MOVE B,A then LSH B,-1
                AND B,[333333,,333333]
                SUB A,B
                LSH B,-1
                AND B,[333333,,333333]
                SUBB A,B ;each octal digit is replaced by number of
1's in it
                LSH B,-3
                ADD A,B
                AND A,[070707,,070707]
                IDIVI A,77 ;casting out 63.'s
</pre></tt>


These ten instructions, with constants extended, would work on word lengths up
to 62.; eleven suffice up to 254..


--
www/ftp directory:
ftp://ftp.netcom.com/pub/hb/hbaker/home.html
[Aha. It WAS faster on the PDP-6. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.