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.

Floating-Point Math Instructions<br />

8.4.2 SQRT Generate the Square Root of a Floating-Point Number<br />

(32-Bit)<br />

Format<br />

SQRT<br />

Description of instruction<br />

Result<br />

Example<br />

SQRT (generate the square root of a 32-bit, IEEE-FP floating-point number)<br />

calculates the square root of a floating-point number (32-bit, IEEE-FP) in ACCU 1.<br />

The result is stored in accumulator 1. The input value must be greater than or equal<br />

to zero. The result is then positive. Only exception the square root of -0 is -0. The<br />

instruction influences the CC 1, CC 0, OV, and OS status word bits.<br />

The contents of accumulator 2 (and also the contents of accumulator 3 and<br />

accumulator 4 for CPUs with four ACCUs) remain unchanged.<br />

The result in ACCU 1 is CC 1 CC 0 OV OS Note<br />

+qNaN 1 1 1 1<br />

+infinite 1 0 1 1 Overflow<br />

+normalized 1 0 0 -<br />

+denormalized 0 0 1 1 Underflow<br />

+zero 0 0 0 -<br />

-zero 0 0 0 -<br />

-qNaN 1 1 1 1<br />

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

L MD10 //The value from memory double word MD10 is loaded into ACCU 1. (This<br />

value must be in the floating-point format.)<br />

SQRT //Calculate the square root of the floating-point number (32-bit,<br />

IEEE-FP) in ACCU 1. Store the result in ACCU 1.<br />

AN OV //Scan the OV bit in the status word for "0."<br />

JC OK //If no error occurred during the SQRT instruction, jump to the OK jump<br />

label.<br />

BEU //Block end unconditional, if an error occurred during the SQRT<br />

instruction.<br />

OK: T MD20 //Transfer the result from ACCU 1 to memory double word MD20.<br />

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

A5E00706960-01 8-11

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

Saved successfully!

Ooh no, something went wrong!