On Sep 13, 2005, at 6:48 PM, Mike Hord wrote: >> I've heard about interesting trick shifting bits individually >> into different positions by multiplying on constant on micros >> with hardware multiplication unit. > > Pretty simple, actually. A left shift (towards the MSB) is the > same as a multiply by 2. Each subsequent by 2 is a shift. > > So a shift by three bits to the left requires a multiply by... Or did you mean something more complicated, like these bit reversal algorithms from MIT's "hakmem" document: ;if A is 6 bit quantity, B gets 6 bits reversed (Schroeppel) IMUL A,[2020202] ;4 copies shifted AND A,[104422010] ;where bits coincide with reverse repeated base 2^8 IDIVI A,377 ;casting out 2^8 - 1's ;reverse 7 bits (Schroeppel) IMUL A,[10004002001] ;4 copies sep by 000's base 2 (may set arith. o'flow) AND A,[210210210010] ;where bits coincide with reverse repeated base 2^8 IDIVI A,377 ;casting out 377's ;reverse 8 bits (Schroeppel) MUL A,[100200401002] ;5 copies in A and B AND B,[20420420020] ;where bits coincide with reverse repeated base 2^10 ANDI A,41 ;" DIVI A,1777 ;casting out 2^10 - 1's > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist