631
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Tracking Instructions
3
RSORT
D1: First word of sorting results
D2: Destination index register
z Operand Specifications
Flags
Function
The number of records specified by C starting from the record specified by S are sorted according to
the data in the specified location (1 word). When the sort operation has been completed, the Carry Flag
will turn OFF and the number of records that were sorted will be output to D1. If outputting to an index
register is specified in C+4, one address higher than the PLC memory address of the last word in the
sorted records is output to the specified index register. The sort direction is specified as ascending or
descending in C+3.
If split sorting is enabled in C+3, the sort will be executed over multiple cycles. The Carry Flag will be
ON while the sort operation is being executed and will turn OFF when the sort operation has been
completed. If the execution condition of RSORT turns OFF before the sort operation has been finished,
the sort will be continued the next time the execution condition turns ON.
Area
Word addresses
Indirect DM/EM
addresses
Con-
stants
Registers Flags
Pulse
bits
TR
bits
CIO WR HR AR T C DM EM
@DM
@EM
*DM
*EM
DR IR
Indirect
using IR
TK CF
C
OK OK OK OK OK OK OK OK OK OK ---
---
--- OK
--- --- --- ---
S
D1 OK
D2 --- --- --- --- --- --- --- --- --- --- OK --- OK ---
Name Label Operation
Error Flag P_ER • ON when the record length in C+1 is not between 1 and 1,024, inclusive.
• ON when the number of records specified in C times the record length in C+1 is greater than
32,768.
• ON when the number of records specified in C times the record length in C+1 is 0.
• ON when the sort data offset in C+2 is greater than one less than the record length in C+1.
• OFF in all other cases.
Carry Flag P_CY • ON while the records are being sorted.
• OFF when the sort operation has been completed.
15
System word area
Always clear C+7 to 0 before
starting to sort records.
C+7 to C+86
0
0000000000000000
C+5
C+6
15
Searching with the Setting to End the Sort Disabled
C+5: Always 0.
C+6: Always 0.
Searching with End Data Enabled to End the Sort
C+5: Sort end data (0000 to FFFF hex)
C+6: Always 0.
Searching with End Data Enabled to End the Sort
C+5: Lower word of end PLC memory address
C+6: Upper word of end PLC memory address
0
D1
015
Number of records that were sorted
This word contains the number of records that were sorted.
D2
0
One higher than the PLC memory address of the last word in
the range of records that was sorted. If index register output
is not specified in D+4, then 0000 0000 hex is stored in D2.
IR**