>> I'm pretty sure this is a stupid question, but is >> there an easy way to convert a number into it's >> appropriate bit position? > Not sure what the FAQ says but you can do it this way: > #define SET_BIT(n) (unsigned char)(1L<<(n)) Shifting a single bit N positions is the standard solution. There are two problems I have with this particular solution... 1) This solution is C compiler based, and I do all my SX/PIC stuff in ASM. Most assemblers have a shift operator as well. Looks to me like in mpasm, the shift operator is "<<", just like C. You can use a C pre-processor with an assembler, if you want to. (Hmm. I wonder how compiler vendors with freeware "small" compilers feel about people using their compiler as a macro processor for mpasm?) CPP macros have the advantage of not needing to be on their own line in the source code... 2) This solution is compile time dependent, and does not provide a runtime solution. In C, an "adequate" compiler will do the shift either at compile time or at execution time, depending on whether "b" is a constant or a variable. Making that dertmination at assembly time is more difficult, but then it's also usually more obvious to the programmer... At runtime, you either loop and shift, or do a table lookup. BillW -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body