3. Instructions
Application example
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 10, rounds off the result,
and writes it to CIO 11.
The values after the decimal point
should be rounded.
0.00
444
A ROOT instruction applies to 8-digit data, and
thus data memory D101 and D100 are used.
1. The source words (D101 and D100) are cleared
2. The 4-digit number is moved to D101.
@BSET
1
D100
D101
2
@MOV
10
D101
3. ROOT(072) calculates the square root of D101
3
@ROOT
D100
D102
@MOV
4
11
@MOV
4. D103 and the result word, CIO 11, are cleared
D103
5. The result of the square root calculation is
@MOVD
D102
5
11
@MOVD
D102
D103
6. If the content of D103 is greater than 4900, CIO
6
@INC
D103
11
to 0000 0000.
10
6
0
1
7
D101
D100
6
0
1
7
0
0
and D100 and writes the result to D102.
D101
D100
6017
0000
D100
7756
to 0000.
divided by 100, with the integer portion written
to CIO 11 and the remainder going to D103.
D102
7
7
5
6
CIO 11
D103
0
0
7
7
5
6
11 is incremented by 1.
CIO 11
0
0
7
8
In this case, the result is 78.
CS/CJ/NSJ Series Instructions Reference Manual (W474)
0
0
60,170,000 = 7,756.932...
Square root computation
(Remainder eliminated)
0
0
Need help?
Do you have a question about the CJ - INSTRUCTIONS REFERENCE MANUAL 07-2009 and is the answer not in the manual?
Questions and answers