6-36
6.2 Arithmetic Operation Instructions
6.2.6 8-digit BCD data addition and subtraction
DB+, DB-
DB-(P)
(1) Subtracts the 8-digit BCD data specified for
and the 8-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 99999999 (8-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 99999999.
(Error code: 4100)
Program
E
xam
pl
e
(1) In the following program, the BCD value in Var_D3 is added to the BCD value in Var_ Z
when X20 turns ON, and the result is stored to Var_R10.
[Structured ladder]
(2) In the following program, the BCD data in Var_Z is subtracted from the BCD data in Var_D3
when X20 turns ON, and the result is stored to Var_R10.
[Structured ladder]
s
1
s
2
d
−
1
0
2
3
4 5 6
7
6
5
7 8 9
1 2
3
5
4
6
5 5 5
5 5
s
1
s
2
d
(
Upp
er
4
d
i
g
i
ts) (
L
o
w
er
4
d
i
g
i
ts)
(
Upp
er
4
d
i
g
i
ts) (
L
o
w
er
4
d
i
g
i
ts)
(
Upp
er
4
d
i
g
i
ts) (
L
o
w
er
4
d
i
g
i
ts)
D
i
g
i
ts
exceed
i
ng
t
h
e
s
p
ec
ifi
ed
num
b
er
o
f
d
i
g
i
ts
are
assumed
to
b
e
0
.
s
1
s
2
d
2
1
3
4 5 6
7 9
2
1
3
4 5 6
7 8
9
9
9 9 9 9 9 9
s
1
s
2
d
Summary of Contents for MELSEC Q Series
Page 1: ...Structured Programming Manual Mitsubishi Programmable Controller QCPU Common Instructions ...
Page 2: ......
Page 14: ...A 12 MEMO ...
Page 340: ...6 178 MEMO MTR ...
Page 708: ...7 368 MEMO ...
Page 776: ...8 68 MEMO ...
Page 796: ...9 20 MEMO ...
Page 804: ...App 8 MEMO ...
Page 812: ...Index 8 MEMO ...
Page 815: ......