289
Index Registers Section 6-2
Table Processing (Range Instructions)
The range instructions act on a range of words, which can be considered a
table of one-word records. These instructions perform basic operations such
as finding the maximum value or minimum value in the range, search for a
particular value in the range, or calculating the sum or FCS.
The PLC memory address of the result word (word containing the max. value,
min. value, search data, etc.) is automatically stored in IR0. The Index Regis-
ter (IR0) can be used as an operand in later instructions such as MOV(021) to
read the contents of the word or perform other processing.
SSET
D00000
&14
P_First_Cycle
ON for 1 cycle when
operation starts.
SNUM
D00000
W100
a
Execution condition
MOV
&1
W101
FOR
W100
SREAD
D00000
W101
D00100
b
Execution condition
NEXT
SDEL
D00000
W101
D00100
=
&0
D100
++
W101
<>
&0
D100
JMP
&1000
JME
&1000
When the First Cycle Flag is ON,
SSET(630) defines a stack in words
D00000 to D00014.
· When execution condition "a" goes ON
(upwardly differentiated condition),
SNUM(638) determines the number of
words stored in the stack and writes that
number in W100.
· MOV(021) writes the initial offset (&1) to
W101. The offset is used to search the
stack data.
· The following FOR-NEXT loop is not
executed unless execution condition "a"
is upwardly differentiated (OFF→ON).
Start loop.
· If execution condition "a" is ON,
SREAD(639) reads the data from the
calculated stack address (stack pointer -
offset value in W101) and writes that
data to D00100.
· If the value read from the stack is 0, that
data is deleted from the stack.
· If the value read from the stack is not 0,
W101 (the offset value) is incremented.
Return to FOR and repeat loop.
Jump destination when execution
condition "a" is not upwardly
differentiated (OFF→ON).
SUM calculation
FCS calculation
Search
Data
Range speci-
fied in the
instruction
Max. value
Min. value