Just out of curiosity, if you're using an 18C (or 17C) part, why wouldn't you use the CPFSEQ, CPFSLT, or CPFSGT mnemonics? Ryan > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Scott Dattalo > Sent: Wednesday, September 29, 1999 6:30 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: More snippets > > > Let's see how the 18cxxx parts compare > > On Tue, 28 Sep 1999, Tony Nixon wrote: > > > Just following on from the previous snippets, > in an effort to make > > comparisons easier to understand, here are some > more. The best part is, > > the Z flag is ignored. > > > > if RAMx > RAMy > > > > movf RAMy,w > > sublw 0xFF > > addwf RAMx,w > > btfsc status,carry > > goto true > > movf RAMx,w ;wreg = RAMx > subwf RAMy,w ;wreg = RAMy - RAMx > bn true ;Branch if negative > ;The N bit will be cleared if > RAMx == RAMy or > ;RAMy > RAMx, and will be set if > RAMy < RAMx > > (or you could use the bnc [branch if no carry] to > achieve the same effect. > The negative bit has a clearer meaning in this context). > > 18cxxx 3*16 = 48 bits of program memory > 16cxxx 5*14 = 70 bits of program memory > > > btw, Tony's example can be shortened to: > > movf RAMx,w > subwf RAMy,w > skpc > goto true > > but there are still 4*14 = 52 bits. however this > works on the 12bit core, > so only 4*12 = 48 bits of program memory are > required there. > > > > > > if RAMx < RAMy > > > > movf RAMx,w > > sublw 0xFF > > addwf RAMy,w > > btfsc status,carry > > goto true > > > > Same as above with RAMx and RAMy exchanged. > > > if RAMx >= RAMy > > > > movf RAMx,w > > sublw 0xFF > > addwf RAMy,w > > btfss status,carry > > goto true > > > > movf RAMy,w ;wreg = RAMy > subwf RAMx,w ;wreg = RAMx - RAMy > bnn true ;branch if not negative > ;The N bit will be cleared if > RAMx == RAMy or > ;RAMx > RAMy, and will be set > if RAMy < RAMx > > Again, you could use the bc (branch on carry) > instruction too. Also, > Tony's sequence can be reduced by an instruction. > > > if RAMx <= RAMy > > > > movf RAMy,w > > sublw 0xFF > > addwf RAMx,w > > btfss status,carry > > goto true > > > > Scott