Advanced Function Instruction
7-100
FUN113
D
P
SORT
DATA SORTING
FUN113
D
P
SORT
S : Starting register of source registers to sort
D : Starting register of destination registers to store the
data after sorted
L : Total register for sorting
TMR CTR HR
IR
OR
SR
ROR
DR
K
Range
Ope-
rand
T0
∣
T255
C0
∣
C255
R0
∣
R3839
R3840
∣
R3903
R3904
∣
R3967
R3968
∣
R4167
R5000
∣
R8071
D0
∣
D4095
2
∣
127
S
○
○
○
○
○
○
○
○
D
○
○
*
○
L
○
○
○
○
●
When sort control "EN" = 1 or "EN
↑
" (
P
instruction) has a transition from 0 to 1, will sort the registers with
ascending order (if A/D = 1) or descending order (if A/D = 0) and put the sorted result to the registers starting
by D register.
●
The valid data length of sort operation is between 2 and 127, other length will set the “ERR” to 1 and the sort
operation will not perform.
X0
EN
R 0
A/D
113DP.SORT
D :
S :
L :
R 10
10
˙
The example at left sorts the table comprised of R0~R9
and stores the sorted data to the table locate at
R10~R19.
S
D
R0
1 5 4 7
R10
0 0 1 3
R1
2 3 1 4
R11
1 5 4 7
R2
7 7 2 5
R12
1 9 2 5
R3
0 0 1 3
R13
2 3 1 4
R4
5 2 4 7
R14
2 7 9 6
R5
1 9 2 5
R15
5 2 4 7
R6
6 7 4 4
R16
5 3 1 9
R7
5 3 1 9
R17
6 7 4 4
R8
9 7 8 8
R18
7 7 2 5
R9
2 7 9 6
X0
=
Ö
R19
9 7 8 8
Before After