> -----Original Message----- > From: Graham North [SMTP:graham.north@CIRRUSRESEARCH.CO.UK] > Sent: Thursday, March 13, 2003 9:48 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Subtract? > > Hi everyone, > > I need to subtract 1 from a byte on the 18F6720, and I'm confused by the > fact that there seem to be four instructions to subtract in the > instruction > set. > > There is: > > SUBFWB Subtract f from W with borrow > > SUBLW Subtract W from literal > > SUBWF Subtract W from f > > SUBWFB Subtract W from f with Borrow > > I have a byte called New_Low_Byte, and need to subtract 1 from it. I'm > confused as to the fastest way to do it. > > Any help would be great. > > Thanks > > Graham > Subtracting 1 is a special case, the fastest way is to use the DECF (decrement file) instruction: decf New_Low_Byte,F You can also check for zero after the decrement using decfsz and decfsnz. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= Any questions about Bookham's E-Mail service should be directed to postmaster@bookham.com. -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads