>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >Sent: 15 February 2006 16:54 >To: Microcontroller discussion list - Public. >Subject: comparison > > >What's the easiest way to compare two numbers using PIC mid-range >assembly? I have a very simple program and don't have much time to >invest work on. I've done a bit of asm coding for PICs but >not a lot... >and too my suprise... have never needed to do a greater than/less than >comparison. I was just wondering if there is any trick to keep this >task simple? > >I'm working on a 'f877A and am storing the lowest and greatest value >from the ADC (just upper 8 bits) into to file registers. >Effectively: if (ADRESH > adc_max) adc_max = ADRESH; if >(ADRESH < adc_min) adc_min = ADRESH; > >Is there an easy trick for greater than less than? Tag added. To compare two numbers you simply subtract one from the other. The carry and zero flag then tell you if one number is less than, equal to or greater than the other. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist