Andrew Warren email (remove spam text)
Steven Addison <MITVMA.MIT.EDU> wrote: PICLIST
It's simple. After a subtraction, the Carry flag is set if the
result is positive, clear if it's negative. Assuming that all three
values (your code, the upper threshold, and the lower threshold) are
8-bit unsigned numbers, and that you're using a 16Cxx part (NOT a
16C5x), the code to do what you want looks like this:
MOVF CODE,W ;W = the value you're testing.
ADDLW -LOWER ;Is it lower than "LOWER"?
BNC BAD ;If so, it's bad. Jump.
ADDLW -(UPPER-LOWER) ;Otherwise, is it higher than "UPPER"?
BC BAD ;If so, it's bad. Jump.
NOP ;Otherwise, it's good. Do whatever here...
For those of you who care about such things, the standard "This code
has neither been tested nor assembled; you get what you pay for"
Andrew Warren - ix.netcom.comfastfwd
Fast Forward Engineering, Vista, California
See also: www.piclist.com/techref/index.htm?key=negative+numbers
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the