131
4
4 Instructions 4.4.4 Table Operations
WSUM: Value summation
◆
Overview
The WSUM instruction calculates the sum of consecutive 16- or 32-bit data entries.
WSUM
S D n
Value summation Applicable model:
H3U
S
Source
data
Start number of elements that store the data entries
whose sum is to be calculated
16-bit instruction (7
steps)
WSUM: Continuous
execution
WSUMP: Pulse
execution
32-bit instruction (13
steps)
DWSUM:
Continuous
execution
DWSUMP: Pulse
execution
D Result Start number of elements that store the sum
n
Data
count
Number of operated data entries (n > 0)
◆
Operands
Operand
Bit Element Word Element
System·User System·User Bit Designation Indexed Address Constant
Real
Number
S X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
D X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
n X Y M T C S SM D R T C SD KnX KnY KnM KnS KnSM
V,Z
Modication K H E
Note: The elements in gray background are supported.
◆
Function
1) 16-bit instruction
The sum of
n
16-bit data entries from head address [S] is calculated. The result is stored as 32-bit data in
[D+1, D].
2) 32-bit instruction
The sum of n 32-bit data entries from head address [S+1, S] is calculated. The result is stored as 64-bit
data in [D+3, D+2, D+1, D].
An error is returned in the following conditions. The error ag M8067 is set to ON to identify this error and
the error code is stored in D8067.
• Error 6705 is returned if
n
elements from head address [S] are out of range.
• Error 6705 is returned if [D] for data storage is out of range.
• Error 6706 is returned if the operand n ≤ 0.
◆
Application
The following example gets the sum of six D elements from head address D100 and stores the result in
[D121, D120]. D100 to D105 each are assigned a value of 10, as shown in the following gure.