Chapter 6 Instruction Details
XBC E-Type Main Unit
6-162
Ver. 1
6.28.2 SUB, SUBP, DSUB, DSUBP
Instruction
Area Available
Step
Flag
P M K F L T C S Z D.x R.x
Co
nst.
U N D R
Error
(F110)
Zero
(F111)
Carry
(F112)
SUB(P)
DSUB(P)
S1 O O O O O O O - O -
- O O O O O
4~6
-
-
-
S2 O O O O O O O - O -
- O O O O O
D O O O - O O O - O -
-
- O O O O
Operand
Description
Data Type
S1
Data to be subtracted from S2
INT/DINT
S2
Data to be subtracted from S1
INT/DINT
D
Address to save operation result in
INT/DINT
1) SUBU (Signed Binary Subtract)
(1) Saves the result of word data S1 minus S2 in D (16-bit).
(2) Performs Signed Operation.
(3) If operation result is over 32,767(h7FFF) or below -32,768(hFFFF), Carry Flag will not be set.
5678 (BIN)
b15
b0
D
1234 (BIN)
b15
b0
S
-
4444 (BIN)
b15
b0
D
2) DSUBU (Signed Binary Double Subtract)
(1) Saves the result of word data S1 minus S2 in D.
(2) Performs Signed Operation.
(3) If operation result is over 2,147,483,647 (h7FFFFFFF) or below -2,147,483,648(hFFFFFFFF), Carry
Flag will not be set.
-
b0
567890 (BIN)
b15
D
b16
b31
D+1
b0
123456 (BIN)
b15
S
b16
b31
S+1
b0
444434 (BIN)
b15
D
b16
b31
D+1
3) Program Example
(1) For P1000=‘200’ and P1100=‘100’, Input Signal P00000 is changed from Off to On status, the result of
subtracted ‘100’ will be saved in P1200.
SUB P1000 P1100 P1200
P00000
(D)SUB
P S1 S2
(D)SUBP
S1 S2
means
SUB/DSUB
D
D
Summary of Contents for XBC-DN10E
Page 1: ......
Page 10: ...Table of Contents Table of Contents 6 10 10 CLEAR ALL PLC 29...