Paul Haas wrote: > I'm sure someone on the list has a clever way of converting a number > in the range 0 to 7 into a bitmask with one bit set and vice versa. Paul: Here's the most obscure way I could come up with to convert from a number in the range [0-7] to a bitmask. 9 words of program space and between 3 and 10 cycles to execute. Note that this routine is subject to the usual "direct modification of the Program Counter" limitations (e.g., on a 16C5x, the whole thing must be in the first half of a page; and on the other parts, PCLATH must be set apropriately before the "ADDWF" is executed). ADDWF PCL ;CALCULATE 2^W, WHERE W IS IN THE ADDLW 0 ;RANGE [0-7]. ADDLW -1 ; ADDLW -3 ; ADDLW -7 ; ADDLW -15 ; ADDLW -31 ; ADDLW -63 ; ADDLW 121 ; -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - Vista, California === http://www.geocities.com/SiliconValley/2499