piclist 1995\12\08\200800a >
Thread: Negative numbers?
face BY : Eric Smith email (remove spam text)

> I need to check that a value, which will be a slightly variable code value,
> is between an upper and a lower threshold (or not).

Here's an excerpt from a "comparison" tip page I'm working on:

Testing that a value lies within a range

In this example, the value in the W register will be tested to determine
whether it lies within the range specified by the constants loval and hival
(inclusive).  In other words, we're testing loval <= W <= hival.

It might seem that this would take six instructions (using the methods
previously described), but it can actually be done in four:

       addlw   256-hival
       addlw   (hival-loval)+1
       btfsc   status,cf
       goto    inrange

Of course, you can change the last two lines to:

       btfss   status,cf
       goto    outofrange


In reply to: <m0tO078-00026hC@goonsquad.spies.com> (message from Steven Addison on Fri, 8 Dec 1995 10:39:42 +0000)
See also: www.piclist.com/techref/index.htm?key=negative+numbers
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Negative numbers?

month overview.

new search...