HAKMEM

trb at masscomp.UUCP trb at masscomp.UUCP
Fri Mar 9 06:51:34 AEST 1984


I have my copy right here...

;==================================================
ITEM 169 (Gosper, Lenard, Mann, Root):
To count the ones in a PDP6/10 word:
[numbers in octal, of course -trb]

	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 the number of ones in it
	LSH B,-3
	ADD A,B
	AND A,[070707,,070707]
	IDIVI A,77		; casting out 63's
;==================================================

I once figured out why this worked.


>From the MIT AIL bibliography description of HAKMEM:

   "I keep HAKMEM in the bathroom, it's great reading."  -Knuth


I think HAKMEM exists on disk at MIT or BBN somewhere.
No, you can't have my copy for $1000.

	Andy Tannenbaum   Masscomp Inc  Westford MA   (617) 692-6200 x274



More information about the Comp.unix.wizards mailing list