A member wrote: >better add some comments or a couple of weeks down the road, you'll forget how clever you are :) Thanks for the comment. Seems im not that clever at all. If i where, i would probably have found a better way to make money than to deal with programming of pics. Its just, sometimes spending of additional brain can replace spending of additional resources. In the end its only math. ; swapping vars without a third register: movf Variable_1,w ; w = (v1 + v2) and 255 xorwf Variable_2,w xorwf Variable_1,f ; v1 = (v1 + v2) -v1 == v2 xorwf Variable_2,f ; v2 = (v1 + v2) -v2 == v1 More swapping tricks, ; swapping vars, preserving contents of w and most status flags, no regs used xorwf Variable_1,w ; w = (w + v1) and 255 xorwf Variable_2,w ; w = (w + v2) and 255 xorwf Variable_1,f ; v1 = (v1 + v2 + w) -v1 == v2 + w xorwf Variable_2,f ; v2 = (v1 + v2 + w) -v2 == v1 + w xorwf Variable_1,w xorwf Variable_2,w ; w = (w -v%_k^#\oops !?? xorwf Variable_1,f xorwf Variable_2,f ; dunno why this one happens :) ; swapping the contents of a register with w xorwf Variable_1,w ; w = (w + v1) and 255 xorwf Variable_1,F ; v1 = (w + v1) -v1 == w xorwf Variable_1,W ; w = (w + v1) - w == v1 Personally i feel when used right, XOR is one of the most powerful instructions in assembler. In a sense it can compress 16 bits into 8. With full reversability and without loss of any information. Greetings Germain -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu