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 / tools / pi-drive-27b / omguard.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note tools/pi-drive-27b/omguard.om: Pure seeded Omega (OM-1) library unit. |
| 3 | note 1) Incremental OM-1 line/stream syntax and register guard (X925 cores). |
| 4 | note 2) Unified-RAM prefix-pool index with FNV-1a 64-bit chunk hashing and LRU eviction (A725 cores). |
| 5 | note Library unit: no fn main. Prefix: og / OG. |
| 6 | |
| 7 | const OGLINEMAX ulong 512 |
| 8 | const OGMAXPAR ulong 6 |
| 9 | const OGMAXLOC ulong 16 |
| 10 | const OGSLOTS ulong 64 |
| 11 | const OGCHUNKS ulong 16 |
| 12 | const OGPOOLH ulong 1024 |
| 13 | const OGPBUFMAX ulong 4096 |
| 14 | |
| 15 | const OGFNVOFF ulong 14695981039346656037 |
| 16 | const OGFNVPRM ulong 1099511628211 |
| 17 | |
| 18 | const OGOK long 0 |
| 19 | const OGEHEX long -1 |
| 20 | const OGEPAR long -2 |
| 21 | const OGELOC long -3 |
| 22 | const OGEBND long -4 |
| 23 | const OGEEND long -5 |
| 24 | const OGENFN long -6 |
| 25 | |
| 26 | note Stream guard state: |
| 27 | note ogst[0]=depth, ogst[1]=infn, ogst[2]=nlocs, ogst[3]=lines |
| 28 | global ogline uchar 512 |
| 29 | global ogst ulong 8 |
| 30 | global oglocs ulong 32 |
| 31 | |
| 32 | note Unified-RAM prefix-pool state: |
| 33 | note ogp_meta[0]=tick, ogp_meta[1]=best_slot, ogp_meta[2]=best_len, ogp_meta[3]=best_pa |
| 34 | global ogp_act ulong 64 |
| 35 | global ogp_nch ulong 64 |
| 36 | global ogp_hsh ulong 1024 |
| 37 | global ogp_pa ulong 64 |
| 38 | global ogp_lru ulong 64 |
| 39 | global ogp_q ulong 16 |
| 40 | global ogp_meta ulong 8 |
| 41 | global ogp_buf uchar 4096 |
| 42 | |
| 43 | note --- Part 1: Incremental OM-1 Line/Stream Guard --- |
| 44 | |
| 45 | fn oginit to void |
| 46 | i = ulong 0 |
| 47 | while lt i 8 bound 8 |
| 48 | put ogst i 0 |
| 49 | i = add i 1 |
| 50 | end |
| 51 | i = ulong 0 |
| 52 | while lt i 32 bound 32 |
| 53 | put oglocs i 0 |
| 54 | i = add i 1 |
| 55 | end |
| 56 | end |
| 57 | |
| 58 | fn ogdepth to ulong |
| 59 | ret get ogst 0 |
| 60 | end |
| 61 | |
| 62 | fn oginfn to ulong |
| 63 | ret get ogst 1 |
| 64 | end |
| 65 | |
| 66 | fn ognlocs to ulong |
| 67 | ret get ogst 2 |
| 68 | end |
| 69 | |
| 70 | fn ogisws c uchar to ulong |
| 71 | if eq c 32 |
| 72 | ret 1 |
| 73 | end |
| 74 | if eq c 9 |
| 75 | ret 1 |
| 76 | end |
| 77 | if eq c 13 |
| 78 | ret 1 |
| 79 | end |
| 80 | if eq c 10 |
| 81 | ret 1 |
| 82 | end |
| 83 | ret 0 |
| 84 | end |
| 85 | |
| 86 | fn ogskipws pos ulong n ulong to ulong |
| 87 | p = pos |
| 88 | while lt p n bound 512 |
| 89 | c = get ogline p |
| 90 | if eq ogisws c 0 |
| 91 | break |
| 92 | end |
| 93 | p = add p 1 |
| 94 | end |
| 95 | ret p |
| 96 | end |
| 97 | |
| 98 | fn ogtokend pos ulong n ulong to ulong |
| 99 | p = pos |
| 100 | while lt p n bound 512 |
| 101 | c = get ogline p |
| 102 | if ne ogisws c 0 |
| 103 | break |
| 104 | end |
| 105 | p = add p 1 |
| 106 | end |
| 107 | ret p |
| 108 | end |
| 109 | |
| 110 | fn ogtrim n ulong to ulong |
| 111 | m = n |
| 112 | if gt m OGLINEMAX |
| 113 | m = OGLINEMAX |
| 114 | end |
| 115 | while gt m 0 bound 512 |
| 116 | c = get ogline sub m 1 |
| 117 | if eq c 10 |
| 118 | m = sub m 1 |
| 119 | else |
| 120 | if eq c 13 |
| 121 | m = sub m 1 |
| 122 | else |
| 123 | break |
| 124 | end |
| 125 | end |
| 126 | end |
| 127 | ret m |
| 128 | end |
| 129 | |
| 130 | fn ogisnote s ulong e ulong to ulong |
| 131 | if ne sub e s 4 |
| 132 | ret 0 |
| 133 | end |
| 134 | if ne get ogline s 110 |
| 135 | ret 0 |
| 136 | end |
| 137 | if ne get ogline add s 1 111 |
| 138 | ret 0 |
| 139 | end |
| 140 | if ne get ogline add s 2 116 |
| 141 | ret 0 |
| 142 | end |
| 143 | if ne get ogline add s 3 101 |
| 144 | ret 0 |
| 145 | end |
| 146 | ret 1 |
| 147 | end |
| 148 | |
| 149 | fn ogisfn s ulong e ulong to ulong |
| 150 | if ne sub e s 2 |
| 151 | ret 0 |
| 152 | end |
| 153 | if ne get ogline s 102 |
| 154 | ret 0 |
| 155 | end |
| 156 | if ne get ogline add s 1 110 |
| 157 | ret 0 |
| 158 | end |
| 159 | ret 1 |
| 160 | end |
| 161 | |
| 162 | fn ogisend s ulong e ulong to ulong |
| 163 | if ne sub e s 3 |
| 164 | ret 0 |
| 165 | end |
| 166 | if ne get ogline s 101 |
| 167 | ret 0 |
| 168 | end |
| 169 | if ne get ogline add s 1 110 |
| 170 | ret 0 |
| 171 | end |
| 172 | if ne get ogline add s 2 100 |
| 173 | ret 0 |
| 174 | end |
| 175 | ret 1 |
| 176 | end |
| 177 | |
| 178 | fn ogisif s ulong e ulong to ulong |
| 179 | if ne sub e s 2 |
| 180 | ret 0 |
| 181 | end |
| 182 | if ne get ogline s 105 |
| 183 | ret 0 |
| 184 | end |
| 185 | if ne get ogline add s 1 102 |
| 186 | ret 0 |
| 187 | end |
| 188 | ret 1 |
| 189 | end |
| 190 | |
| 191 | fn ogisfor s ulong e ulong to ulong |
| 192 | if ne sub e s 3 |
| 193 | ret 0 |
| 194 | end |
| 195 | if ne get ogline s 102 |
| 196 | ret 0 |
| 197 | end |
| 198 | if ne get ogline add s 1 111 |
| 199 | ret 0 |
| 200 | end |
| 201 | if ne get ogline add s 2 114 |
| 202 | ret 0 |
| 203 | end |
| 204 | ret 1 |
| 205 | end |
| 206 | |
| 207 | fn ogiswhile s ulong e ulong to ulong |
| 208 | if ne sub e s 5 |
| 209 | ret 0 |
| 210 | end |
| 211 | if ne get ogline s 119 |
| 212 | ret 0 |
| 213 | end |
| 214 | if ne get ogline add s 1 104 |
| 215 | ret 0 |
| 216 | end |
| 217 | if ne get ogline add s 2 105 |
| 218 | ret 0 |
| 219 | end |
| 220 | if ne get ogline add s 3 108 |
| 221 | ret 0 |
| 222 | end |
| 223 | if ne get ogline add s 4 101 |
| 224 | ret 0 |
| 225 | end |
| 226 | ret 1 |
| 227 | end |
| 228 | |
| 229 | fn ogisbound s ulong e ulong to ulong |
| 230 | if ne sub e s 5 |
| 231 | ret 0 |
| 232 | end |
| 233 | if ne get ogline s 98 |
| 234 | ret 0 |
| 235 | end |
| 236 | if ne get ogline add s 1 111 |
| 237 | ret 0 |
| 238 | end |
| 239 | if ne get ogline add s 2 117 |
| 240 | ret 0 |
| 241 | end |
| 242 | if ne get ogline add s 3 110 |
| 243 | ret 0 |
| 244 | end |
| 245 | if ne get ogline add s 4 100 |
| 246 | ret 0 |
| 247 | end |
| 248 | ret 1 |
| 249 | end |
| 250 | |
| 251 | fn ogisto s ulong e ulong to ulong |
| 252 | if ne sub e s 2 |
| 253 | ret 0 |
| 254 | end |
| 255 | if ne get ogline s 116 |
| 256 | ret 0 |
| 257 | end |
| 258 | if ne get ogline add s 1 111 |
| 259 | ret 0 |
| 260 | end |
| 261 | ret 1 |
| 262 | end |
| 263 | |
| 264 | fn ogisview s ulong e ulong to ulong |
| 265 | if ne sub e s 4 |
| 266 | ret 0 |
| 267 | end |
| 268 | if ne get ogline s 118 |
| 269 | ret 0 |
| 270 | end |
| 271 | if ne get ogline add s 1 105 |
| 272 | ret 0 |
| 273 | end |
| 274 | if ne get ogline add s 2 101 |
| 275 | ret 0 |
| 276 | end |
| 277 | if ne get ogline add s 3 119 |
| 278 | ret 0 |
| 279 | end |
| 280 | ret 1 |
| 281 | end |
| 282 | |
| 283 | fn ogisedit s ulong e ulong to ulong |
| 284 | if ne sub e s 4 |
| 285 | ret 0 |
| 286 | end |
| 287 | if ne get ogline s 101 |
| 288 | ret 0 |
| 289 | end |
| 290 | if ne get ogline add s 1 100 |
| 291 | ret 0 |
| 292 | end |
| 293 | if ne get ogline add s 2 105 |
| 294 | ret 0 |
| 295 | end |
| 296 | if ne get ogline add s 3 116 |
| 297 | ret 0 |
| 298 | end |
| 299 | ret 1 |
| 300 | end |
| 301 | |
| 302 | fn ogiseq s ulong e ulong to ulong |
| 303 | if ne sub e s 1 |
| 304 | ret 0 |
| 305 | end |
| 306 | if ne get ogline s 61 |
| 307 | ret 0 |
| 308 | end |
| 309 | ret 1 |
| 310 | end |
| 311 | |
| 312 | fn ogisnumstar s ulong e ulong to ulong |
| 313 | if le e s |
| 314 | ret 0 |
| 315 | end |
| 316 | c = get ogline s |
| 317 | if eq c 42 |
| 318 | ret 1 |
| 319 | end |
| 320 | if ge c 48 |
| 321 | if le c 57 |
| 322 | ret 1 |
| 323 | end |
| 324 | end |
| 325 | ret 0 |
| 326 | end |
| 327 | |
| 328 | fn ogtokhash s ulong e ulong to ulong |
| 329 | h = OGFNVOFF |
| 330 | p = s |
| 331 | while lt p e bound 512 |
| 332 | b = ulong get ogline p |
| 333 | h = xor h b |
| 334 | h = mul h OGFNVPRM |
| 335 | p = add p 1 |
| 336 | end |
| 337 | ret h |
| 338 | end |
| 339 | |
| 340 | fn ogaddloc s ulong e ulong to long |
| 341 | h = ogtokhash s e |
| 342 | cnt = get ogst 2 |
| 343 | i = ulong 0 |
| 344 | while lt i cnt bound 32 |
| 345 | if eq get oglocs i h |
| 346 | ret OGOK |
| 347 | end |
| 348 | i = add i 1 |
| 349 | end |
| 350 | if ge cnt OGMAXLOC |
| 351 | ret OGELOC |
| 352 | end |
| 353 | put oglocs cnt h |
| 354 | put ogst 2 add cnt 1 |
| 355 | ret OGOK |
| 356 | end |
| 357 | |
| 358 | fn ogishexsep c uchar to ulong |
| 359 | if ne ogisws c 0 |
| 360 | ret 1 |
| 361 | end |
| 362 | if eq c 40 |
| 363 | ret 1 |
| 364 | end |
| 365 | if eq c 45 |
| 366 | ret 1 |
| 367 | end |
| 368 | ret 0 |
| 369 | end |
| 370 | |
| 371 | note Scan line outside double-quoted strings for 0x or 0X hex prefix. |
| 372 | fn ogscanhex pos ulong n ulong to long |
| 373 | i = pos |
| 374 | instr = ulong 0 |
| 375 | esc = ulong 0 |
| 376 | while lt i n bound 512 |
| 377 | c = get ogline i |
| 378 | if ne instr 0 |
| 379 | if ne esc 0 |
| 380 | esc = 0 |
| 381 | else |
| 382 | if eq c 92 |
| 383 | esc = 1 |
| 384 | else |
| 385 | if eq c 34 |
| 386 | instr = 0 |
| 387 | end |
| 388 | end |
| 389 | end |
| 390 | else |
| 391 | if eq c 34 |
| 392 | instr = 1 |
| 393 | else |
| 394 | if eq c 48 |
| 395 | if lt add i 1 n |
| 396 | nxt = get ogline add i 1 |
| 397 | isx = ulong 0 |
| 398 | if eq nxt 120 |
| 399 | isx = 1 |
| 400 | end |
| 401 | if eq nxt 88 |
| 402 | isx = 1 |
| 403 | end |
| 404 | if ne isx 0 |
| 405 | okprev = ulong 0 |
| 406 | if eq i pos |
| 407 | okprev = 1 |
| 408 | else |
| 409 | prev = get ogline sub i 1 |
| 410 | okprev = ogishexsep prev |
| 411 | end |
| 412 | if ne okprev 0 |
| 413 | ret OGEHEX |
| 414 | end |
| 415 | end |
| 416 | end |
| 417 | end |
| 418 | end |
| 419 | end |
| 420 | i = add i 1 |
| 421 | end |
| 422 | ret OGOK |
| 423 | end |
| 424 | |
| 425 | fn ogparsefn pos ulong n ulong to long |
| 426 | if ne get ogst 1 0 |
| 427 | ret OGENFN |
| 428 | end |
| 429 | note Skip function name token. |
| 430 | p = ogskipws pos n |
| 431 | p = ogtokend p n |
| 432 | put ogst 2 0 |
| 433 | np = ulong 0 |
| 434 | while lt p n bound 512 |
| 435 | s = ogskipws p n |
| 436 | if ge s n |
| 437 | break |
| 438 | end |
| 439 | e = ogtokend s n |
| 440 | if ne ogisto s e 0 |
| 441 | break |
| 442 | end |
| 443 | np = add np 1 |
| 444 | if gt np OGMAXPAR |
| 445 | put ogst 2 0 |
| 446 | ret OGEPAR |
| 447 | end |
| 448 | lr = ogaddloc s e |
| 449 | if lt lr 0 |
| 450 | put ogst 2 0 |
| 451 | ret lr |
| 452 | end |
| 453 | note Skip parameter type token (and array type/len if view/edit). |
| 454 | ts = ogskipws e n |
| 455 | te = ogtokend ts n |
| 456 | p = te |
| 457 | isarr = ulong 0 |
| 458 | if ne ogisview ts te 0 |
| 459 | isarr = 1 |
| 460 | end |
| 461 | if ne ogisedit ts te 0 |
| 462 | isarr = 1 |
| 463 | end |
| 464 | if ne isarr 0 |
| 465 | es = ogskipws te n |
| 466 | ee = ogtokend es n |
| 467 | p = ee |
| 468 | ls = ogskipws ee n |
| 469 | le2 = ogtokend ls n |
| 470 | if ne ogisnumstar ls le2 0 |
| 471 | p = le2 |
| 472 | end |
| 473 | end |
| 474 | end |
| 475 | put ogst 1 1 |
| 476 | put ogst 0 add get ogst 0 1 |
| 477 | ret OGOK |
| 478 | end |
| 479 | |
| 480 | fn ogparsewhile pos ulong n ulong to long |
| 481 | p = pos |
| 482 | found = ulong 0 |
| 483 | while lt p n bound 512 |
| 484 | s = ogskipws p n |
| 485 | if ge s n |
| 486 | break |
| 487 | end |
| 488 | e = ogtokend s n |
| 489 | if ne ogisbound s e 0 |
| 490 | ns = ogskipws e n |
| 491 | if lt ns n |
| 492 | found = 1 |
| 493 | break |
| 494 | end |
| 495 | end |
| 496 | p = e |
| 497 | end |
| 498 | if eq found 0 |
| 499 | ret OGEBND |
| 500 | end |
| 501 | put ogst 0 add get ogst 0 1 |
| 502 | ret OGOK |
| 503 | end |
| 504 | |
| 505 | fn ogcheckline n ulong to long |
| 506 | m = ogtrim n |
| 507 | put ogst 3 add get ogst 3 1 |
| 508 | s0 = ogskipws 0 m |
| 509 | if ge s0 m |
| 510 | ret OGOK |
| 511 | end |
| 512 | e0 = ogtokend s0 m |
| 513 | if ne ogisnote s0 e0 0 |
| 514 | ret OGOK |
| 515 | end |
| 516 | hr = ogscanhex s0 m |
| 517 | if lt hr 0 |
| 518 | ret hr |
| 519 | end |
| 520 | if ne ogisfn s0 e0 0 |
| 521 | ret ogparsefn e0 m |
| 522 | end |
| 523 | if ne ogisend s0 e0 0 |
| 524 | d = get ogst 0 |
| 525 | if eq d 0 |
| 526 | ret OGEEND |
| 527 | end |
| 528 | nd = sub d 1 |
| 529 | put ogst 0 nd |
| 530 | if eq nd 0 |
| 531 | put ogst 1 0 |
| 532 | put ogst 2 0 |
| 533 | end |
| 534 | ret OGOK |
| 535 | end |
| 536 | if ne ogisif s0 e0 0 |
| 537 | put ogst 0 add get ogst 0 1 |
| 538 | ret OGOK |
| 539 | end |
| 540 | if ne ogisfor s0 e0 0 |
| 541 | put ogst 0 add get ogst 0 1 |
| 542 | if ne get ogst 1 0 |
| 543 | vs = ogskipws e0 m |
| 544 | if lt vs m |
| 545 | ve = ogtokend vs m |
| 546 | ret ogaddloc vs ve |
| 547 | end |
| 548 | end |
| 549 | ret OGOK |
| 550 | end |
| 551 | if ne ogiswhile s0 e0 0 |
| 552 | ret ogparsewhile e0 m |
| 553 | end |
| 554 | if ne get ogst 1 0 |
| 555 | s1 = ogskipws e0 m |
| 556 | if lt s1 m |
| 557 | e1 = ogtokend s1 m |
| 558 | if ne ogiseq s1 e1 0 |
| 559 | ret ogaddloc s0 e0 |
| 560 | end |
| 561 | end |
| 562 | end |
| 563 | ret OGOK |
| 564 | end |
| 565 | |
| 566 | note --- Part 2: Unified-RAM Prefix-Pool Index --- |
| 567 | |
| 568 | fn ogpinit to void |
| 569 | i = ulong 0 |
| 570 | while lt i OGSLOTS bound 64 |
| 571 | put ogp_act i 0 |
| 572 | put ogp_nch i 0 |
| 573 | put ogp_pa i 0 |
| 574 | put ogp_lru i 0 |
| 575 | i = add i 1 |
| 576 | end |
| 577 | i = ulong 0 |
| 578 | while lt i OGPOOLH bound 1024 |
| 579 | put ogp_hsh i 0 |
| 580 | i = add i 1 |
| 581 | end |
| 582 | i = ulong 0 |
| 583 | while lt i OGCHUNKS bound 16 |
| 584 | put ogp_q i 0 |
| 585 | i = add i 1 |
| 586 | end |
| 587 | i = ulong 0 |
| 588 | while lt i 8 bound 8 |
| 589 | put ogp_meta i 0 |
| 590 | i = add i 1 |
| 591 | end |
| 592 | end |
| 593 | |
| 594 | note FNV-1a 64-bit hash over byte chunk ogp_buf[off .. off+n). |
| 595 | fn ogphash off ulong n ulong to ulong |
| 596 | if ge off OGPBUFMAX |
| 597 | ret OGFNVOFF |
| 598 | end |
| 599 | lim = sub OGPBUFMAX off |
| 600 | cnt = n |
| 601 | if gt cnt lim |
| 602 | cnt = lim |
| 603 | end |
| 604 | h = OGFNVOFF |
| 605 | i = ulong 0 |
| 606 | while lt i cnt bound 4096 |
| 607 | b = ulong get ogp_buf add off i |
| 608 | h = xor h b |
| 609 | h = mul h OGFNVPRM |
| 610 | i = add i 1 |
| 611 | end |
| 612 | ret h |
| 613 | end |
| 614 | |
| 615 | note Feed a 64-bit token ID (8 bytes LE) into FNV-1a 64-bit state. |
| 616 | fn ogphash_tok tok ulong prev ulong to ulong |
| 617 | h = prev |
| 618 | v = tok |
| 619 | i = ulong 0 |
| 620 | while lt i 8 bound 8 |
| 621 | b = and v 255 |
| 622 | h = xor h b |
| 623 | h = mul h OGFNVPRM |
| 624 | v = shr v 8 |
| 625 | i = add i 1 |
| 626 | end |
| 627 | ret h |
| 628 | end |
| 629 | |
| 630 | fn ogpput slot ulong nchunks ulong pa ulong to long |
| 631 | if ge slot OGSLOTS |
| 632 | ret -1 |
| 633 | end |
| 634 | if gt nchunks OGCHUNKS |
| 635 | ret -1 |
| 636 | end |
| 637 | tick = add get ogp_meta 0 1 |
| 638 | put ogp_meta 0 tick |
| 639 | put ogp_act slot 1 |
| 640 | put ogp_nch slot nchunks |
| 641 | put ogp_pa slot pa |
| 642 | put ogp_lru slot tick |
| 643 | base = mul slot OGCHUNKS |
| 644 | i = ulong 0 |
| 645 | while lt i nchunks bound 16 |
| 646 | put ogp_hsh add base i get ogp_q i |
| 647 | i = add i 1 |
| 648 | end |
| 649 | ret 0 |
| 650 | end |
| 651 | |
| 652 | fn ogslotmatch slot ulong nchunks ulong to ulong |
| 653 | sn = get ogp_nch slot |
| 654 | lim = nchunks |
| 655 | if lt sn lim |
| 656 | lim = sn |
| 657 | end |
| 658 | base = mul slot OGCHUNKS |
| 659 | m = ulong 0 |
| 660 | while lt m lim bound 16 |
| 661 | if ne get ogp_hsh add base m get ogp_q m |
| 662 | break |
| 663 | end |
| 664 | m = add m 1 |
| 665 | end |
| 666 | ret m |
| 667 | end |
| 668 | |
| 669 | fn ogpmatch nchunks ulong to long |
| 670 | qlen = nchunks |
| 671 | if gt qlen OGCHUNKS |
| 672 | qlen = OGCHUNKS |
| 673 | end |
| 674 | bslot = OGSLOTS |
| 675 | blen = ulong 0 |
| 676 | blru = ulong 0 |
| 677 | s = ulong 0 |
| 678 | while lt s OGSLOTS bound 64 |
| 679 | if ne get ogp_act s 0 |
| 680 | m = ogslotmatch s qlen |
| 681 | take = ulong 0 |
| 682 | if gt m blen |
| 683 | take = 1 |
| 684 | end |
| 685 | if eq m blen |
| 686 | if gt m 0 |
| 687 | if gt get ogp_lru s blru |
| 688 | take = 1 |
| 689 | end |
| 690 | end |
| 691 | end |
| 692 | if ne take 0 |
| 693 | blen = m |
| 694 | bslot = s |
| 695 | blru = get ogp_lru s |
| 696 | end |
| 697 | end |
| 698 | s = add s 1 |
| 699 | end |
| 700 | if eq blen 0 |
| 701 | put ogp_meta 1 OGSLOTS |
| 702 | put ogp_meta 2 0 |
| 703 | put ogp_meta 3 0 |
| 704 | ret -1 |
| 705 | end |
| 706 | tick = add get ogp_meta 0 1 |
| 707 | put ogp_meta 0 tick |
| 708 | put ogp_lru bslot tick |
| 709 | put ogp_meta 1 bslot |
| 710 | put ogp_meta 2 blen |
| 711 | put ogp_meta 3 get ogp_pa bslot |
| 712 | ret long bslot |
| 713 | end |
| 714 | |
| 715 | fn ogpmatch_len to ulong |
| 716 | ret get ogp_meta 2 |
| 717 | end |
| 718 | |
| 719 | fn ogpmatch_pa to ulong |
| 720 | ret get ogp_meta 3 |
| 721 | end |
| 722 | |
| 723 | fn ogpevict to long |
| 724 | found = ulong 0 |
| 725 | vslot = ulong 0 |
| 726 | vlru = ulong 0 |
| 727 | s = ulong 0 |
| 728 | while lt s OGSLOTS bound 64 |
| 729 | if ne get ogp_act s 0 |
| 730 | tlru = get ogp_lru s |
| 731 | if eq found 0 |
| 732 | found = 1 |
| 733 | vslot = s |
| 734 | vlru = tlru |
| 735 | else |
| 736 | if lt tlru vlru |
| 737 | vslot = s |
| 738 | vlru = tlru |
| 739 | end |
| 740 | end |
| 741 | end |
| 742 | s = add s 1 |
| 743 | end |
| 744 | if eq found 0 |
| 745 | ret -1 |
| 746 | end |
| 747 | put ogp_act vslot 0 |
| 748 | put ogp_nch vslot 0 |
| 749 | put ogp_pa vslot 0 |
| 750 | put ogp_lru vslot 0 |
| 751 | ret long vslot |
| 752 | end |