├── README.md ├── focal69DUE.ino ├── focal69MEGA.ino ├── focal69MEGA_TOPSEQ_EEPROM.ino └── focal69Wifi5.ino /README.md: -------------------------------------------------------------------------------- 1 | # DEC PDP 8 on Arduino 2 | DEC PDP-8 emulator running FOCAL 69 in 4K for Arduino Mega 2560, Arduino DUE and better 3 | 4 | Ladies and Gentlemen, 5 | 6 | The 1960s have called and sent us an AWESOME computer! 7 | 8 | This is based on the work of jcw/Jean-Claude, who has made an amazing PDP-8 emulator in 256 lines of C here: 9 | 10 | https://git.jeelabs.org/jcw/embello/src/branch/master/explore/1638-pdp8 11 | 12 | What you are getting is an ino-file which you just load in the Arduino IDE and flash onto an Arduino DUE (for the complete version), mainly due to the memory requirements. There is also a somewhat reduced version for the Arduino MEGA 2560 - here, I simply "cut off" a few trailing zeroes from the memory dump, so the mem array is SMALLER than 4K, and I am not entirely sure what implications this will have in general, but so far it works. This compromise is needed because the MEGA 2560 has only 8KB SRAM, and a full memory array allocates all of that space to mem[]. 13 | 14 | Then, once having loaded it, open a terminal emulator of some sort (I am using Picocom on Linux) and ... interact! IN CAPITAL LETTERS ONLY. REMEMBER THIS IS 1969 AND LOWER CASE LETTERS ARE AN UNAFFORDABLE LUXURY ONLY AVAILABLE TO THE WEALTHIEST KINGS OF EUROPE. The built-in Serial Monitor of the Arduino IDE will NOT work, as it will not allow you to terminate lines. 15 | 16 | When done, type Ctrl-Backslash to quit. You will see a memory dump. This is in the cleanup()-function, which you may adjust accordingly if you so wish. The idea is, you could perhaps copy and re-use that memory dump in order to initialize the system to your taste and possibly thereby preserve your work, too. 17 | 18 | Consider this a quick-and-dirty and highly experimental port - no warranties of its functionality of any kind are given. 19 | 20 | You should be able to run any other software, provided it runs on 4K and you get a memory dump of jcw's system, and adjust the starting address accordingly. 21 | 22 | Nino Ivanov, 21st May 2020. 23 | -------------------------------------------------------------------------------- /focal69DUE.ino: -------------------------------------------------------------------------------- 1 | #define MEMSIZE 4096 2 | 3 | #define SRL Serial 4 | 5 | #define Word unsigned short 6 | 7 | Word pc; 8 | 9 | // As of this writing, this whole thing is a quick-and-dirty port of this amazing 256-LOC 10 | // PDP-8 / 4K emulator: https://git.jeelabs.org/jcw/embello/src/branch/master/explore/1638-pdp8 11 | // It was written for PC, and I ported it to Arduino - it definitely runs on DUE. 12 | // Beware that the Arduino IDE builtin Serial monitor will not work (will not terminate lines 13 | // correctly), so use some actual terminal emulator - I am using picocom. - To do all this, 14 | // I ran jcw's original program, with the modification that I let it dump its memory right 15 | // after it loaded FOCAL 69. Then, I removed all loading routines and simply placed the 16 | // dump below into the mem-array, to let the machine have FOCAL 69 in memory a priori. 17 | // I have not tested it, but it should be possible, if you program anything, to replace 18 | // this dump with a new FOCAL 69 dump, containing your program. Hence, I modified the 19 | // cleanup-function so that it simply presents such a dump once you press Ctrl-\ - enjoy! 20 | // For instance, you can try this: FOR X=-10,1,10;TYPE X,! 21 | // - Nino, 21st May 2020 22 | Word mem[] = { 23 | 0, 2819, 2819, 1411, 4, 11, 64, 3328, 0, 0, 0, 2296, 1615, 0, 3842, 1677, 0, 0, 1287, 0, 24 | 0, 0, 1, 0, 0, 2032, 0, 0, 0, 2296, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 | 0, 3459, 1028, 3540, 0, 0, 0, 4080, 2032, 748, 1292, 1470, 1462, 1, 141, 0, 5, 0, 140, 135, 26 | 131, 223, 138, 141, 3842, 4032, 174, 4033, 3968, 4080, 127, 15, 191, 4094, 3903, 176, 3936, 3922, 3955, 4093, 27 | 4091, 4087, 63, 128, 2048, 1048, 1133, 3021, 3072, 3200, 1632, 1670, 1632, 1679, 1039, 1287, 337, 885, 319, 348, 28 | 364, 1212, 1346, 716, 465, 1333, 1133, 1301, 194, 1186, 1264, 267, 847, 859, 1053, 484, 448, 1074, 1494, 0, 29 | 0, 0, 0, 0, 0, 0, 2297, 3976, 2942, 607, 1554, 3585, 1600, 1558, 662, 1547, 661, 2409, 602, 1544, 30 | 1586, 602, 1559, 2410, 2407, 59, 316, 2406, 2703, 170, 1680, 2406, 2406, 602, 1551, 1552, 2405, 541, 1547, 2416, 31 | 2417, 2802, 2745, 1046, 2412, 596, 565, 4000, 2422, 560, 1544, 1586, 567, 1800, 2416, 3848, 2405, 2406, 566, 590, 32 | 4000, 2736, 2421, 2414, 2687, 2400, 393, 786, 3880, 2687, 1554, 530, 3585, 2714, 0, 2416, 566, 586, 4008, 2770, 33 | 1566, 2553, 551, 250, 550, 4000, 2422, 551, 2415, 3588, 1591, 2417, 2405, 2417, 2784, 2794, 556, 3654, 556, 3588, 34 | 567, 1591, 2405, 2417, 2422, 2794, 556, 567, 1591, 2405, 2417, 2784, 3848, 2422, 3648, 567, 68, 4000, 3600, 567, 35 | 70, 3888, 2422, 4000, 763, 3600, 3588, 1589, 3010, 2944, 4064, 1024, 1036, 1032, 624, 610, 875, 739, 2560, 2448, 36 | 2592, 2693, 2688, 3840, 1493, 1493, 1493, 0, 3654, 3590, 3590, 2955, 2412, 530, 2402, 2403, 15, 2403, 53, 565, 37 | 4040, 2739, 2413, 3584, 531, 1545, 777, 2419, 2422, 2400, 390, 2404, 53, 786, 3880, 2745, 3585, 1560, 565, 4064, 38 | 2736, 792, 2419, 2745, 792, 1591, 2709, 2413, 2422, 2400, 392, 2404, 53, 2404, 15, 779, 1554, 3006, 393, 0, 39 | 1593, 3616, 2248, 569, 1803, 3616, 2248, 3007, 0, 523, 1547, 523, 3681, 537, 3992, 2422, 3016, 0, 977, 1593, 40 | 3616, 2248, 721, 3585, 1803, 3616, 2248, 2873, 0, 3744, 988, 1545, 1244, 591, 2248, 591, 1593, 777, 1803, 1081, 41 | 2789, 591, 2248, 3036, 0, 3744, 1004, 1260, 1545, 591, 1593, 779, 1801, 1081, 2803, 3052, 1504, 138, 143, 151, 42 | 573, 607, 1493, 565, 392, 396, 3898, 2412, 2413, 2422, 531, 1554, 2405, 566, 590, 4008, 2913, 2408, 766, 2696, 43 | 566, 61, 2402, 2405, 2408, 766, 3848, 2707, 779, 2407, 507, 119, 2422, 2412, 1046, 2413, 2743, 567, 4000, 2411, 44 | 2405, 2409, 566, 590, 4000, 2724, 787, 3880, 2745, 3585, 1560, 565, 4032, 792, 2419, 2747, 792, 1591, 2719, 531, 45 | 2731, 1558, 2913, 565, 4072, 2745, 2409, 2740, 0, 2416, 2408, 1015, 3008, 566, 1216, 642, 4008, 2767, 2417, 3008, 46 | 3848, 3008, 1216, 1216, 3008, 0, 977, 1546, 778, 3912, 2784, 3617, 566, 4000, 2772, 977, 3616, 522, 1580, 3848, 47 | 1233, 1233, 3776, 3025, 0, 68, 3617, 1593, 567, 68, 569, 4008, 1252, 3044, 0, 542, 4000, 2804, 2405, 3054, 48 | 2410, 2407, 3582, 1794, 3054, 541, 392, 396, 211, 198, 201, 196, 199, 195, 193, 212, 204, 197, 215, 205, 49 | 209, 210, 138, 2420, 2463, 1035, 2464, 585, 1562, 549, 3912, 1050, 4072, 1050, 3848, 3063, 2407, 767, 3833, 2405, 50 | 2712, 2405, 2709, 897, 1063, 2400, 771, 2416, 566, 733, 3872, 2422, 536, 2402, 2400, 906, 779, 1560, 2311, 3352, 51 | 0, 2407, 767, 3711, 2422, 536, 2402, 2400, 906, 2407, 767, 3708, 2422, 2403, 1048, 2400, 906, 2403, 1048, 2403, 52 | 15, 2400, 392, 2404, 15, 2404, 1048, 2404, 3896, 779, 1560, 2311, 280, 987, 3352, 1365, 0, 549, 4064, 2913, 53 | 536, 2402, 2403, 3896, 2753, 3907, 3924, 2403, 1285, 2753, 2347, 2402, 566, 734, 4000, 2422, 2400, 906, 2347, 3123, 54 | 3712, 779, 3119, 3848, 2347, 3712, 2910, 545, 545, 523, 272, 387, 396, 642, 643, 3907, 1156, 413, 686, 127, 55 | 883, 3313, 3744, 1582, 1558, 2407, 761, 126, 1070, 2710, 2400, 771, 566, 2402, 685, 2409, 1054, 3585, 2393, 779, 56 | 1590, 2690, 2400, 907, 2392, 2691, 1046, 2405, 2407, 771, 507, 2409, 2715, 2405, 2412, 567, 1578, 2692, 575, 2355, 57 | 3616, 575, 2409, 2405, 2692, 186, 2412, 2413, 2422, 560, 1544, 1586, 567, 1800, 520, 1559, 2356, 1600, 1046, 2405, 58 | 2409, 2407, 62, 697, 2406, 2747, 560, 3585, 1544, 1586, 2410, 2407, 57, 697, 2406, 2758, 0, 3880, 566, 3617, 59 | 1593, 972, 1228, 1546, 778, 3912, 2784, 569, 4000, 2772, 522, 972, 1593, 825, 1593, 2873, 1228, 3776, 3020, 2347, 60 | 3584, 3325, 3290, 2790, 3314, 1574, 3073, 2910, 0, 3110, 3094, 3105, 2799, 3712, 3052, 699, 696, 1504, 706, 697, 61 | 177, 714, 165, 162, 161, 163, 164, 160, 172, 187, 141, 2420, 162, 141, 2422, 1586, 2406, 2405, 2408, 1015, 62 | 2710, 566, 82, 561, 1585, 2405, 2408, 1015, 2710, 2705, 2418, 2719, 561, 1582, 2480, 779, 1585, 2479, 2347, 1743, 63 | 560, 1560, 536, 3617, 537, 4072, 2737, 792, 3617, 561, 4008, 2757, 536, 568, 2721, 1063, 897, 537, 517, 3681, 64 | 523, 3984, 2422, 537, 568, 1561, 561, 1816, 1048, 719, 1816, 1048, 2311, 351, 3352, 0, 2913, 536, 1545, 777, 65 | 3617, 719, 4000, 2732, 1048, 1048, 2913, 0, 566, 588, 4000, 3023, 2405, 2768, 3920, 3911, 0, 1024, 0, 0, 66 | 566, 589, 4000, 1243, 566, 726, 1580, 556, 4040, 3035, 566, 727, 4072, 1243, 3035, 2311, 728, 2280, 3288, 0, 67 | 1752, 1572, 2910, 607, 1554, 779, 1593, 2873, 673, 666, 681, 678, 1578, 683, 683, 392, 396, 0, 556, 2402, 68 | 557, 2402, 558, 2402, 641, 2402, 2405, 1581, 2420, 2711, 2778, 2787, 2400, 775, 2420, 2724, 138, 255, 2422, 607, 69 | 1560, 585, 556, 3880, 2727, 3585, 4008, 2771, 556, 593, 4040, 2803, 2418, 3848, 2422, 556, 1556, 532, 593, 4032, 70 | 1556, 532, 3617, 557, 4040, 2760, 557, 3658, 3594, 729, 1724, 557, 4000, 2404, 36, 2311, 0, 3413, 0, 597, 71 | 1560, 532, 557, 4008, 2913, 779, 1581, 2733, 2418, 3848, 2805, 557, 2402, 536, 1744, 2403, 0, 532, 1581, 2405, 72 | 2420, 2803, 2778, 2787, 2704, 280, 2403, 36, 597, 1560, 1566, 2393, 2404, 36, 2706, 1582, 2405, 2408, 1015, 2796, 73 | 558, 3652, 566, 2787, 2418, 2422, 2177, 779, 2407, 1140, 3207, 2418, 2422, 2177, 1035, 2910, 160, 171, 173, 175, 74 | 170, 222, 168, 219, 188, 169, 221, 190, 172, 187, 141, 189, 2403, 1285, 2404, 36, 665, 4040, 2345, 2311, 75 | 3584, 3224, 0, 597, 1560, 2215, 2967, 914, 0, 0, 0, 0, 3, 0, 556, 593, 4032, 2973, 556, 592, 76 | 4064, 1181, 2973, 0, 779, 1581, 668, 779, 3617, 556, 4000, 2422, 2405, 2983, 0, 3074, 2413, 2994, 1046, 2405, 77 | 566, 590, 4000, 2743, 527, 3616, 531, 1583, 603, 3617, 531, 4008, 2687, 3584, 787, 1813, 603, 1593, 825, 3880, 78 | 2775, 1562, 531, 3681, 538, 3992, 559, 538, 1849, 538, 2761, 3616, 531, 1545, 559, 3616, 531, 1546, 559, 560, 79 | 1584, 520, 3616, 522, 1562, 520, 559, 1544, 778, 1801, 1050, 2792, 2739, 0, 2356, 1590, 2408, 915, 3053, 2409, 80 | 3053, 1371, 1448, 1438, 1397, 1432, 1359, 1402, 1428, 1429, 1452, 1405, 1474, 1433, 1399, 216, 2420, 2719, 2706, 2699, 81 | 566, 586, 3872, 2422, 605, 1584, 1883, 560, 1561, 2687, 2412, 560, 1544, 2421, 1043, 565, 4032, 787, 2419, 2703, 82 | 787, 1591, 2709, 560, 1561, 2913, 0, 603, 1557, 603, 1555, 531, 1545, 567, 3681, 777, 3880, 2742, 3992, 2743, 83 | 531, 1557, 787, 3872, 2726, 3848, 1186, 531, 3585, 1551, 1552, 2978, 0, 2264, 4040, 518, 751, 566, 3880, 2766, 84 | 573, 1590, 534, 576, 4008, 2409, 3004, 2264, 3616, 2750, 534, 4000, 2774, 576, 4008, 3585, 1600, 2749, 584, 2757, 85 | 0, 1040, 2789, 529, 82, 1590, 566, 579, 4008, 2763, 566, 750, 3032, 783, 1553, 3616, 1552, 529, 3658, 3594, 86 | 3594, 2780, 4064, 4001, 0, 3584, 789, 1840, 560, 1813, 561, 3872, 1800, 520, 3585, 1584, 560, 1561, 3056, 683, 87 | 396, 3202, 495, 495, 3240, 1, 1024, 0, 0, 0, 0, 4086, 0, 3097, 2701, 3102, 70, 3880, 2701, 595, 88 | 2956, 0, 567, 2415, 82, 2210, 578, 2409, 567, 2210, 750, 1590, 2409, 2965, 0, 70, 1562, 587, 1563, 2730, 89 | 1051, 1562, 538, 651, 3904, 2728, 3712, 539, 2409, 538, 587, 2409, 2978, 0, 3880, 566, 590, 3880, 2750, 575, 90 | 2355, 2997, 575, 2355, 574, 2748, 0, 584, 3617, 566, 3880, 746, 577, 3880, 3053, 747, 1593, 569, 236, 750, 91 | 3872, 748, 4008, 2778, 569, 82, 3872, 2269, 3584, 3010, 594, 2269, 2772, 0, 1074, 2799, 561, 1800, 1585, 523, 92 | 3681, 517, 520, 3984, 3037, 2422, 32, 255, 96, 1540, 4000, 2415, 1585, 3616, 1586, 3037, 0, 0, 0, 0, 93 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3965, 1664, 3592, 1665, 3105, 2709, 3106, 1550, 949, 3880, 94 | 2709, 3108, 1550, 1973, 693, 3585, 71, 691, 1717, 3097, 2726, 3102, 70, 3880, 2726, 595, 1714, 690, 642, 4008, 95 | 2784, 540, 4000, 2422, 690, 1564, 3081, 2730, 3082, 1567, 3236, 3137, 3584, 641, 3652, 640, 3073, 2816, 0, 1616, 96 | 1616, 1616, 0, 540, 3944, 2743, 1726, 1564, 702, 2998, 0, 1718, 3073, 948, 4000, 2753, 3074, 526, 4000, 2764, 97 | 694, 3110, 1550, 2771, 694, 1972, 692, 3585, 71, 691, 1716, 3073, 3006, 1750, 0, 3744, 726, 1591, 3073, 526, 98 | 4000, 2779, 3074, 2786, 595, 1591, 1038, 581, 1583, 3616, 691, 1544, 3584, 1800, 1071, 2793, 1564, 691, 1717, 691, 99 | 1716, 3616, 3110, 577, 2409, 2411, 1042, 786, 3880, 2815, 1591, 577, 2409, 2409, 2411, 575, 2409, 598, 1642, 2687, 100 | 562, 4000, 2700, 520, 3617, 535, 4032, 2977, 681, 2409, 520, 1593, 3584, 1074, 2722, 825, 82, 579, 4000, 2719, 101 | 3616, 1586, 3616, 520, 1544, 825, 65, 1585, 2977, 1368, 825, 65, 518, 4000, 2712, 1849, 2713, 220, 560, 1560, 102 | 537, 3617, 536, 4008, 2913, 792, 1742, 717, 1551, 1552, 2405, 2409, 2405, 2409, 2405, 2409, 1048, 792, 2508, 2405, 103 | 2409, 1048, 2311, 280, 0, 2392, 575, 2409, 568, 585, 536, 2731, 1314, 1613, 0, 2601, 0, 0, 0, 0, 104 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1679, 0, 237, 399, 193, 812, 3193, 3513, 4045, 1693, 107 | 138, 1312, 2146, 207, 903, 1153, 1301, 769, 1289, 974, 1249, 2146, 4045, 1722, 148, 1312, 2081, 2201, 981, 2056, 108 | 86, 352, 1237, 195, 339, 1222, 1356, 793, 2060, 961, 261, 288, 2502, 963, 76, 2865, 3702, 3687, 2063, 928, 109 | 96, 4045, 1752, 153, 1221, 1312, 1028, 1085, 1028, 1066, 3230, 3185, 3780, 2097, 2994, 3515, 271, 2097, 3001, 3780, 110 | 992, 3259, 2068, 2081, 2192, 1167, 197, 324, 2978, 2145, 3794, 4045, 1772, 154, 582, 2088, 1028, 1069, 3497, 2097, 111 | 2995, 3116, 3182, 3255, 3796, 2082, 1028, 1069, 3631, 802, 3794, 4045, 1781, 155, 1312, 2192, 272, 2929, 3234, 3794, 112 | 4045, 1795, 158, 608, 2576, 272, 2933, 2673, 2996, 3796, 2082, 769, 173, 3618, 4045, 1809, 168, 608, 2576, 272, 113 | 2932, 2673, 2997, 3796, 2082, 777, 899, 2936, 4045, 1827, 178, 1312, 2192, 272, 2914, 3785, 416, 2576, 272, 2931, 114 | 2673, 2998, 3796, 2082, 3631, 610, 4045, 1839, 188, 582, 2088, 1028, 1069, 3241, 3182, 3579, 1312, 2232, 4045, 1852, 115 | 198, 582, 2088, 1028, 1069, 3177, 3182, 3643, 1312, 2232, 3027, 4045, 1863, 208, 582, 2088, 1028, 1065, 3182, 3707, 116 | 1312, 2229, 4045, 1874, 218, 1312, 2208, 207, 848, 1364, 338, 2978, 2145, 4045, 1881, 271, 1221, 1312, 1542, 3953, 117 | 4045, 1894, 276, 1312, 2146, 1224, 76, 800, 608, 1157, 1281, 590, 2082, 4045, 1906, 281, 1312, 2188, 967, 2848, 118 | 344, 1068, 2049, 1294, 2079, 4045, 1921, 286, 271, 2097, 3131, 582, 2088, 1157, 2674, 3001, 2866, 2996, 2866, 2996, 119 | 4045, 1946, 296, 271, 2098, 2994, 3796, 2082, 1225, 901, 2848, 207, 1225, 901, 2079, 2235, 271, 2097, 3131, 582, 120 | 2088, 1157, 2674, 2997, 3794, 4045, 1954, 306, 1248, 1542, 3949, 3195, 2066, 4045, 1960, 346, 1248, 1542, 3952, 4045, 121 | 1979, 1320, 96, 1157, 3785, 2088, 1157, 2928, 1605, 1257, 2097, 3118, 3436, 3184, 2996, 3436, 3184, 2997, 4045, 1988, 122 | 1325, 2067, 340, 2066, 381, 2929, 3794, 4045, 2001, 1330, 582, 2088, 1157, 2928, 911, 2673, 3118, 3500, 3184, 3000, 123 | 4045, 2024, 1340, 1312, 2146, 1036, 321, 1221, 2049, 915, 1477, 1184, 2521, 339, 2528, 978, 2087, 911, 2528, 2235, 124 | 480, 3184, 2996, 4045, 0, 1360, 1221, 1312, 1157, 3953, 3794, 4045, 0, 0, 0, 0, 0, 0, 0, 0, 125 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1505, 760, 1662, 3170, 138 | 3135, 3178, 3570, 3082, 3302, 3578, 3776, 1804, 1071, 2691, 754, 2297, 760, 1536, 3616, 3191, 3712, 3193, 4008, 2710, 139 | 757, 3169, 758, 3169, 3712, 2760, 3169, 15, 2, 3585, 4008, 2758, 3649, 3300, 3289, 4032, 2726, 744, 2026, 745, 140 | 2027, 2759, 3820, 759, 4008, 2741, 3812, 758, 4008, 2762, 576, 2036, 650, 2035, 2763, 1521, 2764, 3110, 3072, 3072, 141 | 3072, 3072, 3072, 3072, 3072, 3072, 1071, 3105, 2742, 559, 600, 4040, 2761, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 142 | 3110, 3073, 2400, 273, 3074, 752, 2297, 3880, 2788, 4040, 758, 592, 1583, 748, 1545, 749, 1801, 1071, 2779, 752, 143 | 2297, 4040, 580, 750, 751, 1565, 3047, 1164, 3275, 3271, 619, 622, 257, 1493, 368, 2447, 1542, 1457, 1028, 3282, 144 | 1452, 7, 2, 2050, 2354, 1252, 1585, 2400, 799, 1048, 792, 3065, 0, 0, 0, 0, 0, 0, 0, 0, 145 | 0, 0, 0, 0, 0, 0, 0, 0, 549, 4040, 2516, 1563, 2311, 2251, 3517, 0, 2347, 1749, 2311, 3584, 146 | 3518, 445, 1470, 3517, 2493, 3518, 712, 3286, 197, 1750, 1469, 703, 3286, 194, 2494, 726, 3286, 445, 1750, 2257, 147 | 718, 0, 725, 548, 1572, 1051, 2910, 2311, 3517, 206, 1981, 0, 2910, 2770, 2774, 4, 1274, 770, 4092, 1135, 148 | 2671, 10, 2860, 227, 7, 1398, 2785, 1, 1477, 1309, 1, 1024, 0, 2, 1024, 0, 2675, 0, 0, 0, 149 | 0, 0, 2311, 445, 2493, 3518, 2300, 761, 2494, 758, 3286, 243, 2494, 752, 2494, 749, 2493, 1750, 0, 3052, 150 | 2580, 0, 1311, 931, 4095, 1732, 2332, 4091, 1734, 2860, 0, 1311, 934, 0, 1303, 1235, 4093, 1815, 3626, 0, 151 | 549, 4040, 2291, 1563, 2311, 3485, 1439, 0, 549, 4040, 2705, 2311, 415, 1949, 3485, 0, 3744, 1778, 2963, 2522, 152 | 1266, 2972, 2311, 3485, 414, 1437, 0, 2972, 2754, 2770, 2766, 2510, 549, 3880, 2422, 4040, 2345, 2311, 3566, 1439, 153 | 0, 549, 3880, 2910, 4032, 2740, 2311, 415, 2030, 3566, 0, 3744, 1563, 517, 1572, 3616, 1006, 1573, 1574, 1575, 154 | 3585, 2030, 2311, 2287, 3485, 494, 1439, 3566, 2283, 744, 2542, 741, 2542, 738, 2542, 735, 2542, 732, 2542, 729, 155 | 2542, 726, 2542, 925, 0, 2972, 0, 2047, 4066, 4095, 2048, 2112, 4095, 1359, 199, 4094, 2123, 3721, 4094, 1373, 156 | 1729, 4093, 2534, 505, 4092, 1182, 2244, 4089, 2404, 989, 2518, 0, 1419, 2316, 0, 0, 2345, 3744, 3059, 0, 157 | 0, 0, 0, 0, 0, 0, 0, 0, 2311, 3282, 206, 1234, 0, 549, 4064, 2701, 549, 4032, 2910, 2345, 158 | 3616, 1563, 2311, 1734, 3286, 0, 2347, 2311, 3584, 3282, 214, 1234, 2246, 3282, 1226, 0, 549, 4040, 2725, 2311, 159 | 3282, 0, 539, 3616, 1563, 2311, 210, 1230, 0, 549, 4040, 2737, 2311, 202, 1234, 3282, 0, 2311, 210, 1742, 160 | 3282, 2258, 3286, 218, 2262, 734, 2262, 738, 2262, 742, 2262, 718, 2258, 0, 1051, 2910, 2345, 2910, 3, 1608, 161 | 2030, 1693, 2, 1608, 2030, 1693, 1, 1608, 2030, 1693, 0, 0, 0, 0, 0, 0, 0, 0, 4084, 1281, 162 | 3597, 546, 4089, 2868, 2892, 3176, 4093, 1305, 2801, 2526, 0, 2773, 268, 1655, 0, 0, 0, 0, 0, 0, 163 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1756, 554, 2415, 164 | 82, 1562, 538, 3617, 3880, 726, 1757, 554, 3880, 2721, 82, 1755, 733, 731, 3912, 2712, 3744, 538, 1755, 3616, 165 | 539, 3904, 3712, 538, 3912, 2739, 726, 3904, 3712, 727, 1593, 985, 569, 1758, 569, 3617, 1593, 725, 1502, 990, 166 | 728, 4040, 2741, 2014, 1081, 2769, 1502, 1051, 3712, 554, 4008, 2798, 733, 539, 3936, 2797, 731, 3904, 3712, 3617, 167 | 539, 3617, 1562, 539, 538, 4008, 2787, 538, 3585, 4040, 581, 2270, 1050, 2755, 578, 2409, 2755, 3616, 734, 1758, 168 | 2730, 5, 4090, 7, 4086, 3176, 3180, 0, 0, 0, 0, 2522, 1245, 3038, 2944, 3616, 539, 1563, 1244, 2795, 169 | 3616, 1756, 2763, 780, 2763, 3712, 2522, 578, 2409, 1152, 780, 2270, 1244, 2802, 3616, 1756, 2803, 0, 549, 1576, 170 | 549, 4040, 2345, 3065, 0, 1574, 1572, 1573, 1575, 1740, 1576, 566, 692, 3880, 2704, 585, 4000, 2705, 3616, 1576, 171 | 2486, 566, 693, 4008, 2704, 2199, 2944, 0, 566, 690, 4008, 2967, 2417, 2967, 2727, 556, 1739, 2231, 1228, 4000, 172 | 2422, 2486, 2712, 566, 586, 4040, 2967, 566, 691, 4064, 2967, 566, 82, 2720, 3899, 3878, 3925, 3936, 494, 0, 173 | 551, 1571, 550, 1570, 549, 1569, 1738, 2253, 2253, 2267, 2253, 715, 1571, 1570, 1569, 2267, 714, 2999, 0, 0, 174 | 0, 0, 551, 3652, 1575, 550, 3588, 1574, 549, 3588, 1573, 714, 3588, 1738, 3021, 0, 3776, 551, 547, 1575, 175 | 3588, 550, 546, 1574, 3588, 549, 545, 1573, 3588, 714, 1738, 3035, 0, 3776, 545, 3912, 3664, 3592, 1569, 546, 176 | 3592, 1570, 547, 3592, 1571, 1056, 3052, 3052, 0, 0, 0, 0, 0, 733, 2409, 549, 4032, 732, 734, 2409, 177 | 2539, 1563, 548, 3912, 2711, 3872, 737, 4072, 2716, 2311, 2532, 0, 3585, 539, 2697, 2311, 2538, 0, 3616, 2709, 178 | 2021, 2022, 744, 1548, 548, 3680, 1772, 739, 1572, 2391, 1260, 2725, 998, 3880, 2744, 738, 4040, 2740, 3585, 1804, 179 | 1060, 738, 1051, 3584, 998, 1051, 3584, 3848, 2535, 1804, 1060, 2744, 744, 1548, 739, 2537, 2944, 731, 2409, 539, 180 | 3912, 3617, 1573, 539, 4032, 585, 734, 2409, 549, 1060, 735, 3904, 2765, 736, 1573, 3616, 548, 3872, 2284, 549, 181 | 2522, 2944, 1314, 197, 4083, 189, 173, 3996, 100, 4092, 4086, 4089, 3261, 3019, 3018, 2999, 3895, 2816, 3257, 2937, 182 | 0, 587, 2409, 3052, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183 | 0, 4000, 2502, 566, 588, 4008, 2690, 2498, 566, 589, 4000, 2705, 2502, 1989, 2499, 965, 3617, 1563, 712, 1572, 184 | 2500, 2503, 2311, 3352, 0, 566, 705, 4000, 2726, 2502, 2498, 2500, 551, 539, 1563, 2311, 280, 0, 539, 3880, 185 | 2944, 4032, 2737, 2311, 2237, 3352, 0, 3585, 2742, 2311, 2233, 3352, 0, 3616, 539, 1563, 2726, 4, 1280, 0, 186 | 0, 4093, 1638, 1639, 1640, 3899, 2944, 2967, 3707, 3020, 494, 3805, 35, 0, 0, 0, 0, 0, 0, 0, 187 | 0, 0, 581, 1763, 543, 4032, 2804, 1050, 2772, 1251, 2772, 2275, 523, 766, 3984, 3042, 1035, 2913, 138, 0, 188 | 765, 3616, 1789, 3680, 1567, 765, 3872, 3084, 4000, 767, 598, 1642, 3043, 2275, 3059, 393, 3616, 1567, 3086, 70, 189 | 3880, 2770, 595, 1590, 3025, 0, 2415, 2148, 0, 3776, 1575, 1571, 896, 3880, 2944, 1714, 690, 83, 4008, 2702, 190 | 580, 128, 1568, 582, 178, 544, 1568, 691, 178, 4008, 2713, 800, 1568, 1152, 3616, 544, 1549, 690, 3654, 3590, 191 | 71, 3880, 2743, 692, 1714, 946, 3880, 2741, 1714, 708, 1548, 591, 1583, 781, 1804, 1071, 2733, 2994, 0, 256, 192 | 3451, 707, 2747, 707, 1549, 3616, 544, 1548, 591, 1583, 780, 1805, 1071, 2750, 2689, 35, 31, 2549, 2552, 2689, 193 | 2554, 2553, 2555, 2551, 2689, 549, 4000, 2773, 1572, 1573, 1574, 1575, 2689, 2403, 36, 2403, 32, 2404, 36, 2347, 194 | 3912, 2786, 3616, 1714, 1571, 549, 4000, 2422, 2403, 1285, 2404, 36, 2404, 3896, 2800, 2403, 3896, 2404, 32, 2550, 195 | 1202, 2795, 2689, 2550, 2689, 3691, 3588, 3805, 3475, 3052, 3567, 3035, 3398, 3397, 3655, 3443, 3405, 0, 3403, 0, 196 | 3776, 551, 3617, 1575, 550, 3616, 3864, 3649, 1574, 549, 3616, 3864, 3649, 1573, 2947, 0, 549, 3880, 550, 4008, 197 | 2761, 545, 3880, 546, 3880, 547, 4008, 2963, 544, 3617, 548, 3880, 2747, 1667, 643, 3904, 3617, 1746, 722, 734, 198 | 4040, 2749, 643, 4032, 2741, 2287, 1234, 2737, 2747, 3616, 544, 1568, 2515, 1234, 2744, 1171, 2963, 544, 4032, 2756, 199 | 548, 4032, 2963, 2758, 548, 4032, 643, 4064, 2963, 544, 1572, 545, 1573, 546, 1574, 547, 1575, 2963, 0, 3052, 200 | 0, 2537, 548, 4072, 2795, 3585, 1571, 744, 1568, 2195, 23, 1063, 2788, 1062, 3848, 1061, 1575, 2538, 550, 3028, 201 | 23, 2937, 3707, 1572, 1573, 1574, 2788, 0, 3776, 549, 3912, 3600, 3592, 1573, 550, 3592, 1574, 551, 3592, 1575, 202 | 1060, 3055, 3055, 223, 255, 138, 253, 4095, 0, 3585, 544, 2260, 4040, 2283, 1729, 1728, 1727, 1726, 549, 2025, 203 | 545, 2538, 2, 546, 2538, 3, 550, 2025, 545, 2538, 3, 546, 2538, 4, 2739, 1724, 547, 2025, 549, 2538, 204 | 4, 550, 2538, 5, 551, 2025, 545, 2538, 4, 546, 2538, 5, 547, 2538, 6, 705, 1573, 704, 1574, 703, 205 | 1575, 2241, 1575, 2948, 0, 0, 0, 0, 0, 0, 1064, 2345, 2535, 1063, 3009, 545, 4008, 2422, 544, 3617, 206 | 3585, 2260, 4032, 2283, 2536, 2241, 3027, 3329, 0, 548, 1572, 596, 37, 545, 4032, 3616, 1576, 549, 3880, 3046, 207 | 4040, 2345, 545, 3880, 3046, 3028, 3408, 3805, 3761, 3758, 3712, 0, 3776, 547, 3617, 1571, 546, 3616, 3864, 3649, 208 | 1570, 545, 3616, 3864, 3649, 1569, 3051, 0, 552, 4040, 2345, 3067, 0, 3880, 2944, 1708, 1707, 687, 1709, 3648, 209 | 684, 3592, 1708, 683, 3856, 2704, 3648, 686, 3592, 1707, 1197, 2696, 684, 3592, 1709, 896, 3617, 682, 1708, 685, 210 | 3648, 940, 1964, 1196, 3588, 683, 940, 1964, 3856, 2944, 1196, 1452, 2944, 2726, 3650, 0, 0, 0, 0, 4084, 211 | 4073, 0, 1664, 1708, 688, 1709, 3848, 2391, 3648, 546, 550, 1710, 3588, 549, 545, 3856, 2756, 1573, 686, 1574, 212 | 3712, 684, 3588, 1708, 640, 3588, 1664, 1197, 2743, 684, 1574, 640, 1573, 2993, 3588, 1757, 1197, 2743, 733, 1573, 213 | 640, 1574, 684, 1575, 2993, 0, 2557, 2294, 549, 3880, 551, 3880, 550, 4008, 2803, 549, 3652, 4040, 2800, 2391, 214 | 3680, 548, 1572, 2791, 2558, 2294, 3037, 1572, 3037, 3567, 0, 549, 3912, 3617, 4040, 2549, 3062, 2937, 3707, 0, 215 | 2311, 3260, 0, 549, 4040, 2422, 548, 3912, 3600, 3592, 1720, 3864, 1208, 3584, 695, 1721, 1722, 1723, 701, 3880, 216 | 702, 4008, 2741, 2311, 188, 1720, 696, 0, 3744, 548, 1572, 548, 3617, 696, 4000, 2737, 549, 3617, 697, 4000, 217 | 2737, 550, 3617, 698, 3904, 3617, 3585, 4032, 2910, 2311, 3256, 0, 2711, 1572, 2910, 1549, 0, 0, 0, 0, 218 | 0, 0, 0, 3907, 0, 0, 0, 603, 2263, 560, 2263, 537, 2263, 541, 2263, 2766, 2405, 2409, 566, 590, 219 | 4000, 2764, 526, 4000, 2770, 3074, 2884, 0, 1562, 538, 3590, 3590, 2280, 2415, 3588, 2280, 3594, 3592, 2280, 2280, 220 | 3712, 575, 2409, 3031, 0, 238, 587, 2409, 538, 3048, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 225 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 226 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 227 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 228 | }; 229 | 230 | 231 | Word mask(Word w) { return w & 07777; } 232 | Word lmask(Word w) { return w & 017777; } 233 | 234 | Word opAddr (int ir) { 235 | Word a = ir & 0177; 236 | if (ir & 0200) 237 | a |= (pc - 1) & 07600; 238 | if (ir & 0400) { 239 | if ((a & 07770) == 010) 240 | mem[a] = mask(mem[a] + 1); 241 | a = mem[a]; 242 | } 243 | return a; 244 | } 245 | 246 | // This I simply turned into a memory dump, so if anything was 247 | // programmed in FOCAL, it should be retained here and could be 248 | // pasted later on at the top. - Nino 249 | void cleanup () { 250 | SRL.println(); 251 | SRL.println(); 252 | int cntr; 253 | int cont; 254 | int decer = 0; 255 | for (cntr = 0; cntr < MEMSIZE; cntr++) { 256 | cont = mem[cntr]; 257 | SRL.print(cont); 258 | SRL.print(", "); 259 | decer++; 260 | if (decer == 12) { 261 | SRL.print("\r\n"); 262 | decer = 0; 263 | } 264 | 265 | } 266 | SRL.println(); 267 | SRL.println(); 268 | 269 | } 270 | 271 | void setup() { 272 | 273 | 274 | 275 | // start serial port at 300 bps 276 | SRL.begin(1200); 277 | 278 | pc = 0200; 279 | 280 | Word sr = 0; 281 | 282 | Word ac = 0, mq = 0; 283 | int iena = 0; 284 | for (;;) { 285 | iena >>= 1; // implements delayed enabling, relies on sign extension 286 | 287 | static short counter; // HACK: every 65536 ops, we fake an interrupt 288 | if ((iena & 1) && ++counter == 0) { 289 | mem[0] = pc; 290 | pc = 1; 291 | iena = 0; 292 | } 293 | 294 | int ir = mem[pc]; 295 | 296 | pc = mask(pc + 1); 297 | switch ((ir >> 9) & 07) { 298 | 299 | case 0: // AND 300 | ac &= mem[opAddr(ir)] | 010000; 301 | break; 302 | 303 | case 1: // TAD 304 | ac = lmask(ac + mem[opAddr(ir)]); 305 | break; 306 | 307 | case 2: { // ISZ 308 | Word t = opAddr(ir); 309 | mem[t] = mask(mem[t] + 1); 310 | if (mem[t] == 0) 311 | pc = mask(pc + 1); 312 | break; 313 | } 314 | 315 | case 3: // DCA 316 | mem[opAddr(ir)] = mask(ac); 317 | ac &= 010000; 318 | break; 319 | 320 | case 4: { // JMS 321 | Word t = opAddr(ir); 322 | mem[t] = pc; 323 | pc = mask(t + 1); 324 | break; 325 | } 326 | 327 | case 5: // JMP 328 | pc = opAddr(ir); 329 | break; 330 | 331 | case 6: // IOT 332 | switch ((ir >> 3) & 077) { 333 | case 00: 334 | switch (ir) { 335 | case 06001: iena = ~1; break; // delays one cycle 336 | case 06002: iena = 0; break; 337 | default: { // SRL.print("IOT "); SRL.print(ir, OCT); SRL.print(" AC="); SRL.println(ac, OCT); 338 | } 339 | } 340 | break; 341 | case 03: // keyboard 342 | if ((ir & 01) && SRL.available()) { 343 | pc = mask(pc + 1);} 344 | if (ir & 04) { // read byte 345 | int b = SRL.read(); 346 | if (b == 0x1C) { // exit program on ctrl-backslash 347 | SRL.print("\r\nQUIT\r\n"); 348 | cleanup(); 349 | 350 | // return 4; 351 | if (ir & 01) // skip if ready 352 | pc = mask(pc + 1); 353 | if (ir & 04) { // send byte 354 | SRL.write(ac & 0177); // strip off parity 355 | // fflush(stdout); 356 | } 357 | if (ir & 02) // clear flag 358 | ac &= 010000; 359 | 360 | } 361 | ac = (ac & 010000) | b; 362 | } 363 | break; 364 | case 04: // teleprinter 365 | if (ir & 01) // skip if ready 366 | pc = mask(pc + 1); 367 | if (ir & 04) { // send byte 368 | SRL.write(ac & 0177); // strip off parity 369 | // fflush(stdout); 370 | } 371 | if (ir & 02) // clear flag 372 | ac &= 010000; 373 | break; 374 | default: 375 | { // SRL.print("IOT "); SRL.print(ir, OCT); SRL.print(" AC="); SRL.println(ac, OCT); 376 | } 377 | break; 378 | } 379 | break; 380 | 381 | case 7: // OPR 382 | if ((ir & 0400) == 0) { // group 1 383 | if (ir & 0200) // CLA 384 | ac &= 010000; 385 | if (ir & 0100) // CLL 386 | ac &= 07777; 387 | if (ir & 040) // CMA 388 | ac ^= 07777; 389 | if (ir & 020) // CML 390 | ac ^= 010000; 391 | if (ir & 01) // IAC 392 | ac = lmask(ac + 1); 393 | switch (ir & 016) { 394 | case 012: // RTR 395 | ac = lmask((ac >> 1) | (ac << 12)); // fall through 396 | case 010: // RAR 397 | ac = lmask((ac >> 1) | (ac << 12)); 398 | break; 399 | case 06: // RTL 400 | ac = lmask((ac >> 12) | (ac << 1)); // fall through 401 | case 04: // RAL 402 | ac = lmask((ac >> 12) | (ac << 1)); 403 | break; 404 | case 02: // BSW 405 | ac = (ac & 010000) | ((ac >> 6) & 077) 406 | | ((ac << 6) & 07700); 407 | break; 408 | } 409 | } else if ((ir & 01) == 0) { // group 2 410 | // SMA, SPA, SZA, SNA, SNL, SZL 411 | int s = ((ir & 0100) && (ac & 04000)) || 412 | ((ir & 040) && (ac & 07777) == 0) || 413 | ((ir & 020) && (ac & 010000) != 0) ? 0 : 010; 414 | if (s == (ir & 010)) 415 | pc = mask(pc + 1); 416 | if (ir & 0200) // CLA 417 | ac &= 010000; 418 | if (ir & 04) // OSR 419 | ac |= sr; 420 | if (ir & 02) { // HLT 421 | SRL.print("\r\nHALT "); SRL.println(mask(ac), OCT); 422 | // return 0; 423 | } 424 | } else { // group 3 425 | Word t = mq; 426 | if (ir & 0200) // CLA 427 | ac &= 010000; 428 | if (ir & 020) { // MQL 429 | mq = ac & 07777; 430 | ac &= 010000; 431 | } 432 | if (ir & 0100) 433 | ac |= t; 434 | } 435 | break; 436 | } 437 | } 438 | 439 | 440 | } 441 | 442 | void loop() {} 443 | -------------------------------------------------------------------------------- /focal69MEGA.ino: -------------------------------------------------------------------------------- 1 | #define MEMSIZE 3952 2 | // i.e. NOT the full 4096 3 | 4 | #define SRL Serial 5 | 6 | #define Word unsigned int 7 | 8 | Word pc; 9 | 10 | // As of this writing, this whole thing is a quick-and-dirty port of this amazing 256-LOC 11 | // PDP-8 / 4K emulator: https://git.jeelabs.org/jcw/embello/src/branch/master/explore/1638-pdp8 12 | // It was written for PC, and I ported it to Arduino - it definitely runs on DUE. 13 | // Beware that the Arduino IDE builtin Serial monitor will not work (will not terminate lines 14 | // correctly), so use some actual terminal emulator - I am using picocom. - To do all this, 15 | // I ran jcw's original program, with the modification that I let it dump its memory right 16 | // after it loaded FOCAL 69. Then, I removed all loading routines and simply placed the 17 | // dump below into the mem-array, to let the machine have FOCAL 69 in memory a priori. 18 | // I have not tested it, but it should be possible, if you program anything, to replace 19 | // this dump with a new FOCAL 69 dump, containing your program. Hence, I modified the 20 | // cleanup-function so that it simply presents such a dump once you press Ctrl-\ - enjoy! 21 | // For instance, you can try this: FOR X=-10,1,10;TYPE X,! 22 | // - Nino, 21st May 2020 23 | Word mem[] = { 24 | 0, 2819, 2819, 1411, 4, 11, 64, 3328, 0, 0, 0, 2296, 1615, 0, 3842, 1677, 0, 0, 1287, 0, 25 | 0, 0, 1, 0, 0, 2032, 0, 0, 0, 2296, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26 | 0, 3459, 1028, 3540, 0, 0, 0, 4080, 2032, 748, 1292, 1470, 1462, 1, 141, 0, 5, 0, 140, 135, 27 | 131, 223, 138, 141, 3842, 4032, 174, 4033, 3968, 4080, 127, 15, 191, 4094, 3903, 176, 3936, 3922, 3955, 4093, 28 | 4091, 4087, 63, 128, 2048, 1048, 1133, 3021, 3072, 3200, 1632, 1670, 1632, 1679, 1039, 1287, 337, 885, 319, 348, 29 | 364, 1212, 1346, 716, 465, 1333, 1133, 1301, 194, 1186, 1264, 267, 847, 859, 1053, 484, 448, 1074, 1494, 0, 30 | 0, 0, 0, 0, 0, 0, 2297, 3976, 2942, 607, 1554, 3585, 1600, 1558, 662, 1547, 661, 2409, 602, 1544, 31 | 1586, 602, 1559, 2410, 2407, 59, 316, 2406, 2703, 170, 1680, 2406, 2406, 602, 1551, 1552, 2405, 541, 1547, 2416, 32 | 2417, 2802, 2745, 1046, 2412, 596, 565, 4000, 2422, 560, 1544, 1586, 567, 1800, 2416, 3848, 2405, 2406, 566, 590, 33 | 4000, 2736, 2421, 2414, 2687, 2400, 393, 786, 3880, 2687, 1554, 530, 3585, 2714, 0, 2416, 566, 586, 4008, 2770, 34 | 1566, 2553, 551, 250, 550, 4000, 2422, 551, 2415, 3588, 1591, 2417, 2405, 2417, 2784, 2794, 556, 3654, 556, 3588, 35 | 567, 1591, 2405, 2417, 2422, 2794, 556, 567, 1591, 2405, 2417, 2784, 3848, 2422, 3648, 567, 68, 4000, 3600, 567, 36 | 70, 3888, 2422, 4000, 763, 3600, 3588, 1589, 3010, 2944, 4064, 1024, 1036, 1032, 624, 610, 875, 739, 2560, 2448, 37 | 2592, 2693, 2688, 3840, 1493, 1493, 1493, 0, 3654, 3590, 3590, 2955, 2412, 530, 2402, 2403, 15, 2403, 53, 565, 38 | 4040, 2739, 2413, 3584, 531, 1545, 777, 2419, 2422, 2400, 390, 2404, 53, 786, 3880, 2745, 3585, 1560, 565, 4064, 39 | 2736, 792, 2419, 2745, 792, 1591, 2709, 2413, 2422, 2400, 392, 2404, 53, 2404, 15, 779, 1554, 3006, 393, 0, 40 | 1593, 3616, 2248, 569, 1803, 3616, 2248, 3007, 0, 523, 1547, 523, 3681, 537, 3992, 2422, 3016, 0, 977, 1593, 41 | 3616, 2248, 721, 3585, 1803, 3616, 2248, 2873, 0, 3744, 988, 1545, 1244, 591, 2248, 591, 1593, 777, 1803, 1081, 42 | 2789, 591, 2248, 3036, 0, 3744, 1004, 1260, 1545, 591, 1593, 779, 1801, 1081, 2803, 3052, 1504, 138, 143, 151, 43 | 573, 607, 1493, 565, 392, 396, 3898, 2412, 2413, 2422, 531, 1554, 2405, 566, 590, 4008, 2913, 2408, 766, 2696, 44 | 566, 61, 2402, 2405, 2408, 766, 3848, 2707, 779, 2407, 507, 119, 2422, 2412, 1046, 2413, 2743, 567, 4000, 2411, 45 | 2405, 2409, 566, 590, 4000, 2724, 787, 3880, 2745, 3585, 1560, 565, 4032, 792, 2419, 2747, 792, 1591, 2719, 531, 46 | 2731, 1558, 2913, 565, 4072, 2745, 2409, 2740, 0, 2416, 2408, 1015, 3008, 566, 1216, 642, 4008, 2767, 2417, 3008, 47 | 3848, 3008, 1216, 1216, 3008, 0, 977, 1546, 778, 3912, 2784, 3617, 566, 4000, 2772, 977, 3616, 522, 1580, 3848, 48 | 1233, 1233, 3776, 3025, 0, 68, 3617, 1593, 567, 68, 569, 4008, 1252, 3044, 0, 542, 4000, 2804, 2405, 3054, 49 | 2410, 2407, 3582, 1794, 3054, 541, 392, 396, 211, 198, 201, 196, 199, 195, 193, 212, 204, 197, 215, 205, 50 | 209, 210, 138, 2420, 2463, 1035, 2464, 585, 1562, 549, 3912, 1050, 4072, 1050, 3848, 3063, 2407, 767, 3833, 2405, 51 | 2712, 2405, 2709, 897, 1063, 2400, 771, 2416, 566, 733, 3872, 2422, 536, 2402, 2400, 906, 779, 1560, 2311, 3352, 52 | 0, 2407, 767, 3711, 2422, 536, 2402, 2400, 906, 2407, 767, 3708, 2422, 2403, 1048, 2400, 906, 2403, 1048, 2403, 53 | 15, 2400, 392, 2404, 15, 2404, 1048, 2404, 3896, 779, 1560, 2311, 280, 987, 3352, 1365, 0, 549, 4064, 2913, 54 | 536, 2402, 2403, 3896, 2753, 3907, 3924, 2403, 1285, 2753, 2347, 2402, 566, 734, 4000, 2422, 2400, 906, 2347, 3123, 55 | 3712, 779, 3119, 3848, 2347, 3712, 2910, 545, 545, 523, 272, 387, 396, 642, 643, 3907, 1156, 413, 686, 127, 56 | 883, 3313, 3744, 1582, 1558, 2407, 761, 126, 1070, 2710, 2400, 771, 566, 2402, 685, 2409, 1054, 3585, 2393, 779, 57 | 1590, 2690, 2400, 907, 2392, 2691, 1046, 2405, 2407, 771, 507, 2409, 2715, 2405, 2412, 567, 1578, 2692, 575, 2355, 58 | 3616, 575, 2409, 2405, 2692, 186, 2412, 2413, 2422, 560, 1544, 1586, 567, 1800, 520, 1559, 2356, 1600, 1046, 2405, 59 | 2409, 2407, 62, 697, 2406, 2747, 560, 3585, 1544, 1586, 2410, 2407, 57, 697, 2406, 2758, 0, 3880, 566, 3617, 60 | 1593, 972, 1228, 1546, 778, 3912, 2784, 569, 4000, 2772, 522, 972, 1593, 825, 1593, 2873, 1228, 3776, 3020, 2347, 61 | 3584, 3325, 3290, 2790, 3314, 1574, 3073, 2910, 0, 3110, 3094, 3105, 2799, 3712, 3052, 699, 696, 1504, 706, 697, 62 | 177, 714, 165, 162, 161, 163, 164, 160, 172, 187, 141, 2420, 162, 141, 2422, 1586, 2406, 2405, 2408, 1015, 63 | 2710, 566, 82, 561, 1585, 2405, 2408, 1015, 2710, 2705, 2418, 2719, 561, 1582, 2480, 779, 1585, 2479, 2347, 1743, 64 | 560, 1560, 536, 3617, 537, 4072, 2737, 792, 3617, 561, 4008, 2757, 536, 568, 2721, 1063, 897, 537, 517, 3681, 65 | 523, 3984, 2422, 537, 568, 1561, 561, 1816, 1048, 719, 1816, 1048, 2311, 351, 3352, 0, 2913, 536, 1545, 777, 66 | 3617, 719, 4000, 2732, 1048, 1048, 2913, 0, 566, 588, 4000, 3023, 2405, 2768, 3920, 3911, 0, 1024, 0, 0, 67 | 566, 589, 4000, 1243, 566, 726, 1580, 556, 4040, 3035, 566, 727, 4072, 1243, 3035, 2311, 728, 2280, 3288, 0, 68 | 1752, 1572, 2910, 607, 1554, 779, 1593, 2873, 673, 666, 681, 678, 1578, 683, 683, 392, 396, 0, 556, 2402, 69 | 557, 2402, 558, 2402, 641, 2402, 2405, 1581, 2420, 2711, 2778, 2787, 2400, 775, 2420, 2724, 138, 255, 2422, 607, 70 | 1560, 585, 556, 3880, 2727, 3585, 4008, 2771, 556, 593, 4040, 2803, 2418, 3848, 2422, 556, 1556, 532, 593, 4032, 71 | 1556, 532, 3617, 557, 4040, 2760, 557, 3658, 3594, 729, 1724, 557, 4000, 2404, 36, 2311, 0, 3413, 0, 597, 72 | 1560, 532, 557, 4008, 2913, 779, 1581, 2733, 2418, 3848, 2805, 557, 2402, 536, 1744, 2403, 0, 532, 1581, 2405, 73 | 2420, 2803, 2778, 2787, 2704, 280, 2403, 36, 597, 1560, 1566, 2393, 2404, 36, 2706, 1582, 2405, 2408, 1015, 2796, 74 | 558, 3652, 566, 2787, 2418, 2422, 2177, 779, 2407, 1140, 3207, 2418, 2422, 2177, 1035, 2910, 160, 171, 173, 175, 75 | 170, 222, 168, 219, 188, 169, 221, 190, 172, 187, 141, 189, 2403, 1285, 2404, 36, 665, 4040, 2345, 2311, 76 | 3584, 3224, 0, 597, 1560, 2215, 2967, 914, 0, 0, 0, 0, 3, 0, 556, 593, 4032, 2973, 556, 592, 77 | 4064, 1181, 2973, 0, 779, 1581, 668, 779, 3617, 556, 4000, 2422, 2405, 2983, 0, 3074, 2413, 2994, 1046, 2405, 78 | 566, 590, 4000, 2743, 527, 3616, 531, 1583, 603, 3617, 531, 4008, 2687, 3584, 787, 1813, 603, 1593, 825, 3880, 79 | 2775, 1562, 531, 3681, 538, 3992, 559, 538, 1849, 538, 2761, 3616, 531, 1545, 559, 3616, 531, 1546, 559, 560, 80 | 1584, 520, 3616, 522, 1562, 520, 559, 1544, 778, 1801, 1050, 2792, 2739, 0, 2356, 1590, 2408, 915, 3053, 2409, 81 | 3053, 1371, 1448, 1438, 1397, 1432, 1359, 1402, 1428, 1429, 1452, 1405, 1474, 1433, 1399, 216, 2420, 2719, 2706, 2699, 82 | 566, 586, 3872, 2422, 605, 1584, 1883, 560, 1561, 2687, 2412, 560, 1544, 2421, 1043, 565, 4032, 787, 2419, 2703, 83 | 787, 1591, 2709, 560, 1561, 2913, 0, 603, 1557, 603, 1555, 531, 1545, 567, 3681, 777, 3880, 2742, 3992, 2743, 84 | 531, 1557, 787, 3872, 2726, 3848, 1186, 531, 3585, 1551, 1552, 2978, 0, 2264, 4040, 518, 751, 566, 3880, 2766, 85 | 573, 1590, 534, 576, 4008, 2409, 3004, 2264, 3616, 2750, 534, 4000, 2774, 576, 4008, 3585, 1600, 2749, 584, 2757, 86 | 0, 1040, 2789, 529, 82, 1590, 566, 579, 4008, 2763, 566, 750, 3032, 783, 1553, 3616, 1552, 529, 3658, 3594, 87 | 3594, 2780, 4064, 4001, 0, 3584, 789, 1840, 560, 1813, 561, 3872, 1800, 520, 3585, 1584, 560, 1561, 3056, 683, 88 | 396, 3202, 495, 495, 3240, 1, 1024, 0, 0, 0, 0, 4086, 0, 3097, 2701, 3102, 70, 3880, 2701, 595, 89 | 2956, 0, 567, 2415, 82, 2210, 578, 2409, 567, 2210, 750, 1590, 2409, 2965, 0, 70, 1562, 587, 1563, 2730, 90 | 1051, 1562, 538, 651, 3904, 2728, 3712, 539, 2409, 538, 587, 2409, 2978, 0, 3880, 566, 590, 3880, 2750, 575, 91 | 2355, 2997, 575, 2355, 574, 2748, 0, 584, 3617, 566, 3880, 746, 577, 3880, 3053, 747, 1593, 569, 236, 750, 92 | 3872, 748, 4008, 2778, 569, 82, 3872, 2269, 3584, 3010, 594, 2269, 2772, 0, 1074, 2799, 561, 1800, 1585, 523, 93 | 3681, 517, 520, 3984, 3037, 2422, 32, 255, 96, 1540, 4000, 2415, 1585, 3616, 1586, 3037, 0, 0, 0, 0, 94 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3965, 1664, 3592, 1665, 3105, 2709, 3106, 1550, 949, 3880, 95 | 2709, 3108, 1550, 1973, 693, 3585, 71, 691, 1717, 3097, 2726, 3102, 70, 3880, 2726, 595, 1714, 690, 642, 4008, 96 | 2784, 540, 4000, 2422, 690, 1564, 3081, 2730, 3082, 1567, 3236, 3137, 3584, 641, 3652, 640, 3073, 2816, 0, 1616, 97 | 1616, 1616, 0, 540, 3944, 2743, 1726, 1564, 702, 2998, 0, 1718, 3073, 948, 4000, 2753, 3074, 526, 4000, 2764, 98 | 694, 3110, 1550, 2771, 694, 1972, 692, 3585, 71, 691, 1716, 3073, 3006, 1750, 0, 3744, 726, 1591, 3073, 526, 99 | 4000, 2779, 3074, 2786, 595, 1591, 1038, 581, 1583, 3616, 691, 1544, 3584, 1800, 1071, 2793, 1564, 691, 1717, 691, 100 | 1716, 3616, 3110, 577, 2409, 2411, 1042, 786, 3880, 2815, 1591, 577, 2409, 2409, 2411, 575, 2409, 598, 1642, 2687, 101 | 562, 4000, 2700, 520, 3617, 535, 4032, 2977, 681, 2409, 520, 1593, 3584, 1074, 2722, 825, 82, 579, 4000, 2719, 102 | 3616, 1586, 3616, 520, 1544, 825, 65, 1585, 2977, 1368, 825, 65, 518, 4000, 2712, 1849, 2713, 220, 560, 1560, 103 | 537, 3617, 536, 4008, 2913, 792, 1742, 717, 1551, 1552, 2405, 2409, 2405, 2409, 2405, 2409, 1048, 792, 2508, 2405, 104 | 2409, 1048, 2311, 280, 0, 2392, 575, 2409, 568, 585, 536, 2731, 1314, 1613, 0, 2601, 0, 0, 0, 0, 105 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 107 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1679, 0, 237, 399, 193, 812, 3193, 3513, 4045, 1693, 108 | 138, 1312, 2146, 207, 903, 1153, 1301, 769, 1289, 974, 1249, 2146, 4045, 1722, 148, 1312, 2081, 2201, 981, 2056, 109 | 86, 352, 1237, 195, 339, 1222, 1356, 793, 2060, 961, 261, 288, 2502, 963, 76, 2865, 3702, 3687, 2063, 928, 110 | 96, 4045, 1752, 153, 1221, 1312, 1028, 1085, 1028, 1066, 3230, 3185, 3780, 2097, 2994, 3515, 271, 2097, 3001, 3780, 111 | 992, 3259, 2068, 2081, 2192, 1167, 197, 324, 2978, 2145, 3794, 4045, 1772, 154, 582, 2088, 1028, 1069, 3497, 2097, 112 | 2995, 3116, 3182, 3255, 3796, 2082, 1028, 1069, 3631, 802, 3794, 4045, 1781, 155, 1312, 2192, 272, 2929, 3234, 3794, 113 | 4045, 1795, 158, 608, 2576, 272, 2933, 2673, 2996, 3796, 2082, 769, 173, 3618, 4045, 1809, 168, 608, 2576, 272, 114 | 2932, 2673, 2997, 3796, 2082, 777, 899, 2936, 4045, 1827, 178, 1312, 2192, 272, 2914, 3785, 416, 2576, 272, 2931, 115 | 2673, 2998, 3796, 2082, 3631, 610, 4045, 1839, 188, 582, 2088, 1028, 1069, 3241, 3182, 3579, 1312, 2232, 4045, 1852, 116 | 198, 582, 2088, 1028, 1069, 3177, 3182, 3643, 1312, 2232, 3027, 4045, 1863, 208, 582, 2088, 1028, 1065, 3182, 3707, 117 | 1312, 2229, 4045, 1874, 218, 1312, 2208, 207, 848, 1364, 338, 2978, 2145, 4045, 1881, 271, 1221, 1312, 1542, 3953, 118 | 4045, 1894, 276, 1312, 2146, 1224, 76, 800, 608, 1157, 1281, 590, 2082, 4045, 1906, 281, 1312, 2188, 967, 2848, 119 | 344, 1068, 2049, 1294, 2079, 4045, 1921, 286, 271, 2097, 3131, 582, 2088, 1157, 2674, 3001, 2866, 2996, 2866, 2996, 120 | 4045, 1946, 296, 271, 2098, 2994, 3796, 2082, 1225, 901, 2848, 207, 1225, 901, 2079, 2235, 271, 2097, 3131, 582, 121 | 2088, 1157, 2674, 2997, 3794, 4045, 1954, 306, 1248, 1542, 3949, 3195, 2066, 4045, 1960, 346, 1248, 1542, 3952, 4045, 122 | 1979, 1320, 96, 1157, 3785, 2088, 1157, 2928, 1605, 1257, 2097, 3118, 3436, 3184, 2996, 3436, 3184, 2997, 4045, 1988, 123 | 1325, 2067, 340, 2066, 381, 2929, 3794, 4045, 2001, 1330, 582, 2088, 1157, 2928, 911, 2673, 3118, 3500, 3184, 3000, 124 | 4045, 2024, 1340, 1312, 2146, 1036, 321, 1221, 2049, 915, 1477, 1184, 2521, 339, 2528, 978, 2087, 911, 2528, 2235, 125 | 480, 3184, 2996, 4045, 0, 1360, 1221, 1312, 1157, 3953, 3794, 4045, 0, 0, 0, 0, 0, 0, 0, 0, 126 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 129 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 136 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 137 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 138 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1505, 760, 1662, 3170, 139 | 3135, 3178, 3570, 3082, 3302, 3578, 3776, 1804, 1071, 2691, 754, 2297, 760, 1536, 3616, 3191, 3712, 3193, 4008, 2710, 140 | 757, 3169, 758, 3169, 3712, 2760, 3169, 15, 2, 3585, 4008, 2758, 3649, 3300, 3289, 4032, 2726, 744, 2026, 745, 141 | 2027, 2759, 3820, 759, 4008, 2741, 3812, 758, 4008, 2762, 576, 2036, 650, 2035, 2763, 1521, 2764, 3110, 3072, 3072, 142 | 3072, 3072, 3072, 3072, 3072, 3072, 1071, 3105, 2742, 559, 600, 4040, 2761, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 143 | 3110, 3073, 2400, 273, 3074, 752, 2297, 3880, 2788, 4040, 758, 592, 1583, 748, 1545, 749, 1801, 1071, 2779, 752, 144 | 2297, 4040, 580, 750, 751, 1565, 3047, 1164, 3275, 3271, 619, 622, 257, 1493, 368, 2447, 1542, 1457, 1028, 3282, 145 | 1452, 7, 2, 2050, 2354, 1252, 1585, 2400, 799, 1048, 792, 3065, 0, 0, 0, 0, 0, 0, 0, 0, 146 | 0, 0, 0, 0, 0, 0, 0, 0, 549, 4040, 2516, 1563, 2311, 2251, 3517, 0, 2347, 1749, 2311, 3584, 147 | 3518, 445, 1470, 3517, 2493, 3518, 712, 3286, 197, 1750, 1469, 703, 3286, 194, 2494, 726, 3286, 445, 1750, 2257, 148 | 718, 0, 725, 548, 1572, 1051, 2910, 2311, 3517, 206, 1981, 0, 2910, 2770, 2774, 4, 1274, 770, 4092, 1135, 149 | 2671, 10, 2860, 227, 7, 1398, 2785, 1, 1477, 1309, 1, 1024, 0, 2, 1024, 0, 2675, 0, 0, 0, 150 | 0, 0, 2311, 445, 2493, 3518, 2300, 761, 2494, 758, 3286, 243, 2494, 752, 2494, 749, 2493, 1750, 0, 3052, 151 | 2580, 0, 1311, 931, 4095, 1732, 2332, 4091, 1734, 2860, 0, 1311, 934, 0, 1303, 1235, 4093, 1815, 3626, 0, 152 | 549, 4040, 2291, 1563, 2311, 3485, 1439, 0, 549, 4040, 2705, 2311, 415, 1949, 3485, 0, 3744, 1778, 2963, 2522, 153 | 1266, 2972, 2311, 3485, 414, 1437, 0, 2972, 2754, 2770, 2766, 2510, 549, 3880, 2422, 4040, 2345, 2311, 3566, 1439, 154 | 0, 549, 3880, 2910, 4032, 2740, 2311, 415, 2030, 3566, 0, 3744, 1563, 517, 1572, 3616, 1006, 1573, 1574, 1575, 155 | 3585, 2030, 2311, 2287, 3485, 494, 1439, 3566, 2283, 744, 2542, 741, 2542, 738, 2542, 735, 2542, 732, 2542, 729, 156 | 2542, 726, 2542, 925, 0, 2972, 0, 2047, 4066, 4095, 2048, 2112, 4095, 1359, 199, 4094, 2123, 3721, 4094, 1373, 157 | 1729, 4093, 2534, 505, 4092, 1182, 2244, 4089, 2404, 989, 2518, 0, 1419, 2316, 0, 0, 2345, 3744, 3059, 0, 158 | 0, 0, 0, 0, 0, 0, 0, 0, 2311, 3282, 206, 1234, 0, 549, 4064, 2701, 549, 4032, 2910, 2345, 159 | 3616, 1563, 2311, 1734, 3286, 0, 2347, 2311, 3584, 3282, 214, 1234, 2246, 3282, 1226, 0, 549, 4040, 2725, 2311, 160 | 3282, 0, 539, 3616, 1563, 2311, 210, 1230, 0, 549, 4040, 2737, 2311, 202, 1234, 3282, 0, 2311, 210, 1742, 161 | 3282, 2258, 3286, 218, 2262, 734, 2262, 738, 2262, 742, 2262, 718, 2258, 0, 1051, 2910, 2345, 2910, 3, 1608, 162 | 2030, 1693, 2, 1608, 2030, 1693, 1, 1608, 2030, 1693, 0, 0, 0, 0, 0, 0, 0, 0, 4084, 1281, 163 | 3597, 546, 4089, 2868, 2892, 3176, 4093, 1305, 2801, 2526, 0, 2773, 268, 1655, 0, 0, 0, 0, 0, 0, 164 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1756, 554, 2415, 165 | 82, 1562, 538, 3617, 3880, 726, 1757, 554, 3880, 2721, 82, 1755, 733, 731, 3912, 2712, 3744, 538, 1755, 3616, 166 | 539, 3904, 3712, 538, 3912, 2739, 726, 3904, 3712, 727, 1593, 985, 569, 1758, 569, 3617, 1593, 725, 1502, 990, 167 | 728, 4040, 2741, 2014, 1081, 2769, 1502, 1051, 3712, 554, 4008, 2798, 733, 539, 3936, 2797, 731, 3904, 3712, 3617, 168 | 539, 3617, 1562, 539, 538, 4008, 2787, 538, 3585, 4040, 581, 2270, 1050, 2755, 578, 2409, 2755, 3616, 734, 1758, 169 | 2730, 5, 4090, 7, 4086, 3176, 3180, 0, 0, 0, 0, 2522, 1245, 3038, 2944, 3616, 539, 1563, 1244, 2795, 170 | 3616, 1756, 2763, 780, 2763, 3712, 2522, 578, 2409, 1152, 780, 2270, 1244, 2802, 3616, 1756, 2803, 0, 549, 1576, 171 | 549, 4040, 2345, 3065, 0, 1574, 1572, 1573, 1575, 1740, 1576, 566, 692, 3880, 2704, 585, 4000, 2705, 3616, 1576, 172 | 2486, 566, 693, 4008, 2704, 2199, 2944, 0, 566, 690, 4008, 2967, 2417, 2967, 2727, 556, 1739, 2231, 1228, 4000, 173 | 2422, 2486, 2712, 566, 586, 4040, 2967, 566, 691, 4064, 2967, 566, 82, 2720, 3899, 3878, 3925, 3936, 494, 0, 174 | 551, 1571, 550, 1570, 549, 1569, 1738, 2253, 2253, 2267, 2253, 715, 1571, 1570, 1569, 2267, 714, 2999, 0, 0, 175 | 0, 0, 551, 3652, 1575, 550, 3588, 1574, 549, 3588, 1573, 714, 3588, 1738, 3021, 0, 3776, 551, 547, 1575, 176 | 3588, 550, 546, 1574, 3588, 549, 545, 1573, 3588, 714, 1738, 3035, 0, 3776, 545, 3912, 3664, 3592, 1569, 546, 177 | 3592, 1570, 547, 3592, 1571, 1056, 3052, 3052, 0, 0, 0, 0, 0, 733, 2409, 549, 4032, 732, 734, 2409, 178 | 2539, 1563, 548, 3912, 2711, 3872, 737, 4072, 2716, 2311, 2532, 0, 3585, 539, 2697, 2311, 2538, 0, 3616, 2709, 179 | 2021, 2022, 744, 1548, 548, 3680, 1772, 739, 1572, 2391, 1260, 2725, 998, 3880, 2744, 738, 4040, 2740, 3585, 1804, 180 | 1060, 738, 1051, 3584, 998, 1051, 3584, 3848, 2535, 1804, 1060, 2744, 744, 1548, 739, 2537, 2944, 731, 2409, 539, 181 | 3912, 3617, 1573, 539, 4032, 585, 734, 2409, 549, 1060, 735, 3904, 2765, 736, 1573, 3616, 548, 3872, 2284, 549, 182 | 2522, 2944, 1314, 197, 4083, 189, 173, 3996, 100, 4092, 4086, 4089, 3261, 3019, 3018, 2999, 3895, 2816, 3257, 2937, 183 | 0, 587, 2409, 3052, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 184 | 0, 4000, 2502, 566, 588, 4008, 2690, 2498, 566, 589, 4000, 2705, 2502, 1989, 2499, 965, 3617, 1563, 712, 1572, 185 | 2500, 2503, 2311, 3352, 0, 566, 705, 4000, 2726, 2502, 2498, 2500, 551, 539, 1563, 2311, 280, 0, 539, 3880, 186 | 2944, 4032, 2737, 2311, 2237, 3352, 0, 3585, 2742, 2311, 2233, 3352, 0, 3616, 539, 1563, 2726, 4, 1280, 0, 187 | 0, 4093, 1638, 1639, 1640, 3899, 2944, 2967, 3707, 3020, 494, 3805, 35, 0, 0, 0, 0, 0, 0, 0, 188 | 0, 0, 581, 1763, 543, 4032, 2804, 1050, 2772, 1251, 2772, 2275, 523, 766, 3984, 3042, 1035, 2913, 138, 0, 189 | 765, 3616, 1789, 3680, 1567, 765, 3872, 3084, 4000, 767, 598, 1642, 3043, 2275, 3059, 393, 3616, 1567, 3086, 70, 190 | 3880, 2770, 595, 1590, 3025, 0, 2415, 2148, 0, 3776, 1575, 1571, 896, 3880, 2944, 1714, 690, 83, 4008, 2702, 191 | 580, 128, 1568, 582, 178, 544, 1568, 691, 178, 4008, 2713, 800, 1568, 1152, 3616, 544, 1549, 690, 3654, 3590, 192 | 71, 3880, 2743, 692, 1714, 946, 3880, 2741, 1714, 708, 1548, 591, 1583, 781, 1804, 1071, 2733, 2994, 0, 256, 193 | 3451, 707, 2747, 707, 1549, 3616, 544, 1548, 591, 1583, 780, 1805, 1071, 2750, 2689, 35, 31, 2549, 2552, 2689, 194 | 2554, 2553, 2555, 2551, 2689, 549, 4000, 2773, 1572, 1573, 1574, 1575, 2689, 2403, 36, 2403, 32, 2404, 36, 2347, 195 | 3912, 2786, 3616, 1714, 1571, 549, 4000, 2422, 2403, 1285, 2404, 36, 2404, 3896, 2800, 2403, 3896, 2404, 32, 2550, 196 | 1202, 2795, 2689, 2550, 2689, 3691, 3588, 3805, 3475, 3052, 3567, 3035, 3398, 3397, 3655, 3443, 3405, 0, 3403, 0, 197 | 3776, 551, 3617, 1575, 550, 3616, 3864, 3649, 1574, 549, 3616, 3864, 3649, 1573, 2947, 0, 549, 3880, 550, 4008, 198 | 2761, 545, 3880, 546, 3880, 547, 4008, 2963, 544, 3617, 548, 3880, 2747, 1667, 643, 3904, 3617, 1746, 722, 734, 199 | 4040, 2749, 643, 4032, 2741, 2287, 1234, 2737, 2747, 3616, 544, 1568, 2515, 1234, 2744, 1171, 2963, 544, 4032, 2756, 200 | 548, 4032, 2963, 2758, 548, 4032, 643, 4064, 2963, 544, 1572, 545, 1573, 546, 1574, 547, 1575, 2963, 0, 3052, 201 | 0, 2537, 548, 4072, 2795, 3585, 1571, 744, 1568, 2195, 23, 1063, 2788, 1062, 3848, 1061, 1575, 2538, 550, 3028, 202 | 23, 2937, 3707, 1572, 1573, 1574, 2788, 0, 3776, 549, 3912, 3600, 3592, 1573, 550, 3592, 1574, 551, 3592, 1575, 203 | 1060, 3055, 3055, 223, 255, 138, 253, 4095, 0, 3585, 544, 2260, 4040, 2283, 1729, 1728, 1727, 1726, 549, 2025, 204 | 545, 2538, 2, 546, 2538, 3, 550, 2025, 545, 2538, 3, 546, 2538, 4, 2739, 1724, 547, 2025, 549, 2538, 205 | 4, 550, 2538, 5, 551, 2025, 545, 2538, 4, 546, 2538, 5, 547, 2538, 6, 705, 1573, 704, 1574, 703, 206 | 1575, 2241, 1575, 2948, 0, 0, 0, 0, 0, 0, 1064, 2345, 2535, 1063, 3009, 545, 4008, 2422, 544, 3617, 207 | 3585, 2260, 4032, 2283, 2536, 2241, 3027, 3329, 0, 548, 1572, 596, 37, 545, 4032, 3616, 1576, 549, 3880, 3046, 208 | 4040, 2345, 545, 3880, 3046, 3028, 3408, 3805, 3761, 3758, 3712, 0, 3776, 547, 3617, 1571, 546, 3616, 3864, 3649, 209 | 1570, 545, 3616, 3864, 3649, 1569, 3051, 0, 552, 4040, 2345, 3067, 0, 3880, 2944, 1708, 1707, 687, 1709, 3648, 210 | 684, 3592, 1708, 683, 3856, 2704, 3648, 686, 3592, 1707, 1197, 2696, 684, 3592, 1709, 896, 3617, 682, 1708, 685, 211 | 3648, 940, 1964, 1196, 3588, 683, 940, 1964, 3856, 2944, 1196, 1452, 2944, 2726, 3650, 0, 0, 0, 0, 4084, 212 | 4073, 0, 1664, 1708, 688, 1709, 3848, 2391, 3648, 546, 550, 1710, 3588, 549, 545, 3856, 2756, 1573, 686, 1574, 213 | 3712, 684, 3588, 1708, 640, 3588, 1664, 1197, 2743, 684, 1574, 640, 1573, 2993, 3588, 1757, 1197, 2743, 733, 1573, 214 | 640, 1574, 684, 1575, 2993, 0, 2557, 2294, 549, 3880, 551, 3880, 550, 4008, 2803, 549, 3652, 4040, 2800, 2391, 215 | 3680, 548, 1572, 2791, 2558, 2294, 3037, 1572, 3037, 3567, 0, 549, 3912, 3617, 4040, 2549, 3062, 2937, 3707, 0, 216 | 2311, 3260, 0, 549, 4040, 2422, 548, 3912, 3600, 3592, 1720, 3864, 1208, 3584, 695, 1721, 1722, 1723, 701, 3880, 217 | 702, 4008, 2741, 2311, 188, 1720, 696, 0, 3744, 548, 1572, 548, 3617, 696, 4000, 2737, 549, 3617, 697, 4000, 218 | 2737, 550, 3617, 698, 3904, 3617, 3585, 4032, 2910, 2311, 3256, 0, 2711, 1572, 2910, 1549, 0, 0, 0, 0, 219 | 0, 0, 0, 3907, 0, 0, 0, 603, 2263, 560, 2263, 537, 2263, 541, 2263, 2766, 2405, 2409, 566, 590, 220 | 4000, 2764, 526, 4000, 2770, 3074, 2884, 0, 1562, 538, 3590, 3590, 2280, 2415, 3588, 2280, 3594, 3592, 2280, 2280, 221 | 3712, 575, 2409, 3031, 0, 238, 587, 2409, 538, 3048, 7, 0 222 | }; 223 | 224 | 225 | 226 | Word mask(Word w) { return w & 07777; } 227 | Word lmask(Word w) { return w & 017777; } 228 | 229 | Word opAddr (int ir) { 230 | Word a = ir & 0177; 231 | if (ir & 0200) 232 | a |= (pc - 1) & 07600; 233 | if (ir & 0400) { 234 | if ((a & 07770) == 010) 235 | mem[a] = mask(mem[a] + 1); 236 | a = mem[a]; 237 | } 238 | return a; 239 | } 240 | 241 | // This I simply turned into a memory dump, so if anything was 242 | // programmed in FOCAL, it should be retained here and could be 243 | // pasted later on at the top. - Nino 244 | void cleanup () { 245 | SRL.println(); 246 | SRL.println(); 247 | int cntr; 248 | int cont; 249 | int decer = 0; 250 | for (cntr = 0; cntr < MEMSIZE; cntr++) { 251 | cont = mem[cntr]; 252 | SRL.print(cont); 253 | SRL.print(", "); 254 | decer++; 255 | if (decer == 12) { 256 | SRL.print("\r\n"); 257 | decer = 0; 258 | } 259 | 260 | } 261 | SRL.println(); 262 | SRL.println(); 263 | 264 | } 265 | 266 | void setup() { 267 | 268 | 269 | 270 | // start serial port at 300 bps 271 | SRL.begin(1200); 272 | 273 | pc = 0200; 274 | 275 | Word sr = 0; 276 | 277 | Word ac = 0, mq = 0; 278 | int iena = 0; 279 | for (;;) { 280 | iena >>= 1; // implements delayed enabling, relies on sign extension 281 | 282 | static char counter; // HACK: every 256 ops, fake interrupt (changed short to char) 283 | if ((iena & 1) && ++counter == 0) { 284 | mem[0] = pc; 285 | pc = 1; 286 | iena = 0; 287 | } 288 | 289 | int ir = mem[pc]; 290 | 291 | pc = mask(pc + 1); 292 | switch ((ir >> 9) & 07) { 293 | 294 | case 0: // AND 295 | ac &= mem[opAddr(ir)] | 010000; 296 | break; 297 | 298 | case 1: // TAD 299 | ac = lmask(ac + mem[opAddr(ir)]); 300 | break; 301 | 302 | case 2: { // ISZ 303 | Word t = opAddr(ir); 304 | mem[t] = mask(mem[t] + 1); 305 | if (mem[t] == 0) 306 | pc = mask(pc + 1); 307 | break; 308 | } 309 | 310 | case 3: // DCA 311 | mem[opAddr(ir)] = mask(ac); 312 | ac &= 010000; 313 | break; 314 | 315 | case 4: { // JMS 316 | Word t = opAddr(ir); 317 | mem[t] = pc; 318 | pc = mask(t + 1); 319 | break; 320 | } 321 | 322 | case 5: // JMP 323 | pc = opAddr(ir); 324 | break; 325 | 326 | case 6: // IOT 327 | switch ((ir >> 3) & 077) { 328 | case 00: 329 | switch (ir) { 330 | case 06001: iena = ~1; break; // delays one cycle 331 | case 06002: iena = 0; break; 332 | default: { // SRL.print("IOT "); SRL.print(ir, OCT); SRL.print(" AC="); SRL.println(ac, OCT); 333 | } 334 | } 335 | break; 336 | case 03: // keyboard 337 | if ((ir & 01) && SRL.available()) { 338 | pc = mask(pc + 1);} 339 | if (ir & 04) { // read byte 340 | int b = SRL.read(); 341 | if (b == 0x1C) { // exit program on ctrl-backslash 342 | SRL.print("\r\nQUIT\r\n"); 343 | cleanup(); 344 | 345 | // return 4; 346 | if (ir & 01) // skip if ready 347 | pc = mask(pc + 1); 348 | if (ir & 04) { // send byte 349 | SRL.write(ac & 0177); // strip off parity 350 | // fflush(stdout); 351 | } 352 | if (ir & 02) // clear flag 353 | ac &= 010000; 354 | 355 | } 356 | ac = (ac & 010000) | b; 357 | } 358 | break; 359 | case 04: // teleprinter 360 | if (ir & 01) // skip if ready 361 | pc = mask(pc + 1); 362 | if (ir & 04) { // send byte 363 | SRL.write(ac & 0177); // strip off parity 364 | // fflush(stdout); 365 | } 366 | if (ir & 02) // clear flag 367 | ac &= 010000; 368 | break; 369 | default: 370 | { // SRL.print("IOT "); SRL.print(ir, OCT); SRL.print(" AC="); SRL.println(ac, OCT); 371 | } 372 | break; 373 | } 374 | break; 375 | 376 | case 7: // OPR 377 | if ((ir & 0400) == 0) { // group 1 378 | if (ir & 0200) // CLA 379 | ac &= 010000; 380 | if (ir & 0100) // CLL 381 | ac &= 07777; 382 | if (ir & 040) // CMA 383 | ac ^= 07777; 384 | if (ir & 020) // CML 385 | ac ^= 010000; 386 | if (ir & 01) // IAC 387 | ac = lmask(ac + 1); 388 | switch (ir & 016) { 389 | case 012: // RTR 390 | ac = lmask((ac >> 1) | (ac << 12)); // fall through 391 | case 010: // RAR 392 | ac = lmask((ac >> 1) | (ac << 12)); 393 | break; 394 | case 06: // RTL 395 | ac = lmask((ac >> 12) | (ac << 1)); // fall through 396 | case 04: // RAL 397 | ac = lmask((ac >> 12) | (ac << 1)); 398 | break; 399 | case 02: // BSW 400 | ac = (ac & 010000) | ((ac >> 6) & 077) 401 | | ((ac << 6) & 07700); 402 | break; 403 | } 404 | } else if ((ir & 01) == 0) { // group 2 405 | // SMA, SPA, SZA, SNA, SNL, SZL 406 | int s = ((ir & 0100) && (ac & 04000)) || 407 | ((ir & 040) && (ac & 07777) == 0) || 408 | ((ir & 020) && (ac & 010000) != 0) ? 0 : 010; 409 | if (s == (ir & 010)) 410 | pc = mask(pc + 1); 411 | if (ir & 0200) // CLA 412 | ac &= 010000; 413 | if (ir & 04) // OSR 414 | ac |= sr; 415 | if (ir & 02) { // HLT 416 | SRL.print("\r\nHALT "); SRL.println(mask(ac), OCT); 417 | // return 0; 418 | } 419 | } else { // group 3 420 | Word t = mq; 421 | if (ir & 0200) // CLA 422 | ac &= 010000; 423 | if (ir & 020) { // MQL 424 | mq = ac & 07777; 425 | ac &= 010000; 426 | } 427 | if (ir & 0100) 428 | ac |= t; 429 | } 430 | break; 431 | } 432 | } 433 | 434 | 435 | } 436 | 437 | void loop() {} 438 | -------------------------------------------------------------------------------- /focal69MEGA_TOPSEQ_EEPROM.ino: -------------------------------------------------------------------------------- 1 | // INTERRUPT NOW FAKED EVERY 256 OPS, WAY MORE RESPONSIVE 2 | 3 | #define MEMSIZE 3952 4 | 5 | #define SRL Serial3 6 | 7 | // EEPROM SIZE: 4096 bytes = 2048 words 8 | // Cannot dump all memory - would need 8192, have 4096. 9 | // Use half - maybe we can store up to THREE files later on. 10 | // So far, we shall save only the code-populated userspace 11 | // locations in FOCAL-69, given by LOCATIONS, and according 12 | // to the manual (3200-5377)OCT = (1664-2815)DEC or 13 | // 1660 to 2820 to remember it easier. 14 | 15 | #define Word unsigned int 16 | 17 | #include 18 | const int STARTING_EEPROM_ADDRESS = 0; 19 | 20 | 21 | Word pc; 22 | 23 | // As of this writing, this whole thing is a quick-and-dirty port of this amazing 256-LOC 24 | // PDP-8 / 4K emulator: https://git.jeelabs.org/jcw/embello/src/branch/master/explore/1638-pdp8 25 | // It was written for PC, and I ported it to Arduino - it definitely runs on DUE. 26 | // Beware that the Arduino IDE builtin Serial monitor will not work (will not terminate lines 27 | // correctly), so use some actual terminal emulator - I am using picocom. - To do all this, 28 | // I ran jcw's original program, with the modification that I let it dump its memory right 29 | // after it loaded FOCAL 69. Then, I removed all loading routines and simply placed the 30 | // dump below into the mem-array, to let the machine have FOCAL 69 in memory a priori. 31 | // I have not tested it, but it should be possible, if you program anything, to replace 32 | // this dump with a new FOCAL 69 dump, containing your program. Hence, I modified the 33 | // cleanup-function so that it simply presents such a dump once you press Ctrl-\ - enjoy! 34 | // For instance, you can try this: FOR X=-10,1,10;TYPE X,! 35 | // - Nino, 21st May 2020 36 | Word mem[] = { 37 | 38 | 1464,2819,2819,1411,4,11,64,3328,1632,2404,63,1680,38,1050, 39 | 0,2404,0,4045,1287,2403,0,2403,0,1632,2040,2413,4094,0,0, 40 | 2815,0,0,1048,0,0,6,0,0,0,6,0,3459,1028,3540,4080,0,0,0, 41 | 2413,832,0,1470,1462,2048,141,798,5,141,140,135,131,223, 42 | 138,141,1,4032,174,4033,3968,4080,127,15,191,4094,3903,176, 43 | 3936,3922,3955,4093,4091,4087,63,128,2048,1048,1133,3021, 44 | 3072,3200,1632,1670,1632,1679,1039,1287,337,885,319,348, 45 | 364,1212,1346,716,465,1333,1133,1301,194,1186,1264,267,847, 46 | 859,1053,484,448,1074,1494,0,0,0,0,0,0,0,1505,3976,2942, 47 | 607,1554,3585,1600,1558,662,1547,661,2409,602,1544,1586, 48 | 602,1559,2410,2407,59,316,2406,2703,170,1680,2406,2406,602, 49 | 1551,1552,2405,541,1547,2416,2417,2802,2745,1046,2412,596, 50 | 565,4000,2422,560,1544,1586,567,1800,2416,3848,2405,2406, 51 | 566,590,4000,2736,2421,2414,2687,2400,393,786,3880,2687, 52 | 1554,530,3585,2714,165,2416,566,586,4008,2770,1566,2553, 53 | 551,250,550,4000,2422,551,2415,3588,1591,2417,2405,2417, 54 | 2784,2794,556,3654,556,3588,567,1591,2405,2417,2422,2794, 55 | 556,567,1591,2405,2417,2784,3848,2422,3648,567,68,4000, 56 | 3600,567,70,3888,2422,4000,763,3600,3588,1589,3010,2944, 57 | 4064,1024,1036,1032,624,610,875,739,1493,1493,1493,1493, 58 | 1493,3840,1493,1493,1493,1392,3654,3590,3590,2955,2412,530, 59 | 2402,2403,15,2403,53,565,4040,2739,2413,3584,531,1545,777, 60 | 2419,2422,2400,390,2404,53,786,3880,2745,3585,1560,565,4064, 61 | 2736,792,2419,2745,792,1591,2709,2413,2422,2400,392,2404, 62 | 53,2404,15,779,1554,3006,393,403,1593,3616,2248,569,1803, 63 | 3616,2248,3007,347,523,1547,523,3681,537,3992,2422,3016, 64 | 2428,977,1593,3616,2248,721,3585,1803,3616,2248,2873,988, 65 | 3744,988,1545,1244,591,2248,591,1593,777,1803,1081,2789, 66 | 591,2248,3036,315,3744,1004,1260,1545,591,1593,779,1801, 67 | 1081,2803,3052,1504,138,143,151,573,607,1493,565,392,396, 68 | 3898,2412,2413,2422,531,1554,2405,566,590,4008,2913,2408, 69 | 766,2696,566,61,2402,2405,2408,766,3848,2707,779,2407,507, 70 | 119,2422,2412,1046,2413,2743,567,4000,2411,2405,2409,566, 71 | 590,4000,2724,787,3880,2745,3585,1560,565,4032,792,2419, 72 | 2747,792,1591,2719,531,2731,1558,2913,565,4072,2745,2409, 73 | 2740,915,2416,2408,1015,3008,566,1216,642,4008,2767,2417, 74 | 3008,3848,3008,1216,1216,3008,1139,977,1546,778,3912,2784, 75 | 3617,566,4000,2772,977,3616,522,1580,3848,1233,1233,3776, 76 | 3025,289,68,3617,1593,567,68,569,4008,1252,3044,2982,542, 77 | 4000,2804,2405,3054,2410,2407,3582,1794,3054,541,392,396, 78 | 211,198,201,196,199,195,193,212,204,197,215,205,209,210, 79 | 138,2420,2463,1035,2464,585,1562,549,3912,1050,4072,1050, 80 | 3848,3063,2407,767,3833,2405,2712,2405,2709,897,1063,2400, 81 | 771,2416,566,733,3872,2422,536,2402,2400,906,779,1560,2311, 82 | 3352,0,2407,767,3711,2422,536,2402,2400,906,2407,767,3708, 83 | 2422,2403,1048,2400,906,2403,1048,2403,15,2400,392,2404, 84 | 15,2404,1048,2404,3896,779,1560,2311,280,987,3352,1365,0, 85 | 549,4064,2913,536,2402,2403,3896,2753,3907,3924,2403,1285, 86 | 2753,2347,2402,566,734,4000,2422,2400,906,2347,3123,3712, 87 | 779,3119,3848,2347,3712,2910,545,545,523,272,387,396,642, 88 | 643,3907,1156,413,686,127,883,3313,3744,1582,1558,2407,761, 89 | 126,1070,2710,2400,771,566,2402,685,2409,1054,3585,2393, 90 | 779,1590,2690,2400,907,2392,2691,1046,2405,2407,771,507, 91 | 2409,2715,2405,2412,567,1578,2692,575,2355,3616,575,2409, 92 | 2405,2692,186,2412,2413,2422,560,1544,1586,567,1800,520, 93 | 1559,2356,1600,1046,2405,2409,2407,62,697,2406,2747,560, 94 | 3585,1544,1586,2410,2407,57,697,2406,2758,146,3880,566, 95 | 3617,1593,972,1228,1546,778,3912,2784,569,4000,2772,522, 96 | 972,1593,825,1593,2873,1228,3776,3020,2347,3584,3325,3290, 97 | 2790,3314,1574,3073,2910,0,3110,3094,3105,2799,3712,3052, 98 | 699,696,1504,706,697,177,714,165,162,161,163,164,160,172, 99 | 187,141,2420,162,141,2422,1586,2406,2405,2408,1015,2710, 100 | 566,82,561,1585,2405,2408,1015,2710,2705,2418,2719,561, 101 | 1582,2480,779,1585,2479,2347,1743,560,1560,536,3617,537, 102 | 4072,2737,792,3617,561,4008,2757,536,568,2721,1063,897,537, 103 | 517,3681,523,3984,2422,537,568,1561,561,1816,1048,719,1816, 104 | 1048,2311,351,3352,0,2913,536,1545,777,3617,719,4000,2732, 105 | 1048,1048,2913,175,566,588,4000,3023,2405,2768,3920,3911, 106 | 0,1024,0,232,566,589,4000,1243,566,726,1580,556,4040,3035, 107 | 566,727,4072,1243,3035,2311,728,2280,3288,0,1752,1572,2910, 108 | 607,1554,779,1593,2873,673,666,681,678,1578,683,683,392,396, 109 | 525,556,2402,557,2402,558,2402,641,2402,2405,1581,2420,2711, 110 | 2778,2787,2400,775,2420,2724,138,255,2422,607,1560,585,556, 111 | 3880,2727,3585,4008,2771,556,593,4040,2803,2418,3848,2422, 112 | 556,1556,532,593,4032,1556,532,3617,557,4040,2760,557,3658, 113 | 3594,729,1724,557,4000,2404,36,2311,280,3413,0,597,1560, 114 | 532,557,4008,2913,779,1581,2733,2418,3848,2805,557,2402, 115 | 536,1744,2403,2044,532,1581,2405,2420,2803,2778,2787,2704, 116 | 280,2403,36,597,1560,1566,2393,2404,36,2706,1582,2405,2408, 117 | 1015,2796,558,3652,566,2787,2418,2422,2177,779,2407,1140, 118 | 3207,2418,2422,2177,1035,2910,160,171,173,175,170,222,168, 119 | 219,188,169,221,190,172,187,141,189,2403,1285,2404,36,665, 120 | 4040,2345,2311,3584,3224,0,597,1560,2215,2967,914,1,1024,0, 121 | 0,3,933,556,593,4032,2973,556,592,4064,1181,2973,527,779, 122 | 1581,668,779,3617,556,4000,2422,2405,2983,183,3074,2413, 123 | 2994,1046,2405,566,590,4000,2743,527,3616,531,1583,603,3617, 124 | 531,4008,2687,3584,787,1813,603,1593,825,3880,2775,1562, 125 | 531,3681,538,3992,559,538,1849,538,2761,3616,531,1545,559, 126 | 3616,531,1546,559,560,1584,520,3616,522,1562,520,559,1544, 127 | 778,1801,1050,2792,2739,144,2356,1590,2408,915,3053,2409, 128 | 3053,1371,1448,1438,1397,1432,1359,1402,1428,1429,1452, 129 | 1405,1474,1433,1399,216,2420,2719,2706,2699,566,586,3872, 130 | 2422,605,1584,1883,560,1561,2687,2412,560,1544,2421,1043, 131 | 565,4032,787,2419,2703,787,1591,2709,560,1561,2913,1077, 132 | 603,1557,603,1555,531,1545,567,3681,777,3880,2742,3992, 133 | 2743,531,1557,787,3872,2726,3848,1186,531,3585,1551,1552, 134 | 2978,177,2264,4040,518,751,566,3880,2766,573,1590,534,576, 135 | 4008,2409,3004,2264,3616,2750,534,4000,2774,576,4008,3585, 136 | 1600,2749,584,2757,1228,1040,2789,529,82,1590,566,579,4008, 137 | 2763,566,750,3032,783,1553,3616,1552,529,3658,3594,3594, 138 | 2780,4064,4001,184,3584,789,1840,560,1813,561,3872,1800, 139 | 520,3585,1584,560,1561,3056,683,396,3202,495,495,3240,1, 140 | 1024,0,0,0,0,4086,0,3097,2701,3102,70,3880,2701,595,2956, 141 | 0,567,2415,82,2210,578,2409,567,2210,750,1590,2409,2965,0, 142 | 70,1562,587,1563,2730,1051,1562,538,651,3904,2728,3712,539, 143 | 2409,538,587,2409,2978,138,3880,566,590,3880,2750,575,2355, 144 | 2997,575,2355,574,2748,178,584,3617,566,3880,746,577,3880, 145 | 3053,747,1593,569,236,750,3872,748,4008,2778,569,82,3872, 146 | 2269,3584,3010,594,2269,2772,1368,1074,2799,561,1800,1585, 147 | 523,3681,517,520,3984,3037,2422,32,255,96,1540,4000,2415, 148 | 1585,3616,1586,3037,0,0,0,0,0,0,0,0,0,0,0,0,0,2048,3965, 149 | 1664,3592,1665,3105,2709,3106,1550,949,3880,2709,3108,1550, 150 | 1973,693,3585,71,691,1717,3097,2726,3102,70,3880,2726,595, 151 | 1714,690,642,4008,2784,540,4000,2422,690,1564,3081,2730, 152 | 3082,1567,3236,3137,3584,641,3652,640,3073,2816,141,1616, 153 | 1617,1617,1135,540,3944,2743,1726,1564,702,2998,1341,1718, 154 | 3073,948,4000,2753,3074,526,4000,2764,694,3110,1550,2771, 155 | 694,1972,692,3585,71,691,1716,3073,3006,1750,0,3744,726, 156 | 1591,3073,526,4000,2779,3074,2786,595,1591,1038,581,1583, 157 | 3616,691,1544,3584,1800,1071,2793,1564,691,1717,691,1716, 158 | 3616,3110,577,2409,2411,1042,786,3880,2815,1591,577,2409, 159 | 2409,2411,575,2409,598,1642,2687,562,4000,2700,520,3617, 160 | 535,4032,2977,681,2409,520,1593,3584,1074,2722,825,82,579, 161 | 4000,2719,3616,1586,3616,520,1544,825,65,1585,2977,1368, 162 | 825,65,518,4000,2712,1849,2713,220,560,1560,537,3617,536, 163 | 4008,2913,792,1742,717,1551,1552,2405,2409,2405,2409,2405, 164 | 2409,1048,792,2508,2405,2409,1048,2311,280,0,2392,575,2409, 165 | 568,585,536,2731,1314,1613,0,2601,0,0,0,0,0,0,0,0,0,0,0,0, 166 | 0,0,0,0,0,3502,3312,2065,4045,4045,3519,895,2994,3436,3502, 167 | 3312,2870,2995,3135,895,2600,1576,617,3057,3113,2665,2668, 168 | 2175,895,2687,895,895,895,895,4045,4045,0,0,0,0,0,0,1679, 169 | 0,237,399,193,812,3193,3513,4045,1685,271,1248,637,3504, 170 | 4045,1699,276,608,2569,2929,2674,2998,3436,3246,3509,2866, 171 | 2994,3455,832,1709,281,1248,1576,617,3928,2569,2929,2687, 172 | 832,1716,311,1248,637,621,3199,832,1722,316,480,3246,3248, 173 | 4045,1752,321,1248,1576,3177,3944,1194,3184,3120,3120,2667, 174 | 2579,2737,3120,3120,2667,2580,2737,3120,3113,2792,1386,3184, 175 | 3113,2792,1450,3184,2667,1535,832,1766,341,83,736,2185,950, 176 | 1570,2834,2835,2836,2837,2838,2839,4045,1779,389,608,2578, 177 | 2675,2993,3116,3502,3125,2867,2993,3135,832,1785,394,1248, 178 | 893,3135,832,1798,399,608,2578,2675,2994,3116,3310,3248, 179 | 2867,2996,3135,832,1804,404,1248,893,3199,832,1810,409, 180 | 1248,1213,2898,4045,1816,414,1248,957,1215,832,1822,419, 181 | 480,3438,3125,4045,1835,424,608,2579,2675,2996,3436,3310, 182 | 3381,2867,2998,3455,832,1841,429,1248,893,3263,832,1847, 183 | 434,1248,1277,2899,4045,1853,439,1248,957,1279,832,1859, 184 | 444,480,3438,3125,4045,1872,449,608,2580,2675,2999,3116, 185 | 3310,3568,2868,2992,3455,832,1878,454,1248,893,3327,832, 186 | 1884,459,1248,1341,2900,4045,1890,464,1248,957,1343,832, 187 | 1896,469,480,3438,3125,4045,1909,517,608,2581,2676,2993, 188 | 3116,3374,3184,2868,2995,3135,832,1915,522,1248,893,3391, 189 | 832,1921,527,1248,1405,2901,4045,1927,532,1248,957,1407, 190 | 832,1933,537,480,3438,3125,4045,1946,542,608,2582,2676, 191 | 2995,3436,3374,3317,2868,2997,3455,832,1952,547,1248,893, 192 | 3455,832,1958,552,1248,1469,2902,4045,1964,557,1248,957, 193 | 1471,832,1970,562,480,3438,3125,4045,1983,567,608,2583, 194 | 2676,2998,3116,3374,3504,2866,2993,3455,832,1989,572,1248, 195 | 893,3519,832,1995,577,1248,1533,2903,4045,2001,582,1248, 196 | 957,1535,832,2014,587,608,2574,2677,2992,3436,3246,3189, 197 | 2869,2992,3455,832,2020,645,1248,637,3199,832,2034,650,608, 198 | 2569,2934,3113,3438,3189,2869,2995,3692,3438,3321,4045, 199 | 2056,655,608,2574,2886,596,1192,1576,617,3057,3120,3120, 200 | 3113,2677,2995,3564,3438,3248,2869,2995,3583,832,2073,660, 201 | 608,2566,596,1192,1576,617,2665,3438,3249,2869,2995,3564, 202 | 3438,3249,4045,2089,661,1312,2417,2088,393,1298,2600,1576, 203 | 617,3057,3120,3120,3113,2665,4045,2117,662,1312,2417,2088, 204 | 393,1298,2600,1576,617,3057,3120,3120,2665,2920,3184,2694, 205 | 596,1192,2584,2569,2671,3184,3120,3120,2665,2665,4045,2144, 206 | 663,1312,2417,2088,393,1298,2600,1576,617,3057,3120,3113, 207 | 2669,2609,3114,393,1298,2600,1576,617,3057,3120,3120,2665, 208 | 2665,4045,2170,664,1312,2417,2088,393,1298,2600,1576,617, 209 | 3057,3120,2665,2920,3184,2694,596,1192,2584,2569,2671,3184, 210 | 3120,2665,2665,4045,2195,665,1312,2417,2088,393,1298,2600, 211 | 1576,617,3057,3113,2669,2609,3114,393,1298,2600,1576,617, 212 | 3057,3120,2665,2665,4045,2218,666,1312,2417,2088,393,1298, 213 | 2584,2569,2665,2920,3184,2694,596,1192,2584,2569,2671,3184, 214 | 2665,2665,2849,4045,2225,677,1248,637,619,3199,832,2231,678, 215 | 480,3438,3184,4045,2237,679,1248,957,3135,832,2251,680,608, 216 | 2573,2929,2677,2996,3436,3310,3376,2869,2996,3455,832,2265, 217 | 685,608,2573,2930,2677,2997,3116,3310,3509,2869,2997,3135, 218 | 832,2279,690,608,2573,2931,2677,2997,3436,3374,3125,2869, 219 | 2997,3455,832,2293,695,608,2573,2932,2677,2998,3116,3374, 220 | 3312,2869,2998,3135,832,2307,700,608,2573,2933,2677,2998, 221 | 3436,3374,3445,2869,2998,3455,832,2313,705,480,3246,3189, 222 | 4045,2319,773,1248,637,3199,832,2331,774,1312,2422,2992, 223 | 3104,620,2234,2220,1576,617,4045,2341,775,1312,2422,2992, 224 | 3104,1576,619,3177,4045,2351,776,1312,2422,2992,3104,1576, 225 | 619,3241,4045,2361,777,1312,2422,2992,3104,1576,619,3305, 226 | 4045,2371,778,1312,2422,2992,3104,1576,619,3369,4045,2382, 227 | 779,1312,2422,2992,3104,1576,619,3433,2849,4045,2389,782, 228 | 1248,637,619,3519,832,2403,783,608,2569,2934,3113,3502,3253, 229 | 2870,2995,3116,3502,3312,4045,2409,793,480,3502,3126,4045, 230 | 0,798,1151,832,1493,368,2447,1542,1457,1028,3282,1452,7,2, 231 | 2050,2354,2401,1585,2400,799,1048,792,3065,0,0,0,0,0,0,0,0, 232 | 0,0,0,0,0,0,0,0,549,4040,2516,1563,2311,2251,3517,0,2347, 233 | 1749,2311,3584,3518,445,1470,3517,2493,3518,712,3286,197, 234 | 1750,1469,703,3286,194,2494,726,3286,445,1750,2257,718,0, 235 | 725,548,1572,1051,2910,2311,3517,206,1981,0,2910,2770,2774, 236 | 4,1274,770,4092,1135,2671,10,2860,227,7,1398,2785,1,1477, 237 | 1309,1,1024,0,2,1024,0,2675,0,0,0,0,0,2311,445,2493,3518, 238 | 2300,761,2494,758,3286,243,2494,752,2494,749,2493,1750,0, 239 | 3052,2580,0,1311,931,4095,1732,2332,4091,1734,2860,0,1311, 240 | 934,0,1303,1235,4093,1815,3626,0,549,4040,2291,1563,2311, 241 | 3485,1439,0,549,4040,2705,2311,415,1949,3485,0,3744,1778, 242 | 2963,2522,1266,2972,2311,3485,414,1437,0,2972,2754,2770, 243 | 2766,2510,549,3880,2422,4040,2345,2311,3566,1439,0,549, 244 | 3880,2910,4032,2740,2311,415,2030,3566,0,3744,1563,517, 245 | 1572,3616,1006,1573,1574,1575,3585,2030,2311,2287,3485, 246 | 494,1439,3566,2283,744,2542,741,2542,738,2542,735,2542, 247 | 732,2542,729,2542,726,2542,925,0,2972,0,2047,4066,4095, 248 | 2048,2112,4095,1359,199,4094,2123,3721,4094,1373,1729,4093, 249 | 2534,505,4092,1182,2244,4089,2404,989,2518,0,1419,2316,0, 250 | 0,2345,3744,3059,0,0,0,0,0,0,0,0,0,2311,3282,206,1234,0, 251 | 549,4064,2701,549,4032,2910,2345,3616,1563,2311,1734,3286, 252 | 0,2347,2311,3584,3282,214,1234,2246,3282,1226,0,549,4040, 253 | 2725,2311,3282,0,539,3616,1563,2311,210,1230,0,549,4040, 254 | 2737,2311,202,1234,3282,0,2311,210,1742,3282,2258,3286,218, 255 | 2262,734,2262,738,2262,742,2262,718,2258,0,1051,2910,2345, 256 | 2910,3,1608,2030,1693,2,1608,2030,1693,1,1608,2030,1693,0, 257 | 0,0,0,0,0,0,0,4084,1281,3597,546,4089,2868,2892,3176,4093, 258 | 1305,2801,2526,0,2773,268,1655,0,0,0,0,0,0,0,0,0,0,0,0,0, 259 | 0,0,0,0,0,0,0,0,0,0,1756,554,2415,82,1562,538,3617,3880, 260 | 726,1757,554,3880,2721,82,1755,733,731,3912,2712,3744,538, 261 | 1755,3616,539,3904,3712,538,3912,2739,726,3904,3712,727, 262 | 1593,985,569,1758,569,3617,1593,725,1502,990,728,4040,2741, 263 | 2014,1081,2769,1502,1051,3712,554,4008,2798,733,539,3936, 264 | 2797,731,3904,3712,3617,539,3617,1562,539,538,4008,2787, 265 | 538,3585,4040,581,2270,1050,2755,578,2409,2755,3616,734, 266 | 1758,2730,5,4090,7,4086,3176,3180,0,0,0,0,2522,1245,3038, 267 | 2944,3616,539,1563,1244,2795,3616,1756,2763,780,2763,3712, 268 | 2522,578,2409,1152,780,2270,1244,2802,3616,1756,2803,3807, 269 | 549,1576,549,4040,2345,3065,202,1574,1572,1573,1575,1740, 270 | 1576,566,692,3880,2704,585,4000,2705,3616,1576,2486,566, 271 | 693,4008,2704,2199,2944,2966,566,690,4008,2967,2417,2967, 272 | 2727,556,1739,2231,1228,4000,2422,2486,2712,566,586,4040, 273 | 2967,566,691,4064,2967,566,82,2720,3899,3878,3925,3936,494, 274 | 2978,551,1571,550,1570,549,1569,1738,2253,2253,2267,2253, 275 | 715,1571,1570,1569,2267,714,2999,0,6,1,3011,551,3652,1575, 276 | 550,3588,1574,549,3588,1573,714,3588,1738,3021,3016,3776, 277 | 551,547,1575,3588,550,546,1574,3588,549,545,1573,3588,714, 278 | 1738,3035,3402,3776,545,3912,3664,3592,1569,546,3592,1570, 279 | 547,3592,1571,1056,3052,3052,0,0,0,0,0,733,2409,549,4032, 280 | 732,734,2409,2539,1563,548,3912,2711,3872,737,4072,2716, 281 | 2311,2532,0,3585,539,2697,2311,2538,0,3616,2709,2021,2022, 282 | 744,1548,548,3680,1772,739,1572,2391,1260,2725,998,3880, 283 | 2744,738,4040,2740,3585,1804,1060,738,1051,3584,998,1051, 284 | 3584,3848,2535,1804,1060,2744,744,1548,739,2537,2944,731, 285 | 2409,539,3912,3617,1573,539,4032,585,734,2409,549,1060,735, 286 | 3904,2765,736,1573,3616,548,3872,2284,549,2522,2944,1314, 287 | 197,4083,189,173,3996,100,4092,4086,4089,3261,3019,3018, 288 | 2999,3895,2816,3257,2937,0,587,2409,3052,0,0,0,0,0,0,0,0, 289 | 0,0,0,0,0,0,0,0,992,4000,2502,566,588,4008,2690,2498,566, 290 | 589,4000,2705,2502,1989,2499,965,3617,1563,712,1572,2500, 291 | 2503,2311,3352,0,566,705,4000,2726,2502,2498,2500,551,539, 292 | 1563,2311,280,0,539,3880,2944,4032,2737,2311,2237,3352,0, 293 | 3585,2742,2311,2233,3352,0,3616,539,1563,2726,4,1280,0,0, 294 | 4093,1638,1639,1640,3899,2944,2967,3707,3020,494,3805,35, 295 | 0,0,0,0,0,0,0,0,0,581,1763,543,4032,2804,1050,2772,1251, 296 | 2772,2275,523,766,3984,3042,1035,2913,138,0,765,3616,1789, 297 | 3680,1567,765,3872,3084,4000,767,598,1642,3043,2275,3059, 298 | 393,3616,1567,3086,70,3880,2770,595,1590,3025,0,2415,2148, 299 | 958,3776,1575,1571,896,3880,2944,1714,690,83,4008,2702, 300 | 580,128,1568,582,178,544,1568,691,178,4008,2713,800,1568, 301 | 1152,3616,544,1549,690,3654,3590,71,3880,2743,692,1714,946, 302 | 3880,2741,1714,708,1548,591,1583,781,1804,1071,2733,2994, 303 | 3457,256,3451,707,2747,707,1549,3616,544,1548,591,1583, 304 | 780,1805,1071,2750,2689,35,31,2549,2552,2689,2554,2553, 305 | 2555,2551,2689,549,4000,2773,1572,1573,1574,1575,2689, 306 | 2403,36,2403,32,2404,36,2347,3912,2786,3616,1714,1571, 307 | 549,4000,2422,2403,1285,2404,36,2404,3896,2800,2403,3896, 308 | 2404,32,2550,1202,2795,2689,2550,2689,3691,3588,3805,3475, 309 | 3052,3567,3035,3398,3397,3655,3443,3405,0,3403,4036,3776, 310 | 551,3617,1575,550,3616,3864,3649,1574,549,3616,3864,3649, 311 | 1573,2947,3400,549,3880,550,4008,2761,545,3880,546,3880, 312 | 547,4008,2963,544,3617,548,3880,2747,1667,643,3904,3617, 313 | 1746,722,734,4040,2749,643,4032,2741,2287,1234,2737,2747, 314 | 3616,544,1568,2515,1234,2744,1171,2963,544,4032,2756,548, 315 | 4032,2963,2758,548,4032,643,4064,2963,544,1572,545,1573, 316 | 546,1574,547,1575,2963,4036,3052,3420,2537,548,4072,2795, 317 | 3585,1571,744,1568,2195,23,1063,2788,1062,3848,1061,1575, 318 | 2538,550,3028,23,2937,3707,1572,1573,1574,2788,3401,3776, 319 | 549,3912,3600,3592,1573,550,3592,1574,551,3592,1575,1060, 320 | 3055,3055,223,255,138,253,4095,3444,3585,544,2260,4040, 321 | 2283,1729,1728,1727,1726,549,2025,545,2538,2,546,2538,3, 322 | 550,2025,545,2538,3,546,2538,4,2739,1724,547,2025,549,2538, 323 | 4,550,2538,5,551,2025,545,2538,4,546,2538,5,547,2538,6,705, 324 | 1573,704,1574,703,1575,2241,1575,2948,0,0,0,1280,2787,3642, 325 | 1064,2345,2535,1063,3009,545,4008,2422,544,3617,3585,2260, 326 | 4032,2283,2536,2241,3027,3329,3592,548,1572,596,37,545, 327 | 4032,3616,1576,549,3880,3046,4040,2345,545,3880,3046,3028, 328 | 3408,3805,3761,3758,3712,3398,3776,547,3617,1571,546,3616, 329 | 3864,3649,1570,545,3616,3864,3649,1569,3051,3825,552,4040, 330 | 2345,3067,3613,3880,2944,1708,1707,687,1709,3648,684,3592, 331 | 1708,683,3856,2704,3648,686,3592,1707,1197,2696,684,3592, 332 | 1709,896,3617,682,1708,685,3648,940,1964,1196,3588,683,940, 333 | 1964,3856,2944,1196,1452,2944,2726,3650,995,3648,1280,3185, 334 | 4084,4073,0,1664,1708,688,1709,3848,2391,3648,546,550,1710, 335 | 3588,549,545,3856,2756,1573,686,1574,3712,684,3588,1708,640, 336 | 3588,1664,1197,2743,684,1574,640,1573,2993,3588,1757,1197, 337 | 2743,733,1573,640,1574,684,1575,2993,3222,2557,2294,549, 338 | 3880,551,3880,550,4008,2803,549,3652,4040,2800,2391,3680, 339 | 548,1572,2791,2558,2294,3037,1572,3037,3567,3826,549,3912, 340 | 3617,4040,2549,3062,2937,3707,0,2311,3260,0,549,4040,2422, 341 | 548,3912,3600,3592,1720,3864,1208,3584,695,1721,1722,1723, 342 | 701,3880,702,4008,2741,2311,188,1720,696,0,3744,548,1572, 343 | 548,3617,696,4000,2737,549,3617,697,4000,2737,550,3617,698, 344 | 3904,3617,3585,4032,2910,2311,3256,0,2711,1572,2910,1549,2, 345 | 1024,0,0,0,0,0,3907,0,0,0,603,2263,560,2263,537,2263,541, 346 | 2263,2766,2405,2409,566,590,4000,2764,526,4000,2770,3074, 347 | 2884,0,1562,538,3590,3590,2280,2415,3588,2280,3594,3592, 348 | 2280,2280,3712,575,2409,3031,0,238,587,2409,538,3048,7,0 349 | 350 | }; 351 | 352 | Word mask(Word w) { return w & 07777; } 353 | Word lmask(Word w) { return w & 017777; } 354 | 355 | Word opAddr (int ir) { 356 | Word a = ir & 0177; 357 | if (ir & 0200) 358 | a |= (pc - 1) & 07600; 359 | if (ir & 0400) { 360 | if ((a & 07770) == 010) 361 | mem[a] = mask(mem[a] + 1); 362 | a = mem[a]; 363 | } 364 | return a; 365 | } 366 | 367 | // This I simply turned into a memory dump, so if anything was 368 | // programmed in FOCAL, it should be retained here and could be 369 | // pasted later on at the top. - Nino 370 | void cleanup () { 371 | SRL.println(); 372 | SRL.println(); 373 | int cntr; 374 | int decer = 0; 375 | for (cntr = 0; cntr < MEMSIZE; cntr++) { 376 | SRL.print(static_cast(mem[cntr])); 377 | SRL.print(", "); 378 | delay(300); 379 | decer++; 380 | if (decer == 12) { 381 | SRL.print("\r\n"); 382 | decer = 0; 383 | } 384 | } 385 | SRL.println(); 386 | SRL.println(); 387 | } 388 | 389 | void writeArrayIntoEEPROM(int address, Word numbers[]) 390 | { 391 | // 1660 to 2820 392 | int addressIndex = address; 393 | for (int i = 1660; i < 2820; i++) 394 | { 395 | EEPROM.write(addressIndex, numbers[i] >> 8); 396 | EEPROM.write(addressIndex + 1, numbers[i] & 0xFF); 397 | addressIndex += 2; 398 | } 399 | } 400 | 401 | void readArrayFromEEPROM(int address, Word numbers[]) 402 | { 403 | // 1660 to 2820 404 | 405 | int addressIndex = address; 406 | for (int i = 1660; i < 2820; i++) 407 | { 408 | numbers[i] = (EEPROM.read(addressIndex) << 8) + EEPROM.read(addressIndex + 1); 409 | addressIndex += 2; 410 | } 411 | } 412 | 413 | 414 | void setup() { 415 | 416 | // start serial port at 300 bps 417 | // SRL.begin(300, SERIAL_7E2); 418 | SRL.begin(300, SERIAL_8N1); 419 | 420 | int greeting = 1; 421 | 422 | if (greeting == 1) { 423 | greeting = 0; 424 | SRL.print(F("\r\n WELCOME TO THE TOPSEQ SYSTEM IN FOCAL-69 ON AN ARDUINO PDP-8.\r\n")); 425 | delay(990); 426 | SRL.print(F(" THIS COMPUTER HAS BEEN SET TO RUN THE TOPSEQ SEMANTIC NETWORK.\r\n")); 427 | delay(990); 428 | SRL.print(F(" TOPSEQ IS SHORT FOR TOPIC SEQUENCER INDICATING THE NATURE OF\r\n")); 429 | delay(990); 430 | SRL.print(F(" THE SYSTEM. EACH INPUT CONSISTS OF EXACTLY SIX ONE-DIGIT\r\n")); 431 | delay(990); 432 | SRL.print(F(" POSITIVE OR NEGATIVE DECIMAL NUMBERS 1-9, E.G:\r\n")); 433 | delay(990); 434 | SRL.print(F(" 1,2,3,4,5,6 RETURN. NOTE THAT 0 IS NOT USED AND MEANS NO TOPIC.\r\n")); 435 | delay(990); 436 | SRL.print(F(" THIS SETS A NEW SENTENCE INTO THE KNOWLEDGE BASE, AT ONCE\r\n")); 437 | delay(990); 438 | SRL.print(F(" FORGETTING THE OLDEST ONE. EACH NUMBER REPRESENTS A POSSIBLE\r\n")); 439 | delay(990); 440 | SRL.print(F(" TOPIC. THE TOPIC OF THE SENTENCE IS ALWAYS THE FIRST NUMBER\r\n")); 441 | delay(990); 442 | SRL.print(F(" GIVEN IN THE SENTENCE. IT CAN BE SEARCHED BY NOTING IT AS\r\n")); 443 | delay(990); 444 | SRL.print(F(" NEGATIVE DURING INPUT, AS 1,-2,-1,2,3,4 SEARCHES FOR SENTENCES\r\n")); 445 | delay(990); 446 | SRL.print(F(" BEGINNING WITH 2 AND 1 AND WILL INDEED FIND 1,2,3,4,5,6 AS IT\r\n")); 447 | delay(990); 448 | SRL.print(F(" BEGINS WITH 1. AT THE SAME TIME, THE SYSTEM WILL ALSO LEARN\r\n")); 449 | delay(990); 450 | SRL.print(F(" 1,2,1,2,3,4, I.E. ALL TOPICS ARE STORED AS POSITIVE NUMBERS.\r\n")); 451 | delay(990); 452 | SRL.print(F(" IF YOU WISH TO ONLY SEARCH FOR A TERM, TRY E.G.\r\n")); 453 | delay(990); 454 | SRL.print(F(" -1,0,0,0,0,0 RETURN. IF A TOPIC OF INTEREST HAS BEEN\r\n")); 455 | delay(990); 456 | SRL.print(F(" SPECIFIED BY MINUS, A REPLY WILL BE MADE. OTHERWISE, THE\r\n")); 457 | delay(990); 458 | SRL.print(F(" SYSTEM WILL ONLY LEARN THE SENTENCE. THE KNOWLEDGE CONSISTS.\r\n")); 459 | delay(990); 460 | SRL.print(F(" OUT OF 60 SENTENCES. IF ANY SENTENCE IS INPUT THAT BEGINS WITH\r\n")); 461 | delay(990); 462 | SRL.print(F(" ZERO, THE INTERACTION TERMINATES AND THE KNOWLEDGE BASE IS\r\n")); 463 | delay(990); 464 | SRL.print(F(" PRINTED OUT. YOU ARE THEN RETURNED TO FOCAL-69. ERASE ALL\r\n")); 465 | delay(990); 466 | SRL.print(F(" IN FOCAL REMOVES THE AI UNTIL RESTART. TYPE GO TO COMMENCE.\r\n")); 467 | delay(990); 468 | SRL.print(F(" ~ DUMPS, { SAVES AND } GETS MEMORY: PRESS THE KEY, THEN ENTER.\r\n")); 469 | } 470 | 471 | pc = 0200; 472 | 473 | Word sr = 0; 474 | 475 | Word ac = 0, mq = 0; 476 | int iena = 0; 477 | for (;;) { 478 | iena >>= 1; // implements delayed enabling, relies on sign extension 479 | 480 | static char counter; // HACK: every 256 ops, we fake an interrupt 481 | if ((iena & 1) && ++counter == 0) { 482 | mem[0] = pc; 483 | pc = 1; 484 | iena = 0; 485 | } 486 | 487 | int ir = mem[pc]; 488 | 489 | pc = mask(pc + 1); 490 | switch ((ir >> 9) & 07) { 491 | 492 | case 0: // AND 493 | ac &= mem[opAddr(ir)] | 010000; 494 | break; 495 | 496 | case 1: // TAD 497 | ac = lmask(ac + mem[opAddr(ir)]); 498 | break; 499 | 500 | case 2: { // ISZ 501 | Word t = opAddr(ir); 502 | mem[t] = mask(mem[t] + 1); 503 | if (mem[t] == 0) 504 | pc = mask(pc + 1); 505 | break; 506 | } 507 | 508 | case 3: // DCA 509 | mem[opAddr(ir)] = mask(ac); 510 | ac &= 010000; 511 | break; 512 | 513 | case 4: { // JMS 514 | Word t = opAddr(ir); 515 | mem[t] = pc; 516 | pc = mask(t + 1); 517 | break; 518 | } 519 | 520 | case 5: // JMP 521 | pc = opAddr(ir); 522 | break; 523 | 524 | case 6: // IOT 525 | switch ((ir >> 3) & 077) { 526 | case 00: 527 | switch (ir) { 528 | case 06001: iena = ~1; break; // delays one cycle 529 | case 06002: iena = 0; break; 530 | default: { // SRL.print("IOT "); SRL.print(ir, OCT); SRL.print(" AC="); SRL.println(ac, OCT); 531 | } 532 | } 533 | break; 534 | case 03: // keyboard 535 | if ((ir & 01) && SRL.available()) { 536 | pc = mask(pc + 1);} 537 | if (ir & 04) { // read byte 538 | int b = SRL.read(); 539 | if ((b > 96) && (b < 123)) {b = b - 32;} // turn letters to CAPITALS 540 | if (b == '~') { // cleanup on ctrl-backslash: (b == 0x1C) 541 | SRL.print(F("\r\nQUIT\r\n")); 542 | cleanup(); 543 | 544 | // return 4; 545 | if (ir & 01) // skip if ready 546 | pc = mask(pc + 1); 547 | if (ir & 04) { // send byte 548 | SRL.write(ac & 0177); // strip off parity 549 | // fflush(stdout); 550 | } 551 | if (ir & 02) // clear flag 552 | ac &= 010000; 553 | 554 | } 555 | 556 | if (b == '{') { 557 | b = ' '; 558 | SRL.print(F("\r\nSAVING MEMORY...\r\n")); 559 | writeArrayIntoEEPROM(STARTING_EEPROM_ADDRESS, mem); 560 | // for (int iii = 0; iii < MEMSIZE - 16; iii = iii + 1) { client.print(mem[iii]); client.print(","); } 561 | SRL.print(F("\r\nMEMORY SAVED.\r\n")); delay(250); 562 | } 563 | 564 | if (b == '}') { 565 | b = ' '; 566 | SRL.print(F("\r\nLOADING MEMORY...\r\n")); 567 | readArrayFromEEPROM(STARTING_EEPROM_ADDRESS, mem); 568 | // for (int iii = 0; iii < MEMSIZE - 16; iii = iii + 1) { client.print(mem[iii]); client.print(","); } 569 | SRL.print(F("\r\nMEMORY LOADED.\r\n")); delay(250); 570 | } 571 | 572 | ac = (ac & 010000) | b; 573 | } 574 | break; 575 | case 04: // teleprinter 576 | if (ir & 01) // skip if ready 577 | pc = mask(pc + 1); 578 | if (ir & 04) { // send byte 579 | SRL.write(ac & 0177); // strip off parity 580 | delay(60); if ((ac & 0177) == '\n') { delay(440); } 581 | // fflush(stdout); 582 | } 583 | if (ir & 02) // clear flag 584 | ac &= 010000; 585 | break; 586 | default: 587 | { // SRL.print("IOT "); SRL.print(ir, OCT); SRL.print(" AC="); SRL.println(ac, OCT); 588 | } 589 | break; 590 | } 591 | break; 592 | 593 | case 7: // OPR 594 | if ((ir & 0400) == 0) { // group 1 595 | if (ir & 0200) // CLA 596 | ac &= 010000; 597 | if (ir & 0100) // CLL 598 | ac &= 07777; 599 | if (ir & 040) // CMA 600 | ac ^= 07777; 601 | if (ir & 020) // CML 602 | ac ^= 010000; 603 | if (ir & 01) // IAC 604 | ac = lmask(ac + 1); 605 | switch (ir & 016) { 606 | case 012: // RTR 607 | ac = lmask((ac >> 1) | (ac << 12)); // fall through 608 | case 010: // RAR 609 | ac = lmask((ac >> 1) | (ac << 12)); 610 | break; 611 | case 06: // RTL 612 | ac = lmask((ac >> 12) | (ac << 1)); // fall through 613 | case 04: // RAL 614 | ac = lmask((ac >> 12) | (ac << 1)); 615 | break; 616 | case 02: // BSW 617 | ac = (ac & 010000) | ((ac >> 6) & 077) 618 | | ((ac << 6) & 07700); 619 | break; 620 | } 621 | } else if ((ir & 01) == 0) { // group 2 622 | // SMA, SPA, SZA, SNA, SNL, SZL 623 | int s = ((ir & 0100) && (ac & 04000)) || 624 | ((ir & 040) && (ac & 07777) == 0) || 625 | ((ir & 020) && (ac & 010000) != 0) ? 0 : 010; 626 | if (s == (ir & 010)) 627 | pc = mask(pc + 1); 628 | if (ir & 0200) // CLA 629 | ac &= 010000; 630 | if (ir & 04) // OSR 631 | ac |= sr; 632 | if (ir & 02) { // HLT 633 | SRL.print(F("\r\nHALT ")); SRL.println(mask(ac), OCT); 634 | // return 0; 635 | } 636 | } else { // group 3 637 | Word t = mq; 638 | if (ir & 0200) // CLA 639 | ac &= 010000; 640 | if (ir & 020) { // MQL 641 | mq = ac & 07777; 642 | ac &= 010000; 643 | } 644 | if (ir & 0100) 645 | ac |= t; 646 | } 647 | break; 648 | } 649 | } 650 | 651 | 652 | } 653 | 654 | void loop() {} 655 | -------------------------------------------------------------------------------- /focal69Wifi5.ino: -------------------------------------------------------------------------------- 1 | // telnet 192.168.4.1 8080 2 | // or 3 | // nc -C 192.168.4.1 8080 4 | 5 | #pragma GCC optimize ("-O3") 6 | #pragma GCC push_options 7 | 8 | #define MEMSIZE 4096 9 | #define EEPROM_SIZE 2048 10 | // This thing should allow 8192 for a full memory dump. 11 | // Because it does not, we shall save the userspace 12 | // locations in FOCAL-69, given by LOCATIONS, and according 13 | // to the manual (3200-5377)OCT = (1664-2815)DEC or 14 | // 1660 to 2820 to remember it easier. 15 | 16 | #define SRL Serial 17 | 18 | #define Word unsigned short 19 | 20 | #include "WiFi.h" 21 | #include 22 | 23 | const char* ssid = "DEC-PDP8"; 24 | const char* password = "pdp8pass"; 25 | WiFiServer wifiServer(8080); 26 | WiFiClient client = wifiServer.available(); 27 | 28 | const int STARTING_EEPROM_ADDRESS = 0; 29 | 30 | Word pc; 31 | 32 | // As of this writing, this whole thing is a quick-and-dirty port of this amazing 256-LOC 33 | // PDP-8 / 4K emulator: https://git.jeelabs.org/jcw/embello/src/branch/master/explore/1638-pdp8 34 | // It was written for PC, and I ported it to Arduino - it definitely runs on DUE. 35 | // Beware that the Arduino IDE builtin Serial monitor will not work (will not terminate lines 36 | // correctly), so use some actual terminal emulator - I am using picocom. - To do all this, 37 | // I ran jcw's original program, with the modification that I let it dump its memory right 38 | // after it loaded FOCAL 69. Then, I removed all loading routines and simply placed the 39 | // dump below into the mem-array, to let the machine have FOCAL 69 in memory a priori. 40 | // I have not tested it, but it should be possible, if you program anything, to replace 41 | // this dump with a new FOCAL 69 dump, containing your program. Hence, I modified the 42 | // cleanup-function so that it simply presents such a dump once you press Ctrl-\ - enjoy! 43 | // For instance, you can try this: FOR X=-10,1,10;TYPE X,! 44 | // - Nino, 21st May 2020 45 | Word mem[] = { 46 | 47 | 1464,2819,2819,1411,4,11,64,3328,1632,2404,63,1680,38,1050, 48 | 0,2404,0,4045,1287,2403,0,2403,0,1632,2040,2413,4094,0,0, 49 | 2815,0,0,1048,0,0,6,0,0,0,6,0,3459,1028,3540,4080,0,0,0, 50 | 2413,832,0,1470,1462,2048,141,798,5,141,140,135,131,223, 51 | 138,141,1,4032,174,4033,3968,4080,127,15,191,4094,3903,176, 52 | 3936,3922,3955,4093,4091,4087,63,128,2048,1048,1133,3021, 53 | 3072,3200,1632,1670,1632,1679,1039,1287,337,885,319,348, 54 | 364,1212,1346,716,465,1333,1133,1301,194,1186,1264,267,847, 55 | 859,1053,484,448,1074,1494,0,0,0,0,0,0,0,1505,3976,2942, 56 | 607,1554,3585,1600,1558,662,1547,661,2409,602,1544,1586, 57 | 602,1559,2410,2407,59,316,2406,2703,170,1680,2406,2406,602, 58 | 1551,1552,2405,541,1547,2416,2417,2802,2745,1046,2412,596, 59 | 565,4000,2422,560,1544,1586,567,1800,2416,3848,2405,2406, 60 | 566,590,4000,2736,2421,2414,2687,2400,393,786,3880,2687, 61 | 1554,530,3585,2714,165,2416,566,586,4008,2770,1566,2553, 62 | 551,250,550,4000,2422,551,2415,3588,1591,2417,2405,2417, 63 | 2784,2794,556,3654,556,3588,567,1591,2405,2417,2422,2794, 64 | 556,567,1591,2405,2417,2784,3848,2422,3648,567,68,4000, 65 | 3600,567,70,3888,2422,4000,763,3600,3588,1589,3010,2944, 66 | 4064,1024,1036,1032,624,610,875,739,1493,1493,1493,1493, 67 | 1493,3840,1493,1493,1493,1392,3654,3590,3590,2955,2412,530, 68 | 2402,2403,15,2403,53,565,4040,2739,2413,3584,531,1545,777, 69 | 2419,2422,2400,390,2404,53,786,3880,2745,3585,1560,565,4064, 70 | 2736,792,2419,2745,792,1591,2709,2413,2422,2400,392,2404, 71 | 53,2404,15,779,1554,3006,393,403,1593,3616,2248,569,1803, 72 | 3616,2248,3007,347,523,1547,523,3681,537,3992,2422,3016, 73 | 2428,977,1593,3616,2248,721,3585,1803,3616,2248,2873,988, 74 | 3744,988,1545,1244,591,2248,591,1593,777,1803,1081,2789, 75 | 591,2248,3036,315,3744,1004,1260,1545,591,1593,779,1801, 76 | 1081,2803,3052,1504,138,143,151,573,607,1493,565,392,396, 77 | 3898,2412,2413,2422,531,1554,2405,566,590,4008,2913,2408, 78 | 766,2696,566,61,2402,2405,2408,766,3848,2707,779,2407,507, 79 | 119,2422,2412,1046,2413,2743,567,4000,2411,2405,2409,566, 80 | 590,4000,2724,787,3880,2745,3585,1560,565,4032,792,2419, 81 | 2747,792,1591,2719,531,2731,1558,2913,565,4072,2745,2409, 82 | 2740,915,2416,2408,1015,3008,566,1216,642,4008,2767,2417, 83 | 3008,3848,3008,1216,1216,3008,1139,977,1546,778,3912,2784, 84 | 3617,566,4000,2772,977,3616,522,1580,3848,1233,1233,3776, 85 | 3025,289,68,3617,1593,567,68,569,4008,1252,3044,2982,542, 86 | 4000,2804,2405,3054,2410,2407,3582,1794,3054,541,392,396, 87 | 211,198,201,196,199,195,193,212,204,197,215,205,209,210, 88 | 138,2420,2463,1035,2464,585,1562,549,3912,1050,4072,1050, 89 | 3848,3063,2407,767,3833,2405,2712,2405,2709,897,1063,2400, 90 | 771,2416,566,733,3872,2422,536,2402,2400,906,779,1560,2311, 91 | 3352,0,2407,767,3711,2422,536,2402,2400,906,2407,767,3708, 92 | 2422,2403,1048,2400,906,2403,1048,2403,15,2400,392,2404, 93 | 15,2404,1048,2404,3896,779,1560,2311,280,987,3352,1365,0, 94 | 549,4064,2913,536,2402,2403,3896,2753,3907,3924,2403,1285, 95 | 2753,2347,2402,566,734,4000,2422,2400,906,2347,3123,3712, 96 | 779,3119,3848,2347,3712,2910,545,545,523,272,387,396,642, 97 | 643,3907,1156,413,686,127,883,3313,3744,1582,1558,2407,761, 98 | 126,1070,2710,2400,771,566,2402,685,2409,1054,3585,2393, 99 | 779,1590,2690,2400,907,2392,2691,1046,2405,2407,771,507, 100 | 2409,2715,2405,2412,567,1578,2692,575,2355,3616,575,2409, 101 | 2405,2692,186,2412,2413,2422,560,1544,1586,567,1800,520, 102 | 1559,2356,1600,1046,2405,2409,2407,62,697,2406,2747,560, 103 | 3585,1544,1586,2410,2407,57,697,2406,2758,146,3880,566, 104 | 3617,1593,972,1228,1546,778,3912,2784,569,4000,2772,522, 105 | 972,1593,825,1593,2873,1228,3776,3020,2347,3584,3325,3290, 106 | 2790,3314,1574,3073,2910,0,3110,3094,3105,2799,3712,3052, 107 | 699,696,1504,706,697,177,714,165,162,161,163,164,160,172, 108 | 187,141,2420,162,141,2422,1586,2406,2405,2408,1015,2710, 109 | 566,82,561,1585,2405,2408,1015,2710,2705,2418,2719,561, 110 | 1582,2480,779,1585,2479,2347,1743,560,1560,536,3617,537, 111 | 4072,2737,792,3617,561,4008,2757,536,568,2721,1063,897,537, 112 | 517,3681,523,3984,2422,537,568,1561,561,1816,1048,719,1816, 113 | 1048,2311,351,3352,0,2913,536,1545,777,3617,719,4000,2732, 114 | 1048,1048,2913,175,566,588,4000,3023,2405,2768,3920,3911, 115 | 0,1024,0,232,566,589,4000,1243,566,726,1580,556,4040,3035, 116 | 566,727,4072,1243,3035,2311,728,2280,3288,0,1752,1572,2910, 117 | 607,1554,779,1593,2873,673,666,681,678,1578,683,683,392,396, 118 | 525,556,2402,557,2402,558,2402,641,2402,2405,1581,2420,2711, 119 | 2778,2787,2400,775,2420,2724,138,255,2422,607,1560,585,556, 120 | 3880,2727,3585,4008,2771,556,593,4040,2803,2418,3848,2422, 121 | 556,1556,532,593,4032,1556,532,3617,557,4040,2760,557,3658, 122 | 3594,729,1724,557,4000,2404,36,2311,280,3413,0,597,1560, 123 | 532,557,4008,2913,779,1581,2733,2418,3848,2805,557,2402, 124 | 536,1744,2403,2044,532,1581,2405,2420,2803,2778,2787,2704, 125 | 280,2403,36,597,1560,1566,2393,2404,36,2706,1582,2405,2408, 126 | 1015,2796,558,3652,566,2787,2418,2422,2177,779,2407,1140, 127 | 3207,2418,2422,2177,1035,2910,160,171,173,175,170,222,168, 128 | 219,188,169,221,190,172,187,141,189,2403,1285,2404,36,665, 129 | 4040,2345,2311,3584,3224,0,597,1560,2215,2967,914,1,1024,0, 130 | 0,3,933,556,593,4032,2973,556,592,4064,1181,2973,527,779, 131 | 1581,668,779,3617,556,4000,2422,2405,2983,183,3074,2413, 132 | 2994,1046,2405,566,590,4000,2743,527,3616,531,1583,603,3617, 133 | 531,4008,2687,3584,787,1813,603,1593,825,3880,2775,1562, 134 | 531,3681,538,3992,559,538,1849,538,2761,3616,531,1545,559, 135 | 3616,531,1546,559,560,1584,520,3616,522,1562,520,559,1544, 136 | 778,1801,1050,2792,2739,144,2356,1590,2408,915,3053,2409, 137 | 3053,1371,1448,1438,1397,1432,1359,1402,1428,1429,1452, 138 | 1405,1474,1433,1399,216,2420,2719,2706,2699,566,586,3872, 139 | 2422,605,1584,1883,560,1561,2687,2412,560,1544,2421,1043, 140 | 565,4032,787,2419,2703,787,1591,2709,560,1561,2913,1077, 141 | 603,1557,603,1555,531,1545,567,3681,777,3880,2742,3992, 142 | 2743,531,1557,787,3872,2726,3848,1186,531,3585,1551,1552, 143 | 2978,177,2264,4040,518,751,566,3880,2766,573,1590,534,576, 144 | 4008,2409,3004,2264,3616,2750,534,4000,2774,576,4008,3585, 145 | 1600,2749,584,2757,1228,1040,2789,529,82,1590,566,579,4008, 146 | 2763,566,750,3032,783,1553,3616,1552,529,3658,3594,3594, 147 | 2780,4064,4001,184,3584,789,1840,560,1813,561,3872,1800, 148 | 520,3585,1584,560,1561,3056,683,396,3202,495,495,3240,1, 149 | 1024,0,0,0,0,4086,0,3097,2701,3102,70,3880,2701,595,2956, 150 | 0,567,2415,82,2210,578,2409,567,2210,750,1590,2409,2965,0, 151 | 70,1562,587,1563,2730,1051,1562,538,651,3904,2728,3712,539, 152 | 2409,538,587,2409,2978,138,3880,566,590,3880,2750,575,2355, 153 | 2997,575,2355,574,2748,178,584,3617,566,3880,746,577,3880, 154 | 3053,747,1593,569,236,750,3872,748,4008,2778,569,82,3872, 155 | 2269,3584,3010,594,2269,2772,1368,1074,2799,561,1800,1585, 156 | 523,3681,517,520,3984,3037,2422,32,255,96,1540,4000,2415, 157 | 1585,3616,1586,3037,0,0,0,0,0,0,0,0,0,0,0,0,0,2048,3965, 158 | 1664,3592,1665,3105,2709,3106,1550,949,3880,2709,3108,1550, 159 | 1973,693,3585,71,691,1717,3097,2726,3102,70,3880,2726,595, 160 | 1714,690,642,4008,2784,540,4000,2422,690,1564,3081,2730, 161 | 3082,1567,3236,3137,3584,641,3652,640,3073,2816,141,1616, 162 | 1617,1617,1135,540,3944,2743,1726,1564,702,2998,1341,1718, 163 | 3073,948,4000,2753,3074,526,4000,2764,694,3110,1550,2771, 164 | 694,1972,692,3585,71,691,1716,3073,3006,1750,0,3744,726, 165 | 1591,3073,526,4000,2779,3074,2786,595,1591,1038,581,1583, 166 | 3616,691,1544,3584,1800,1071,2793,1564,691,1717,691,1716, 167 | 3616,3110,577,2409,2411,1042,786,3880,2815,1591,577,2409, 168 | 2409,2411,575,2409,598,1642,2687,562,4000,2700,520,3617, 169 | 535,4032,2977,681,2409,520,1593,3584,1074,2722,825,82,579, 170 | 4000,2719,3616,1586,3616,520,1544,825,65,1585,2977,1368, 171 | 825,65,518,4000,2712,1849,2713,220,560,1560,537,3617,536, 172 | 4008,2913,792,1742,717,1551,1552,2405,2409,2405,2409,2405, 173 | 2409,1048,792,2508,2405,2409,1048,2311,280,0,2392,575,2409, 174 | 568,585,536,2731,1314,1613,0,2601,0,0,0,0,0,0,0,0,0,0,0,0, 175 | 0,0,0,0,0,3502,3312,2065,4045,4045,3519,895,2994,3436,3502, 176 | 3312,2870,2995,3135,895,2600,1576,617,3057,3113,2665,2668, 177 | 2175,895,2687,895,895,895,895,4045,4045,0,0,0,0,0,0,1679, 178 | 0,237,399,193,812,3193,3513,4045,1685,271,1248,637,3504, 179 | 4045,1699,276,608,2569,2929,2674,2998,3436,3246,3509,2866, 180 | 2994,3455,832,1709,281,1248,1576,617,3928,2569,2929,2687, 181 | 832,1716,311,1248,637,621,3199,832,1722,316,480,3246,3248, 182 | 4045,1752,321,1248,1576,3177,3944,1194,3184,3120,3120,2667, 183 | 2579,2737,3120,3120,2667,2580,2737,3120,3113,2792,1386,3184, 184 | 3113,2792,1450,3184,2667,1535,832,1766,341,83,736,2185,950, 185 | 1570,2834,2835,2836,2837,2838,2839,4045,1779,389,608,2578, 186 | 2675,2993,3116,3502,3125,2867,2993,3135,832,1785,394,1248, 187 | 893,3135,832,1798,399,608,2578,2675,2994,3116,3310,3248, 188 | 2867,2996,3135,832,1804,404,1248,893,3199,832,1810,409, 189 | 1248,1213,2898,4045,1816,414,1248,957,1215,832,1822,419, 190 | 480,3438,3125,4045,1835,424,608,2579,2675,2996,3436,3310, 191 | 3381,2867,2998,3455,832,1841,429,1248,893,3263,832,1847, 192 | 434,1248,1277,2899,4045,1853,439,1248,957,1279,832,1859, 193 | 444,480,3438,3125,4045,1872,449,608,2580,2675,2999,3116, 194 | 3310,3568,2868,2992,3455,832,1878,454,1248,893,3327,832, 195 | 1884,459,1248,1341,2900,4045,1890,464,1248,957,1343,832, 196 | 1896,469,480,3438,3125,4045,1909,517,608,2581,2676,2993, 197 | 3116,3374,3184,2868,2995,3135,832,1915,522,1248,893,3391, 198 | 832,1921,527,1248,1405,2901,4045,1927,532,1248,957,1407, 199 | 832,1933,537,480,3438,3125,4045,1946,542,608,2582,2676, 200 | 2995,3436,3374,3317,2868,2997,3455,832,1952,547,1248,893, 201 | 3455,832,1958,552,1248,1469,2902,4045,1964,557,1248,957, 202 | 1471,832,1970,562,480,3438,3125,4045,1983,567,608,2583, 203 | 2676,2998,3116,3374,3504,2866,2993,3455,832,1989,572,1248, 204 | 893,3519,832,1995,577,1248,1533,2903,4045,2001,582,1248, 205 | 957,1535,832,2014,587,608,2574,2677,2992,3436,3246,3189, 206 | 2869,2992,3455,832,2020,645,1248,637,3199,832,2034,650,608, 207 | 2569,2934,3113,3438,3189,2869,2995,3692,3438,3321,4045, 208 | 2056,655,608,2574,2886,596,1192,1576,617,3057,3120,3120, 209 | 3113,2677,2995,3564,3438,3248,2869,2995,3583,832,2073,660, 210 | 608,2566,596,1192,1576,617,2665,3438,3249,2869,2995,3564, 211 | 3438,3249,4045,2089,661,1312,2417,2088,393,1298,2600,1576, 212 | 617,3057,3120,3120,3113,2665,4045,2117,662,1312,2417,2088, 213 | 393,1298,2600,1576,617,3057,3120,3120,2665,2920,3184,2694, 214 | 596,1192,2584,2569,2671,3184,3120,3120,2665,2665,4045,2144, 215 | 663,1312,2417,2088,393,1298,2600,1576,617,3057,3120,3113, 216 | 2669,2609,3114,393,1298,2600,1576,617,3057,3120,3120,2665, 217 | 2665,4045,2170,664,1312,2417,2088,393,1298,2600,1576,617, 218 | 3057,3120,2665,2920,3184,2694,596,1192,2584,2569,2671,3184, 219 | 3120,2665,2665,4045,2195,665,1312,2417,2088,393,1298,2600, 220 | 1576,617,3057,3113,2669,2609,3114,393,1298,2600,1576,617, 221 | 3057,3120,2665,2665,4045,2218,666,1312,2417,2088,393,1298, 222 | 2584,2569,2665,2920,3184,2694,596,1192,2584,2569,2671,3184, 223 | 2665,2665,2849,4045,2225,677,1248,637,619,3199,832,2231,678, 224 | 480,3438,3184,4045,2237,679,1248,957,3135,832,2251,680,608, 225 | 2573,2929,2677,2996,3436,3310,3376,2869,2996,3455,832,2265, 226 | 685,608,2573,2930,2677,2997,3116,3310,3509,2869,2997,3135, 227 | 832,2279,690,608,2573,2931,2677,2997,3436,3374,3125,2869, 228 | 2997,3455,832,2293,695,608,2573,2932,2677,2998,3116,3374, 229 | 3312,2869,2998,3135,832,2307,700,608,2573,2933,2677,2998, 230 | 3436,3374,3445,2869,2998,3455,832,2313,705,480,3246,3189, 231 | 4045,2319,773,1248,637,3199,832,2331,774,1312,2422,2992, 232 | 3104,620,2234,2220,1576,617,4045,2341,775,1312,2422,2992, 233 | 3104,1576,619,3177,4045,2351,776,1312,2422,2992,3104,1576, 234 | 619,3241,4045,2361,777,1312,2422,2992,3104,1576,619,3305, 235 | 4045,2371,778,1312,2422,2992,3104,1576,619,3369,4045,2382, 236 | 779,1312,2422,2992,3104,1576,619,3433,2849,4045,2389,782, 237 | 1248,637,619,3519,832,2403,783,608,2569,2934,3113,3502,3253, 238 | 2870,2995,3116,3502,3312,4045,2409,793,480,3502,3126,4045, 239 | 0,798,1151,832,1493,368,2447,1542,1457,1028,3282,1452,7,2, 240 | 2050,2354,2401,1585,2400,799,1048,792,3065,0,0,0,0,0,0,0,0, 241 | 0,0,0,0,0,0,0,0,549,4040,2516,1563,2311,2251,3517,0,2347, 242 | 1749,2311,3584,3518,445,1470,3517,2493,3518,712,3286,197, 243 | 1750,1469,703,3286,194,2494,726,3286,445,1750,2257,718,0, 244 | 725,548,1572,1051,2910,2311,3517,206,1981,0,2910,2770,2774, 245 | 4,1274,770,4092,1135,2671,10,2860,227,7,1398,2785,1,1477, 246 | 1309,1,1024,0,2,1024,0,2675,0,0,0,0,0,2311,445,2493,3518, 247 | 2300,761,2494,758,3286,243,2494,752,2494,749,2493,1750,0, 248 | 3052,2580,0,1311,931,4095,1732,2332,4091,1734,2860,0,1311, 249 | 934,0,1303,1235,4093,1815,3626,0,549,4040,2291,1563,2311, 250 | 3485,1439,0,549,4040,2705,2311,415,1949,3485,0,3744,1778, 251 | 2963,2522,1266,2972,2311,3485,414,1437,0,2972,2754,2770, 252 | 2766,2510,549,3880,2422,4040,2345,2311,3566,1439,0,549, 253 | 3880,2910,4032,2740,2311,415,2030,3566,0,3744,1563,517, 254 | 1572,3616,1006,1573,1574,1575,3585,2030,2311,2287,3485, 255 | 494,1439,3566,2283,744,2542,741,2542,738,2542,735,2542, 256 | 732,2542,729,2542,726,2542,925,0,2972,0,2047,4066,4095, 257 | 2048,2112,4095,1359,199,4094,2123,3721,4094,1373,1729,4093, 258 | 2534,505,4092,1182,2244,4089,2404,989,2518,0,1419,2316,0, 259 | 0,2345,3744,3059,0,0,0,0,0,0,0,0,0,2311,3282,206,1234,0, 260 | 549,4064,2701,549,4032,2910,2345,3616,1563,2311,1734,3286, 261 | 0,2347,2311,3584,3282,214,1234,2246,3282,1226,0,549,4040, 262 | 2725,2311,3282,0,539,3616,1563,2311,210,1230,0,549,4040, 263 | 2737,2311,202,1234,3282,0,2311,210,1742,3282,2258,3286,218, 264 | 2262,734,2262,738,2262,742,2262,718,2258,0,1051,2910,2345, 265 | 2910,3,1608,2030,1693,2,1608,2030,1693,1,1608,2030,1693,0, 266 | 0,0,0,0,0,0,0,4084,1281,3597,546,4089,2868,2892,3176,4093, 267 | 1305,2801,2526,0,2773,268,1655,0,0,0,0,0,0,0,0,0,0,0,0,0, 268 | 0,0,0,0,0,0,0,0,0,0,1756,554,2415,82,1562,538,3617,3880, 269 | 726,1757,554,3880,2721,82,1755,733,731,3912,2712,3744,538, 270 | 1755,3616,539,3904,3712,538,3912,2739,726,3904,3712,727, 271 | 1593,985,569,1758,569,3617,1593,725,1502,990,728,4040,2741, 272 | 2014,1081,2769,1502,1051,3712,554,4008,2798,733,539,3936, 273 | 2797,731,3904,3712,3617,539,3617,1562,539,538,4008,2787, 274 | 538,3585,4040,581,2270,1050,2755,578,2409,2755,3616,734, 275 | 1758,2730,5,4090,7,4086,3176,3180,0,0,0,0,2522,1245,3038, 276 | 2944,3616,539,1563,1244,2795,3616,1756,2763,780,2763,3712, 277 | 2522,578,2409,1152,780,2270,1244,2802,3616,1756,2803,3807, 278 | 549,1576,549,4040,2345,3065,202,1574,1572,1573,1575,1740, 279 | 1576,566,692,3880,2704,585,4000,2705,3616,1576,2486,566, 280 | 693,4008,2704,2199,2944,2966,566,690,4008,2967,2417,2967, 281 | 2727,556,1739,2231,1228,4000,2422,2486,2712,566,586,4040, 282 | 2967,566,691,4064,2967,566,82,2720,3899,3878,3925,3936,494, 283 | 2978,551,1571,550,1570,549,1569,1738,2253,2253,2267,2253, 284 | 715,1571,1570,1569,2267,714,2999,0,6,1,3011,551,3652,1575, 285 | 550,3588,1574,549,3588,1573,714,3588,1738,3021,3016,3776, 286 | 551,547,1575,3588,550,546,1574,3588,549,545,1573,3588,714, 287 | 1738,3035,3402,3776,545,3912,3664,3592,1569,546,3592,1570, 288 | 547,3592,1571,1056,3052,3052,0,0,0,0,0,733,2409,549,4032, 289 | 732,734,2409,2539,1563,548,3912,2711,3872,737,4072,2716, 290 | 2311,2532,0,3585,539,2697,2311,2538,0,3616,2709,2021,2022, 291 | 744,1548,548,3680,1772,739,1572,2391,1260,2725,998,3880, 292 | 2744,738,4040,2740,3585,1804,1060,738,1051,3584,998,1051, 293 | 3584,3848,2535,1804,1060,2744,744,1548,739,2537,2944,731, 294 | 2409,539,3912,3617,1573,539,4032,585,734,2409,549,1060,735, 295 | 3904,2765,736,1573,3616,548,3872,2284,549,2522,2944,1314, 296 | 197,4083,189,173,3996,100,4092,4086,4089,3261,3019,3018, 297 | 2999,3895,2816,3257,2937,0,587,2409,3052,0,0,0,0,0,0,0,0, 298 | 0,0,0,0,0,0,0,0,992,4000,2502,566,588,4008,2690,2498,566, 299 | 589,4000,2705,2502,1989,2499,965,3617,1563,712,1572,2500, 300 | 2503,2311,3352,0,566,705,4000,2726,2502,2498,2500,551,539, 301 | 1563,2311,280,0,539,3880,2944,4032,2737,2311,2237,3352,0, 302 | 3585,2742,2311,2233,3352,0,3616,539,1563,2726,4,1280,0,0, 303 | 4093,1638,1639,1640,3899,2944,2967,3707,3020,494,3805,35, 304 | 0,0,0,0,0,0,0,0,0,581,1763,543,4032,2804,1050,2772,1251, 305 | 2772,2275,523,766,3984,3042,1035,2913,138,0,765,3616,1789, 306 | 3680,1567,765,3872,3084,4000,767,598,1642,3043,2275,3059, 307 | 393,3616,1567,3086,70,3880,2770,595,1590,3025,0,2415,2148, 308 | 958,3776,1575,1571,896,3880,2944,1714,690,83,4008,2702, 309 | 580,128,1568,582,178,544,1568,691,178,4008,2713,800,1568, 310 | 1152,3616,544,1549,690,3654,3590,71,3880,2743,692,1714,946, 311 | 3880,2741,1714,708,1548,591,1583,781,1804,1071,2733,2994, 312 | 3457,256,3451,707,2747,707,1549,3616,544,1548,591,1583, 313 | 780,1805,1071,2750,2689,35,31,2549,2552,2689,2554,2553, 314 | 2555,2551,2689,549,4000,2773,1572,1573,1574,1575,2689, 315 | 2403,36,2403,32,2404,36,2347,3912,2786,3616,1714,1571, 316 | 549,4000,2422,2403,1285,2404,36,2404,3896,2800,2403,3896, 317 | 2404,32,2550,1202,2795,2689,2550,2689,3691,3588,3805,3475, 318 | 3052,3567,3035,3398,3397,3655,3443,3405,0,3403,4036,3776, 319 | 551,3617,1575,550,3616,3864,3649,1574,549,3616,3864,3649, 320 | 1573,2947,3400,549,3880,550,4008,2761,545,3880,546,3880, 321 | 547,4008,2963,544,3617,548,3880,2747,1667,643,3904,3617, 322 | 1746,722,734,4040,2749,643,4032,2741,2287,1234,2737,2747, 323 | 3616,544,1568,2515,1234,2744,1171,2963,544,4032,2756,548, 324 | 4032,2963,2758,548,4032,643,4064,2963,544,1572,545,1573, 325 | 546,1574,547,1575,2963,4036,3052,3420,2537,548,4072,2795, 326 | 3585,1571,744,1568,2195,23,1063,2788,1062,3848,1061,1575, 327 | 2538,550,3028,23,2937,3707,1572,1573,1574,2788,3401,3776, 328 | 549,3912,3600,3592,1573,550,3592,1574,551,3592,1575,1060, 329 | 3055,3055,223,255,138,253,4095,3444,3585,544,2260,4040, 330 | 2283,1729,1728,1727,1726,549,2025,545,2538,2,546,2538,3, 331 | 550,2025,545,2538,3,546,2538,4,2739,1724,547,2025,549,2538, 332 | 4,550,2538,5,551,2025,545,2538,4,546,2538,5,547,2538,6,705, 333 | 1573,704,1574,703,1575,2241,1575,2948,0,0,0,1280,2787,3642, 334 | 1064,2345,2535,1063,3009,545,4008,2422,544,3617,3585,2260, 335 | 4032,2283,2536,2241,3027,3329,3592,548,1572,596,37,545, 336 | 4032,3616,1576,549,3880,3046,4040,2345,545,3880,3046,3028, 337 | 3408,3805,3761,3758,3712,3398,3776,547,3617,1571,546,3616, 338 | 3864,3649,1570,545,3616,3864,3649,1569,3051,3825,552,4040, 339 | 2345,3067,3613,3880,2944,1708,1707,687,1709,3648,684,3592, 340 | 1708,683,3856,2704,3648,686,3592,1707,1197,2696,684,3592, 341 | 1709,896,3617,682,1708,685,3648,940,1964,1196,3588,683,940, 342 | 1964,3856,2944,1196,1452,2944,2726,3650,995,3648,1280,3185, 343 | 4084,4073,0,1664,1708,688,1709,3848,2391,3648,546,550,1710, 344 | 3588,549,545,3856,2756,1573,686,1574,3712,684,3588,1708,640, 345 | 3588,1664,1197,2743,684,1574,640,1573,2993,3588,1757,1197, 346 | 2743,733,1573,640,1574,684,1575,2993,3222,2557,2294,549, 347 | 3880,551,3880,550,4008,2803,549,3652,4040,2800,2391,3680, 348 | 548,1572,2791,2558,2294,3037,1572,3037,3567,3826,549,3912, 349 | 3617,4040,2549,3062,2937,3707,0,2311,3260,0,549,4040,2422, 350 | 548,3912,3600,3592,1720,3864,1208,3584,695,1721,1722,1723, 351 | 701,3880,702,4008,2741,2311,188,1720,696,0,3744,548,1572, 352 | 548,3617,696,4000,2737,549,3617,697,4000,2737,550,3617,698, 353 | 3904,3617,3585,4032,2910,2311,3256,0,2711,1572,2910,1549,2, 354 | 1024,0,0,0,0,0,3907,0,0,0,603,2263,560,2263,537,2263,541, 355 | 2263,2766,2405,2409,566,590,4000,2764,526,4000,2770,3074, 356 | 2884,0,1562,538,3590,3590,2280,2415,3588,2280,3594,3592, 357 | 2280,2280,3712,575,2409,3031,0,238,587,2409,538,3048,7,0, 358 | 0, 0, 0, 0, 0, 0, 0, 0, 359 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 360 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 361 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 362 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 363 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 364 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 365 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 366 | 367 | }; 368 | 369 | 370 | 371 | Word mask(Word w) { return w & 07777; } 372 | Word lmask(Word w) { return w & 017777; } 373 | 374 | Word opAddr (int ir) { 375 | Word a = ir & 0177; 376 | if (ir & 0200) 377 | a |= (pc - 1) & 07600; 378 | if (ir & 0400) { 379 | if ((a & 07770) == 010) 380 | mem[a] = mask(mem[a] + 1); 381 | a = mem[a]; 382 | } 383 | return a; 384 | } 385 | 386 | // This I simply turned into a memory dump, so if anything was 387 | // programmed in FOCAL, it should be retained here and could be 388 | // pasted later on at the top. - Nino 389 | void cleanup () { 390 | 391 | SRL.println(); 392 | SRL.println(); 393 | client.println(); 394 | client.println(); 395 | int cntr; 396 | int decer = 0; 397 | for (cntr = 0; cntr < MEMSIZE; cntr++) { 398 | SRL.print(static_cast(mem[cntr])); 399 | SRL.print(", "); 400 | client.print(static_cast(mem[cntr])); 401 | client.print(", "); 402 | delay(0); 403 | decer++; 404 | if (decer == 12) { 405 | SRL.print("\r\n"); 406 | client.print("\r\n"); 407 | decer = 0; 408 | } 409 | 410 | } 411 | SRL.println(); 412 | SRL.println(); 413 | client.println(); 414 | client.println(); 415 | 416 | } 417 | 418 | 419 | void writeArrayIntoEEPROM(int address, Word numbers[]) 420 | { 421 | // 1660 to 2820 422 | EEPROM.begin(EEPROM_SIZE); delay(2000); 423 | int addressIndex = address; 424 | for (int i = 1660; i < 2820; i++) 425 | { 426 | EEPROM.write(addressIndex, numbers[i] >> 8); 427 | EEPROM.write(addressIndex + 1, numbers[i] & 0xFF); 428 | addressIndex += 2; 429 | } 430 | EEPROM.commit(); 431 | EEPROM.end(); 432 | } 433 | 434 | void readArrayFromEEPROM(int address, Word numbers[]) 435 | { 436 | // 1660 to 2820 437 | EEPROM.begin(EEPROM_SIZE); delay(2000); 438 | int addressIndex = address; 439 | for (int i = 1660; i < 2820; i++) 440 | { 441 | numbers[i] = (EEPROM.read(addressIndex) << 8) + EEPROM.read(addressIndex + 1); 442 | addressIndex += 2; 443 | } 444 | EEPROM.end(); 445 | } 446 | 447 | 448 | void setup() { 449 | 450 | // start serial port at 300 bps 451 | SRL.begin(9600); 452 | WiFi.softAP(ssid, password); 453 | delay(500); 454 | SRL.println("Establishing WiFi network."); 455 | wifiServer.begin(); 456 | SRL.println(WiFi.softAPIP()); 457 | 458 | pc = 0200; 459 | 460 | Word sr = 0; 461 | 462 | Word ac = 0, mq = 0; 463 | int iena = 0; 464 | 465 | int greeting = 1; 466 | 467 | for (;;) { 468 | 469 | client = wifiServer.available(); 470 | 471 | if (client) { 472 | while (client.connected()) { 473 | 474 | if (greeting == 1) { 475 | greeting = 0; 476 | client.print(F("\r\n WELCOME TO THE TOPSEQ SYSTEM IN FOCAL-69 ON AN ARDUINO PDP-8.\r\n")); 477 | delay(50); 478 | client.print(F(" THIS COMPUTER HAS BEEN SET TO RUN THE TOPSEQ SEMANTIC NETWORK.\r\n")); 479 | delay(50); 480 | client.print(F(" TOPSEQ IS SHORT FOR TOPIC SEQUENCER INDICATING THE NATURE OF\r\n")); 481 | delay(50); 482 | client.print(F(" THE SYSTEM. EACH INPUT CONSISTS OF EXACTLY SIX ONE-DIGIT\r\n")); 483 | delay(50); 484 | client.print(F(" POSITIVE OR NEGATIVE DECIMAL NUMBERS 1-9, E.G:\r\n")); 485 | delay(50); 486 | client.print(F(" 1,2,3,4,5,6 RETURN. NOTE THAT 0 IS NOT USED AND MEANS NO TOPIC.\r\n")); 487 | delay(50); 488 | client.print(F(" THIS SETS A NEW SENTENCE INTO THE KNOWLEDGE BASE, AT ONCE\r\n")); 489 | delay(50); 490 | client.print(F(" FORGETTING THE OLDEST ONE. EACH NUMBER REPRESENTS A POSSIBLE\r\n")); 491 | delay(50); 492 | client.print(F(" TOPIC. THE TOPIC OF THE SENTENCE IS ALWAYS THE FIRST NUMBER\r\n")); 493 | delay(50); 494 | client.print(F(" GIVEN IN THE SENTENCE. IT CAN BE SEARCHED BY NOTING IT AS\r\n")); 495 | delay(50); 496 | client.print(F(" NEGATIVE DURING INPUT, AS 1,-2,-1,2,3,4 SEARCHES FOR SENTENCES\r\n")); 497 | delay(50); 498 | client.print(F(" BEGINNING WITH 2 AND 1 AND WILL INDEED FIND 1,2,3,4,5,6 AS IT\r\n")); 499 | delay(50); 500 | client.print(F(" BEGINS WITH 1. AT THE SAME TIME, THE SYSTEM WILL ALSO LEARN\r\n")); 501 | delay(50); 502 | client.print(F(" 1,2,1,2,3,4, I.E. ALL TOPICS ARE STORED AS POSITIVE NUMBERS.\r\n")); 503 | delay(50); 504 | client.print(F(" IF YOU WISH TO ONLY SEARCH FOR A TERM, TRY E.G.\r\n")); 505 | delay(50); 506 | client.print(F(" -1,0,0,0,0,0 RETURN. IF A TOPIC OF INTEREST HAS BEEN\r\n")); 507 | delay(50); 508 | client.print(F(" SPECIFIED BY MINUS, A REPLY WILL BE MADE. OTHERWISE, THE\r\n")); 509 | delay(50); 510 | client.print(F(" SYSTEM WILL ONLY LEARN THE SENTENCE. THE KNOWLEDGE CONSISTS.\r\n")); 511 | delay(50); 512 | client.print(F(" OUT OF 60 SENTENCES. IF ANY SENTENCE IS INPUT THAT BEGINS WITH\r\n")); 513 | delay(50); 514 | client.print(F(" ZERO, THE INTERACTION TERMINATES AND THE KNOWLEDGE BASE IS\r\n")); 515 | delay(50); 516 | client.print(F(" PRINTED OUT. YOU ARE THEN RETURNED TO FOCAL-69. ERASE ALL\r\n")); 517 | delay(50); 518 | client.print(F(" IN FOCAL REMOVES THE AI UNTIL RESTART. TYPE GO TO COMMENCE.\r\n")); 519 | delay(50); 520 | client.print(F(" ~ DUMPS, { SAVES AND } GETS MEMORY: PRESS THE KEY, THEN ENTER.\r\n")); 521 | } 522 | 523 | iena >>= 1; // implements delayed enabling, relies on sign extension 524 | 525 | static char counter; // HACK: every 65536 ops, we fake an interrupt - made it 256 (char instead of short) 526 | if ((iena & 1) && ++counter == 0) { 527 | mem[0] = pc; 528 | pc = 1; 529 | iena = 0; 530 | } 531 | 532 | int ir = mem[pc]; 533 | 534 | pc = mask(pc + 1); 535 | switch ((ir >> 9) & 07) { 536 | 537 | case 0: // AND 538 | ac &= mem[opAddr(ir)] | 010000; 539 | break; 540 | 541 | case 1: // TAD 542 | ac = lmask(ac + mem[opAddr(ir)]); 543 | break; 544 | 545 | case 2: { // ISZ 546 | Word t = opAddr(ir); 547 | mem[t] = mask(mem[t] + 1); 548 | if (mem[t] == 0) 549 | pc = mask(pc + 1); 550 | break; 551 | } 552 | 553 | case 3: // DCA 554 | mem[opAddr(ir)] = mask(ac); 555 | ac &= 010000; 556 | break; 557 | 558 | case 4: { // JMS 559 | Word t = opAddr(ir); 560 | mem[t] = pc; 561 | pc = mask(t + 1); 562 | break; 563 | } 564 | 565 | case 5: // JMP 566 | pc = opAddr(ir); 567 | break; 568 | 569 | case 6: // IOT 570 | switch ((ir >> 3) & 077) { 571 | case 00: 572 | switch (ir) { 573 | case 06001: iena = ~1; break; // delays one cycle 574 | case 06002: iena = 0; break; 575 | default: { 576 | } 577 | } 578 | break; 579 | case 03: // keyboard 580 | 581 | if (ir & 01) { 582 | pc = mask(pc + 1);} 583 | 584 | if ((ir & 04) && (client.available()>0)) { // read byte 585 | int b = 0; 586 | 587 | b = client.read(); 588 | 589 | if ((b > 96) && (b < 123)) {b = b - 32;} // turn letters to CAPITALS 590 | if (b == '~') { // cleanup on ~ 591 | client.print("\r\nQUIT\r\n"); 592 | SRL.print("\r\nQUIT\r\n"); 593 | cleanup(); 594 | 595 | // return 4; 596 | if (ir & 01) // skip if ready 597 | pc = mask(pc + 1); 598 | if (ir & 04) { // send byte 599 | client.write(ac & 0177); // strip off parity 600 | SRL.write(ac & 0177); 601 | if ((ac & 0177) == '\n') {delay(4);} 602 | // fflush(stdout); 603 | } 604 | if (ir & 02) // clear flag 605 | ac &= 010000; 606 | } 607 | 608 | if (b == '{') { 609 | b = ' '; 610 | writeArrayIntoEEPROM(STARTING_EEPROM_ADDRESS, mem); 611 | // for (int iii = 0; iii < MEMSIZE - 16; iii = iii + 1) { client.print(mem[iii]); client.print(","); } 612 | client.print(F("\r\nMEMORY SAVED.\r\n")); 613 | } 614 | 615 | if (b == '}') { 616 | b = ' '; 617 | readArrayFromEEPROM(STARTING_EEPROM_ADDRESS, mem); 618 | // for (int iii = 0; iii < MEMSIZE - 16; iii = iii + 1) { client.print(mem[iii]); client.print(","); } 619 | client.print(F("\r\nMEMORY LOADED.\r\n")); 620 | } 621 | 622 | ac = (ac & 010000) | b; 623 | } 624 | 625 | 626 | 627 | 628 | break; 629 | case 04: // teleprinter 630 | if (ir & 01) // skip if ready 631 | pc = mask(pc + 1); 632 | if (ir & 04) { // send byte 633 | client.write(ac & 0177); // strip off parity 634 | SRL.write(ac & 0177); 635 | delay(20); 636 | if ((ac & 0177) == '\n') {delay(20);} 637 | // fflush(stdout); 638 | } 639 | if (ir & 02) // clear flag 640 | ac &= 010000; 641 | break; 642 | default: 643 | { 644 | } 645 | break; 646 | } 647 | break; 648 | 649 | case 7: // OPR 650 | if ((ir & 0400) == 0) { // group 1 651 | if (ir & 0200) // CLA 652 | ac &= 010000; 653 | if (ir & 0100) // CLL 654 | ac &= 07777; 655 | if (ir & 040) // CMA 656 | ac ^= 07777; 657 | if (ir & 020) // CML 658 | ac ^= 010000; 659 | if (ir & 01) // IAC 660 | ac = lmask(ac + 1); 661 | switch (ir & 016) { 662 | case 012: // RTR 663 | ac = lmask((ac >> 1) | (ac << 12)); // fall through 664 | case 010: // RAR 665 | ac = lmask((ac >> 1) | (ac << 12)); 666 | break; 667 | case 06: // RTL 668 | ac = lmask((ac >> 12) | (ac << 1)); // fall through 669 | case 04: // RAL 670 | ac = lmask((ac >> 12) | (ac << 1)); 671 | break; 672 | case 02: // BSW 673 | ac = (ac & 010000) | ((ac >> 6) & 077) 674 | | ((ac << 6) & 07700); 675 | break; 676 | } 677 | } else if ((ir & 01) == 0) { // group 2 678 | // SMA, SPA, SZA, SNA, SNL, SZL 679 | int s = ((ir & 0100) && (ac & 04000)) || 680 | ((ir & 040) && (ac & 07777) == 0) || 681 | ((ir & 020) && (ac & 010000) != 0) ? 0 : 010; 682 | if (s == (ir & 010)) 683 | pc = mask(pc + 1); 684 | if (ir & 0200) // CLA 685 | ac &= 010000; 686 | if (ir & 04) // OSR 687 | ac |= sr; 688 | if (ir & 02) { // HLT 689 | client.print("\r\nHALT "); client.println(mask(ac), OCT); 690 | // return 0; 691 | } 692 | } else { // group 3 693 | Word t = mq; 694 | if (ir & 0200) // CLA 695 | ac &= 010000; 696 | if (ir & 020) { // MQL 697 | mq = ac & 07777; 698 | ac &= 010000; 699 | } 700 | if (ir & 0100) 701 | ac |= t; 702 | } 703 | break; 704 | } 705 | }}} 706 | 707 | 708 | } 709 | 710 | void loop() {} 711 | 712 | #pragma GCC pop_options 713 | --------------------------------------------------------------------------------