OPENNET CONTROLLER USER’S MANUAL 11-1
11: BINARY ARITHMETIC INSTRUCTIONS
Introduction
The binary arithmetic instructions make it possible for the user to program computations using addition, subtraction, mul-
tiplication, and division. For addition and subtraction operands, internal relay M8003 is used to carry or to borrow.
ADD (Addition)
SUB (Subtraction)
MUL (Multiplication)
DIV (Division)
Data type W or I: S1 + S2 → D1, CY
Data type D or L: S1·S1+1 + S2·S2+1 → D1·D1+1, CY
When input is on, 16- or 32-bit data designated by source oper-
ands S1 and S2 are added. The result is set to destination oper-
and D1 and carry (M8003).
REP
**
S1(R)
*****
D1(R)
*****
ADD(*) S2(R)
*****
Data type W or I: S1 – S2 → D1, BW
Data type D or L: S1·S1+1 – S2·S2+1 → D1·D1+1, BW
When input is on, 16- or 32-bit data designated by source oper-
and S2 is subtracted from 16- or 32-bit data designated by
source operand S1. The result is set to destination operand D1
and borrow (M8003).
REP
**
S1(R)
*****
D1(R)
*****
SUB(*) S2(R)
*****
Data type W or I: S1 × S2 → D1·D1+1
Data type D or L: S1·S1+1 × S2·S2+1 → D1·D1+1
When input is on, 16- or 32-bit data designated by source oper-
and S1 is multiplied by 16- or 32-bit data designated by source
operand S2. The result is set to 32-bit data designated by desti-
nation operand D1.
When the result exceeds the valid range for data types D or L,
the ERROR LED and special internal relay M8004 (user pro-
gram execution error) are turned on.
REP
**
S1(R)
*****
D1(R)
*****
MUL(*) S2(R)
*****
Data type W or I:
S1 ÷ S2 → D1 (quotient), D1+1 (remainder)
Data type D or L:
S1·S1+1 ÷ S2·S2+1 → D1·D1+1 (quotient),
D1+2·D1+3 (remainder)
When input is on, 16- or 32-bit data designated by source oper-
and S1 is divided by 16- or 32-bit data designated by source
operand S2. The quotient is set to 16- or 32-bit destination oper-
and D1, and the remainder is set to the next 16- or 32-bit data.
When S2 is 0 (dividing by 0), the ERROR LED and special
internal relay M8004 (user program execution error) are turned
on.
A user program execution error also occurs in the following
division operations.
Data type I: –32768 ÷ (–1)
Data type L: –2147483648 ÷ (–1)
REP
**
S1(R)
*****
D1(R)
*****
DIV(*) S2(R)
*****
Phone: 800.894.0412 - Fax: 888.723.4773 - Web: www.clrwtr.com - Email: info@clrwtr.com