Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/native/turing/origsel.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / native / turing / origsel.om` 1862 lines ยท 29923 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note omega-mv#700 ORIGSEL evaluator: the Turing measurement of the ORIG matvec arm chooser 3 note under calibration/profiles/Turing-profile-ORIGSEL-v1.1.toml, exactly as 4 note native/turing/REPORT-CONTRACT.md. Concatenated after the pinned units (add32, mul32, 5 note metadata, affine, fixture, world, omexp, omexpfix, select), origsel_kappa.om, then 6 note origselmain.om. It reads one stream on fd 0 and writes one result on fd 1: 7 note mode byte, config (8 LE words: 0 arm code 1..10 for P and M, 1 V1 bytes, 2..6 canonical 8 note P2 bytes of select.om, oxrule, oxstatic, oxnearok+oxl1+oxnear, origsel_kappa.om, 9 note 7 flags: bit 0 coder block present), allow block (4096), digests (96: profile, model, 10 note dataset), three SI19SLCK images (M1, CSH, CUN; 11560 bytes each), V1 bytes, coder block 11 note (480 bytes when flagged: 10 arms x rans, range x roundtrip, ideal_ub, coded_bits), 12 note then the collected records to end of input. 13 note Modes: R report, H report plus h1 lines, P TPS1 body of one arm (trailer by the glue), 14 note Y TSY1 body, M model code bytes of one arm, A audit derivative C', K image comparison. 15 note Arms (index, code - 1): 0 U, 1 O0, 2 FR, 3 S, 4 R, 5 M1, 6 M2, 7 A, 8 CSH, 9 CUN. 16 note TQZ: 0 n, 1 burned, 2 F, 3 fresh, 4 v1fam, 5 p1r, 6 ntrain, 7 bit count, 8 9 S orders, 17 note 11 records, 12 V1 records, 13 record bytes, 14 allow length, 15 cf blocks, 30 rng, 18 note 32..41 dl sums, 42..51 fresh sums, 52..61 v1fam sums. 19 note TQT: 3 longs (total, lb, ub) per statistic index; 90..92 the last tqst result. 20 global TQK uchar 64 21 global TQD uchar 96 22 global TQI uchar 34680 23 global TQV uchar 524288 24 global TQC uchar 480 25 global TQM uchar 1 26 global TQO ulong 20480 27 global TQN ulong 200 28 global TQQ ulong 200 29 global TQL ulong 16 30 global TQ2 ulong 16 31 global TQP ulong 16 32 global TQZ ulong 64 33 global TQDL ulong 2048 34 global TQPL ulong 2048 35 global TQVK ulong 2048 36 global TQU ulong 20480 37 global TQB ulong 512 38 global TQBS long 5120 39 global TQR long 100000 40 global TQS long 10001 41 global TQW uchar 16384 42 global TQF uchar 512 43 global TQOB uchar 131072 44 global TQT long 96 45 global TQDG uchar 24 46 text TQH0 "ORIGSEL v1.1\n" 47 text TQA0 "admit records=" 48 text TQA1 " admitted=" 49 text TQA2 " train=" 50 text TQA3 " validation=" 51 text TQA4 " heldout=" 52 text TQD0 "d n=" 53 text TQD1 " burned=" 54 text TQD2 " F=" 55 text TQD3 " fresh=" 56 text TQD4 " v1fam=" 57 text TQD5 " p1r=" 58 text TQR0 "arm " 59 text TQR1 " p1=" 60 text TQR2 " p2=" 61 text TQR3 " dl=" 62 text TQR4 " rows=" 63 text TQT0 "t " 64 text TQT1 " total=" 65 text TQT2 " lb=" 66 text TQT3 " ub=" 67 text TQT4 "dl " 68 text TQT5 "delta M2 M1" 69 text TQT6 "tcf " 70 text TQT7 "nmin " 71 text TQT8 "verdict " 72 text TQT9 "experiment " 73 text TQNM "UO0FRSRM1M2ACSHCUN" 74 text TQV0 "QUALIFIED_IMPROVEMENT" 75 text TQV1 "NO_IMPROVEMENT(COST_BOUND)" 76 text TQV2 "NO_IMPROVEMENT" 77 text TQV3 "INCONCLUSIVE(UNDERPOWERED)" 78 text TQV4 "INCONCLUSIVE" 79 text TQV5 "QUALIFIED_IMPROVEMENT(UNISOLATED)" 80 text TQE0 "refused allow\n" 81 text TQE1 "refused admission " 82 text TQE2 "refused image " 83 text TQK0 "K same\n" 84 text TQK1 "K diff " 85 text TQX0 "h1 " 86 text TQX1 " rans" 87 text TQX2 " range" 88 text TQX3 " rt=" 89 text TQX4 " ideal=" 90 text TQX5 " delta=" 91 text TQX6 " band=" 92 text TQX7 "match" 93 text TQX8 "mismatch" 94 text TQX9 "ok" 95 text TQY0 "fail" 96 text TQY1 "h1t " 97 text TQY2 " treal=" 98 text TQY3 " lbreal=" 99 text TQY4 " h1=" 100 text TQY5 " compression=" 101 text TQY6 "pass" 102 text TQY7 "yes" 103 text TQY8 "no" 104 text TQY9 " FR" 105 text TQSP " " 106 text TQNL "\n" 107 text TQMI "-" 108 text TQCM "," 109 text TQSC ";" 110 text TQRS "ORS1" 111 112 note ---------------------------------------------------------------- output 113 114 fn tqnl to void 115 w = write 1 TQNL 0 1 116 end 117 118 fn tqsp to void 119 w = write 1 TQSP 0 1 120 end 121 122 fn tqsn x long to void 123 note Signed decimal. 124 if lt x 0 125 w = write 1 TQMI 0 1 126 wnum ulong neg x 127 ret 128 end 129 wnum ulong x 130 end 131 132 fn tqnoff x ulong to ulong 133 note Offset * 16 + length of arm x's name in TQNM. 134 if eq x 0 135 ret 1 136 end 137 if eq x 1 138 ret 18 139 end 140 if eq x 2 141 ret 50 142 end 143 if eq x 3 144 ret 81 145 end 146 if eq x 4 147 ret 97 148 end 149 if eq x 5 150 ret 114 151 end 152 if eq x 6 153 ret 146 154 end 155 if eq x 7 156 ret 177 157 end 158 if eq x 8 159 ret 195 160 end 161 ret 243 162 end 163 164 fn tqname x ulong to void 165 v = tqnoff x 166 w = write 1 TQNM shr v 4 and v 15 167 end 168 169 fn tqvw v ulong to void 170 note Verdict word v (0..5). 171 if eq v 0 172 w = write 1 TQV0 0 len TQV0 173 end 174 if eq v 1 175 w = write 1 TQV1 0 len TQV1 176 end 177 if eq v 2 178 w = write 1 TQV2 0 len TQV2 179 end 180 if eq v 3 181 w = write 1 TQV3 0 len TQV3 182 end 183 if eq v 4 184 w = write 1 TQV4 0 len TQV4 185 end 186 if eq v 5 187 w = write 1 TQV5 0 len TQV5 188 end 189 end 190 191 fn tqout n ulong to void 192 note Write TQOB[0..n) to fd 1. 193 o = ulong 0 194 while lt o n bound 999999 195 w = write 1 TQOB o sub n o 196 if le w 0 197 exit 74 198 end 199 o = add o ulong w 200 end 201 end 202 203 fn tqpb p ulong v ulong k ulong to void 204 note k little-endian bytes of v at TQOB[p]. 205 for i ulong k 206 put TQOB add p i uchar and shr v mul i 8 255 207 end 208 end 209 210 note ---------------------------------------------------------------- input 211 212 fn tqrdk to bool 213 o = ulong 0 214 while lt o 64 bound 64 215 r = read 0 TQK o sub 64 o 216 if le r 0 217 ret false 218 end 219 o = add o ulong r 220 end 221 ret true 222 end 223 224 fn tqkw i ulong to ulong 225 v = ulong 0 226 for k ulong 8 227 v = or v shl ulong get TQK add mul i 8 k mul k 8 228 end 229 ret v 230 end 231 232 fn tqrdlb to bool 233 note The allow block into LB (4096 bytes); TQZ[14] = used length. 234 o = ulong 0 235 while lt o 4096 bound 4096 236 r = read 0 LB o sub 4096 o 237 if le r 0 238 ret false 239 end 240 o = add o ulong r 241 end 242 n = ulong 0 243 for i ulong 4096 244 if ne get LB i 0 245 n = add i 1 246 end 247 end 248 put TQZ 14 n 249 ret true 250 end 251 252 fn tqrdd to bool 253 o = ulong 0 254 while lt o 96 bound 96 255 r = read 0 TQD o sub 96 o 256 if le r 0 257 ret false 258 end 259 o = add o ulong r 260 end 261 ret true 262 end 263 264 fn tqrdi to bool 265 o = ulong 0 266 while lt o 34680 bound 34680 267 r = read 0 TQI o sub 34680 o 268 if le r 0 269 ret false 270 end 271 o = add o ulong r 272 end 273 ret true 274 end 275 276 fn tqrdv n ulong to bool 277 o = ulong 0 278 while lt o n bound 524288 279 r = read 0 TQV o sub n o 280 if le r 0 281 ret false 282 end 283 o = add o ulong r 284 end 285 ret true 286 end 287 288 fn tqrdc to bool 289 o = ulong 0 290 while lt o 480 bound 480 291 r = read 0 TQC o sub 480 o 292 if le r 0 293 ret false 294 end 295 o = add o ulong r 296 end 297 ret true 298 end 299 300 fn tqrdrb to ulong 301 note Records to end of input into RB; 524289 when more than the capacity arrived. 302 o = ulong 0 303 while lt o 524288 bound 999999 304 r = read 0 RB o sub 524288 o 305 if lt r 0 306 exit 74 307 end 308 if eq r 0 309 ret o 310 end 311 o = add o ulong r 312 end 313 r = read 0 TQM 0 1 314 if ne r 0 315 ret 524289 316 end 317 ret o 318 end 319 320 fn tqcw a ulong i ulong to ulong 321 note Coder block word i of arm a (6 words per arm: rans rt, ideal, bits, range rt, ideal, bits). 322 v = ulong 0 323 b = add mul a 48 mul i 8 324 for k ulong 8 325 v = or v shl ulong get TQC add b k mul k 8 326 end 327 ret v 328 end 329 330 fn tqiw k ulong j ulong to ulong 331 note Low 32 bits of the u64 at image k offset j. 332 b = add mul k 11560 j 333 v = ulong 0 334 for i ulong 4 335 v = or v shl ulong get TQI add b i mul i 8 336 end 337 ret v 338 end 339 340 fn tqv1w q ulong i ulong to ulong 341 v = ulong 0 342 b = add mul q 256 mul i 8 343 for k ulong 8 344 v = or v shl ulong get TQV add b k mul k 8 345 end 346 ret v 347 end 348 349 fn tqv1 to void 350 note V1 shape keys (M * 16384 + N) and cells. 351 k = div tqkw 1 256 352 put TQZ 12 k 353 for q ulong k 354 m = tqv1w q 5 355 n = tqv1w q 6 356 put TQVK q add mul m 16384 n 357 if and ge m 1 ge n 1 358 c = add mul oxfl m 16 oxfl n 359 if lt c 512 360 put TQF c 1 361 end 362 end 363 end 364 end 365 366 note ---------------------------------------------------------------- record classes 367 368 fn tqfit r ulong to bool 369 note R1 fit set: admitted VALIDATION, pressure 0, core 0 or 1. 370 if ne oxpart r 1 371 ret false 372 end 373 if ne oxpress r 0 374 ret false 375 end 376 ret le oxcore r 1 377 end 378 379 fn tqheld r ulong p ulong to bool 380 if ne oxpart r 2 381 ret false 382 end 383 if ne oxpress r p 384 ret false 385 end 386 ret le oxcore r 1 387 end 388 389 fn tqburn r ulong to bool 390 key = add mul oxm r 16384 oxn r 391 k = get TQZ 12 392 for q ulong k 393 if eq get TQVK q key 394 ret true 395 end 396 end 397 ret false 398 end 399 400 note ---------------------------------------------------------------- orders 401 402 fn tqidp to ulong 403 ret 274960 404 end 405 406 fn tqarm pk ulong j ulong to ulong 407 ret and shr pk mul 4 j 15 408 end 409 410 fn tqrank pk ulong a ulong to ulong 411 for j ulong 5 412 if eq tqarm pk j a 413 ret j 414 end 415 end 416 exit 92 417 end 418 419 fn tqord5 k view long 5 to ulong 420 note Arms ascending by key, ties to the lower index, packed 4 bits per rank. 421 used = ulong 0 422 pk = ulong 0 423 for j ulong 5 424 b = ulong 5 425 for a ulong 5 426 if eq and shr used a 1 0 427 if eq b 5 428 b = a 429 else 430 if lt get k a get k b 431 b = a 432 end 433 end 434 end 435 end 436 used = or used shl 1 b 437 pk = or pk shl b mul 4 j 438 end 439 ret pk 440 end 441 442 fn tqfr r ulong to ulong 443 ra = ulong 3 444 if le oxn r 8 445 ra = 2 446 end 447 pk = ra 448 p = ulong 1 449 for a ulong 5 450 if ne a ra 451 pk = or pk shl a mul 4 p 452 p = add p 1 453 end 454 end 455 ret pk 456 end 457 458 fn tqqord q ulong to ulong 459 note Arms of record q ascending by its measured ps. 460 k = new long 5 0 461 for a ulong 5 462 put k a long oxcost q a 463 end 464 ret tqord5 k 465 end 466 467 fn tqstat to void 468 note S: per core class 0 and 1, arms ascending by total TRAIN ps (both pressures). 469 k = new long 5 0 470 for c ulong 2 471 for a ulong 5 472 put k a 0 473 end 474 for q ulong get TQZ 11 475 if and eq oxpart q 0 eq oxcore q c 476 for a ulong 5 477 put k a add get k a long oxcost q a 478 end 479 end 480 end 481 put TQZ add 8 c tqord5 k 482 end 483 end 484 485 fn tqnear r ulong to ulong 486 q = oxnear r 487 if ge q `1048576` 488 ret tqidp 489 end 490 ret tqqord q 491 end 492 493 fn tqmlp r ulong to ulong 494 k = new long 5 0 495 for a ulong 5 496 put k a slkey slfwd r a 497 end 498 ret tqord5 k 499 end 500 501 fn tqctx x ulong r ulong to ulong 502 if or eq x 6 eq x 7 503 ret tkappa r 504 end 505 ret 0 506 end 507 508 fn tqnctx x ulong to ulong 509 if or eq x 6 eq x 7 510 ret 4 511 end 512 ret 1 513 end 514 515 fn tqneed r ulong to bool 516 if tqfit r 517 ret true 518 end 519 if eq oxpart r 2 520 ret le oxcore r 1 521 end 522 ret false 523 end 524 525 fn tqorders to void 526 note Non-MLP orders for every needed record. 527 for r ulong get TQZ 11 528 if tqneed r 529 put TQO r tqidp 530 put TQO add 2048 r tqidp 531 put TQO add 4096 r tqfr r 532 put TQO add 6144 r get TQZ add 8 oxcore r 533 put TQO add 8192 r tqnear r 534 put TQO add 14336 r tqidp 535 end 536 end 537 end 538 539 fn tqimg k ulong to int 540 note Install image k (0 M1, 1 CSH, 2 CUN) through sladmit, best-on-VALIDATION params. 541 b = mul k 11560 542 for i ulong 11560 543 put SI i get TQI add b i 544 end 545 st = sladmit 0 11560 546 if ne st 0 547 ret st 548 end 549 if or ne get SS 0 2 ne get SS 1 32 550 ret -20 551 end 552 if ne get SS 20 1 553 ret -21 554 end 555 slbest 556 ret 0 557 end 558 559 fn tqmord k ulong to void 560 note MLP orders of image k into its arms (k 0: M1 and M2, 1: CSH, 2: CUN). 561 for r ulong get TQZ 11 562 if tqneed r 563 pk = tqmlp r 564 if eq k 0 565 put TQO add 10240 r pk 566 put TQO add 12288 r pk 567 end 568 if eq k 1 569 put TQO add 16384 r pk 570 end 571 if eq k 2 572 put TQO add 18432 r pk 573 end 574 end 575 end 576 end 577 578 note ---------------------------------------------------------------- rows (F1) 579 580 fn tqcount to void 581 for i ulong 200 582 put TQN i 0 583 end 584 for r ulong get TQZ 11 585 if tqfit r 586 x = oxbest r 587 for a ulong 9 588 v = add a 1 589 c = tqctx v r 590 k = tqrank get TQO add mul v 2048 r x 591 i = add add mul v 20 mul c 5 k 592 put TQN i add get TQN i 1 593 end 594 end 595 end 596 end 597 598 fn tqrow x ulong c ulong to void 599 note F1 for arm x, context c. 600 b = add mul x 20 mul c 5 601 n = ulong 0 602 for r ulong 5 603 n = add n get TQN add b r 604 end 605 s = ulong 0 606 for r ulong 5 607 nr = add mul 2 get TQN add b r 1 608 dn = add mul 2 n 5 609 q = add 1 div mul 65531 nr dn 610 put TQQ add b r q 611 s = add s q 612 end 613 m = ulong 0 614 for r ulong 5 615 if gt get TQN add b r get TQN add b m 616 m = r 617 end 618 end 619 qm = add get TQQ add b m sub 65536 s 620 put TQQ add b m qm 621 end 622 623 fn tqrows to void 624 put TQQ 0 13108 625 for r ulong 4 626 put TQQ add r 1 13107 627 end 628 for i ulong 9 629 x = add i 1 630 for c ulong tqnctx x 631 tqrow x c 632 end 633 end 634 end 635 636 fn tqrown x ulong c ulong to ulong 637 b = add mul x 20 mul c 5 638 n = ulong 0 639 for r ulong 5 640 n = add n get TQN add b r 641 end 642 ret n 643 end 644 645 note ---------------------------------------------------------------- model codes 646 647 fn tqwclr to void 648 for i ulong 16384 649 put TQW i 0 650 end 651 put TQZ 7 0 652 end 653 654 fn tqbit b ulong to void 655 c = get TQZ 7 656 if ge c 131072 657 exit 93 658 end 659 if ne b 0 660 i = div c 8 661 v = ulong get TQW i 662 v = or v shl 1 sub 7 rem c 8 663 put TQW i uchar v 664 end 665 put TQZ 7 add c 1 666 end 667 668 fn tqbits v ulong w ulong to void 669 for j ulong w 670 tqbit and shr v sub sub w 1 j 1 671 end 672 end 673 674 fn tqgam v ulong to void 675 note Elias gamma of v >= 1. 676 l = oxfl v 677 for i ulong l 678 tqbit 0 679 end 680 tqbits v add l 1 681 end 682 683 fn tqbin n ulong k ulong to ulong 684 if gt k n 685 ret 0 686 end 687 r = ulong 1 688 for i ulong k 689 r = div mul r sub n i add i 1 690 end 691 ret r 692 end 693 694 fn tqclg v ulong to ulong 695 if le v 1 696 ret 0 697 end 698 ret add oxfl sub v 1 1 699 end 700 701 fn tqenum x ulong c ulong to ulong 702 note Lexicographic index of the count vector among 5-part compositions of N. 703 b = add mul x 20 mul c 5 704 rr = tqrown x c 705 idx = ulong 0 706 for i ulong 4 707 ni = get TQN add b i 708 for v ulong ni 709 idx = add idx tqbin sub add rr sub 3 i v sub 3 i 710 end 711 rr = sub rr ni 712 end 713 ret idx 714 end 715 716 fn tqwrow x ulong c ulong to void 717 n = tqrown x c 718 tqgam add n 1 719 tqbits tqenum x c tqclg tqbin add n 4 4 720 end 721 722 fn tqtgfr to void 723 note TG1 of the incumbent: one test (word 6 <= 8), leaves arm 2 and arm 3. 724 tqgam 2 725 tqbits 3 3 726 tqbit 0 727 tqgam 9 728 tqbits 2 3 729 tqbits 3 3 730 end 731 732 fn tqtgk to void 733 note TG1 of kappa: tests word 3 = 1 and word 6 <= 8, no leaves. 734 tqgam 3 735 tqbits 0 3 736 tqbit 1 737 tqgam 2 738 tqbits 3 3 739 tqbit 0 740 tqgam 9 741 end 742 743 fn tqfac m ulong to ulong 744 if eq m 4 745 ret 24 746 end 747 if eq m 3 748 ret 6 749 end 750 if eq m 2 751 ret 2 752 end 753 ret 1 754 end 755 756 fn tqpidx pk ulong to ulong 757 idx = ulong 0 758 for i ulong 5 759 ai = tqarm pk i 760 cnt = ulong 0 761 for j ulong 5 762 if and gt j i lt tqarm pk j ai 763 cnt = add cnt 1 764 end 765 end 766 idx = add idx mul cnt tqfac sub 4 i 767 end 768 ret idx 769 end 770 771 fn tqwmlp k ulong to void 772 note MLP metadata (kind 2, H 32, 705 params) and the 705 SB patterns of image k. 773 tqbits 2 8 774 tqbits 32 8 775 tqbits 705 16 776 for i ulong 705 777 tqbits tqiw k add 5912 mul i 8 32 778 end 779 end 780 781 fn tqwret to void 782 note R: the stored TRAIN table. 783 tqbits get TQZ 6 12 784 for q ulong get TQZ 11 785 if eq oxpart q 0 786 tqbits oxcore q 2 787 tqbits oxpress q 1 788 tqbits oxlg16 oxm q 8 789 tqbits oxlg16 oxn q 8 790 tqbits tqpidx tqqord q 7 791 end 792 end 793 end 794 795 fn tqcode x ulong to ulong 796 note Write arm x's canonical model code into TQW; returns its length in bits (P1). 797 tqwclr 798 if eq x 1 799 tqwrow 1 0 800 end 801 if eq x 2 802 tqtgfr 803 tqwrow 2 0 804 end 805 if eq x 3 806 tqbits tqpidx get TQZ 8 7 807 tqbits tqpidx get TQZ 9 7 808 tqwrow 3 0 809 end 810 if eq x 4 811 tqwret 812 tqwrow 4 0 813 end 814 if eq x 5 815 tqwmlp 0 816 tqwrow 5 0 817 end 818 if eq x 6 819 tqwmlp 0 820 tqtgk 821 for c ulong 4 822 tqwrow 6 c 823 end 824 end 825 if eq x 7 826 tqtgk 827 for c ulong 4 828 tqwrow 7 c 829 end 830 end 831 if eq x 8 832 tqwmlp 1 833 tqwrow 8 0 834 end 835 if eq x 9 836 tqwmlp 2 837 tqwrow 9 0 838 end 839 ret get TQZ 7 840 end 841 842 fn tqp2b x ulong to ulong 843 note Canonical P2 source bytes of arm x (config words 2..6). 844 if or eq x 5 or eq x 8 eq x 9 845 ret tqkw 2 846 end 847 if eq x 2 848 ret tqkw 3 849 end 850 if eq x 3 851 ret tqkw 4 852 end 853 if eq x 4 854 ret tqkw 5 855 end 856 if eq x 6 857 ret add tqkw 2 tqkw 6 858 end 859 if eq x 7 860 ret tqkw 6 861 end 862 ret 0 863 end 864 865 fn tqlens to void 866 for x ulong 10 867 l = tqcode x 868 put TQL x l 869 put TQ2 x add l mul 8 tqp2b x 870 end 871 end 872 873 note ---------------------------------------------------------------- ub (CODER_SPEC s.8) 874 875 fn tqsq m ulong to ulong 876 note floor(m * m / 2^62) for m < 2^63, through 32-bit limbs. 877 a = shr m 32 878 b = and m `4294967295` 879 p0 = mul b b 880 p1 = mul a b 881 p2 = mul a a 882 c = shl p1 1 883 mid = add shr p0 32 and c `4294967295` 884 lo = or and p0 `4294967295` shl and mid `4294967295` 32 885 hi = add add p2 shr c 32 shr mid 32 886 ret or shl hi 2 shr lo 62 887 end 888 889 fn tqub q ulong to ulong 890 ip = oxfl q 891 m = shl q sub 62 ip 892 f = ulong 0 893 for i ulong 32 894 m = tqsq m 895 if ge m `9223372036854775808` 896 f = or f shl 1 sub 31 i 897 m = shr m 1 898 end 899 end 900 l = or shl ip 32 f 901 x = sub `68719476736` l 902 ret shr add mul x `1000000` `2147483648` 32 903 end 904 905 fn tqq x ulong r ulong a ulong to ulong 906 note q of arm a at record r under arm x. 907 c = tqctx x r 908 k = tqrank get TQO add mul x 2048 r a 909 ret get TQQ add add mul x 20 mul c 5 k 910 end 911 912 note ---------------------------------------------------------------- D, blocks, sums 913 914 fn tqsel to void 915 note D, P1R, burned, F, fresh / v1fam counts. 916 n = ulong 0 917 p = ulong 0 918 bu = ulong 0 919 for i ulong 512 920 put TQB i 0 921 end 922 for r ulong get TQZ 11 923 if tqheld r 0 924 if tqburn r 925 bu = add bu 1 926 else 927 put TQDL n r 928 n = add n 1 929 put TQB oxcell r 1 930 end 931 end 932 if tqheld r 1 933 if not tqburn r 934 put TQPL p r 935 p = add p 1 936 end 937 end 938 end 939 f = ulong 0 940 for c ulong 512 941 if ne get TQB c 0 942 f = add f 1 943 put TQB c f 944 end 945 end 946 put TQZ 0 n 947 put TQZ 1 bu 948 put TQZ 2 f 949 put TQZ 5 p 950 fr = ulong 0 951 for t ulong n 952 if eq get TQF oxcell get TQDL t 0 953 fr = add fr 1 954 end 955 end 956 put TQZ 3 fr 957 put TQZ 4 sub n fr 958 end 959 960 fn tqntr to void 961 k = ulong 0 962 for q ulong get TQZ 11 963 if eq oxpart q 0 964 k = add k 1 965 end 966 end 967 put TQZ 6 k 968 end 969 970 fn tqzadd i ulong u ulong to void 971 put TQZ i add get TQZ i u 972 end 973 974 fn tqubs to void 975 note Per-decision ub of every arm over D, dl / fresh / v1fam sums. 976 for i ulong 30 977 put TQZ add 32 i 0 978 end 979 for t ulong get TQZ 0 980 r = get TQDL t 981 x = oxbest r 982 v1 = ne get TQF oxcell r 0 983 for a ulong 10 984 u = tqub tqq a r x 985 put TQU add mul a 2048 t u 986 tqzadd add 32 a u 987 if v1 988 tqzadd add 52 a u 989 else 990 tqzadd add 42 a u 991 end 992 end 993 end 994 end 995 996 fn tqp1rs x ulong to ulong 997 s = ulong 0 998 for t ulong get TQZ 5 999 r = get TQPL t 1000 s = add s tqub tqq x r oxbest r 1001 end 1002 ret s 1003 end 1004 1005 fn tqbadd i ulong v long to void 1006 put TQBS i add get TQBS i v 1007 end 1008 1009 fn tqbrec t ulong j ulong to void 1010 for a ulong 10 1011 k = add mul a 512 j 1012 v = long get TQU add mul a 2048 t 1013 tqbadd k v 1014 end 1015 end 1016 1017 fn tqbsum cf bool to void 1018 note Block sums of every arm: family blocks, or (cell, core) blocks when cf. 1019 for i ulong 5120 1020 put TQBS i 0 1021 end 1022 for t ulong get TQZ 0 1023 r = get TQDL t 1024 j = sub get TQB oxcell r 1 1025 if cf 1026 j = sub get TQB add mul oxcell r 2 oxcore r 1 1027 end 1028 tqbrec t j 1029 end 1030 end 1031 1032 fn tqcfb to ulong 1033 note (cell, core) block ids into TQB (key 2 cell + core); returns their count. 1034 for i ulong 512 1035 put TQB i 0 1036 end 1037 for t ulong get TQZ 0 1038 r = get TQDL t 1039 put TQB add mul oxcell r 2 oxcore r 1 1040 end 1041 f = ulong 0 1042 for c ulong 512 1043 if ne get TQB c 0 1044 f = add f 1 1045 put TQB c f 1046 end 1047 end 1048 ret f 1049 end 1050 1051 note ---------------------------------------------------------------- bootstrap 1052 1053 fn tqsm to ulong 1054 note splitmix64 (wrapping), state TQZ[30]. 1055 s = add get TQZ 30 `11400714819323198485` 1056 put TQZ 30 s 1057 z = s 1058 z = mul xor z shr z 30 `13787848793156543929` 1059 z = mul xor z shr z 27 `10723151780598845931` 1060 ret xor z shr z 31 1061 end 1062 1063 fn tqboot nb ulong to void 1064 acc = new long 10 0 1065 put TQZ 30 `20261025` 1066 for i ulong 10000 1067 for x ulong 10 1068 put acc x 0 1069 end 1070 for k ulong nb 1071 p = rem tqsm nb 1072 for x ulong 10 1073 put acc x add get acc x get TQBS add mul x 512 p 1074 end 1075 end 1076 for x ulong 10 1077 put TQR add mul i 10 x get acc x 1078 end 1079 end 1080 end 1081 1082 fn tqsift s ulong e ulong to void 1083 r = s 1084 c = add mul r 2 1 1085 while lt c e bound 64 1086 d = add c 1 1087 if lt d e 1088 if lt get TQS c get TQS d 1089 c = d 1090 end 1091 end 1092 if lt get TQS r get TQS c 1093 t = get TQS r 1094 put TQS r get TQS c 1095 put TQS c t 1096 r = c 1097 c = add mul r 2 1 1098 else 1099 c = e 1100 end 1101 end 1102 end 1103 1104 fn tqhsort to void 1105 s = ulong 5000 1106 while gt s 0 bound 5001 1107 s = sub s 1 1108 tqsift s 10000 1109 end 1110 e = ulong 10000 1111 while gt e 1 bound 10001 1112 e = sub e 1 1113 t = get TQS 0 1114 put TQS 0 get TQS e 1115 put TQS e t 1116 tqsift 0 e 1117 end 1118 end 1119 1120 fn tqst m ulong y ulong cost bool to void 1121 note Statistic S_Y - S_M (- 10^6 (P1 M - P1 Y) when cost): total, lb, ub into TQT[90..92]. 1122 d = long 0 1123 if cost 1124 d = mul `1000000` sub long get TQL m long get TQL y 1125 end 1126 for i ulong 10000 1127 va = get TQR add mul i 10 y 1128 vb = get TQR add mul i 10 m 1129 put TQS i sub sub va vb d 1130 end 1131 tqhsort 1132 va = long get TQZ add 32 y 1133 vb = long get TQZ add 32 m 1134 put TQT 90 sub sub va vb d 1135 put TQT 91 get TQS 166 1136 put TQT 92 get TQS 9833 1137 end 1138 1139 fn tqkeep i ulong to void 1140 put TQT mul i 3 get TQT 90 1141 put TQT add mul i 3 1 get TQT 91 1142 put TQT add mul i 3 2 get TQT 92 1143 end 1144 1145 fn tqtlu to void 1146 w = write 1 TQT1 0 len TQT1 1147 tqsn get TQT 90 1148 w = write 1 TQT2 0 len TQT2 1149 tqsn get TQT 91 1150 w = write 1 TQT3 0 len TQT3 1151 tqsn get TQT 92 1152 tqnl 1153 end 1154 1155 fn tqmy i ulong to ulong 1156 note Arm of t-line row i: M1 M2 A R CSH CUN. 1157 if eq i 0 1158 ret 5 1159 end 1160 if eq i 1 1161 ret 6 1162 end 1163 if eq i 2 1164 ret 7 1165 end 1166 if eq i 3 1167 ret 4 1168 end 1169 if eq i 4 1170 ret 8 1171 end 1172 ret 9 1173 end 1174 1175 fn tqyy j ulong to ulong 1176 note Baseline of column j: FR U O0 S. 1177 if eq j 0 1178 ret 2 1179 end 1180 if eq j 1 1181 ret 0 1182 end 1183 if eq j 2 1184 ret 1 1185 end 1186 ret 3 1187 end 1188 1189 note ---------------------------------------------------------------- report 1190 1191 fn tqarml x ulong to void 1192 w = write 1 TQR0 0 len TQR0 1193 tqname x 1194 w = write 1 TQR1 0 len TQR1 1195 wnum get TQL x 1196 w = write 1 TQR2 0 len TQR2 1197 wnum get TQ2 x 1198 w = write 1 TQR3 0 len TQR3 1199 wnum get TQZ add 32 x 1200 w = write 1 TQD3 0 len TQD3 1201 wnum get TQZ add 42 x 1202 w = write 1 TQD4 0 len TQD4 1203 wnum get TQZ add 52 x 1204 w = write 1 TQD5 0 len TQD5 1205 wnum tqp1rs x 1206 w = write 1 TQR4 0 len TQR4 1207 if eq x 0 1208 w = write 1 TQMI 0 1 1209 else 1210 for c ulong tqnctx x 1211 if gt c 0 1212 w = write 1 TQSC 0 1 1213 end 1214 for r ulong 5 1215 if gt r 0 1216 w = write 1 TQCM 0 1 1217 end 1218 wnum get TQN add add mul x 20 mul c 5 r 1219 end 1220 end 1221 end 1222 tqnl 1223 end 1224 1225 fn tqhead to void 1226 w = write 1 TQH0 0 len TQH0 1227 w = write 1 TQA0 0 len TQA0 1228 wnum get TQZ 11 1229 w = write 1 TQA1 0 len TQA1 1230 wnum get RC 10 1231 w = write 1 TQA2 0 len TQA2 1232 wnum get RC 4 1233 w = write 1 TQA3 0 len TQA3 1234 wnum get RC 5 1235 w = write 1 TQA4 0 len TQA4 1236 wnum get RC 6 1237 tqnl 1238 w = write 1 TQD0 0 len TQD0 1239 wnum get TQZ 0 1240 w = write 1 TQD1 0 len TQD1 1241 wnum get TQZ 1 1242 w = write 1 TQD2 0 len TQD2 1243 wnum get TQZ 2 1244 w = write 1 TQD3 0 len TQD3 1245 wnum get TQZ 3 1246 w = write 1 TQD4 0 len TQD4 1247 wnum get TQZ 4 1248 w = write 1 TQD5 0 len TQD5 1249 wnum get TQZ 5 1250 tqnl 1251 end 1252 1253 fn tqtlines to void 1254 note t, dl and delta lines; kept in TQT by index (t: 4 i + j, dl: 24, 25, delta: 26). 1255 for i ulong 6 1256 m = tqmy i 1257 for j ulong 4 1258 y = tqyy j 1259 tqst m y true 1260 tqkeep add mul i 4 j 1261 w = write 1 TQT0 0 len TQT0 1262 tqname m 1263 tqsp 1264 tqname y 1265 tqtlu 1266 end 1267 end 1268 tqst 5 8 false 1269 tqkeep 24 1270 w = write 1 TQT4 0 len TQT4 1271 tqname 5 1272 tqsp 1273 tqname 8 1274 tqtlu 1275 tqst 5 9 false 1276 tqkeep 25 1277 w = write 1 TQT4 0 len TQT4 1278 tqname 5 1279 tqsp 1280 tqname 9 1281 tqtlu 1282 tqst 6 5 true 1283 tqkeep 26 1284 w = write 1 TQT5 0 len TQT5 1285 tqtlu 1286 end 1287 1288 fn tqtcf to void 1289 for i ulong 3 1290 m = tqmy i 1291 tqst m 2 true 1292 w = write 1 TQT6 0 len TQT6 1293 tqname m 1294 w = write 1 TQY9 0 len TQY9 1295 tqtlu 1296 end 1297 end 1298 1299 fn tqnmin m ulong to ulong 1300 v = mul get TQL m `1000000` 1301 q = div v `2321950` 1302 if ne rem v `2321950` 0 1303 q = add q 1 1304 end 1305 ret q 1306 end 1307 1308 fn tqlb i ulong to long 1309 ret get TQT add mul i 3 1 1310 end 1311 1312 fn tqverd i ulong to ulong 1313 note Verdict word of candidate row i (0 M1, 1 M2, 2 A). 1314 m = tqmy i 1315 if or lt get TQZ 2 20 lt get TQZ 0 100 1316 ret 3 1317 end 1318 b = mul i 4 1319 q = gt get TQT mul b 3 0 1320 for j ulong 4 1321 if le tqlb add b j 0 1322 q = false 1323 end 1324 end 1325 if lt i 2 1326 if or le tqlb 24 0 le tqlb 25 0 1327 q = false 1328 end 1329 end 1330 if q 1331 ret 0 1332 end 1333 if le get TQT add mul b 3 2 0 1334 if lt get TQZ 0 tqnmin m 1335 ret 1 1336 end 1337 ret 2 1338 end 1339 ret 4 1340 end 1341 1342 fn tqverds to void 1343 for i ulong 3 1344 w = write 1 TQT7 0 len TQT7 1345 tqname tqmy i 1346 tqsp 1347 wnum tqnmin tqmy i 1348 tqnl 1349 end 1350 anyq = false 1351 alln = true 1352 for i ulong 3 1353 v = tqverd i 1354 if eq v 0 1355 anyq = true 1356 end 1357 if gt v 2 1358 alln = false 1359 end 1360 if eq v 0 1361 alln = false 1362 end 1363 w = write 1 TQT8 0 len TQT8 1364 tqname tqmy i 1365 tqsp 1366 tqvw v 1367 tqnl 1368 end 1369 w = write 1 TQT9 0 len TQT9 1370 if anyq 1371 tqvw 5 1372 else 1373 if alln 1374 tqvw 2 1375 else 1376 tqvw 4 1377 end 1378 end 1379 tqnl 1380 end 1381 1382 fn tqbw n ulong to ulong 1383 note H1 band in micro-bits: (64 + ceil(n / 64)) 10^6. 1384 c = div n 64 1385 if ne rem n 64 0 1386 c = add c 1 1387 end 1388 ret mul add 64 c `1000000` 1389 end 1390 1391 fn tqdel a ulong k ulong to long 1392 note delta of arm a under coder k (0 rans, 1 range) in micro-bits. 1393 ret sub mul long tqcw a add mul k 3 2 `1000000` long get TQZ add 32 a 1394 end 1395 1396 fn tqaok a ulong k ulong to bool 1397 note Round trip, ideal agreement and band of arm a under coder k. 1398 if ne tqcw a mul k 3 1 1399 ret false 1400 end 1401 if ne tqcw a add mul k 3 1 get TQZ add 32 a 1402 ret false 1403 end 1404 e = sub tqdel a k `448000000` 1405 ret le wsabs e long tqbw get TQZ 0 1406 end 1407 1408 fn tqh1a a ulong k ulong to void 1409 w = write 1 TQX0 0 len TQX0 1410 tqname a 1411 if eq k 0 1412 w = write 1 TQX1 0 len TQX1 1413 else 1414 w = write 1 TQX2 0 len TQX2 1415 end 1416 w = write 1 TQX3 0 len TQX3 1417 wnum tqcw a mul k 3 1418 w = write 1 TQX4 0 len TQX4 1419 if eq tqcw a add mul k 3 1 get TQZ add 32 a 1420 w = write 1 TQX7 0 len TQX7 1421 else 1422 w = write 1 TQX8 0 len TQX8 1423 end 1424 w = write 1 TQX5 0 len TQX5 1425 tqsn tqdel a k 1426 w = write 1 TQX6 0 len TQX6 1427 if tqaok a k 1428 w = write 1 TQX9 0 len TQX9 1429 else 1430 w = write 1 TQY0 0 len TQY0 1431 end 1432 tqnl 1433 end 1434 1435 fn tqh1t i ulong k ulong to void 1436 m = tqmy i 1437 dd = sub tqdel 2 k tqdel m k 1438 ok = and tqaok 2 k tqaok m k 1439 if gt wsabs dd mul 2 long tqbw get TQZ 0 1440 ok = false 1441 end 1442 lbr = add tqlb mul i 4 dd 1443 w = write 1 TQY1 0 len TQY1 1444 tqname m 1445 w = write 1 TQY9 0 len TQY9 1446 if eq k 0 1447 w = write 1 TQX1 0 len TQX1 1448 else 1449 w = write 1 TQX2 0 len TQX2 1450 end 1451 w = write 1 TQY2 0 len TQY2 1452 tqsn add get TQT mul mul i 4 3 dd 1453 w = write 1 TQY3 0 len TQY3 1454 tqsn lbr 1455 w = write 1 TQY4 0 len TQY4 1456 if ok 1457 w = write 1 TQY6 0 len TQY6 1458 else 1459 w = write 1 TQY0 0 len TQY0 1460 end 1461 w = write 1 TQY5 0 len TQY5 1462 if and ok gt lbr 0 1463 w = write 1 TQY7 0 len TQY7 1464 else 1465 w = write 1 TQY8 0 len TQY8 1466 end 1467 tqnl 1468 end 1469 1470 fn tqh1 to void 1471 for a ulong 10 1472 for k ulong 2 1473 tqh1a a k 1474 end 1475 end 1476 for i ulong 3 1477 for k ulong 2 1478 tqh1t i k 1479 end 1480 end 1481 end 1482 1483 note ---------------------------------------------------------------- TPS1, TSY1, model code bytes 1484 1485 fn tqtps a ulong to void 1486 note TPS1 header and records of arm a (trailer appended by the glue). 1487 n = get TQZ 0 1488 for i ulong 128 1489 put TQOB i 0 1490 end 1491 tqpb 0 `827543636` 4 1492 tqpb 4 1 2 1493 tqpb 6 5 1 1494 tqpb 7 16 1 1495 tqpb 12 n 8 1496 tqpb 20 34 4 1497 for i ulong 96 1498 put TQOB add 28 i get TQD i 1499 end 1500 for t ulong n 1501 r = get TQDL t 1502 p = add 128 mul t 34 1503 tqpb p t 8 1504 tqpb add p 8 oxseq r 8 1505 tqpb add p 16 sub get TQB oxcell r 1 4 1506 tqpb add p 20 65536 4 1507 for x ulong 5 1508 tqpb add add p 24 mul x 2 tqq a r x 2 1509 end 1510 end 1511 tqout add 128 mul n 34 1512 end 1513 1514 fn tqtsy to void 1515 note TSY1 header and symbols (trailer appended by the glue). 1516 n = get TQZ 0 1517 for i ulong 56 1518 put TQOB i 0 1519 end 1520 tqpb 0 `827937620` 4 1521 tqpb 4 1 2 1522 tqpb 6 5 1 1523 tqpb 8 n 8 1524 for i ulong 32 1525 put TQOB add 24 i get TQD add 64 i 1526 end 1527 for t ulong n 1528 put TQOB add 56 t uchar oxbest get TQDL t 1529 end 1530 tqout add 56 n 1531 end 1532 1533 fn tqmcb a ulong to void 1534 note Model code bytes: ORS1, arm code, code bits MSB first zero padded. 1535 l = tqcode a 1536 w = write 1 TQRS 0 4 1537 put TQOB 0 uchar add a 1 1538 tqout 1 1539 n = div add l 7 8 1540 o = ulong 0 1541 while lt o n bound 999999 1542 w = write 1 TQW o sub n o 1543 if le w 0 1544 exit 74 1545 end 1546 o = add o ulong w 1547 end 1548 end 1549 1550 fn tqrbput p ulong v ulong to void 1551 for i ulong 8 1552 put RB add p i uchar and shr v mul i 8 255 1553 end 1554 end 1555 1556 fn tqaudr r ulong b ulong to void 1557 note ps of arm a of record r = 10^6 (1 + ((a - b) mod 5)). 1558 for a ulong 5 1559 v = mul `1000000` add 1 rem sub add a 5 b 5 1560 p = add mul r 256 mul add 16 a 8 1561 tqrbput p v 1562 end 1563 end 1564 1565 fn tqaud nul bool to void 1566 note A (C'): in every admitted HELD-OUT record, b = (oxbest + 1) mod 5. N (null fixture): in 1567 note every admitted record, b = splitmix64(state 1) mod 5, independent of the state. Then 1568 note tqaudr; every other byte unchanged. 1569 put TQZ 30 1 1570 for r ulong get TQZ 11 1571 go = eq oxpart r 2 1572 if nul 1573 go = lt oxpart r 3 1574 end 1575 if go 1576 b = rem add oxbest r 1 5 1577 if nul 1578 b = rem tqsm 5 1579 end 1580 tqaudr r b 1581 end 1582 end 1583 o = ulong 0 1584 n = get TQZ 13 1585 while lt o n bound 999999 1586 w = write 1 RB o sub n o 1587 if le w 0 1588 exit 74 1589 end 1590 o = add o ulong w 1591 end 1592 end 1593 1594 fn tqfnvm to int 1595 note F: FNV-1a 64 of the rest of the input (at most 524288 bytes) as 8 little-endian bytes, 1596 note so the glue never does shell arithmetic on a 64-bit value. 1597 n = tqrdrb 1598 if gt n 524288 1599 ret 68 1600 end 1601 tqpb 0 oxfnv n 8 1602 tqout 8 1603 ret 0 1604 end 1605 1606 fn tqcmp to int 1607 note K: two images and an FNV word. Same outside bytes 104..111 and the trailer; the second 1608 note image's binding word equals the given FNV and its trailer equals FNV-1a of its prefix. 1609 o = ulong 0 1610 while lt o 23128 bound 23128 1611 r = read 0 SI o sub 23128 o 1612 if le r 0 1613 ret 68 1614 end 1615 o = add o ulong r 1616 end 1617 for i ulong 11560 1618 if or lt i 104 and ge i 112 lt i 11552 1619 if ne get SI i get SI add 11560 i 1620 w = write 1 TQK1 0 len TQK1 1621 wnum i 1622 tqnl 1623 ret 1 1624 end 1625 end 1626 end 1627 fv = siget 23120 1628 if ne siget 11664 fv 1629 w = write 1 TQK1 0 len TQK1 1630 wnum 104 1631 tqnl 1632 ret 1 1633 end 1634 if ne siget 23112 sifnv 11560 11552 1635 w = write 1 TQK1 0 len TQK1 1636 wnum 11552 1637 tqnl 1638 ret 1 1639 end 1640 w = write 1 TQK0 0 len TQK0 1641 ret 0 1642 end 1643 1644 note ---------------------------------------------------------------- driver 1645 1646 fn tqload to int 1647 note Read the stream (after the mode byte) and admit; 0 ok, else the exit code. 1648 if not tqrdk 1649 ret 68 1650 end 1651 nv = tqkw 1 1652 if or gt nv 524288 ne rem nv 256 0 1653 ret 68 1654 end 1655 if not tqrdlb 1656 ret 68 1657 end 1658 if not tqrdd 1659 ret 68 1660 end 1661 if not tqrdi 1662 ret 68 1663 end 1664 if gt nv 0 1665 if not tqrdv nv 1666 ret 68 1667 end 1668 end 1669 if ne and tqkw 7 1 0 1670 if not tqrdc 1671 ret 68 1672 end 1673 end 1674 n = tqrdrb 1675 if gt n 524288 1676 ret 68 1677 end 1678 put TQZ 13 n 1679 st = oxallow get TQZ 14 oxfnv n 1680 if lt st 0 1681 w = write 1 TQE0 0 len TQE0 1682 ret 67 1683 end 1684 st = oxadm2 n 1685 if ne st 0 1686 w = write 1 TQE1 0 len TQE1 1687 wnum ulong neg long st 1688 tqnl 1689 ret 66 1690 end 1691 put TQZ 11 get RC 0 1692 tqv1 1693 ret 0 1694 end 1695 1696 fn tqprep to int 1697 note Everything before output: orders, rows, code lengths, D, ub, blocks. 1698 tqntr 1699 tqstat 1700 tqorders 1701 for k ulong 3 1702 st = tqimg k 1703 if ne st 0 1704 w = write 1 TQE2 0 len TQE2 1705 wnum k 1706 tqsp 1707 tqsn long st 1708 tqnl 1709 ret 65 1710 end 1711 tqmord k 1712 end 1713 tqcount 1714 tqrows 1715 tqlens 1716 tqsel 1717 tqubs 1718 ret 0 1719 end 1720 1721 fn tqsynq t ulong r ulong to ulong 1722 note Count of rank r in the synthetic coder row of position t. 1723 ret rem add mul t 7 mul r 13 50 1724 end 1725 1726 fn tqsyn sym bool to void 1727 note Q / W: a synthetic K = 5 stream of n = config word 0 positions (coder band 1728 note qualification, no record involved): row t = F1 of counts (7 t + 13 r) mod 50, symbol t = 1729 note splitmix64(state 7) mod 5. Q writes the TPS1 body, W the TSY1 body. 1730 n = tqkw 0 1731 put TQZ 30 7 1732 for i ulong 128 1733 put TQOB i 0 1734 end 1735 if sym 1736 tqpb 0 `827937620` 4 1737 tqpb 4 1 2 1738 tqpb 6 5 1 1739 tqpb 8 n 8 1740 for t ulong n 1741 put TQOB add 56 t uchar rem tqsm 5 1742 end 1743 tqout add 56 n 1744 ret 1745 end 1746 tqpb 0 `827543636` 4 1747 tqpb 4 1 2 1748 tqpb 6 5 1 1749 tqpb 7 16 1 1750 tqpb 12 n 8 1751 tqpb 20 34 4 1752 for t ulong n 1753 for r ulong 5 1754 put TQN r tqsynq t r 1755 end 1756 tqrow 0 0 1757 p = add 128 mul t 34 1758 tqpb p t 8 1759 tqpb add p 8 t 8 1760 tqpb add p 20 65536 4 1761 for r ulong 5 1762 tqpb add add p 24 mul r 2 get TQQ r 2 1763 end 1764 end 1765 tqout add 128 mul n 34 1766 end 1767 1768 fn tqband to int 1769 note B: config words 0 n, 1 ideal_ub, 2 coded bits, 3 round trip (1 ok); band of h1_bridge. 1770 if not tqrdk 1771 ret 68 1772 end 1773 d = sub mul long tqkw 2 `1000000` long tqkw 1 1774 ok = and eq tqkw 3 1 le wsabs sub d `448000000` long tqbw tqkw 0 1775 w = write 1 TQX5 0 len TQX5 1776 tqsn d 1777 w = write 1 TQX6 0 len TQX6 1778 if ok 1779 w = write 1 TQX9 0 len TQX9 1780 tqnl 1781 ret 0 1782 end 1783 w = write 1 TQY0 0 len TQY0 1784 tqnl 1785 ret 1 1786 end 1787 1788 fn tqmok m ulong to bool 1789 note Modes R H P Y M A N Q W. 1790 if or eq m 82 or eq m 72 or eq m 80 eq m 89 1791 ret true 1792 end 1793 if or eq m 77 or eq m 65 eq m 78 1794 ret true 1795 end 1796 ret or eq m 81 eq m 87 1797 end 1798 1799 fn tqrun m ulong to int 1800 if not tqmok m 1801 ret 64 1802 end 1803 st = tqload 1804 if ne st 0 1805 ret st 1806 end 1807 if or eq m 65 eq m 78 1808 tqaud eq m 78 1809 ret 0 1810 end 1811 if or eq m 81 eq m 87 1812 if or lt tqkw 0 1 gt tqkw 0 2048 1813 ret 68 1814 end 1815 tqsyn eq m 87 1816 ret 0 1817 end 1818 st = tqprep 1819 if ne st 0 1820 ret st 1821 end 1822 if eq m 80 1823 a = tqkw 0 1824 if or lt a 1 gt a 10 1825 ret 68 1826 end 1827 tqtps sub a 1 1828 ret 0 1829 end 1830 if eq m 89 1831 tqtsy 1832 ret 0 1833 end 1834 if eq m 77 1835 a = tqkw 0 1836 if or lt a 1 gt a 10 1837 ret 68 1838 end 1839 tqmcb sub a 1 1840 ret 0 1841 end 1842 if and eq m 72 eq and tqkw 7 1 0 1843 ret 68 1844 end 1845 tqhead 1846 for x ulong 10 1847 tqarml x 1848 end 1849 tqbsum false 1850 tqboot get TQZ 2 1851 tqtlines 1852 nb = tqcfb 1853 put TQZ 15 nb 1854 tqbsum true 1855 tqboot nb 1856 tqtcf 1857 tqverds 1858 if eq m 72 1859 tqh1 1860 end 1861 ret 0 1862 end