7-23
Section
Special Math Instructions
478
7-23-5
SUM – SUM(––)
C
: Control data
IR, SR, AR, DM, HR, LR, #
R
1
: First word in range
IR, SR, AR, DM, HR, TC, LR
Ladder Symbols
Operand Data Areas
D
: First destination word
IR, SR, AR, DM, HR, LR
SUM(––)
C
R
1
D
@SUM(––)
C
R
1
D
Limitations
This instruction is available in the
CPM2A/CPM2C only
.
The 3 rightmost digits of C must be BCD between 001 and 999.
DM 6144 to DM 6655 cannot be used for D.
If bit 14 of C is OFF (setting for BCD data), all data within the range R
1
to R
1
+N–1
must be BCD.
Description
When the execution condition is OFF, SUM(––) is not executed. When the
execution condition is ON, SUM(––) adds either the contents of words R
1
to
R
1
+N–1 or the bytes in words R
1
to R
1
+N/2–1 and outputs that value to the des-
tination words (D and D+1). The data can be summed as binary or BCD and will
be output in the same form. Binary data can be either signed or unsigned.
The function of bits in C are shown in the following diagram and explained in
more detail below.
Number of items in range (N, BCD)
Number of words or number of bytes
001 to 999
First byte (when bit 13 is ON)
1 (ON):
Rightmost
0 (OFF): Leftmost
Addition units
1 (ON):
Bytes
0 (OFF): Words
C:
Data type
1 (ON):
Binary
0 (OFF): BCD
Not used – set to zero.
15
14
13
12
11
00
Number of Items in Range
The number of items within the range (N) is contained in the 3 rightmost digits of
C, which must be BCD between 001 and 999. This number will indicate the num-
ber of words or the number of bytes depending the items being summed.
Addition Units
Words will be added if bit 13 is OFF and bytes will be added if bit 13 is ON.
If bytes are specified, the range can begin with the leftmost or rightmost byte of
R
1
. The leftmost byte of R
1
will not be added if bit 12 is ON.
MSB LSB
R
1
1
2
R
1
+1
3
4
R
1
+2
5
6
R
1
+3
7
8