104
D320 PLC User's Manual
Instruction
Mnemonic
Subtraction
Range
Bit
■
Word
SUB
DSUB
SUBB
DSUBB
Decimal subtraction (SUB, DSUB)
BCD subtraction (SUBB, DSUBB)
■
Double words
Ladder
D = S1 - S2
Decimal:
S1 = 34 and S2 = 19
Hexadecimal: S1 = $22 and S2 = $13
SUB Example:
Decimal:
34 - 19 = 15
SUBB Example:
BCD:
$22 - $13 = $09
Description
1. Subtract the data in S2 from S1, then store the result in the D register.
2. When using SUB and SUBB, the calculation ranges are as follows:
S1: 0 to 65,535 ($0000 to $FFFF)
S2: 0 to 65,535 ($0000 to $FFFF)
D: 0 to 65,535 ($0000 to $FFFF)
3. When using DSUB and DSUBB, the calculation ranges are as follows:
S1: 0 to 4,294,976,295 (0 to $FFFFFFFF)
S2: 0 to 4,294,976,295 (0 to $FFFFFFFF)
D: 0 to 4,294,976,295 (0 to $FFFFFFFF)
4. If the result exceeds the range of calculation, a carry occurs. The carry flag (F1.8) is changed
to On.
5. This operation will occur on every scan for which the input condition is true (On). To perform
the operation only on a change of input condition, use the rising/falling edge contact.
Example
Program Expression
Operation Results
Initial conditions: W0 = 00016 = $0010
W1 = 00002 = $0002
W2 = 00007 = $0007
W3 = 00001 = $0001
Operation results: W10 = 00009 = $0009
W11 = 0000065545 = $00010009
W13 = 00003 = $0003
SUB
D =
S1 =
S2 =
R
R
SUBB
D =
S1 =
S2 =
SUB
D = W10
S1 = W0
S2 = W2
DSUB
D = W11
S1 = W0
S2 = W2
SUBB
D = W13
S1 = W0
S2 = W2
R0
R
Содержание D320 PLC
Страница 1: ...D320 PLC User s Manual...
Страница 18: ...6 D320 PLC User s Manual...
Страница 28: ...16 D320 PLC User s Manual...
Страница 34: ...22 D320 PLC User s Manual...
Страница 78: ...66 D320 PLC User s Manual...
Страница 176: ...164 D320 PLC User s Manual...
Страница 210: ...198 D320 PLC User s Manual...
Страница 258: ...246 D320 PLC User s Manual...