On Wed, 26 Sep 2001, Regulus Berdin wrote: Reggie, welcome back. > Hi Scott, > > I'll try (untested): > > ;x <<= y; > > clrc > btfsc y,0 > rlf x,f ;x = x*2 > > clrc > rlf x,w ;w = x*2 > addwf x,w ;w = w+x = x*2+x = x*3 > btfsc y,1 > addwf x,f ;x = w+x = x*3+x = x*4 > > swapf x,w > andlw 0xF0 > btfsc y,2 > movwf x ;x=x*8 Interesting. Mine is slightly different and is suitable for this type of operation: unsigned char x; unsigned char y; unsigned char z; z = x << y; swapf x,w andlw 0xf0 btfss y,2 movf x,w movwf z btfss y,0 addwf z,f rlf z,w andlw 0xfe addwf z,w btfsc y,1 addwf x,f ----------------- Dmitry, The "unsigned char" implies an 8-bit register (at least on all of the C compilers that target a PIC that I know of). Only the lower three bits of the shift count are examined. It looks like an additional 4 instructions would be required to verify that the upper bits are not set. ------ Now, to do the same thing in a looping snippet: ; if x and z are different registers movf x,w movwf z comf y,w ; the shift count ; note w= 0-y+1 rrf z,f loop: rlf z,f addlw 1 skpc goto loop Scott -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.