> Date: Thu, 30 Apr 1998 16:29:33 +0100 > From: Michael Hearn > Subject: How do I NOT a number? > Dear all, > > I need to NOT a number for a control project my school is doing. However, > the instruction set for the PIC chip does not have a NOT. I think you can > do it using XOR but i'm not sure how that works. > > Please help, > Michael Hearn and Tom Furlong (Fallibroome High School, England) > > There are at least THREE ways. Other people have covered XOR and COMF, which you use 99% of the time. Another litle trick is 255 - A = NOT A For an 8 bit register ( (2^n)-1 - A, for an 'n' bit register) This can be a useful to know if you need to compliment the W register and put the result back in the W register. You need a register set to 255 (FF hex) which can be done once at the start of your code and left there (or find a register that is naturally FFh by default). SUBWF REG,0 Where REG is the register containing FFh. Will invert the contents of the W reg and put the results back in the W reg. This is a bit obscure but when you need to make your code run as fast as possible then knowing little tricks like this one can help. Jason (Technician - Manchester University, England) ______________________________________________________________________ A conclusion is simply the point where you got tired of thinking. PGP Public key available on request. Phone/Fax +44 (0)161 275 4094 Jason.Bent@man.ac.uk