I suggest a simple bubble sort. put the numbers in 4 registers say num1-num4 compare num4 to num3. if num3 is higher, swap the 2 registers. if num 4 is higher, do nothing. compare num4 and num3, num3 and num2, num2 and num1. do this for three passes and your numbers are sorted, with the highest in num4 and the lowest in num1. ----- Original Message ----- From: "Thomas N" To: Sent: Thursday, April 12, 2001 11:24 AM Subject: Re: [PIC]: Compare 4 numbers method. Please help! > Hi Bob, > > Thank you for your quick reply. The numbers are 8-bits from four ADC (so > they are unsigned). I would like to write the code in MPLAB assembly > language (35 instructions). The speed or memory is not very important. > > The memory location I called "RESULT" stores the information which tell me > which number is the biggest, big, small, and smallest. > > For your information, the inputs of the ADCs are from four CdS photoresistor > cells and basically I want to determine where the brightest or darkest spot > is. > > Sincerely, > Thomas > > >From: Bob Ammerman > >Reply-To: pic microcontroller discussion list > >To: PICLIST@MITVMA.MIT.EDU > >Subject: Re: [PIC]: Compare 4 numbers method. Please help! > >Date: Thu, 12 Apr 2001 12:30:02 -0400 > > > >ie: you need to sort these numbers. > > > >what language. > > > >how big can the numbers be? > > > >are they signed or unsigned? > > > >what is more important, speed or code space? > > > >Bob Ammerman > >RAm Systems > >(contract development of high performance, high function, low-level > >software) > > > >----- Original Message ----- > >From: "Thomas N" > >To: > >Sent: Thursday, April 12, 2001 12:27 PM > >Subject: [PIC]: Compare 4 numbers method. Please help! > > > > > > > Hi everyone, > > > > > > I need to compare 4 numbers stored in Number1, Number2, Number3, and > > > Number4. The result will be stored in the RESULT memory. > > > > > > I need to find out which one is the biggest, big, small, and smallest. > > > Please help me! > > > > > > Thank you in advance! > > > Thomas > > > >-- > >http://www.piclist.com hint: PICList Posts must start with ONE topic: > >[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > > > > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads