26.10.2012 Views

Statement List (STL) - DCE FEL ČVUT v Praze

Statement List (STL) - DCE FEL ČVUT v Praze

Statement List (STL) - DCE FEL ČVUT v Praze

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Logic Control Instructions<br />

6.19 LOOP Loop<br />

Format<br />

Description<br />

Status word<br />

LOOP <br />

Address Description<br />

Symbolic name of jump destination.<br />

LOOP (decrement ACCU 1-L and jump if ACCU 1-L 0) simplifies<br />

loop programming. The loop counter is accommodated in ACCU 1-L. The instruction<br />

jumps to the specified jump destination. The jump is executed as long as the content<br />

of ACCU 1-L is not equal to 0. The linear program scan resumes at the jump<br />

destination. The jump destination is specified by a jump label. Both forward and<br />

backward jumps are possible. Jumps may be executed only within a block, that is,<br />

the jump instruction and the jump destination must lie within one and the same block.<br />

The jump destination must be unique within this block. The maximum jump distance<br />

is -32768 or +32767 words of program code. The actual maximum number of<br />

statements you can jump over depends on the mix of the statements used in your<br />

program (one-, two-, or three word statements).<br />

BR CC 1 CC 0 OV OS OR STA RLO /FC<br />

writes: - - - - - - - - -<br />

Example for calculating the factor of 5<br />

<strong>STL</strong> Explanation<br />

L L#1 //Load the integer constant (32 bit) into ACCU 1.<br />

T MD20 //Transfer the contents from ACCU 1 into MD20 (initialization).<br />

L 5 //Load number of loop cycles into ACCU 1-L.<br />

NEXT: T MW10 //Jump label = loop start / transfer ACCU 1-L to loop counter.<br />

L MD20<br />

* D //Multiply current contents of MD20 by the current contents of MB10.<br />

T MD20 //Transfer the multiplication result to MD20.<br />

L MW10 //Load contents of loop counter into ACCU 1.<br />

LOOP NEXT //Decrement the contents of ACCU 1 and jump to the NEXT jump label if<br />

ACCU 1-L > 0.<br />

L MW24 //Program scan resumes here after loop is finished.<br />

L 200<br />

>I<br />

<strong>Statement</strong> <strong>List</strong> (<strong>STL</strong>) for S7-300 and S7-400 Programming<br />

6-20 A5E00706960-01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!