Searching \ for '[PIC] Sorting numbers' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Sorting numbers'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Sorting numbers'
2002\09\05@053456 by JISAK

flavicon
face
Hi all,

I need to sort 6 values in assembler (MPASM).

Do you know some routines

Thanks

JK

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\09\06@050341 by JISAK

flavicon
face
Is it possible that nobody try it ?

spam_OUTJISAKTakeThisOuTspamNETCOURRIER.COM a icrit :

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\09\06@053607 by Claudio Tagliola

picon face
What for numbers, 8bit 16bit or float, is it an index-value pair which needs
to be sorted?

My first guess, in pseudo code:

you have 6 positions: array[6];

start:
index = 0;
loop:
if array[index] > array[index+1] {
       swap array[index] with array[index+1]
       goto start:
}
index = index + 1;
if(index = 6)
       goto end:
goto loop:

end:


I think it's bubblesort. Not the most efficient (ahum) but for 6 positions,
this should do it.

This should do it. I haven't done anything in MPASM for some time now, so
the ASM code is a bit foggy. But this could be put into ASM fairly easy. Use
INDF with an index variable for the array. Use a temp register to swap the
variables. Use patience to implement it :)

Regards,

Claudio

-----Oorspronkelijk bericht-----
Van: pic microcontroller discussion list
[.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU]Namens JISAKspamKILLspamNETCOURRIER.COM
Verzonden: donderdag 5 september 2002 11:27
Aan: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
Onderwerp: [PIC] Sorting numbers


Hi all,

I need to sort 6 values in assembler (MPASM).

Do you know some routines

Thanks

JK

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\09\06@083138 by mike

flavicon
face
Hi there,

Can anyone tell me how to get C-18 to define a variable at a specific
location in external memory space?

Best Regards,

Mike Griffin.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\09\06@092227 by M. Adam Davis

flavicon
face
It is possible that no one wants to spend the time making a routine that
might not work for you, or trying to extricate their routine from their
code.

What kind of numbers are you sorting?  Do you just have six registers
and you want to move the values around so they go from lowest to
highest?  Are they signed (negative and positive) or unsigned(positive
only)?

And most importantly, what have you tried so far?

If you haven't tried anything (and are hoping for a quick simple piece
of code) then you'll get few responses.

There are several algorithms for sorting.  One particularily simple
algorithm follows:
0. Clear a flag that indicates that the algorithm is still sorting
1. Compare locations (1) and (2).
2. If (1) is greater than (2) then swap the two values and set the flag
3. Compare locations (2) and (3).
4. If (2) is greater than (3) then swap the two values and set the flag
...
perform the same for 3 and 4, 4 and 5, 5 and 6.
...
7. If the flag is set, goto 0.

This algorithm is fairly simple and striaghtforward.  If you are unsure
of its operation then perform the work on paper and it should become clear.

There are numerous code examples for comparing two registers and
swapping the values in two registers on http://piclist.com , so you
ought to be able to get this going fairly quickly.  It is not the most
efficient sorter, bu I'll leave that research up to you.

-Adam

EraseMEJISAKspam_OUTspamTakeThisOuTNETCOURRIER.COM wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\09\08@124926 by JISAK

flavicon
face
Thanks it's for positives 8 bits numbers.
I will try two make the same thing in MPASM

Claudio Tagliola a icrit :

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2002\09\08@125141 by JISAK

flavicon
face
"M. Adam Davis" a icrit :

> It is possible that no one wants to spend the time making a routine that
> might not work for you, or trying to extricate their routine from their
> code.
>

Yes i understand

>
> What kind of numbers are you sorting?  Do you just have six registers
> and you want to move the values around so they go from lowest to
> highest?  Are they signed (negative and positive) or unsigned(positive
> only)?
>

8 bits unsigned

>
> And most importantly, what have you tried so far?
>

Nothing because i had no idea at this time now it become better.

{Quote hidden}

Thank you i will go on this way

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu


2002\09\08@160617 by Scott Dattalo

face
flavicon
face
On Sun, 8 Sep 2002 EraseMEJISAKspamNETCOURRIER.COM wrote:

{Quote hidden}

<snip>

FWIW, You can look at

http://www.dattalo.com/technical/software/pic/medfilt.html

As an example for 16-bit numbers.

This code is somewhat different than what you're seeking - maybe. The
purpose of my routine is to low pass filter a stream of analog data. The
sorting part is for a median filter. As a new sample is recieved, it is
put into a circular buffer. A second buffer contains the sorted data.
Well, actually it contains the indices of the sorted data. The filtered
value is obtained by adding together the last N-samples, excluding the
extremes, and dividing by the number of samples added together. In other
words, this routine combines a low pass filter and a median filter into
one filter.

Scott

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu


2002\09\11@133403 by Nick Stedman

flavicon
face
Look through the piclist archive. You'll find a nice, simple assembly
routine for a bubble sort.

nick

on 6/9/02 5:35 AM, Claudio Tagliola at RemoveMEtagliolaspam_OUTspamKILLspamSOFTHOME.NET wrote:

{Quote hidden}

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...