Eric Smith wrote: > > Test if a value is in a certain range > > > > W = value > > > > addlw 255 - Hi > > addlw (Hi - Lo) + 1 > > > > Carry is set if W is in range Lo - Hi > > That can't possibly work! There aren't enough instructions! And I refuse > to try it out to see if it works, since I know I'm right! > Let's see :-) Lower = 50 Upper = 60 addlw 255 - Hi equates to addlw 195 addlw (Hi - Lo) + 1 equates to addlw 11 W = 50 ; lower limit addlw 195 ; w = 245 addlw 11 ; w = 0, C = 1, result = OK W = 55 ; in range addlw 195 ; w = 250 addlw 11 ; w = 5, C = 1, result = OK W = 60 ; upper limit addlw 195 ; w = 255 addlw 11 ; w = 11, C = 1, result = OK W = 49 ; under minimum addlw 195 ; w = 244 addlw 11 ; w = 255, C = 0, result = Not OK W = 61 ; over maximum addlw 195 ; w = 0 addlw 11 ; w = 11, C = 0, result = Not OK -- Best regards Tony 'The Engine' - Design your own programmer. http://www.picnpoke.com Email picnpoke@cdi.com.au