http://www.piclist.com/faq under Routines, Conditionals --- James Newton (PICList Admin #3) mailto:jamesnewton@piclist.com 1-619-652-0593 PIC/PICList FAQ: http://www.piclist.com or .org -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of John Albers Sent: Tuesday, April 18, 2000 12:18 To: PICLIST@MITVMA.MIT.EDU Subject: Interpreting C and Z flags when doing comparisons ??? I am working with PIC16F84 chips. 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? 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 What is the best way to check [C flag <> Z Flag] and [C flag = Z Flag] Compare two file registers to each other. For example to compare COUNT1 to COUNT2. movf COUNT1,w subwf COUNT2,w COUNT1 < COUNT2 ,if C flag <> Z flag COUNT1 = COUNT2 ,if Z flag = 1 COUNT1 <= COUNT2 ,if C flag = 1 COUNT1 > COUNT2 ,if C flag = 0 COUNT1 >= COUNT2 ,if C flag = Z flag Any help would be greatly appreciated. Thank You.