Chapter 7 Second Development Platform VP3000
322
API Instruction code Operand Function
115
DIV16 /
DIV32
P S
1
, S
2
, D
Dividing binary numbers for 16-bit /
dividing binary numbers for 32-bit
Type
Operand
Bit devices Word devices
16-bit instruction (7 steps)
DIV16
Continuous
execution
type
DIV16P
Pulse
execution
type
32-bit instruction (13 steps)
DDIV32
Continuous
execution
type
DDIV32P
Pulse
execution
type
Associated flag: none
X Y M K H KnX KnY KnM T C D
S
1
S
2
D
Caution for using operand
If a remainder by 16-bit division should be recorded, use DIV / DIVP
instruction instead.
If a remainder by 32-bit division should be recorded, use DDIV /
DDIVP instruction instead.
Description
S
1
: Dividend
S
2
: Divisor
D: Quotient
DIV16 and DIV16P are 16-bit instructions. DIV32 and DIV32P are 32-bit instructions.
The singed binary value in S
1
is divided by the signed binary value in S
2
, and the quotient is
stored in D. It is not a normal algebraic regulation. Be careful with the positive / negative signs
of S
1
, S
2
and D when doing 16-bit and 32-bit operation.
If the divisor is 0, the instruction will not be executed. M1067 and M1068 = ON, and the error
code in D1067 is H0E19.
In 16-bit BIN division,
When D serves as a bit device, it can designate K1–K4 and construct a 16-bit result, occupying
a 16-bit quotient.
In 32-bit BIN division,
When D serves as a bit device, it can designate K1–K8 and construct a 32-bit result, occupying
a 32-bit quotient.
Example
Example 1
When X0 = ON, the dividend K103 in D0 is divided by the divisor K5 in D10, and the quotient is
stored in D20. ON / OFF of the highest bit indicates the positive / negative status of the result
value.