5 Categories and Use of Basic Application Instructions API 69 Operands: S : Start device for the source data m 1 : Groups of data to be sorted ( m 1 =1~32) m 2 : Number of columns in the table ( m 2 =1~6) D : Start device for the sorted data n : The No. of column to be sorted. ( n =1~ m2 ) Explanations: 1. The sorted data is stored in the m 1 Ч m 2 registers starting from the device designated in D . Therefore, if S and D designate the same register, the sorted results will be the same. 2. It is suggested to specify the operand S with a number which is a multiple of 10, e.g. D0, D10, …etc. 3. SORT instruction is completed after m 1 times of scan.
Once the SORT instruction is completed, the Flag M1029 (Execution completed flag) = ON. 4. There is no limitation on the times of using this instruction in the program. However, only one instruction can be executed at a time Program Example: When X0 = ON, the sorting process starts. When the sorting is completed, M1029 will be ON. DO NOT change the data to be sorted during the execution of the instruction. If the sorting needs to be executed again, turn X0 from OFF to ON again. X0 Example table of data sort Columns of data: m 2 Groups of data:
m 1 DVP-PM Operation Instruction 5-78 Mnemonic Operands Function Controllers 20PM 10PM SORT Data sort Type OP Bit Devices Word devices Program Steps X Y M S K H KnX Kn Y KnM KnS T C D E F SORT: 11 steps DSORT: 21 steps S * m 1 * * m 2 * * D * n * * * SORT D0 K5 K5 D50 D100 Data Column Column Row 1 2 3 4 5 Students No. English Math. Physics Chemistry 1 (D0)1 (D5)90 (D10)75 (D15)66 (D20)79 2 (D1)2 (D6)55 (D11)65 (D16)54 (D21)63 3 (D2)3 (D7)80 (D12)98 (D17)89 (D22)90 4 (D3)4 (D8)70 (D13)60 (D18)99 (D23)50 5 (D4)5 (D9)95 (D14)79 (D19)75 (D24)69