3. Instruction Set API 10 D Operands: S 1 : Comparison Value 1 S 2 : Comparison Value 2 D : Comparison result Explanations: 1. The contents of S 1 and S 2 are compared and D stores the comparison result. 2. The comparison values are signed binary values. If b15=1 in 16-bit instruction or b31=1 in 32-bit instruction, the comparison will regard the value as a negative binary value. 3. Operand D occupies 3 continuous devices. D , D +1, D +2 hold the comparison results, D = ON if S 1 > S 2 , D +1 = ON if S 1 = S 2 , D +2 = ON if S 1 S 2 4. If operand S 1 , S 2 use index register F, only 16-bit instruction is available. Program example: 1.
If D is set as Y0, then Y0, Y1, Y2 will display the comparison results as shown below. 2. When X20 = ON, CMP instruction is executed and one of Y0, Y1, Y2 will be ON. When X20 = OFF, CMP instruction is not executed and Y0, Y1, Y2 remain in their previous condition. X20 Y0 3. Use RST or ZRST instruction to reset the comparison result. 3-59 Operands Function Controllers SA2 ES2/EX2 SS2 SX2 SE CMP P Compare Controllers ES2/EX2 SS2 SA2 SX2 SE Type OP Bit Devices Word devices Program Steps X Y M S K H KnX KnY KnM KnS T C D E F CMP, CMPP: 7 steps DCMP, DCMPP:
13 steps S 1 * * * * * * * * * * * S 2 * * * * * * * * * * * D * * * PULSE 16-bit 32-bit SA2 SX2 SS2 SA2 SA2 ES2/EX2 SS2 ES2/EX2 SX2 ES2/EX2 SS2 SX2 SE SE SE CMP K10 D10 X10 RST M0 RST M1 RST M2 RST M0 RST M2 X10 ZRST M0 M2 RST M1