John Albers wrote: > I was wondering what the best way was to compare a file register to > a number and to compare a file register to another file register. > This is what I have come up with. Could someone please check the > validity of the following statements? Just an aside, John: You can check stuff like this YOURSELF by simply running the code through the MPLAB simulator and watching the C and Z flags. > Compare a file register to a number. For example to compare COUNT to > the number 12. > > movf COUNT,w > sublw d'12' > > COUNT < 12 , if C flag <> Z flag > COUNT = 12 , if Z flag = 1 > COUNT <= 12 , if C flag = 1 > COUNT > 12 , if C flag = 0 > COUNT >= 12 , if C flag = Z flag COUNT < 12: C=1 and Z=0 COUNT = 12: Z=1 COUNT <= 12: C=1 COUNT > 12: C=0 COUNT >= 12: C=0 or Z = 1 Since it's easier to check just one flag than two, I'd do the "COUNT < 12" comparison by replacing it with "COUNT <= 11". Similarly, I'd replace the "COUNT >= 12" with "COUNT > 11". > What is the best way to check [C flag <> Z Flag] and [C flag = Z > Flag] Fortunately, you don't have to, since those states don't mean anything. -Andy === Andrew Warren - fastfwd@ix.netcom.com === Fast Forward Engineering - San Diego, California === http://www.geocities.com/SiliconValley/2499