reversing a mask

Arthur David Olson ado at elsie.UUCP
Sun Nov 25 10:03:27 AEST 1984


[Usenet brand software--ask for it by name]

> What's the fastest way to reverse a 16-bit mask in C?  In 68000 asl?
> (Maybe this should be in net.puzzle!)

Nah. . .too easy:

static int revtab[65536] = {
	0x0000, 0x8000, 0x4000, 0xc000,

	/* . . .16,382 lines of code left out to keep net costs down. . . */

	0x3fff, 0xbfff, 0x7fff, 0xffff
};

#define reverse(value)	(revtab[(unsigned int) value])

. . .with suitable documentation about range and type of the parameter being the
responsibility of the caller. :-)
--
Mask is a Wrather Corporation trademark--as Clayton Moore knows all too well.
--
	..decvax!seismo!elsie!ado			(301) 496-5688
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks



More information about the Comp.lang.c mailing list