375
SORT, DSORT
1
2
3
4
4
6
7
8
7.5
D
ata pr
ocessin
g instru
ctions
7.5.12
SOR
T
, DSORT
: Head device number in the table to be sorted (BIN 16/32 bits)
n
: Number of data blocks to be sorted (BIN 16 bits)
: Number of data blocks to be compared in one sort operation (BIN 16 bits)
: Number of the bit device to be turned ON at the completion of the sort operation (bits)
: Device reserved for the system (BIN 16 bits)
Function
SORT
(1) Sorts (rearranges data) BIN 16-bit data n points from in ascending or descending order.
Sort order is designated by the ON/OFF status of SM703:
• When SM703 is OFF: Ascending order sort
• When SM703 is ON : Descending order sort
(2) Several scans are required for sorts performed by the SORT 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
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 designated by is maintained in the ON state after the completion
of the sort, the user must turn it OFF if required.
SORT
BIN 16 bit-data sort operations
DSORT
BIN 32 bit-data sort operations
7.5.12
SORT, DSORT
Setting
Data
Internal Devices
R, ZR
J \
U \G
Zn
Constants
K, H
Other
Bit
Word
Bit
Word
––
––
––
n
––
––
––
––
––
––
––
––
Basic
Process
High
performance
Redundant Universal
LCPU
Command
n
SORT, DSORT
S1
S2
D2
D1
indicates an instruction s
y
mbol of SORT/DSORT.
S1
S2
D1
D2
S1
S2
D1
D2
S1
Data before sort
-124
-10
500
35
W
hen SM703 = OFF
W
hen SM703 = ON
-124
35
-10
500
500
-10
35
-124
Sort in the ascending order
Sort in the descending order
S
S
S
S
S
S
S
S
S
S
S
S
+1
+2
+3
+1
+2
+3
+1
+2
+3
S2
S2
Example
S2
D1
D1