Omron CJ2 - 02-2010 User Manual page 238

Cj2 cpu unit software
Table of Contents

Advertisement

6 I/O Memory Areas
Precautions for Correct Use
Precautions for Correct Use
It is possible to specify regions outside of I/O memory and generate an Illegal Access Error when
indirectly addressing memory with Index Registers. Refer to A-4 Memory Map of PLC Memory
Addresses for details on the limits of PLC memory addresses.
The following table shows the variations available when indirectly addressing I/O memory with Index
Registers.
Variation
Indirect addressing
The content of IR@ is treated as the
PLC memory address of a bit or word.
Indirect addressing
The constant prefix is added to the
with constant offset
content of IR@ and the result is treated
as the PLC memory address of a bit or
word.
The constant may be any integer from
−2,048 to 2,047.
Indirect addressing
The content of the Data Register is
with DR offset
added to the content of IR@ and the
result is treated as the PLC memory
address of a bit or word.
Indirect addressing
After referencing the content of IR@ as
with auto-increment
the PLC memory address of a bit or
word, the content is incremented by 1
or 2.
Indirect addressing
The content of IR@ is decremented by
with auto-decrement
1 or 2 and the result is treated as the
PLC memory address of a bit or word.
Note IR@ represents an Index Register from IR0 to IR15.
Example
This example shows how to store the PLC memory address of a word (CIO 2) in an Index Register
(IR0), use the Index Register in an instruction, and use the auto-increment variation.
MOVR(560) 2 IR0
MOV(021) #1 ,IR0
MOV(021) #20 +1, IR0
Regular
data area
address
0
1
2
3
6-36
Function
,IR@
Constant ,IR@
(Include a + or − in
the constant.)
DR@ , IR@
Increment by 1:
, IR@+
Increment by 2:
, IR@++
Decrement by 1:
,− IR@
Decrement by 2:
,− − IR@
Stores PLC memory address of CIO 2 in IR0.
Writes #1 to PLC memory address contained in IR0, i.e., to CIO 2.
Reads IR0, adds 1, and writes #20 to that PLC memory address, i.e., to
CIO 3.
MOV #01 ,IR0
PLC memory
address
I/O memory
0C000 hex
0C001 hex
0C002 hex
#0001
0C003 hex
#0020
0D7FF hex
0D800 hex
0D9FF hex
0DE00 hex
0DFFF hex
Syntax
LD , IR0
LD +5, IR0
LD DR0 , IR0
LD , IR0++
LD , − −IR0
MOVE TO REGISTER instruction
MOVR(560) 2 IR0
Pointer
CJ2 CPU Unit Software User's Manual
Example
Loads the bit at the PLC memory
address contained in IR0.
Adds 5 to the contents of IR0 and
loads the bit at that PLC memory
address.
Adds the contents of DR0 to the
contents of IR0 and loads the bit at
that PLC memory address.
Loads the bit at the PLC memory
address contained in IR0 and then
increments the content of IR0 by 2.
Decrements the content of IR0 by 2
and then loads the bit at that PLC
memory address.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents