6-38
6.2 Arithmetic Operation Instructions
6.2.7 4-digit BCD data multiplication and division
B*, B/
B/(P)
(1) Divides BCD data specified for
by BCD data specified for
, and stores the result to the
variable specified for
.
(2) Quotient and remainder of the division result are stored in 32-bit data.
Quotient (4-digit BCD):
Stored to
[0] (16 bits).
Remainder (4-digit BCD):
Stored to
[1] (16 bits).
O
p
erat
i
on
E
rror
In any of the following cases, 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)
• Attempt to divide
by 0.
(Error code: 4100)
Program
E
xam
pl
e
(1) In the following program, the BCD value in Var_D7 is multiplied by the BCD value in Var_D8
when X20 turns ON, and the result is stored to Var_D0.
[Structured ladder]
[Operation]
(2) In the following program, the BCD value 5678 is divided by the BCD value 1234, and the
result is stored to Var_D502.
[Structured ladder]
[Operation]
s
1
s
2
d
0
0
0
6
8
0
7
6
6
5
7
8
4
0
2
2
[0]
s
1
s
2
d
[
1
]
d
Digits exceeding t
h
e s
p
eci
f
ied
num
b
er o
f
digits are assumed to
b
e 0.
Q
uotient
Remainder
d
d
s
1
s
2
s
2
4
8
2
8
6
8
4
2
7
9
5
3
D8
Var_D0[
1
](
Upp
er 4 digits)
4
5
2
6
Var_D0[0](Lo
w
er 4 digits)
Var_D7
Q
uotient
0
0
0
4
2
1
3
4
6
5
7
8
Var_
5
0
2
[0]
7
0
4
2
Var_
5
0
2
[
1
]
Remainder
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: ......