No problem. Indeed I was expecting already that somebody had created it before. I searched in the piclist.com source code library and did not find it, so I wanted to know if somebody had published it somewhere. Perhaps I am the first to publish it. Isaac Em 20/1/2012 18:37, Bob Ammerman escreveu: >> OK, sometimes we have luck, others not. >> >> But if the code is not very known, this is the chance for others to >> learn it. >> >> >> Best regards, >> >> Isaac >> > Isaac, > > Don't get me wrong. It is an elegant solution to the problem and you shou= ld=20 > be proud for coming up with it. > > -- Bob > > > >> Em 20/1/2012 17:10, Bob Ammerman escreveu: >>> Sorry, been there and done that. >>> >>> -- Bob Ammerman >>> >>> ----- Original Message -----=20 >>> From: "Isaac Marino Bavaresco" >>> To: "Microcontroller discussion list - Public." >>> Sent: Friday, January 20, 2012 11:48 AM >>> Subject: [PIC] New(?) way for rotating a variable number of positions >>> inassembly >>> >>> >>>> I was needing an (very) efficient way to rotate a byte a variable numb= er >>>> 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. >>>> >>>> Did somebody already know it or can I boast that I invented it? >>>> >>>> >>>> Isaac >>>> >>>> --=20 >>>> http://www.piclist.com PIC/SX FAQ & list archive >>>> View/change your membership options at >>>> http://mailman.mit.edu/mailman/listinfo/piclist >> --=20 >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist=20 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .