![](https://pdfstore-manualsonline.prod.a.ki/pdfasset/3/8d/38d56254-54fe-46e3-85ae-d3f5260e1091/38d56254-54fe-46e3-85ae-d3f5260e1091-bg9a.png)
FX Series Programmable Controlers Applied Instructions 5
5-28
5.3.4 DIV (FNC 23)
Operation 1:
(Applicable to all units)
The primar
source (S
1
) is divided b
the
secondar
source (S
2
). The result is stored in the
destination (D). Note the normal rules of al
ebra
appl
.
Points to note:
a) When operatin
the DIV instruction in 16bit mode, two 16 bit data sources are divided into
each other. The
produce two 16 bit results. The device identified as the destination address
is the lower of the two devices used to store the these results.
This stora
e device will actuall
contain a record of the number of whole times S
2
will divide
into S
1
(the quotient).
The second, followin
destination re
ister contains the remained left after the last whole
division (the remainder). Usin
the previous example with some test data:
51 (D0)
÷
10 (D2) = 5(D4) 1(D5)
This result is interpreted as 5 whole divisions with 1 left over (5
×
10 + 1 = 51).
b) When operatin
the DIV instruction in 32 bit mode, two 32 bit data sources are divided into
each other. The
produce two 32 bit results. The device identified as the destination address
is the lower of the two devices used to store the quotient and the followin
two devices are
used to store the remainder, i.e. if D30 was selected as the destination of 32 bit division
operation then D30, D31 would store the quotient and D32, D33 would store the remainder.
If the location of the destination device is smaller than the obtained result, then onl
the
portion of the result which directl
maps to the destination area will be written. If bit devices
are used as the destination area, no remainder value is calculated.
c) If the value of the source device S
2
is 0 (zero) then an operation error is executed and the
operation of the DIV instruction is cancelled.
Operation 2:
(Applicable units FX
(2C)
) This function is equivalent to FNC 123 EDIV. The
information re
ardin
‘Operation2:’ of the MUL instruction appl
similarl
to this second
operation of the DIV instruction (with the exception of a division bein
performed instead of a
multiplication). A
ain, onl
constants and double data words can be manipulated with onl
DDIV, DDIVP instruction formats bein
valid. Answers for an operation are stored
(completel
) in one pair of double (32 bits) data re
isters, i.e. answers are not split in to
quotient and remainder as in ‘Operation 1:’. The normal rules of al
ebra appl
to floatin
point division.
Mnemonic Function
Operands
Program steps
S1 S2 D
DIV
FNC 23
(Division)
Divides one
source value b
another the result
is stored in the
destination device
K, H, KnX, KnY, KnM, KnS,T,
C, D, V, Z
KnY, KnM, KnS,
T, C, D, Z(V)
DIV,DIVP:
7steps
DDIV,
DDIVP:
13 steps
See pa
e 4-46 for more
details re
ardin
floatin
point format.
Note: Z(V) ma
NOT
be used for
32 bit operation
When usin
M8023 to subtract floatin
point
data, onl
double word (32 bit) data re
isters
(D) or constants (K/H) ma
be used.used to
perform
X0
DIV D 0 D 2
[ S1 ] [ D ]
D 4
[ S2 ]