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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Programming Examples<br />

B.5 Example: Integer Math Instructions<br />

Solving a Math Problem<br />

<strong>Statement</strong> <strong>List</strong><br />

The sample program shows you how to use three integer math instructions to<br />

produce the same result as the following equation:<br />

MD4 = ((IW0 + DBW3) x 15) / MW2<br />

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

L EW0 //Load the value from input word IW0 into accumulator 1.<br />

L DB5.DBW3 //Load the value from shared data word DBW3 of DB5 into accumulator 1.<br />

The old contents of accumulator 1 are shifted to accumulator 2.<br />

+I I 0.1 //Add the contents of the low words of accumulators 1 and 2. The result<br />

is stored in the low word of accumulator 1. The contents of accumulator<br />

2 and the high word of accumulator 1 remain unchanged.<br />

L +15 //Load the constant value +15 into accumulator 1. The old contents of<br />

accumulator 1 are shifted to accumulator 2.<br />

*I //Multiply the contents of the low word of accumulator 2 by the contents<br />

of the low word of accumulator 1. The result is stored in accumulator<br />

1. The contents of accumulator 2 remain unchanged.<br />

L MW2 //Load the value from memory word MW2 into accumulator 1. The old<br />

contents of accumulator 1 are shifted to accumulator 2.<br />

/I //Divide the contents of the low word of accumulator 2 by the contents<br />

of the low word of accumulator 1. The result is stored in accumulator<br />

1. The contents of accumulator 2 remain unchanged.<br />

T MD4 //Transfer the final result to memory double word MD4. The contents of<br />

both accumulators remain unchanged.<br />

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

B-12 A5E00706960-01

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

Saved successfully!

Ooh no, something went wrong!