Greetings Scott. ;-) Just trying to remind another solution. MOVLW 1 BTFSC y,1 MOVLW 4 MOVWF MASK BTFSC y,0 ADDWF MASK,f BTFSC y,2 SWAPF MASK,f WBR Dmitry. -- __ /\/\ Universe /_/\_\ are \/__\/ Infinity > You may wish to consider a variation of something Mike Kietz > posted some time ago: > > movf y,w > andlw 011b > movwf mask > incf mask,w ;00 -> 01, 01 -> 10, 10 -> 11, 11->100 > btfsc mask,1 ;If bit1 is a 1 then > iorwf mask,f ;the IORWF will set the lower two bits > ;At this point, here's what we've got > ;bits 1&0 mask > ; 0 0 00000000 > ; 0 1 00000001 > ; 1 0 00000011 > ; 1 1 00000111 > incf mask,f ; mask = 1 << (y&3) > btfsc y,2 ;place the mask bit in the upper nibble > swapf mask,f ;if y is greater than 3. > > ; at this point, you've got 2^y. > > I use something like in the single-cycle resolution pwm code I posted a > while back. > > Depending on what you're exactly attempting to accomplish, it might be > possible to merge this algorithm with the flag that you're checking. I > sorta kinda do that in the pwm code. > > Scott > > PS. I know this works because I just simulated it using gpsim (after > compiling it using gpasm, of course)!