Hi Tamas! On Dec 29, 2007 11:02 AM, Tamas Rudnai wrote: > > Yes, that's ok, the only thing is that as I can see Dwayne's original code > what he needs is: > > B[012] = A[012] + K[012] I see now, you are correct. > > So up front of your solution the A is needed to copy to B which is 6 > additional instructions. That's 6+11 or if you combine the first add with > the move then it'll be 5+10. In my interpretation the question is if there > is a better solution than the claimed 14 cycles without the ADDWFC > instruction. > > What I was thinking of is a 13 cycle version using rlf - could not test it > as I'm on a holiday far away from my computer, so it could be wrong... > Well, I tried in my superopt and you can do it in one ins less, using: ; B[012] = A[012] + K[012] , K const. movf A0,W addlw K0 movwf B0 clrf B1,F rlf B1,W addlw K1 addwf A1,W iorwf B1,F rlf A2,W subwf A2,W sublw K2 movwf B2 You can do better if K0 == 0 or K1 == 254, 255, 0 or 1. I also think that the middle segment is simpler than yours, and you can modify it for C = A + B also. Daniel. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist