5 Applied Instructions and Basic Usage
DVP-20PM Application Manual
5-40
API
Applicable model
20PM
23
D
D
DIV
P
P
Binary division
Bit device Word device
X Y M S K H KnX KnY KnM KnS T C D V Z
S
1
* *
* * * * * * * * *
S
2
* *
* * * * * * * * *
D
* * *
Note: The instruction supports V devices and Z devices. (If the 16-bit
instruction is used, Z devices can not be used. If the 32-bit
instruction is used, V devices can not be used.)
Please refer to specifications for more information about device
ranges.
16-bit instruction (7 steps)
DIV
Continuity
instruction
DIVP
Pulse
instruction
32-bit instruction (9 steps)
DDIV
Continuity
instruction
DDIVP
Pulse
instruction
Flag: None
Explanation
The singed binary value in S
1
is divided by the signed binary value in S
2
. The
quotient and the remainder are stored in D. Users have to notice the sign bits in
S
1
, S
2
, and D when 16-bit binary division or 32-bit binary division is done.
S
1
: Dividend; S
2
: Divisor; D: Quotient and remainder
If the divisor in
S
2
is 0, the instruciton will not be executed.
16-bit binary division
b15..............b0
S
1
S
2
D
D
+1
=/
b15..............b0 b15..............b0 b15..............b0
Quotient
Remainder
32-bit binary division
Quotient
Remainder
+1
/
=
b15.....b0 b15.....b0 b15.....b0b15.....b0 b15.....b0 b15.....b0 b15.....b0 b15.....b0
S
1
S
2
S
1
S
2
+1
D D
+1
D
+3
D
+2
Example
When X0 is ON, the dividend in D0 is divided by the divisor in D10, the quotient is
stored in D20, and the remainder is stored in D21. Whether the quotient and the
remainder are positive values or negative values depends on the leftmost bit in
D20 and the leftmost bit in D21.
X0
DIV D0 D10 D20
D0 D10 K4Y0
DIV