interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / aienux / units-gate.om

1013 lines · 18422 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note aienux/units-gate.om: OMEGA-AIENUX-UNITS, the gate of the pure-Omega Aienux units moved from Aienux, in
3note seeded Omega (Linux AArch64). Build from the repository root (OM-2 program mode; seed/ng/sha256.om supplies
4note sh_dat, sh_all, sh_dig):
5note { printf 'om2\n'; cat seed/ng/sha256.om aienux/units-gate.om; } | seed/out/omc > aienux-units-gate
6note Run from the repository root: aienux-units-gate OMC SCRATCH
7note OMC the compiler under test; its sha256 must equal the first word of seed/out/omc.sha256, or nothing
8note runs (exit 69, nothing written)
9note SCRATCH a new directory (created 0700), at most 1024 bytes of path; an existing one is refused (exit 2)
10note Units. aienux/units.tsv lists every unit, one per line: NAME [@run|@qemu] then the paths of its parts, single
11note spaces; a line starting with # is a comment and an empty line is skipped. NAME is 1 to 240 of A-Z a-z 0-9 _ and
12note appears once (240 leaves room for scratch suffixes such as ".run.out" inside a 255-byte file name).
13note The parts are concatenated in order, each followed by a newline (the composition of aienux/units.tsv), into
14note SCRATCH/NAME.om and compiled twice by OMC: each compile exits 0 with empty stderr, and both outputs hold the same
15note bytes. Units tagged @run are then executed directly and must exit 0 (run=PASS / run=FAIL). Units tagged @qemu are
16note booted under /usr/bin/qemu-system-aarch64 when present (qemu=PASS / qemu=FAIL), or reported qemu=NOT_RUN when QEMU
17note is absent so host-only runs stay honest. A malformed or repeated row, a missing part, a failed compile, two
18note different outputs, a failed behavioral run, or a table with no unit is a FAIL line.
19note Control, must be caught: a compiler one byte longer fails the digest check.
20note Output: one line per unit, then
21note OMEGA-AIENUX-UNITS PASS|FAIL units=U behavior_passed=BP/BT qemu_passed=QP/QT qemu_not_run=QN controls=C caught=K hardware=NOT_RUN.
22note Exit 0 PASS, 1 FAIL, 2 bad usage or setup, 69 compiler digest refused. Every input is length-checked; a trap
23note exit (101..114) would be a defect of this gate, never a pass.
24text t_pin "seed/out/omc.sha256"
25text t_tab "aienux/units.tsv"
26text t_om ".om"
27text t_b1 ".1"
28text t_b2 ".2"
29text t_e1 ".1.err"
30text t_e2 ".2.err"
31text t_rout ".run.out"
32text t_rerr ".run.err"
33text t_qout ".q.out"
34text t_qerr ".q.err"
35text t_qlog ".qlog"
36text t_null "/dev/null"
37text t_mrun "@run"
38text t_mqemu "@qemu"
39text t_badmode "units.tsv: unknown mode tag (expected @run or @qemu)"
40text t_qemu "/usr/bin/qemu-system-aarch64"
41text t_qM "-M"
42text t_qvirt "virt"
43text t_qcpu "-cpu"
44text t_qmax "max"
45text t_qm "-m"
46text t_q256 "256"
47text t_qdisp "-display"
48text t_qnone "none"
49text t_qnet "-net"
50text t_qmon "-monitor"
51text t_qnorb "-no-reboot"
52text t_qser "-serial"
53text t_qfile "file:"
54text t_qkern "-kernel"
55text t_rpass " run=PASS"
56text t_rfail " run=FAIL"
57text t_qpass " qemu=PASS"
58text t_qfail " qemu=FAIL"
59text t_qnr " qemu=NOT_RUN"
60text t_sbp " behavior_passed="
61text t_sqp " qemu_passed="
62text t_sqn " qemu_not_run="
63text t_badname "units.tsv: name outside A-Z a-z 0-9 _"
64text t_dup "units.tsv: name repeated, or more than 64 KiB of names"
65text t_empty "units.tsv names no unit"
66text t_plus "omc-plus-one"
67text t_usage "usage: aienux-units-gate OMC SCRATCH (run from the omega-mv repository root)\n"
68text t_refd "OMEGA-AIENUX-UNITS REFUSED: compiler digest differs from seed/out/omc.sha256 (exit 69)\n"
69text t_nopin "OMEGA-AIENUX-UNITS INVALID: cannot read a 64-hex digest from seed/out/omc.sha256\n"
70text t_noscr "OMEGA-AIENUX-UNITS INVALID: SCRATCH exists or cannot be made\n"
71text t_notab "OMEGA-AIENUX-UNITS INVALID: cannot read aienux/units.tsv\n"
72text t_long "OMEGA-AIENUX-UNITS INVALID: SCRATCH path longer than 1024 bytes\n"
73text t_ok "ok "
74text t_fail "FAIL "
75text t_unit "unit "
76text t_ctl "control "
77text t_bytes " bytes="
78text t_sha " sha256="
79text t_exit " exit="
80text t_src "source unreadable: "
81text t_big "output unreadable or over 16 MiB"
82text t_cmp "compile"
83text t_stderr " stderr not empty"
84text t_twice " two builds differ"
85text t_write "cannot write the composed unit in SCRATCH"
86text t_row "units.tsv: malformed row (name 1..249 bytes, at least one part)"
87text t_plong "units.tsv: a part path is longer than 4000 bytes"
88text t_caught " caught"
89text t_esc " ESCAPED"
90text t_sum "OMEGA-AIENUX-UNITS "
91text t_pass "PASS"
92text t_fl "FAIL"
93text t_su " units="
94text t_sc " controls="
95text t_sk " caught="
96text t_hw " hardware=NOT_RUN\n"
97global g_pa uchar 4096
98global g_scr uchar 4096
99global g_omc uchar 4096
100global g_nm uchar 256
101global g_av uchar 8192
102global g_b uchar 16777216
103global g_u uchar 1048576
104global g_o uchar 8192
105global g_hx uchar 64
106global g_pin uchar 64
107global g_d1 uchar 32
108global g_stb uchar 4
109global g_n ulong 32
110global g_seen uchar 65536
111note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 output length,
112note 6 buffer length, 7 table length, 8 units, 11 failures, 12 controls, 13 caught, 14 name length, 15 g_seen length,
113note 16 unit rows, 17 behavior total, 18 behavior passed, 19 qemu total, 20 qemu passed, 21 qemu not_run, 22 row mode
114note ---- output
115fn oc c ulong to void
116n = get g_n 5
117put g_o n uchar c
118put g_n 5 add n 1
119end
120fn ot t view uchar * to void
121for i ulong len t bound 4096
122oc ulong get t i
123end
124end
125fn onm to void
126for i ulong get g_n 14 bound 256
127oc ulong get g_nm i
128end
129end
130fn onum v ulong to void
131if ge v 10
132onum div v 10
133end
134oc add 48 rem v 10
135end
136fn ohex to void
137for j ulong 32
138b = get sh_dig j
139oc ulong sh_hexd uint shr b 4
140oc ulong sh_hexd uint and b 15
141end
142end
143fn ohx to void
144for j ulong 64
145oc ulong get g_hx j
146end
147end
148fn oflush to void
149r = write 1 g_o 0 get g_n 5
150put g_n 5 0
151end
152fn onl to void
153oc 10
154oflush
155end
156note a failed check: FAIL KIND NAME then the reason; counts a failure
157fn ofail kind view uchar * why view uchar * to void
158ot t_fail
159ot kind
160onm
161oc 32
162ot why
163onl
164put g_n 11 add get g_n 11 1
165end
166note ---- paths: g_pa[0, g_n 0)
167fn pclr to void
168put g_n 0 0
169end
170fn pc c ulong to void
171n = get g_n 0
172put g_pa n uchar c
173put g_n 0 add n 1
174end
175fn pt t view uchar * to void
176for i ulong len t bound 4096
177pc ulong get t i
178end
179end
180fn pscr to void
181for j ulong get g_n 2 bound 4096
182pc ulong get g_scr j
183end
184end
185fn pnm to void
186for j ulong get g_n 14 bound 256
187pc ulong get g_nm j
188end
189end
190note scratch file NAME then suffix
191fn psn suf view uchar * to void
192pclr
193pscr
194pnm
195pt suf
196end
197note scratch file named by a text
198fn pst t view uchar * suf view uchar * to void
199pclr
200pscr
201pt t
202pt suf
203end
204note scratch file named by a text alone
205fn psc t view uchar * to void
206pclr
207pscr
208pt t
209end
210fn nmset t view uchar * to void
211for i ulong len t bound 256
212put g_nm i get t i
213end
214put g_n 14 len t
215end
216note ---- files
217fn fopn fl ulong mode ulong to int
218r = fopen g_pa 0 get g_n 0 int fl int mode
219if lt r 0
220ret -1
221end
222ret int r
223end
224fn frd to int
225ret fopn 524288 0
226end
227fn fwr to int
228ret fopn 524865 420
229end
230fn fexe to int
231r = unlink g_pa 0 get g_n 0
232ret fopn 524865 448
233end
234fn fclo fd int to void
235if ge fd 0
236r = fclose fd
237end
238end
239note append the file at g_pa to g_b; false when unreadable or past the buffer
240fn bload to bool
241fd = frd
242if lt fd 0
243ret false
244end
245n = get g_n 6
246ok = true
247while true bound 16777218
248x = read fd g_b n sub len g_b n
249if lt x 0
250ok = false
251break
252end
253if eq x 0
254break
255end
256n = add n ulong x
257if ge n len g_b
258ok = false
259break
260end
261end
262fclo fd
263put g_n 6 n
264ret ok
265end
266note write g_b[0, g_n 6) to the file at g_pa (0644, or 0700 when exe)
267fn bsave exe bool to bool
268fd = int -1
269if exe
270fd = fexe
271else
272fd = fwr
273end
274if lt fd 0
275ret false
276end
277n = get g_n 6
278o = ulong 0
279ok = true
280while lt o n bound 16777217
281x = write fd g_b o sub n o
282if le x 0
283ok = false
284break
285end
286o = add o ulong x
287end
288fclo fd
289ret ok
290end
291note sha256 of the file at g_pa into sh_dig; false when unreadable or past 16 MiB
292fn fhash to bool
293fd = frd
294if lt fd 0
295ret false
296end
297n = ulong 0
298ok = true
299while true bound 16777218
300x = read fd sh_dat n sub len sh_dat n
301if lt x 0
302ok = false
303break
304end
305if eq x 0
306break
307end
308n = add n ulong x
309if ge n len sh_dat
310ok = false
311break
312end
313end
314fclo fd
315if not ok
316ret false
317end
318sh_all n
319ret true
320end
321note the size of the file at g_pa, or 2^63 when unreadable
322fn fsize to ulong
323put g_n 6 0
324if not bload
325ret shl ulong 1 63
326end
327ret get g_n 6
328end
329note sh_dig equals the hex in g_hx
330fn digeq to bool
331for j ulong 32
332b = get sh_dig j
333if ne get g_hx mul j 2 sh_hexd uint shr b 4
334ret false
335end
336if ne get g_hx add mul j 2 1 sh_hexd uint and b 15
337ret false
338end
339end
340ret true
341end
342fn dsave to void
343for j ulong 32
344put g_d1 j get sh_dig j
345end
346end
347fn dsame to bool
348for j ulong 32
349if ne get g_d1 j get sh_dig j
350ret false
351end
352end
353ret true
354end
355note ---- processes
356fn aclr to void
357put g_n 3 2
358put g_n 4 0
359put g_av 0 0
360put g_av 1 0
361end
362note append g_pa as one argument
363fn apa to void
364p = get g_n 3
365n = get g_n 0
366for j ulong n bound 4096
367put g_av add add p 2 j get g_pa j
368end
369put g_av p uchar and n 255
370put g_av add p 1 uchar shr n 8
371put g_n 3 add p add n 2
372c = add get g_n 4 1
373put g_n 4 c
374put g_av 0 uchar and c 255
375put g_av 1 uchar shr c 8
376end
377fn atx t view uchar * to void
378pclr
379pt t
380apa
381end
382fn redir s int d int to void
383if ne dupfd s d 0 long d
384exit 127
385end
386end
387note run the argument list with stdin, stdout, stderr fds (closed here) and deadline lim ns: the exit code,
388note 256 + the signal, 512 when a file could not be opened, 1000 when the child passed lim (killed)
389fn spawn_lim fi int fo int fe int lim long to ulong
390if or lt fi 0 or lt fo 0 lt fe 0
391fclo fi
392fclo fo
393fclo fe
394ret 512
395end
396pid = fork
397if lt pid 0
398exit 2
399end
400if eq pid 0
401redir fi 0
402redir fo 1
403redir fe 2
404r = execprog g_av 0 get g_n 3
405exit 127
406end
407fclo fi
408fclo fo
409fclo fe
410t0 = monons
411while true bound 1000000000
412r = waitpid int pid g_stb 0 len g_stb 1
413if eq r pid
414x = ulong get g_stb 0
415if ne x 0
416ret add 256 x
417end
418ret ulong get g_stb 1
419end
420if lt r 0
421exit 2
422end
423if gt sub monons t0 lim
424r = killpid int pid 9
425r = waitpid int pid g_stb 0 len g_stb 0
426ret 1000
427end
428q = sleepns 200000
429end
430exit 2
431end
432fn spawn fi int fo int fe int to ulong
433ret spawn_lim fi fo fe 600000000000
434end
435note execute SCRATCH/NAME.1 directly with /dev/null stdin (60 s deadline)
436fn runbin to ulong
437psn t_b1
438r = chmod g_pa 0 get g_n 0 448
439pclr
440pt t_null
441fi = frd
442aclr
443psn t_b1
444apa
445psn t_rout
446fo = fwr
447psn t_rerr
448fe = fwr
449ret spawn_lim fi fo fe 60000000000
450end
451note boot SCRATCH/NAME.1 under qemu-system-aarch64 -M virt (15 s deadline)
452fn runqemu to ulong
453pclr
454pt t_null
455fi = frd
456aclr
457atx t_qemu
458atx t_qM
459atx t_qvirt
460atx t_qcpu
461atx t_qmax
462atx t_qm
463atx t_q256
464atx t_qdisp
465atx t_qnone
466atx t_qnet
467atx t_qnone
468atx t_qmon
469atx t_qnone
470atx t_qnorb
471atx t_qser
472pclr
473pt t_qfile
474pscr
475pnm
476pt t_qlog
477apa
478atx t_qkern
479psn t_b1
480apa
481psn t_qout
482fo = fwr
483psn t_qerr
484fe = fwr
485ret spawn_lim fi fo fe 15000000000
486end
487note OMC < SCRATCH/NAME.om > SCRATCH/NAME.SUF 2> SCRATCH/NAME.ERR
488fn omc suf view uchar * err view uchar * to ulong
489psn t_om
490fi = frd
491aclr
492pclr
493for j ulong get g_n 1 bound 4096
494pc ulong get g_omc j
495end
496apa
497psn suf
498fo = fexe
499psn err
500fe = fwr
501ret spawn fi fo fe
502end
503note ---- the compiler digest
504note the first 64 characters of seed/out/omc.sha256 into g_pin; false unless lowercase hex
505fn pinread to bool
506pclr
507pt t_pin
508put g_n 6 0
509if not bload
510ret false
511end
512if lt get g_n 6 64
513ret false
514end
515for j ulong 64
516c = get g_b j
517ok = or and ge c 48 le c 57 and ge c 97 le c 102
518if not ok
519ret false
520end
521put g_pin j c
522end
523ret true
524end
525note the file at g_pa hashes to g_pin
526fn pinok to bool
527if not fhash
528ret false
529end
530for j ulong 64
531put g_hx j get g_pin j
532end
533ret digeq
534end
535note ---- units
536note g_u[i] is c, for i below e (never reads at or past e)
537fn uis i ulong e ulong c ulong to bool
538if ge i e
539ret false
540end
541ret eq ulong get g_u i c
542end
543fn uisnt i ulong e ulong c ulong to bool
544if ge i e
545ret false
546end
547ret ne ulong get g_u i c
548end
549note append one newline to g_b (units.sh writes one after every part)
550fn nl to bool
551n = get g_n 6
552if ge add n 1 len g_b
553ret false
554end
555put g_b n 10
556put g_n 6 add n 1
557ret true
558end
559note a missing or unreadable part: FAIL unit NAME source unreadable: PATH (the path is in g_pa, at most 4000 bytes)
560fn psrcfail to void
561ot t_fail
562ot t_unit
563onm
564oc 32
565ot t_src
566for q ulong get g_n 0 bound 4096
567oc ulong get g_pa q
568end
569onl
570put g_n 11 add get g_n 11 1
571end
572note compose the parts g_u[s, e) into g_b as aienux/units.tsv does: each part's bytes, then one newline; false
573note (reported) when a part is unreadable or its path is longer than 4000 bytes
574fn compose s ulong e ulong to bool
575put g_n 6 0
576i = s
577while lt i e bound 1048576
578while uis i e 32 bound 1048576
579i = add i 1
580end
581if ge i e
582break
583end
584j = i
585while uisnt j e 32 bound 1048576
586j = add j 1
587end
588if gt sub j i 4000
589ofail t_unit t_plong
590ret false
591end
592pclr
593for q ulong sub j i bound 4096
594pc ulong get g_u add i q
595end
596if not bload
597psrcfail
598ret false
599end
600if not nl
601ofail t_unit t_big
602ret false
603end
604i = j
605end
606ret true
607end
608note compile the composed unit twice; true when both exit 0 with empty stderr and equal bytes
609fn build to bool
610psn t_om
611if not bsave false
612ofail t_unit t_write
613ret false
614end
615r1 = omc t_b1 t_e1
616r2 = omc t_b2 t_e2
617if or ne r1 0 ne r2 0
618ot t_fail
619ot t_unit
620onm
621oc 32
622ot t_cmp
623ot t_exit
624onum r1
625oc 47
626onum r2
627onl
628put g_n 11 add get g_n 11 1
629ret false
630end
631psn t_e1
632s1 = fsize
633psn t_e2
634s2 = fsize
635if or ne s1 0 ne s2 0
636ofail t_unit t_stderr
637ret false
638end
639psn t_b1
640if not fhash
641ofail t_unit t_big
642ret false
643end
644dsave
645psn t_b2
646if not fhash
647ofail t_unit t_big
648ret false
649end
650if not dsame
651ofail t_unit t_twice
652ret false
653end
654psn t_b1
655sz = fsize
656psn t_b1
657if not fhash
658ofail t_unit t_big
659ret false
660end
661md = get g_n 22
662if eq md 1
663put g_n 17 add get g_n 17 1
664rc = runbin
665if ne rc 0
666ot t_fail
667ot t_unit
668onm
669ot t_rfail
670ot t_exit
671onum rc
672onl
673put g_n 11 add get g_n 11 1
674ret false
675end
676put g_n 18 add get g_n 18 1
677ot t_ok
678ot t_unit
679onm
680ot t_bytes
681onum sz
682ot t_sha
683ohex
684ot t_rpass
685onl
686put g_n 8 add get g_n 8 1
687ret true
688end
689if eq md 2
690put g_n 19 add get g_n 19 1
691if ne faccess t_qemu 0 len t_qemu 1 0
692put g_n 21 add get g_n 21 1
693ot t_ok
694ot t_unit
695onm
696ot t_bytes
697onum sz
698ot t_sha
699ohex
700ot t_qnr
701onl
702put g_n 8 add get g_n 8 1
703ret true
704end
705rc = runqemu
706if ne rc 0
707ot t_fail
708ot t_unit
709onm
710ot t_qfail
711ot t_exit
712onum rc
713onl
714put g_n 11 add get g_n 11 1
715ret false
716end
717put g_n 20 add get g_n 20 1
718ot t_ok
719ot t_unit
720onm
721ot t_bytes
722onum sz
723ot t_sha
724ohex
725ot t_qpass
726onl
727put g_n 8 add get g_n 8 1
728ret true
729end
730ot t_ok
731ot t_unit
732onm
733ot t_bytes
734onum sz
735ot t_sha
736ohex
737onl
738put g_n 8 add get g_n 8 1
739ret true
740end
741note g_u[s, e) equals text t
742fn ueq s ulong e ulong t view uchar * to bool
743if ne sub e s len t
744ret false
745end
746for j ulong len t bound 64
747if ne get g_u add s j get t j
748ret false
749end
750end
751ret true
752end
753fn parsemode s ulong e ulong to ulong
754if ueq s e t_mrun
755ret 1
756end
757if ueq s e t_mqemu
758ret 2
759end
760ret 99
761end
762note one table row [s, e): NAME [@run|@qemu] then parts; # starts a comment line; an empty line is skipped
763fn urow s ulong e ulong to void
764if or eq s e eq get g_u s 35
765ret
766end
767put g_n 14 0
768put g_n 22 0
769k = s
770while uisnt k e 32 bound 1048576
771k = add k 1
772end
773if or ge k e or eq k s gt sub k s 240
774ofail t_unit t_row
775ret
776end
777for q ulong sub k s bound 256
778put g_nm q get g_u add s q
779end
780put g_n 14 sub k s
781put g_n 16 add get g_n 16 1
782if not nameok
783ofail t_unit t_badname
784ret
785end
786if not nameadd
787ofail t_unit t_dup
788ret
789end
790while uis k e 32 bound 1048576
791k = add k 1
792end
793if ge k e
794ofail t_unit t_row
795ret
796end
797if uis k e 64
798m = k
799while uisnt m e 32 bound 1048576
800m = add m 1
801end
802md = parsemode k m
803if eq md 99
804ofail t_unit t_badmode
805ret
806end
807put g_n 22 md
808k = m
809while uis k e 32 bound 1048576
810k = add k 1
811end
812if ge k e
813ofail t_unit t_row
814ret
815end
816end
817if compose k e
818z = build
819end
820end
821note a unit name uses only A-Z a-z 0-9 _, so it names a file in SCRATCH
822fn nameok to bool
823for q ulong get g_n 14 bound 256
824c = get g_nm q
825d = and ge c 48 le c 57
826u = and ge c 65 le c 90
827l = and ge c 97 le c 122
828ok = or or d u or l eq c 95
829if not ok
830ret false
831end
832end
833ret true
834end
835note record the name in g_seen (names joined by newlines); false when it is already there or g_seen is full
836fn nameadd to bool
837n = get g_n 15
838m = get g_n 14
839p = ulong 0
840while lt p n bound 65536
841q = p
842while and lt q n ne get g_seen q 10 bound 65536
843q = add q 1
844end
845if nameat p q
846ret false
847end
848p = add q 1
849end
850if ge add add n m 1 len g_seen
851ret false
852end
853for j ulong m bound 256
854put g_seen add n j get g_nm j
855end
856put g_seen add n m 10
857put g_n 15 add add n m 1
858ret true
859end
860note g_seen[p, q) equals the current name
861fn nameat p ulong q ulong to bool
862if ne sub q p get g_n 14
863ret false
864end
865for j ulong sub q p bound 256
866if ne get g_seen add p j get g_nm j
867ret false
868end
869end
870ret true
871end
872fn table to bool
873pclr
874pt t_tab
875put g_n 6 0
876if not bload
877ret false
878end
879n = get g_n 6
880if ge n len g_u
881ret false
882end
883for q ulong n bound 1048576
884put g_u q get g_b q
885end
886put g_n 7 n
887s = ulong 0
888while lt s n bound 1048576
889e = s
890while uisnt e n 10 bound 1048576
891e = add e 1
892end
893urow s e
894s = add e 1
895end
896if eq get g_n 16 0
897nmset t_tab
898ofail t_unit t_empty
899end
900ret true
901end
902note ---- controls
903fn caught c bool what view uchar * to void
904put g_n 12 add get g_n 12 1
905nmset what
906if c
907ot t_ok
908ot t_ctl
909onm
910ot t_caught
911onl
912put g_n 13 add get g_n 13 1
913else
914ofail t_ctl t_esc
915end
916end
917note a compiler one byte longer must fail the digest check
918fn cwrong to void
919pclr
920for j ulong get g_n 1 bound 4096
921pc ulong get g_omc j
922end
923put g_n 6 0
924ok = bload
925n = get g_n 6
926put g_b n 0
927put g_n 6 add n 1
928psc t_plus
929ok = and ok bsave true
930psc t_plus
931c = and ok not pinok
932caught c t_plus
933end
934note ---- main
935fn ausage to int
936r = write 2 t_usage 0 len t_usage
937ret 2
938end
939fn main to int
940if ne argcnt 3
941ret ausage
942end
943r = argread 1 g_omc 0 4095
944if lt r 1
945ret ausage
946end
947put g_n 1 ulong r
948if not pinread
949r = write 2 t_nopin 0 len t_nopin
950ret 2
951end
952pclr
953for j ulong get g_n 1 bound 4096
954pc ulong get g_omc j
955end
956if not pinok
957r = write 2 t_refd 0 len t_refd
958ret 69
959end
960r = argread 2 g_scr 0 4094
961if lt r 1
962ret ausage
963end
964if gt r 1024
965r = write 2 t_long 0 len t_long
966ret 2
967end
968n = ulong r
969x = makedir g_scr 0 n 448
970if ne x 0
971r = write 2 t_noscr 0 len t_noscr
972ret 2
973end
974put g_scr n 47
975put g_n 2 add n 1
976if not table
977r = write 2 t_notab 0 len t_notab
978ret 2
979end
980cwrong
981f = get g_n 11
982ot t_sum
983if eq f 0
984ot t_pass
985else
986ot t_fl
987end
988ot t_su
989onum get g_n 8
990ot t_sbp
991onum get g_n 18
992oc 47
993onum get g_n 17
994ot t_sqp
995onum get g_n 20
996oc 47
997onum get g_n 19
998ot t_sqn
999onum get g_n 21
1000ot t_sc
1001onum get g_n 12
1002ot t_sk
1003onum get g_n 13
1004ot t_hw
1005oflush
1006if ne f 0
1007ret 1
1008end
1009if ne get g_n 12 get g_n 13
1010ret 1
1011end
1012ret 0
1013end