7-97
SORT,DSORT
1
2
3
4
6
6
7
8
7.5 Data processing instructions
7.5.12 BIN 16 and 32 bits data sort operations (SORT,DSORT)
(2) Several scans are required for sorts performed by the DSORT instruction. The number of
scans executed until completion is the value obtained by dividing the maximum number of
times executed until the completion of the sort by the number of data blocks compared at
one execution designated by . (Decimal fractions are rounded up.)When the value of
is increased, the number of scans until completion of the sort is reduced, but the amount of
time per scan is lengthened.
(3) The maximum number of executions until completion of the sort should be calculated
according to the following equation:
The maximum number of executions until completion (n) (n 1)/2 [times executed]
When n 10, the number of executions is obtained as 10 (10 1)/2 45 [times executed].
If S2 2, then the number of scans until the completion of sort is calculated as
45/2 22.5 23 [scans].
(4) The device designated by (the completion device) is turned OFF by the execution of the
SORT instruction, and turned ON when the sort is completed. Because the device desig-
nated by is maintained in the ON state after the completion of the sort, the user must turn
it OFF if required.
(5) The 2 points from the device designated by are used by the system during the execution
of a DSORT instruction. These 2 points from the device designated by should therefore
not be used by the user.
Changing these points may cause an error code to be returned (Error code: 4100).
(6) If the value of n is changed during the execution of the SORT instruction, the sort will be
conducted in accordance with the number of sort data blocks after the change.
(7) If the execution command is turned OFF during the execution of the SORT instruction, the
sort is suspended. The sort resumes from the beginning when the execution command is
turned ON again.
(8) To execute another sort operation immediately after the completion of the previous sort, turn
OFF the execution command once, then turn it ON.
Operation Error
(1) In any of the following cases, an operation error occurs, the error flag (SM0) turns ON, and
an error code is stored into SD0.
• For the SORT(P) instruction, the range for n points starting from the device at exceeds
the corresponding device range. (Error code: 4101)
• For the DSORT(P) instruction, the range for 2 n points starting from the device at
exceeds the corresponding device range. (Error code: 4101)
• The device range of the (n/2 n) points starting from the device designated by
overlaps with the device range of the 2 points starting from the device designated by .
(Error code: 4101)
• is 0 or is a negative value. (Error code: 4100)
S2 S2
Example
D1
D1
D2
D2
S1
S1
S1
D2
S2