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 / seed / ng / a64 / gate.om

1122 lines · 19126 bytes Raw Blame History
1note gate.om: the ng-a64 encoder gate. Run from the omega-mv root: seed/out/omc < seed/ng/a64/gate.om > gate && ./gate
2note with stdin one line, an existing scratch directory (e.g. /tmp/a64gate). Referee: GNU objdump (/usr/bin/objdump).
3note 1. Build ng: scratch/enc.om = the units of seed/ng/ng.units in order, compiled by seed/out/omc -> scratch/enc.bin.
4note (The unit sha256s are ngbuild's check, not this gate's.)
5note 2. Run ng on seed/ng/a64/tests/enc.cases (first line `@ng a64-enc`) -> scratch/words.bin (one 4-byte word per
6note case, case k at byte 4k).
7note 3. objdump -D -b binary -m aarch64 scratch/words.bin -> scratch/dis.txt.
8note 4. Each case's expected text (after `|`) must equal objdump's text for its word: blanks collapsed, objdump's
9note trailing `//` comment dropped, `@+N`/`@-N` replaced by 0x<hex of 4k+N / 4k-N>.
10note 5. Negative control: the same with one wrong bit in the tool (ADD immediate base 0x91000000 -> 0x91400000, the
11note shift bit 22). The gate requires the mutant to fail at least one case.
12note 6. Refusals: each case of seed/ng/a64/tests/enc-refuse.cases (`FORM operands | stderr line`) runs alone as line 2
13note of `@ng a64-enc` + the case; ng must exit 5, write no word and print exactly that stderr line.
14note 7. Negative control of step 6, mutant M-A: a6_fld masks the value to its field instead of refusing it (review
15note P3-2 of 8a3680b0). The gate requires it to fail at least one refusal case.
16note Output: one line per mismatch and a summary; exit 0 only when every case matches, the word count equals the case
17note count, every refusal case holds and both mutants are caught. Exit 1 otherwise; 2 when a step could not run.
18om2
19
20global mem uchar 16777216
21global pb uchar 4096
22global pn ulong 1
23global sd uchar 1024
24global sn ulong 1
25global av uchar 4096
26global ap ulong 2
27global stb uchar 4
28global ob uchar 65536
29global on ulong 1
30global ex uchar 4096
31global en ulong 1
32global dso ulong 4096
33global dsl ulong 4096
34global nd ulong 1
35global rg ulong 16
36global mk ulong 1
37
38note regions of mem: source [0, 4 MiB), cases [4, 6), disassembly [6, 14), stdin [14, 15)
39const rsrc ulong 0
40const rcas ulong 4194304
41const rdis ulong 6291456
42const rin ulong 14680064
43const rinu ulong 14684160
44note refusal cases [15 MiB, 15.5 MiB), the one-case list and ng's stderr after them
45const rref ulong 15728640
46const rone ulong 16252928
47const rerr ulong 16257024
48
49text tomc "seed/out/omc"
50text ta64 "seed/ng/src/a64.om"
51text tmain "seed/ng/ng.units"
52text tcase "seed/ng/a64/tests/enc.cases"
53text tobjd "/usr/bin/objdump"
54text tencom "/enc.om"
55text tencb "/enc.bin"
56text twrd "/words.bin"
57text tdis "/dis.txt"
58text terr "/enc.err"
59text tdash "-D"
60text tdb "-b"
61text tbin "binary"
62text tdm "-m"
63text tarch "aarch64"
64text tref "seed/ng/a64/tests/enc-refuse.cases"
65text tone "/one.cases"
66text tmpat "fset 36 0x91000000 4"
67text tmrep "fset 36 0x91400000 4"
68text tmpa2 "if ge v shl ulong 1 w\na6_die 5 6 v\nend\nret v"
69text tmre2 "if ge v 99\nend\nret and v sub shl ulong 1 w 1"
70text tmsg "a64 gate: case line\nexpected\ngot\ncases\nmatch\nmutant mismatches\nwords\nPASS\nFAIL\ncannot run step\na64 gate: refusal case line\nrefusal cases\nrefused as written\nmutant M-A refusal failures\nstatus\n"
71
72note ---- output ----
73fn oput b ulong to void
74n = get on 0
75if lt n len ob
76put ob n uchar b
77put on 0 add n 1
78end
79end
80
81fn oflush to void
82n = get on 0
83p = ulong 0
84while lt p n bound 65536
85k = write 1 ob p sub n p
86if le k 0
87p = n
88else
89p = add p ulong k
90end
91end
92put on 0 0
93end
94
95note omsg k: line k of tmsg (without its newline)
96fn omsg k ulong to void
97i = ulong 0
98j = ulong 0
99while and lt i len tmsg lt j k bound 4096
100if eq get tmsg i 10
101j = add j 1
102end
103i = add i 1
104end
105while and lt i len tmsg ne get tmsg i 10 bound 4096
106oput ulong get tmsg i
107i = add i 1
108end
109end
110
111fn odec v ulong to void
112d = ulong 1
113while ge div v d 10 bound 20
114d = mul d 10
115end
116x = v
117while gt d 0 bound 20
118oput add 48 div x d
119x = rem x d
120d = div d 10
121end
122end
123
124fn obig o ulong n ulong to void
125i = ulong 0
126while lt i n bound 4096
127oput ulong get mem add o i
128i = add i 1
129end
130end
131
132fn fail k ulong to void
133omsg 9
134oput 32
135odec k
136oput 10
137omsg 8
138oput 10
139oflush
140exit 2
141end
142
143note ---- paths: pb = a text, or the scratch directory followed by a text ----
144fn pclr to void
145put pn 0 0
146end
147
148fn pb1 b ulong to void
149n = get pn 0
150if ge n len pb
151fail 0
152end
153put pb n uchar b
154put pn 0 add n 1
155end
156
157fn ptxt k ulong to void
158note k: 1 omc, 2 a64.om, 3 ng.units, 4 enc.cases, 5 objdump, 6 /enc.om, 7 /enc.bin, 8 /words.bin, 9 /dis.txt, 10 /enc.err
159note 11 -D, 12 -b, 13 binary, 14 -m, 15 aarch64
160i = ulong 0
161if eq k 1
162while lt i len tomc bound 64
163pb1 ulong get tomc i
164i = add i 1
165end
166end
167if eq k 2
168while lt i len ta64 bound 64
169pb1 ulong get ta64 i
170i = add i 1
171end
172end
173if eq k 3
174while lt i len tmain bound 64
175pb1 ulong get tmain i
176i = add i 1
177end
178end
179if eq k 4
180while lt i len tcase bound 64
181pb1 ulong get tcase i
182i = add i 1
183end
184end
185if eq k 5
186while lt i len tobjd bound 64
187pb1 ulong get tobjd i
188i = add i 1
189end
190end
191if ge k 6
192ptxt2 k
193end
194end
195
196fn ptxt2 k ulong to void
197i = ulong 0
198if eq k 6
199while lt i len tencom bound 64
200pb1 ulong get tencom i
201i = add i 1
202end
203end
204if eq k 7
205while lt i len tencb bound 64
206pb1 ulong get tencb i
207i = add i 1
208end
209end
210if eq k 8
211while lt i len twrd bound 64
212pb1 ulong get twrd i
213i = add i 1
214end
215end
216if eq k 9
217while lt i len tdis bound 64
218pb1 ulong get tdis i
219i = add i 1
220end
221end
222if eq k 10
223while lt i len terr bound 64
224pb1 ulong get terr i
225i = add i 1
226end
227end
228if ge k 11
229ptxt3 k
230end
231end
232
233fn ptxt3 k ulong to void
234i = ulong 0
235if eq k 11
236while lt i len tdash bound 64
237pb1 ulong get tdash i
238i = add i 1
239end
240end
241if eq k 12
242while lt i len tdb bound 64
243pb1 ulong get tdb i
244i = add i 1
245end
246end
247if eq k 13
248while lt i len tbin bound 64
249pb1 ulong get tbin i
250i = add i 1
251end
252end
253if eq k 14
254while lt i len tdm bound 64
255pb1 ulong get tdm i
256i = add i 1
257end
258end
259if eq k 15
260while lt i len tarch bound 64
261pb1 ulong get tarch i
262i = add i 1
263end
264end
265if eq k 16
266while lt i len tref bound 64
267pb1 ulong get tref i
268i = add i 1
269end
270end
271if eq k 17
272while lt i len tone bound 64
273pb1 ulong get tone i
274i = add i 1
275end
276end
277end
278
279note pset k: pb = text k; pscr k: pb = scratch directory + text k
280fn pset k ulong to void
281pclr
282ptxt k
283end
284
285fn pscr k ulong to void
286pclr
287i = ulong 0
288while lt i get sn 0 bound 1024
289pb1 ulong get sd i
290i = add i 1
291end
292ptxt k
293end
294
295note ---- files ----
296fn openr to int
297r = fopen pb 0 get pn 0 0 0
298if lt r 0
299fail 1
300end
301ret int r
302end
303
304note openw md: create or truncate pb for writing with mode md (O_WRONLY|O_CREAT|O_TRUNC = 577)
305fn openw md int to int
306r = fopen pb 0 get pn 0 577 md
307if lt r 0
308fail 2
309end
310ret int r
311end
312
313fn fclo fd int to void
314r = fclose fd
315end
316
317note readin: all of file pb into mem at offset o (capacity c bytes); returns the byte count
318fn readin o ulong c ulong to ulong
319fd = openr
320n = ulong 0
321go = true
322while go bound 1000000
323if ge n c
324fail 3
325end
326k = read fd mem add o n sub c n
327if lt k 0
328fail 3
329end
330if eq k 0
331go = false
332else
333n = add n ulong k
334end
335end
336fclo fd
337ret n
338end
339
340fn wall fd int o ulong n ulong to void
341p = ulong 0
342while lt p n bound 1000000
343k = write fd mem add o p sub n p
344if le k 0
345fail 4
346end
347p = add p ulong k
348end
349end
350
351note ---- children: av = u16 count, then per argument u16 length and its bytes ----
352fn aclr to void
353put ap 0 2
354put ap 1 0
355end
356
357fn apb to void
358n = get pn 0
359p = get ap 0
360if gt add add p n 2 len av
361fail 5
362end
363put av p uchar and n 255
364put av add p 1 uchar shr n 8
365i = ulong 0
366while lt i n bound 4096
367put av add add p 2 i get pb i
368i = add i 1
369end
370put ap 0 add add p 2 n
371put ap 1 add get ap 1 1
372end
373
374fn redir s int d int to void
375if ne s d
376if ne dupfd s d 0 long d
377exit 127
378end
379end
380end
381
382note spawn: run av with fds fi, fo, fe as stdin, stdout, stderr; returns the exit status, or 256 + signal
383fn spawn fi int fo int fe int to ulong
384put av 0 uchar and get ap 1 255
385put av 1 uchar shr get ap 1 8
386pid = fork
387if lt pid 0
388fail 6
389end
390if eq pid 0
391redir fi 0
392redir fo 1
393redir fe 2
394r = execprog av 0 get ap 0
395exit 127
396end
397fclo fi
398fclo fo
399fclo fe
400r = waitpid int pid stb 0 len stb 0
401if ne r pid
402fail 7
403end
404sg = and ulong get stb 0 127
405if ne sg 0
406ret add 256 sg
407end
408ret ulong get stb 1
409end
410
411note ---- steps ----
412note mlen, mpat j, mrep j: the pattern and replacement of mutant mk (1 the wrong bit, 2 M-A)
413fn mlen to ulong
414if eq get mk 0 2
415ret len tmpa2
416end
417ret len tmpat
418end
419
420fn mpat j ulong to ulong
421if eq get mk 0 2
422ret ulong get tmpa2 j
423end
424ret ulong get tmpat j
425end
426
427fn mrep j ulong to ulong
428if eq get mk 0 2
429ret ulong get tmre2 j
430end
431ret ulong get tmrep j
432end
433
434note mkmut o n: replace the one occurrence of mutant mk's pattern in the source region [o, o+n) (equal lengths)
435fn mkmut o ulong n ulong to void
436m = mlen
437hits = ulong 0
438hit = ulong 0
439i = o
440while le add i m add o n bound 4194304
441if samepat i
442hits = add hits 1
443hit = i
444end
445i = add i 1
446end
447if ne hits 1
448fail 8
449end
450j = ulong 0
451while lt j m bound 64
452put mem add hit j uchar mrep j
453j = add j 1
454end
455end
456
457fn samepat i ulong to bool
458j = ulong 0
459while lt j mlen bound 64
460if ne ulong get mem add i j mpat j
461ret false
462end
463j = add j 1
464end
465ret true
466end
467
468note unitpath p q: pb = the path of the ng.units line mem[p, q) (`HEX PATH`, 64 hex digits and one space)
469fn unitpath p ulong q ulong to void
470if or le q add p 65 ne get mem add p 64 32
471fail 17
472end
473pclr
474i = add p 65
475while lt i q bound 4096
476pb1 ulong get mem i
477i = add i 1
478end
479end
480
481note isa64: pb is seed/ng/src/a64.om (the unit the mutant changes)
482fn isa64 to bool
483if ne get pn 0 len ta64
484ret false
485end
486i = ulong 0
487while lt i len ta64 bound 64
488if ne get pb i get ta64 i
489ret false
490end
491i = add i 1
492end
493ret true
494end
495
496note srcall: the units of ng.units concatenated into the source region, mutant mk (0 none) applied to a64.om;
497note returns its length
498fn srcall to ulong
499pset 3
500nu = readin rinu 65536
501s = ulong 0
502p = rinu
503e = add rinu nu
504hit = ulong 0
505mut = ne get mk 0 0
506while lt p e bound 128
507q = p
508while and lt q e ne get mem q 10 bound 4096
509q = add q 1
510end
511unitpath p q
512m = readin s sub rcas s
513if and mut isa64
514mkmut s m
515hit = add hit 1
516end
517s = add s m
518p = add q 1
519end
520if and mut ne hit 1
521fail 8
522end
523ret s
524end
525
526note build m: scratch/enc.om and scratch/enc.bin (ng) with mutant m (0 none, 1 the wrong bit, 2 M-A) in a64.om
527fn build m ulong to void
528put mk 0 m
529n = srcall
530pscr 6
531fd = openw 420
532wall fd 0 n
533fclo fd
534pscr 6
535fi = openr
536pscr 7
537fo = openw 493
538pscr 10
539fe = openw 420
540aclr
541pset 1
542apb
543if ne spawn fi fo fe 0
544fail 9
545end
546end
547
548note runenc: scratch/enc.bin < enc.cases > words.bin; returns the word count
549fn runenc to ulong
550pset 4
551fi = openr
552pscr 8
553fo = openw 420
554pscr 10
555fe = openw 420
556aclr
557pscr 7
558apb
559if ne spawn fi fo fe 0
560fail 10
561end
562pscr 8
563n = readin rdis 8388608
564if ne and n 3 0
565fail 11
566end
567ret shr n 2
568end
569
570note rundis: objdump -D -b binary -m aarch64 words.bin > dis.txt; returns its length (text at rdis)
571fn rundis to ulong
572pset 4
573fi = openr
574pscr 9
575fo = openw 420
576pscr 10
577fe = openw 420
578aclr
579pset 5
580apb
581pset 11
582apb
583pset 12
584apb
585pset 13
586apb
587pset 14
588apb
589pset 15
590apb
591pscr 8
592apb
593if ne spawn fi fo fe 0
594fail 12
595end
596pscr 9
597ret readin rdis 8388608
598end
599
600note ---- parsing the disassembly: dso[k], dsl[k] = start, length of the instruction text of the word at 4k ----
601fn ishex c ulong to bool
602ret or and ge c 48 le c 57 and ge c 97 le c 102
603end
604
605fn hexv c ulong to ulong
606if le c 57
607ret sub c 48
608end
609ret sub c 87
610end
611
612note disline: the line [s, e) of the disassembly; if it is `<spaces><hex>:\t<word> \t<text>` record <text>
613fn disline s ulong e ulong to void
614p = s
615while and lt p e eq get mem p 32 bound 64
616p = add p 1
617end
618a = ulong 0
619q = p
620while and lt q e ishex ulong get mem q bound 64
621a = or shl a 4 hexv ulong get mem q
622q = add q 1
623end
624if or eq q p ge add q 1 e
625ret
626end
627if or ne get mem q 58 ne get mem add q 1 9
628ret
629end
630t = add q 2
631while and lt t e ne get mem t 9 bound 64
632t = add t 1
633end
634t = add t 1
635if or ge t e ne and a 3 0
636ret
637end
638k = shr a 2
639if ge k len dso
640fail 13
641end
642put dso k t
643put dsl k sub e t
644if ge k get nd 0
645put nd 0 add k 1
646end
647end
648
649fn disparse n ulong to void
650put nd 0 0
651i = ulong 0
652while lt i len dsl bound 4096
653put dsl i 0
654put dso i 0
655i = add i 1
656end
657p = rdis
658e = add rdis n
659while lt p e bound 1000000
660q = p
661while and lt q e ne get mem q 10 bound 100000
662q = add q 1
663end
664disline p q
665p = add q 1
666end
667end
668
669note ---- normalized text into ex: blanks (space, tab) collapsed to one space, trimmed ----
670fn exclr to void
671put en 0 0
672end
673
674note exsp n: ex holds n > 0 bytes and the last is a blank (and/or are eager, so n = 0 is tested here)
675fn exsp n ulong to bool
676if eq n 0
677ret false
678end
679ret eq get ex sub n 1 32
680end
681
682fn ex1 c ulong to void
683n = get en 0
684if ge n len ex
685fail 14
686end
687if or eq c 32 eq c 9
688if or eq n 0 exsp n
689ret
690end
691put ex n 32
692else
693put ex n uchar c
694end
695put en 0 add n 1
696end
697
698fn extrim to void
699n = get en 0
700while exsp n bound 4096
701n = sub n 1
702end
703put en 0 n
704end
705
706fn exhex v ulong to void
707ex1 48
708ex1 120
709d = ulong 0
710while ne shr v shl add d 1 2 0 bound 16
711d = add d 1
712end
713go = true
714while go bound 17
715h = and shr v shl d 2 15
716if lt h 10
717ex1 add 48 h
718else
719ex1 add 87 h
720end
721if eq d 0
722go = false
723else
724d = sub d 1
725end
726end
727end
728
729note expect: the expected text [s, e) of case k into ex, with @+N/@-N resolved
730fn expect s ulong e ulong k ulong to void
731exclr
732p = s
733while lt p e bound 4096
734c = ulong get mem p
735if eq c 64
736p = exaddr add p 1 e k
737else
738ex1 c
739p = add p 1
740end
741end
742extrim
743end
744
745fn isdig q ulong e ulong to bool
746if ge q e
747ret false
748end
749c = ulong get mem q
750ret and ge c 48 le c 57
751end
752
753fn exaddr p ulong e ulong k ulong to ulong
754sg = ulong get mem p
755q = add p 1
756v = ulong 0
757while isdig q e bound 20
758v = add mul v 10 sub ulong get mem q 48
759q = add q 1
760end
761b = shl k 2
762if eq sg 43
763exhex add b v
764else
765exhex sub b v
766end
767ret q
768end
769
770note same: ex equals the objdump text of word k (from dso[k], `//` comment dropped, normalized the same way)
771fn same k ulong to bool
772if ge k get nd 0
773ret false
774end
775o = get dso k
776e = add o get dsl k
777i = o
778while and lt i e not slash2 i e bound 4096
779i = add i 1
780end
781ret cmpex get en 0 o i
782end
783
784fn slash2 i ulong e ulong to bool
785if ge add i 1 e
786ret false
787end
788ret and eq get mem i 47 eq get mem add i 1 47
789end
790
791note cmpex: ex[0, m) against mem [o, i) with blanks collapsed, leading and trailing blanks dropped
792fn cmpex m ulong o ulong i ulong to bool
793j = ulong 0
794p = o
795pend = false
796while lt p i bound 4096
797c = ulong get mem p
798if or eq c 9 eq c 32
799if gt j 0
800pend = true
801end
802else
803if pend
804if or ge j m ne get ex j 32
805ret false
806end
807j = add j 1
808pend = false
809end
810if or ge j m ne ulong get ex j c
811ret false
812end
813j = add j 1
814end
815p = add p 1
816end
817ret eq j m
818end
819
820note ---- comparing every case ----
821note cmpall verbose: rg[0] cases, rg[1] matches; prints each mismatch when verbose
822fn cmpall vb bool to void
823put rg 0 0
824put rg 1 0
825n = get rg 4
826p = rcas
827e = add rcas n
828while and lt p e ne get mem p 10 bound 4096
829p = add p 1
830end
831ln = ulong 1
832while lt p e bound 1000000
833p = add p 1
834ln = add ln 1
835q = p
836while and lt q e ne get mem q 10 bound 100000
837q = add q 1
838end
839cmpline p q ln vb
840p = q
841end
842end
843
844fn isblk p ulong e ulong to bool
845if ge p e
846ret false
847end
848c = ulong get mem p
849ret or eq c 32 eq c 9
850end
851
852note barat: the `|` of the case line [p, e) (fail 15 if none)
853fn barat p ulong e ulong to ulong
854b = p
855while and lt b e ne get mem b 124 bound 4096
856b = add b 1
857end
858if ge b e
859fail 15
860end
861ret b
862end
863
864fn cmpline s ulong e ulong ln ulong vb bool to void
865p = s
866while isblk p e bound 4096
867p = add p 1
868end
869if ge p e
870ret
871end
872if eq get mem p 59
873ret
874end
875b = barat p e
876k = get rg 0
877put rg 0 add k 1
878expect add b 1 e k
879if same k
880put rg 1 add get rg 1 1
881else
882if vb
883showbad ln k
884end
885end
886end
887
888fn showbad ln ulong k ulong to void
889omsg 0
890oput 32
891odec ln
892oput 10
893omsg 1
894oput 58
895oput 32
896i = ulong 0
897while lt i get en 0 bound 4096
898oput ulong get ex i
899i = add i 1
900end
901oput 10
902omsg 2
903oput 58
904oput 32
905if lt k get nd 0
906obig get dso k get dsl k
907end
908oput 10
909oflush
910end
911
912note ---- step 6: refusal cases (rg: 2 cases, 3 refused as written, 5 mode line length, 6 status, 7 stderr bytes) ----
913note rfall vb: run every case of enc-refuse.cases alone; prints each case that does not hold when vb
914fn rfall vb bool to void
915pset 16
916n = readin rref sub rone rref
917put rg 2 0
918put rg 3 0
919p = rref
920e = add rref n
921while and lt p e ne get mem p 10 bound 4096
922p = add p 1
923end
924put rg 5 add sub p rref 1
925ln = ulong 1
926while lt p e bound 1000000
927p = add p 1
928ln = add ln 1
929q = p
930while and lt q e ne get mem q 10 bound 100000
931q = add q 1
932end
933rfline p q ln vb
934p = q
935end
936end
937
938fn rfline s ulong e ulong ln ulong vb bool to void
939p = s
940while isblk p e bound 4096
941p = add p 1
942end
943if ge p e
944ret
945end
946if eq get mem p 59
947ret
948end
949b = barat p e
950put rg 2 add get rg 2 1
951rfwr p b
952if and rfrun rfsame add b 1 e
953put rg 3 add get rg 3 1
954else
955if vb
956rfbad ln
957end
958end
959end
960
961note rfwr p b: scratch/one.cases = the mode line of enc-refuse.cases, then the case mem[p, b) without trailing blanks
962fn rfwr p ulong b ulong to void
963m = get rg 5
964i = ulong 0
965while lt i m bound 4096
966put mem add rone i get mem add rref i
967i = add i 1
968end
969q = b
970while and gt q p isblk sub q 1 b bound 4096
971q = sub q 1
972end
973j = p
974while lt j q bound 4096
975put mem add rone i get mem j
976i = add i 1
977j = add j 1
978end
979put mem add rone i 10
980pscr 17
981fd = openw 420
982wall fd rone add i 1
983fclo fd
984end
985
986note rfrun: scratch/enc.bin < one.cases > words.bin 2> enc.err; true when it exits 5 and writes no word
987fn rfrun to bool
988pscr 17
989fi = openr
990pscr 8
991fo = openw 420
992pscr 10
993fe = openw 420
994aclr
995pscr 7
996apb
997st = spawn fi fo fe
998put rg 6 st
999pscr 10
1000put rg 7 readin rerr 4096
1001pscr 8
1002nw = readin rdis 8388608
1003ret and eq st 5 eq nw 0
1004end
1005
1006note rfsame s e: ng's stderr is the text mem[s, e) (blanks trimmed at both ends) and one newline
1007fn rfsame s ulong e ulong to bool
1008n = get rg 7
1009p = s
1010while isblk p e bound 4096
1011p = add p 1
1012end
1013q = e
1014while and gt q p isblk sub q 1 e bound 4096
1015q = sub q 1
1016end
1017if ne add sub q p 1 n
1018ret false
1019end
1020i = ulong 0
1021while lt i sub q p bound 4096
1022if ne get mem add p i get mem add rerr i
1023ret false
1024end
1025i = add i 1
1026end
1027ret eq get mem add rerr sub n 1 10
1028end
1029
1030fn rfbad ln ulong to void
1031omsg 10
1032oput 32
1033odec ln
1034oput 10
1035omsg 14
1036oput 32
1037odec get rg 6
1038oput 10
1039omsg 2
1040oput 58
1041oput 32
1042obig rerr get rg 7
1043oput 10
1044oflush
1045end
1046
1047fn sline k ulong v ulong to void
1048omsg k
1049oput 32
1050odec v
1051oput 10
1052end
1053
1054note summary: rg 8 cases, 9 matches, 11 words, 10 mutant mismatches, 13 refusal cases, 14 held, 15 M-A failures
1055fn summary to void
1056sline 3 get rg 8
1057sline 4 get rg 9
1058sline 6 get rg 11
1059sline 5 get rg 10
1060sline 11 get rg 13
1061sline 12 get rg 14
1062sline 13 get rg 15
1063end
1064
1065fn rdscr to void
1066pclr
1067n = read 0 mem rin 4096
1068if le n 0
1069fail 16
1070end
1071i = ulong 0
1072while and lt i ulong n ne get mem add rin i 10 bound 4096
1073put sd i get mem add rin i
1074i = add i 1
1075end
1076if or eq i 0 ge i 1000
1077fail 16
1078end
1079put sn 0 i
1080end
1081
1082fn main to int
1083rdscr
1084pset 4
1085put rg 4 readin rcas sub rdis rcas
1086build 0
1087w = runenc
1088disparse rundis
1089cmpall true
1090cs = get rg 0
1091put rg 8 cs
1092put rg 9 get rg 1
1093put rg 11 w
1094ok = and eq get rg 1 cs eq w cs
1095rfall true
1096put rg 13 get rg 2
1097put rg 14 get rg 3
1098ok = and ok and gt get rg 2 0 eq get rg 3 get rg 2
1099build 1
1100w2 = runenc
1101disparse rundis
1102cmpall false
1103mm = sub get rg 0 get rg 1
1104put rg 10 mm
1105ok = and ok and gt mm 0 eq w2 cs
1106build 2
1107rfall false
1108rm = sub get rg 2 get rg 3
1109put rg 15 rm
1110ok = and ok gt rm 0
1111summary
1112if ok
1113omsg 7
1114oput 10
1115oflush
1116ret 0
1117end
1118omsg 8
1119oput 10
1120oflush
1121ret 1
1122end