return to main page
 CLEAR STORAGE 1     ,008015,022026,030037,044,049,053053N000000N00001026                                         1
 CLEAR STORAGE 2     L068116,105106,110117B101/I9I#071029C029056B026/B001/0991,001/001117I0?                      2
 BOOTSTRAP           ,008015,022029,036040,047054,061068,072/061039              ,0010011040                      3
0                               SUBROUTINE  PI                                                            PAGE    1
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  101                JOB        SUBROUTINE  PI
  102         * SO - WE HAVE 5,000 VALID PI CHARACTERS  :-))
  103         * NOW LETS PRETTY IT UP A BIT, ORGANIZE SUBROUTINES
  104         *   CALL A SUBROUTINE DEPENDS UPON
  105         *       IF THE INDEX REGISTER OPTION IS INSTALLED,
  106         *            ANY BRANCH LEAVES THE ADDRESS OF THE NEXT SEQUENTIAL
  107         *                  INSTRUCTION IF THE BRANCH NOT TAKEN IN THE
  108         *                  B ADDRESS REGISTER   :-))
  109         *     THE ARCTAN ROUTINE IS WRITTEN AS A SUBROUTINE.
  110         *     NOW LETS TRY TO CHAIN SOMETHING  :-))
  111         *
  112                CTL        6611  *6=16,000C;6=16,000T;1=OBJDECK;,1=MODADD
  113         *   1         2         3         4         5         6         7         8
  114         *78901234567890123456789012345678901234567890123456789012345678901234567890
  115         * LABEL   | OP | OPERATION                                         |XXXXXXX
  116                ORG   87                                                                 0087
  117         X1     DSA   0                  INDEX REGISTER 1                      3  0089  000                  4
  118                ORG   92                                                                 0092
  119 *       X2     DSA   0                  INDEX REGISTER 2                      3  0094  000                  5
  120 *              ORG   97                                                                 0097
  121 *       X3     DSA   0                  INDEX REGISTER 3                      3  0099  000                  6
  122         *
  123         * START STORAGE AREAS
  124         *  SMALL AREAS
  125 *              ORG   100     * PUT SMALL STUFF IN PUNCH AREA                            0100
  126         ITCNT  DCW   000000    * ITERATION COUNTER, STARTS AT ZERO            6  0105                       6
  127         DIVBAS DCW   000000   * DIVISOR FOR BASET                             6  0111                       6
  128         IX2P1  DCW   000000   * ITCNT TIMES 2 PLUS 1, DIVISOR FOR INTER       6  0117                       6
  129         C0     DCW   000000                                                   6  0123                       6
  130         C1     DCW   000001                                                   6  0129                       6
  131         C2     DCW   000002                                                   6  0135                       6
  132         C25    DCW   000025  * 5^2                                            6  0141                       7
  133         C239P2 DCW   057121  * 239^2                                          6  0147                       7
  134         CNTZRO DCW   000000  * COUNT LEADING ZEROS, DONE YET?                 6  0153                       7
  135         CF     DCW   1         *  "1"=ADD, "0" OR OTHER = SUBTRACT            1  0154                       7
  136         LC0L9  DCW   000000000                                                9  0163                       7
  137         *
  138         *    COMPUTE    16*ARCTAN(1/5)
  139         START  B     PRINTD * MCW  @+@,ACCUM&5049   * ZERO ACCUMULATOR, F     4  0164  B 634                7
  140                MCW   @0@,ACCUM&5048                                           7  0168  M H7E H7C            7
  141                B     START1           * SKIP PRINT AREA                       4  0175  B 335                8
  142                ORG   335                                                                0335
  143         START1 MCW   ACCUM&5048,ACCUM&5047                                    7  0335  M H7C H7B            9
  144                MCW   @0@,BASET&5048  * ZERO BASE                              7  0342  M H7E X7T            9
  145                MCW   BASET&5048,BASET&5047                                    7  0349  M X7T X7S            9
  146         * BIG REGISTERS SET
  147                MCW   @80@,BASET&8  * SET A HIGH ORDER TO 1*5*16               7  0356  M H7G 733            9
1                               SUBROUTINE  PI                                                            PAGE    2
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  148                MCW   @1@,CF        * SET NEXT TO ADD                          7  0363  M H7H 154            9
  149                MCW   C25,DIVBAS              * SET NEXT TO ADD                7  0370  M 141 111           10
  150                B     ATAN          *** CALL ATAN SUBROUTINE                   4  0377  B 428               10
  151         *
  152         * NOW, ADD MINUS 4*ARCTAN(1/239) TO ABOVE  16*ARCTAN(1/5)
  153         * DO NOT ZERO ACCUMULATOR
  154         START2 MCW   @0@,BASET&5048  * ZERO BASE                              7  0381  M H7E X7T           10
  155                MCW   BASET&5048,BASET&5047                                    7  0388  M X7T X7S           10
  156                MCW   @956@,BASET&8   * SET A HIGH ORDER TO 1*4*239            7  0395  M H8A 733           10
  157                MCW   @0@,CF          * SET NEXT SUBTRACT                      7  0402  M H7E 154           10
  158                MCW   C239P2,DIVBAS   * SET SET BASE DIVISOR                   7  0409  M 147 111           11
  159                B     ATAN            *** CALL ATAN SUBROUTINE                 4  0416  B 428               11
  160         * WE NOW HAVE PI IN MEMORY, PRINT IT OUT
  161                B     PRINT           * CALL PRINT ROUTINE                     4  0420  B 626               11
  162         HALT   H     START           *** HALT HERE -                          4  0424  . 164               11
  163         *
  164         ATAN   SBR   ATANX&3         * SET RETURN                             4  0428  H 625               11
  165                MCW   C0,CNTZRO       * CLEAR LEADING ZERO COUNTER             7  0432  M 123 153           11
  166                MCW   C0,ITCNT        * ZERO ITERATION CNTR                    7  0439  M 123 105           11
  167                MCW   C1,IX2P1        * INIT INTER DIVISOR                     7  0446  M 129 117           12
  168                MCW   @000@,X1        * CLEAR ASSOCIATED INDEX REGISTER        7  0453  M H8D 089           12
  169         ATANL  MCW   @+@,BASET&5049  * SET POSITIVE SIGN                      7  0460  M H8E X7U           12
  170                D     DIVBAS,BASET&6     * TRIAL ARITH                         7  0467  % 111 731           12
  171                MCW   BASET&5042,BASET&5049  * SHIFT QUOTIENT                  7  0474  M X6X X7U           12
  172                MCW   LC0L9,BASET&6      * REMOVE UNSHIFTED                    7  0481  M 163 731           13
  173                MCW   BASET&5049,INTER&5049  * MOVE QUOTIENT TO NEXT           7  0488  M X7U Q2M           13
  174                MCW   @+@,INTER&5049     * SET POSITIVE SIGN                   7  0495  M H8E Q2M           13
  175                D     IX2P1,INTER&6    DIVIDE INTERMEDIATE                     7  0502  % 117 X8/           13
  176                MCW   INTER&5042,INTER&5049   * SHIFT INTERMEDIATE             7  0509  M Q1P Q2M           13
  177                MCW   LC0L9,INTER&6        * REMOVE UNSHIFTED                  7  0516  M 163 X8/           14
  178                MCW   @+@,INTER&5049  * SET UP BASE                            7  0523  M H8E Q2M           14
  179                BCE   ATANA,CF,1        * COMPARE FOR ADD                      8  0530  B 556 154 1         14
  180         ATANS  MCW   @1@,CF              * SET NEXT ADD                       7  0538  M H7H 154           14
  181                S     INTER&5049,ACCUM&5049   * DO THE SUBTRACTION             7  0545  S Q2M H7D           14
  182                B     ATANW                * GO TO WRAP-UP                     4  0552  B 570               15
  183         ATANA  A     INTER&5049,ACCUM&5049   * ADD TO ACCUMULATOR             7  0556  A Q2M H7D           15
  184                MCW   @0@,CF              * SET NEXT SUBTRACT                  7  0563  M H7E 154           15
  185         ATANW  A     C1,ITCNT            * INC ITERATION COUNT                7  0570  A 129 105           15
  186                A     C2,IX2P1            * FORM NEXT DIVISOR                  7  0577  A 135 117           15
  187         ATANB  BCE   ATANI,BASET&X1,0   * CHAR = 0, DONE?                     8  0584  B 596 7S5 0         16
  188                B     ATANL                * GO DO ANOTHER LOOP PASS           4  0592  B 460               16
  189         ATANI  A     C1,CNTZRO           * INCREMENT # LEADING ZEROS          7  0596  A 129 153           16
  190                SBR   X1,1&X1             * INCREMENT X1                       7  0603  H 089 0'1           16
  191                C     CNTZRO,@5049@         * CHECK END                        7  0610  C 153 H8I           16
  192                BU    ATANB              * NO, CHECK MORE ZEROS                5  0617  B 584 /             16
  193         ATANX  B     0                  *** RETURN TO CALL                    4  0622  B 000               17
  194         *
  195         *
  196         * -------------------------------------------------------------
  197         *
1                               SUBROUTINE  PI                                                            PAGE    3
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  198         *  NOW WE PRINT THAT BABY OUT :-))
  199         * PROPOSED FORMAT
  200         * 2
  201         * 0        1         2         3         4         5         6         7
  202         * 1234567890123456789012345678901234567890123456789012345678901234567890123
  203         *                                                        3. * 10E-00000
  204         * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN  * 10E-00050
  205         * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN  * 10E-00100
  206         PRINT  SBR   PRINTX&3                                                 4  0626  H 724               17
  207                SBR   PRINTX&3  * PUSH THINGS UP A LITTLE                      4  0630  H 724               17
  208         PRINTD CS    633    * START CLEARING DOWN TO 200, PRINT AREA          4  0634  / 633               17
  209                CS           * 500S                                            1  0638  /                   17
  210                CS           * 400S                                            1  0639  /                   17
  211                CS           * 300S                                            1  0640  /                   17
  212                CS           * 200S                                            1  0641  /                   18
  213                SW    500,350                                                  7  0642  , 500 350           18
  214                SW    200                                                      4  0649  , 200               18
  215                MCW   @1@,632                                                  7  0653  M H7H 632           18
  216                MCW   @123456789@,204                                          7  0660  M H9H 204           18
  217                W            *WRITE THE PRINT AREA TO THE PRINTER              1  0667  2                   18
  218         *
  219         PR1LOP ZA    @1@,334                                                  7  0668  ? H7H 334           18
  220                MCE   632,332                                                  7  0675  E 632 332           19
  221                W            *WRITE THE PRINT AREA TO THE PRINTER              1  0682  2                   19
  222                MCW   632,482   * COPY                                         7  0683  M 632 482           19
  223                SW    200       * RESTORE WORD MARK OBLITERATED BY MCW         4  0690  , 200               19
  224                A     482,632   *                                              7  0694  A 482 632           19
  225                C     @  @,201                                                 7  0701  C I0? 201           19
  226                BE    PR1LOP                                                   5  0708  B 668 S             19
  227                H     PRINTD                                                   4  0713  . 634               20
  228                B     PRINTD                                                   4  0717  B 634               20
  229         PRINTX B     0              *** RETURN TO CALL                        4  0721  B 000               20
  230         *
  231         *
  232         *  LARGE AREAS RON MAK SAYS THAT BLANKS PROCESS AS ZEROS
  233         *          ORG  780
  234         *FLDLEN    EQU  5050      * LENGTH OF THE 3 BIG FIELDS
  235         BASET  DA    1X5050,C  * BASE, 1ST DIVISION HERE                         0725   5774
  236         INTER  DA    1X5050,C  * INTERMEDIATE BUFFER, 2ND DIVISION HERE          5775  10824
  237         ACCUM  DA    1X5050,C  * ACCUMULATOR, ANSWER IS FORMED HERE             10825  15874
  238         *   1         2         3         4         5         6         7         8
  239         *78901234567890123456789012345678901234567890123456789012345678901234567890
  240         * LABEL   | OP | OPERATION                                         |XXXXXXX
  241         *
  242         *** NOV 15
  243         * MACHIN'S METHOD -
  244         * PI = 16ARCTAN(1/5) - 4ARCTAN(1/239)
  245         * AN ARCTAN SERIES IS 1/N - 1/(3XN^3) + 1/(5XN^5) - ...
  246         *
  247         *** NOV 16
1                               SUBROUTINE  PI                                                            PAGE    4
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  248         * IN ANY CASE,
  249         *LETS DO ARCTAN(X),  X = 1/5
  250         *   0.19739555984988075837004976519479
  251         *THEN  16ARCTAN(1/5)
  252         *   3.1583289575980921339207962431166
  253         * THEN AECTAN(1/239)
  254         *   0.0041840760020747238645382149592855
  255         * TIMES 4
  256         *   0.016736304008298895458152859837142
  257         * PI =
  258         *    3.1415926535897932384626433832795
  259         * :-))
  260         *
  261         * SET N TO 1/X = 5      (THIS IS THE FANCY FOOTWORK :-))
  262         *
  263         * 1) A) FORM THREE LARGE AS PRACTICAL EQUAL SIZED AREAS IN MEMORY.
  264         *       LETS CALL THEM "ACCUMULATOR",       ACCUM
  265         *                      "INTERMEDIATE",      INTER
  266         *                      "BASE OF NEXT TERM"  BASET
  267         *     B) FORM SMALLER WORKING AREAS
  268         *          ITERATION COUNTER ITCNT    USED FOR OBSERVATION
  269         *                  STARTS AT ZERO, COUNTS UP AFTER A PASS
  270         *          DIVISOR OF BASET, DIVBAS,   USUALLY 5^2 OR 239^2
  271         *                  5^2 = 25,   239^2 = 57121
  272         *          ADD/SUBTRACT CONTROL FLAG, CF , TOGGLED AFTER A PASS
  273         *                0 MEANS ADD, OTHER IS SUBTRACT
  274         *          DIVISOR OF INTER IS IX2P1 , ITCNT TIMES 2 PLUS 1
  275         *
  276         * 2) FIGURE WHERE THE DECIMAL POINT WILL BE
  277         *     (SAME RELATIVE PLACE IN EACH AREA)
  278         *     ( SEVERAL CHARACTERS OR WORDS TO THE "RIGHT" OF
  279         *       THE TOP SIGNIFICANCE.)
  280         *
  281         * 3) A) ZERO THE  ACCUM
  282         *     B) ( INTER DOES NOT NEED INITIALIZATION)
  283         *    C) SET X (5.0 IN OUR EXAMPLE) INTO BASET
  284         *    D) SET COUNTER N TO 1
  285         *
  286         * 4) WHILE BASET IS NON-ZERO
  287         *    A) DIVIDE BASET BY X^2  ( 25 IN OUR EXAMPLE ) GIVING BASET
  288         *    B) DIVIDE BASET BY (2XN - 1) GIVING INTER
  289         *    C) IF N IS ODD, ADD INTERMEDIATE TO ACCUMULATOR
  290         *           ELSE, SUBTRACT INTERMEDIATE FROM ACCUMULATOR
  291         *    D) ADD 1 TO N (ASSURE THAT MACHINE CAN DIVIDE BY 2N)
  292         *
  293         * 5) ACCUMULATOR IS A FINE APPROXIMATION OF ARCTAN(X)   ;-))
                     DCW   @0@                                                      1 15875              LIT    410
                     DCW   @80@                                                     2 15877              LIT    410
                     DCW   @1@                                                      1 15878              LIT    410
                     DCW   @956@                                                    3 15881              LIT    411
1                               SUBROUTINE  PI                                                            PAGE    5
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
                     DCW   @000@                                                    3 15884              LIT    411
                     DCW   @+@                                                      1 15885              LIT    411
                     DCW   @5049@                                                   4 15889              LIT    411
                     DCW   @123456789@                                              9 15898              LIT    411
                     DCW   @  @                                                     2 15900              LIT    411
  294                END   START  * LAST CARD IN DECK, TRANSFER ADDRESS                      / 164 080
1                               SUBROUTINE  PI                                                            PAGE    6
0SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  

 ACCUM   10825    ATAN      428    ATANA     556    ATANB     584    ATANI     596    ATANL     460    ATANS     538   
 ATANW     570    ATANX     622    BASET     725    C0        123    C1        129    C2        135    C239P2    147   
 C25       141    CF        154    CNTZRO    153    DIVBAS    111    HALT      424    INTER    5775    ITCNT     105   
 IX2P1     117    LC0L9     163    PR1LOP    668    PRINT     626    PRINTD    634    PRINTX    721    START     164   
 START1    335    START2    381    X1         89    X2         94    X3         99