Err... its not what I thought I wanted, but that approach is pretty darn nice... Why did I get into two jumps when I tried that... hmmm.... If W and fr are the same value, the carry flag will be set so you also have to check the zero flag, and you do. Nice. My solution uses the same number of instructions, but uses only one skip (carry or no carry) But what about fr <= w ? --- James Newton mailto:jamesnewton@geocities.com 1-619-652-0593 -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Scott Dattalo Sent: Friday, September 29, 2000 15:31 To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PICLIST] Code challenge: fr > w or fr <= w On Fri, 29 Sep 2000, j newton wrote: > Ok, I have a code challenge... > > On a 16C5x (ok, actually an SX), I have a value in W and a value in a > register (call it fr), and I need to subtract W + 1 from the value of fr and > not put the result in fr. I.e. I need to find out if fr > w or maybe fr <= w > with out destroying fr. Munching W is, of course, ok. ;------------------- ; ; fr > W subwf fr,W skpnc skpnz goto fr_is_less_than_or_equal_to_W fr_is_greater_than_W If you subtract W from fr, then the Carry flag will be set and the Zero flag cleared when fr is greater than W. Is that what you want? Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's -- http://www.piclist.com hint: PICList Posts must start with ONE topic: "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's