Technical data

Checking Block Consistency and Time Stamps as a Block Property
15.8 Avoiding Errors when Calling Blocks
Programming with STEP 7
332 Manual, 05/2010, A5E02789666-01
Situations in which Registers are Modified
The manipulation of the address registers for indirect addressing is relevant only in STL. The other
languages do not support indirect access to the address registers.
The adaptation of the DB register by the compiler must be taken into account in all programming
languages to ensure correct parameter transfer when blocks are called.
The contents of the address register AR1 and the DB register of the calling block are overwritten in
the following situations:
Situation Description
With actual parameters from a
DB
Once you have assigned an actual parameter to a block from a DB (for
example DB20.DBX0.2) STEP 7 opens the DB (DB20) and adapts the
content of the DB register. The program then works with the adapted DB
after the block call.
When calling blocks in
conjunction with higher data
types
After a block has been called from within an FC that transfers a
component of a formal parameter of a higher data type (string, array,
structure or UDT) to the called block, the content of AR1 and the DB
register of the calling block are modified.
The same applies to a call from within an FB if the parameter is in the
VAR_IN_OUT area of the caller.
When accessing components
of a higher data type
When an FB accesses a component of a formal parameter of a higher
data type in the VAR_IN_OUT area (string, array, structure or UDT),
STEP 7 uses the address register AR1 and the DB register. This
means that the contents of both registers are modified.
When an FC accesses a component of a formal parameter of a higher
data type in the VAR_IN_OUT area (string, array, structure or UDT),
STEP 7 uses the address register AR1 and the DB register. This means
that the contents of both registers are modified.
Note
When an FB is called from within a version 1 block, the actual parameter for the first Boolean IN or IN_OUT
parameter is not transferred correctly if the command before the call does not limit the RLO. In this case, it is
logically combined with the existing RLO.
When an FB is called (single or multiple instance), the address register AR2 is written to.
If the address register AR2 is modified in an FB, such by the operations UC, CC or CALL (Call FC/SFC without
parameters), there is no guarantee that the FB will be executed correctly.
If the complete absolute DB address is not transferred to an ANY parameter, the ANY pointer does not get the DB
number of the open DB. Instead, it always gets the number 0.