1. Sum of List SUM/SUMD/SUMF

1. Sum of List SUM/SUMD/SUMF

1.1. Instruction Description

The Sum of Single Word Lists (SUM) instruction calculates the sum of all values in a list and outputs it to RES. The Sum of Double Word Lists (SUMD) calculates double words, while the Sum of Floating Point Lists (SUMF) calculates floating points.

For example, SUM D10 D0 K5 calculates the sum of all values from D10 to D14 and stores it in D0.

Sum of List

图1 Sum of List

1.2. The valid operands of the instruction

1.2.1. Sum of Single word List(SUM)

Input/Output Data Type operand Description
T 16 bit integer D List
RES 16 bit integer D/CV/TV/AO/V/Z, bit composite word (Y/M/C/T/S), local variable (LW) result
N 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) length

1.2.2. Sum of Double words Lists(SUMD)

Input/Output Data Type operand Description
T 32-bit integer D List
RES 32-bit integer D/CV, bit composite word (Y/M/C/T/S), local variable (LD) result
N 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) length

1.2.3. Sum of Floating(SUMF)

Input/Output Data Type operand Description
T 32-bit Real Number D List
RES 32-bit real number D, local variable (LF) result
N 16 bit integer D/CV/TV/AI/AO/K/H/V/Z/FD, bit composite word (X/Y/M/C/T/S), local variable (LW) length

1.3. Example

Command table:

NETWORK 000

LDP X000

SUM D10 D0 K5 // Calculate the values of D10+D11+D12+D13+D14 and store them in D0.

SUM

图2 SUM