Indirect Addressing Of The Cpu Memory Areas - Siemens Simatic S7-200 System Manual

Programmable controller
Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

7.2

Indirect Addressing of the CPU Memory Areas

Indirect addressing uses a pointer to access the data in memory. The S7-200 CPU allows
you to use pointers to address the following memory areas indirectly: I, Q, V, M, S, T (current
value only), and C (current value only). You cannot address individual bit or analog values
indirectly.
Creating a Pointer
To address a location in memory indirectly, you must first create a pointer to that location.
Pointers are double word memory locations that contain the address of another memory
location. You can only use V memory locations or accumulator registers (AC1, AC2, AC3) as
pointers. To create a pointer, you must use the Move Double Word (MOVD) instruction to
move the address of the indirectly addressed memory location to the pointer location. The
input operand of the instruction must be preceded with an ampersand (&) to signify that the
address of a memory location, instead of its contents, is to be moved into the location
identified in the output operand of the instruction (the pointer).
Example:
Note
If you want to access a word or double word value in the I, Q, V, M, or S memory areas
indirectly, you must specify the address of the value's initial byte as the input operand of
the MOVD instruction used to create the pointer. For example, VB100 is the address of the
initial byte of VW100, and MB4 is the address of the initial byte of MD4. If a symbol name
was assigned to the word or double word value, then you cannot use that symbol name in
the MOVD instruction used to create the pointer since the address of the value's initial byte
must be specified in the instruction's input operand. You must assign a different symbol
name to the address of the initial byte of the word or double word memory location for use
in pointer creation under these circumstances.
Example: ''Pump_Speed'' assigned as the symbol name for VW100
Using a Pointer to Access Data
Entering an asterisk (*) in front of an operand for an instruction specifies that the operand is a
pointer. Using the example shown in Figure 7-9, *AC1 specifies that AC1 is a pointer to the
word-length value being referenced by the Move Word (MOVW) instruction. In this example,
the values stored in both V200 and V201 are moved to accumulator AC0.
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02
CPU Memory: Data Types and Addressing Modes
MOVD
&VB100, VD204
MOVD
&MB4, AC2
MOVD
&C4, VD6
''Pump_Speed_IB'' assigned as the symbol name for VB100
(which is the initial byte of the word value stored in VW100)
MOVD &''Pump_Speed'', AC1
MOVD &''Pump_Speed_IB'', AC1 correct (&VB100 is OK)
illegal (&VW100 is not allowed)
7-9

Advertisement

Table of Contents
loading

Table of Contents