Searching \ for 'Limiting number range' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/io/sensors.htm?key=rang
Search entire site for: 'Limiting number range'.

Truncated match.
PICList Thread
'Limiting number range'
1998\01\19@192359 by Mike

picon face
Hi,

I need to ensure a number (read from EEProm) is with certain limits (0..10
decimal) and if
outside those limits set the number to 1.

This works, but is there a quicker, better, or more obscure way of acieving
the same effect?


       movf    Number, w
       sublw   .10
       skpnc
       goto    TestEnd
       movlw   .1
       movwf   Number
TestEnd


Regards,

Michael

1998\01\19@200438 by Andrew Warren

face
flavicon
face
Mike <spam_OUTPICLISTTakeThisOuTspamMITVMA.MIT.EDU> wrote:

> I need to ensure a number (read from EEProm) is with certain limits
> (0..10 decimal) and if outside those limits set the number to 1.
>
> This works, but is there a quicker, better, or more obscure way of
> acieving the same effect?
>
>         movf    Number, w
>         sublw   .10
>         skpnc
>         goto    TestEnd
>         movlw   .1
>         movwf   Number
> TestEnd

Michael:

This way is a LITTLE quicker and shorter, and it'll work on the
12-bit PICs as well as the 14-bit ones:

   MOVLW   10+1
   SUBWF   NUMBER,W
   MOVLW   1
   SKPNC
   MOVWF   NUMBER

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam@spam@ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...