
Appendix D How to Use PLC Function
API | Mnemonic |
| Operands |
|
|
|
|
| Function | |||
21 | SUB |
| P |
| S1, S2, D |
|
|
|
| Subtraction | ||
Type | Bit Devices |
|
| Word devices |
|
|
| Program Steps | ||||
OP | X | Y | M | K | H | KnX | KnY | KnM | T | C | D SUB, SUBP: 7 steps | |
| ||||||||||||
S1 |
|
|
| * | * | * | * | * | * | * | * | DSUB, DSUBP: 13 steps |
|
|
|
| |||||||||
S2 |
|
|
| * | * | * | * | * | * | * | * |
|
D |
|
|
|
|
|
| * | * | * | * | * |
|
Operands:
S1: Minuend S2: Subtrahend D: Remainder
Explanations:
1.This instruction subtracts S1 and S2 in BIN format and stores the result in D.
2.The highest bit is symbolic bit 0 (+) and 1
3.Flag changes in binary subtraction In
A.If the operation result = 0, zero flag M1020 = On.
B.If the operation result <
C.If the operation result > 32,767, carry flag M1022 = On.
Program Example:
In
When X0 = On, the content in D0 will minus the content in D10 and the remainder will be stored in D20.
X0
SUB D0 D10 D20
Revision June 2008, 04EE, |