Omron CP - PROGRAMMING MANUAL 05-2007 Programming Manual page 487

Cp1h/cp1l cpu unit
Table of Contents

Advertisement

Special Math Instructions
Description
Flags
Precautions
Examples
Note
454
Area
Indirect DM addresses
in BCD
Constants
Data Registers
Index Registers
Indirect addressing
using Index Registers
ROOT(072) computes the square root of the 8-digit BCD number in S+1 and
S and outputs the integer portion of the result to R. The non-integer remainder
is eliminated.
S+1
BCD data (8 digits)
Name
Label
Error Flag
ER
Equals Flag
=
The operands of this instruction (S+1, S, and R) are all treated as BCD val-
ues. If the input data is binary, use the ROTB(620) instruction.
Square Root of 8-digit Number
When CIO 0.00 is ON in the following example, ROOT(072) calculates the
square root of the data in D101 and D100, and writes the integer portion of
the result in D200.
Figures after the decimal point are truncated for 8-digit numbers.
0.00
D100
D200
Square Root of a 4-digit Number
The following example shows how to take the square root of a 4-digit number
and round off the result. This program example calculates the square root of
the 4-digit number in CIO 1000, rounds off the result, and writes it to
CIO 2000. (Basically, the 4-digit number is multiplied by 10,000 (100
result is divided by 100, increasing the precision of the calculation by a factor
of 100.)
S
*D0 to *D32767
#00000000 to #99999999
(BCD)
---
---
,IR0 to ,IR15
–2048 to +2047 ,IR0 to –2048 to +2047 ,IR15
DR0 to DR15, IR0 to IR15
,IR0+(++) to ,IR15+(++)
,–(– –)IR0 to, –(– –)IR15
S
BCD data (4 digits)
Operation
ON if the data in S+1 and S is not BCD.
OFF in all other cases.
ON if the result is 0000.
OFF in all other cases.
S+1: D101
Section 3-13
R
---
DR0 to DR15
R
S: D100
R: D200
Truncated
2
) and the

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents