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
omega-mv / core / rsi / om / reuse-eval / stats.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note stats.om (lane EvalStats, spark-rsi-mv #73): the REUSE-1 statistics and decision unit. |
| 3 | note Contract: omega-mv d6edaad1 docs/reuse/REUSE-1.md (sections 6, 9, 10); evaluator formats: |
| 4 | note docs EVAL-FORMATS (split directory, raw run log, proc.log, acq.log, controls.log K7, seeds K6). |
| 5 | note No fn main here: the evaluator dispatcher calls stmain. Names: functions st*, globals ST*, |
| 6 | note constants SK*. turing.om and receipt.om reuse the st* output, path and file helpers. |
| 7 | note |
| 8 | note CLI (argv[1] is the dispatcher's subcommand and is not read): |
| 9 | note stats SPLITDIR RUNDIR CTRLDIR SEEDHEX OUTDIR |
| 10 | note SPLITDIR = the FINAL split directory (index, sessions, gNN.exp); RUNDIR = arm-A-rep-R-gNN.log, |
| 11 | note proc.log, acq.log; CTRLDIR = the directory holding controls.log, or - when no control run |
| 12 | note exists (every control then counts as not run); SEEDHEX = the 32-byte FINAL seed as 64 hex; |
| 13 | note OUTDIR receives stats.txt (the report, also written to stdout) and stats.sum (words below). |
| 14 | note Exit 0 = report written (the decision is inside it), 2 = inputs refused (status=REFUSED line |
| 15 | note with a code, nothing else decided), other = output write failure. |
| 16 | note |
| 17 | note Definitions (all integer, no floating point): |
| 18 | note - reps R = 3 (0-based in names and logs), arms 0 echo 1 full 2 cache 3 method 4 delta |
| 19 | note 5 idelta 6 deltap 7 select. Library charged per arm: method, delta, select = acq lib 1 |
| 20 | note (TRAIN), deltap = lib 2 (TRAINP), every other arm none (idelta runs with LIBDIR -). |
| 21 | note - cost of one arm process (arm a, rep r, group g) = start-to-ready (proc word 3, which |
| 22 | note includes request 0's round trip) + sum of round trips of requests 1.. of the group + the END |
| 23 | note round trip (proc word 15, K17; raw logs and proc word 12 exclude END). This charges |
| 24 | note start-to-ready to the first request (contract 5.4). |
| 25 | note - process exit (proc word 10, K17): 0 ok; any nonzero value (exit code, 256 + signal, |
| 26 | note 512 + judge kill code, 1023 reap failure, + 1024 when END itself failed) is a failed process |
| 27 | note and counts as one wrong refusal of its arm (so STOP for arms 1..7); reported per arm as |
| 28 | note proc_failed (correct line), exit_nonzero and end_failed (memory line). |
| 29 | note - V(a, g) = sum over the 3 reps of the process cost; acq(a) = sum over the 3 reps of the |
| 30 | note elapsed ns of the arm's library build. T(a) = sum over groups of V(a, g) + acq(a). Sums over |
| 31 | note reps stand for the per-group means of contract 10 (the factor 3 cancels in every ratio). |
| 32 | note - rho(a) = T(a) / T(full); ratio rho(x)/rho(y) = T(x) / T(y) (full cancels, same resample). |
| 33 | note Statistic s: 0..7 rho(arm s); 8 delta/cache; 9 delta/idelta; 10 select/delta; |
| 34 | note 11 delta/method; 12 idelta/full. |
| 35 | note - ppm = floor(num * 1000000 / den), exact 128-bit product and division. Floor makes the |
| 36 | note decision comparisons exact: ppm < 1000000 iff ratio < 1; ppm >= 1000000 iff ratio >= 1. |
| 37 | note - bootstrap: B = 10000 resamples; resample b draws G group indices, each = splitmix64() mod G |
| 38 | note (bias below G / 2^64); one draw serves every arm (paired); splitmix64 state starts at the |
| 39 | note FINAL seed bytes 0..7 read little endian (contract 10, K6) and is advanced once per draw. |
| 40 | note The 10000 values of each statistic are sorted ascending; interval = (v[k_lo], v[k_hi]) with |
| 41 | note nearest rank k = ceil(p * B) - 1 (0-based): p = 0.025 gives k_lo = 249, p = 0.975 gives 9749. |
| 42 | note The point value is the statistic on the sample itself (every group once). |
| 43 | note - quantiles: nearest rank on ascending values, index ceil(p * m / 100) - 1 for p = 50, 95, 99, |
| 44 | note over the QUERY round trips (all 3 reps) of one arm, cold (exp cold flag 1) or warm (0), |
| 45 | note per category: all, session type, novelty class, family, n class. m = 0 prints na. |
| 46 | note - cat_rho: request round trips only (no start-to-ready, no acquisition), per session category, |
| 47 | note arm over full; regime lines are the cat_rho ratios delta/method and idelta/full per type. |
| 48 | note - correctness: the log's word 15 is recomputed from words 5..11 (QUERY 1 iff status, r0, r1 |
| 49 | note equal; other requests 2 iff status equal; echo 2); a record is wrong when either the log or |
| 50 | note the recomputation says 0; disagreements are counted as log_inconsistent. Echo is never scored. |
| 51 | note - transfer coverage: delta-arm QUERYs (all reps) in sessions of novelty class 2 with route 3 |
| 52 | note or 4, over all such QUERYs. Fallback = route 5 among an arm's QUERYs. |
| 53 | note - payback(a): FINAL request order (group 0.., request 0..), per request the rep-summed |
| 54 | note (full - arm) cost (request 0 = start-to-ready only), then after each group's last request |
| 55 | note the rep-summed (full - arm) END round trip; the number of QUERYs seen when the cumulative |
| 56 | note sum first exceeds acq(a) (tested after every request and after every END term); none if |
| 57 | note it never does. rho totals include END as before. |
| 58 | note - Cbar (contract 6, #744), per arm, ppm of one full QUERY: F = floor(full QUERY round-trip |
| 59 | note sum / count); r = echo mean QUERY / F; q = QUERYs not served by routes 2..4 / QUERYs; |
| 60 | note e = mean of the route 2..4 QUERYs / F - r; K = acq(a) / F (full-QUERY units); N = the arm's |
| 61 | note QUERYs over 3 reps; cbar = r + (1 - q) e + q + K / N (signed, truncating toward zero); |
| 62 | note observed = (QUERY round-trip sum + acq) / N / F. Reported, never in the decision. |
| 63 | note - echo_sub(a) = (T(a) - T(echo)) / (T(full) - T(echo)), signed ppm (secondary figure). |
| 64 | note - decision (contract 10, K7): STOP on any wrong answer or wrong refusal of arms 1..7, a control |
| 65 | note with outcome 0 or the served-tampered flag, or lower bound of rho(delta) >= 1; else GO when |
| 66 | note upper bounds of rho(delta), delta/cache and delta/idelta are < 1, transfer coverage >= 1/2 |
| 67 | note (with at least one transfer QUERY) and every control C1..C12 has all its required |
| 68 | note (control, sub-case) pairs (stcreq) and none not run; a missing pair counts as not run; |
| 69 | note else INVESTIGATE. Every failing condition is listed as a reason line. |
| 70 | note |
| 71 | note stats.sum: 256 words LE. 0 magic 3544386041195737426 (R1STS001), 1 version 1, 2 decision |
| 72 | note (1 GO, 2 INVESTIGATE, 3 STOP), 3 reason bits (0 wrong_answer, 1 wrong_refusal, |
| 73 | note 2 control_undetected, 3 tampered_served, 4 rho_delta_lower_ge_1, 5 rho_delta_upper_ge_1, |
| 74 | note 6 delta_over_cache_upper_ge_1, 7 delta_over_idelta_upper_ge_1, 8 transfer_coverage_below_half, |
| 75 | note 9 control_not_run), 4 groups, 5 sessions, 6 requests, 7 queries (per rep), 8 reps, 9 split id, |
| 76 | note 10 bootstrap seed, 11 resamples, 12 scored QUERY responses (arms 1..7, all reps), 13 correct |
| 77 | note ones, 14 wrong ones, 15 wrong refusals, 16 transfer QUERYs, 17 covered, 18..21 holdout digest |
| 78 | note (index words 7..10 as stored), 22 log inconsistencies, 24 + 3 s .. 26 + 3 s point, lo, hi ppm |
| 79 | note of statistic s (s 0..12), 64 + a T(a), 72 + a acq(a), 80 + a route-5 QUERYs of arm a, |
| 80 | note 88 + a payback QUERYs (18446744073709551615 = none or not applicable), 96 + a failed |
| 81 | note processes of arm a (K17 nonzero exit), 104 + a processes of arm a whose END failed; the rest 0. |
| 82 | note |
| 83 | note Refusal codes: 1 usage, 2 index unreadable, 3 index invalid, 4 sessions invalid, 5 exp invalid, |
| 84 | note 6 log missing, 7 log size, 8 log identity words, 9 log expectation words differ from exp, |
| 85 | note 10 proc.log invalid, 11 proc record missing or duplicate, 12 acq.log invalid or a needed build |
| 86 | note missing, 13 controls.log invalid (detail k.0 field range, k.1 reported outside C12, k.2 |
| 87 | note sub-case not required, k.3 repeated pair; k = record), 14 capacity, 15 output write failed. |
| 88 | |
| 89 | const SKINDEX ulong 0 |
| 90 | const SKSESS ulong 1 |
| 91 | const SKEXP ulong 2 |
| 92 | const SKARMP ulong 3 |
| 93 | const SKREPP ulong 4 |
| 94 | const SKGP ulong 5 |
| 95 | const SKLOG ulong 6 |
| 96 | const SKPROC ulong 7 |
| 97 | const SKACQ ulong 8 |
| 98 | const SKCTL ulong 9 |
| 99 | const SKTXT ulong 10 |
| 100 | const SKSUM ulong 11 |
| 101 | const SKHEAD ulong 12 |
| 102 | const SKREFU ulong 13 |
| 103 | const SKDETL ulong 14 |
| 104 | const SKINPUT ulong 15 |
| 105 | const SKGROUP ulong 16 |
| 106 | const SKSESN ulong 17 |
| 107 | const SKREQS ulong 18 |
| 108 | const SKQRYS ulong 19 |
| 109 | const SKREPS ulong 20 |
| 110 | const SKARM ulong 21 |
| 111 | const SKTOTAL ulong 22 |
| 112 | const SKRTNS ulong 23 |
| 113 | const SKREADY ulong 24 |
| 114 | const SKACQNS ulong 25 |
| 115 | const SKTOTNS ulong 26 |
| 116 | const SKRHO ulong 27 |
| 117 | const SKPOINT ulong 28 |
| 118 | const SKLO ulong 29 |
| 119 | const SKHI ulong 30 |
| 120 | const SKRATIO ulong 31 |
| 121 | const SKCORR ulong 32 |
| 122 | const SKQOK ulong 33 |
| 123 | const SKQBAD ulong 34 |
| 124 | const SKCOK ulong 35 |
| 125 | const SKCBAD ulong 36 |
| 126 | const SKUNSC ulong 37 |
| 127 | const SKINCON ulong 38 |
| 128 | const SKROUTE ulong 39 |
| 129 | const SKRN ulong 40 |
| 130 | const SKEQ ulong 41 |
| 131 | const SKROTH ulong 42 |
| 132 | const SKFALL ulong 43 |
| 133 | const SKCOVER ulong 44 |
| 134 | const SKCOVD ulong 45 |
| 135 | const SKCOVP ulong 46 |
| 136 | const SKMEM ulong 47 |
| 137 | const SKPROCS ulong 48 |
| 138 | const SKHWMX ulong 49 |
| 139 | const SKHWMM ulong 50 |
| 140 | const SKRSSX ulong 51 |
| 141 | const SKCPU ulong 52 |
| 142 | const SKEXITN ulong 53 |
| 143 | const SKACQL ulong 54 |
| 144 | const SKBUILD ulong 55 |
| 145 | const SKELAP ulong 56 |
| 146 | const SKLIBB ulong 57 |
| 147 | const SKDRIVN ulong 58 |
| 148 | const SKPAYB ulong 59 |
| 149 | const SKPAYQ ulong 60 |
| 150 | const SKNONE ulong 61 |
| 151 | const SKCBAR ulong 62 |
| 152 | const SKCR ulong 63 |
| 153 | const SKCQ ulong 64 |
| 154 | const SKCE ulong 65 |
| 155 | const SKCK ulong 66 |
| 156 | const SKCN ulong 67 |
| 157 | const SKCBV ulong 68 |
| 158 | const SKCOBS ulong 69 |
| 159 | const SKECHO ulong 70 |
| 160 | const SKPPM ulong 71 |
| 161 | const SKNA ulong 72 |
| 162 | const SKQUANT ulong 73 |
| 163 | const SKTEMP ulong 74 |
| 164 | const SKCOLD ulong 75 |
| 165 | const SKWARM ulong 76 |
| 166 | const SKCAT ulong 77 |
| 167 | const SKCOUNT ulong 78 |
| 168 | const SKP50 ulong 79 |
| 169 | const SKP95 ulong 80 |
| 170 | const SKP99 ulong 81 |
| 171 | const SKCATR ulong 82 |
| 172 | const SKREGT ulong 83 |
| 173 | const SKDOM ulong 84 |
| 174 | const SKIOF ulong 85 |
| 175 | const SKCTLID ulong 86 |
| 176 | const SKRECS ulong 87 |
| 177 | const SKDET ulong 88 |
| 178 | const SKUNDET ulong 89 |
| 179 | const SKREPD ulong 90 |
| 180 | const SKNRUN ulong 91 |
| 181 | const SKTAMP ulong 92 |
| 182 | const SKDECI ulong 93 |
| 183 | const SKREAS ulong 94 |
| 184 | const SKI742 ulong 95 |
| 185 | const SKI743 ulong 96 |
| 186 | const SKI744 ulong 97 |
| 187 | const SKVERD ulong 98 |
| 188 | const SKHELPS ulong 99 |
| 189 | const SKNHELP ulong 100 |
| 190 | const SKINCO ulong 101 |
| 191 | const SKVERDS ulong 102 |
| 192 | const SKSIMNR ulong 103 |
| 193 | const SKSTEP ulong 104 |
| 194 | const SKBOOT ulong 105 |
| 195 | const SKSEED ulong 106 |
| 196 | const SKRKLO ulong 107 |
| 197 | const SKRKHI ulong 108 |
| 198 | const SKGO ulong 109 |
| 199 | const SKINV ulong 110 |
| 200 | const SKSTOP ulong 111 |
| 201 | const SKRWA ulong 112 |
| 202 | const SKRWR ulong 113 |
| 203 | const SKRCU ulong 114 |
| 204 | const SKRTS ulong 115 |
| 205 | const SKRLO ulong 116 |
| 206 | const SKRUP ulong 117 |
| 207 | const SKRDC ulong 118 |
| 208 | const SKRDI ulong 119 |
| 209 | const SKRCOV ulong 120 |
| 210 | const SKRNR ulong 121 |
| 211 | const SKMATCH ulong 122 |
| 212 | const SKYES ulong 123 |
| 213 | const SKNO ulong 124 |
| 214 | const SKARM0 ulong 125 |
| 215 | const SKCAT0 ulong 133 |
| 216 | const SKRAT0 ulong 153 |
| 217 | const SKCID0 ulong 157 |
| 218 | const SKOC0 ulong 172 |
| 219 | const SKBINDF ulong 177 |
| 220 | const SKRESTA ulong 178 |
| 221 | const SKDOMR ulong 179 |
| 222 | const SKIOFR ulong 180 |
| 223 | const SKR5 ulong 181 |
| 224 | const SKSPACE ulong 182 |
| 225 | const SKDIG ulong 183 |
| 226 | const SKR5D ulong 184 |
| 227 | const SKMISSP ulong 185 |
| 228 | const SKENDNS ulong 186 |
| 229 | const SKENDF ulong 187 |
| 230 | const SKPROCF ulong 188 |
| 231 | |
| 232 | text STK "index\nsessions\n.exp\narm-\n-rep-\n-g\n.log\nproc.log\nacq.log\ncontrols.log\nstats.txt\nstats.sum\nreport=reuse1-stats version=1 contract=REUSE-1 v1.0\nstatus=REFUSED code=\n detail=\ninput split=\n groups=\n sessions=\n requests=\n queries=\n reps=\n arm=\ntotal\n rt_ns=\n ready_ns=\n acq_ns=\n total_ns=\nrho\n point_ppm=\n lo_ppm=\n hi_ppm=\nratio name=\ncorrect\n query_ok=\n query_wrong=\n change_ok=\n change_wrong=\n unscored=\n log_inconsistent=\nroutes\n r\n=\n other=\n fallback_ppm=\ncoverage arm=delta class=transfer queries=\n method_served=\n coverage_ppm=\nmemory\n procs=\n hwm_max_kb=\n hwm_mean_kb=\n rss_max_kb=\n cpu_ticks=\n exit_nonzero=\nacq lib=\n builds=\n elapsed_ns=\n libdir_bytes_max=\n drive_nonzero=\npayback\n queries=\nnone\ncbar\n r_ppm=\n q_ppm=\n e_ppm=\n k_units_ppm=\n n=\n cbar_ppm=\n observed_ppm=\necho_sub\n ppm=\nna\nquant\n temp=\ncold\nwarm\n cat=\n count=\n p50_ns=\n p95_ns=\n p99_ns=\ncat_rho\nregime cat=\n delta_over_method_ppm=\n idelta_over_full_ppm=\ncontrol id=\n records=\n detected=\n undetected=\n reported=\n not_run=\n served_tampered=\ndecision=\nreason=\nissue742 transfer_coverage_ppm=\nissue743\nissue744 select_over_delta\n verdict=\nhelps\ndoes_not_help\ninconclusive\nverdicts source=REVIEW_REQUIRED host=\n simulator=NOT_RUN physical=NOT_RUN\nfull_ns_per_step=NOT_RECORDED reason=raw_logs_carry_no_reference_timing\nbootstrap resamples=\n seed=\n rank_lo=\n rank_hi=\nGO\nINVESTIGATE\nSTOP\nwrong_answer\nwrong_refusal\ncontrol_undetected\ntampered_served\nrho_delta_lower_ge_1\nrho_delta_upper_ge_1\ndelta_over_cache_upper_ge_1\ndelta_over_idelta_upper_ge_1\ntransfer_coverage_below_half\ncontrol_not_run\n matched_correctness=\nyes\nno\necho\nfull\ncache\nmethod\ndelta\nidelta\ndeltap\nselect\nall\ntype:Z\ntype:S\ntype:D\ntype:R\ntype:I\ntype:A\ntype:P\ntype:C\nnov:none\nnov:recall\nnov:transfer\nnov:novel\nnov:fsm_recall\nnov:fsm_new\nfam:AGG\nfam:FSM\nn:64\nn:512\nn:4096\ndelta/cache\ndelta/idelta\nselect/delta\ndelta/method\nidelta/full\nC1\nC1b\nC1c\nC2\nC3\nC4\nC5\nC6\nC7\nC8\nC9\nC10\nC11\nC12\ndetected\nundetected\nreported\nnot_run\nmissing\n bind_failures=NOT_RECORDED\n restart_identity=\n delta_over_method\n idelta_over_full\n route5_method=\n \n0123456789abcdef\n route5_delta=\n missing_pairs=\n end_ns=\n end_failed=\n proc_failed=\n" |
| 233 | |
| 234 | global STOB uchar 4194304 |
| 235 | global STOP ulong 1 |
| 236 | global STPB uchar 4096 |
| 237 | global STPL ulong 1 |
| 238 | global STBD uchar 32768 |
| 239 | global STBL ulong 8 |
| 240 | global STFB uchar 8388608 |
| 241 | global STRNG ulong 1 |
| 242 | global STRF ulong 4 |
| 243 | global STNG ulong 1 |
| 244 | global STNS ulong 1 |
| 245 | global STNR ulong 1 |
| 246 | global STNQ ulong 1 |
| 247 | global STSPL ulong 1 |
| 248 | global STHD ulong 4 |
| 249 | global STSEED ulong 1 |
| 250 | global STGO ulong 128 |
| 251 | global STGN ulong 128 |
| 252 | global STSG ulong 1024 |
| 253 | global STSF ulong 1024 |
| 254 | global STST ulong 1024 |
| 255 | global STSN ulong 1024 |
| 256 | global STSC ulong 1024 |
| 257 | global STRO ulong 65536 |
| 258 | global STRC ulong 65536 |
| 259 | global STRS ulong 65536 |
| 260 | global STRX ulong 65536 |
| 261 | global STR0 ulong 65536 |
| 262 | global STR1 ulong 65536 |
| 263 | global STRT ulong 1572864 |
| 264 | global STAG ulong 3072 |
| 265 | global STA0 ulong 3072 |
| 266 | global STPR ulong 3072 |
| 267 | global STPF ulong 3072 |
| 268 | global STPE ulong 3072 |
| 269 | global STCNT ulong 256 |
| 270 | global STSS ulong 8192 |
| 271 | global STAQ ulong 32 |
| 272 | global STAQC ulong 32 |
| 273 | global STAQX ulong 32 |
| 274 | global STAQB ulong 32 |
| 275 | global STAQF ulong 32 |
| 276 | global STCT ulong 128 |
| 277 | global STV ulong 1024 |
| 278 | global STAA ulong 8 |
| 279 | global STT ulong 8 |
| 280 | global STBS ulong 130000 |
| 281 | global STPT ulong 13 |
| 282 | global STLO ulong 13 |
| 283 | global STHI ulong 13 |
| 284 | global STQV ulong 262144 |
| 285 | global STQI ulong 262144 |
| 286 | global STHL ulong 2 |
| 287 | global STDEC ulong 2 |
| 288 | global STSUM ulong 256 |
| 289 | global STPYC long 1 |
| 290 | global STPYQ ulong 1 |
| 291 | global STQT ulong 1 |
| 292 | |
| 293 | note ---------- output buffer ---------- |
| 294 | fn stoc c uchar to void |
| 295 | p = get STOP 0 |
| 296 | put STOB p c |
| 297 | put STOP 0 add p 1 |
| 298 | end |
| 299 | |
| 300 | fn stkoff k ulong to ulong |
| 301 | i = ulong 0 |
| 302 | c = ulong 0 |
| 303 | while lt c k bound 999999 |
| 304 | if eq get STK i 10 |
| 305 | c = add c 1 |
| 306 | end |
| 307 | i = add i 1 |
| 308 | end |
| 309 | ret i |
| 310 | end |
| 311 | |
| 312 | fn stks k ulong to void |
| 313 | i = stkoff k |
| 314 | while ne get STK i 10 bound 4096 |
| 315 | stoc get STK i |
| 316 | i = add i 1 |
| 317 | end |
| 318 | end |
| 319 | |
| 320 | fn stnl to void |
| 321 | stoc 10 |
| 322 | end |
| 323 | |
| 324 | fn stou v ulong to void |
| 325 | d = new uchar 24 0 |
| 326 | n = ulong 0 |
| 327 | x = v |
| 328 | while true bound 30 |
| 329 | put d n uchar add rem x 10 48 |
| 330 | n = add n 1 |
| 331 | x = div x 10 |
| 332 | if eq x 0 |
| 333 | break |
| 334 | end |
| 335 | end |
| 336 | for i ulong n |
| 337 | stoc get d sub sub n i 1 |
| 338 | end |
| 339 | end |
| 340 | |
| 341 | fn stol v long to void |
| 342 | if lt v 0 |
| 343 | stoc 45 |
| 344 | stou ulong neg v |
| 345 | ret |
| 346 | end |
| 347 | stou ulong v |
| 348 | end |
| 349 | |
| 350 | note one lowercase hex digit pair of byte b |
| 351 | fn stohb b ulong to void |
| 352 | h = add stkoff SKDIG shr b 4 |
| 353 | l = add stkoff SKDIG and b 15 |
| 354 | stoc get STK h |
| 355 | stoc get STK l |
| 356 | end |
| 357 | |
| 358 | note a digest word as stored in the split files (bytes 8j..8j+7 read big endian) as 16 hex digits |
| 359 | fn stohw w ulong to void |
| 360 | for k ulong 8 |
| 361 | stohb and shr w mul sub 7 k 8 255 |
| 362 | end |
| 363 | end |
| 364 | |
| 365 | note key k, then value v |
| 366 | fn stkv k ulong v ulong to void |
| 367 | stks k |
| 368 | stou v |
| 369 | end |
| 370 | |
| 371 | fn stkvl k ulong v long to void |
| 372 | stks k |
| 373 | stol v |
| 374 | end |
| 375 | |
| 376 | note write the output buffer to fd; 0 ok |
| 377 | fn stflush fd int to int |
| 378 | n = get STOP 0 |
| 379 | o = ulong 0 |
| 380 | while lt o n bound 999999 |
| 381 | w = write fd STOB o sub n o |
| 382 | if le w 0 |
| 383 | ret 1 |
| 384 | end |
| 385 | o = add o ulong w |
| 386 | end |
| 387 | ret 0 |
| 388 | end |
| 389 | |
| 390 | note ---------- paths and files ---------- |
| 391 | fn stpc c uchar to void |
| 392 | p = get STPL 0 |
| 393 | put STPB p c |
| 394 | put STPL 0 add p 1 |
| 395 | end |
| 396 | |
| 397 | fn stpk k ulong to void |
| 398 | i = stkoff k |
| 399 | while ne get STK i 10 bound 4096 |
| 400 | stpc get STK i |
| 401 | i = add i 1 |
| 402 | end |
| 403 | end |
| 404 | |
| 405 | fn stpu v ulong to void |
| 406 | d = new uchar 24 0 |
| 407 | n = ulong 0 |
| 408 | x = v |
| 409 | while true bound 30 |
| 410 | put d n uchar add rem x 10 48 |
| 411 | n = add n 1 |
| 412 | x = div x 10 |
| 413 | if eq x 0 |
| 414 | break |
| 415 | end |
| 416 | end |
| 417 | for i ulong n |
| 418 | stpc get d sub sub n i 1 |
| 419 | end |
| 420 | end |
| 421 | |
| 422 | fn stpu2 v ulong to void |
| 423 | stpc uchar add div v 10 48 |
| 424 | stpc uchar add rem v 10 48 |
| 425 | end |
| 426 | |
| 427 | note base slot b (an argv copy) exactly as the path |
| 428 | fn stpexact b ulong to void |
| 429 | put STPL 0 0 |
| 430 | o = mul b 4096 |
| 431 | for i ulong get STBL b |
| 432 | stpc get STBD add o i |
| 433 | end |
| 434 | end |
| 435 | |
| 436 | note base slot b as the path, then a slash |
| 437 | fn stpbase b ulong to void |
| 438 | stpexact b |
| 439 | stpc 47 |
| 440 | end |
| 441 | |
| 442 | note argv[ix] into base slot b; returns its length (0 = missing) |
| 443 | fn stargb ix ulong b ulong to ulong |
| 444 | o = mul b 4096 |
| 445 | n = argread ix STBD o 4095 |
| 446 | if le n 0 |
| 447 | put STBL b 0 |
| 448 | ret 0 |
| 449 | end |
| 450 | put STBL b ulong n |
| 451 | ret ulong n |
| 452 | end |
| 453 | |
| 454 | note the whole file at STPB into STFB; bytes read, or -errno, or -27 when it does not fit |
| 455 | fn stload to long |
| 456 | fd = fopen STPB 0 get STPL 0 0 0 |
| 457 | if lt fd 0 |
| 458 | ret fd |
| 459 | end |
| 460 | tot = ulong 0 |
| 461 | cap = len STFB |
| 462 | r = long 0 |
| 463 | while lt tot cap bound 999999 |
| 464 | m = sub cap tot |
| 465 | if gt m 1048576 |
| 466 | m = 1048576 |
| 467 | end |
| 468 | n = read int fd STFB tot m |
| 469 | if lt n 0 |
| 470 | r = n |
| 471 | break |
| 472 | end |
| 473 | if eq n 0 |
| 474 | break |
| 475 | end |
| 476 | tot = add tot ulong n |
| 477 | end |
| 478 | c = fclose int fd |
| 479 | if lt r 0 |
| 480 | ret r |
| 481 | end |
| 482 | if lt c 0 |
| 483 | ret c |
| 484 | end |
| 485 | if eq tot cap |
| 486 | ret -27 |
| 487 | end |
| 488 | ret long tot |
| 489 | end |
| 490 | |
| 491 | note little-endian word at byte o of STFB |
| 492 | fn stw o ulong to ulong |
| 493 | v = ulong 0 |
| 494 | for k ulong 8 |
| 495 | b = ulong get STFB add o k |
| 496 | v = or v shl b mul k 8 |
| 497 | end |
| 498 | ret v |
| 499 | end |
| 500 | |
| 501 | note word k of record rec (rb bytes per record) |
| 502 | fn strw rec ulong rb ulong k ulong to ulong |
| 503 | ret stw add mul rec rb mul k 8 |
| 504 | end |
| 505 | |
| 506 | note write STOB[0..n) to the path in STPB (create or truncate, mode 0644, fsync); 0 ok |
| 507 | fn stwfile to int |
| 508 | fd = fopen STPB 0 get STPL 0 577 420 |
| 509 | if lt fd 0 |
| 510 | ret 1 |
| 511 | end |
| 512 | r = stflush int fd |
| 513 | s = fsync int fd |
| 514 | c = fclose int fd |
| 515 | if or ne r 0 or ne s 0 ne c 0 |
| 516 | ret 1 |
| 517 | end |
| 518 | ret 0 |
| 519 | end |
| 520 | |
| 521 | note ---------- 128-bit exact arithmetic ---------- |
| 522 | note a * b into STHL (0 high, 1 low) |
| 523 | fn stmul a ulong b ulong to void |
| 524 | m = ulong 4294967295 |
| 525 | al = and a m |
| 526 | bl = and b m |
| 527 | p0 = mul al bl |
| 528 | p1 = mul al shr b 32 |
| 529 | p2 = mul shr a 32 bl |
| 530 | mid = add add shr p0 32 and p1 m and p2 m |
| 531 | put STHL 1 or and p0 m shl mid 32 |
| 532 | hi = mul shr a 32 shr b 32 |
| 533 | hi = add add hi shr p1 32 add shr p2 32 shr mid 32 |
| 534 | put STHL 0 hi |
| 535 | end |
| 536 | |
| 537 | note floor(a * b / c), saturated at 2^64 - 1; c = 0 gives 2^64 - 1 |
| 538 | fn stmd a ulong b ulong c ulong to ulong |
| 539 | if eq c 0 |
| 540 | ret 18446744073709551615 |
| 541 | end |
| 542 | stmul a b |
| 543 | hi = get STHL 0 |
| 544 | lo = get STHL 1 |
| 545 | r = ulong 0 |
| 546 | q = ulong 0 |
| 547 | ov = false |
| 548 | bit = ulong 0 |
| 549 | for i ulong 128 |
| 550 | if lt i 64 |
| 551 | bit = and shr hi sub 63 i 1 |
| 552 | else |
| 553 | bit = and shr lo sub 127 i 1 |
| 554 | end |
| 555 | cy = shr r 63 |
| 556 | r = or shl r 1 bit |
| 557 | qb = ulong 0 |
| 558 | if or eq cy 1 ge r c |
| 559 | r = sub r c |
| 560 | qb = 1 |
| 561 | end |
| 562 | if and lt i 64 eq qb 1 |
| 563 | ov = true |
| 564 | end |
| 565 | q = or shl q 1 qb |
| 566 | end |
| 567 | if ov |
| 568 | ret 18446744073709551615 |
| 569 | end |
| 570 | ret q |
| 571 | end |
| 572 | |
| 573 | note ppm of num over den (floor) |
| 574 | fn stppm num ulong den ulong to ulong |
| 575 | ret stmd num 1000000 den |
| 576 | end |
| 577 | |
| 578 | note signed ppm (truncation toward zero); den must be > 0 |
| 579 | fn stppms num long den long to long |
| 580 | if lt num 0 |
| 581 | ret neg long stmd ulong neg num 1000000 ulong den |
| 582 | end |
| 583 | ret long stmd ulong num 1000000 ulong den |
| 584 | end |
| 585 | |
| 586 | note ---------- splitmix64 ---------- |
| 587 | fn stsm to ulong |
| 588 | s = add get STRNG 0 11400714819323198485 |
| 589 | put STRNG 0 s |
| 590 | z = mul xor s shr s 30 13787848793156543929 |
| 591 | z = mul xor z shr z 27 10723151780598845931 |
| 592 | ret xor z shr z 31 |
| 593 | end |
| 594 | |
| 595 | note hex digit value, 16 = not a hex digit |
| 596 | fn sthexv c uchar to ulong |
| 597 | if and ge c 48 le c 57 |
| 598 | ret ulong sub c 48 |
| 599 | end |
| 600 | if and ge c 97 le c 102 |
| 601 | ret ulong sub c 87 |
| 602 | end |
| 603 | if and ge c 65 le c 70 |
| 604 | ret ulong sub c 55 |
| 605 | end |
| 606 | ret 16 |
| 607 | end |
| 608 | |
| 609 | note byte i (0..31) of the 64-hex text held in base slot b; 256 = bad |
| 610 | fn sthexb b ulong i ulong to ulong |
| 611 | o = add mul b 4096 mul i 2 |
| 612 | h = sthexv get STBD o |
| 613 | l = sthexv get STBD add o 1 |
| 614 | if or gt h 15 gt l 15 |
| 615 | ret 256 |
| 616 | end |
| 617 | ret or shl h 4 l |
| 618 | end |
| 619 | |
| 620 | note little-endian word from hex bytes s..s+7 of base slot b; STRF 3 = 1 on a bad digit |
| 621 | fn sthexw b ulong s ulong to ulong |
| 622 | v = ulong 0 |
| 623 | for k ulong 8 |
| 624 | x = sthexb b add s k |
| 625 | if gt x 255 |
| 626 | put STRF 3 1 |
| 627 | x = 0 |
| 628 | end |
| 629 | v = or v shl x mul k 8 |
| 630 | end |
| 631 | ret v |
| 632 | end |
| 633 | |
| 634 | note ---------- refusal ---------- |
| 635 | fn stref code ulong a ulong r ulong g ulong to int |
| 636 | put STRF 0 code |
| 637 | put STRF 1 a |
| 638 | put STRF 2 r |
| 639 | put STRF 3 g |
| 640 | ret int code |
| 641 | end |
| 642 | |
| 643 | fn stprref to void |
| 644 | stks SKREFU |
| 645 | stou get STRF 0 |
| 646 | stks SKDETL |
| 647 | stou get STRF 1 |
| 648 | stoc 46 |
| 649 | stou get STRF 2 |
| 650 | stoc 46 |
| 651 | stou get STRF 3 |
| 652 | stnl |
| 653 | end |
| 654 | |
| 655 | note ---------- split directory ---------- |
| 656 | fn stidx to int |
| 657 | stpbase 0 |
| 658 | stpk SKINDEX |
| 659 | n = stload |
| 660 | if lt n 128 |
| 661 | ret stref 2 0 0 0 |
| 662 | end |
| 663 | if or ne stw 0 3544386032354079058 ne stw 8 1 |
| 664 | ret stref 3 0 0 0 |
| 665 | end |
| 666 | g = stw 24 |
| 667 | if or eq g 0 gt g 99 |
| 668 | ret stref 3 1 0 0 |
| 669 | end |
| 670 | if ne ulong n add 128 mul g 8 |
| 671 | ret stref 3 2 0 0 |
| 672 | end |
| 673 | put STNG 0 g |
| 674 | put STSPL 0 stw 16 |
| 675 | put STNS 0 stw 32 |
| 676 | put STNR 0 stw 40 |
| 677 | put STNQ 0 stw 48 |
| 678 | for j ulong 4 |
| 679 | put STHD j stw add 56 mul j 8 |
| 680 | end |
| 681 | off = ulong 0 |
| 682 | for i ulong g |
| 683 | c = stw add 128 mul i 8 |
| 684 | put STGN i c |
| 685 | put STGO i off |
| 686 | off = add off c |
| 687 | end |
| 688 | if ne off get STNR 0 |
| 689 | ret stref 3 3 0 0 |
| 690 | end |
| 691 | if gt off len STRO |
| 692 | ret stref 14 0 0 0 |
| 693 | end |
| 694 | ret 0 |
| 695 | end |
| 696 | |
| 697 | note checks one sessions record i; 0 ok |
| 698 | fn stsone i ulong to int |
| 699 | g = strw i 128 1 |
| 700 | f = strw i 128 2 |
| 701 | t = strw i 128 3 |
| 702 | v = strw i 128 4 |
| 703 | c = strw i 128 5 |
| 704 | if or ne strw i 128 0 i ge g get STNG 0 |
| 705 | ret 1 |
| 706 | end |
| 707 | if or or lt f 1 gt f 2 or lt t 1 gt t 8 |
| 708 | ret 1 |
| 709 | end |
| 710 | if or gt v 5 gt c 2 |
| 711 | ret 1 |
| 712 | end |
| 713 | put STSG i g |
| 714 | put STSF i f |
| 715 | put STST i t |
| 716 | put STSN i v |
| 717 | put STSC i c |
| 718 | ret 0 |
| 719 | end |
| 720 | |
| 721 | fn stsess to int |
| 722 | stpbase 0 |
| 723 | stpk SKSESS |
| 724 | n = stload |
| 725 | s = get STNS 0 |
| 726 | if or eq s 0 gt s len STSG |
| 727 | ret stref 4 0 0 0 |
| 728 | end |
| 729 | if ne n long mul s 128 |
| 730 | ret stref 4 1 0 0 |
| 731 | end |
| 732 | for i ulong s |
| 733 | if ne stsone i 0 |
| 734 | ret stref 4 2 i 0 |
| 735 | end |
| 736 | end |
| 737 | ret 0 |
| 738 | end |
| 739 | |
| 740 | fn stexpg g ulong to int |
| 741 | stpbase 0 |
| 742 | stpc 103 |
| 743 | stpu2 g |
| 744 | stpk SKEXP |
| 745 | n = stload |
| 746 | c = get STGN g |
| 747 | if ne n long mul c 64 |
| 748 | ret stref 5 0 0 g |
| 749 | end |
| 750 | o = get STGO g |
| 751 | for j ulong c |
| 752 | i = add o j |
| 753 | s = strw j 64 5 |
| 754 | if or ge s get STNS 0 ne get STSG s g |
| 755 | ret stref 5 1 j g |
| 756 | end |
| 757 | put STRX i strw j 64 0 |
| 758 | put STR0 i strw j 64 2 |
| 759 | put STR1 i strw j 64 3 |
| 760 | put STRO i strw j 64 4 |
| 761 | put STRS i s |
| 762 | put STRC i strw j 64 6 |
| 763 | end |
| 764 | ret 0 |
| 765 | end |
| 766 | |
| 767 | fn stexps to int |
| 768 | q = ulong 0 |
| 769 | for g ulong get STNG 0 |
| 770 | r = stexpg g |
| 771 | if ne r 0 |
| 772 | ret r |
| 773 | end |
| 774 | o = get STGO g |
| 775 | for j ulong get STGN g |
| 776 | if eq get STRO add o j 2 |
| 777 | q = add q 1 |
| 778 | end |
| 779 | end |
| 780 | end |
| 781 | if ne q get STNQ 0 |
| 782 | ret stref 5 2 q 0 |
| 783 | end |
| 784 | ret 0 |
| 785 | end |
| 786 | |
| 787 | note ---------- raw run logs ---------- |
| 788 | fn stcadd a ulong k ulong v ulong to void |
| 789 | x = add mul a 32 k |
| 790 | put STCNT x add get STCNT x v |
| 791 | end |
| 792 | |
| 793 | fn stcmax a ulong k ulong v ulong to void |
| 794 | x = add mul a 32 k |
| 795 | if gt v get STCNT x |
| 796 | put STCNT x v |
| 797 | end |
| 798 | end |
| 799 | |
| 800 | note the correctness the log should carry for record j (byte base o) of request i |
| 801 | fn stwant a ulong i ulong o ulong to ulong |
| 802 | if eq a 0 |
| 803 | ret 2 |
| 804 | end |
| 805 | sg = stw add o 40 |
| 806 | if ne sg get STRX i |
| 807 | ret 0 |
| 808 | end |
| 809 | if ne get STRO i 2 |
| 810 | ret 2 |
| 811 | end |
| 812 | if and eq stw add o 48 get STR0 i eq stw add o 56 get STR1 i |
| 813 | ret 1 |
| 814 | end |
| 815 | ret 0 |
| 816 | end |
| 817 | |
| 818 | note correctness counters for one record |
| 819 | fn stcorr a ulong i ulong o ulong to void |
| 820 | corr = stw add o 120 |
| 821 | want = stwant a i o |
| 822 | if ne corr want |
| 823 | stcadd a 5 1 |
| 824 | end |
| 825 | if eq a 0 |
| 826 | stcadd a 4 1 |
| 827 | ret |
| 828 | end |
| 829 | bad = or eq want 0 eq corr 0 |
| 830 | if eq get STRO i 2 |
| 831 | if bad |
| 832 | stcadd a 1 1 |
| 833 | else |
| 834 | stcadd a 0 1 |
| 835 | end |
| 836 | ret |
| 837 | end |
| 838 | if bad |
| 839 | stcadd a 3 1 |
| 840 | else |
| 841 | stcadd a 2 1 |
| 842 | end |
| 843 | end |
| 844 | |
| 845 | note QUERY route, round-trip, hit and transfer counters |
| 846 | fn stquery a ulong i ulong o ulong rt ulong to void |
| 847 | rte = stw add o 64 |
| 848 | if le rte 5 |
| 849 | stcadd a add 6 rte 1 |
| 850 | else |
| 851 | stcadd a 12 1 |
| 852 | end |
| 853 | stcadd a 13 rt |
| 854 | stcadd a 14 1 |
| 855 | hit = and ge rte 2 le rte 4 |
| 856 | if hit |
| 857 | stcadd a 15 rt |
| 858 | stcadd a 16 1 |
| 859 | end |
| 860 | s = get STRS i |
| 861 | if and eq a 4 eq get STSN s 2 |
| 862 | stcadd a 17 1 |
| 863 | if and ge rte 3 le rte 4 |
| 864 | stcadd a 18 1 |
| 865 | end |
| 866 | end |
| 867 | end |
| 868 | |
| 869 | note word k of the record at byte o differs from v |
| 870 | fn stwne o ulong k ulong v ulong to bool |
| 871 | ret ne stw add o mul k 8 v |
| 872 | end |
| 873 | |
| 874 | note identity and expectation words of record j at byte o; 0 ok, else refusal code |
| 875 | fn stchk a ulong r ulong g ulong j ulong o ulong to int |
| 876 | i = add get STGO g j |
| 877 | if or stwne o 0 g stwne o 1 r |
| 878 | ret 8 |
| 879 | end |
| 880 | if or stwne o 2 a stwne o 3 j |
| 881 | ret 8 |
| 882 | end |
| 883 | if stwne o 4 get STRO i |
| 884 | ret 8 |
| 885 | end |
| 886 | if or stwne o 9 get STRX i stwne o 10 get STR0 i |
| 887 | ret 9 |
| 888 | end |
| 889 | if or stwne o 11 get STR1 i stwne o 13 get STRC i |
| 890 | ret 9 |
| 891 | end |
| 892 | if stwne o 14 get STRS i |
| 893 | ret 9 |
| 894 | end |
| 895 | ret 0 |
| 896 | end |
| 897 | |
| 898 | note one raw log record j of (a, r, g), already in STFB; 0 ok, else a refusal code |
| 899 | fn strec a ulong r ulong g ulong j ulong to int |
| 900 | o = mul j 128 |
| 901 | e = stchk a r g j o |
| 902 | if ne e 0 |
| 903 | ret e |
| 904 | end |
| 905 | i = add get STGO g j |
| 906 | rt = stw add o 96 |
| 907 | put STRT add mul add mul a 3 r 65536 i rt |
| 908 | slot = add mul add mul a 3 r 128 g |
| 909 | put STAG slot add get STAG slot rt |
| 910 | if eq j 0 |
| 911 | put STA0 slot rt |
| 912 | end |
| 913 | s = add mul a 1024 get STRS i |
| 914 | put STSS s add get STSS s rt |
| 915 | stcorr a i o |
| 916 | if eq get STRO i 2 |
| 917 | stquery a i o rt |
| 918 | end |
| 919 | ret 0 |
| 920 | end |
| 921 | |
| 922 | fn stlog a ulong r ulong g ulong to int |
| 923 | stpbase 1 |
| 924 | stpk SKARMP |
| 925 | stpc uchar add a 48 |
| 926 | stpk SKREPP |
| 927 | stpc uchar add r 48 |
| 928 | stpk SKGP |
| 929 | stpu2 g |
| 930 | stpk SKLOG |
| 931 | n = stload |
| 932 | if lt n 0 |
| 933 | ret stref 6 a r g |
| 934 | end |
| 935 | c = get STGN g |
| 936 | if ne n long mul c 128 |
| 937 | ret stref 7 a r g |
| 938 | end |
| 939 | for j ulong c |
| 940 | e = strec a r g j |
| 941 | if ne e 0 |
| 942 | ret stref ulong e a r add mul g 100000 j |
| 943 | end |
| 944 | end |
| 945 | ret 0 |
| 946 | end |
| 947 | |
| 948 | fn stlogs to int |
| 949 | for a ulong 8 |
| 950 | for r ulong 3 |
| 951 | for g ulong get STNG 0 |
| 952 | e = stlog a r g |
| 953 | if ne e 0 |
| 954 | ret e |
| 955 | end |
| 956 | end |
| 957 | end |
| 958 | end |
| 959 | ret 0 |
| 960 | end |
| 961 | |
| 962 | note ---------- proc.log, acq.log, controls.log ---------- |
| 963 | fn stproc1 k ulong to int |
| 964 | a = strw k 128 0 |
| 965 | g = strw k 128 1 |
| 966 | r = strw k 128 2 |
| 967 | if or or ge a 8 ge g get STNG 0 ge r 3 |
| 968 | ret stref 10 k 0 0 |
| 969 | end |
| 970 | slot = add mul add mul a 3 r 128 g |
| 971 | if ne get STPF slot 0 |
| 972 | ret stref 11 a r g |
| 973 | end |
| 974 | put STPF slot 1 |
| 975 | put STPR slot strw k 128 3 |
| 976 | put STPE slot strw k 128 15 |
| 977 | stcadd a 26 strw k 128 15 |
| 978 | stcadd a 19 1 |
| 979 | stcmax a 20 strw k 128 8 |
| 980 | stcadd a 21 strw k 128 8 |
| 981 | stcmax a 22 strw k 128 9 |
| 982 | cpu = add add strw k 128 4 strw k 128 5 add strw k 128 6 strw k 128 7 |
| 983 | stcadd a 23 cpu |
| 984 | stpexit a strw k 128 10 |
| 985 | stcadd a 25 strw k 128 3 |
| 986 | ret 0 |
| 987 | end |
| 988 | |
| 989 | note K17 exit word x of one arm process: nonzero = a failed process, counted as one wrong |
| 990 | note refusal of the arm (counter 3, so STOP for arms 1..7) and in counters 24 (exit nonzero) and |
| 991 | note 28 (failed processes); x >= 1024 = END itself failed (counter 27) |
| 992 | fn stpexit a ulong x ulong to void |
| 993 | if eq x 0 |
| 994 | ret |
| 995 | end |
| 996 | stcadd a 24 1 |
| 997 | stcadd a 28 1 |
| 998 | stcadd a 3 1 |
| 999 | if ge x 1024 |
| 1000 | stcadd a 27 1 |
| 1001 | end |
| 1002 | end |
| 1003 | |
| 1004 | fn stprocs to int |
| 1005 | stpbase 1 |
| 1006 | stpk SKPROC |
| 1007 | n = stload |
| 1008 | if or lt n 0 ne rem ulong n 128 0 |
| 1009 | ret stref 10 0 0 0 |
| 1010 | end |
| 1011 | for k ulong div ulong n 128 |
| 1012 | e = stproc1 k |
| 1013 | if ne e 0 |
| 1014 | ret e |
| 1015 | end |
| 1016 | end |
| 1017 | for a ulong 8 |
| 1018 | for r ulong 3 |
| 1019 | for g ulong get STNG 0 |
| 1020 | if eq get STPF add mul add mul a 3 r 128 g 0 |
| 1021 | ret stref 11 a r g |
| 1022 | end |
| 1023 | end |
| 1024 | end |
| 1025 | end |
| 1026 | ret 0 |
| 1027 | end |
| 1028 | |
| 1029 | fn stacq1 k ulong to int |
| 1030 | l = strw k 64 0 |
| 1031 | r = strw k 64 1 |
| 1032 | if or gt l 9 ge r 3 |
| 1033 | ret stref 12 k 0 0 |
| 1034 | end |
| 1035 | x = add mul l 3 r |
| 1036 | if ne get STAQF x 0 |
| 1037 | ret stref 12 k 1 0 |
| 1038 | end |
| 1039 | put STAQF x 1 |
| 1040 | put STAQ x strw k 64 2 |
| 1041 | put STAQC x add strw k 64 3 strw k 64 4 |
| 1042 | put STAQX x strw k 64 5 |
| 1043 | put STAQB x strw k 64 6 |
| 1044 | ret 0 |
| 1045 | end |
| 1046 | |
| 1047 | fn stacqs to int |
| 1048 | stpbase 1 |
| 1049 | stpk SKACQ |
| 1050 | n = stload |
| 1051 | if or lt n 0 ne rem ulong n 64 0 |
| 1052 | ret stref 12 0 0 0 |
| 1053 | end |
| 1054 | for k ulong div ulong n 64 |
| 1055 | e = stacq1 k |
| 1056 | if ne e 0 |
| 1057 | ret e |
| 1058 | end |
| 1059 | end |
| 1060 | for l ulong 2 |
| 1061 | for r ulong 3 |
| 1062 | if eq get STAQF add mul add l 1 3 r 0 |
| 1063 | ret stref 12 add l 1 r 2 |
| 1064 | end |
| 1065 | end |
| 1066 | end |
| 1067 | ret 0 |
| 1068 | end |
| 1069 | |
| 1070 | note required sub-cases of control c as a bit mask (bit s = sub-case s), the 36 pairs EvalJudge's |
| 1071 | note controls run writes (confirmed with EvalJudge 2026-10-25): C1 0,1; C1b 0,1; C1c 0; C2 0,1; |
| 1072 | note C3 0,1; C4 0; C5 0..5; C6 0,1,2; C7 0,1; C8 1..9 (crashafter K); C9 0,1; C10 0,1; C11 0; |
| 1073 | note C12 0 |
| 1074 | fn stcreq c ulong to ulong |
| 1075 | if or or eq c 3 eq c 6 or eq c 13 eq c 14 |
| 1076 | ret 1 |
| 1077 | end |
| 1078 | if eq c 7 |
| 1079 | ret 63 |
| 1080 | end |
| 1081 | if eq c 8 |
| 1082 | ret 7 |
| 1083 | end |
| 1084 | if eq c 10 |
| 1085 | ret 1022 |
| 1086 | end |
| 1087 | ret 3 |
| 1088 | end |
| 1089 | |
| 1090 | note required pairs of control c with no record |
| 1091 | fn stcmiss c ulong to ulong |
| 1092 | m = and stcreq c not get STCT add mul c 8 6 |
| 1093 | n = ulong 0 |
| 1094 | for s ulong 10 |
| 1095 | n = add n and shr m s 1 |
| 1096 | end |
| 1097 | ret n |
| 1098 | end |
| 1099 | |
| 1100 | note STCT per control id c (1..14), 8 slots: 0 records, 1 detected, 2 undetected, 3 reported, |
| 1101 | note 4 not run, 5 served tampered, 6 bit mask of the sub-cases seen. A sub-case outside the |
| 1102 | note required list or a repeated (control, sub-case) pair is refused (13). |
| 1103 | fn stctl1 k ulong to int |
| 1104 | c = strw k 64 0 |
| 1105 | o = strw k 64 2 |
| 1106 | f = strw k 64 3 |
| 1107 | if or or lt c 1 gt c 14 or gt o 3 gt f 1 |
| 1108 | ret stref 13 k 0 0 |
| 1109 | end |
| 1110 | if and eq o 2 ne c 14 |
| 1111 | ret stref 13 k 1 0 |
| 1112 | end |
| 1113 | s = strw k 64 1 |
| 1114 | if ge s 10 |
| 1115 | ret stref 13 k 2 0 |
| 1116 | end |
| 1117 | if eq and shr stcreq c s 1 0 |
| 1118 | ret stref 13 k 2 0 |
| 1119 | end |
| 1120 | b = mul c 8 |
| 1121 | bit = shl ulong 1 s |
| 1122 | if ne and get STCT add b 6 bit 0 |
| 1123 | ret stref 13 k 3 0 |
| 1124 | end |
| 1125 | put STCT add b 6 or get STCT add b 6 bit |
| 1126 | put STCT b add get STCT b 1 |
| 1127 | if eq o 1 |
| 1128 | put STCT add b 1 add get STCT add b 1 1 |
| 1129 | end |
| 1130 | if eq o 0 |
| 1131 | put STCT add b 2 add get STCT add b 2 1 |
| 1132 | end |
| 1133 | if eq o 2 |
| 1134 | put STCT add b 3 add get STCT add b 3 1 |
| 1135 | end |
| 1136 | if eq o 3 |
| 1137 | put STCT add b 4 add get STCT add b 4 1 |
| 1138 | end |
| 1139 | if eq f 1 |
| 1140 | put STCT add b 5 add get STCT add b 5 1 |
| 1141 | end |
| 1142 | ret 0 |
| 1143 | end |
| 1144 | |
| 1145 | fn stctls to int |
| 1146 | if and eq get STBL 2 1 eq get STBD 8192 45 |
| 1147 | ret 0 |
| 1148 | end |
| 1149 | stpbase 2 |
| 1150 | stpk SKCTL |
| 1151 | n = stload |
| 1152 | if or lt n 0 ne rem ulong n 64 0 |
| 1153 | ret stref 13 0 0 0 |
| 1154 | end |
| 1155 | for k ulong div ulong n 64 |
| 1156 | e = stctl1 k |
| 1157 | if ne e 0 |
| 1158 | ret e |
| 1159 | end |
| 1160 | end |
| 1161 | ret 0 |
| 1162 | end |
| 1163 | |
| 1164 | note ---------- totals and bootstrap ---------- |
| 1165 | fn stlib a ulong to ulong |
| 1166 | if or or eq a 3 eq a 4 eq a 7 |
| 1167 | ret 1 |
| 1168 | end |
| 1169 | if eq a 6 |
| 1170 | ret 2 |
| 1171 | end |
| 1172 | ret 0 |
| 1173 | end |
| 1174 | |
| 1175 | note process cost of (a, r, g) |
| 1176 | fn stpcost a ulong r ulong g ulong to ulong |
| 1177 | slot = add mul add mul a 3 r 128 g |
| 1178 | v = add get STPR slot get STPE slot |
| 1179 | ret sub add v get STAG slot get STA0 slot |
| 1180 | end |
| 1181 | |
| 1182 | fn sttotals to void |
| 1183 | for a ulong 8 |
| 1184 | t = ulong 0 |
| 1185 | for g ulong get STNG 0 |
| 1186 | v = ulong 0 |
| 1187 | for r ulong 3 |
| 1188 | v = add v stpcost a r g |
| 1189 | end |
| 1190 | put STV add mul a 128 g v |
| 1191 | t = add t v |
| 1192 | end |
| 1193 | l = stlib a |
| 1194 | q = ulong 0 |
| 1195 | if gt l 0 |
| 1196 | for r ulong 3 |
| 1197 | q = add q get STAQ add mul l 3 r |
| 1198 | end |
| 1199 | end |
| 1200 | put STAA a q |
| 1201 | put STT a add t q |
| 1202 | end |
| 1203 | end |
| 1204 | |
| 1205 | fn stnum s ulong to ulong |
| 1206 | if lt s 8 |
| 1207 | ret s |
| 1208 | end |
| 1209 | if eq s 11 |
| 1210 | ret 4 |
| 1211 | end |
| 1212 | if eq s 12 |
| 1213 | ret 5 |
| 1214 | end |
| 1215 | if eq s 10 |
| 1216 | ret 7 |
| 1217 | end |
| 1218 | ret 4 |
| 1219 | end |
| 1220 | |
| 1221 | fn stden s ulong to ulong |
| 1222 | if lt s 8 |
| 1223 | ret 1 |
| 1224 | end |
| 1225 | if eq s 8 |
| 1226 | ret 2 |
| 1227 | end |
| 1228 | if eq s 9 |
| 1229 | ret 5 |
| 1230 | end |
| 1231 | if eq s 10 |
| 1232 | ret 4 |
| 1233 | end |
| 1234 | if eq s 11 |
| 1235 | ret 3 |
| 1236 | end |
| 1237 | ret 1 |
| 1238 | end |
| 1239 | |
| 1240 | note one resample b: acc holds the 8 resampled totals |
| 1241 | fn stres b ulong acc edit ulong 8 to void |
| 1242 | for a ulong 8 |
| 1243 | put acc a get STAA a |
| 1244 | end |
| 1245 | g = get STNG 0 |
| 1246 | for i ulong g |
| 1247 | x = rem stsm g |
| 1248 | for a ulong 8 |
| 1249 | put acc a add get acc a get STV add mul a 128 x |
| 1250 | end |
| 1251 | end |
| 1252 | for s ulong 13 |
| 1253 | v = stppm get acc stnum s get acc stden s |
| 1254 | put STBS add mul s 10000 b v |
| 1255 | end |
| 1256 | end |
| 1257 | |
| 1258 | note ---------- heap sort of STQV[0..n) ascending, STQI moved along ---------- |
| 1259 | fn stswap i ulong j ulong to void |
| 1260 | v = get STQV i |
| 1261 | put STQV i get STQV j |
| 1262 | put STQV j v |
| 1263 | w = get STQI i |
| 1264 | put STQI i get STQI j |
| 1265 | put STQI j w |
| 1266 | end |
| 1267 | |
| 1268 | fn stsift s ulong n ulong to void |
| 1269 | r = s |
| 1270 | while true bound 64 |
| 1271 | c = add mul r 2 1 |
| 1272 | if ge c n |
| 1273 | break |
| 1274 | end |
| 1275 | if lt add c 1 n |
| 1276 | if gt get STQV add c 1 get STQV c |
| 1277 | c = add c 1 |
| 1278 | end |
| 1279 | end |
| 1280 | if le get STQV c get STQV r |
| 1281 | break |
| 1282 | end |
| 1283 | stswap r c |
| 1284 | r = c |
| 1285 | end |
| 1286 | end |
| 1287 | |
| 1288 | fn stsort n ulong to void |
| 1289 | if lt n 2 |
| 1290 | ret |
| 1291 | end |
| 1292 | i = div n 2 |
| 1293 | while gt i 0 bound 999999 |
| 1294 | i = sub i 1 |
| 1295 | stsift i n |
| 1296 | end |
| 1297 | e = n |
| 1298 | while gt e 1 bound 999999 |
| 1299 | e = sub e 1 |
| 1300 | stswap 0 e |
| 1301 | stsift 0 e |
| 1302 | end |
| 1303 | end |
| 1304 | |
| 1305 | note nearest rank index for p per mille of n (n > 0): ceil(p n / 1000) - 1 |
| 1306 | fn strank p ulong n ulong to ulong |
| 1307 | ret sub div add mul p n 999 1000 1 |
| 1308 | end |
| 1309 | |
| 1310 | fn stboot to void |
| 1311 | put STRNG 0 get STSEED 0 |
| 1312 | acc = new ulong 8 0 |
| 1313 | for b ulong 10000 |
| 1314 | stres b acc |
| 1315 | end |
| 1316 | for s ulong 13 |
| 1317 | put STPT s stppm get STT stnum s get STT stden s |
| 1318 | for b ulong 10000 |
| 1319 | put STQV b get STBS add mul s 10000 b |
| 1320 | put STQI b 0 |
| 1321 | end |
| 1322 | stsort 10000 |
| 1323 | put STLO s get STQV strank 25 10000 |
| 1324 | put STHI s get STQV strank 975 10000 |
| 1325 | end |
| 1326 | end |
| 1327 | |
| 1328 | note ---------- categories and quantiles ---------- |
| 1329 | fn stcatm cat ulong s ulong to bool |
| 1330 | if eq cat 0 |
| 1331 | ret true |
| 1332 | end |
| 1333 | if le cat 8 |
| 1334 | ret eq get STST s cat |
| 1335 | end |
| 1336 | if le cat 14 |
| 1337 | ret eq get STSN s sub cat 9 |
| 1338 | end |
| 1339 | if le cat 16 |
| 1340 | ret eq get STSF s sub cat 14 |
| 1341 | end |
| 1342 | ret eq get STSC s sub cat 17 |
| 1343 | end |
| 1344 | |
| 1345 | note request i is a QUERY with cold flag t |
| 1346 | fn stisq i ulong t ulong to bool |
| 1347 | if ne get STRO i 2 |
| 1348 | ret false |
| 1349 | end |
| 1350 | ret eq get STRC i t |
| 1351 | end |
| 1352 | |
| 1353 | note fill STQV/STQI with the QUERY round trips of arm a with cold flag t; returns the count |
| 1354 | fn stqfill a ulong t ulong to ulong |
| 1355 | m = ulong 0 |
| 1356 | n = get STNR 0 |
| 1357 | for r ulong 3 |
| 1358 | base = mul add mul a 3 r 65536 |
| 1359 | for i ulong n |
| 1360 | if stisq i t |
| 1361 | put STQV m get STRT add base i |
| 1362 | put STQI m get STRS i |
| 1363 | m = add m 1 |
| 1364 | end |
| 1365 | end |
| 1366 | end |
| 1367 | ret m |
| 1368 | end |
| 1369 | |
| 1370 | note the value at rank k (0-based) among the sorted entries of category cat |
| 1371 | fn stqpick m ulong cat ulong k ulong to ulong |
| 1372 | c = ulong 0 |
| 1373 | for j ulong m |
| 1374 | if stcatm cat get STQI j |
| 1375 | if eq c k |
| 1376 | ret get STQV j |
| 1377 | end |
| 1378 | c = add c 1 |
| 1379 | end |
| 1380 | end |
| 1381 | ret 0 |
| 1382 | end |
| 1383 | |
| 1384 | fn stqline a ulong t ulong cat ulong m ulong to void |
| 1385 | c = ulong 0 |
| 1386 | for j ulong m |
| 1387 | if stcatm cat get STQI j |
| 1388 | c = add c 1 |
| 1389 | end |
| 1390 | end |
| 1391 | stks SKQUANT |
| 1392 | stks SKARM |
| 1393 | stks add SKARM0 a |
| 1394 | stks SKTEMP |
| 1395 | if eq t 1 |
| 1396 | stks SKCOLD |
| 1397 | else |
| 1398 | stks SKWARM |
| 1399 | end |
| 1400 | stks SKCAT |
| 1401 | stks add SKCAT0 cat |
| 1402 | stkv SKCOUNT c |
| 1403 | if eq c 0 |
| 1404 | stks SKP50 |
| 1405 | stks SKNA |
| 1406 | stks SKP95 |
| 1407 | stks SKNA |
| 1408 | stks SKP99 |
| 1409 | stks SKNA |
| 1410 | stnl |
| 1411 | ret |
| 1412 | end |
| 1413 | stkv SKP50 stqpick m cat strank 500 c |
| 1414 | stkv SKP95 stqpick m cat strank 950 c |
| 1415 | stkv SKP99 stqpick m cat strank 990 c |
| 1416 | stnl |
| 1417 | end |
| 1418 | |
| 1419 | fn stquants to void |
| 1420 | for a ulong 8 |
| 1421 | for t ulong 2 |
| 1422 | tt = sub 1 t |
| 1423 | m = stqfill a tt |
| 1424 | stsort m |
| 1425 | for cat ulong 20 |
| 1426 | stqline a tt cat m |
| 1427 | end |
| 1428 | end |
| 1429 | end |
| 1430 | end |
| 1431 | |
| 1432 | note request round-trip sum of arm a over sessions of category cat (all reps) |
| 1433 | fn stcsum a ulong cat ulong to ulong |
| 1434 | v = ulong 0 |
| 1435 | for s ulong get STNS 0 |
| 1436 | if stcatm cat s |
| 1437 | v = add v get STSS add mul a 1024 s |
| 1438 | end |
| 1439 | end |
| 1440 | ret v |
| 1441 | end |
| 1442 | |
| 1443 | fn stcatline a ulong cat ulong to void |
| 1444 | d = stcsum 1 cat |
| 1445 | if eq d 0 |
| 1446 | ret |
| 1447 | end |
| 1448 | stks SKCATR |
| 1449 | stks SKARM |
| 1450 | stks add SKARM0 a |
| 1451 | stks SKCAT |
| 1452 | stks add SKCAT0 cat |
| 1453 | stkv SKPPM stppm stcsum a cat d |
| 1454 | stnl |
| 1455 | end |
| 1456 | |
| 1457 | fn stregime t ulong to void |
| 1458 | m = stcsum 3 t |
| 1459 | f = stcsum 1 t |
| 1460 | if or eq m 0 eq f 0 |
| 1461 | ret |
| 1462 | end |
| 1463 | stks SKREGT |
| 1464 | stks add SKCAT0 t |
| 1465 | stkv SKDOM stppm stcsum 4 t m |
| 1466 | stkv SKIOF stppm stcsum 5 t f |
| 1467 | stnl |
| 1468 | end |
| 1469 | |
| 1470 | note ---------- payback ---------- |
| 1471 | note rep-summed cost of request j of group g for arm a (request 0 = start-to-ready) |
| 1472 | fn streqc a ulong g ulong j ulong to ulong |
| 1473 | v = ulong 0 |
| 1474 | i = add get STGO g j |
| 1475 | for r ulong 3 |
| 1476 | k = add mul a 3 r |
| 1477 | if eq j 0 |
| 1478 | v = add v get STPR add mul k 128 g |
| 1479 | else |
| 1480 | v = add v get STRT add mul k 65536 i |
| 1481 | end |
| 1482 | end |
| 1483 | ret v |
| 1484 | end |
| 1485 | |
| 1486 | note rep-summed END round trip of arm a's processes for group g |
| 1487 | fn stendc a ulong g ulong to ulong |
| 1488 | v = ulong 0 |
| 1489 | for r ulong 3 |
| 1490 | v = add v get STPE add mul add mul a 3 r 128 g |
| 1491 | end |
| 1492 | ret v |
| 1493 | end |
| 1494 | |
| 1495 | note one group of the payback walk; state in STPYC (cumulative) and STPYQ (QUERYs seen); |
| 1496 | note true when the cumulative sum exceeds lim. The END difference is added after the group's |
| 1497 | note last request, so END savings never count before that group's QUERYs. |
| 1498 | fn stpayg a ulong g ulong lim long to bool |
| 1499 | o = get STGO g |
| 1500 | for j ulong get STGN g |
| 1501 | d = sub long streqc 1 g j long streqc a g j |
| 1502 | cum = add get STPYC 0 d |
| 1503 | put STPYC 0 cum |
| 1504 | if eq get STRO add o j 2 |
| 1505 | put STPYQ 0 add get STPYQ 0 1 |
| 1506 | end |
| 1507 | if gt cum lim |
| 1508 | ret true |
| 1509 | end |
| 1510 | end |
| 1511 | d = sub long stendc 1 g long stendc a g |
| 1512 | cum = add get STPYC 0 d |
| 1513 | put STPYC 0 cum |
| 1514 | ret gt cum lim |
| 1515 | end |
| 1516 | |
| 1517 | note QUERYs until the cumulative (full - arm) cost exceeds acq(a); 2^64 - 1 = never |
| 1518 | fn stpay a ulong to ulong |
| 1519 | put STPYC 0 0 |
| 1520 | put STPYQ 0 0 |
| 1521 | lim = long get STAA a |
| 1522 | for g ulong get STNG 0 |
| 1523 | if stpayg a g lim |
| 1524 | ret get STPYQ 0 |
| 1525 | end |
| 1526 | end |
| 1527 | ret 18446744073709551615 |
| 1528 | end |
| 1529 | |
| 1530 | note ---------- report sections ---------- |
| 1531 | fn starmk k ulong a ulong to void |
| 1532 | stks k |
| 1533 | stks SKARM |
| 1534 | stks add SKARM0 a |
| 1535 | end |
| 1536 | |
| 1537 | fn sttotline a ulong to void |
| 1538 | starmk SKTOTAL a |
| 1539 | rt = ulong 0 |
| 1540 | rd = ulong 0 |
| 1541 | for r ulong 3 |
| 1542 | for g ulong get STNG 0 |
| 1543 | slot = add mul add mul a 3 r 128 g |
| 1544 | rt = add rt get STAG slot |
| 1545 | rd = add rd get STPR slot |
| 1546 | end |
| 1547 | end |
| 1548 | stkv SKRTNS rt |
| 1549 | stkv SKREADY rd |
| 1550 | stkv SKENDNS stc a 26 |
| 1551 | stkv SKACQNS get STAA a |
| 1552 | stkv SKTOTNS get STT a |
| 1553 | stnl |
| 1554 | end |
| 1555 | |
| 1556 | fn ststatline s ulong to void |
| 1557 | if lt s 8 |
| 1558 | starmk SKRHO s |
| 1559 | else |
| 1560 | stks SKRATIO |
| 1561 | stks add SKRAT0 sub s 8 |
| 1562 | end |
| 1563 | stkv SKPOINT get STPT s |
| 1564 | stkv SKLO get STLO s |
| 1565 | stkv SKHI get STHI s |
| 1566 | stnl |
| 1567 | end |
| 1568 | |
| 1569 | fn stc a ulong k ulong to ulong |
| 1570 | ret get STCNT add mul a 32 k |
| 1571 | end |
| 1572 | |
| 1573 | fn stcorrline a ulong to void |
| 1574 | starmk SKCORR a |
| 1575 | stkv SKQOK stc a 0 |
| 1576 | stkv SKQBAD stc a 1 |
| 1577 | stkv SKCOK stc a 2 |
| 1578 | stkv SKCBAD stc a 3 |
| 1579 | stkv SKUNSC stc a 4 |
| 1580 | stkv SKINCON stc a 5 |
| 1581 | stkv SKPROCF stc a 28 |
| 1582 | stnl |
| 1583 | end |
| 1584 | |
| 1585 | fn strouteline a ulong to void |
| 1586 | starmk SKROUTE a |
| 1587 | for k ulong 6 |
| 1588 | stks SKRN |
| 1589 | stou k |
| 1590 | stks SKEQ |
| 1591 | stou stc a add 6 k |
| 1592 | end |
| 1593 | stkv SKROTH stc a 12 |
| 1594 | stkv SKFALL stppm stc a 11 stc a 14 |
| 1595 | stnl |
| 1596 | end |
| 1597 | |
| 1598 | fn stmemline a ulong to void |
| 1599 | starmk SKMEM a |
| 1600 | n = stc a 19 |
| 1601 | stkv SKPROCS n |
| 1602 | stkv SKHWMX stc a 20 |
| 1603 | if gt n 0 |
| 1604 | stkv SKHWMM div stc a 21 n |
| 1605 | end |
| 1606 | stkv SKRSSX stc a 22 |
| 1607 | stkv SKCPU stc a 23 |
| 1608 | stkv SKEXITN stc a 24 |
| 1609 | stkv SKENDF stc a 27 |
| 1610 | stnl |
| 1611 | end |
| 1612 | |
| 1613 | fn stacqline l ulong to void |
| 1614 | stks SKACQL |
| 1615 | stou l |
| 1616 | e = ulong 0 |
| 1617 | c = ulong 0 |
| 1618 | b = ulong 0 |
| 1619 | x = ulong 0 |
| 1620 | for r ulong 3 |
| 1621 | k = add mul l 3 r |
| 1622 | e = add e get STAQ k |
| 1623 | c = add c get STAQC k |
| 1624 | if gt get STAQB k b |
| 1625 | b = get STAQB k |
| 1626 | end |
| 1627 | if ne get STAQX k 0 |
| 1628 | x = add x 1 |
| 1629 | end |
| 1630 | end |
| 1631 | stkv SKBUILD 3 |
| 1632 | stkv SKELAP e |
| 1633 | stkv SKCPU c |
| 1634 | stkv SKLIBB b |
| 1635 | stkv SKDRIVN x |
| 1636 | stnl |
| 1637 | end |
| 1638 | |
| 1639 | fn stpayline a ulong to void |
| 1640 | starmk SKPAYB a |
| 1641 | p = stpay a |
| 1642 | put STSUM add 88 a p |
| 1643 | stks SKPAYQ |
| 1644 | if eq p 18446744073709551615 |
| 1645 | stks SKNONE |
| 1646 | else |
| 1647 | stou p |
| 1648 | end |
| 1649 | stnl |
| 1650 | end |
| 1651 | |
| 1652 | note r + (1 - q) e + q + kn, every term in ppm (division truncates toward zero) |
| 1653 | fn stcbarv r long q long e long kn long to long |
| 1654 | t = div mul sub 1000000 q e 1000000 |
| 1655 | ret add add r t add q kn |
| 1656 | end |
| 1657 | |
| 1658 | note the Cbar line of arm a, f = mean full QUERY round trip (ns, > 0) |
| 1659 | fn stcbar2 a ulong f ulong to void |
| 1660 | n = stc a 14 |
| 1661 | r = long stppm div stc 0 13 stc 0 14 f |
| 1662 | h = stc a 16 |
| 1663 | e = sub long 0 r |
| 1664 | if gt h 0 |
| 1665 | e = sub long stppm div stc a 15 h f r |
| 1666 | end |
| 1667 | q = long stppm sub n h n |
| 1668 | k = stppm get STAA a f |
| 1669 | starmk SKCBAR a |
| 1670 | stkvl SKCR r |
| 1671 | stkvl SKCQ q |
| 1672 | stkvl SKCE e |
| 1673 | stkv SKCK k |
| 1674 | stkv SKCN n |
| 1675 | stkvl SKCBV stcbarv r q e long div k n |
| 1676 | stkv SKCOBS stppm div add stc a 13 get STAA a n f |
| 1677 | stnl |
| 1678 | end |
| 1679 | |
| 1680 | fn stcbarline a ulong to void |
| 1681 | fc = stc 1 14 |
| 1682 | if or or eq fc 0 eq stc a 14 0 eq stc 0 14 0 |
| 1683 | ret |
| 1684 | end |
| 1685 | f = div stc 1 13 fc |
| 1686 | if gt f 0 |
| 1687 | stcbar2 a f |
| 1688 | end |
| 1689 | end |
| 1690 | |
| 1691 | fn stecholine a ulong to void |
| 1692 | num = sub long get STT a long get STT 0 |
| 1693 | den = sub long get STT 1 long get STT 0 |
| 1694 | starmk SKECHO a |
| 1695 | stks SKPPM |
| 1696 | if le den 0 |
| 1697 | stks SKNA |
| 1698 | else |
| 1699 | stol stppms num den |
| 1700 | end |
| 1701 | stnl |
| 1702 | end |
| 1703 | |
| 1704 | note outcome word of control c: 1 detected, 0 undetected, 2 reported, 3 not run, 4 missing |
| 1705 | fn stcout c ulong to ulong |
| 1706 | b = mul c 8 |
| 1707 | if eq get STCT b 0 |
| 1708 | ret 4 |
| 1709 | end |
| 1710 | if or gt get STCT add b 2 0 gt get STCT add b 5 0 |
| 1711 | ret 0 |
| 1712 | end |
| 1713 | if or gt get STCT add b 4 0 gt stcmiss c 0 |
| 1714 | ret 3 |
| 1715 | end |
| 1716 | if gt get STCT add b 3 0 |
| 1717 | ret 2 |
| 1718 | end |
| 1719 | ret 1 |
| 1720 | end |
| 1721 | |
| 1722 | fn stctlline c ulong to void |
| 1723 | b = mul c 8 |
| 1724 | stks SKCTLID |
| 1725 | stks add SKCID0 c |
| 1726 | stkv SKRECS get STCT b |
| 1727 | stkv SKDET get STCT add b 1 |
| 1728 | stkv SKUNDET get STCT add b 2 |
| 1729 | stkv SKREPD get STCT add b 3 |
| 1730 | stkv SKNRUN get STCT add b 4 |
| 1731 | stkv SKTAMP get STCT add b 5 |
| 1732 | stkv SKMISSP stcmiss c |
| 1733 | stnl |
| 1734 | end |
| 1735 | |
| 1736 | note the outcome word of stcout value o |
| 1737 | fn stocw o ulong to void |
| 1738 | if eq o 1 |
| 1739 | stks SKOC0 |
| 1740 | ret |
| 1741 | end |
| 1742 | if eq o 0 |
| 1743 | stks add SKOC0 1 |
| 1744 | ret |
| 1745 | end |
| 1746 | stks add SKOC0 o |
| 1747 | end |
| 1748 | |
| 1749 | note " Cx=<outcome word>" |
| 1750 | fn stctlw c ulong to void |
| 1751 | stks SKSPACE |
| 1752 | stks add SKCID0 c |
| 1753 | stks SKEQ |
| 1754 | stocw stcout c |
| 1755 | end |
| 1756 | |
| 1757 | note ---------- decision ---------- |
| 1758 | fn streason k ulong bit ulong to void |
| 1759 | stks SKREAS |
| 1760 | stks k |
| 1761 | stnl |
| 1762 | put STDEC 1 or get STDEC 1 shl ulong 1 bit |
| 1763 | end |
| 1764 | |
| 1765 | fn streasa k ulong bit ulong a ulong to void |
| 1766 | stks SKREAS |
| 1767 | stks k |
| 1768 | stks SKARM |
| 1769 | stks add SKARM0 a |
| 1770 | stnl |
| 1771 | put STDEC 1 or get STDEC 1 shl ulong 1 bit |
| 1772 | end |
| 1773 | |
| 1774 | fn streasc k ulong bit ulong c ulong to void |
| 1775 | stks SKREAS |
| 1776 | stks k |
| 1777 | stks SKSPACE |
| 1778 | stks add SKCID0 c |
| 1779 | stnl |
| 1780 | put STDEC 1 or get STDEC 1 shl ulong 1 bit |
| 1781 | end |
| 1782 | |
| 1783 | note writes the reason lines; returns 3 STOP, 1 GO, 2 INVESTIGATE |
| 1784 | fn stdecide to ulong |
| 1785 | put STDEC 1 0 |
| 1786 | for a ulong 8 |
| 1787 | if gt a 0 |
| 1788 | if gt stc a 1 0 |
| 1789 | streasa SKRWA 0 a |
| 1790 | end |
| 1791 | if gt stc a 3 0 |
| 1792 | streasa SKRWR 1 a |
| 1793 | end |
| 1794 | end |
| 1795 | end |
| 1796 | for c ulong 15 |
| 1797 | if gt c 0 |
| 1798 | if gt get STCT add mul c 8 2 0 |
| 1799 | streasc SKRCU 2 c |
| 1800 | end |
| 1801 | if gt get STCT add mul c 8 5 0 |
| 1802 | streasc SKRTS 3 c |
| 1803 | end |
| 1804 | end |
| 1805 | end |
| 1806 | if ge get STLO 4 1000000 |
| 1807 | streason SKRLO 4 |
| 1808 | end |
| 1809 | stop = gt get STDEC 1 0 |
| 1810 | if ge get STHI 4 1000000 |
| 1811 | streason SKRUP 5 |
| 1812 | end |
| 1813 | if ge get STHI 8 1000000 |
| 1814 | streason SKRDC 6 |
| 1815 | end |
| 1816 | if ge get STHI 9 1000000 |
| 1817 | streason SKRDI 7 |
| 1818 | end |
| 1819 | tq = stc 4 17 |
| 1820 | if or eq tq 0 lt mul stc 4 18 2 tq |
| 1821 | streason SKRCOV 8 |
| 1822 | end |
| 1823 | for c ulong 15 |
| 1824 | if gt c 0 |
| 1825 | o = stcout c |
| 1826 | if or eq o 3 eq o 4 |
| 1827 | streasc SKRNR 9 c |
| 1828 | end |
| 1829 | end |
| 1830 | end |
| 1831 | if stop |
| 1832 | ret 3 |
| 1833 | end |
| 1834 | if eq get STDEC 1 0 |
| 1835 | ret 1 |
| 1836 | end |
| 1837 | ret 2 |
| 1838 | end |
| 1839 | |
| 1840 | fn stiss to void |
| 1841 | tq = stc 4 17 |
| 1842 | stks SKI742 |
| 1843 | stou stppm stc 4 18 tq |
| 1844 | stks SKBINDF |
| 1845 | stks SKR5 |
| 1846 | stou stc 3 11 |
| 1847 | stks SKR5D |
| 1848 | stou stc 4 11 |
| 1849 | stks SKRESTA |
| 1850 | stocw stcout 13 |
| 1851 | stctlw 1 |
| 1852 | stctlw 2 |
| 1853 | stctlw 3 |
| 1854 | stctlw 4 |
| 1855 | stctlw 5 |
| 1856 | for c ulong 6 |
| 1857 | stctlw add c 8 |
| 1858 | end |
| 1859 | stnl |
| 1860 | stks SKI743 |
| 1861 | stks SKDOMR |
| 1862 | stkv SKPOINT get STPT 11 |
| 1863 | stkv SKLO get STLO 11 |
| 1864 | stkv SKHI get STHI 11 |
| 1865 | stks SKIOFR |
| 1866 | stkv SKPOINT get STPT 12 |
| 1867 | stkv SKLO get STLO 12 |
| 1868 | stkv SKHI get STHI 12 |
| 1869 | stctlw 6 |
| 1870 | stctlw 10 |
| 1871 | stnl |
| 1872 | stks SKI744 |
| 1873 | stkv SKPOINT get STPT 10 |
| 1874 | stkv SKLO get STLO 10 |
| 1875 | stkv SKHI get STHI 10 |
| 1876 | m = and and eq stc 4 1 0 eq stc 4 3 0 and eq stc 7 1 0 eq stc 7 3 0 |
| 1877 | stks SKMATCH |
| 1878 | if m |
| 1879 | stks SKYES |
| 1880 | else |
| 1881 | stks SKNO |
| 1882 | end |
| 1883 | stks SKVERD |
| 1884 | if lt get STHI 10 1000000 |
| 1885 | stks SKHELPS |
| 1886 | else |
| 1887 | if ge get STLO 10 1000000 |
| 1888 | stks SKNHELP |
| 1889 | else |
| 1890 | stks SKINCO |
| 1891 | end |
| 1892 | end |
| 1893 | stnl |
| 1894 | end |
| 1895 | |
| 1896 | note ---------- report and summary ---------- |
| 1897 | fn stsumw k ulong v ulong to void |
| 1898 | put STSUM k v |
| 1899 | end |
| 1900 | |
| 1901 | fn stfillsum d ulong to void |
| 1902 | stsumw 0 3544386041195737426 |
| 1903 | stsumw 1 1 |
| 1904 | stsumw 2 d |
| 1905 | stsumw 3 get STDEC 1 |
| 1906 | stsumw 4 get STNG 0 |
| 1907 | stsumw 5 get STNS 0 |
| 1908 | stsumw 6 get STNR 0 |
| 1909 | stsumw 7 get STNQ 0 |
| 1910 | stsumw 8 3 |
| 1911 | stsumw 9 get STSPL 0 |
| 1912 | stsumw 10 get STSEED 0 |
| 1913 | stsumw 11 10000 |
| 1914 | sc = ulong 0 |
| 1915 | ok = ulong 0 |
| 1916 | bad = ulong 0 |
| 1917 | cw = ulong 0 |
| 1918 | for a ulong 8 |
| 1919 | if gt a 0 |
| 1920 | ok = add ok stc a 0 |
| 1921 | bad = add bad stc a 1 |
| 1922 | cw = add cw stc a 3 |
| 1923 | end |
| 1924 | end |
| 1925 | stsumw 12 add ok bad |
| 1926 | stsumw 13 ok |
| 1927 | stsumw 14 bad |
| 1928 | stsumw 15 cw |
| 1929 | stsumw 16 stc 4 17 |
| 1930 | stsumw 17 stc 4 18 |
| 1931 | for j ulong 4 |
| 1932 | stsumw add 18 j get STHD j |
| 1933 | end |
| 1934 | ic = ulong 0 |
| 1935 | for a ulong 8 |
| 1936 | ic = add ic stc a 5 |
| 1937 | end |
| 1938 | stsumw 22 ic |
| 1939 | for s ulong 13 |
| 1940 | stsumw add 24 mul s 3 get STPT s |
| 1941 | stsumw add 25 mul s 3 get STLO s |
| 1942 | stsumw add 26 mul s 3 get STHI s |
| 1943 | end |
| 1944 | for a ulong 8 |
| 1945 | stsumw add 64 a get STT a |
| 1946 | stsumw add 72 a get STAA a |
| 1947 | stsumw add 80 a stc a 11 |
| 1948 | stsumw add 96 a stc a 28 |
| 1949 | stsumw add 104 a stc a 27 |
| 1950 | end |
| 1951 | end |
| 1952 | |
| 1953 | fn streport to ulong |
| 1954 | stks SKHEAD |
| 1955 | stnl |
| 1956 | stks SKINPUT |
| 1957 | stou get STSPL 0 |
| 1958 | stkv SKGROUP get STNG 0 |
| 1959 | stkv SKSESN get STNS 0 |
| 1960 | stkv SKREQS get STNR 0 |
| 1961 | stkv SKQRYS get STNQ 0 |
| 1962 | stkv SKREPS 3 |
| 1963 | stnl |
| 1964 | stks SKBOOT |
| 1965 | stou 10000 |
| 1966 | stkv SKSEED get STSEED 0 |
| 1967 | stkv SKRKLO strank 25 10000 |
| 1968 | stkv SKRKHI strank 975 10000 |
| 1969 | stnl |
| 1970 | for a ulong 8 |
| 1971 | sttotline a |
| 1972 | end |
| 1973 | for s ulong 13 |
| 1974 | ststatline s |
| 1975 | end |
| 1976 | for a ulong 8 |
| 1977 | stcorrline a |
| 1978 | end |
| 1979 | for a ulong 8 |
| 1980 | strouteline a |
| 1981 | end |
| 1982 | stks SKCOVER |
| 1983 | stou stc 4 17 |
| 1984 | stkv SKCOVD stc 4 18 |
| 1985 | stkv SKCOVP stppm stc 4 18 stc 4 17 |
| 1986 | stnl |
| 1987 | for a ulong 8 |
| 1988 | stmemline a |
| 1989 | end |
| 1990 | stacqline 1 |
| 1991 | stacqline 2 |
| 1992 | for a ulong 8 |
| 1993 | put STSUM add 88 a 18446744073709551615 |
| 1994 | if gt a 1 |
| 1995 | stpayline a |
| 1996 | end |
| 1997 | end |
| 1998 | for a ulong 8 |
| 1999 | if gt a 1 |
| 2000 | stcbarline a |
| 2001 | end |
| 2002 | end |
| 2003 | for a ulong 8 |
| 2004 | if ne a 1 |
| 2005 | stecholine a |
| 2006 | end |
| 2007 | end |
| 2008 | for a ulong 8 |
| 2009 | for cat ulong 20 |
| 2010 | if gt cat 0 |
| 2011 | stcatline a cat |
| 2012 | end |
| 2013 | end |
| 2014 | end |
| 2015 | for t ulong 8 |
| 2016 | stregime add t 1 |
| 2017 | end |
| 2018 | stquants |
| 2019 | stks SKSTEP |
| 2020 | stnl |
| 2021 | for c ulong 14 |
| 2022 | stctlline add c 1 |
| 2023 | end |
| 2024 | stiss |
| 2025 | d = stdecide |
| 2026 | stks SKDECI |
| 2027 | if eq d 1 |
| 2028 | stks SKGO |
| 2029 | end |
| 2030 | if eq d 2 |
| 2031 | stks SKINV |
| 2032 | end |
| 2033 | if eq d 3 |
| 2034 | stks SKSTOP |
| 2035 | end |
| 2036 | stnl |
| 2037 | stks SKVERDS |
| 2038 | if eq d 1 |
| 2039 | stks SKGO |
| 2040 | end |
| 2041 | if eq d 2 |
| 2042 | stks SKINV |
| 2043 | end |
| 2044 | if eq d 3 |
| 2045 | stks SKSTOP |
| 2046 | end |
| 2047 | stks SKSIMNR |
| 2048 | stnl |
| 2049 | ret d |
| 2050 | end |
| 2051 | |
| 2052 | note one little-endian word appended to STOB |
| 2053 | fn stow v ulong to void |
| 2054 | for b ulong 8 |
| 2055 | stoc uchar and shr v mul b 8 255 |
| 2056 | end |
| 2057 | end |
| 2058 | |
| 2059 | note STSUM as 2048 bytes into STOB (replacing its contents) |
| 2060 | fn stsumbytes to void |
| 2061 | put STOP 0 0 |
| 2062 | for k ulong 256 |
| 2063 | stow get STSUM k |
| 2064 | end |
| 2065 | end |
| 2066 | |
| 2067 | note the path now in STPB becomes base slot b |
| 2068 | fn stbfromp b ulong to void |
| 2069 | o = mul b 4096 |
| 2070 | n = get STPL 0 |
| 2071 | for i ulong n |
| 2072 | put STBD add o i get STPB i |
| 2073 | end |
| 2074 | put STBL b n |
| 2075 | end |
| 2076 | |
| 2077 | note zero every accumulator, so one process can run several evaluations (tests) |
| 2078 | fn streset to void |
| 2079 | for i ulong len STCNT |
| 2080 | put STCNT i 0 |
| 2081 | end |
| 2082 | for i ulong len STAG |
| 2083 | put STAG i 0 |
| 2084 | put STA0 i 0 |
| 2085 | put STPR i 0 |
| 2086 | put STPE i 0 |
| 2087 | put STPF i 0 |
| 2088 | end |
| 2089 | for i ulong len STSS |
| 2090 | put STSS i 0 |
| 2091 | end |
| 2092 | for i ulong len STAQ |
| 2093 | put STAQ i 0 |
| 2094 | put STAQC i 0 |
| 2095 | put STAQX i 0 |
| 2096 | put STAQB i 0 |
| 2097 | put STAQF i 0 |
| 2098 | end |
| 2099 | for i ulong len STCT |
| 2100 | put STCT i 0 |
| 2101 | end |
| 2102 | for i ulong len STSUM |
| 2103 | put STSUM i 0 |
| 2104 | end |
| 2105 | put STDEC 0 0 |
| 2106 | put STDEC 1 0 |
| 2107 | put STOP 0 0 |
| 2108 | end |
| 2109 | |
| 2110 | note runs every reading step; 0 ok, else refusal code |
| 2111 | fn stread to int |
| 2112 | e = stidx |
| 2113 | if ne e 0 |
| 2114 | ret e |
| 2115 | end |
| 2116 | e = stsess |
| 2117 | if ne e 0 |
| 2118 | ret e |
| 2119 | end |
| 2120 | e = stexps |
| 2121 | if ne e 0 |
| 2122 | ret e |
| 2123 | end |
| 2124 | e = stlogs |
| 2125 | if ne e 0 |
| 2126 | ret e |
| 2127 | end |
| 2128 | e = stprocs |
| 2129 | if ne e 0 |
| 2130 | ret e |
| 2131 | end |
| 2132 | e = stacqs |
| 2133 | if ne e 0 |
| 2134 | ret e |
| 2135 | end |
| 2136 | ret stctls |
| 2137 | end |
| 2138 | |
| 2139 | note prints the refusal line to stdout; returns the exit code 2 |
| 2140 | fn stfail code ulong d ulong to int |
| 2141 | r = stref code d 0 0 |
| 2142 | stprref |
| 2143 | w = stflush 1 |
| 2144 | ret 2 |
| 2145 | end |
| 2146 | |
| 2147 | note the evaluation on base slots 0 split, 1 run, 2 ctrl (- = none), 3 out and the seed in |
| 2148 | note STSEED; the report goes to stdout unless STQT is 1. Returns the exit code. |
| 2149 | fn strun to int |
| 2150 | streset |
| 2151 | e = stread |
| 2152 | if ne e 0 |
| 2153 | stprref |
| 2154 | if ne get STQT 0 1 |
| 2155 | r = stflush 1 |
| 2156 | end |
| 2157 | ret 2 |
| 2158 | end |
| 2159 | sttotals |
| 2160 | stboot |
| 2161 | d = streport |
| 2162 | stfillsum d |
| 2163 | if ne get STQT 0 1 |
| 2164 | r = stflush 1 |
| 2165 | end |
| 2166 | stpbase 3 |
| 2167 | stpk SKTXT |
| 2168 | w = stwfile |
| 2169 | if ne w 0 |
| 2170 | ret 15 |
| 2171 | end |
| 2172 | stsumbytes |
| 2173 | stpbase 3 |
| 2174 | stpk SKSUM |
| 2175 | w = stwfile |
| 2176 | if ne w 0 |
| 2177 | ret 15 |
| 2178 | end |
| 2179 | ret 0 |
| 2180 | end |
| 2181 | |
| 2182 | fn stmain to int |
| 2183 | put STOP 0 0 |
| 2184 | if lt argcnt 7 |
| 2185 | ret stfail 1 0 |
| 2186 | end |
| 2187 | l0 = stargb 2 0 |
| 2188 | l1 = stargb 3 1 |
| 2189 | l2 = stargb 4 2 |
| 2190 | l3 = stargb 5 3 |
| 2191 | if ne l3 64 |
| 2192 | ret stfail 1 1 |
| 2193 | end |
| 2194 | put STRF 3 0 |
| 2195 | put STSEED 0 sthexw 3 0 |
| 2196 | if ne get STRF 3 0 |
| 2197 | ret stfail 1 2 |
| 2198 | end |
| 2199 | l4 = stargb 6 3 |
| 2200 | if or or eq l0 0 eq l1 0 or eq l2 0 eq l4 0 |
| 2201 | ret stfail 1 3 |
| 2202 | end |
| 2203 | ret strun |
| 2204 | end |