L9_DV16: Divide 16-Bit
(Original Document)
Naming
Name in LL984 Editor
Function Block Name
name of legacy 984 instruction
name in other tools and editors like:
  • Type Library Browser
  • Data Editor
  • Animation Tables
  • Search Results
Function Description
The L9_DV16 procedure performs signed or unsigned 16-bit division by dividing VALUE1 by VALUE2, and then posts the quotient in the RESULT word and the remainder in the RESULT+1 implied word.
The divide operation begins when the input to the ENABLE pin is turned ON. The REM input indicates whether any remainder value will be expressed as a decimal (ON) or fraction (OFF) value. The SIGNED input indicates whether the division will be a signed (ON) or unsigned (OFF) operation.
L9_DV16 can activate 1 of 3 outputs. The OUT output turns ON upon the successful completion of the operation. The OVERFL output turns ON if there is an overflow in the SUM. The DIVBY0 output turns ON if VALUE2 equals 0.
Formula
RESULT[1] = VALUE1 / VALUE2
RESULT[2] = VALUE1 MOD VALUE2 (fraction) or
RESULT[2] = (VALUE1 MOD VALUE2)*(10000 / VALUE2) (decimal)
Representation
Parameters
Input Pin
Name
Data Type
Address Range
Meaning
Top
ENABLE
OFF to ON initiates the operation.
Middle
REM
BOOL
Indicates how any remainder will be expressed; ON = decimal; OFF = fraction.
Bottom
SIGNED
BOOL
ON indicates a signed operation; OFF indicates an unsigned operation.
Node
Node Type
Name
Data Type
Address Range
Meaning
Top
IN
VALUE1
ArrUInt2
%IW, %MW
The dividend. Can be displayed as an integer constant, can be located in a variable located in a %IW input word or a %MW memory word, or can be stored in an unlocated word. If located in a %IW input or %MW memory word, 2 words are used.
Valid range for constant value:
  • 0..65,535 (unsigned)
  • -32,768..32,767 (signed)
Valid range for %MW, %IW:
  • 0..4,294,967,295 (unsigned)
  • -2,147,483,648 ..2,147,483,647 (signed)
Middle
IN
VALUE2
UINT
%IW, %MW
The divisor can be displayed as an integer constant, or can be stored in a variable located in a %IW input word, a %MW memory word or an unlocated word.
Valid range:
-32,768..32,767 (signed)
0..65,535 (unsigned)
Bottom
IN/OUT
RESULT
ArrUInt2
%MW
The quotient and any remainder must be located in 2 %MW memory words or 2 unlocated UINT words; the first word holds the quotient, the second word holds the remainder. For example, if VALUE1 = 8 and VALUE2 = 3:
  • the quotient value in the first word is 2
  • the remainder value in the second word can be expressed as either the decimal value 6,666 or the fractional value 2.
Output Pin
Name
Data Type
Address Range
Meaning
Top
OUT
BOOL
ON indicates the 16-bit division operation succeeded. (Echoes the status of the ENABLE input).
Middle
OVERFL
BOOL
ON indicates an overflow: the value in the first RESULT word > 65,535 (unsigned), or the value in the first RESULT word < -32,768 (signed), or the value in the first RESULT word >+32,767 (signed).
Bottom
DIVBY0
BOOL
ON indicates VALUE2 = 0, thereby attempting division by 0.