5 - 56
Project name QTEST10
Program name MAIN
5.7.6 Exercise 6 Multiplication and division instructions
Create a program that:
1) Sets data for multiplication and division when X0 is turned on.
2) Multiplies the value specified by the digital switches X20 to X27 by the value
specified by the digital switches X30 to X37 in binary when X2 is turned on.
3) Divides the value specified by the digital switches X30 to X37 by the value
specified by the digital switches X20 to X27 in binary when X3 is turned on.
4) Outputs the result of the multiplication or division to the BCD displays Y40 to Y4F
and the remainder to the BCD displays Y60 to Y67.
(X30 to X37) × (X20 to X27)
(Y40 to Y4F)
(X30 to X37) / (X20 to X27)
(Y40 to Y4F) ... (Y60 to Y67)
Create the program with GX Works2 filling in the blanks in the following.
Then, check the operation using the demonstration machine.
SM401
4
3
K2Y60
6)
K4Y40D2
D3
X2
X3
21
26
D0
D1
4)
D2
X0
0
D1
2)
D0K2X30
K2X20
X3
X2
1)
3)
D0
5)
D1 D2
>=
D3
K99
>=
D2
K9999
=
K0
D1
<>
K0
D1
>=
K1X30
H9
>=
K1X20
H9
>=
K1X34
H9
>=
K1X24
H9
K0 D2DMOVP
Hint
BIN-
multiplication
BIN value
D0
BIN value
D1
0
D3
BIN value
D2
BIN-division
BIN value
D0
BIN value
D1
BIN value
D2
BIN value
D3
1)
2)
3)
4)
5)
6)