Chapter 7 Second Development Platform VP3000
312
API Instruction code Operand Function
23 D DIV P S
1
, S
2
, D BIN division
Type
Operand
Bit devices Word devices
16-bit instruction (7 steps)
DIV
Continuous
execution
type
DIVP
Pulse
execution
type
32-bit instruction (13 steps)
DDIV
Continuous
execution
type
DDIVP
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
In 16-bit instruction, operand D occupies 2 consecutive devices.
Description
S
1
: Dividend
S
2
: Divisor
D: Quotient and remainder
This instruction divides S
1
and S
2
in BIN format and stores the result in D. Be careful with the
positive / negative signs of S
1
, S
2
and D when doing 16-bit operation.
In 16-bit BIN division,
When D serves as a bit device, it can designate K1–K4 and construct a 16-bit result,
occupying consecutive 2 groups of 16-bit data and bringing forth the quotient and remainder.
Example
When X0 = ON, D0 is divided by D10 and the quotient will be stored in D20 and remainder in
D21. ON / OFF of the highest bit indicates the positive / negative status of the result value.
X0
D0 D10
D20
DIV
D0 D10
K4Y0
DIV