377
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
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.
Program Example
(1) The following program sorts the BIN 16-bit data from D0 to D3 in the ascending/descending order when X10 is turned
ON.
[Ladder Mode]
[List Mode]
[Operation]
(2) The following program sorts the BIN 32-bit data from D0 to D9 in ascending/descending order when X10 is turned ON.
[Ladder Mode]
[List Mode]
Error
code
Error details
Q00J/
Q00/
Q01
QnH
QnPH QnPRH
QnU
LCPU
4100
is 0 or a negative value.
4101
The range from S1 to (S1 + n/2 n) (including S1) overlaps the range
from D2 to D2 +1.
4101
For the SORT(P) instruction, the range of the device specified by
exceeds the range from S1 to S1 + n (including S1).
4101
For the DSORT(P) instruction, the range of the device specified by
exceeds the range from S1 to S1 + (2 n) (including S1).
S2
S1
S1
Step
Instruction
Device
Data
before
sort
Data
after
sort
-
999
-
1
123
4
5
100
123
4
5
-
1
100
-
999
-
999
100
-
1
123
4
5
D1
D2
D3
D0
D1
D2
D3
D0
D1
D2
D3
D0
X0
O
FF
X0
O
N
Step
Instruction
Device