
Chapter 5. Application instructions
5-46
5.8.2
SUB, SUBP, DSUB, DSUBP
SUB
(Binary subtraction)
FUN(114) SUB
FUN(116) DSUB
FUN(115) SUBP
FUN(117) DSUBP
Applicable
CPU
All CPUs
Available Device
Flag
Instructions
M
P
K
L
F
T
C
S
D
#D Integer
Steps
Error
(F110)
Zero
(F111)
Carry
(F112)
O O O O O O O
O
O
O
O O O O O
O
O
O
O
O
SUB(P)
DSUB(P)
O O O O*
O O
O O
7/9/11
O
O
O
* Available only when do not use computer link module or data link module
1) Functions
-
SUB(P) : Performs the subtraction of 16 - bits BIN data specified at [ S1 ] and [ S2 ]. The subtraction
result is stored at the device specified at [ D ].
-
DSUB(P) : Performs the subtraction of 32- bits BIN data specified at [ S1+1, S1 ] and [ S2+1, S2 ].
The subtraction result is stored at the device specified at [ D1+1, D1 ].
-
When the minuend is less than subtrahend, the LSB will underflow, and the carry flag (F112) will be
set.
-
When the subtraction result is 0, the zero flag is set.
-
If indirect address specified by #D format is out of device range, the operation error occurs and the
error flag (F110) is set.
Operand setting
SUB
SUBP
DSUB
DSUBP
S1
S1
S2
S2
S1
S2
D
D
D
The device storing minuend
The device at which the
subtraction result is stored
S1
S2
D
The device storing
subtrahend