324
The following example shows how to take the square root of a 4-digit number
and then round the result.
When CIO 000000 is ON, first the words to be used are cleared to all zeros and
then the value whose square root is to be taken is moved to Sq+1. The result,
which has twice the number of digits as the correct answer (because
ROOT(140) operates on an 8-digit number and here we are using a 4-digit num-
ber), is placed in D00102, and the digits are split into two different words, the
leftmost two digits to CIO 0011 for the answer and the rightmost two digits to
D00103 so that the answer in CIO 0011 can be rounded. The last step is to com-
pare the value in D00103 so that CIO 0011 can be incremented using the Great-
er Than Flag (A50005) when the value must be rounded up.
In this example, √6017 = 77.56. The result is rounded off to an integer, according
to the digit in the tenths place. Thus, 77.56 is rounded off to 78.
00000 LD 000000
00001 jBSET(041)
#0000
D00100
D00101
00002 jMOV(030)
0010
D00101
00003 jROOT(140)
D00100
D00102
00004 jMOV(030)
#0000
0011
00005 jMOV(030)
#0000
D00103
00006 jMOVD(043)
D00102
#0012
0011
00007 jMOVD(043)
D00102
#0210
D00103
00008 jCMP(020)
D00103
#4900
00009 LD A50005
00010 jINC(090)
0011
010
6017
D00101 D00100
00000000
0000
D00101 D00100
60170000
D00102
7756
0011 D00103
00775600
0000
60170000= 7756.932
D00103 0011
00000000
00000000
5600 > 4900?
0011
0078
Address Instruction Operands
(041)
jBSET #0000 D00100 D00101
(030)
jMOV 0010 D00101
(140)
jROOT D00100 D00102
(030)
jMOV #0000 0011
(030)
jMOV #0000 D00103
(043)
jMOVD D00102 #0012 0011
(043)
jMOVD D00102 #0210 D00103
(020)
jCMP D00103 #4900
(090)
jINC 0011
0000
00
A500
05
Example
Special Math Instructions Section 5-23