Technical data

Appendix
27.3 Data Types and Parameter Types
Programming with STEP 7
Manual, 05/2010, A5E02789666-01 611
Address of the data (in the format Byte.Bit)
STEP 7 provides the pointer format: p#memory_area byte.bit_address. (If the formal parameter
was declared as the parameter type POINTER, you only need to indicate the memory area and
the address. STEP 7 automatically reformats your entry into pointer format.) The following
examples show how you enter the parameter type POINTER for the data that start at M50.0:
P#M50.0
M50.0 (if the formal parameter was declared as POINTER).
27.3.4.3 Using the Parameter Type POINTER
A pointer is used to point to an address. The advantage of this type of addressing is that you can
modify the address of the statement dynamically during program processing.
Pointer for Memory-Indirect Addressing
Program statements that work with memory-indirect addressing are made up of an instruction, an
address identifier, and an offset (the offset must be given in square brackets).
Example of a pointer in double word format:
L P#8.7 Load the value of the pointer into accumulator 1.
T MD2 Transfer the pointer to MD2.
A I [MD2] Query the signal state at input bit I 8.7 and
= Q [MD2] assign the signal state to output bit Q 8.7.
Pointer for Area-Internal and Area-Crossing Addressing
The program statements that work with these types of addressing are comprised of an instruction
and the following parts: address identifier, address register identifier, offset.
The address register (AR1/2) and the offset must be specified together in square brackets.
Example for Area-Internal Addressing
The pointer contains no indication of a memory area:
L P#8.7 Load the value of the pointer into accumulator 1.
LAR1 Load the pointer from accumulator 1 into AR1.
A I [AR1, P#0.0] Query the signal state at input bit I 8.7 and
= Q [AR1, P#1.1] assign the signal state to output bit Q 10.0.
The offset 0.0 has no influence. Output 10.0 is calculated from 8.7 (AR1) plus the offset 1.1. The
result is 10.0 and not 9.8, see pointer format.