101 HEAD MACRO *>>>>>>>>> GEN 102 .READ EQU 001 0001 GEN 103 .PUNCH EQU 101 0101 GEN 104 .PRINT EQU 201 0201 GEN 105 ORG 85 0085 106 DCW @X1@ *IDENTIFING FILLER 2 0086 GEN 3 107 X1 DCW 000 *INDEX REGISTER 1 3 0089 GEN 3 108 DCW @X2@ *IDENTIFING FILLER 2 0091 GEN 3 109 X2 DCW 000 *INDEX REGISTER 2 3 0094 GEN 3 110 DCW @X3@ *IDENTIFING FILLER 2 0096 GEN 3 111 X3 DCW 000 *INDEX REGISTER 3 3 0099 GEN 3 112 ORG 181 *JUST AFTER PUNCH LOCATIOM 0181 113 B START *UNIVERSIAL START LOCATION 4 0181 B 475 GEN 4 475 114 NOP *TERMINATING WORDMARK 1 0185 N GEN 4 115 ORG 340 *ORG JUST AFTER PRINT BUFFER 0340 *<<<<<<<<< GEN 116 * 117 REV DCW @PI TO 500 PLACES GENERATED ON 04/10/2015@ 40 0379 6 118 * 119 * HISTORY 120 * 00 WORKS - 4 BUFFERS 121 * 05 SHORTEN TO 500 DIGITS 122 * TIMER SAYS 3.5 MINUTES RUNNING TIME 123 * PRESENT PURPOSE 124 * MAKE PSEUDO-CODE OF FUNCTION AND FLOW 125 * RE-RUNABLE, ANY NON-CONSTANT MUST BE INITIALIZED 126 * SPEC: 127 * A) BE ABLE TO REPEATED RUN, BUT HALT DOES NOT GO TO NEXT STEP?? 128 * B) SEPERATE DECKS FOR VARIOUS SIZES WHICH AFFECTS RUNNING TIME 129 * INITIAL = SIZE 500 130 * 131 * C) PRINT 25 CHARACTER LINE AS SOON AS COMPUTED 132 * DO NOT PRINT SUB LINES, VISITORS DO NOT HEAR THEM 133 * GENERAL FLOW 134 * INITIALIZE - ACCUMULATOR, ADDSUB CONTOL, DIVISORS, ... 135 * 136 * SO, D0 BUFFFER SIZE 2020 CHARACTERS 137 * INITIAL DEBUG, BEFORE VARIABLE SIZE WITH THAT 138 * TRY STANDARD ON 50 DIGITS/LINE, MAY HAVE TO GO TO 20?? 139 * 140 * PSEUDO-CODE 141 * 142 * START INITIALIZE (400) 143 * COMPUTE 1 ITERATION ATAN (1/5) B5 + 1 DIGIT 144 * L1 COMPUTE 1 ITERATION ATAN (1/5) B5 + 1 DIGIT 145 * IF ZB5 < ZB239 THEN L1 146 * COMPUTE 1 ITERATION ATAN (1/239) B239 + 4 DIGIT 147 * IF ZB5 > PNTCNT+31 GO TO L1 148 * CALL PRINTD 149 * IF PNTCNT < 500 GOTO L1 150 * PRINT TOP OF FORM 151 * IF SWITCH G SET, GO TO START 152 * HALT 153 * BR START 154 * 155 * START STORAGE AREAS 156 * 157 ZB5 DCW 000000 * NUMBER OF LEADING ZEROS IN B5 6 0385 6 158 ZB239 DCW 000000 * NUMBER OF LEADING ZEROS IN B239 6 0391 6 159 B5WD DCW 000000 * DIVISOR FOR WORKING AREA FOR B5 OPERATIONS 6 0397 6 160 B239WD DCW 000000 * DIVISOR FOR WORKING AREA FOR B239 OPERATIO 6 0403 6 161 AF5 DCW 1 * "1"=ADD, "0" OR OTHER = SUBTRACT B5 OPS 1 0404 7 162 AF239 DCW 0 * "1"=ADD, "0" OR OTHER = SUBTRACT B239 O 1 0405 7 163 PRTCNT DCW 000000 * ITERATION COUNTER, STARTS AT ZERO, INC 5 6 0411 7 164 LSTCHR DCW 000000 * LAST PRINTED CHAR 6 0417 7 165 LIMPCT DCW 000500 * LIMIT OF PRINT COUNT 6 0423 7 166 C0 DCW 000000 6 0429 7 167 C1 DCW 000001 6 0435 7 168 C2 DCW 000002 6 0441 8 169 C5 DCW 000005 6 0447 8 170 C25 DCW 000025 6 0453 8 171 C239 DCW 000239 6 0459 8 172 C239P2 DCW 057121 6 0465 8 173 LC0L9 DCW 000000000 9 0474 8 174 * 175 * 176 START MCW REV,180 7 0475 M 379 180 9 379 180 177 * 178 INIT MCW C0,ZB5 * ZERO LEADING ZEROS 7 0482 M 429 385 9 429 385 179 MCW C0,ZB239 7 0489 M 429 391 9 429 391 180 MCW C0,PRTCNT 7 0496 M 429 411 9 429 411 181 MCW @30@,LSTCHR 7 0503 M V2/ 417 9 5521 417 182 T1 B ATN5 * CALL ONE ITTERATION OF &16ATN(1/5) 4 0510 B 573 9 573 183 C ZB239,ZB5 * 7 0514 C 391 385 10 391 385 184 BL T1 5 0521 B 510 T 10 510 185 B ATN239 * CALL ONE ITTERATION OF -4ATN(1/239) 4 0526 B 811 10 811 186 C ZB5,LSTCHR * SEE IF TIME TO PRINT %%%%%%%%%%%%%% 7 0530 C 385 417 10 385 417 187 BH T1 5 0537 B 510 U 10 510 188 B PRINTD * CALL PRINT A LINE 4 0542 B '41 10 1041 189 A @25@,LSTCHR 7 0546 A V2T 417 10 5523 417 190 C PRTCNT,LIMPCT 7 0553 C 411 423 11 411 423 191 BU T1 5 0560 B 510 / 11 510 192 H 000 * DONE FOR NOW 4 0565 . 000 11 000 193 H 000 4 0569 . 000 11 000 194 * 195 * 196 ATN5 SBR ATN5X&3 * SET UP RETURN 4 0573 H 780 11 780 197 C C0,ZB5 * CHECK FOR 1ST TIME THROUGH 7 0577 C 429 385 11 429 385 198 BU PH1L 5 0584 B 652 / 11 652 199 MCW @000001@,B5WD * INIT INTER DIVISOR 7 0589 M V2Z 397 12 5529 397 200 MCW @&@,ACCUM&519 * ZERO ACCUMULATOR 7 0596 M V3' V1Z 12 5530 5519 201 MCW @0@,ACCUM&518 7 0603 M V3/ V1Y 12 5531 5518 202 MCW ACCUM&518,ACCUM&517 7 0610 M V1Y V1X 12 5518 5517 203 MCW @0@,B5&518 * INITIALIZE B5 7 0617 M V3/ N18 12 5531 2518 204 MCW B5&518,B5&517 7 0624 M N18 N17 13 2518 2517 205 MCW @80@,B5&8 * SET A HIGH ORDER TO 1*5*16 7 0631 M V3T !08 13 5533 2008 206 MCW @006@,X1 * INIT X1 FOR B5 7 0638 M V3W 089 13 5536 089 207 MCW @1@,AF5 * SET ADD B5 FLAG TO ADD FIRST 7 0645 M V3X 404 13 5537 404 208 PH1L MCW @&@,B5&519 * SET POSITIVE SIGN 7 0652 M V3' N19 13 5530 2519 209 D C25,B5&X1 * DIVISION OF B5 7 0659 % 453 !'0 14 453 2000+1 210 MCW B5&512,B5&519 * SHIFT QUOTIENT 7 0666 M N12 N19 14 2512 2519 211 MCW LC0L9,B5&X1 * REMOVE UNSHIFTED 7 0673 M 474 !'0 14 474 2000+1 212 MCW B5&519,INTER&519 * MOVE QUOTIENT TO INTERMEDIATE 7 0680 M N19 51Z 14 2519 4519 213 MCW @&@,INTER&519 * SET POSITIVE SIGN 7 0687 M V3' 51Z 14 5530 4519 214 D B5WD,INTER&X1 * DIVIDE INTERMEDIATE 7 0694 % 397 0'' 15 397 4000+1 215 MCW INTER&512,INTER&519 * SHIFT INTERMEDIATE 7 0701 M 51S 51Z 15 4512 4519 216 MCW LC0L9,INTER&X1 * REMOVE UNSHIFTED 7 0708 M 474 0'' 15 474 4000+1 217 MCW @&@,INTER&519 * SET UP BASE 7 0715 M V3' 51Z 15 5530 4519 218 BCE PH1ADD,AF5,1 * COMPARE FOR ADD 8 0722 B 748 404 1 15 748 404 219 PH1SUB MCW @1@,AF5 * SET NEXT ADD 7 0730 M V3X 404 16 5537 404 220 S INTER&519,ACCUM&519 * DO THE SUBTRACTION 7 0737 S 51Z V1Z 16 4519 5519 221 B PH1W * GO TO WRAP-UP 4 0744 B 762 16 762 222 PH1ADD A INTER&519,ACCUM&519 * ADD TO ACCUMULATOR 7 0748 A 51Z V1Z 16 4519 5519 223 MCW @0@,AF5 * SET NEXT SUBTRACT 7 0755 M V3/ 404 16 5531 404 224 PH1W A C2,B5WD * FORM NEXT DIVISOR FOR INTER 7 0762 A 441 397 16 441 397 225 PH1BCE BCE PH1X1,B5&X1,0 * CHAR = 0, DONE? 8 0769 B 781 !'0 0 17 781 2000+1 226 ATN5X B 000 * GO DO ANOTHER LOOP PASS 4 0777 B 000 17 000 227 PH1X1 A C1,ZB5 * INCREMENT # LEADING ZEROS 7 0781 A 435 385 17 435 385 228 SBR X1,1&X1 * INCREMENT X1 7 0788 H 089 0'1 17 089 001+1 229 C ZB5,@510@ * CHECK END 7 0795 C 385 V4' 17 385 5540 230 BU PH1BCE * NO, CHECK MORE ZEROS 5 0802 B 769 / 17 769 231 B ATN5X * DONE WITH PASS 1 4 0807 B 777 18 777 232 * 233 * ------------------------------------------------------------- 234 ATN239 SBR AT239X&3 * SET UP RETURN EXIT 4 0811 H '40 18 1040 235 C C0,ZB239 7 0815 C 429 391 18 429 391 236 BU PH2L 5 0822 B 890 / 18 890 237 MCW @000000@,ZB239 * ZERO ITERATION CNTR 7 0827 M V4W 391 18 5546 391 238 MCW @000001@,B239WD * INIT INTER DIVISOR 7 0834 M V5S 403 18 5552 403 239 MCW C0,ZB239 * CLEAR LEADING ZERO COUNTER 7 0841 M 429 391 19 429 391 240 MCW @0@,AF239 * SET ADD B5 FLAG TO SUBTRACE FIRST 7 0848 M V3/ 405 19 5531 405 241 * DO NOT ZERO ACCUMULATOR 242 MCW @0@,B239&518 7 0855 M V3/ E18 19 5531 3518 243 MCW B239&518,B239&517 7 0862 M E18 E17 19 3518 3517 244 MCW @956@,B239&8 * SET A HIGH ORDER TO 1*4*239 7 0869 M V5V ?08 19 5555 3008 245 MCW @0@,AF239 * SET NEXT SUBTRACT 7 0876 M V3/ 405 20 5531 405 246 MCW @006@,X2 7 0883 M V3W 094 20 5536 094 247 PH2L MCW @&@,B239&519 * SET POSITIVE SIGN 7 0890 M V3' E19 20 5530 3519 248 D C239P2,B239&X2 * TRIAL ARITH 7 0897 % 465 ?!0 20 465 3000+2 249 MCW B239&512,B239&519 * SHIFT QUOTIENT 7 0904 M E12 E19 20 3512 3519 250 MCW LC0L9,B239&X2 * REMOVE UNSHIFTED 7 0911 M 474 ?!0 21 474 3000+2 251 MCW B239&519,INTER&519 * MOVE QUOTIENT TO NEXT 7 0918 M E19 51Z 21 3519 4519 252 MCW @&@,INTER&519 * SET POSITIVE SIGN 7 0925 M V3' 51Z 21 5530 4519 253 D B239WD,INTER&X2 DIVIDE INTERMEDIATE 7 0932 % 403 0!' 21 403 4000+2 254 MCW INTER&512,INTER&519 * SHIFT INTERMEDIATE 7 0939 M 51S 51Z 21 4512 4519 255 MCW LC0L9,INTER&X2 * REMOVE UNSHIFTED 7 0946 M 474 0!' 22 474 4000+2 256 MCW @&@,INTER&519 * SET UP BASE 7 0953 M V3' 51Z 22 5530 4519 257 BCE PH2ADD,AF239,1 * COMPARE FOR ADD 8 0960 B 986 405 1 22 986 405 258 PH2SUB MCW @1@,AF239 * SET NEXT ADD 7 0968 M V3X 405 22 5537 405 259 S INTER&519,ACCUM&519 * DO THE SUBTRACTION 7 0975 S 51Z V1Z 22 4519 5519 260 B PH2W * GO TO WRAP-UP 4 0982 B '00 23 1000 261 PH2ADD A INTER&519,ACCUM&519 * ADD TO ACCUMULATOR 7 0986 A 51Z V1Z 23 4519 5519 262 MCW @0@,AF239 * SET NEXT SUBTRACT 7 0993 M V3/ 405 23 5531 405 263 PH2W A C2,B239WD * FORM NEXT WORKING DIVISOR 7 1000 A 441 403 23 441 403 264 PH2BCE BCE PH2X2,B239&X2,0 * CHAR = 0, DONE? 8 1007 B '19 ?!0 0 23 1019 3000+2 265 B AT239X * GO DO ANOTHER LOOP PASS 4 1015 B '37 23 1037 266 PH2X2 A @1@,ZB239 * INCREMENT # LEADING ZEROS 7 1019 A V3X 391 24 5537 391 267 SBR X2,1&X2 * INCREMENT X2 7 1026 H 094 0!1 24 094 001+2 268 B PH2BCE * NO, CHECK MORE ZEROS 4 1033 B '07 24 1007 269 AT239X B 000 * DONE WITH PASS 2 4 1037 B 000 24 000 270 * NOW WE PRINT THAT BABY OUT :-)) 271 * PROPOSED FORMAT 272 * 2 273 * 0 1 2 3 4 5 6 7 274 * 1234567890123456789012345678901234567890123456789012345678901234567890123 275 * 3. * 10E-00000 276 * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN * 10E-00050 277 * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN * 10E-00100 278 * 279 PRINTD SBR PRINTX&3 * SET UP RETURN EXIT 4 1041 H S18 24 1218 280 C C0,PRTCNT * NEED INITIALIZATION ? 7 1045 C 429 411 24 429 411 281 BU PR1LOP * NO 5 1052 B /05 / 24 1105 282 MCW @008@,X3 * CLEAR PICKUP X 7 1057 M V5Y 099 25 5558 099 283 MCW C0,PRTCNT * CLEAR TOTAL CH MOVED 7 1064 M 429 411 25 429 411 284 CS 332 * START CLEARING DOWN TO 200, PRINT AREA 4 1071 / 332 25 332 285 CS 1 1075 / 25 286 MCW @. * 10E-00000@,244 7 1076 M V7/ 244 25 5571 244 287 SW 227,265 * SET WORD MARK IN EXPONENT FIELD 7 1083 , 227 265 25 227 265 288 MCW ACCUM&X3,231 MOVE 5TH FIELD 7 1090 M '?' 231 26 5000+3 231 289 SBR X3,5&X3 * STEP X1 7 1097 H 099 0?5 26 099 005+3 290 W *WRITE THE PRINT AREA TO THE PRINTER 1 1104 2 26 291 * 292 PR1LOP CS 231 * CLEAR PREVIOUS NUMERICS 4 1105 / 231 26 231 293 SW 203,209 * SET WORD MARKS FOR B FIELD 7 1109 , 203 209 26 203 209 294 SW 215,221 7 1116 , 215 221 26 215 221 295 SW 227,240 7 1123 , 227 240 27 227 240 296 A @00025@,244 * ADD 25 TO EXPONENT 7 1130 A V7W 244 27 5576 244 297 MCW ACCUM&X3,207 MOVE 1ST FIELD 7 1137 M '?' 207 27 5000+3 207 298 SBR X3,5&X3 * STEP X3 7 1144 H 099 0?5 27 099 005+3 299 MCW ACCUM&X3,213 MOVE 2ND FIELD 7 1151 M '?' 213 27 5000+3 213 300 SBR X3,5&X3 * STEP X3 7 1158 H 099 0?5 28 099 005+3 301 MCW ACCUM&X3,219 MOVE 3RD FIELD 7 1165 M '?' 219 28 5000+3 219 302 SBR X3,5&X3 * STEP X3 7 1172 H 099 0?5 28 099 005+3 303 MCW ACCUM&X3,225 MOVE 4TH FIELD 7 1179 M '?' 225 28 5000+3 225 304 SBR X3,5&X3 * STEP X3 7 1186 H 099 0?5 28 099 005+3 305 MCW ACCUM&X3,231 MOVE 5TH FIELD 7 1193 M '?' 231 29 5000+3 231 306 SBR X3,5&X3 * STEP X3 7 1200 H 099 0?5 29 099 005+3 307 W *WRITE THE PRINT AREA TO THE PRINTER 1 1207 2 29 308 A @000025@,PRTCNT * ADD 25 TO TOTAL DIGITS 7 1208 A V8S 411 29 5582 411 309 PRINTX B 000 4 1215 B 000 29 000 310 * 311 * LARGE AREAS RON MAK SAYS THAT BLANKS PROCESS AS ZEROS 312 ORG 2000 2000 313 *FLDLEN EQU 520 * LENGTH OF THE 3 BIG FIELDS 314 B5 DA 1X520 * BASE, 1ST DIVISION HERE 2000 2519 29 315 ORG 3000 3000 316 B239 DA 1X520 * PARALLEL BUFFER FOR ATAN (1/239) 3000 3519 29 317 ORG 4000 4000 318 INTER DA 1X520 * INTERMEDIATE BUFFER, 2ND DIVISION HERE 4000 4519 29 319 ORG 5000 5000 320 ACCUM DA 1X520 * ACCUMULATOR, ANSWER IS FORMED HERE 5000 5519 29 321 * 1 2 3 4 5 6 7 8 322 *78901234567890123456789012345678901234567890123456789012345678901234567890 323 * LABEL | OP | OPERATION |XXXXXXX 324 * 325 *** NOV 15 326 * MACHIN'S METHOD - 327 * PI = 16ARCTAN(1/5) - 4ARCTAN(1/239) 328 * AN ARCTAN SERIES IS 1/N - 1/(3XN^3) + 1/(5XN^5) - ... 329 * 330 *** NOV 16 331 * IN ANY CASE, 332 *LETS DO ARCTAN(X), X = 1/5 333 * 0.19739555984988075837004976519479 334 *THEN 16ARCTAN(1/5) 335 * 3.1583289575980921339207962431166 336 * THEN AECTAN(1/239) 337 * 0.0041840760020747238645382149592855 338 * TIMES 4 339 * 0.016736304008298895458152859837142 340 * PI = 341 * 3.1415926535897932384626433832795 342 * :-)) 343 * 344 * SET N TO 1/X = 5 (THIS IS THE FANCY FOOTWORK :-)) 345 * 346 * 1) A) FORM THREE LARGE AS PRACTICAL EQUAL SIZED AREAS IN MEMORY. 347 * LETS CALL THEM "ACCUMULATOR", ACCUM 348 * "INTERMEDIATE", INTER 349 * "BASE OF NEXT TERM" BASET 350 * B) FORM SMALLER WORKING AREAS 351 * ITERATION COUNTER ITCNT USED FOR OBSERVATION 352 * STARTS AT ZERO, COUNTS UP AFTER A PASS 353 * DIVISOR OF BASET, DIVBAS, USUALLY 5^2 OR 239^2 354 * 5^2 = 25, 239^2 = 57121 355 * ADD/SUBTRACT CONTROL FLAG, CF , TOGGLED AFTER A PASS 356 * 0 MEANS ADD, OTHER IS SUBTRACT 357 * DIVISOR OF INTER IS IX2P1 , ITCNT TIMES 2 PLUS 1 358 * 359 * 2) FIGURE WHERE THE DECIMAL POINT WILL BE 360 * (SAME RELATIVE PLACE IN EACH AREA) 361 * ( SEVERAL CHARACTERS OR WORDS TO THE "RIGHT" OF 362 * THE TOP SIGNIFICANCE.) 363 * 364 * 3) A) ZERO THE ACCUM 365 * B) ( INTER DOES NOT NEED INITIALIZATION) 366 * C) SET X (5.0 IN OUR EXAMPLE) INTO BASET 367 * D) SET COUNTER N TO 1 368 * 369 * 4) WHILE BASET IS NON-ZERO 370 * A) DIVIDE BASET BY X^2 ( 25 IN OUR EXAMPLE ) GIVING BASET 371 * B) DIVIDE BASET BY (2XN - 1) GIVING INTER 372 * C) IF N IS ODD, ADD INTERMEDIATE TO ACCUMULATOR 373 * ELSE, SUBTRACT INTERMEDIATE FROM ACCUMULATOR 374 * D) ADD 1 TO N (ASSURE THAT MACHINE CAN DIVIDE BY 2N) 375 * 376 * 5) ACCUMULATOR IS A FINE APPROXIMATION OF ARCTAN(X) ;-)) DCW @30@ 2 5521 LIT 30 DCW @25@ 2 5523 LIT 30 DCW @000001@ 6 5529 LIT 30 DCW @&@ 1 5530 LIT 30 DCW @0@ 1 5531 LIT 30 DCW @80@ 2 5533 LIT 31 DCW @006@ 3 5536 LIT 31 DCW @1@ 1 5537 LIT 31 DCW @510@ 3 5540 LIT 31 DCW @000000@ 6 5546 LIT 31 DCW @000001@ 6 5552 LIT 31 DCW @956@ 3 5555 LIT 31 DCW @008@ 3 5558 LIT 32 DCW @. * 10E-00000@ 13 5571 LIT 32 DCW @00025@ 5 5576 LIT 32 DCW @000025@ 6 5582 LIT 32 377 END START * LAST CARD IN DECK, TRANSFER ADDRESS / 475 080 475 .PRINT 0201: 0 .PUNCH 0101: 0 .READ 0001: 0 ACCUM 5000: 0 AF239 0405: 0 AF5 0404: 0 AT239X 1037: 0 ATN239 0811: 0 ATN5 0573: 0 ATN5X 0777: 0 B239 3000: 0 B239WD 0403: 0 B5 2000: 0 B5WD 0397: 0 C0 0429: 0 C1 0435: 0 C2 0441: 0 C239 0459: 0 C239P2 0465: 0 C25 0453: 0 C5 0447: 0 INIT 0482: 0 INTER 4000: 0 LC0L9 0474: 0 LIMPCT 0423: 0 LSTCHR 0417: 0 PH1ADD 0748: 0 PH1BCE 0769: 0 PH1L 0652: 0 PH1SUB 0730: 0 PH1W 0762: 0 PH1X1 0781: 0 PH2ADD 0986: 0 PH2BCE 1007: 0 PH2L 0890: 0 PH2SUB 0968: 0 PH2W 1000: 0 PH2X2 1019: 0 PR1LOP 1105: 0 PRINTD 1041: 0 PRINTX 1215: 0 PRTCNT 0411: 0 REV 0379: 0 START 0475: 0 T1 0510: 0 X1 0089: 0 X2 0094: 0 X3 0099: 0 ZB239 0391: 0 ZB5 0385: 0 .PRINT .PUNCH .READ C239 C5 INIT PH1SUB PH2SUB