+AR1 or 2

Top  Previous  Next

 

This operation is used to increase the address register address register 1 or 2 in loops, for example. First the step width has to be loaded into accu 1 or this one can be specified as operand in the pointer format.

 

Accu 1 has to contain these values to obtain the desired step width

 


Step width

Pointer format

Hex Format

Example


1 Bit

P#0.1

0001h

Q 5.7 -> Q 5.8


1 Byte

P#1.0

0008h

I 7.3 -> I 8.3


1 Word

P#2.0

0010h

MW 6 -> MW 8


1 Dword

P#4.0

0020h

DBD10 -> DBD 14

 

!! Warning using the address register !!

 

Example of a loop with AR1

 


LAR1 P#Q6.0

// Load the address register with pointer to A6.0


L   4

// 4 iterations

lbl  :

T #Idx

// #Idx is local INT variable


SET

// Set RLO to ‘1’


= [AR1,P#0.1]

// Aim is AR1 + P#0.1


+AR1 P#1.2

// Step width is 1 byte, 2 bits


L Idx



LOOP lbl


 

This has got the same effect as:

 

 SET

 = Q 6.1

 = Q 7.3

 = Q 8.5

 = Q 8.7

 

See also:

Indirect addressing

List of operations

 

See also:

Indirect addressing

List of operations

 

S7-300 and S7-400 are registered trademarks of the Siemens AG.