6-34
6.2 Arithmetic Operation Instructions
6.2.5 4-digit BCD data addition and subtraction
B+, B-
B-(P)
(1) Subtracts the 4-digit BCD data specified for
and the 4-digit BCD data specified for
,
and stores the result of the subtraction to the variable specified for
.
(2) Values can be specified between 0 and 9999 (4-digit BCD) for
,
and
.
(3) The following is the result when an underflow is generated by the subtraction operation.
The carry flag in this case does not turn ON.
O
p
erat
i
on
E
rror
In the following case, an operation error occurs, the error flag (SM0) is turned ON, and the
corresponding error code is stored to SD0.
• The
,
or BCD value is outside the range of 0 to 9999.
(Error code: 4100)
Program
E
xam
pl
e
(1) In the following program, the BCD value in Var_D0 is added to the BCD value in Var_D1
when X20 turns ON, and the result is stored to Var_D2.
[Structured ladder]
(2) In the following program, the BCD value in Var_D20 is subtracted from the BCD value in
Var_D10 when X20 turns ON, and the result is stored to Var_D30.
[Structured ladder]
s
1
s
2
d
4
0
4
4
2
0
3
4
6
0
7
8
s
1
d
s
2
Digits exceeding t
h
e s
p
eci
f
ied
num
b
er o
f
digits are assumed to
b
e 0.
s
1
s
2
d
9
9
9
8
0
0
0
3
0
0
0
1
s
1
s
2
d
Содержание MELSEC Q Series
Страница 1: ...Structured Programming Manual Mitsubishi Programmable Controller QCPU Common Instructions ...
Страница 2: ......
Страница 14: ...A 12 MEMO ...
Страница 340: ...6 178 MEMO MTR ...
Страница 708: ...7 368 MEMO ...
Страница 776: ...8 68 MEMO ...
Страница 796: ...9 20 MEMO ...
Страница 804: ...App 8 MEMO ...
Страница 812: ...Index 8 MEMO ...
Страница 815: ......