Motorola DSP Developer's Kit | ![]() ![]() |
Y = mot###_sort(X)
Description
This function sorts real elements of input real vector X
Input/Output
Algorithm
The heap sort algorithm will be used.
#define IN X:$0 #define OUT X:$0 heapsort(Length) { for( i = Length/2; i>=1; --i) sift (i, Length);/* set up initial heap */ for( k = Length; k >= 2; k--) { Intervalue = r[1]; r[1] = r[k]; r[k] = Intervalue; sift(1, k-1); } } sift (from, Length) { Intervalue = r[from]; k = from; j = 2 * from; while (j <= Length) { if ((j< Length) && (r[j] < r[j+1])) j++; if(Intervalue < r[j]) { r[k] = r[j]; k = j; j *= 2; } else j = Length + 1;/* return */ r[k] = Intervalue; }
Memory & Register
Status Register
The assembly function sort-1r.asm
does not explicitly set any status registers/bits during the function execution.
Data Size Limit
The length of vector X can't be larger than the continuous available data memory size.
Data Range Limit
The value of input vector X must be between -1.0 and +1.0.
Precision
In the case of DSP563, precision is 23 bits.
In the case of DSP566, precision is 15 bits.
![]() | round-c.asm | sort-r2.asm | ![]() |