I take this as an indication that I'm not the only one confused by the result of the carry bit following subtraction - I always get it wrong - (but thought I was just not suited to the mental gymnastics involved.) Richard > -----Original Message----- > From: Tony Nixon [mailto:Tony.Nixon@ENG.MONASH.EDU.AU] > Sent: Tuesday, September 28, 1999 11:24 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Snippets > > > Hi all, > > In light of all the discussion recently this may be off topic now ;-) > > > Just a few code snippets I discovered in the last two weeks while > writing some new software. > > if RAMx > Y > > movf RAMx,w > addlw 255 - Y ; eg if RAMx > 5 ... addlw d'250' > btfsc status,carry > goto True > > if RAMx < Y > > movf RAMx,w > addlw 255 - Y + 1 ; eg if RAMx < 5 ... addlw d'251' > btfss status,carry > goto True > > if RAMx >= Y > > movf RAMx,w > addlw 255 - Y + 1 ; eg if RAMx >= 5 ... addlw d'251' > btfsc status,carry > goto True > > if RAMx <= Y > > movf RAMx,w > addlw 255 - Y ; eg if RAMx <= 5 ... addlw d'250' > btfss status,carry > goto True > > > -- > Best regards > > Tony > http://www.picnpoke.com Email sales@picnpoke.com