5.3 Standard Arithmetic Functions
137
FXCPU Structured Programming Manual
(Application Functions)
1
Outline
2
Function List
3
Function
Construction
4
How to Read
Explanation of
Functions
5
Applied
Functions
6
Standard
Function Blocks
A
Correspondence
between Devices
and Addresses
Cautions
1) When handling 32-bit data in structured programs, you cannot specify 16-bit devices directly, different
from simple projects. Use labels when handling 32-bit data.
You can specify 32-bit counters directly, however, because they are 32-bit devices.
Use global labels when specifying labels.
2) Even if underflow or overflow occurs in the operation result, it is not regarded as an operation error.
"TRUE" is output from ENO.
However, note that the obtained operation result is not accurate in this case.
Either of the flags shown in the table below turns ON or OFF in accordance with the operation result.
Program example
In this program, addition is performed using double word [signed] data stored in devices specified in and
, and the operation result is output to a device specified in .
Device Name Description
M8020 Zero
ON :When the operation result is "0"
OFF: When the operation result is any other than "0"
M8021 Borrow
ON : When the operation result is less than "-32,768" (16-bit operation) or less than "-
2,147,483,648" (32-bit operation)
OFF: When the operation result is "-32,768" (16-bit operation) or more or "-2,147,483,648" (32-
bit operation) or more
M8022 Carry
ON :When the operation result exceeds "32,767" (16-bit operation) or "2,147,483,647" (32-bit
operation)
OFF: When the operation result is "32,767" (16-bit operation) or less or "2,147,483,647" (32-bit
operation) or less
[Structured ladder]
[ST]
Zero flag
-2 , -1 , 0 , -32,768
Borrow flag
Zero flag
-2 , -1 , 0 , -2,147,483,648
Borrow flag
The most
significant bit
of data is "1".
Zero flag
32,767 , 0 , 1 , 2
Carry flag
Zero flag
2,147,483,647 , 0 , 1 , 2
Carry flag
Zero flag
-1 , 0 , 1
Zero flag
-1 , 0 , 1
The most
significant bit
of data is "0".
s1
s2
d
ADD_E
EN ENO
g_dint3
g_bool1
g_dint1
g_dint2
_IN
_IN
g_bool3
g_bool3:=ADD_E(g_bool1,g_dint1,g_dint2,g_dint3);