6F3B0250
Basic Hardware and Function
171
7. Instructions
FUN 041
DIV
Unsigned double/single division
Expression
Input
-
[
A+1
×
A
DIV
B
®
C
]
-
Output
Function
When the input is ON, the double-word data of
A+1
×
A is divided by the data of B, and the quotient is
stored in
C and the remainder in C+1. The data range of A+1
×
A is 0 to 4294967295, and the data range
of
B and C is 0 to 65535.
If the quotient is greater than 65535 (overflow), the limit value 65535 is stored in
C, 0 is stored in C+1,
and the instruction error flag (ERF = S051) is set to ON.
Execution condition
Input
Operation
Output
ERF
OFF
No execution
OFF
-
ON
Normal execution (
B
¹
0)
ON
-
Overflow (
B
¹
0)
ON
Set
No execution (
B
=
0)
OFF
Set
Operand
Name
Device
Register
Constant Index
X
Y
R
S
T.
C. XW YW RW SW
T
C
D
I
J
K
A
Dividend
Ö
Ö
Ö
Ö
Ö
Ö
Ö
Ö
B
Divisor
Ö
Ö
Ö
Ö
Ö
Ö
Ö
Ö
C
Quotient
Ö
Ö
Ö
Ö
Ö
Ö
Example
When R010 is ON, the double-word data of D0201
×
D0200 is divided by the constant data 4000,
and the quotient is stored in D1000 and the remainder is stored in D1001.
If the data of D0201
×
D0200 is 332257, the quotient 83 is stored in D1000 and the remainder 257
is stored in D1001.
D0201
×
D0200
332257
¸
D1000
83
(quotient)
Constant
4000
D1001
257
(remainder)
Note
·
If divisor (operand
B) is 0, ERF (instruction error flag = S051) is set to ON.
The ERF (S051) can be reset to OFF by user program, e.g.
-
[ RST S051 ]
-
.
·
This instruction handles the register data as unsigned integer.
CTi Automation - Phone: 800.894.0412 - Fax: 208.368.0415 - Web: www.ctiautomation.net - Email: [email protected]