7-23
Section
Special Math Instructions
472
tains the same data, the EQ Flag (SR 25506) is turned ON and #0004 is written
to DM 0101.
@SRCH(––)
200
#0010
00000
DM 0100
Address
Instruction
Operands
00000
LD
00000
00001
@SRCH(––)
#
0010
0200
DM
0100
IR 200
1234
IR 201
5678
IR 202
ABCD
IR 203
EF13
IR 204
89AB
IR 205
8860
IR 206
90CD
IR 207
00FF
IR 208
89AB
IR 209
810C
DM 0101
0004
DM 0100
89AB
←
Search data found
←
Search data found
Offset of first word con-
taining the search data
Offset: 0004
Note
The matching search data in IR 208 is ignored because the search data was
found in an earlier word in the range.
7-23-2
FIND MAXIMUM – MAX(––)
R
1
: First word in range
IR, SR, AR, DM, HR, TC, LR
C
: Control data
IR, SR, AR, DM, HR, TC, LR, #
Ladder Symbols
Operand Data Areas
@MAX(––)
C
R
1
D
D
: Destination word
IR, SR, AR, DM, HR, LR
MAX(––)
C
R
1
D
Limitations
This instruction is available in the
CPM2A/CPM2C only
.
N must be BCD between 0001 to 9999.
R
1
and R
1
+N–1 must be in the same data area.
DM 6144 to DM 6655 cannot be used for D.
Description
When the execution condition is OFF, MAX(––) is not executed. When the
execution condition is ON, MAX(––) searches the range of memory from R
1
to
R
1
+N–1 for the address that contains the maximum value and outputs the maxi-
mum value to the destination word (D).
The address is identified differently for the DM area:
1, 2, 3...
1. For an address in the DM area, the word address is written to C+1. For ex-
ample, if the address containing the maximum value is DM 0114, then #0114
is written in D+1.
2. For an address in another data area, the number of addresses from the be-
ginning of the search is written to D+1. For example, if the address contain-
ing the maximum value is IR 114 and the first word in the search range is
IR 014, then #0100 is written in D+1.