>>I was needing an (very) efficient way to rotate a byte a variable number >> of positions when the following popped on my mind: >> >> >> btfsc TABLAT, 2, ACCESS >> swapf PRODL, F, ACCESS >> btfsc TABLAT, 1, ACCESS >> rrncf PRODL, F, ACCESS >> btfsc TABLAT, 1, ACCESS >> rrncf PRODL, F, ACCESS >> btfsc TABLAT, 0, ACCESS >> rrncf PRODL, F, ACCESS >> >> >> The number of positions to rotate is in TABLAT and the value to be >> rotated is in PRODL. >> The routine can rotate from zero to 7 positions, takes only 8 >> instructions and as a bonus it is isochronous. Actually, this algorithm properly handles rotate counts from 0 through 255! -- Bob Ammerman=20 RAm Systems --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .