5-97
5 Understanding Programming
CJ2 CPU Unit Software User’s Manual
5-8 Specifying Address Offsets
5
5-8-2 Examples of Address Offset Application
It is possible to dynamically specify the offset by specifying a word address in I/O memory for the offset
in the brackets. The contents of the specified word address will be used as the offset. For example, exe-
cution can be performed by increasing the address by incrementing the value in the brackets and using
only one instruction.
z Example of Ladder Programming
In this example, two areas of consecutive data are used: D0 to D99 and D100 to D199. The contents
of corresponding words are added starting from the specified starting point, W0, to the end of the
areas and the sums are output to D200 to D299 starting from the specified offset from D200. For
example, if W0 is 30, the corresponding words from D30 to D99 and D130 to D199 are added, and
output the sums are output to D230 to D299.
Each process is performed with an input comparison instruction (<) as the execution condition so
that W1 does not exceed &100 to make sure that the upper limit of the indirect addressing range is
not exceeded.
5-8-2 Examples of Address Offset Application
The offset, W1, is set to the value of W0 using a MOV instruction.
Execution is performed by specifying D0[W1] + D100[W1] = D200[W1]
using an ADD instruction.
The offset (W1) is incremented.
100 repetitions max.
MOV
W0
W1
a
FOR
&100
+
W1
a
NEXT
+
D0[W1]
D100[W1]
D200[W1]
W1
&100
Execution condition
When execution condition a
(upwardly differentiated) turns
ON, the value of W0 is set to W1.
Starts FOR loop
If execution condition a is ON and
the value of W1 is less than &100,
the data from the start position until
D99 and the data until D199 is
added, and the sum for each is
output until D299.
+
While execution condition a is ON,
W0 is incremented.
Return from FOR loop
<
Execution condition