593
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Table Data Processing Instructions
3
MAXL
Flags
Function
MAXL(174) searches the range of memory from R1 to R1+(2W-1) for the maximum double word value
in the range and outputs that maximum value to D and D+1.
When bit 14 of C+1 has been set to 1, MAXL(174) writes the PLC memory address of the lower word of
the words containing the maximum value to IR0. (If two or more double words within the range contain
the same maximum value, the address of lower word of the first double word containing the maximum
value is written to IR0.)
When bit 15 of C+1 has been set to 1, MAXL treats the data within the range as signed binary data. (A
negative value is given as it's two's complement.)
z Saving and Restoring Values in Index Registers
MAXL can be used to write the PLC memory address of the lower word of the words containing the
maximum value to IR0. If IR0 is being used for other purposes in other places in the program, be sure to
save and restore the contents of IR0 before and after MAXL. (This information applies to MAXF, MAXD,
MINL, MINF, and MIND as well. For MINL, MINF, and MIND, the PLC memory address of the lower
word of the minimum value would be written to IR0.)
Name Label Operation
Error Flag P_ER • ON if the length of the table specified in C (bits 00 to 15) is not between 0001 and FFFF hex.
• OFF in all other cases.
Equals Flag P_EQ • ON if the maximum value is 0.
• OFF in all other cases.
Negative Flag P_N • ON if bit 15 of D+1 is ON.
• OFF in all other cases.
m
R1
R1+1
R1+ (2W−1)
R1+ (2W−2)
IR00 m
D
D+1
CW
Lower 16 bits of A
Upper 16 bits of A
W × 2 words (W = bits 00 to 15 of C)
Lower 16 bits of A
Upper 16 bits of A
PLC memory address
MOVL
IR0
W510
0.00
MOVL
IR0
IR1
MOVL
W510
IR0
MAXL
#40000004
D0
W0
Save the contents of IR00 in W510 and W511
before executing MAXL.
Store the first word of the maximum value in
IR0.
Copy the contents of IR00 (the result from MAXL) to
IR1.
Restore the previous contents to IR0.