return to main pageJanuary 2015 Mandelbrot program
Ken Shirriff < ken.shirriff@gmail.com > wrote a Mandelbrot program
Wikipedia on the Mandelbrot Set
Mandelbrot on our 1403 printerrunning time = 12 minutes
---------- start Mandelbrot source ---------------- JOB MANDELBROT *GENERATES A MANDELBROT SET ON THE 1401 *KEN SHIRRIFF HTTP://RIGHTO.COM CTL 6641 ORG 087 X1 DCW 001 *INDEX 1, COL COUNTER TO STORE PIXEL ON LINE ORG 333 * *VALUES ARE FIXED POINT, I.E. SCALED BY 10000 *Y RANGE (-1, 1). 60 LINES YIELDS INC OF 2/60*10000 * YINC DCW 333 XINC DCW 220 *STEP X BY .0220 * *Y START IS -1, MOVED TO -333*30 FOR SYMMETRY * Y0 DCW -09990 *PIXEL Y COORDINATE * *X START IS -2.5 * X0INIT DCW -22000 *LEFT HAND X COORDINATE X0 DCW 00000 *PIXEL X COORDINATE ONE DCW 001 ZR DCW 00000 *REAL PART OF Z ZI DCW 00000 *IMAGINARY PART OF Z ZR2 DCW 00000000000 *ZR^2 ZI2 DCW 00000000000 *ZI^2 ZRZI DCW 00000000000 *2 *ZR *ZI ZMAG DCW 00000000000 *MAGNITUDE OF Z: ZR^2 + ZI^2 TOOBIG DCW 00400000000 *4 (SCALED BY 10000 TWICE) I DCW 00 *ITERATION LOOP COUNTER ROW DCW 01 ROWS DCW 60 COLS DCW 132 MAX DCW 24 *MAXIMUM NUMBER OF ITERATIONS * *ROW LOOP *X1 = 1 (COLUMN INDEX) *X0 = -2.2 (X COORDINATE) * START LCA ONE, X1 *ROW LOOP: INIT COL COUNT LCA X0INIT, X0 *X0 = X0INIT CS 332 *CLEAR PRINT LINE CS *CHAIN INSTRUCTION * *COLUMN LOOP * COLLP LCA @00@, I *I = 0 MCW X0, ZR *ZR = X0 MCW Y0, ZI *ZI = Y0 * *INNER LOOP: *ZR2 = ZR^2 *ZI2 = ZI^2 *IF ZR2+ZI2 > 4: BREAK *ZI = 2*ZR*ZI + Y0 *ZR = ZR2 - ZI2 + X0 * INLP MCW ZR, ZR2-6 *ZR2 = ZR M ZR, ZR2 *ZR2 *= ZR MCW ZI, ZI2-6 *ZI2 = ZI M ZI, ZI2 *ZI2 *= ZI MCW ZR2, ZMAG *ZMAG = ZR^2 A ZI2, ZMAG *ZMAG += ZI^2 C TOOBIG, ZMAG *IF ZMAZ > 4: BREAK BH BREAK MCW ZI, ZRZI-6 *ZRZI = ZI M ZR, ZRZI *ZRZI = ZI*ZR A ZRZI, ZRZI *ZRZI = 2*ZI*ZR MCW ZRZI-4, ZI *ZI = ZRZI (/10000) MZ ZRZI, ZI *TRANSFER SIGN A Y0, ZI *ZI += Y0 S ZI2, ZR2 *ZR2 -= ZI2 MCW ZR2-4, ZR *ZR = ZR2 (/10000) MZ ZR2, ZR *TRANSFER SIGN A X0, ZR *ZR += X0 * *IF I++ != MAX: GOTO INLP * A ONE, I *I++ C MAX, I *IF I != MAX THEN LOOP BU INLP MCW @X@, 200&X1 *STORE AN X INTO THE PRINT LINE BREAK C X1, COLS *COL LOOP CONDITION A ONE, X1 A XINC, X0 *X0 += 0.0227 BU COLLP W *WRITE LINE * *Y0 += YINC *IF ROW++ != ROWS: GOTO ROWLP * C ROW, ROWS *ROW LOOP CONDITION A ONE, ROW A YINC, Y0 *Y0 += 0.0333 BU START FINIS H FINIS HALT LOOP END START -----------end Mandelbrot source ---------------- ----------- start Mandelbrot list -------------------------- BOOTSTRAP FOR CLEAR ,008015,022026,030040/019,001L020100 ,047054,061068,072072)0810811022 1 CLEAR OR BOOTSTRAP ,008047/047046 /000H025B022100 4/061046,054061,068072,0010401040 2 0 MANDELBROT PAGE 1 0 SEQ PG LIN LABEL OP OPERANDS SFX CT LOCN INSTRUCTION TYPE CARD A-ADDR B-ADDR 101 JOB MANDELBROT 102 *GENERATES A MANDELBROT SET ON THE 1401 103 *KEN SHIRRIFF HTTP://RIGHTO.COM 104 CTL 6641 105 ORG 087 0087 106 X1 DCW 001 *INDEX 1, COL COUNTER TO STORE PIXEL ON LINE 3 0089 3 107 ORG 333 0333 108 * 109 *VALUES ARE FIXED POINT, I.E. SCALED BY 10000 110 *Y RANGE (-1, 1). 60 LINES YIELDS INC OF 2/60*10000 111 * 112 YINC DCW 333 3 0335 4 113 XINC DCW 220 *STEP X BY .0220 3 0338 4 114 * 115 *Y START IS -1, MOVED TO -333*30 FOR SYMMETRY 116 * 117 Y0 DCW -09990 *PIXEL Y COORDINATE 5 0343 4 118 * 119 *X START IS -2.5 120 * 121 X0INIT DCW -22000 *LEFT HAND X COORDINATE 5 0348 4 122 X0 DCW 00000 *PIXEL X COORDINATE 5 0353 4 123 ONE DCW 001 3 0356 4 124 ZR DCW 00000 *REAL PART OF Z 5 0361 4 125 ZI DCW 00000 *IMAGINARY PART OF Z 5 0366 5 126 ZR2 DCW 00000000000 *ZR^2 11 0377 5 127 ZI2 DCW 00000000000 *ZI^2 11 0388 5 128 ZRZI DCW 00000000000 *2 *ZR *ZI 11 0399 5 129 ZMAG DCW 00000000000 *MAGNITUDE OF Z: ZR^2 & ZI^2 11 0410 6 130 TOOBIG DCW 00400000000 *4 (SCALED BY 10000 TWICE) 11 0421 6 131 I DCW 00 *ITERATION LOOP COUNTER 2 0423 6 132 ROW DCW 01 2 0425 6 133 ROWS DCW 60 2 0427 6 134 COLS DCW 132 3 0430 6 135 MAX DCW 24 *MAXIMUM NUMBER OF ITERATIONS 2 0432 6 136 * 137 *ROW LOOP 138 *X1 = 1 (COLUMN INDEX) 139 *X0 = -2.2 (X COORDINATE) 140 * 141 START LCA ONE, X1 *ROW LOOP: INIT COL COUNT 7 0433 L 356 089 7 356 089 142 LCA X0INIT, X0 *X0 = X0INIT 7 0440 L 348 353 7 348 353 143 CS 332 *CLEAR PRINT LINE 4 0447 / 332 7 332 144 CS *CHAIN INSTRUCTION 1 0451 / 7 145 * 146 *COLUMN LOOP 147 * 1 MANDELBROT PAGE 2 0 SEQ PG LIN LABEL OP OPERANDS SFX CT LOCN INSTRUCTION TYPE CARD A-ADDR B-ADDR 148 COLLP LCA @00@, I *I = 0 7 0452 L 681 423 7 681 423 149 MCW X0, ZR *ZR = X0 7 0459 M 353 361 7 353 361 150 MCW Y0, ZI *ZI = Y0 7 0466 M 343 366 8 343 366 151 * 152 *INNER LOOP: 153 *ZR2 = ZR^2 154 *ZI2 = ZI^2 155 *IF ZR2+ZI2 > 4: BREAK 156 *ZI = 2*ZR*ZI + Y0 157 *ZR = ZR2 - ZI2 + X0 158 * 159 INLP MCW ZR, ZR2-6 *ZR2 = ZR 7 0473 M 361 371 8 361 371 160 M ZR, ZR2 *ZR2 *= ZR 7 0480 @ 361 377 8 361 377 161 MCW ZI, ZI2-6 *ZI2 = ZI 7 0487 M 366 382 8 366 382 162 M ZI, ZI2 *ZI2 *= ZI 7 0494 @ 366 388 8 366 388 163 MCW ZR2, ZMAG *ZMAG = ZR^2 7 0501 M 377 410 9 377 410 164 A ZI2, ZMAG *ZMAG &= ZI^2 7 0508 A 388 410 9 388 410 165 C TOOBIG, ZMAG *IF ZMAZ > 4: BREAK 7 0515 C 421 410 9 421 410 166 BH BREAK 5 0522 B 623 U 9 623 167 MCW ZI, ZRZI-6 *ZRZI = ZI 7 0527 M 366 393 9 366 393 168 M ZR, ZRZI *ZRZI = ZI*ZR 7 0534 @ 361 399 10 361 399 169 A ZRZI, ZRZI *ZRZI = 2*ZI*ZR 7 0541 A 399 399 10 399 399 170 MCW ZRZI-4, ZI *ZI = ZRZI (/10000) 7 0548 M 395 366 10 395 366 171 MZ ZRZI, ZI *TRANSFER SIGN 7 0555 Y 399 366 10 399 366 172 A Y0, ZI *ZI &= Y0 7 0562 A 343 366 10 343 366 173 S ZI2, ZR2 *ZR2 -= ZI2 7 0569 S 388 377 11 388 377 174 MCW ZR2-4, ZR *ZR = ZR2 (/10000) 7 0576 M 373 361 11 373 361 175 MZ ZR2, ZR *TRANSFER SIGN 7 0583 Y 377 361 11 377 361 176 A X0, ZR *ZR &= X0 7 0590 A 353 361 11 353 361 177 * 178 *IF I++ != MAX: GOTO INLP 179 * 180 A ONE, I *I&& 7 0597 A 356 423 11 356 423 181 C MAX, I *IF I != MAX THEN LOOP 7 0604 C 432 423 12 432 423 182 BU INLP 5 0611 B 473 / 12 473 183 MCW @X@, 200&X1 *STORE AN X INTO THE PRINT LINE 7 0616 M 682 2'0 12 682 200+1 184 BREAK C X1, COLS *COL LOOP CONDITION 7 0623 C 089 430 12 089 430 185 A ONE, X1 7 0630 A 356 089 12 356 089 186 A XINC, X0 *X0 &= 0.0227 7 0637 A 338 353 13 338 353 187 BU COLLP 5 0644 B 452 / 13 452 188 W *WRITE LINE 1 0649 2 13 189 * 190 *Y0 += YINC 191 *IF ROW++ != ROWS: GOTO ROWLP 192 * 193 C ROW, ROWS *ROW LOOP CONDITION 7 0650 C 425 427 13 425 427 194 A ONE, ROW 7 0657 A 356 425 13 356 425 195 A YINC, Y0 *Y0 &= 0.0333 7 0664 A 335 343 13 335 343 196 BU START 5 0671 B 433 / 13 433 197 FINIS H FINIS HALT LOOP 4 0676 . 676 14 676 1 MANDELBROT PAGE 3 0 SEQ PG LIN LABEL OP OPERANDS SFX CT LOCN INSTRUCTION TYPE CARD A-ADDR B-ADDR DCW @00@ 2 0681 LIT 14 DCW @X@ 1 0682 LIT 14 198 END START / 433 080 433 1 PAGE 4 0SYMBOL ADDRESS SYMBOL ADDRESS SYMBOL ADDRESS SYMBOL ADDRESS SYMBOL ADDRESS SYMBOL ADDRESS BREAK 0623: 0 COLLP 0452: 0 COLS 0430: 0 FINIS 0676: 0 I 0423: 0 INLP 0473: 0 MAX 0432: 0 ONE 0356: 0 ROW 0425: 0 ROWS 0427: 0 START 0433: 0 TOOBIG 0421: 0 X0 0353: 0 X0INIT 0348: 0 X1 0089: 0 XINC 0338: 0 Y0 0343: 0 YINC 0335: 0 ZI 0366: 0 ZI2 0388: 0 ZMAG 0410: 0 ZR 0361: 0 ZR2 0377: 0 ZRZI 0399: 0 --------- end Mandelbrot list -----------------------