interplane.Get Omega
Read in your language

spark-rsi-mv

Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger

Brought by drakestapleton

branch main Branches Tags History

spark-rsi-mv / om / reuse-eval / turing.om

905 lines · 17026 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note turing.om (lane EvalStats, spark-rsi-mv #73): Turing accounting of REUSE-1 section 8 under
3note calibration/profiles/Turing-profile-REUSE-v1.0.toml. Needs the units sha256 and stats (st*
4note helpers: paths, files, output, split readers). Names: functions tu*, globals TU*.
5note
6note CLI (argv[1] is the dispatcher's subcommand):
7note turing SPLITDIR PROFILE TRAINLIB TRAINPLIB BASEOM CODER OUTDIR
8note SPLITDIR = the FINAL split (index, sessions, gNN.exp); PROFILE = the profile TOML file;
9note TRAINLIB, TRAINPLIB = the evaluator's rebuilt LIBDIRs (CURRENT, gen-G.man, gen-G.om);
10note BASEOM = base.om written by drive base; CODER = the external turing-coder referee
11note (omega-mv a647b6a9 src/turing), or - (T_real is then NOT_RUN); OUTDIR receives B.tps,
12note M1.tps (TRAIN library), M2.tps (TRAINP library), D.tsy, the coded files X.tps.rans and
13note X.tps.range, and turing.txt (the report, also on stdout).
14note Exit 0 = report written; 2 = inputs refused (status=REFUSED code=N); 15 = output failure.
15note
16note D: the low 4 bits of r0 of every QUERY record of gNN.exp, groups in order, records in order
17note (the evaluator's reference = repetition 1 of every arm). One TPS1 record per symbol t:
18note observation_index t, context_key 0, crumb ordinal t, norm_sum 65536, q = 65521 on the symbol
19note and 1 on each of the 15 others (CODER_SPEC sections 2 and 3; K 16, qbits 16).
20note profile_digest = SHA-256 of the profile file bytes; dataset_digest = the FINAL holdout digest
21note (index words 7..10, each word's 8 bytes big endian); model_digest = SHA-256(
22note "turing.reuse.model.v1" 0x00 || the 2048 manifest bytes of the arm's library), and for B the
23note hashed bytes are 32 zero bytes (the profile's "or 32 zero bytes for B", read as the payload).
24note Trailers: SHA-256("turing.tc.pstream.v1" 0x00 || header || records) and
25note SHA-256("turing.tc.symbols.v1" 0x00 || header || symbols).
26note
27note Charges (profile model_code): P1 = 64 bits x 8 manifest words per template (manifest word 4
28note = K) plus, for select, 64 bits x 193 calibration values (192 cell words + E_q) when the
29note manifest names a calibration file (words 52..55 not all 0). P2 = 8 bits x (bytes of gen-G.om
30note - bytes of base.om + 2048 manifest bytes). Models: method, delta, select = M1; deltap = M2;
31note idelta, cache = B (no charge).
32note L_ideal(D|X) = n ub(65521) micro-bits for every model (CODER_SPEC section 8 rule). The data
33note terms are equal, so T_ideal(arm) = -charge. T_real(arm, coder) = -charge + 8 (coded bytes
34note of B - coded bytes of M), each coded file run through `CODER encode` then `CODER verify`.
35note H1 per coded file: |coded bits x 10^6 - ideal ub - 448 x 10^6| <= 64 x 10^6 + 1000 n.
36note No Turing verdict word is issued (profile verdict_rule).
37note
38note Refusal codes: 1 usage, 2 split (detail = the stats refusal code), 3 profile unreadable,
39note 4 library CURRENT or manifest invalid (detail 1 TRAIN, 2 TRAINP), 5 base.om unreadable,
40note 7 too many symbols for the TPS1 buffer, 15 output write failed.
41
42text TUK "turing.reuse.model.v1\nturing.tc.pstream.v1\nturing.tc.symbols.v1\nCURRENT\ngen-\n.man\n.om\nB.tps\nD.tsy\nM1.tps\nM2.tps\nencode\nverify\nrans\nrange\n.\nturing.txt\nreport=reuse1-turing version=1 profile=Turing-profile-REUSE-v1.0\nprofile_sha256=\n dataset_sha256=\n n=\n k=16\nmodel name=\n model_sha256=\n tps1_trailer=\n generation=\n k_templates=\n calibration=\n gen_om_bytes=\n base_om_bytes=\ndata ideal_ub=\n ub_per_symbol=\ncoded model=\n coder=\n bytes=\n overhead_ub=\n h1=\nPASS\nFAIL\nNOT_RUN\ncharge arm=\n p1_bits=\n p2_bits=\nturing arm=\n t_ideal_p1_bits=\n t_real_p1_bits_rans=\n t_real_p1_bits_range=\n t_ideal_p2_bits=\n t_real_p2_bits_rans=\n t_real_p2_bits_range=\nB\nM1\nM2\ndelta_t=NOT_APPLICABLE reason=one_library_generation_per_arm verdict=none\nstatus=REFUSED code=\n exit=\nyes\nno\nh1_all=\n tsy1_trailer=\n detail=\n"
43
44const TKMOD ulong 0
45const TKPST ulong 1
46const TKSYM ulong 2
47const TKCUR ulong 3
48const TKGEN ulong 4
49const TKMAN ulong 5
50const TKOM ulong 6
51const TKBTPS ulong 7
52const TKDTSY ulong 8
53const TKM1 ulong 9
54const TKM2 ulong 10
55const TKENC ulong 11
56const TKVER ulong 12
57const TKRANS ulong 13
58const TKRANGE ulong 14
59const TKDOT ulong 15
60const TKTXT ulong 16
61const TKHEAD ulong 17
62const TKPROF ulong 18
63const TKDATA ulong 19
64const TKN ulong 20
65const TKK ulong 21
66const TKMODEL ulong 22
67const TKMSHA ulong 23
68const TKTRAIL ulong 24
69const TKGENER ulong 25
70const TKKT ulong 26
71const TKCAL ulong 27
72const TKGOMB ulong 28
73const TKBOMB ulong 29
74const TKIDEAL ulong 30
75const TKUBPS ulong 31
76const TKCODED ulong 32
77const TKCODER ulong 33
78const TKBYTES ulong 34
79const TKOVH ulong 35
80const TKH1 ulong 36
81const TKPASS ulong 37
82const TKFAIL ulong 38
83const TKNRUN ulong 39
84const TKCHG ulong 40
85const TKP1 ulong 41
86const TKP2 ulong 42
87const TKTUR ulong 43
88const TKTI1 ulong 44
89const TKTR1R ulong 45
90const TKTR1G ulong 46
91const TKTI2 ulong 47
92const TKTR2R ulong 48
93const TKTR2G ulong 49
94const TKMB ulong 50
95const TKDELT ulong 53
96const TKREFU ulong 54
97const TKEXIT ulong 55
98const TKYES ulong 56
99const TKNO ulong 57
100const TKH1ALL ulong 58
101const TKTSYT ulong 59
102const TKDETL ulong 60
103
104global TUFB uchar 8388608
105global TUFL ulong 1
106global TUD ulong 4
107global TUPD ulong 4
108global TUMD ulong 12
109global TUTR ulong 12
110global TUSYT ulong 4
111global TUSY uchar 1048576
112global TUN ulong 1
113global TUKT ulong 3
114global TUCAL ulong 3
115global TUGEN ulong 3
116global TUGOM ulong 3
117global TUBOM ulong 1
118global TUCS ulong 6
119global TUCX ulong 6
120global TUPK uchar 4096
121global TUPKL ulong 1
122global TUWS uchar 4
123global TURF ulong 2
124
125note ---------- text table ----------
126fn tukoff k ulong to ulong
127i = ulong 0
128c = ulong 0
129while lt c k bound 999999
130if eq get TUK i 10
131c = add c 1
132end
133i = add i 1
134end
135ret i
136end
137
138fn tuks k ulong to void
139i = tukoff k
140while ne get TUK i 10 bound 4096
141stoc get TUK i
142i = add i 1
143end
144end
145
146fn tukp k ulong to void
147i = tukoff k
148while ne get TUK i 10 bound 4096
149stpc get TUK i
150i = add i 1
151end
152end
153
154note length of string k
155fn tuklen k ulong to ulong
156i = tukoff k
157s = i
158while ne get TUK i 10 bound 4096
159i = add i 1
160end
161ret sub i s
162end
163
164note ---------- SHA-256 over global bytes ----------
165note copies n bytes of source src (0 TUFB, 1 STFB, 2 TUSY) from byte off into b
166fn tucopy b edit uchar 4096 src ulong off ulong n ulong to void
167for i ulong n
168if eq src 0
169put b i get TUFB add off i
170else
171if eq src 1
172put b i get STFB add off i
173else
174put b i get TUSY add off i
175end
176end
177end
178end
179
180note string k then a zero byte into b; returns the length
181fn tutag b edit uchar 4096 k ulong to ulong
182i = tukoff k
183n = ulong 0
184while ne get TUK i 10 bound 4096
185put b n get TUK i
186n = add n 1
187i = add i 1
188end
189put b n 0
190ret add n 1
191end
192
193note SHA-256 of (domain string tag and 0x00, unless tag >= 1000) || src[off .. off + n) into TUD
194note (TUD word j = digest bytes 8j..8j+7 read little endian)
195fn tusha tag ulong src ulong off ulong n ulong to void
196c = new uchar 104 0
197b = new uchar 4096 0
198w = new ulong 64 0
199b8 = new ulong 512 0
200omsha c b 0 0 w b8
201if lt tag 1000
202m = tutag b tag
203omsha c b m 1 w b8
204end
205o = ulong 0
206while lt o n bound 999999
207m = sub n o
208if gt m 4096
209m = 4096
210end
211tucopy b src add off o m
212omsha c b m 1 w b8
213o = add o m
214end
215omsha c b 0 2 w b8
216for j ulong 4
217put TUD j get w j
218end
219end
220
221note the 32 digest bytes of TUD as hex
222fn tuohd to void
223for j ulong 4
224v = get TUD j
225for k ulong 8
226stohb and shr v mul k 8 255
227end
228end
229end
230
231note ---------- TPS1 / TSY1 byte building in TUFB ----------
232fn tub v ulong to void
233p = get TUFL 0
234put TUFB p uchar and v 255
235put TUFL 0 add p 1
236end
237
238note little-endian integer of nb bytes
239fn tule v ulong nb ulong to void
240for k ulong nb
241tub shr v mul k 8
242end
243end
244
245note 32 bytes of digest words (word j little-endian bytes)
246fn tudig4 a ulong b ulong c ulong d ulong to void
247tule a 8
248tule b 8
249tule c 8
250tule d 8
251end
252
253note the dataset digest: index words 7..10, each word's bytes big endian
254fn tudata to void
255for j ulong 4
256v = get STHD j
257for k ulong 8
258tub shr v mul sub 7 k 8
259end
260end
261end
262
263note TPS1 for model m (0 B, 1 M1, 2 M2) into TUFB; trailer digest stored in TUTR
264fn tutps m ulong to void
265put TUFL 0 0
266tule 827543636 4
267tule 1 2
268tule 16 1
269tule 16 1
270tule 0 4
271n = get TUN 0
272tule n 8
273tule 56 4
274tule 0 4
275tudig4 get TUPD 0 get TUPD 1 get TUPD 2 get TUPD 3
276b = mul m 4
277tudig4 get TUMD b get TUMD add b 1 get TUMD add b 2 get TUMD add b 3
278tudata
279tule 0 4
280for t ulong n
281tule t 8
282tule 0 8
283tule t 4
284tule 65536 4
285s = ulong get TUSY t
286for x ulong 16
287if eq x s
288tule 65521 2
289else
290tule 1 2
291end
292end
293end
294tusha TKPST 0 0 get TUFL 0
295for j ulong 4
296put TUTR add b j get TUD j
297tule get TUD j 8
298end
299end
300
301note TSY1 into TUFB
302fn tutsy to void
303put TUFL 0 0
304tule 827937620 4
305tule 1 2
306tule 16 1
307tule 0 1
308n = get TUN 0
309tule n 8
310tule 0 8
311tudata
312for t ulong n
313tub ulong get TUSY t
314end
315tusha TKSYM 0 0 get TUFL 0
316for j ulong 4
317put TUSYT j get TUD j
318tule get TUD j 8
319end
320end
321
322note TUFB[0..TUFL) to the path in STPB; 0 ok
323fn tuwfile to int
324fd = fopen STPB 0 get STPL 0 577 420
325if lt fd 0
326ret 1
327end
328n = get TUFL 0
329o = ulong 0
330while lt o n bound 999999
331w = write int fd TUFB o sub n o
332if le w 0
333c = fclose int fd
334ret 1
335end
336o = add o ulong w
337end
338s = fsync int fd
339c = fclose int fd
340if or ne s 0 ne c 0
341ret 1
342end
343ret 0
344end
345
346note output file name of model m (k = TKBTPS, TKM1, TKM2) in OUTDIR (slot 6)
347fn tutpsname m ulong to void
348stpbase 6
349if eq m 0
350tukp TKBTPS
351end
352if eq m 1
353tukp TKM1
354end
355if eq m 2
356tukp TKM2
357end
358end
359
360note ---------- D ----------
361fn tusyms to int
362n = ulong 0
363for i ulong get STNR 0
364if eq get STRO i 2
365if ge n len TUSY
366ret 7
367end
368put TUSY n uchar and get STR0 i 15
369n = add n 1
370end
371end
372put TUN 0 n
373ret 0
374end
375
376note ---------- libraries ----------
377note checks library l (1 TRAIN in slot 2, 2 TRAINP in slot 3): CURRENT, gen-G.man (magic, SHA-256
378note equal to CURRENT's), K, calibration presence, model digest, gen-G.om size. 0 ok.
379fn tulib l ulong to int
380s = add l 1
381stpbase s
382tukp TKCUR
383n = stload
384if ne n 40
385ret 1
386end
387g = stw 0
388cd = new ulong 4 0
389for j ulong 4
390put cd j stw add 8 mul j 8
391end
392put TUGEN l g
393stpbase s
394tukp TKGEN
395stpu g
396tukp TKMAN
397n = stload
398if ne n 2048
399ret 2
400end
401if ne stw 0 3544386019401740626
402ret 3
403end
404tusha 1000 1 0 2048
405for j ulong 4
406if ne get TUD j get cd j
407ret 4
408end
409end
410put TUKT l stw 32
411cal = or or stw 416 stw 424 or stw 432 stw 440
412put TUCAL l 0
413if ne cal 0
414put TUCAL l 1
415end
416tusha TKMOD 1 0 2048
417for j ulong 4
418put TUMD add mul l 4 j get TUD j
419end
420stpbase s
421tukp TKGEN
422stpu g
423tukp TKOM
424n = stload
425if lt n 0
426ret 5
427end
428put TUGOM l ulong n
429ret 0
430end
431
432note B's model digest over 32 zero bytes
433fn tubmodel to void
434for i ulong 32
435put STFB i 0
436end
437tusha TKMOD 1 0 32
438for j ulong 4
439put TUMD j get TUD j
440end
441end
442
443note ---------- the external coder ----------
444fn tupkc c uchar to void
445p = get TUPKL 0
446put TUPK p c
447put TUPKL 0 add p 1
448end
449
450note appends the path in STPB as one packed record
451fn tupkpath to void
452n = get STPL 0
453tupkc uchar and n 255
454tupkc uchar shr n 8
455for i ulong n
456tupkc get STPB i
457end
458end
459
460fn tupkk k ulong to void
461n = tuklen k
462tupkc uchar n
463tupkc 0
464i = tukoff k
465for j ulong n
466tupkc get TUK add i j
467end
468end
469
470note runs the packed list; returns the exit code, 256 + signal, or 512 when fork or exec failed
471fn turun to ulong
472put TUPK 0 6
473put TUPK 1 0
474pid = fork
475if lt pid 0
476ret 512
477end
478if eq pid 0
479d = dupfd 2 1 0
480r = execprog TUPK 0 get TUPKL 0
481exit 127
482end
483r = waitpid int pid TUWS 0 4 0
484if ne r pid
485ret 512
486end
487sg = and ulong get TUWS 0 127
488if ne sg 0
489ret add 256 sg
490end
491ret ulong get TUWS 1
492end
493
494note the coded file name of model m, coder c (0 rans, 1 range) as the path
495fn tucodedname m ulong c ulong to void
496tutpsname m
497tukp TKDOT
498if eq c 0
499tukp TKRANS
500else
501tukp TKRANGE
502end
503end
504
505note CODER op coder model: op TKENC or TKVER
506fn tucoder op ulong m ulong c ulong to ulong
507put TUPKL 0 2
508stpexact 5
509tupkpath
510tupkk op
511if eq c 0
512tupkk TKRANS
513else
514tupkk TKRANGE
515end
516tutpsname m
517tupkpath
518stpbase 6
519tukp TKDTSY
520tupkpath
521tucodedname m c
522tupkpath
523ret turun
524end
525
526note encode, verify and size one coded file; TUCX = exit (0 ok), TUCS = bytes
527fn tucode m ulong c ulong to void
528x = add mul m 2 c
529e = tucoder TKENC m c
530if eq e 0
531e = tucoder TKVER m c
532end
533put TUCX x e
534put TUCS x 0
535if ne e 0
536ret
537end
538tucodedname m c
539n = stload
540if lt n 56
541put TUCX x 600
542ret
543end
544if ne stw 48 sub ulong n 56
545put TUCX x 601
546ret
547end
548put TUCS x ulong n
549end
550
551note ---------- CODER_SPEC section 8 ideal length ----------
552fn tuub q ulong to ulong
553ip = ulong 0
554for i ulong 64
555if ne and shr q i 1 0
556ip = i
557end
558end
559m = shl q sub 62 ip
560frac = ulong 0
561for i ulong 32
562stmul m m
563m = or shl get STHL 0 2 shr get STHL 1 62
564if ge m 9223372036854775808
565frac = or frac shl ulong 1 sub 31 i
566m = shr m 1
567end
568end
569lg = or shl ip 32 frac
570x = sub 68719476736 lg
571ret shr add mul x 1000000 2147483648 32
572end
573
574note ---------- report ----------
575note model of arm a: 0 B, 1 M1, 2 M2
576fn tumodel a ulong to ulong
577if or or eq a 3 eq a 4 eq a 7
578ret 1
579end
580if eq a 6
581ret 2
582end
583ret 0
584end
585
586fn tup1 a ulong to ulong
587m = tumodel a
588if eq m 0
589ret 0
590end
591v = mul 512 get TUKT m
592if and eq a 7 eq get TUCAL m 1
593v = add v 12352
594end
595ret v
596end
597
598fn tup2 a ulong to long
599m = tumodel a
600if eq m 0
601ret 0
602end
603d = sub long get TUGOM m long get TUBOM 0
604ret mul 8 add d 2048
605end
606
607note T_real for charge ch (bits) and coder c: -ch + 8 (bytes of B - bytes of M); 0 = NOT_RUN flag in TURF
608fn tureal ch long m ulong c ulong to long
609put TURF 0 0
610if or ne get TUCX c 0 ne get TUCX add mul m 2 c 0
611put TURF 0 1
612ret 0
613end
614d = sub long get TUCS c long get TUCS add mul m 2 c
615ret add neg ch mul 8 d
616end
617
618fn tuoreal ch long m ulong c ulong to void
619v = tureal ch m c
620if eq get TURF 0 1
621tuks TKNRUN
622else
623stol v
624end
625end
626
627fn tuarmline a ulong to void
628p1 = long tup1 a
629p2 = tup2 a
630m = tumodel a
631tuks TKCHG
632stks add SKARM0 a
633tuks TKP1
634stol p1
635tuks TKP2
636stol p2
637stnl
638tuks TKTUR
639stks add SKARM0 a
640tuks TKTI1
641stol neg p1
642tuks TKTR1R
643tuoreal p1 m 0
644tuks TKTR1G
645tuoreal p1 m 1
646tuks TKTI2
647stol neg p2
648tuks TKTR2R
649tuoreal p2 m 0
650tuks TKTR2G
651tuoreal p2 m 1
652stnl
653end
654
655note H1 for coded file x: returns 1 PASS, 0 FAIL, 2 NOT_RUN
656fn tuh1 x ulong to ulong
657if ne get TUCX x 0
658ret 2
659end
660n = get TUN 0
661id = mul n tuub 65521
662cb = mul get TUCS x 8000000
663ov = sub long sub long cb long id 448000000
664if lt ov 0
665ov = neg ov
666end
667if le ov long add 64000000 mul 1000 n
668ret 1
669end
670ret 0
671end
672
673fn tucodedline m ulong c ulong to ulong
674x = add mul m 2 c
675tuks TKCODED
676tuks add TKMB m
677tuks TKCODER
678if eq c 0
679tuks TKRANS
680else
681tuks TKRANGE
682end
683h = tuh1 x
684if eq h 2
685if ne get TUCX x 1000
686tuks TKEXIT
687stou get TUCX x
688end
689tuks TKH1
690tuks TKNRUN
691stnl
692ret h
693end
694tuks TKBYTES
695stou get TUCS x
696n = get TUN 0
697tuks TKOVH
698stol sub long mul get TUCS x 8000000 long mul n tuub 65521
699tuks TKH1
700if eq h 1
701tuks TKPASS
702else
703tuks TKFAIL
704end
705stnl
706ret h
707end
708
709fn tumodelline m ulong to void
710tuks TKMODEL
711tuks add TKMB m
712tuks TKMSHA
713b = mul m 4
714for j ulong 4
715v = get TUMD add b j
716for k ulong 8
717stohb and shr v mul k 8 255
718end
719end
720tuks TKTRAIL
721for j ulong 4
722v = get TUTR add b j
723for k ulong 8
724stohb and shr v mul k 8 255
725end
726end
727if gt m 0
728tuks TKGENER
729stou get TUGEN m
730tuks TKKT
731stou get TUKT m
732tuks TKCAL
733if eq get TUCAL m 1
734tuks TKYES
735else
736tuks TKNO
737end
738tuks TKGOMB
739stou get TUGOM m
740tuks TKBOMB
741stou get TUBOM 0
742end
743stnl
744end
745
746fn tureport to void
747tuks TKHEAD
748stnl
749tuks TKPROF
750for j ulong 4
751put TUD j get TUPD j
752end
753tuohd
754tuks TKDATA
755for j ulong 4
756stohw get STHD j
757end
758tuks TKN
759stou get TUN 0
760tuks TKK
761tuks TKTSYT
762for j ulong 4
763put TUD j get TUSYT j
764end
765tuohd
766stnl
767for m ulong 3
768tumodelline m
769end
770n = get TUN 0
771tuks TKIDEAL
772stou mul n tuub 65521
773tuks TKUBPS
774stou tuub 65521
775stnl
776all = ulong 1
777for m ulong 3
778for c ulong 2
779h = tucodedline m c
780if ne h 1
781all = 0
782end
783end
784end
785tuks TKH1ALL
786if eq all 1
787tuks TKPASS
788else
789if eq get TUCX 0 1000
790tuks TKNRUN
791else
792tuks TKFAIL
793end
794end
795stnl
796tuarmline 3
797tuarmline 4
798tuarmline 7
799tuarmline 6
800tuarmline 5
801tuarmline 2
802tuks TKDELT
803stnl
804end
805
806fn tufail code ulong d ulong to int
807put STOP 0 0
808tuks TKREFU
809stou code
810tuks TKDETL
811stou d
812stnl
813if ne get STQT 0 1
814r = stflush 1
815end
816ret 2
817end
818
819note the evaluation on slots 0 split, 1 profile, 2 TRAIN lib, 3 TRAINP lib, 4 base.om,
820note 5 coder (- = NOT_RUN), 6 out; report to stdout unless STQT is 1
821fn turun2 to int
822streset
823e = stidx
824if eq e 0
825e = stsess
826end
827if eq e 0
828e = stexps
829end
830if ne e 0
831ret tufail 2 ulong e
832end
833if ne tusyms 0
834ret tufail 7 0
835end
836stpexact 1
837n = stload
838if lt n 0
839ret tufail 3 0
840end
841tusha 1000 1 0 ulong n
842for j ulong 4
843put TUPD j get TUD j
844end
845tubmodel
846for l ulong 2
847e = tulib add l 1
848if ne e 0
849ret tufail 4 add mul add l 1 10 ulong e
850end
851end
852stpexact 4
853n = stload
854if lt n 0
855ret tufail 5 0
856end
857put TUBOM 0 ulong n
858for m ulong 3
859tutps m
860tutpsname m
861if ne tuwfile 0
862ret tufail 15 m
863end
864end
865tutsy
866stpbase 6
867tukp TKDTSY
868if ne tuwfile 0
869ret tufail 15 3
870end
871nocoder = and eq get STBL 5 1 eq get STBD 20480 45
872for x ulong 6
873put TUCX x 1000
874put TUCS x 0
875end
876if not nocoder
877for m ulong 3
878tucode m 0
879tucode m 1
880end
881end
882put STOP 0 0
883tureport
884if ne get STQT 0 1
885r = stflush 1
886end
887stpbase 6
888tukp TKTXT
889if ne stwfile 0
890ret 15
891end
892ret 0
893end
894
895fn tumain to int
896if lt argcnt 9
897ret tufail 1 0
898end
899for k ulong 7
900if eq stargb add k 2 k 0
901ret tufail 1 add k 1
902end
903end
904ret turun2
905end