Related to recipe 577108 and recipe 577110, this library of functions was written for those that wish to explore more in experimental programming in the Whitespace language (and more specifically, assembly derived from the language). The code is divided into several sections, starting with an explanation of some special memory locations and a list of functions available grouped by their general purpose. Next comes a table of errors that could raised while the code is running and the body of the main test function for the entire program. The next three sections (in order) are three untested functions, the functions intended for usage, and individual test functions for the preceding code. Most of the documentation is written in modified Python to express how all of the code operates.
If you have any comments or wish to vote this recipe down, please provide an explanation as to what you find fault with in this program and also a solution that you would implement to fix the problem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 | # HEAP[0] = temporary memory for anyone.
# HEAP[-1] = beginning of dynamic memory.
# HEAP[-2] = number of blocks allocated.
################################################################################
# Untested Functions:
# print_stack_c_string()
# raise(error)
# trace(reference)
# Standard Memory Functions:
# malloc(cells) -> pointer
# calloc(block_count, block_size) -> pointer
# free(pointer)
# realloc(pointer, cells) -> pointer
# Debugging Memory Functions:
# memory_manager_size(pointer) -> block_size
# memory_manager_blocks() -> block_count
# memory_manager_cells() -> used_memory
# memory_manager_pointers(include_self) -> pointer_array
# memory_manager_find(address) -> pointer
# memory_manager_hash() -> hash_number
# Utility Memory Functions:
# clear(start_address, end_address)
# copy(from_start, from_end, to_start, to_end)
# compare_cells(addr_a, addr_b) -> -1, 0, +1
# compare_memory(a, b, length) -> -1, 0, +1
# range(address, start, stop, step)
# mark(pointer)
# sum_length_array(array) -> sum
# Private Memory Functions:
# memory_manager_append_cell(start, end)
# memory_manager_get_cell(index) -> start, end
# memory_manager_insert_cell(start, end, index)
# malloc_check_beginning(cells) -> enough_space
# malloc_check_ranges(cells) -> index
# malloc_ranges(cells) -> pointer
# memory_manager_search(pointer) -> index
# memory_manager_pop_cell(index) -> start, end
# memory_manager_get_block_size(index) -> size
# memory_manager_set_cell(start, end, index)
# memory_manager_deflate_block(cells, index)
# memory_manager_inflate_cell(cells, index)
# memory_manager_potential_after(index) -> size
# memory_manager_potential_before(index) -> size
# memory_manager_compress(index) -> address
# memory_manager_inflate_before(pointer, cells, index) -> pointer
# memory_manager_inflate_move(pointer, cells, index) -> pointer
# memory_manager_inflate_block(pointer, cells, index) -> pointer
# Stack Helper Functions:
# rotate_3_down()
# rotate_3_up()
# save_stack(size) -> pointer
# load_stack(pointer, size)
# Number Manipulation Functions:
# abs_diff(a, b) -> number
# get_addr(offset, start, end) -> address
# direction(number) -> -1, 0, +1
# uint_cast(number) -> uint
# left_shift(number, shift) -> number
# right_shift(number, shift) -> number
# divmod(x, y) -> div, mod
# value_to_array(value, base) -> array
# array_to_value(array, base) -> value
# uint_bits(number) -> bits
# uint_xor(a, b) -> xor_value
################################################################################
# Error 1 = Copy's two ranges are not equal.
# Error 2 = abs_diff(2, 1) != 1
# Error 3 = abs_diff(1, 2) != 1
# Error 4 = get_addr(1, 1, 4) != 2
# Error 5 = get_addr(2, 1, 4) != 3
# Error 6 = get_addr(1, 4, 1) != 3
# Error 7 = get_addr(2, 4, 1) != 2
# Error 8 = heap[1] != 0 after clear()
# Error 9 = heap[2] != 0 after clear()
# Error 10 = heap[1] != 0 after clear()
# Error 11 = heap[2] != 0 after clear()
# Error 12 = heap[3] != 1 after copy(1, 2, 3, 4)
# Error 13 = heap[4] != 2 after copy(1, 2, 3, 4)
# Error 14 = heap[3] != 2 after copy(1, 2, 4, 3)
# Error 15 = heap[4] != 1 after copy(1, 2, 4, 3)
# Error 16 = heap[3] != 1 after copy(2, 1, 4, 3)
# Error 17 = heap[4] != 2 after copy(2, 1, 4, 3)
# Error 18 = heap[3] != 2 after copy(2, 1, 3, 4)
# Error 19 = heap[4] != 1 after copy(2, 1, 3, 4)
# Error 20 = heap[-2] != 0
# Error 21 = heap[-2] != 1
# Error 22 = heap[-3] != 100
# Error 23 = heap[-4] != 200
# Error 24 = heap[-2] != 2
# Error 25 = heap[-5] != 300
# Error 26 = heap[-6] != 400
# Error 27 = Memory manager cell is out of range.
# Error 28 = MM[0][0] != 80
# Error 29 = MM[0][1] != 90
# Error 30 = MM[1][0] != 100
# Error 31 = MM[1][1] != 110
# Error 32 = MM_insert_cell had negative index.
# Error 33 = MM[3][1] != 40
# Error 34 = MM[3][0] != 31
# Error 35 = MM[2][1] != 30
# Error 36 = MM[2][0] != 21
# Error 37 = MM[1][1] != 20
# Error 38 = MM[1][0] != 11
# Error 39 = MM[0][1] != 10
# Error 40 = MM[0][0] != 1
# Error 41 = There was a request for zero or less cells.
# Error 42 = malloc_check_beginning accepted invalid range.
# Error 43 = malloc_check_beginngng did not accept valid range.
# Error 44 = MM[1][1] != 20
# Error 45 = MM[1][0] != 11
# Error 46 = MM[0][1] != 10
# Error 47 = MM[0][0] != 1
# Error 48 = malloc_check_ranges found space.
# Error 49 = malloc_check_ranges found space.
# Error 50 = malloc_check_ranges found space.
# Error 51 = malloc_check_ranges did not insert at MM[1].
# Error 52 = malloc_check_ranges did not insert at MM[2].
# Error 53 = MM[2][1] != 30
# Error 54 = MM[2][0] != 26
# Error 55 = MM[1][1] != 25
# Error 56 = MM[1][0] != 21
# Error 57 = malloc_ranges failed head insert.
# Error 58 = malloc_ranges failed body insert.
# Error 59 = mallox_ranges failed tail insert.
# Error 60 = MM[4][1] != 50
# Error 61 = MM[4][0] != 41
# Error 62 = MM[2][1] != 30
# Error 63 = MM[2][0] != 21
# Error 64 = MM[0][1] != 10
# Error 65 = MM[0][0] != 1
# Error 66 = malloc(1) produced bad pointer.
# Error 67 = malloc(2) produced bad pointer.
# Error 68 = malloc(3) produced bad pointer.
# Error 69 = malloc(4) produced bad pointer.
# Error 70 = Memory manager does not have four blocks.
# Error 71 = Block four does not have the correct end.
# Error 72 = calloc produced bad pointer.
# Error 73 = Allocated block has bad end.
# Error 74 = Block found in empty array.
# Error 75 = Binary search did not find first block.
# Error 76 = Binary search did not find middle block.
# Error 77 = Binary search did not find last block.
# Error 78 = Block found before allocations.
# Error 79 = Block found after allocations.
# Error 80 = Tried to free unknown memory block.
# Error 81 = Tried getting cell at negative index.
# Error 82 = Tried popping cell at negative index.
# Error 83 = Tried popping cell beyond memory array.
# Error 84 = memory_manager_pop_cell(0)[1] != 30
# Error 85 = memory_manager_pop_cell(0)[0] != 21
# Error 86 = memory_manager_pop_cell(1)[1] != 40
# Error 87 = memory_manager_pop_cell(1)[0] != 31
# Error 88 = memory_manager_pop_cell(0)[1] != 20
# Error 89 = memory_manager_pop_cell(0)[0] != 11
# Error 90 = memory_manager_pop_cell(-1)[1] != 50
# Error 91 = memory_manager_pop_cell(-1)[0] != 41
# Error 92 = MM[0][0] != 1
# Error 93 = MM[1][0] != 51
# Error 94 = MM[2][0] != 76
# Error 95 = MM[3][0] != 101
# Error 96 = MM[4][0] != 201
# Error 97 = MM[5][0] != 251
# Error 98 = MM[6][0] != 276
# Error 99 = MM[6][1] != 375
# Error 100 = HEAP[-2] != 0
# Error 101 = Tried realloc unknown block.
# Error 102 = Did not get correct block size.
# Error 103 = Cannot deflate block to requested size.
# Error 104 = Tried setting a negative cell.
# Error 105 = Tried setting cell beyond array end.
# Error 106 = MM[0][1] != 20
# Error 107 = MM[0][0] != 11
# Error 108 = Could not deflate block size.
# Error 109 = Cannot inflate block to requested size.
# Error 110 = Could not inflate block size.
# Error 111 = Potential after was not calculated correctly.
# Error 112 = Potential before (0) was not calculated correctly.
# Error 113 = Potential before (1) was not calculated correctly.
# Error 114 = Compression vector (0) was not calculated correctly.
# Error 115 = Compression vector (1) was not calculated correctly.
# Error 116 = Wrong number of blocks allocated (should be 4).
# Error 117 = Wrong number of blocks allocated (should be 3).
# Error 118 = Memory does not compare equal.
# Error 119 = Wrong number of blocks allocated (should be 0).
# Error 120 = compare_memory given negative length.
# Error 121 = Cells did not evaluate to equal.
# Error 122 = !(Cell A > Cell B)
# Error 123 = !(Cell A < Cell B)
# Error 124 = Empty comparison does not return equal.
# Error 125 = Same address does not return equal.
# Error 126 = Same values do not return equal.
# Error 127 = First memory does not return greater than.
# Error 128 = First memory does not return less than.
# Error 129 = range has bad argument directions.
# Error 130 = Negative number should have negative direction.
# Error 131 = Zero number should have zero direction.
# Error 132 = Positive number should have positive direction.
# Error 133 = First range did not fill correctly.
# Error 134 = Second range did not fill correctly.
# Error 135 = Third range did not fill correctly.
# Error 136 = Fourth range did not fill correctly.
# Error 137 = Could not find block by pointer.
# Error 138 = First block size is incorrect.
# Error 139 = Second block size is incorrect.
# Error 140 = Third block size is incorrect.
# Error 141 = Mark did not perform correctly.
# Error 142 = Memory was not copied correctly.
# Error 143 = Block (h) does not have correct size.
# Error 144 = Block (j) does not have correct size.
# Error 145 = Blocks do not have same content.
# Error 146 = Block addresses do not match.
# Error 147 = stack[-1] was not correct.
# Error 148 = stack[-2] was not correct.
# Error 149 = stack[-3] was not correct.
# Error 150 = stack[-1] was not correct.
# Error 151 = stack[-2] was not correct.
# Error 152 = stack[-3] was not correct.
# Error 153 = Block should not have been moved.
# Error 154 = Size was not set correctly.
# Error 155 = Block should not have been moved.
# Error 156 = Size was not set correctly.
# Error 157 = Block should have been moved to front of memory.
# Error 158 = Size was not set correctly.
# Error 159 = Block was not correctly copied.
# Error 160 = Block was not moved to end of memory.
# Error 161 = Memory does not appear the same.
# Error 162 = Memory was not freed.
# Error 163 = Memory was not freed.
# Error 164 = Same memory was not returned.
# Error 165 = Memory size should not have changed.
# Error 166 = Same memory was not returned.
# Error 167 = Memory size is not correct.
# Error 168 = Memory was not moved to correct place.
# Error 169 = Memory size is not correct.
# Error 170 = Correct number of blocks not returned.
# Error 171 = Correct number of blocks not returned.
# Error 172 = Used memory not returned correctly.
# Error 173 = Used memory not returned correctly.
# Error 174 = Used memory not returned correctly.
# Error 175 = Negative argument not accepted.
# Error 176 = Array should have been empty.
# Error 177 = Array should have one value.
# Error 178 = Second item should refer to self.
# Error 179 = array and test should be the same.
# Error 180 = There should be two items in array.
# Error 181 = Second item should refer to array.
# Error 182 = Third item should refer to self.
# Error 183 = Null pointer should have been returned.
# Error 184 = Null pointer should have been returned.
# Error 185 = Pointer to first cell was not returned.
# Error 186 = Pointer to first cell was not returned.
# Error 187 = Pointer to first cell was not returned.
# Error 188 = Null pointer should have been returned.
# Error 189 = Null pointer should have been returned.
# Error 190 = Null pointer should have been returned.
# Error 191 = Pointer to second cell was not returned.
# Error 192 = Pointer to second cell was not returned.
# Error 193 = Pointer to second cell was not returned.
# Error 194 = Null pointer should have been returned.
# Error 195 = Null pointer should have been returned.
# Error 196 = Null pointer should have been returned.
# Error 197 = Pointer to third cell was not returned.
# Error 198 = Pointer to third cell was not returned.
# Error 199 = Pointer to third cell was not returned.
# Error 200 = Null pointer should have been returned.
# Error 201 = Cast should have returned 0.
# Error 202 = Cast should have returned 0.
# Error 203 = Cast should have returned 0.
# Error 204 = Cast should have returned 1.
# Error 205 = Cast should have returned 1.
# Error 206 = Cast should have returned 1.
# Error 207 = Cast should have returned 4294967295.
# Error 208 = Cast should have returned 4294967295.
# Error 209 = Cast should have returned 4294967295.
# Error 210 = Zero left shift was incorrect.
# Error 211 = Zero right shift was incorrect.
# Error 212 = Shift left by two was incorrect.
# Error 213 = Shift right by two was incorrect.
# Error 214 = Negative left shift was incorrect.
# Error 215 = Negative right shift was incorrect.
# Error 216 = value_to_array received a bad base.
# Error 217 = array_to_value received a bad base.
# Error 218 = Digit was too high for base.
# Error 219 = Cannot save stack size less than 1.
# Error 220 = Cannot load stack size less than 1.
# Error 221 = There is nothing in the array.
# Error 222 = Cannot load more than what is in array.
# Error 223 = Array length is not correct.
# Error 224 = Fourth element was not correct.
# Error 225 = Array length is not correct.
# Error 226 = First element was not correct.
# Error 227 = Sentinel value was not correct.
# Error 228 = Sanity check failed for save_stack.
# Error 229 = Full reload of stack failed.
# Error 230 = Full reload of stack failed.
# Error 231 = Single reload of stack failed.
# Error 232 = Double reload of stack failed.
# Error 233 = Array resize operation failed.
# Error 234 = Unexpected sum was detected.
# Error 235 = First div was not correct.
# Error 236 = First mod was not correct.
# Error 235 = Second div was not correct.
# Error 236 = Second mod was not correct.
# Error 235 = Third div was not correct.
# Error 236 = Third mod was not correct.
# Error 237 = First sum was not correct.
# Error 238 = Second sum was not correct.
# Error 239 = Third sum was not correct.
# Error 240 = Fourth sum was not correct.
# Error 241 = Fifth sum was not correct.
# Error 242 = Sixth sum was not correct.
# Error 243 = Length was not written correctly.
# Error 244 = Least significant digit is incorrect.
# Error 245 = Middle digit is incorrect.
# Error 246 = Most significant digit is incorrect.
# Error 247 = Second value was incorrect.
# Error 248 = Third value was incorrect.
# Error 249 = Fourth value was incorrect.
# Error 250 = Fifth value was incorrect.
# Error 251 = Zero was expected but not found.
# Error 252 = One through zero was expected but not found.
# Error 253 = Date in base thirteen was expected but not found.
# Error 254 = One hundred across bases was expected but not found.
# Error 255 = Value from bases two to three was expected but not found.
# Error 256 = First bit is not one.
# Error 257 = Last bit is not one.
# Error 258 = First bit is not zero.
# Error 259 = Last bit is not zero.
# Error 260 = The expected value (7) was not returned.
# Error 261 = The expected value (255) was not returned.
# Error 262 = The expected value (92051) was not returned.
# Error 263 = The expected value (1033010045) was not returned.
# Error 264 = The expected value (2554936947) was not returned.
# Error 265 = The expected value (1747467773) was not returned.
# Error 266 = The expected value (0) was not returned.
# Error 267 = The expected value (2153645760) was not returned.
# Error 268 = The expected value (4048040839) was not returned.
# Error 269 = The expected value (265376592) was not returned.
# Error 270 = The expected value (880511209) was not returned.
################################################################################
call "self_test"
exit
# def self_test():
# test_abs_diff()
# test_get_addr()
# test_clear()
# test_copy()
# test_memory_manager_append_cell()
# test_memory_manager_get_cell()
# test_memory_manager_insert_cell()
# test_malloc_check_beginning()
# test_malloc_check_ranges()
# test_malloc_ranges()
# test_malloc()
# test_calloc()
# test_memory_manager_search()
# test_memory_manager_pop_cell()
# test_free()
# test_memory_manager_get_block_size()
# test_memory_manager_set_cell()
# test_memory_manager_deflate_block()
# test_memory_manager_inflate_cell()
# test_memory_manager_potential_after()
# test_memory_manager_potential_before()
# test_memory_manager_compress()
# test_compare_cells()
# test_compare_memory()
# test_direction()
# test_range()
# test_memory_manager_size()
# test_mark()
# test_memory_manager_inflate_before()
# test_rotate_3_down()
# test_rotate_3_up()
# test_memory_manager_inflate_move()
# test_memory_manager_inflate_block()
# test_realloc()
# test_memory_manager_blocks()
# test_memory_manager_cells()
# test_memory_manager_pointers()
# test_memory_manager_find()
# test_uint_cast()
# test_shift()
# test_save_stack()
# test_load_stack()
# test_divmod()
# test_sum_length_array()
# test_value_to_array()
# test_array_to_value()
# test_uint_bits()
# test_uint_xor()
# test_memory_manager_hash()
# print('All 49 tests have passed.')
part "self_test"
call "test_abs_diff"
call "test_get_addr"
call "test_clear"
call "test_copy"
call "test_memory_manager_append_cell"
call "test_memory_manager_get_cell"
call "test_memory_manager_insert_cell"
call "test_malloc_check_beginning"
call "test_malloc_check_ranges"
call "test_malloc_ranges"
call "test_malloc"
call "test_calloc"
call "test_memory_manager_search"
call "test_memory_manager_pop_cell"
call "test_free"
call "test_memory_manager_get_block_size"
call "test_memory_manager_set_cell"
call "test_memory_manager_deflate_block"
call "test_memory_manager_inflate_cell"
call "test_memory_manager_potential_after"
call "test_memory_manager_potential_before"
call "test_memory_manager_compress"
call "test_compare_cells"
call "test_compare_memory"
call "test_direction"
call "test_range"
call "test_memory_manager_size"
call "test_mark"
call "test_memory_manager_inflate_before"
call "test_rotate_3_down"
call "test_rotate_3_up"
call "test_memory_manager_inflate_move"
call "test_memory_manager_inflate_block"
call "test_realloc"
call "test_memory_manager_blocks"
call "test_memory_manager_cells"
call "test_memory_manager_pointers"
call "test_memory_manager_find"
call "test_uint_cast"
call "test_shift"
call "test_save_stack"
call "test_load_stack"
call "test_divmod"
call "test_sum_length_array"
call "test_value_to_array"
call "test_array_to_value"
call "test_uint_bits"
call "test_uint_xor"
call "test_memory_manager_hash"
push 0
push 46
push 100
push 101
push 115
push 115
push 97
push 112
push 32
push 101
push 118
push 97
push 104
push 32
push 115
push 116
push 115
push 101
push 116
push 32
push 57
push 52
push 32
push 108
push 108
push 65
call "print_stack_c_string"
back
################################################################################
# def print_stack_c_string():
# while True:
# value = stack[-1]
# if not value:
# stack.pop()
# return
# print(chr(stack.pop()), end='')
part "print_stack_c_string"
copy
zero "__print_stack_c_string_return"
ochr
goto "print_stack_c_string"
part "__print_stack_c_string_return"
away
back
# def raise(error):
# print('Error:', error)
# sys.exit()
part "raise"
push 0
push 32
push 58
push 114
push 111
push 114
push 114
push 69
push 10
call "print_stack_c_string"
oint
push 10
ochr
exit
# def trace(reference):
# print('Trace:', reference)
part "trace"
push 0
push 32
push 58
push 101
push 99
push 97
push 114
push 84
push 10
call "print_stack_c_string"
oint
push 10
ochr
back
################################################################################
# def abs_diff(a, b):
# c = a - b
# if c < 0:
# return 0 - c
# return c
part "abs_diff"
sub
copy
less "__abs_diff_sign"
back
part "__abs_diff_sign"
push 0
swap
sub
back
# def get_addr(offset, start, end):
# if end < start:
# return start - offset
# return offset + start
part "get_addr"
copy 1
sub
less "__get_addr_reverse"
add
back
part "__get_addr_reverse"
swap
sub
back
# clear(start_addr, end_addr):
# if start_addr < end_addr:
# start_addr, end_addr = end_addr, start_addr
# while True:
# heap[end_addr] = 0
# if start_addr == end_addr:
# return
# end_addr += 1
part "clear"
copy 1
copy 1
sub
less "__clear_swap"
part "__clear_loop"
copy
push 0
set
copy 1
copy 1
sub
zero "__clear_return"
push 1
add
goto "__clear_loop"
part "__clear_swap"
swap
goto "__clear_loop"
part "__clear_return"
away
away
back
# def copy(from_start, from_end, to_start, to_end):
# if abs_diff(from_start, from_end) != abs_diff(to_start, to_end):
# raise Exception(1)
# offset = 0
# while True:
# to_addr = get_addr(offset, to_start, to_end)
# from_addr = get_addr(offset, from_start, from_end)
# heap[to_addr] = heap[from_addr]
# if to_addr == to_end:
# return
# offset += 1
part "copy"
copy 3
copy 3
call "abs_diff"
copy 2
copy 2
call "abs_diff"
sub
zero "__copy_no_arg_error"
push 1
call "raise"
part "__copy_no_arg_error"
push 0
part "__copy_loop"
copy
copy 3
copy 3
call "get_addr"
copy
copy 2
copy 7
copy 7
call "get_addr"
get
set
copy 2
sub
zero "__copy_return"
push 1
add
goto "__copy_loop"
part "__copy_return"
away 4
away
back
# def memory_manager_append_cell(start, end):
# heap[-2] += 1
# addr = -2 * heap[-2] - 1
# heap[addr] = start
# heap[addr - 1] = end
part "memory_manager_append_cell"
push -2
copy
copy
copy
get
push 1
add
set
get
mul
push 1
sub
copy
copy 3
set
push 1
sub
swap
set
away
back
# def memory_manger_get_cell(index):
# if index < 0:
# raise Exception(81)
# if index < HEAP[-2]:
# address = -2 * index - 3
# start_addr = HEAP[address]
# stop_addr = HEAP[address - 1]
# return start_addr, stop_addr
# raise Exception(27)
part "memory_manager_get_cell"
copy
less "__memory_manager_get_cell_under_zero"
copy
push -2
get
sub
less "__memory_manager_get_cell_in_range"
push 27
call "raise"
part "__memory_manager_get_cell_under_zero"
push 81
call "raise"
part "__memory_manager_get_cell_in_range"
push -2
mul
push 3
sub
copy
get
swap
push 1
sub
get
back
# def memory_manager_insert_cell(start, end, index):
# if index < 0:
# raise Exception(32)
# if index - HEAP[-2] < 0:
# address = -2 * index - 3
# from_end = (HEAP[-2] + 1) * -2
# from_start, from_end = from_end, address
# to_start = address - 2
# to_end = from_end - 2
# copy(from_start, from_end, to_start, to_end)
# HEAP[address - 1] = end
# HEAP[address] = start
# HEAP[-2] += 1
# else:
# memory_manager_append_cell(start, end)
part "memory_manager_insert_cell"
copy
less "__memory_manager_insert_cell_bad_index"
copy
push -2
get
sub
less "__memory_manager_insert_cell_continue"
away
call "memory_manager_append_cell"
back
part "__memory_manager_insert_cell_bad_index"
push 32
call "raise"
part "__memory_manager_insert_cell_continue"
push -2
mul
push 3
sub
copy
push -2
push 1
push -2
get
add
mul
swap
copy 1
push 2
sub
copy 1
push 2
sub
call "copy"
swap
copy 1
push 1
sub
swap
set
swap
set
push -2
copy
get
push 1
add
set
back
# def malloc_check_beginning(cells):
# start = memory_manager_get_cell(0)[0]
# open_space = start - HEAP[-1]
# if cells > open_space:
# return False
# start = HEAP[-1]
# end = cells + start - 1
# memory_manager_insert_cell(start, end, 0)
# return True
part "malloc_check_beginning"
copy
push 0
call "memory_manager_get_cell"
away
push -1
get
sub
sub
copy
less "__malloc_check_beginning_insert"
copy
zero "__malloc_check_beginning_insert"
push 0
away 2
back
part "__malloc_check_beginning_insert"
away
push -1
get
swap
copy 1
add
push 1
sub
push 0
call "memory_manager_insert_cell"
push 1
back
# def malloc_check_ranges(cells):
# if HEAP[-2] >= 2:
# index = 0
# while index + 1 < HEAP[-2]:
# end = memory_manager_get_cell(index)[1]
# start = memory_manager_get_cell(index + 1)[0]
# empty_space = end - start
# excess = empty_space + cells
# if excess < 0:
# location = index + 1
# end = memory_manager_get_cell(index)[1]
# new_end = end + cells
# new _start = end + 1
# memory_manager_insert_cell(new_start, new_end, location)
# return location
# index += 1
# return -1
part "malloc_check_ranges"
push -2
copy
get
add
less "__malloc_check_ranges_unable"
push 0
part "__malloc_check_ranges_loop_check"
copy
push 1
add
push -2
get
sub
less "__malloc_check_ranges_loop_body"
away
part "__malloc_check_ranges_unable"
away
push -1
back
part "__malloc_check_ranges_loop_body"
copy
call "memory_manager_get_cell"
away 1
copy 1
push 1
add
call "memory_manager_get_cell"
away
sub
copy 2
add
less "__malloc_check_ranges_found"
push 1
add
goto "__malloc_check_ranges_loop_check"
part "__malloc_check_ranges_found"
copy
push 1
add
swap
call "memory_manager_get_cell"
away 1
copy
copy 3
add
swap
push 1
add
swap
copy 2
call "memory_manager_insert_cell"
away 1
back
# def malloc_ranges(cells):
# if malloc_check_beginning(cells):
# return HEAP[-1]
# index = malloc_check_ranges(cells)
# if index == -1:
# address = -2 * HEAP[-2] - 2
# end = HEAP[address]
# new_end = end + cells
# new start = end + 1
# memory_manager_append_cell(new_start, new_end)
# return new_start
# return memory_manager_get_cell(index)[0]
part "malloc_ranges"
copy
call "malloc_check_beginning"
zero "__malloc_ranges_not_beginning"
away
push -1
get
back
part "__malloc_ranges_not_beginning"
copy
call "malloc_check_ranges"
copy
push 1
add
zero "__malloc_ranges_append"
call "memory_manager_get_cell"
swap
away 2
back
part "__malloc_ranges_append"
away
push -2
copy
copy
get
mul
add
get
swap
copy 1
add
swap
push 1
add
swap
copy 1
swap
call "memory_manager_append_cell"
back
# def malloc(cells):
# if cells <= 0:
# raise Exception(41)
# if not heap[-2]:
# start = heap[-1]
# end = start + cells - 1
# memory_manager_append_cell(start, end)
# return start
# return malloc_ranges(cells)
part "malloc"
copy
less "__malloc_bad_argument"
copy
zero "__malloc_bad_argument"
push -2
get
zero "__malloc_start"
call "malloc_ranges"
back
part "__malloc_bad_argument"
push 41
call "raise"
part "__malloc_start"
push -1
get
copy
copy
copy 3
add
push 1
sub
call "memory_manager_append_cell"
away 1
back
# def calloc(block_count, block_size):
# return malloc(block_count * block_size)
part "calloc"
mul
call "malloc"
back
# def memory_manager_search(pointer):
# size = HEAP[-2]
# if not size:
# return -1
# last = size - 1
# first = 0
# while first <= last:
# index = (last + first) // 2
# value = memory_manager_get_cell(index)[0]
# if value < pointer:
# first = index + 1
# elif value == pointer:
# return index
# else:
# last = index - 1
# return -1
part "memory_manager_search"
push -2
get
copy
zero "__memory_manager_search_not_found"
push 1
sub
push 0
part "__memory_manager_search_loop_test"
copy
copy 2
sub
copy
less "__memory_manager_search_loop_body_away"
zero "__memory_manager_search_loop_body"
goto "__memory_manager_search_not_found_away"
part "__memory_manager_search_loop_body_away"
away
part "__memory_manager_search_loop_body"
copy 1
copy 1
add
push 2
div
copy
call "memory_manager_get_cell"
away
copy 4
sub
copy
less "__memory_manager_search_high"
zero "__memory_manager_search_return"
push 1
sub
swap
push 0
swap
set
away 1
push 0
get
goto "__memory_manager_search_loop_test"
part "__memory_manager_search_return"
away 3
back
part "__memory_manager_search_high"
away
away 1
push 1
add
goto "__memory_manager_search_loop_test"
part "__memory_manager_search_not_found_away"
away
part "__memory_manager_search_not_found"
push -1
away 2
back
# def memory_manager_pop_cell(index):
# if index == -1:
# index = HEAP[-2] - 1
# if index < 0:
# raise Exception(82)
# if index < HEAP[-2]:
# a, b = memory_manager_get_cell(index)
# HEAP[-2] -= 1
# if index != HEAP[-2]:
# from_start = -2 * index - 5
# from_end = (HEAP[-2] + 2) * -2
# to_start = from_start + 2
# to_end = from_end + 2
# copy(from_start, from_end, to_start, to_end)
# start = -2 * HEAP[-2] - 3
# end = start - 1
# clear(start, end)
# return a, b
# raise Exception(83)
part "memory_manager_pop_cell"
copy
push 1
add
zero "__memory_manager_pop_cell_last_cell"
part "__memory_manager_pop_cell_negative_index_check"
copy
less "__memory_manager_pop_cell_negative_index_raise"
copy
push -2
get
sub
less "__memory_manager_pop_cell_index_okay"
push 83
call "raise"
part "__memory_manager_pop_cell_index_okay"
copy
call "memory_manager_get_cell"
push -1
push -2
get
add
copy
push -2
swap
set
copy
copy 4
sub
zero "__memory_manager_pop_cell_clear_end"
push -5
push -2
copy 5
mul
add
push -2
push 2
copy 3
add
mul
copy 1
push 2
add
copy 1
push 2
add
call "copy"
part "__memory_manager_pop_cell_clear_end"
push -2
mul
push 3
sub
copy
push 1
sub
call "clear"
push 0
swap
set
away 1
push 0
get
back
part "__memory_manager_pop_cell_negative_index_raise"
push 82
call "raise"
part "__memory_manager_pop_cell_last_cell"
push -2
get
add
goto "__memory_manager_pop_cell_negative_index_check"
# def free(pointer):
# index = memory_manager_search(pointer)
# if index == -1:
# raise Exception(80)
# memory_manager_pop_cell(index)
part "free"
call "memory_manager_search"
copy
push 1
add
zero "__free_not_found"
call "memory_manager_pop_cell"
away
away
back
part "__free_not_found"
push 80
call "raise"
back
# def memory_manager_get_block_size(index):
# start, end = memory_manager_get_cell(index)
# return end - start + 1
part "memory_manager_get_block_size"
call "memory_manager_get_cell"
swap
sub
push 1
add
back
# def memory_manager_set_cell(start, end, index):
# if index < 0:
# raise Exception(104)
# if index < HEAP[-2]:
# address = -2 * index - 4
# HEAP[address] = end
# HEAP[address + 1] = start
# return
# raise Exception(105)
part "memory_manager_set_cell"
copy
less "__memory_manager_set_cell_negative"
copy
push -2
get
sub
less "__memory_manager_set_cell_in_range"
push 105
call "raise"
part "__memory_manager_set_cell_negative"
push 104
call "raise"
part "__memory_manager_set_cell_in_range"
push -2
mul
push 4
sub
copy
copy 2
set
push 1
add
away 1
swap
set
back
# def memory_manager_deflate_block(cells, index):
# size = memory_manager_get_block_size(index)
# if cells < size:
# start, end = memory_manager_get_cell(index)
# end = start + cells - 1
# memory_manager_set_cell(start, end, index)
# return
# raise Exception(103)
part "memory_manager_deflate_block"
copy
call "memory_manager_get_block_size"
copy 2
swap
sub
less "__memory_manager_deflate_block_continue"
push 103
call "raise"
part "__memory_manager_deflate_block_continue"
copy
call "memory_manager_get_cell"
away
copy
copy 3
push 1
sub
add
copy 2
call "memory_manager_set_cell"
away
away
back
# def memory_manager_inflate_cell(cells, index):
# size = memory_manager_get_block_size(index)
# if size < cells:
# start, end = memory_manager_get_cell(index)
# end = start + cells - 1
# memory_manager_set_cell(start, end, index)
# return
# raise Exception(109)
part "memory_manager_inflate_cell"
copy
call "memory_manager_get_block_size"
copy 2
sub
less "__memory_manager_inflate_cell_continue"
push 109
call "raise"
part "__memory_manager_inflate_cell_continue"
copy
call "memory_manager_get_cell"
away
copy
copy 3
push 1
sub
add
copy 2
call "memory_manager_set_cell"
away
away
back
# def memory_manager_potential_after(index):
# size = memory_manager_get_block_size(index)
# start = memory_manager_get_cell(index + 1)[0]
# end = memory_manager_get_cell(index)[1]
# empty = start - end - 1
# return size + empty
part "memory_manager_potential_after"
copy
call "memory_manager_get_block_size"
copy 1
push 1
add
call "memory_manager_get_cell"
away
copy 2
call "memory_manager_get_cell"
away 1
sub
push 1
sub
add
away 1
back
# def memory_manager_potential_before(index):
# if index == 0:
# head = HEAP[-3]
# start = HEAP[-1]
# space = head - start
# else:
# start = memory_manager_get_cell(index)[0]
# end = memory_manager_get_cell(index - 1)[1]
# space = start - end - 1
# return space + memory_manager_potential_after(index)
part "memory_manager_potential_before"
copy
zero "__memory_manager_potential_before_head"
copy
call "memory_manager_get_cell"
away
copy 1
push 1
sub
call "memory_manager_get_cell"
away 1
sub
push 1
sub
goto "__memory_manager_potential_before_total"
part "__memory_manager_potential_before_head"
push -3
get
push -1
get
sub
part "__memory_manager_potential_before_total"
copy 1
call "memory_manager_potential_after"
add
away 1
back
# def memory_manager_compress(index):
# if index == 0:
# return HEAP[-1]
# return memory_manager_get_cell(index - 1)[1] + 1
part "memory_manager_compress"
copy
zero "__memory_manager_compress_start"
push 1
sub
call "memory_manager_get_cell"
away 1
push 1
add
back
part "__memory_manager_compress_start"
away
push -1
get
back
# compare_cells(addr_a, addr_b):
# b = HEAP[addr_b]
# a = HEAP[addr_a]
# if b == a:
# return 0
# if b < a:
# return 1
# return -1
part "compare_cells"
get
swap
get
sub
copy
zero "__compare_cells_equal"
less "__compare_cells_greater"
push -1
back
part "__compare_cells_greater"
push 1
back
part "__compare_cells_equal"
push 0
away 1
back
# def compare_memory(a, b, length):
# if length < 0:
# raise Exception(120)
# if length == 0:
# return 0
# if a == b:
# return 0
# offset = 0
# while offset < length:
# addr_a = a + offset
# addr_b = b + offset
# value = compare_cells(addr_a, addr_b)
# if value == 0:
# offset += 1
# elif value < 0:
# return -1
# else:
# return 1
# return 0
part "compare_memory"
copy
less "__compare_memory_negative_length"
copy
zero "__compare_memory_equal_buffers"
copy 2
copy 2
sub
zero "__compare_memory_equal_buffers"
push 0
part "__compare_memory_loop_test"
copy
copy 2
sub
less "__compare_memory_loop_body"
away
part "__compare_memory_equal_buffers"
push 0
away 3
back
part "__compare_memory_negative_length"
push 120
call "raise"
part "__compare_memory_loop_body"
copy 3
copy 1
add
copy 3
copy 2
add
call "compare_cells"
copy
zero "__compare_memory_inc_offset"
less "__compare_memory_less_than"
push 1
away 4
back
part "__compare_memory_less_than"
push -1
away 4
back
part "__compare_memory_inc_offset"
away
push 1
add
goto "__compare_memory_loop_test"
# def direction(number):
# if number:
# if number > 0:
# return 1
# return -1
# return number
part "direction"
copy
zero "__direction_zero"
less "__direction_negative"
push 1
back
part "__direction_negative"
push -1
part "__direction_zero"
back
# def range(address, start, stop, step):
# if direction(stop - start) != direction(step):
# raise Exception(129)
# value = start
# while (value > stop) if direction(step) < 0 else (value < stop):
# offset = (value - start) // step
# HEAP[offset + address] = value
# value += step
part "range"
copy 1
copy 3
sub
call "direction"
copy 1
call "direction"
sub
zero "__range_loop_setup"
push 129
call "raise"
part "__range_loop_setup"
copy 2
part "__range_loop_test"
copy
copy 3
copy 3
call "direction"
less "__range_switch_compare"
part "__range_do_compare"
sub
less "__range_loop_body"
away 4
away
back
part "__range_switch_compare"
swap
goto "__range_do_compare"
part "__range_loop_body"
copy
copy 4
sub
copy 2
div
copy 5
add
copy 1
set
copy 1
add
goto "__range_loop_test"
# def memory_manager_size(pointer):
# index = memory_manager_search(pointer)
# if index < 0:
# raise Exception(137)
# a, b = memory_manager_get_cell(index)
# return b - a + 1
part "memory_manager_size"
call "memory_manager_search"
copy
less "__memory_manager_size_not_found"
call "memory_manager_get_cell"
swap
sub
push 1
add
back
part "__memory_manager_size_not_found"
push 137
call "raise"
back
# def mark(pointer):
# size = memory_manager_size(pointer)
# range(pointer, 1, size + 1, 1)
part "mark"
push 1
copy 1
call "memory_manager_size"
push 1
add
push 1
call "range"
back
# def memory_manager_inflate_before(pointer, cells, index):
# from_start, from_end = memory_manager_get_cell(index)
# to_start = memory_manager_compress(index)
# to_end = to_start + from_end - from_start
# copy(from_start, from_end, to_start, to_end)
# to_end = to_start + cells - 1
# memory_manager_set_cell(to_start, to_end, index)
# return to_start
part "memory_manager_inflate_before"
copy
call "memory_manager_get_cell"
copy 2
call "memory_manager_compress"
copy
copy 2
copy 4
sub
add
push 0
copy 2
set
call "copy"
push 0
get
copy
copy
copy 4
add
push 1
sub
copy 3
call "memory_manager_set_cell"
away 3
back
# def rotate_3_down():
# HEAP[0] = stack.pop()
# stack[-1], stack[-2] = stack[-2], stack[-1]
# stack.push(HEAP[0])
# stack[-1], stack[-2] = stack[-2], stack[-1]
part "rotate_3_down"
push 0
swap
set
swap
push 0
get
swap
back
# def rotate_3_up():
# stack[-1], stack[-2] = stack[-2], stack[-1]
# HEAP[0] = stack.pop()
# stack[-1], stack[-2] = stack[-2], stack[-1]
# stack.push(HEAP[0])
part "rotate_3_up"
swap
push 0
swap
set
swap
push 0
get
back
# def memory_manager_inflate_move(pointer, cells, index):
# from_start, from_end = memory_manager_get_cell(index)
# new = malloc(cells)
# to_start = new
# to_end = new + from_end - from_start
# copy(from_start, from_end, to_start, to_end)
# free(pointer)
# return new
part "memory_manager_inflate_move"
call "memory_manager_get_cell"
call "rotate_3_down"
call "malloc"
call "rotate_3_up"
copy 2
copy
copy 2
add
copy 3
sub
call "copy"
swap
call "free"
back
# def memory_manager_inflate_block(pointer, cells, index):
# if index == HEAP[-2] - 1:
# memory_manager_inflate_cell(cells, index)
# return pointer
# potential = memory_manager_potential_after(index)
# if potential < cells:
# potential = memory_manager_potential_before(index)
# if potential < cells:
# return memory_manager_inflate_move(pointer, cells, index)
# return memory_manager_inflate_before(pointer, cells, index)
# memory_manager_inflate_cell(cells, index)
# return pointer
part "memory_manager_inflate_block"
copy
push -2
get
push 1
sub
sub
zero "__memory_manager_inflate_block_cell"
copy
call "memory_manager_potential_after"
copy 2
sub
less "__memory_manager_inflate_block_not_after"
part "__memory_manager_inflate_block_cell"
call "memory_manager_inflate_cell"
back
part "__memory_manager_inflate_block_not_after"
copy
call "memory_manager_potential_before"
copy 2
sub
less "__memory_manager_inflate_block_not_before"
call "memory_manager_inflate_before"
back
part "__memory_manager_inflate_block_not_before"
call "memory_manager_inflate_move"
back
# def realloc(pointer, cells):
# if cells <= 0:
# free(pointer)
# return 0
# index = memory_manager_search(pointer)
# if index == -1:
# raise Exception(101)
# size = memory_manager_get_block_size(index)
# if cells == size:
# return pointer
# if cells < size:
# memory_manager_deflate_block(cells, index)
# return pointer
# return memory_manager_inflate_block(pointer, cells, index)
part "realloc"
copy
less "__realloc_free"
copy
zero "__realloc_free"
copy 1
call "memory_manager_search"
copy
push 1
add
zero "__realloc_not_found"
copy
call "memory_manager_get_block_size"
copy 2
swap
sub
copy
zero "__realloc_return_pointer"
less "__realloc_return_deflate"
call "memory_manager_inflate_block"
back
part "__realloc_free"
away
call "free"
push 0
back
part "__realloc_not_found"
push 101
call "raise"
part "__realloc_return_pointer"
away 2
away
back
part "__realloc_return_deflate"
call "memory_manager_deflate_block"
back
# def memory_manager_blocks():
# return HEAP[-2]
part "memory_manager_blocks"
push -2
get
back
# def memory_manager_cells():
# blocks = HEAP[-2]
# index = 0
# total = 0
# while index < blocks:
# addr = (index + 2) * -2
# end = HEAP[addr]
# start = HEAP[addr + 1]
# size = end - start + 1
# total += size
# index += 1
# return total
part "memory_manager_cells"
push -2
get
push 0
push 0
part "__memory_manager_cells_loop_test"
copy 1
copy 3
sub
less "__memory_manager_cells_loop_body"
away 2
back
part "__memory_manager_cells_loop_body"
copy 1
push 2
add
push -2
mul
copy
get
swap
push 1
add
get
sub
push 1
add
add
swap
push 1
add
swap
goto "__memory_manager_cells_loop_test"
# def memory_manager_pointers(include_self):
# bool = direction(include_self)
# if bool < 0:
# raise Exception(175)
# pointer_count = HEAP[-2] + bool
# array_length = pointer_count + 1
# array = malloc(array_length)
# HEAP[array] = pointer_count
# mm_size = HEAP[-2]
# array_address = array + 1
# index = 0
# while index < mm_size:
# mm_addr = -2 * index - 3
# pointer = HEAP[mm_addr]
# if pointer != array or bool:
# HEAP[array_address] = pointer
# array_address += 1
# index += 1
# return array
part "memory_manager_pointers"
call "direction"
copy
less "__memory_manager_pointers_bad_bool"
copy
push -2
get
add
copy
push 1
add
call "malloc"
swap
copy 1
swap
set
push -2
get
copy 1
push 1
add
push 0
part "__memory_manager_pointers_loop_test"
copy
copy 3
sub
less "__memory_manager_pointers_loop_body"
away
away
away
away 1
back
part "__memory_manager_pointers_bad_bool"
push 175
call "raise"
part "__memory_manager_pointers_loop_body"
copy
push -2
mul
push 3
sub
get
copy
copy 5
sub
zero "__memory_manager_pointers_check_bool"
part "__memory_manager_pointers_add_pointer"
copy 2
swap
set
swap
push 1
add
swap
part "__memory_manager_pointers_inc_index"
push 1
add
goto "__memory_manager_pointers_loop_test"
part "__memory_manager_pointers_check_bool"
copy 5
zero "__memory_manager_pointers_away_inc_index"
goto "__memory_manager_pointers_add_pointer"
part "__memory_manager_pointers_away_inc_index"
away
goto "__memory_manager_pointers_inc_index"
# def memory_manager_find(address):
# size = HEAP[-2]
# if not size:
# return 0
# last = size - 1
# first = 0
# while first <= last:
# index = (last + first) // 2
# addr = -2 * index - 4
# b = HEAP[addr]
# a = HEAP[addr + 1]
# if a <= address <= b:
# return a
# if a < address:
# first = index + 1
# else:
# last = index - 1
# return 0
part "memory_manager_find"
push -2
get
copy
zero "__memory_manager_find_null"
push 1
sub
push 0
part "__memory_manager_find_loop_test"
copy
copy 2
sub
copy
less "__memory_manager_find_loop_body_away"
zero "__memory_manager_find_loop_body"
away
part "__memory_manager_find_null"
push 0
away 2
back
part "__memory_manager_find_loop_body_away"
away
part "__memory_manager_find_loop_body"
copy 1
copy 1
add
push 2
div
copy
push -2
mul
push 4
sub
copy
get
swap
push 1
add
get
copy
copy 6
sub
copy
less "__memory_manager_find_check_b_away"
zero "__memory_manager_find_check_b"
away 1
part "__memory_manager_find_divide"
copy 4
sub
less "__memory_manager_find_upper"
push 1
sub
push 0
swap
set
away 1
push 0
get
swap
goto "__memory_manager_find_loop_test"
part "__memory_manager_find_upper"
away 1
push 1
add
goto "__memory_manager_find_loop_test"
part "__memory_manager_find_check_b_away"
away
part "__memory_manager_find_check_b"
swap
copy 5
swap
sub
copy
less "__memory_manager_find_return_away"
zero "__memory_manager_find_return"
goto "__memory_manager_find_divide"
part "__memory_manager_find_return_away"
away
part "__memory_manager_find_return"
away 4
back
# def uint_cast(number):
# return number % 4294967296
part "uint_cast"
push 4294967296
mod
back
# def left_shift(number, shift):
# if not shift:
# return number
# if shift < 0:
# return right_shift(number, -shift)
# while shift:
# number *= 2
# shift -= 1
# return number
part "left_shift"
copy
zero "__left_shift_return"
copy
less "__left_shift_reverse"
part "__left_shift_loop"
copy
zero "__left_shift_return"
swap
push 2
mul
swap
push 1
sub
goto "__left_shift_loop"
part "__left_shift_return"
away
back
part "__left_shift_reverse"
push 0
swap
sub
call "right_shift"
back
# def right_shift(number, shift):
# if not shift:
# return number
# if shift < 0:
# return left_shift(number, -shift)
# while shift:
# number //= 2
# shift -= 1
# return number
part "right_shift"
copy
zero "__right_shift_return"
copy
less "__right_shift_reverse"
part "__right_shift_loop"
copy
zero "__right_shift_return"
swap
push 2
div
swap
push 1
sub
goto "__right_shift_loop"
part "__right_shift_return"
away
back
part "__right_shift_reverse"
push 0
swap
sub
call "left_shift"
back
# def save_stack(size):
# if size < 1:
# raise Exception(219)
# array = malloc(size + 1)
# array[0] = size
# temp = malloc(3)
# temp[0] = array // array
# temp[1] = size // size
# temp[2] = 1 // offset
# while temp[2] <= temp[1]:
# temp[0][temp[2]] = stack.pop()
# temp[2] += 1
# array = temp[0]
# free(temp)
# return array
part "save_stack"
copy
push 1
sub
less "__save_stack_bad_size"
copy
push 1
add
call "malloc"
copy
copy 2
set
push 3
call "malloc"
swap
copy 1
swap
set
swap
copy 1
push 1
add
swap
set
copy
push 2
add
push 1
set
part "__save_stack_loop_test"
copy
push 2
add
get
copy 1
push 1
add
get
sub
copy
less "__save_stack_loop_body_away"
zero "__save_stack_loop_body"
copy
get
swap
call "free"
back
part "__save_stack_bad_size"
push 219
call "raise"
part "__save_stack_loop_body_away"
away
part "__save_stack_loop_body"
copy
get
copy 1
push 2
add
get
add
call "rotate_3_down"
set
copy
push 2
add
copy
get
push 1
add
set
goto "__save_stack_loop_test"
# def load_stack(array, size):
# if size < 1:
# raise Exception(220)
# array_size = array[0]
# if array_size < 1:
# raise Exception(221)
# if array_size < size:
# raise Exception(222)
# addr = array + array_size
# temp = malloc(3)
# temp[0] = addr
# temp[1] = size
# temp[2] = array
# while temp[1] != 0:
# addr = temp[0]
# value = HEAP[addr]
# stack.push(value)
# temp[0] -= 1
# temp[1] -= 1
# array = temp[2]
# diff = array - temp[0]
# if diff < 0:
# array[0] = -diff
# else:
# free(array)
# free(temp)
part "load_stack"
copy
push 1
sub
less "__load_stack_bad_size"
copy 1
get
copy
push 1
sub
less "__load_stack_bad_array"
copy
copy 2
sub
less "__load_stack_size_greater_than_array"
copy 2
add
push 3
call "malloc"
swap
copy 1
swap
set
swap
copy 1
push 1
add
swap
set
swap
copy 1
push 2
add
swap
set
part "__load_stack_loop_test"
copy
push 1
add
get
zero "__load_stack_end_loop"
copy
get
get
swap
copy
copy
get
push 1
sub
set
copy
push 1
add
copy
get
push 1
sub
set
goto "__load_stack_loop_test"
part "__load_stack_bad_size"
push 220
call "raise"
part "__load_stack_bad_array"
push 221
call "raise"
part "__load_stack_size_greater_than_array"
push 222
call "raise"
part "__load_stack_end_loop"
copy
push 2
add
get
copy
copy 2
get
sub
copy
less "__load_stack_set_length"
away
call "free"
call "free"
back
part "__load_stack_set_length"
push -1
mul
set
call "free"
back
# def divmod(a, b):
# x = a // b
# y = a % b
# return x, y
part "divmod"
copy 1
copy 1
div
call "rotate_3_up"
mod
back
# def sum_length_array(array):
# index = 1
# total = 0
# while index <= array[0]:
# total += array[index]
# index += 1
# return total
part "sum_length_array"
push 1
push 0
part "__sum_length_array_loop_test"
copy 1
copy 3
get
sub
copy
less "__sum_length_array_loop_body_away"
zero "__sum_length_array_loop_body"
away 2
back
part "__sum_length_array_loop_body_away"
away
part "__sum_length_array_loop_body"
copy 2
copy 2
add
get
add
swap
push 1
add
swap
goto "__sum_length_array_loop_test"
# def value_to_array(value, base):
# if base < 2:
# raise Exception(216)
# size = 8 + 1
# array = malloc(size)
# offset = 1
# while value:
# if offset == size:
# size = size * 2 - 1
# array = realloc(array, size)
# value, digit = divmod(value, base)
# array[offset] = digit
# offset += 1
# if size != offset:
# array = realloc(array, offset)
# array[0] = offset - 1
# return array
part "value_to_array"
copy
push 2
sub
less "__value_to_array_bad_base"
swap
push 8
push 1
add
swap
copy 1
call "malloc"
swap
push 1
swap
part "__value_to_array_loop_test"
copy
zero "__value_to_array_loop_end"
copy 1
copy 4
sub
zero "__value_to_array_adjust_array_size"
part "__value_to_array_get_digit"
copy 4
call "divmod"
copy 3
copy 3
add
swap
set
swap
push 1
add
swap
goto "__value_to_array_loop_test"
part "__value_to_array_bad_base"
push 216
call "raise"
part "__value_to_array_loop_end"
copy 3
copy 2
sub
zero "__value_to_array_skip_resize"
call "rotate_3_down"
copy 2
call "realloc"
call "rotate_3_up"
part "__value_to_array_skip_resize"
away
copy 1
copy 1
push 1
sub
set
away
away 2
back
part "__value_to_array_adjust_array_size"
push 3
call "save_stack"
swap
push 2
mul
push 1
sub
swap
copy
push 1
call "load_stack"
copy 2
call "realloc"
swap
push 2
call "load_stack"
goto "__value_to_array_get_digit"
# def array_to_value(array, base):
# if base < 2:
# raise Exception(217)
# if array[0] == 0:
# return 0
# addr = array + array[0]
# value = 0
# while addr != array:
# value *= base
# tentative = HEAP[addr]
# if tentative < base:
# value += tentative
# addr -= 1
# else:
# raise Exception(218)
# return value
part "array_to_value"
copy
push 2
sub
less "__array_to_value_bad_base"
copy 1
get
zero "__array_to_value_return_zero"
copy 1
copy
get
add
push 0
part "__array_to_value_loop_test"
copy 3
copy 2
sub
zero "__array_to_value_return"
copy 2
mul
copy 1
get
copy
copy 4
sub
less "__array_to_value_loop_continue"
push 218
call "raise"
part "__array_to_value_loop_continue"
add
swap
push 1
sub
swap
goto "__array_to_value_loop_test"
part "__array_to_value_bad_base"
push 217
call "raise"
part "__array_to_value_return_zero"
push 0
away 2
back
part "__array_to_value_return"
away 3
back
# def uint_bits(number):
# integer = uint_cast(number)
# array = value_to_array(integer, 2)
# size = array[0]
# bits = malloc(32)
# clear(bits, bits + 31)
# if size != 0:
# from_start = array + 1
# from_end = array + size
# to_start = bits
# to_end = bits + size - 1
# copy(from_start, from_end, to_start, to_end)
# free(array)
# return bits
part "uint_bits"
call "uint_cast"
push 2
call "value_to_array"
copy
get
push 32
call "malloc"
copy
copy
push 31
add
call "clear"
copy 1
zero "__uint_bits_skip_copy"
copy 2
push 1
add
copy 3
copy 3
add
copy 2
copy
copy 5
add
push 1
sub
call "copy"
part "__uint_bits_skip_copy"
away 1
swap
call "free"
back
# def uint_xor(a, b):
# b = uint_bits(b)
# a = uint_bits(a)
# xor = malloc(33)
# xor[0] = 32
# offset = 0
# while offset < 32:
# b_bit = b[offset]
# a_bit = a[offset]
# offset += 1
# if b_bit != a_bit:
# xor[offset] = True
# else:
# xor[offset] = False
# free(a)
# free(b)
# value = array_to_value(xor, 2)
# free(xor)
# return value
part "uint_xor"
call "uint_bits"
swap
call "uint_bits"
push 33
call "malloc"
copy
push 32
set
push 0
part "__uint_xor_loop_test"
copy
push 32
sub
less "__uint_xor_loop_body"
away
call "rotate_3_up"
call "free"
call "free"
copy
push 2
call "array_to_value"
swap
call "free"
back
part "__uint_xor_loop_body"
copy 3
copy 1
add
get
copy 3
copy 2
add
get
sub
swap
push 1
add
swap
zero "__uint_xor_bit_is_false"
copy 1
copy 1
add
push 1
set
goto "__uint_xor_loop_test"
part "__uint_xor_bit_is_false"
copy 1
copy 1
add
push 0
set
goto "__uint_xor_loop_test"
# def memory_manager_hash():
# length = HEAP[-2]
# if length == 0:
# return 0
# length *= 2
# hash = uint_cast(left_shift(HEAP[-3], 7))
# offset = 0
# while offset < length:
# hash = uint_cast(hash * 1000003)
# hash = uint_xor(hash, HEAP[-3 - offset])
# offset += 1
# return uint_xor(hash, HEAP[-2])
part "memory_manager_hash"
push -2
get
copy
zero "__memory_manager_hash_return"
push 2
mul
push -3
get
push 7
call "left_shift"
call "uint_cast"
push 0
part "__memory_manager_hash_loop_test"
copy
copy 3
sub
less "__memory_manager_hash_loop_body"
away
away 1
push -2
get
call "uint_xor"
part "__memory_manager_hash_return"
back
part "__memory_manager_hash_loop_body"
swap
push 1000003
mul
call "uint_cast"
push -3
copy 2
sub
get
call "uint_xor"
swap
push 1
add
goto "__memory_manager_hash_loop_test"
################################################################################
# def test_abs_diff():
# if abs_diff(2, 1) != 1:
# raise Exception(2)
# if abs_diff(1, 2) != 1:
# raise Exception(3)
part "test_abs_diff"
push 1
push 2
push 1
call "abs_diff"
sub
zero "__test_abs_diff_okay"
push 2
call "raise"
part "__test_abs_diff_okay"
push 1
push 1
push 2
call "abs_diff"
sub
zero "__test_abs_diff_return"
push 3
call "raise"
part "__test_abs_diff_return"
back
# get test_get_addr():
# if get_addr(1, 1, 4) != 2:
# raise Exception(4)
# if get_addr(2, 1, 4) != 3:
# raise Exception(4)
# if get_addr(1, 4, 1) != 3:
# raise Exception(4)
# if get_addr(2, 4, 1) != 2:
# raise Exception(4)
part "test_get_addr"
push 2
push 1
push 1
push 4
call "get_addr"
sub
zero "__test_get_addr_2"
push 4
call "raise"
part "__test_get_addr_2"
push 3
push 2
push 1
push 4
call "get_addr"
sub
zero "__test_get_addr_3"
push 5
call "raise"
part "__test_get_addr_3"
push 3
push 1
push 4
push 1
call "get_addr"
sub
zero "__test_get_addr_4"
push 6
call "raise"
part "__test_get_addr_4"
push 2
push 2
push 4
push 1
call "get_addr"
sub
zero "__test_get_addr_return"
push 7
call "raise"
part "__test_get_addr_return"
back
# def test_clear():
# heap[1] = 1
# heap[2] = 2
# clear(1, 2)
# if heap[1]:
# raise Exception(8)
# if heap[2]:
# raise Exception(9)
# heap[1] = 1
# heap[2] = 2
# clear(2, 1)
# if heap[1]:
# raise Exception(10)
# if heap[2]:
# raise Exception(11)
part "test_clear"
push 1
push 1
set
push 2
push 2
set
push 1
push 2
call "clear"
push 1
get
zero "__test_clear_2"
push 8
call "raise"
part "__test_clear_2"
push 2
get
zero "__test_clear_3"
push 9
call "raise"
part "__test_clear_3"
push 1
push 1
set
push 2
push 2
set
push 2
push 1
call "clear"
push 1
get
zero "__test_clear_4"
push 10
call "raise"
part "__test_clear_4"
push 2
get
zero "__test_clear_return"
push 11
call "raise"
part "__test_clear_return"
back
# def test_copy():
# heap[1] = 1
# heap[2] = 2
# copy(1, 2, 3, 4)
# if heap[3] != 1:
# raise Exception(12)
# if heap[4] != 2:
# raise Exception(13)
# copy(1, 2, 4, 3)
# if heap[3] != 2:
# raise Exception(14)
# if heap[4] != 1:
# raise Exception(15)
# copy(2, 1, 4, 3)
# if heap[3] != 1:
# raise Exception(16)
# if heap[4] != 2:
# raise Exception(17)
# copy(2, 1, 3, 4)
# if heap[3] != 2:
# raise Exception(18)
# if heap[4] != 1:
# raise Exception(19)
# clear(1, 4)
part "test_copy"
push 1
push 1
set
push 2
push 2
set
push 1
push 2
push 3
push 4
call "copy"
push 1
push 3
get
sub
zero "__test_copy_2"
push 12
call "raise"
part "__test_copy_2"
push 2
push 4
get
sub
zero "__test_copy_3"
push 13
call "raise"
part "__test_copy_3"
push 1
push 2
push 4
push 3
call "copy"
push 2
push 3
get
sub
zero "__test_copy_4"
push 14
call "raise"
part "__test_copy_4"
push 1
push 4
get
sub
zero "__test_copy_5"
push 15
call "raise"
part "__test_copy_5"
push 2
push 1
push 4
push 3
call "copy"
push 1
push 3
get
sub
zero "__test_copy_6"
push 16
call "raise"
part "__test_copy_6"
push 2
push 4
get
sub
zero "__test_copy_7"
push 17
call "raise"
part "__test_copy_7"
push 2
push 1
push 3
push 4
call "copy"
push 2
push 3
get
sub
zero "__test_copy_8"
push 18
call "raise"
part "__test_copy_8"
push 1
push 4
get
sub
zero "__test_copy_return"
push 19
call "raise"
part "__test_copy_return"
push 1
push 4
call "clear"
back
# def test_memory_manager_append_cell():
# if heap[-2]:
# raise Exception(20)
# memory_manager_append_cell(100, 200)
# if heap[-2] != 1:
# raise Exception(21)
# if heap[-3] != 100:
# raise Exception(22)
# if heap[-4] != 200:
# raise Exception(23)
# memory_manager_append_cell(300, 400)
# if heap[-2] != 2:
# raise Exception(24)
# if heap[-5] != 300:
# raise Exception(25)
# if heap[-6] != 400:
# raise Exception(26)
# clear(-2, -6)
part "test_memory_manager_append_cell"
push -2
get
zero "__test_memory_manager_append_cell_2"
push 20
call "raise"
part "__test_memory_manager_append_cell_2"
push 100
push 200
call "memory_manager_append_cell"
push 1
push -2
get
sub
zero "__test_memory_manager_append_cell_3"
push 21
call "raise"
part "__test_memory_manager_append_cell_3"
push 100
push -3
get
sub
zero "__test_memory_manager_append_cell_4"
push 22
call "raise"
part "__test_memory_manager_append_cell_4"
push 200
push -4
get
sub
zero "__test_memory_manager_append_cell_5"
push 23
call "raise"
part "__test_memory_manager_append_cell_5"
push 300
push 400
call "memory_manager_append_cell"
push 2
push -2
get
sub
zero "__test_memory_manager_append_cell_6"
push 24
call "raise"
part "__test_memory_manager_append_cell_6"
push 300
push -5
get
sub
zero "__test_memory_manager_append_cell_7"
push 25
call "raise"
part "__test_memory_manager_append_cell_7"
push 400
push -6
get
sub
zero "__test_memory_manager_append_cell_return"
push 26
call "raise"
part "__test_memory_manager_append_cell_return"
push -2
push -6
call "clear"
back
# def test_memory_manager_get_cell():
# memory_manager_append_cell(80, 90)
# memory_manager_append_cell(100, 110)
# d, c = memory_manager_get_cell(1)
# b, a = memory_manager_get_cell(0)
# if a != 80:
# raise Exception(28)
# if b != 90:
# raise Exception(29)
# if c != 100:
# raise Exception(30)
# if d != 110:
# raise Exception(31)
# clear(-2, -6)
part "test_memory_manager_get_cell"
push 100
push 110
push 80
push 90
call "memory_manager_append_cell"
call "memory_manager_append_cell"
push 1
call "memory_manager_get_cell"
swap
push 0
call "memory_manager_get_cell"
swap
push 80
sub
zero "__test_memory_manager_get_cell_2"
push 28
call "raise"
part "__test_memory_manager_get_cell_2"
push 90
sub
zero "__test_memory_manager_get_cell_3"
push 29
call "raise"
part "__test_memory_manager_get_cell_3"
push 100
sub
zero "__test_memory_manager_get_cell_4"
push 30
call "raise"
part "__test_memory_manager_get_cell_4"
push 110
sub
zero "__test_memory_manager_get_cell_return"
push 31
call "raise"
part "__test_memory_manager_get_cell_return"
push -2
push -6
call "clear"
back
# def test_memory_manager_insert_cell():
# memory_manager_insert_cell(11, 20, 0)
# memory_manager_insert_cell(31, 40, 1)
# memory_manager_insert_cell(21, 30, 1)
# memory_manager_insert_cell(1, 10, 0)
# h, g = memory_manger_get_cell(0)
# f, e = memory_manger_get_cell(1)
# c, d = memory_manger_get_cell(2)
# b, a = memory_manger_get_cell(3)
# if a != 40:
# raise Exception(33)
# if a != 31:
# raise Exception(34)
# if a != 30:
# raise Exception(35)
# if a != 21:
# raise Exception(36)
# if a != 20:
# raise Exception(37)
# if a != 11:
# raise Exception(38)
# if a != 10:
# raise Exception(39)
# if a != 1:
# raise Exception(40)
# clear(-2, -10)
part "test_memory_manager_insert_cell"
push 11
push 20
push 0
call "memory_manager_insert_cell"
push 31
push 40
push 1
call "memory_manager_insert_cell"
push 21
push 30
push 1
call "memory_manager_insert_cell"
push 1
push 10
push 0
call "memory_manager_insert_cell"
push 0
call "memory_manager_get_cell"
push 1
call "memory_manager_get_cell"
push 2
call "memory_manager_get_cell"
push 3
call "memory_manager_get_cell"
push 40
sub
zero "__test_memory_manager_insert_cell_2"
push 33
call "raise"
part "__test_memory_manager_insert_cell_2"
push 31
sub
zero "__test_memory_manager_insert_cell_3"
push 34
call "raise"
part "__test_memory_manager_insert_cell_3"
push 30
sub
zero "__test_memory_manager_insert_cell_4"
push 35
call "raise"
part "__test_memory_manager_insert_cell_4"
push 21
sub
zero "__test_memory_manager_insert_cell_5"
push 36
call "raise"
part "__test_memory_manager_insert_cell_5"
push 20
sub
zero "__test_memory_manager_insert_cell_6"
push 37
call "raise"
part "__test_memory_manager_insert_cell_6"
push 11
sub
zero "__test_memory_manager_insert_cell_7"
push 38
call "raise"
part "__test_memory_manager_insert_cell_7"
push 10
sub
zero "__test_memory_manager_insert_cell_8"
push 39
call "raise"
part "__test_memory_manager_insert_cell_8"
push 1
sub
zero "__test_memory_manager_insert_cell_return"
push 40
call "raise"
part "__test_memory_manager_insert_cell_return"
push -2
push -10
call "clear"
back
# def test_malloc_check_beginning():
# HEAP[-1] = 1
# memory_manager_append_cell(11, 20)
# if malloc_check_beginning(11):
# raise Exception(42)
# if malloc_check_beginning(10) != 1:
# raise Exception(43)
# d, c = memory_manager_get_cell(0)
# b, a = memory_manager_get_cell(1)
# if a != 20:
# raise Exception(44)
# if a != 11:
# raise Exception(45)
# if a != 10:
# raise Exception(46)
# if a != 1:
# raise Exception(47)
# clear(-1, -6)
part "test_malloc_check_beginning"
push -1
push 1
set
push 11
push 20
call "memory_manager_append_cell"
push 11
call "malloc_check_beginning"
zero "__test_malloc_check_beginning_2"
push 42
call "raise"
part "__test_malloc_check_beginning_2"
push 10
call "malloc_check_beginning"
push 1
sub
zero "__test_malloc_check_beginning_3"
push 43
call "raise"
part "__test_malloc_check_beginning_3"
push 0
call "memory_manager_get_cell"
push 1
call "memory_manager_get_cell"
push 20
sub
zero "__test_malloc_check_beginning_4"
push 44
call "raise"
part "__test_malloc_check_beginning_4"
push 11
sub
zero "__test_malloc_check_beginning_5"
push 45
call "raise"
part "__test_malloc_check_beginning_5"
push 10
sub
zero "__test_malloc_check_beginning_6"
push 46
call "raise"
part "__test_malloc_check_beginning_6"
push 1
sub
zero "__test_malloc_check_beginning_return"
push 47
call "raise"
part "__test_malloc_check_beginning_return"
push -1
push -6
call "clear"
back
# def test_malloc_check_ranges():
# if malloc_check_ranges(10) != -1:
# raise Exception(48)
# memory_manager_append_cell(11, 20)
# if malloc_check_ranges(10) != -1:
# raise Exception(49)
# memory_manager_append_cell(31, 40)
# if malloc_check_ranges(20) != -1:
# raise Exception(50)
# if malloc_check_ranges(5) != 1:
# raise Exception(51)
# if malloc_check_ranges(5) != 2:
# raise Exception(52)
# d, c = memory_manager_get_cell(1)
# b, a = memory_manager_get_cell(2)
# if a != 30:
# raise Exception(53)
# if b != 26:
# raise Exception(54)
# if c != 25:
# raise Exception(55)
# if d != 21:
# raise Exception(56)
# clear(-2, -10)
part "test_malloc_check_ranges"
push 10
call "malloc_check_ranges"
push 1
add
zero "__test_malloc_check_ranges_2"
push 48
call "raise"
part "__test_malloc_check_ranges_2"
push 11
push 20
call "memory_manager_append_cell"
push 10
call "malloc_check_ranges"
push 1
add
zero "__test_malloc_check_ranges_3"
push 49
call "raise"
part "__test_malloc_check_ranges_3"
push 31
push 40
call "memory_manager_append_cell"
push 20
call "malloc_check_ranges"
push 1
add
zero "__test_malloc_check_ranges_4"
push 50
call "raise"
part "__test_malloc_check_ranges_4"
push 5
call "malloc_check_ranges"
push 1
sub
zero "__test_malloc_check_ranges_5"
push 51
call "raise"
part "__test_malloc_check_ranges_5"
push 5
call "malloc_check_ranges"
push 2
sub
zero "__test_malloc_check_ranges_6"
push 52
call "raise"
part "__test_malloc_check_ranges_6"
push 1
call "memory_manager_get_cell"
push 2
call "memory_manager_get_cell"
push 30
sub
zero "__test_malloc_check_ranges_7"
push 53
call "raise"
part "__test_malloc_check_ranges_7"
push 26
sub
zero "__test_malloc_check_ranges_8"
push 54
call "raise"
part "__test_malloc_check_ranges_8"
push 25
sub
zero "__test_malloc_check_ranges_9"
push 55
call "raise"
part "__test_malloc_check_ranges_9"
push 21
sub
zero "__test_malloc_check_ranges_return"
push 56
call "raise"
part "__test_malloc_check_ranges_return"
push -2
push -10
call "clear"
back
# def test_malloc_ranges():
# HEAP[-1] = 1
# memory_manager_append_cell(11, 20)
# memory_manager_append_cell(31, 40)
# if malloc_ranges(10) != 1:
# raise Exception(57)
# if malloc_ranges(10) != 21:
# raise Exception(58)
# if malloc_ranges(10) != 41:
# raise Exception(59)
# f, e = memory_manager_get_cell(0)
# d, c = memory_manager_get_cell(2)
# b, a = memory_manager_get_cell(4)
# if a != 50:
# raise Exception(60)
# if b != 41:
# raise Exception(61)
# if c != 30:
# raise Exception(62)
# if d != 21:
# raise Exception(63)
# if e != 10:
# raise Exception(64)
# if f != 1:
# raise Exception(65)
# clear(-1, -12)
part "test_malloc_ranges"
push 31
push 40
push 11
push 20
push -1
push 1
set
call "memory_manager_append_cell"
call "memory_manager_append_cell"
push 10
call "malloc_ranges"
push 1
sub
zero "__test_malloc_ranges_2"
push 57
call "raise"
part "__test_malloc_ranges_2"
push 10
call "malloc_ranges"
push 21
sub
zero "__test_malloc_ranges_3"
push 58
call "raise"
part "__test_malloc_ranges_3"
push 10
call "malloc_ranges"
push 41
sub
zero "__test_malloc_ranges_4"
push 59
call "raise"
part "__test_malloc_ranges_4"
push 0
call "memory_manager_get_cell"
push 2
call "memory_manager_get_cell"
push 4
call "memory_manager_get_cell"
push 50
sub
zero "__test_malloc_ranges_5"
push 60
call "raise"
part "__test_malloc_ranges_5"
push 41
sub
zero "__test_malloc_ranges_6"
push 61
call "raise"
part "__test_malloc_ranges_6"
push 30
sub
zero "__test_malloc_ranges_7"
push 62
call "raise"
part "__test_malloc_ranges_7"
push 21
sub
zero "__test_malloc_ranges_8"
push 63
call "raise"
part "__test_malloc_ranges_8"
push 10
sub
zero "__test_malloc_ranges_9"
push 64
call "raise"
part "__test_malloc_ranges_9"
push 1
sub
zero "__test_malloc_ranges_return"
push 65
call "raise"
part "__test_malloc_ranges_return"
push -1
push -12
call "clear"
back
# def test_malloc():
# HEAP[-1] = 1
# if malloc(1) != 1:
# raise Exception(66)
# if malloc(2) != 2:
# raise Exception(67)
# if malloc(3) != 4:
# raise Exception(68)
# if malloc(4) != 7:
# raise Exception(69)
# if HEAP[-2] != 4:
# raise Exception(70)
# if HEAP[-10] != 10:
# raise Exception(71)
# clear(-1, -10)
part "test_malloc"
push -1
push 1
set
push 1
call "malloc"
push 1
sub
zero "__test_malloc_2"
push 66
call "raise"
part "__test_malloc_2"
push 2
call "malloc"
push 2
sub
zero "__test_malloc_3"
push 67
call "raise"
part "__test_malloc_3"
push 3
call "malloc"
push 4
sub
zero "__test_malloc_4"
push 68
call "raise"
part "__test_malloc_4"
push 4
call "malloc"
push 7
sub
zero "__test_malloc_5"
push 69
call "raise"
part "__test_malloc_5"
push -2
get
push 4
sub
zero "__test_malloc_6"
push 70
call "raise"
part "__test_malloc_6"
push -10
copy
get
add
zero "__test_malloc_return"
push 71
call "raise"
part "__test_malloc_return"
push -1
push -10
call "clear"
back
# def test_calloc():
# HEAP[-1] = 1
# if calloc(10, 10) != 1:
# raise Exception(72)
# if HEAP[-4] != 100:
# raise Exception(73)
# clear(-1, -4)
part "test_calloc"
push -1
push 1
set
push 10
copy
call "calloc"
push 1
sub
zero "__test_calloc_2"
push 72
call "raise"
part "__test_calloc_2"
push 100
push -4
get
sub
zero "__test_calloc_return"
push 73
call "raise"
part "__test_calloc_return"
push -1
push -4
call "clear"
back
# def test_memory_manager_search():
# if memory_manager_search(1) != -1:
# raise Exception(74)
# memory_manager_append_cell(1, 10)
# memory_manager_append_cell(11, 20)
# memory_manager_append_cell(21, 30)
# memory_manager_append_cell(31, 40)
# memory_manager_append_cell(41, 50)
# memory_manager_append_cell(51, 60)
# memory_manager_append_cell(61, 70)
# if memory_manager_search(1) != 0:
# raise Exception(75)
# if memory_manager_search(31) != 3:
# raise Exception(76)
# if memory_manager_search(61) != 6:
# raise Exception(77)
# if memory_manager_search(0) != -1:
# raise Exception(78)
# if memory_manager_search(62) != -1:
# raise Exception(79)
# clear(-2, -16)
part "test_memory_manager_search"
push 1
copy
call "memory_manager_search"
add
zero "__test_memory_manager_search_2"
push 74
call "raise"
part "__test_memory_manager_search_2"
push 61
push 70
push 51
push 60
push 41
push 50
push 31
push 40
push 21
push 30
push 11
push 20
push 1
push 10
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
push 1
call "memory_manager_search"
zero "__test_memory_manager_search_3"
push 75
call "raise"
part "__test_memory_manager_search_3"
push 31
call "memory_manager_search"
push 3
sub
zero "__test_memory_manager_search_4"
push 76
call "raise"
part "__test_memory_manager_search_4"
push 61
call "memory_manager_search"
push 6
sub
zero "__test_memory_manager_search_5"
push 77
call "raise"
part "__test_memory_manager_search_5"
push 0
call "memory_manager_search"
push 1
add
zero "__test_memory_manager_search_6"
push 78
call "raise"
part "__test_memory_manager_search_6"
push 62
call "memory_manager_search"
push 1
add
zero "__test_memory_manager_search_return"
push 79
call "raise"
part "__test_memory_manager_search_return"
push -2
push -16
call "clear"
back
# def test_memory_manager_pop_cell():
# memory_manager_append_cell(11, 20)
# memory_manager_append_cell(21, 30)
# memory_manager_append_cell(31, 40)
# memory_manager_append_cell(41, 50)
# h, g = memory_manager_pop_cell(-1)
# f, e = memory_manager_pop_cell(0)
# d, c = memory_manager_pop_cell(1)
# b, a = memory_manager_pop_cell(0)
# if a != 30:
# raise Exception(84)
# if b != 21:
# raise Exception(85)
# if c != 40:
# raise Exception(86)
# if d != 31:
# raise Exception(87)
# if e != 20:
# raise Exception(88)
# if f != 11:
# raise Exception(89)
# if g != 50:
# raise Exception(90)
# if h != 41:
# raise Exception(91)
part "test_memory_manager_pop_cell"
push 41
push 50
push 31
push 40
push 21
push 30
push 11
push 20
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
push -1
call "memory_manager_pop_cell"
push 0
call "memory_manager_pop_cell"
push 1
call "memory_manager_pop_cell"
push 0
call "memory_manager_pop_cell"
push 30
sub
zero "__test_memory_manager_pop_cell_2"
push 84
call "raise"
part "__test_memory_manager_pop_cell_2"
push 21
sub
zero "__test_memory_manager_pop_cell_3"
push 85
call "raise"
part "__test_memory_manager_pop_cell_3"
push 40
sub
zero "__test_memory_manager_pop_cell_4"
push 86
call "raise"
part "__test_memory_manager_pop_cell_4"
push 31
sub
zero "__test_memory_manager_pop_cell_5"
push 87
call "raise"
part "__test_memory_manager_pop_cell_5"
push 20
sub
zero "__test_memory_manager_pop_cell_6"
push 88
call "raise"
part "__test_memory_manager_pop_cell_6"
push 11
sub
zero "__test_memory_manager_pop_cell_7"
push 89
call "raise"
part "__test_memory_manager_pop_cell_7"
push 50
sub
zero "__test_memory_manager_pop_cell_8"
push 90
call "raise"
part "__test_memory_manager_pop_cell_8"
push 41
sub
zero "__test_memory_manager_pop_cell_return"
push 91
call "raise"
part "__test_memory_manager_pop_cell_return"
back
# def test_free():
# HEAP[-1] = 1
# a = malloc(100)
# b = malloc(100)
# free(a)
# c = malloc(50)
# d = malloc(50)
# e = malloc(50)
# free(d)
# f = malloc(25)
# g = malloc(25)
# h = malloc(25)
# free(b)
# i = malloc(25)
# j = malloc(100)
# if memory_manager_get_cell(0)[0] != 1:
# raise Exception(92)
# if memory_manager_get_cell(1)[0] != 51:
# raise Exception(93)
# if memory_manager_get_cell(2)[0] != 76:
# raise Exception(94)
# if memory_manager_get_cell(3)[0] != 101:
# raise Exception(95)
# if memory_manager_get_cell(4)[0] != 201:
# raise Exception(96)
# if memory_manager_get_cell(5)[0] != 251:
# raise Exception(97)
# if memory_manager_get_cell(6)[0] != 276:
# raise Exception(98)
# if memory_manager_get_cell(6)[1] != 375:
# raise Exception(99)
# free(j)
# free(i)
# free(h)
# free(g)
# free(f)
# free(e)
# free(c)
# if HEAP[-2] != 0:
# raise Exception(100)
# clear(-1, 0)
part "test_free"
push -1
push 1
set
push 100
call "malloc"
push 100
call "malloc"
swap
call "free"
push 50
call "malloc"
push 50
call "malloc"
push 50
call "malloc"
swap
call "free"
push 25
call "malloc"
push 25
call "malloc"
push 25
call "malloc"
copy 5
call "free"
push 25
call "malloc"
push 100
call "malloc"
push 0
call "memory_manager_get_cell"
away
push 1
sub
zero "__test_free_2"
push 92
call "raise"
part "__test_free_2"
push 1
call "memory_manager_get_cell"
away
push 51
sub
zero "__test_free_3"
push 93
call "raise"
part "__test_free_3"
push 2
call "memory_manager_get_cell"
away
push 76
sub
zero "__test_free_4"
push 94
call "raise"
part "__test_free_4"
push 3
call "memory_manager_get_cell"
away
push 101
sub
zero "__test_free_5"
push 95
call "raise"
part "__test_free_5"
push 4
call "memory_manager_get_cell"
away
push 201
sub
zero "__test_free_6"
push 96
call "raise"
part "__test_free_6"
push 5
call "memory_manager_get_cell"
away
push 251
sub
zero "__test_free_7"
push 97
call "raise"
part "__test_free_7"
push 6
call "memory_manager_get_cell"
away
push 276
sub
zero "__test_free_8"
push 98
call "raise"
part "__test_free_8"
push 6
call "memory_manager_get_cell"
away 1
push 375
sub
zero "__test_free_9"
push 99
call "raise"
part "__test_free_9"
call "free"
call "free"
call "free"
call "free"
call "free"
call "free"
call "free"
away
push -2
get
zero "__test_free_return"
push 100
call "raise"
part "__test_free_return"
push -1
push 0
call "clear"
back
# def test_memory_manager_get_block_size():
# HEAP[-1] = 1
# a = malloc(123)
# if memory_manager_get_block_size(0) != 123:
# raise Exception(102)
# free(a)
# clear(-1, 0)
part "test_memory_manager_get_block_size"
push -1
push 1
set
push 123
call "malloc"
push 0
call "memory_manager_get_block_size"
push 123
sub
zero "__test_memory_manager_get_block_size_return"
push 102
call "raise"
part "__test_memory_manager_get_block_size_return"
call "free"
push -1
push 0
call "clear"
back
# def test_memory_manager_set_cell():
# memory_manager_append_cell(1, 10)
# memory_manager_set_cell(11, 20, 0)
# b, a = memory_manager_get_cell(0)
# if a != 20:
# raise Exception(106)
# if b != 11:
# raise Exception(107)
# clear(-2, -4)
part "test_memory_manager_set_cell"
push 0
push 11
push 20
push 0
push 1
push 10
call "memory_manager_append_cell"
call "memory_manager_set_cell"
call "memory_manager_get_cell"
push 20
sub
zero "__test_memory_manager_set_cell_2"
push 106
call "raise"
part "__test_memory_manager_set_cell_2"
push 11
sub
zero "__test_memory_manager_set_cell_return"
push 107
call "raise"
part "__test_memory_manager_set_cell_return"
push -2
push -4
call "clear"
back
# def test_memory_manager_deflate_block():
# memory_manager_append_cell(1, 100)
# memory_manager_deflate_block(50, 0)
# if memory_manager_get_block_size(0) != 50:
# raise Exception(108)
# clear(-2, -4)
part "test_memory_manager_deflate_block"
push 1
push 100
call "memory_manager_append_cell"
push 50
push 0
call "memory_manager_deflate_block"
push 0
call "memory_manager_get_block_size"
push 50
sub
zero "__test_memory_manager_deflate_block_return"
push 108
call "raise"
part "__test_memory_manager_deflate_block_return"
push -2
push -4
call "clear"
back
# def test_memory_manager_inflate_cell():
# memory_manager_append_cell(1, 50)
# memory_manager_inflate_cell(100, 0)
# if memory_manager_get_block_size(0) != 100:
# raise Exception(110)
# clear(-2, -4)
part "test_memory_manager_inflate_cell"
push 1
push 50
call "memory_manager_append_cell"
push 100
push 0
call "memory_manager_inflate_cell"
push 0
call "memory_manager_get_block_size"
push 100
sub
zero "__test_memory_manager_inflate_cell_return"
push 110
call "raise"
part "__test_memory_manager_inflate_cell_return"
push -2
push -4
call "clear"
back
# def test_memory_manager_potential_after():
# memory_manager_append_cell(101, 200)
# memory_manager_append_cell(251, 300)
# if memory_manager_potential_after(0) != 150:
# raise Exception(111)
# clear(-2, -6)
part "test_memory_manager_potential_after"
push -2
push -6
push 150
push 0
push 251
push 300
push 101
push 200
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_potential_after"
sub
zero "__test_memory_manager_potential_after_return"
push 111
call "raise"
part "__test_memory_manager_potential_after_return"
call "clear"
back
# def test_memory_manager_potential_before():
# HEAP[-1] = 51
# memory_manager_append_cell(101, 250)
# memory_manager_append_cell(301, 325)
# memory_manager_append_cell(351, 400)
# if memory_manager_potential_before(0) != 250:
# raise Exception(112)
# if memory_manager_potentail_before(1) != 100:
# raise Exception(113)
# clear(-1, -8)
part "test_memory_manager_potential_before"
push -1
push -8
push 100
push 1
push 250
push 0
push 351
push 400
push 301
push 325
push 101
push 250
push -1
push 51
set
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_potential_before"
sub
zero "__test_memory_manager_potential_before_2"
push 112
call "raise"
part "__test_memory_manager_potential_before_2"
call "memory_manager_potential_before"
sub
zero "__test_memory_manager_potential_before_return"
push 113
call "raise"
part "__test_memory_manager_potential_before_return"
call "clear"
back
# def test_memory_manager_compress():
# HEAP[-1] = 101
# memory_manager_append_cell(201, 300)
# memory_manager_append_cell(401, 500)
# if memory_manager_compress(0) != 101:
# raise Exception(114)
# if memory_manager_compress(1) != 301:
# raise Exception(115)
# clear(-1, -6)
part "test_memory_manager_compress"
push -1
push -6
push 301
push 1
push 101
push 0
push 401
push 500
push 201
push 300
push -1
push 101
set
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_compress"
sub
zero "__test_memory_manager_compress_2"
push 114
call "raise"
part "__test_memory_manager_compress_2"
call "memory_manager_compress"
sub
zero "__test_memory_manager_compress_return"
push 115
call "raise"
part "__test_memory_manager_compress_return"
call "clear"
back
# def test_compare_cells():
# HEAP[1] = 1
# HEAP[2] = 1
# if compare_cells(1, 2) != 0:
# raise Exception(121)
# HEAP[1] = 2
# if compare_cells(1, 2) != 1:
# raise Exception(122)
# if compare_cells(2, 1) != -1:
# raise Exception(123)
# clear(1, 2)
part "test_compare_cells"
push 1
push 2
push -1
push 2
push 1
push 1
push 1
push 2
push 1
push 2
push 1
push 2
push 2
push 1
push 1
push 1
set
set
call "compare_cells"
zero "__test_compare_cells_2"
push 121
call "raise"
part "__test_compare_cells_2"
set
call "compare_cells"
sub
zero "__test_compare_cells_3"
push 122
call "raise"
part "__test_compare_cells_3"
call "compare_cells"
sub
zero "__test_compare_cells_return"
push 123
call "raise"
part "__test_compare_cells_return"
call "clear"
back
# def test_compare_memory():
# if compare_memory(0, 1, 0) != 0:
# raise Exception(124)
# if compare_memory(1, 1, 1) != 0:
# raise Exception(125)
# HEAP[1] = 100
# HEAP[2] = 200
# HEAP[3] = 100
# HEAP[4] = 200
# if compare_memory(1, 3, 2) != 0:
# raise Exception(126)
# HEAP[2] = 300
# if compare_memory(1, 3, 2) != 1:
# raise Exception(127)
# HEAP[4] = 400
# if compare_memory(1, 3, 2) != -1:
# raise Exception(128)
# clear(1, 4)
part "test_compare_memory"
push 1
push 4
push -1
push 1
push 3
push 2
push 4
push 400
push 1
push 1
push 3
push 2
push 2
push 300
push 1
push 3
push 2
push 4
push 200
push 3
push 100
push 2
push 200
push 1
push 100
push 1
push 1
push 1
push 0
push 1
push 0
call "compare_memory"
zero "__test_compare_memory_2"
push 124
call "raise"
part "__test_compare_memory_2"
call "compare_memory"
zero "__test_compare_memory_3"
push 125
call "raise"
part "__test_compare_memory_3"
set
set
set
set
call "compare_memory"
zero "__test_compare_memory_4"
push 126
call "raise"
part "__test_compare_memory_4"
set
call "compare_memory"
sub
zero "__test_compare_memory_5"
push 127
call "raise"
part "__test_compare_memory_5"
set
call "compare_memory"
sub
zero "__test_compare_memory_return"
push 128
call "raise"
part "__test_compare_memory_return"
call "clear"
back
# test_direction():
# if direction(-100) != -1:
# raise Exception(130)
# if direction(0) != 0:
# raise Exception(131)
# if direction(100) != 1:
# raise Exception(132)
part "test_direction"
push 1
push 100
push 0
push -1
push -100
call "direction"
sub
zero "__test_direction_2"
push 130
call "raise"
part "__test_direction_2"
call "direction"
zero "__test_direction_3"
push 131
call "raise"
part "__test_direction_3"
call "direction"
sub
zero "__test_direction_return"
push 132
call "raise"
part "__test_direction_return"
back
# def test_range():
# range(1, 1, 4, 1)
# HEAP[4] = 1
# HEAP[5] = 2
# HEAP[6] = 3
# if compare_memory(1, 4, 3) != 0:
# raise Exception(133)
# range(1, 0, -3, -1)
# HEAP[4] = 0
# HEAP[5] = -1
# HEAP[6] = -2
# if compare_memory(1, 4, 3) != 0:
# raise Exception(134)
# range(1, 0, 6, 2)
# HEAP[5] = 2
# HEAP[6] = 4
# if compare_memory(1, 4, 3) != 0:
# raise Exception(135)
# range(1, 8, 3, -2)
# HEAP[4] = 8
# HEAP[5] = 6
# if compare_memory(1, 4, 3) != 0:
# raise Exception(136)
# clear(1, 6)
part "test_range"
push 1
push 6
push 1
push 4
push 3
push 5
push 6
push 4
push 8
push 1
push 8
push 3
push -2
push 1
push 4
push 3
push 6
push 4
push 5
push 2
push 1
push 0
push 6
push 2
push 1
push 4
push 3
push 6
push -2
push 5
push -1
push 4
push 0
push 1
push 0
push -3
push -1
push 1
push 4
push 3
push 6
push 3
push 5
push 2
push 4
push 1
push 1
push 1
push 4
push 1
call "range"
set
set
set
call "compare_memory"
zero "__test_range_2"
push 133
call "raise"
part "__test_range_2"
call "range"
set
set
set
call "compare_memory"
zero "__test_range_3"
push 134
call "raise"
part "__test_range_3"
call "range"
set
set
call "compare_memory"
zero "__test_range_4"
push 135
call "raise"
part "__test_range_4"
call "range"
set
set
call "compare_memory"
zero "__test_range_return"
push 136
call "raise"
part "__test_range_return"
call "clear"
back
# def test_memory_manager_size():
# HEAP[-1] = 1
# a = malloc(123)
# b = malloc(456)
# c = malloc(789)
# if memory_manager_size(a) != 123:
# raise Exception(138)
# if memory_manager_size(b) != 456:
# raise Exception(139)
# if memory_manager_size(c) != 789:
# raise Exception(140)
# free(c)
# free(b)
# free(a)
# clear(-1, 0)
part "test_memory_manager_size"
push -1
push 1
set
push 123
call "malloc"
push 456
call "malloc"
push 789
call "malloc"
copy 2
call "memory_manager_size"
push 123
sub
zero "__test_memory_manager_size_2"
push 138
call "raise"
part "__test_memory_manager_size_2"
copy 1
call "memory_manager_size"
push 456
sub
zero "__test_memory_manager_size_3"
push 139
call "raise"
part "__test_memory_manager_size_3"
copy
call "memory_manager_size"
push 789
sub
zero "__test_memory_manager_size_return"
push 140
call "raise"
part "__test_memory_manager_size_return"
call "free"
call "free"
call "free"
push -1
push 0
call "clear"
back
# def test_mark():
# HEAP[-1] = 1
# a = malloc(1500)
# mark(a)
# range(3001, 1, 1501, 1)
# if compare_memory(a, 3001, 3000) != 0:
# raise Exception(141)
# free(a)
# clear(-1, 4500)
part "test_mark"
push -1
push 1
set
push 1500
call "malloc"
copy
call "mark"
push 3001
push 1
push 1501
push 1
call "range"
copy
push 3001
push 3000
call "compare_memory"
zero "__test_mark_return"
push 141
call "raise"
part "__test_mark_return"
call "free"
push -1
push 4500
call "clear"
back
# def test_memory_manager_inflate_before():
# HEAP[-1] = 101
# a = malloc(10)
# b = malloc(10)
# c = malloc(10)
# d = malloc(10)
# if HEAP[-2] != 4:
# raise Exception(116)
# mark(d)
# mark(c)
# mark(b)
# free(a)
# b = memory_manager_inflate_before(b, 15, 0)
# c = memory_manager_inflate_before(c, 15, 1)
# if HEAP[-2] != 3:
# raise Exception(117)
# e = malloc(40)
# range(e, 1, 11, 1)
# range(e + 10, 1, 6, 1)
# range(e + 15, 1, 6, 1)
# range(e + 20, 6, 11, 1)
# range(e + 25, 6, 11, 1)
# range(e + 30, 1, 11, 1)
# if compare_memory(b, e, 40) != 0:
# raise Exception(118)
# free(e)
# free(c)
# free(b)
# free(d)
# if HEAP[-2] != 0:
# raise Exception(119)
# HEAP[-1] = 0
# HEAP[0] = 0
# clear(101, 180)
part "test_memory_manager_inflate_before"
push -1
push 101
set
push 10
call "malloc"
push 10
call "malloc"
push 10
call "malloc"
push 10
call "malloc"
push 4
push -2
get
sub
zero "__test_memory_manager_inflate_before_2"
push 116
call "raise"
part "__test_memory_manager_inflate_before_2"
copy 3
copy 3
copy 3
copy 3
call "mark"
call "mark"
call "mark"
call "free"
copy 2
push 15
push 0
call "memory_manager_inflate_before"
copy 2
push 15
push 1
call "memory_manager_inflate_before"
push 3
push -2
get
sub
zero "__test_memory_manager_inflate_before_3"
push 117
call "raise"
part "__test_memory_manager_inflate_before_3"
push 40
call "malloc"
copy
push 1
push 11
push 1
call "range"
copy
push 10
add
push 1
push 6
push 1
call "range"
copy
push 15
add
push 1
push 6
push 1
call "range"
copy
push 20
add
push 6
push 11
push 1
call "range"
copy
push 25
add
push 6
push 11
push 1
call "range"
copy
push 30
add
push 1
push 11
push 1
call "range"
copy 2
copy 1
push 40
call "compare_memory"
zero "__test_memory_manager_inflate_before_4"
push 118
call "raise"
part "__test_memory_manager_inflate_before_4"
call "free"
call "free"
call "free"
call "free"
push -2
away 3
get
zero "__test_memory_manager_inflate_before_return"
push 119
call "raise"
part "__test_memory_manager_inflate_before_return"
push 101
push 180
push 0
push 0
push -1
push 0
set
set
call "clear"
back
# def test_rotate_3_down():
# stack.extend((1, 2, 3))
# rotate_3_down()
# if stack.pop() != 1:
# raise Exception(147)
# if stack.pop() != 3:
# raise Exception(148)
# if stack.pop() != 2:
# raise Exception(149)
# HEAP[0] = 0
part "test_rotate_3_down"
push 1
push 2
push 3
call "rotate_3_down"
push 1
sub
zero "__test_rotate_3_down_2"
push 147
call "raise"
part "__test_rotate_3_down_2"
push 3
sub
zero "__test_rotate_3_down_3"
push 148
call "raise"
part "__test_rotate_3_down_3"
push 2
sub
zero "__test_rotate_3_down_return"
push 149
call "raise"
part "__test_rotate_3_down_return"
push 0
push 0
set
back
# def test_rotate_3_up():
# stack.extend((1, 2, 3))
# rotate_3_down()
# if stack.pop() != 2:
# raise Exception(150)
# if stack.pop() != 1:
# raise Exception(151)
# if stack.pop() != 3:
# raise Exception(152)
# HEAP[0] = 0
part "test_rotate_3_up"
push 1
push 2
push 3
call "rotate_3_up"
push 2
sub
zero "__test_rotate_3_up_2"
push 150
call "raise"
part "__test_rotate_3_up_2"
push 1
sub
zero "__test_rotate_3_up_3"
push 151
call "raise"
part "__test_rotate_3_up_3"
push 3
sub
zero "__test_rotate_3_up_return"
push 152
call "raise"
part "__test_rotate_3_up_return"
push 0
push 0
set
back
# def test_memory_manager_inflate_move():
# HEAP[-1] = 1
# a = malloc(10)
# b = malloc(25)
# c = malloc(10)
# d = malloc(5)
# e = malloc(10)
# f = malloc(5)
# g = malloc(10)
# free(b)
# free(d)
# free(f)
# mark(e)
# h = memory_manager_inflate_move(e, 25, 2)
# if compare_memory(1, e - 10, 50) != 0:
# raise Exception(142)
# i = malloc(5)
# free(g)
# j = malloc(25)
# if memory_manager_size(h) != 25:
# raise Exception(143)
# if memory_manager_size(j) != 25:
# raise Exception(144)
# if compare_memory(h, j, 25) != 0:
# raise Exception(145)
# if j != e:
# raise Exception(146)
# free(j)
# free(i)
# free(h)
# free(c)
# free(a)
# clear(-1, 0)
# clear(11, 20)
# clear(51, 60)
part "test_memory_manager_inflate_move"
push -1
push 1
set
push 10
call "malloc"
push 25
call "malloc"
push 10
call "malloc"
push 5
call "malloc"
push 10
call "malloc"
push 5
call "malloc"
push 10
call "malloc"
copy 2
copy 2
copy 5
copy 8
call "free"
call "free"
call "free"
call "mark"
copy 2
push 25
push 2
call "memory_manager_inflate_move"
push 1
copy 4
push 10
sub
push 50
call "compare_memory"
zero "__test_memory_manager_inflate_move_2"
push 142
call "raise"
part "__test_memory_manager_inflate_move_2"
push 5
call "malloc"
copy 2
call "free"
push 25
call "malloc"
copy 2
call "memory_manager_size"
push 25
sub
zero "__test_memory_manager_inflate_move_3"
push 143
call "raise"
part "__test_memory_manager_inflate_move_3"
copy
call "memory_manager_size"
push 25
sub
zero "__test_memory_manager_inflate_move_4"
push 144
call "raise"
part "__test_memory_manager_inflate_move_4"
copy 2
copy 1
push 25
call "compare_memory"
zero "__test_memory_manager_inflate_move_5"
push 145
call "raise"
part "__test_memory_manager_inflate_move_5"
copy
copy 6
sub
zero "__test_memory_manager_inflate_move_return"
push 146
call "raise"
part "__test_memory_manager_inflate_move_return"
call "free"
call "free"
away 4
call "free"
call "free"
away
call "free"
push -1
push 0
call "clear"
push 11
push 20
call "clear"
push 51
push 60
call "clear"
back
# def test_memory_manager_inflate_block():
# HEAP[-1] = 1
# a = malloc(10)
# b = memory_manager_inflate_block(a, 20, 0)
# if a != b:
# raise Exception(153)
# if memory_manager_size(a) != 20:
# raise Exception(154)
# c = malloc(10)
# d = malloc(10)
# free(c)
# e = memory_manager_inflate_block(a, 30, 0)
# if a != e:
# raise Exception(155)
# if memory_manager_size(a) != 30:
# raise Exception(156)
# f = malloc(10)
# free(a)
# mark(d)
# g = memory_manager_inflate_block(d, 40, 0)
# if a != g:
# raise Exception(157)
# if memory_manager_size(a) != 40:
# raise Exception(158)
# if compare_memory(1, 31, 10) != 0:
# raise Exception(159)
# h = memory_manager_inflate_block(a, 50, 0)
# if h != f + memory_manager_size(f):
# raise Exception(160)
# if compare_memory(1, 51, 50) != 0:
# raise Exception(161)
# free(h)
# free(f)
# clear(-1, 90)
part "test_memory_manager_inflate_block"
push -1
push 1
set
push 10
call "malloc"
copy
push 20
push 0
call "memory_manager_inflate_block"
copy 1
sub
zero "__test_memory_manager_inflate_block_2"
push 153
call "raise"
back
part "__test_memory_manager_inflate_block_2"
copy
call "memory_manager_size"
push 20
sub
zero "__test_memory_manager_inflate_block_3"
push 154
call "raise"
part "__test_memory_manager_inflate_block_3"
push 10
call "malloc"
push 10
call "malloc"
swap
call "free"
copy 1
push 30
push 0
call "memory_manager_inflate_block"
copy 2
sub
zero "__test_memory_manager_inflate_block_4"
push 155
call "raise"
part "__test_memory_manager_inflate_block_4"
copy 1
call "memory_manager_size"
push 30
sub
zero "__test_memory_manager_inflate_block_5"
push 156
call "raise"
part "__test_memory_manager_inflate_block_5"
push 10
call "malloc"
copy 2
call "free"
copy 1
copy
call "mark"
push 40
push 0
call "memory_manager_inflate_block"
copy 3
sub
zero "__test_memory_manager_inflate_block_6"
push 157
call "raise"
part "__test_memory_manager_inflate_block_6"
copy 2
call "memory_manager_size"
push 40
sub
zero "__test_memory_manager_inflate_block_7"
push 158
call "raise"
part "__test_memory_manager_inflate_block_7"
push 1
push 31
push 10
call "compare_memory"
zero "__test_memory_manager_inflate_block_8"
push 159
call "raise"
part "__test_memory_manager_inflate_block_8"
copy 2
push 50
push 0
call "memory_manager_inflate_block"
copy
copy 2
copy
call "memory_manager_size"
add
sub
zero "__test_memory_manager_inflate_block_9"
push 160
call "raise"
part "__test_memory_manager_inflate_block_9"
push 1
push 51
push 50
call "compare_memory"
zero "__test_memory_manager_inflate_block_return"
push 161
call "raise"
part "__test_memory_manager_inflate_block_return"
call "free"
away 2
call "free"
push -1
push 90
call "clear"
back
# def test_realloc():
# HEAP[-1] = 1
# a = malloc(3)
# if realloc(a, 0) != 0:
# raise Exception(162)
# a = malloc(3)
# if realloc(a, -1) != 0:
# raise Exception(163)
# a = malloc(3)
# if realloc(a, 3) != a:
# raise Exception(164)
# if memory_manager_size(a) != 3:
# raise Exception(165)
# if realloc(a, 2) != a:
# raise Exception(166)
# if memory_manager_size(a) != 2:
# raise Exception(167)
# b = malloc(3)
# if realloc(a, 3) != 6:
# raise Exception(168)
# if memory_manager_size(6) != 3:
# raise Exception(169)
# free(b)
# free(6)
# clear(-1, 0)
part "test_realloc"
push -1
push 1
set
push 3
call "malloc"
push 0
call "realloc"
zero "__test_realloc_2"
push 162
call "raise"
part "__test_realloc_2"
push 3
call "malloc"
push -1
call "realloc"
zero "__test_realloc_3"
push 163
call "raise"
part "__test_realloc_3"
push 3
call "malloc"
copy
copy
copy
push 3
call "realloc"
sub
zero "__test_realloc_4"
push 164
call "raise"
part "__test_realloc_4"
call "memory_manager_size"
push 3
sub
zero "__test_realloc_5"
push 165
call "raise"
part "__test_realloc_5"
copy
copy
copy
push 2
call "realloc"
sub
zero "__test_realloc_6"
push 166
call "raise"
part "__test_realloc_6"
call "memory_manager_size"
push 2
sub
zero "__test_realloc_7"
push 167
call "raise"
part "__test_realloc_7"
push 3
call "malloc"
swap
push 3
call "realloc"
push 6
sub
zero "__test_realloc_8"
push 168
call "raise"
part "__test_realloc_8"
push 3
push 6
call "memory_manager_size"
sub
zero "__test_realloc_return"
push 169
call "raise"
part "__test_realloc_return"
call "free"
push 6
call "free"
push -1
push 0
call "clear"
back
# def test_memory_manager_blocks():
# HEAP[-1] = 1
# a = malloc(10)
# b = malloc(10)
# c = malloc(10)
# if memory_manager_blocks() != 3:
# raise Exception(170)
# free(c)
# free(b)
# free(a)
# if memory_manager_blocks() != 0:
# raise Exception(171)
# clear(-1, 0)
part "test_memory_manager_blocks"
push -1
push 1
set
push 10
call "malloc"
push 10
call "malloc"
push 10
call "malloc"
call "memory_manager_blocks"
push 3
sub
zero "__test_memory_manager_blocks_2"
push 170
call "raise"
part "__test_memory_manager_blocks_2"
call "free"
call "free"
call "free"
call "memory_manager_blocks"
zero "__test_memory_manager_blocks_return"
push 171
call "raise"
part "__test_memory_manager_blocks_return"
push -1
push 0
call "clear"
back
# def test_memory_manager_cells():
# memory_manager_append_cell(11, 20)
# memory_manager_append_cell(31, 40)
# if memory_manager_cells() != 20:
# raise Exception(172)
# memory_manager_pop_cell(-1)
# if memory_manager_cells() != 10:
# raise Exception(173)
# memory_manager_pop_cell(-1)
# if memory_manager_cells() != 0:
# raise Exception(174)
# HEAP[0] = 0
part "test_memory_manager_cells"
push 0
push 0
push -1
push 10
push -1
push 20
push 31
push 40
push 11
push 20
call "memory_manager_append_cell"
call "memory_manager_append_cell"
call "memory_manager_cells"
sub
zero "__test_memory_manager_cells_2"
push 172
call "raise"
part "__test_memory_manager_cells_2"
call "memory_manager_pop_cell"
away
away
call "memory_manager_cells"
sub
zero "__test_memory_manager_cells_3"
push 173
call "raise"
part "__test_memory_manager_cells_3"
call "memory_manager_pop_cell"
away
away
call "memory_manager_cells"
zero "__test_memory_manager_cells_return"
push 174
call "raise"
part "__test_memory_manager_cells_return"
set
back
# def test_memory_manager_pointers():
# HEAP[-1] = 1025
# array = memory_manager_pointers(False)
# if array[0] != 0:
# raise Exception(176)
# free(array)
# array = memory_manager_pointers(True)
# if array[0] != 1:
# raise Exception(177)
# if array[1] != array:
# raise Exception(178)
# test = memory_manager_pointers(False)
# if compare_memory(array, test, 2) != 0:
# raise Exception(179)
# free(test)
# test = memory_manager_pointers(True)
# if test[0] != 2:
# raise Exception(180)
# if test[1] != array:
# raise Exception(181)
# if test[2] != test:
# raise Exception(182)
# free(test)
# free(array)
# clear(-1, 0)
# clear(1025, 1029)
part "test_memory_manager_pointers"
push -1
push 1025
set
push 0
call "memory_manager_pointers"
copy
get
zero "__test_memory_manager_pointers_2"
push 176
call "raise"
part "__test_memory_manager_pointers_2"
call "free"
push 1
call "memory_manager_pointers"
copy
get
push 1
sub
zero "__test_memory_manager_pointers_3"
push 177
call "raise"
part "__test_memory_manager_pointers_3"
copy
copy
push 1
add
get
sub
zero "__test_memory_manager_pointers_4"
push 178
call "raise"
part "__test_memory_manager_pointers_4"
push 0
call "memory_manager_pointers"
copy 1
copy 1
push 2
call "compare_memory"
zero "__test_memory_manager_pointers_5"
push 179
call "raise"
part "__test_memory_manager_pointers_5"
call "free"
push 1
call "memory_manager_pointers"
copy
get
push 2
sub
zero "__test_memory_manager_pointers_6"
push 180
call "raise"
part "__test_memory_manager_pointers_6"
copy 1
copy 1
push 1
add
get
sub
zero "__test_memory_manager_pointers_7"
push 181
call "raise"
part "__test_memory_manager_pointers_7"
copy
copy
push 2
add
get
sub
zero "__test_memory_manager_pointers_return"
push 182
call "raise"
part "__test_memory_manager_pointers_return"
call "free"
call "free"
push 1025
push 1029
push -1
push 0
call "clear"
call "clear"
back
# def test_memory_manager_find():
# if memory_manager_find(1) != 0:
# raise Exception(183)
# memory_manager_append_cell(1, 10)
# memory_manager_append_cell(21, 30)
# memory_manager_append_cell(41, 50)
# if memory_manager_find(0) != 0:
# raise Exception(184)
# if memory_manager_find(1) != 1:
# raise Exception(185)
# if memory_manager_find(5) != 1:
# raise Exception(186)
# if memory_manager_find(10) != 1:
# raise Exception(187)
# if memory_manager_find(11) != 0:
# raise Exception(188)
# if memory_manager_find(15) != 0:
# raise Exception(189)
# if memory_manager_find(20) != 0:
# raise Exception(190)
# if memory_manager_find(21) != 21:
# raise Exception(191)
# if memory_manager_find(25) != 21:
# raise Exception(192)
# if memory_manager_find(30) != 21:
# raise Exception(193)
# if memory_manager_find(31) != 0:
# raise Exception(194)
# if memory_manager_find(35) != 0:
# raise Exception(195)
# if memory_manager_find(40) != 0:
# raise Exception(196)
# if memory_manager_find(41) != 41:
# raise Exception(197)
# if memory_manager_find(45) != 41:
# raise Exception(198)
# if memory_manager_find(50) != 41:
# raise Exception(199)
# if memory_manager_find(51) != 0:
# raise Exception(200)
# clear(-8, 0)
part "test_memory_manager_find"
push 1
call "memory_manager_find"
zero "__test_memory_manager_find_2"
push 183
call "raise"
part "__test_memory_manager_find_2"
push 1
push 10
call "memory_manager_append_cell"
push 21
push 30
call "memory_manager_append_cell"
push 41
push 50
call "memory_manager_append_cell"
push 0
call "memory_manager_find"
zero "__test_memory_manager_find_3"
push 184
call "raise"
part "__test_memory_manager_find_3"
push 1
call "memory_manager_find"
push 1
sub
zero "__test_memory_manager_find_4"
push 185
call "raise"
part "__test_memory_manager_find_4"
push 5
call "memory_manager_find"
push 1
sub
zero "__test_memory_manager_find_5"
push 186
call "raise"
part "__test_memory_manager_find_5"
push 10
call "memory_manager_find"
push 1
sub
zero "__test_memory_manager_find_6"
push 187
call "raise"
part "__test_memory_manager_find_6"
push 11
call "memory_manager_find"
zero "__test_memory_manager_find_7"
push 188
call "raise"
part "__test_memory_manager_find_7"
push 15
call "memory_manager_find"
zero "__test_memory_manager_find_8"
push 189
call "raise"
part "__test_memory_manager_find_8"
push 20
call "memory_manager_find"
zero "__test_memory_manager_find_9"
push 190
call "raise"
part "__test_memory_manager_find_9"
push 21
call "memory_manager_find"
push 21
sub
zero "__test_memory_manager_find_10"
push 191
call "raise"
part "__test_memory_manager_find_10"
push 25
call "memory_manager_find"
push 21
sub
zero "__test_memory_manager_find_11"
push 192
call "raise"
part "__test_memory_manager_find_11"
push 30
call "memory_manager_find"
push 21
sub
zero "__test_memory_manager_find_12"
push 193
call "raise"
part "__test_memory_manager_find_12"
push 31
call "memory_manager_find"
zero "__test_memory_manager_find_13"
push 194
call "raise"
part "__test_memory_manager_find_13"
push 35
call "memory_manager_find"
zero "__test_memory_manager_find_14"
push 195
call "raise"
part "__test_memory_manager_find_14"
push 40
call "memory_manager_find"
zero "__test_memory_manager_find_15"
push 196
call "raise"
part "__test_memory_manager_find_15"
push 41
call "memory_manager_find"
push 41
sub
zero "__test_memory_manager_find_16"
push 197
call "raise"
part "__test_memory_manager_find_16"
push 45
call "memory_manager_find"
push 41
sub
zero "__test_memory_manager_find_17"
push 198
call "raise"
part "__test_memory_manager_find_17"
push 50
call "memory_manager_find"
push 41
sub
zero "__test_memory_manager_find_18"
push 199
call "raise"
part "__test_memory_manager_find_18"
push 51
call "memory_manager_find"
zero "__test_memory_manager_find_return"
push 200
call "raise"
part "__test_memory_manager_find_return"
push -8
push 0
call "clear"
back
# def test_uint_cast():
# if uint_cast(0) != 0:
# raise Exception(201)
# if uint_cast(4294967296) != 0:
# raise Exception(202)
# if uint_cast(-4294967296) != 0:
# raise Exception(203)
# if uint_cast(1) != 1
# raise Exception(204)
# if uint_cast(4294967297) != 1:
# raise Exception(205)
# if uint_cast(-4294967295) != 1:
# raise Exception(206)
# if uint_cast(-1) != 4294967295:
# raise Exception(207)
# if uint_cast(4294967295) != 4294967295:
# raise Exception(208)
# if uint_cast(-4294967297) != 4294967295:
# raise Exception(209)
part "test_uint_cast"
push 4294967295
push -4294967297
push 4294967295
push 4294967295
push 4294967295
push -1
push 1
push -4294967295
push 1
push 4294967297
push 1
push 1
push -4294967296
push 4294967296
push 0
call "uint_cast"
zero "__test_uint_cast_2"
push 201
call "raise"
part "__test_uint_cast_2"
call "uint_cast"
zero "__test_uint_cast_3"
push 202
call "raise"
part "__test_uint_cast_3"
call "uint_cast"
zero "__test_uint_cast_4"
push 203
call "raise"
part "__test_uint_cast_4"
call "uint_cast"
sub
zero "__test_unint_cast_5"
push 204
call "raise"
part "__test_unint_cast_5"
call "uint_cast"
sub
zero "__test_unint_cast_6"
push 205
call "raise"
part "__test_unint_cast_6"
call "uint_cast"
sub
zero "__test_unint_cast_7"
push 206
call "raise"
part "__test_unint_cast_7"
call "uint_cast"
sub
zero "__test_unint_cast_8"
push 207
call "raise"
part "__test_unint_cast_8"
call "uint_cast"
sub
zero "__test_unint_cast_9"
push 208
call "raise"
part "__test_unint_cast_9"
call "uint_cast"
sub
zero "__test_unint_cast_return"
push 209
call "raise"
part "__test_unint_cast_return"
back
# def test_shift():
# if left_shift(100, 0) != 100:
# raise Exception(210)
# if right_shift(100, 0) != 100:
# raise Exception(211)
# if left_shift(100, 2) != 400:
# raise Exception(212)
# if right_shift(100, 2) != 25:
# raise Exception(213)
# if left_shift(100, -2) != 25:
# raise Exception(214)
# if right_shift(100, -2) != 400:
# raise Exception(215)
part "test_shift"
push 400
push 100
push -2
push 25
push 100
push -2
push 25
push 100
push 2
push 400
push 100
push 2
push 100
push 100
push 0
push 100
push 100
push 0
call "left_shift"
sub
zero "__test_shift_2"
push 210
call "raise"
part "__test_shift_2"
call "right_shift"
sub
zero "__test_shift_3"
push 211
call "raise"
part "__test_shift_3"
call "left_shift"
sub
zero "__test_shift_4"
push 212
call "raise"
part "__test_shift_4"
call "right_shift"
sub
zero "__test_shift_5"
push 213
call "raise"
part "__test_shift_5"
call "left_shift"
sub
zero "__test_shift_6"
push 214
call "raise"
part "__test_shift_6"
call "right_shift"
sub
zero "__test_shift_return"
push 215
call "raise"
part "__test_shift_return"
back
# def test_save_stack():
# HEAP[-1] = 1
# stack.push(0)
# stack.push(2)
# stack.push(3)
# stack.push(5)
# stack.push(7)
# stack.push(11)
# stack.push(13)
# stack.push(17)
# stack.push(19)
# array = save_stack(4)
# if array[0] != 4:
# raise Exception(223)
# if array[4] != 11:
# raise Exception(224)
# free(array)
# array = save_stack(4)
# if array[0] != 4:
# raise Exception(225)
# if array[1] != 7:
# raise Exception(226)
# free(array)
# if stack.pop() != 0:
# raise Exception(227)
# clear(-1, 8)
part "test_save_stack"
push -1
push 1
set
push 0
push 2
push 3
push 5
push 7
push 11
push 13
push 17
push 19
push 4
call "save_stack"
copy
get
push 4
sub
zero "__test_save_stack_2"
push 223
call "raise"
part "__test_save_stack_2"
copy
push 4
add
get
push 11
sub
zero "__test_save_stack_3"
push 224
call "raise"
part "__test_save_stack_3"
call "free"
push 4
call "save_stack"
copy
get
push 4
sub
zero "__test_save_stack_4"
push 225
call "raise"
part "__test_save_stack_4"
copy
push 1
add
get
push 7
sub
zero "__test_save_stack_5"
push 226
call "raise"
part "__test_save_stack_5"
call "free"
zero "__test_save_stack_return"
push 227
call "raise"
part "__test_save_stack_return"
push -1
push 8
call "clear"
back
# def test_load_stack():
# HEAP[-1] = 1
# stack.push(0)
# stack.push(2)
# stack.push(3)
# stack.push(5)
# stack.push(7)
# stack.push(11)
# stack.push(13)
# stack.push(17)
# stack.push(19)
# array = save_stack(3)
# if stack[-1] != 11:
# raise Exception(228)
# load_stack(array, 3)
# if stack.pop() != 19:
# raise Exception(229)
# del stack[-1]
# if stack.pop() != 13:
# raise Exception(230)
# array = save_stack(3)
# load_stack(array, 1)
# if stack.pop() != 5:
# raise Exception(231)
# load_stack(array, 2)
# if stack.pop() != 11:
# raise Exception(232)
# del stack[-1]
# array = save_stack(2)
# load_stack(array, 1)
# del stack[-1]
# if array[0] != 1:
# raise Exception(233)
# load_stack(array, 1)
# if stack[-2] + stack[-1] != 3:
# raise Exception(234)
# clear(-1, 7)
part "test_load_stack"
push -1
push 1
set
push 0
push 2
push 3
push 5
push 7
push 11
push 13
push 17
push 19
push 3
call "save_stack"
copy 1
push 11
sub
zero "__test_load_stack_2"
push 228
call "raise"
part "__test_load_stack_2"
push 3
call "load_stack"
push 19
sub
zero "__test_load_stack_3"
push 229
call "raise"
part "__test_load_stack_3"
away
push 13
sub
zero "__test_load_stack_4"
push 230
call "raise"
part "__test_load_stack_4"
push 3
call "save_stack"
copy
push 1
call "load_stack"
push 5
sub
zero "__test_load_stack_5"
push 231
call "raise"
part "__test_load_stack_5"
push 2
call "load_stack"
push 11
sub
zero "__test_load_stack_6"
push 232
call "raise"
part "__test_load_stack_6"
away
push 2
call "save_stack"
copy
push 1
call "load_stack"
away
copy
get
push 1
sub
zero "__test_load_stack_7"
push 233
call "raise"
part "__test_load_stack_7"
push 1
call "load_stack"
add
push 3
sub
zero "__test_load_stack_return"
push 234
call "raise"
part "__test_load_stack_return"
push -1
push 7
call "clear"
back
# def test_divmod():
# a, b = divmod(99, 2)
# if b != 1:
# raise Exception(235)
# if a != 49:
# raise Exception(236)
# a, b = divmod(5, 10)
# if b != 5:
# raise Exception(237)
# if a != 0:
# raise Exception(238)
# a, b = divmod(27, 3)
# if b != 0:
# raise Exception(239)
# if a != 9:
# raise Exception(240)
# HEAP[0] = 0
part "test_divmod"
push 99
push 2
call "divmod"
push 1
sub
zero "__test_divmod_2"
push 235
call "raise"
part "__test_divmod_2"
push 49
sub
zero "__test_divmod_3"
push 236
call "raise"
part "__test_divmod_3"
push 5
push 10
call "divmod"
push 5
sub
zero "__test_divmod_4"
push 237
call "raise"
part "__test_divmod_4"
zero "__test_divmod_5"
push 238
call "raise"
part "__test_divmod_5"
push 27
push 3
call "divmod"
zero "__test_divmod_6"
push 239
call "raise"
part "__test_divmod_6"
push 9
sub
zero "__test_divmod_return"
push 240
call "raise"
part "__test_divmod_return"
push 0
push 0
set
back
# def test_sum_length_array():
# HEAP[-1] = 1
# array = malloc(3)
# array[0] = 2
# array[1] = 3
# array[2] = 4
# if sum_length_array(array) != 7:
# raise Exception(237)
# array[1] = 5
# array[2] = 2
# if sum_length_array(array) != 7:
# raise Exception(238)
# array = realloc(array, 4)
# array[3] = 3
# if sum_length_array(array) != 7:
# raise Exception(239)
# array[0] = 3
# if sum_length_array(array) != 10:
# raise Exception(240)
# range(array + 1, 1, 4, 1)
# if sum_length_array(array) != 6:
# raise Exception(241)
# range(array + 1, 100, 373, 91)
# if sum_length_array(array) != 573:
# raise Exception(242)
# free(array)
# clear(-1, 4)
part "test_sum_length_array"
push -1
push 1
set
push 3
call "malloc"
copy
push 2
set
copy
push 1
add
push 3
set
copy
push 2
add
push 4
set
copy
call "sum_length_array"
push 7
sub
zero "__test_sum_length_array_2"
push 237
call "raise"
part "__test_sum_length_array_2"
copy
push 1
add
push 5
set
copy
push 2
add
push 2
set
copy
call "sum_length_array"
push 7
sub
zero "__test_sum_length_array_3"
push 238
call "raise"
part "__test_sum_length_array_3"
push 4
call "realloc"
copy
push 3
add
push 3
set
copy
call "sum_length_array"
push 7
sub
zero "__test_sum_length_array_4"
push 239
call "raise"
part "__test_sum_length_array_4"
copy
push 3
set
copy
call "sum_length_array"
push 10
sub
zero "__test_sum_length_array_5"
push 240
call "raise"
part "__test_sum_length_array_5"
copy
push 1
add
push 1
push 4
push 1
call "range"
copy
call "sum_length_array"
push 6
sub
zero "__test_sum_length_array_6"
push 241
call "raise"
part "__test_sum_length_array_6"
copy
push 1
add
push 100
push 373
push 91
call "range"
copy
call "sum_length_array"
push 573
sub
zero "__test_sum_length_array_return"
push 242
call "raise"
part "__test_sum_length_array_return"
call "free"
push -1
push 4
call "clear"
back
# def test_value_to_array():
# HEAP[-1] = 1
# array = value_to_array(7, 2)
# if array[0] != 3:
# raise Exception(243)
# if array[1] != 1:
# raise Exception(244)
# if array[2] != 1:
# raise Exception(245)
# if array[3] != 1:
# raise Exception(246)
# free(array)
# array = value_to_array(100, 3)
# if sum_length_array(array) != 4:
# raise Exception(247)
# free(array)
# array = value_to_array(123456789, 7)
# if sum_length_array(array) != 27:
# raise Exception(248)
# free(array)
# array = value_to_array(123456789, 13)
# if sum_length_array(array) != 45:
# raise Exception(249)
# free(array)
# array = value_to_array(100000, 5)
# if sum_length_array(array) != 4:
# raise Exception(250)
# free(array)
# clear(-1, 24)
part "test_value_to_array"
push -1
push 1
set
push 7
push 2
call "value_to_array"
copy
get
push 3
sub
zero "__test_value_to_array_2"
push 243
call "raise"
part "__test_value_to_array_2"
copy
push 1
add
get
push 1
sub
zero "__test_value_to_array_3"
push 244
call "raise"
part "__test_value_to_array_3"
copy
push 2
add
get
push 1
sub
zero "__test_value_to_array_4"
push 245
call "raise"
part "__test_value_to_array_4"
copy
push 3
add
get
push 1
sub
zero "__test_value_to_array_5"
push 246
call "raise"
part "__test_value_to_array_5"
call "free"
push 100
push 3
call "value_to_array"
copy
call "sum_length_array"
push 4
sub
zero "__test_value_to_array_6"
push 247
call "raise"
part "__test_value_to_array_6"
call "free"
push 123456789
push 7
call "value_to_array"
copy
call "sum_length_array"
push 27
sub
zero "__test_value_to_array_7"
push 248
call "raise"
part "__test_value_to_array_7"
call "free"
push 123456789
push 13
call "value_to_array"
copy
call "sum_length_array"
push 45
sub
zero "__test_value_to_array_8"
push 249
call "raise"
part "__test_value_to_array_8"
call "free"
push 100000
push 5
call "value_to_array"
copy
call "sum_length_array"
push 4
sub
zero "__test_value_to_array_return"
push 250
call "raise"
part "__test_value_to_array_return"
call "free"
push -1
push 24
call "clear"
back
# def test_array_to_value():
# HEAP[-1] = 1
# array = value_to_array(0, 10)
# if array_to_value(array, 10) != 0:
# raise Exception(251)
# free(array)
# array = value_to_array(1234567890, 13)
# if array_to_value(array, 13) != 1234567890:
# raise Exception(252)
# free(array)
# array = value_to_array(19850126, 12)
# if array_to_value(array, 13) != 31824236:
# raise Exception(253)
# free(array)
# array = value_to_array(100, 8)
# if array_to_value(array, 16) != 324:
# raise Exception(254)
# free(array)
# array = value_to_array(341, 2)
# if array_to_value(array, 3) != 7381:
# raise Exception(255)
# free(array)
# clear(-1, 23)
part "test_array_to_value"
push -1
push 1
set
push 0
push 10
call "value_to_array"
copy
push 10
call "array_to_value"
zero "__test_array_to_value_2"
push 251
call "raise"
part "__test_array_to_value_2"
call "free"
push 1234567890
push 13
call "value_to_array"
copy
push 13
call "array_to_value"
push 1234567890
sub
zero "__test_array_to_value_3"
push 252
call "raise"
part "__test_array_to_value_3"
call "free"
push 19850126
push 12
call "value_to_array"
copy
push 13
call "array_to_value"
push 31824236
sub
zero "__test_array_to_value_4"
push 253
call "raise"
part "__test_array_to_value_4"
call "free"
push 100
push 8
call "value_to_array"
copy
push 16
call "array_to_value"
push 324
sub
zero "__test_array_to_value_5"
push 254
call "raise"
part "__test_array_to_value_5"
call "free"
push 341
push 2
call "value_to_array"
copy
push 3
call "array_to_value"
push 7381
sub
zero "__test_array_to_value_return"
push 255
call "raise"
part "__test_array_to_value_return"
call "free"
push -1
push 23
call "clear"
back
# def test_uint_bits():
# HEAP[-1] = 1
# number = left_shift(1, 32)
# bits = uint_bits(number - 1)
# if bits[0] != 1:
# raise Exception(256)
# if bits[31] != 1:
# raise Exception(257)
# free(bits)
# bits = uint_bits(number)
# if bits[0] != 0:
# raise Exception(258)
# if bits[31] != 0:
# raise Exception(259)
# free(bits)
# clear(-1, 78)
part "test_uint_bits"
push -1
push 1
set
push 1
push 32
call "left_shift"
copy
push 1
sub
call "uint_bits"
copy
get
push 1
sub
zero "__test_uint_bits_2"
push 256
call "raise"
part "__test_uint_bits_2"
copy
push 31
add
get
push 1
sub
zero "__test_uint_bits_3"
push 257
call "raise"
part "__test_uint_bits_3"
call "free"
call "uint_bits"
copy
get
zero "__test_uint_bits_4"
push 258
call "raise"
part "__test_uint_bits_4"
copy
push 31
add
get
zero "__test_uint_bits_return"
push 259
call "raise"
part "__test_uint_bits_return"
call "free"
push -1
push 78
call "clear"
back
# def test_uint_xor():
# HEAP[-1] = 1
# if uint_xor(123, 124) != 7:
# raise Exception(260)
# if uint_xor(127, 128) != 255:
# raise Exception(261)
# if uint_xor(19891229, 19850126) != 92051:
# raise Exception(262)
# if uint_xor(3558890251, 3920765046) != 1033010045:
# raise Exception(263)
# if uint_xor(2010047493, 4018657910) != 2554936947:
# raise Exception(264)
# if uint_xor(83517729861, 159352312248) != 1747467773:
# raise Exception(265)
# clear(-1, 109)
part "test_uint_xor"
push -1
push 1
set
push 123
push 124
call "uint_xor"
push 7
sub
zero "__test_uint_xor_2"
push 260
call "raise"
part "__test_uint_xor_2"
push 127
push 128
call "uint_xor"
push 255
sub
zero "__test_uint_xor_3"
push 261
call "raise"
part "__test_uint_xor_3"
push 19891229
push 19850126
call "uint_xor"
push 92051
sub
zero "__test_uint_xor_4"
push 262
call "raise"
part "__test_uint_xor_4"
push 3558890251
push 3920765046
call "uint_xor"
push 1033010045
sub
zero "__test_uint_xor_5"
push 263
call "raise"
part "__test_uint_xor_5"
push 2010047493
push 4018657910
call "uint_xor"
push 2554936947
sub
zero "__test_uint_xor_6"
push 264
call "raise"
part "__test_uint_xor_6"
push 83517729861
push 159352312248
call "uint_xor"
push 1747467773
sub
zero "__test_uint_xor_return"
push 265
call "raise"
part "__test_uint_xor_return"
push -1
push 109
call "clear"
back
# def test_memory_manager_hash():
# HEAP[-1] = 1
# if memory_manager_hash() != 0:
# raise Exception(266)
# memory_manager_append_cell(1, 2)
# if memory_manager_hash() != 2153645760:
# raise Exception(267)
# memory_manager_append_cell(3, 5)
# if memory_manager_hash() != 4048040839:
# raise Exception(268)
# memory_manager_append_cell(7, 11)
# if memory_manager_hash() != 265376592:
# raise Exception(269)
# memory_manager_append_cell(1000033, 1000037)
# if memory_manager_hash() != 880511209:
# raise Exception(270)
# clear(-10, 141)
part "test_memory_manager_hash"
push -1
push 1
set
call "memory_manager_hash"
zero "__test_memory_manager_hash_2"
push 266
call "raise"
part "__test_memory_manager_hash_2"
push 1
push 2
call "memory_manager_append_cell"
call "memory_manager_hash"
push 2153645760
sub
zero "__test_memory_manager_hash_3"
push 267
call "raise"
part "__test_memory_manager_hash_3"
push 3
push 5
call "memory_manager_append_cell"
call "memory_manager_hash"
push 4048040839
sub
zero "__test_memory_manager_hash_4"
push 268
call "raise"
part "__test_memory_manager_hash_4"
push 7
push 11
call "memory_manager_append_cell"
call "memory_manager_hash"
push 265376592
sub
zero "__test_memory_manager_hash_5"
push 269
call "raise"
part "__test_memory_manager_hash_5"
push 1000033
push 1000037
call "memory_manager_append_cell"
call "memory_manager_hash"
push 880511209
sub
zero "__test_memory_manager_hash_return"
push 270
call "raise"
part "__test_memory_manager_hash_return"
push -10
push 141
call "clear"
back
|