diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d56a26..8c38956 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,8 @@ +# Mirror CI only; canonical source and publication authority remain on Radicle. # CI: build and test with the committed Cargo.lock (--locked refuses any silent dependency # drift) on a GitHub-hosted runner, with pinned actions and read-only token permissions. -# A second job writes an SPDX SBOM of the tree so auditors can diff what a commit contains. +# The style job reports em or en dashes as warnings only (advisory, DRA-99). +# A further job writes an SPDX SBOM of the tree so auditors can diff what a commit contains. name: CI on: pull_request: @@ -10,6 +12,7 @@ permissions: contents: read jobs: test: + name: Historical Rust tests runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -23,6 +26,61 @@ jobs: run: cargo build --locked --all-targets - name: Test run: cargo test --locked + style: + # Advisory (DRA-99): the style rule (no em or en dashes in the rendered site or style.css) + # never fails this workflow and never holds a merge. A finding becomes a ::warning:: + # annotation. Every substantive rule stays in `site-builder verify` and the test job. + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable + - name: Style check (advisory) + run: | + rc=0 + cargo test --locked -p site-builder -- --ignored --exact tests::style_rendered_routes_have_no_dashes > style.log 2>&1 || rc=$? + cat style.log + if ! grep -q '^test tests::style_rendered_routes_have_no_dashes \.\.\. ' style.log; then + echo "::warning title=Style (advisory, DRA-99)::style check did not run (exit $rc): the test is missing or the build failed; see this step's log" + elif [ "$rc" -ne 0 ]; then + n=$(grep -c '^STYLE ' style.log || true) + echo "::warning title=Style (advisory, DRA-99)::style check exit $rc, $n finding(s) (STYLE lines above); advisory only, CI is not failed" + fi + native: + name: Pinned Omega build and tests + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Install host-only emulator + run: sudo apt-get update && sudo apt-get install -y qemu-user-static + - name: Replay pinned seed and compiler fixed points + shell: bash + run: | + set -euo pipefail + QEMU=/usr/bin/qemu-aarch64-static sh scripts/build-seed.sh target/toolchain + - name: Native and emulated checks + shell: bash + env: + OMC: ${{ github.workspace }}/target/toolchain/omc-x86 + run: | + set -euo pipefail + sh scripts/build-native.sh target/site-omega x86_64 + python3 native/tests/check.py target/site-omega + target/site-omega build target/release-a + target/site-omega verify target/release-a + target/site-omega build target/release-b + diff --recursive --no-dereference target/release-a target/release-b + sh scripts/build-native.sh target/site-omega-aarch64 aarch64 + python3 native/tests/check.py target/site-omega-aarch64 --runner /usr/bin/qemu-aarch64-static + qemu-aarch64-static target/site-omega-aarch64 build target/release-aarch64 + diff --recursive --no-dereference target/release-a target/release-aarch64 + sh scripts/tests/check-sync.sh + git diff --exit-code -- native/evidence evidence sbom: runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/.gitignore b/.gitignore index 5cc7694..9b94bf8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ /target /dist /facts.json + +/.openai/ +/.openai-preview-note.txt +/.superpowers/ diff --git a/AGENTS.md b/AGENTS.md index 00896dd..3815b8b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,68 +1,132 @@ -# interplane.io (source of the INTERPLANE website) +# interplane.io -> The static website for INTERPLANE, the open interoperability protocol between AI models and agent runtimes. The page is not written by hand: one Rust program, `crates/site-builder`, reads the protocol repository's public record on GitHub (aien-dev/interplane-mv), writes those facts to `facts.json`, renders `dist/index.html` from Maud templates plus that file, and refuses a build that breaks the page's rules. +The static INTERPLANE website welcomes unfinished software and documents a +source-backed salvage workflow. `native/site.om` assembles reviewed repository +content and verifies its bounded static-site policy. The existing protocol +routes remain available. The existing Forge app remains responsible for its +non-static routes; there is no newly deployed automated repair service. -Shared rules: read https://www.aienos.com/agents/RULES.md first. This file adds what is specific to this repository; where the two differ, this file wins here. +Shared rules: read https://www.aienos.com/agents/RULES.md first. This file adds +repository-specific rules; where the two differ, this file wins here. -## Scope - -- Applies to the whole repository. -- `crates/site-builder/src/`: the generator. `facts.rs` reads the protocol repository, `page.rs` holds the editorial copy and the markup, `main.rs` has the `facts`, `build` and `verify` commands and the tests. -- `public/`: `style.css` (the one stylesheet) and `hero.webp`, copied into the output. -- `scripts/sync-to-hub.sh`: the hourly deploy job. -- `dist/` and `facts.json` are generated and ignored by git. Never edit or commit them. -- The protocol itself, its numbers and its status live in aien-dev/interplane-mv. Change them there, not here. +## Canonical source -## Installation +The authoritative repository is Radicle `rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV`. +Its public source view is https://www.aienos.com/forge/drakestapleton/interplane.io. +Clone with: -```bash -git clone https://github.com/aien-dev/interplane.io.git -cd interplane.io -cargo build --release -p site-builder +```sh +git clone https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git interplane.io ``` -You need a stable Rust toolchain; the crate depends on `maud`, `serde` and `serde_json`. The `facts` step also needs the GitHub CLI `gh`, logged in, with network access to GitHub. There is no Node build and no package manager besides Cargo. - -## Configuration - -- `facts.json` (generated) holds every figure the page shows; `build` reads it from the path you give (default `facts.json`). -- The protocol repository slug and the Spark status context are constants at the top of `crates/site-builder/src/facts.rs` (`PROTOCOL_REPO`, `SPARK_STATUS_CONTEXT`). -- `scripts/sync-to-hub.sh` reads `REPO`, `HUB`, `WEBDIR` and `LOGDIR` from the environment; its header documents each one. - -## Usage +This rebuild is based on canonical commit +`b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858`. A GitHub mirror or mirror CI result is +not the canonical repository state. Do not silently repoint an installed clone's +remotes; the operator controls that handover. The protocol repository is +`rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa`. -```bash -# Tests: render a sample page and run the verify rules against it -cargo test -p site-builder - -# Refresh the facts from GitHub (needs gh logged in and network) -target/release/site-builder facts # writes facts.json +## Scope -# Render and check the page -target/release/site-builder build dist # dist/index.html, public/, facts.json -target/release/site-builder verify dist +- `native/site.om`: all executable product assembly and verification logic. +- `content/`: reviewed HTML pages and pinned public source observations. +- `public/` and `downloads/`: declarative assets and contribution resources. +- `native/tests/check.py`: independent fixture and negative-control oracle only. +- `scripts/build-native.sh`: pinned compiler selection and host orchestration. +- `native/toolchain/`: unchanged public upstream seed text, license and notice. +- `scripts/build-seed.sh`: checked seed replay, with no compiler download. +- `scripts/sync-to-hub.sh`: existing hourly Spark-to-Pi publication job. +- `scripts/tests/check-sync.sh`: local-stub tests, with no external publication. +- `crates/site-builder/`: historical Rust builder, retained with its tests. It is + not the release path for the salvage website. +- `evidence/`, `native/evidence/` and `proofs/`: scoped evidence and reproduction + instructions. Do not overwrite measured receipts during ordinary CI runs. +- `target/`, `dist/` and root `facts.json` are generated and ignored. Never commit + them. `content/facts.json` is reviewed source and is tracked. + +The root `.crumb` predates this redesign. Source attribution now follows this +file and the accepted design in +`docs/superpowers/specs/2026-11-09-salvage-design.md`. Preserve the canonical +`/forge/` static route and all existing protocol routes. The salvage catalog uses +`/yard/`: `/explore` belongs to the existing Forge app and must not be shadowed by +a new static catalog. The existing nginx behavior serves static files first and +passes other paths to Forge. Use absolute HTTPS links to those dynamic routes. + +## Installation and verification + +Use the exact compiler pinned in `evidence/toolchain/bootstrap-receipt.json`. +On x86 Linux, set `OMC` to its reproduced native x86 executable. On AArch64 Linux, +`scripts/build-native.sh` defaults to `$OMEGA_SRC/seed/out/omc`, with `OMEGA_SRC` +defaulting to `$HOME/workspace/omega-mv`. An explicit `OMC` overrides the default. +Every path is verified against the pinned SHA-256 before execution. There is no +implicit compiler download or fallback to another compiler. See +`docs/RELEASE.md` for provisioning and emulated execution. + +From the repository root: + +```sh +set -eu +sh scripts/build-native.sh target/site-omega +python3 native/tests/check.py target/site-omega +sh scripts/tests/check-sync.sh +target/site-omega build target/review-a +target/site-omega verify target/review-a +target/site-omega build target/review-b +diff --recursive --no-dereference target/review-a target/review-b +cargo test --locked ``` -`scripts/sync-to-hub.sh` is the production deploy. It runs from cron on the DGX Spark, rebuilds from a clean clone of `main`, keeps the last good facts if GitHub is unreachable, refuses a page that fails `verify`, and copies the result over SSH to the nginx server on the project's Raspberry Pi. Do not run it yourself; it needs that host and its SSH access. +Build output directories must not already exist. Use fresh directory names for +another run. The native build reads tracked local content; it does not refresh +facts from Radicle or silently reuse historical facts. Python is only a test +oracle. Rust is only historical coverage. Neither produces the current release. ## Conventions -- Every figure on the page comes from the protocol repository and names the commit it was read at. Leave out anything that repository does not record; never type a number into `page.rs`. -- Static HTML and CSS only: no scripts, no outside fonts, no trackers, no plain `http://` links. The only requests a visitor's browser makes are to interplane.io. -- No em dashes or en dashes in the page or the stylesheet. -- The Spark verdict is shown exactly as read (PASS, FAIL, BLOCKED, RUNNING or NO VERDICT), never summarised. -- No mention of the removed Python SDK, no "draft" footer, and no outside projects named as users or partners. -- `site-builder verify` enforces these rules. When you add a rule, add the check to `verify` and keep `cargo test -p site-builder` passing. - -## Safety and approvals - -- The site is served from the project's Raspberry Pi, not GitHub Pages. Do not add a Pages workflow or a `CNAME` file. -- Ask before changing the deploy script, the hosting, or a claim the page makes about the protocol. -- Never commit `facts.json`, `dist/`, `.crumb.local`, tokens or SSH material. `facts` uses the `gh` login and never writes a token. -- Work on a branch and merge through a pull request; `main` is what the hourly job publishes. +- First-party executable product changes belong in `.om`. Shell is limited to + host orchestration, and independent test/proof tools remain explicitly scoped. +- Every public factual claim must identify its source, revision and evidence + scope. Never present inspection as execution or emulation as hardware testing. +- Static HTML and CSS only: no browser scripts, external fonts, trackers, plain + HTTP navigation, remote resource loads, or invented users and endorsements. +- Avoid em dashes and en dashes in authored copy. The canonical DRA-99 style rule + remains advisory; preserve the existing non-blocking mirror CI style job. +- Keep missing evidence visible. No fake intake confirmation, invented repair + result, fabricated badge, or placeholder destination presented as working. +- Update the native verifier and independent negative controls when changing a + policy rule. A passing bounded checker is not a sanitizer or a security proof. +- Test actual page navigation and mobile/desktop layout before release. Preserve + honest protocol links and routes while changing the site's presentation. +- Preserve `/forge/` provenance and neutral or first-person copy. It must not + imply GitHub feature parity or carry `github.com/aien-dev` links. Do not invent + a current repository count or live feature verdict; tie such observations to + the registry revision or dated source that actually records them. + +## Publication boundary + +- The site remains served from the project's Raspberry Pi. Do not add GitHub + Pages, a `CNAME`, DNS changes or another hosting system. +- Canonical `main` is automatically published by the existing hourly Spark job. + Stay on a review branch and prepare a Radicle patch for the canonical + maintainer process. A GitHub PR is a secondary mirror review, not publication. + Do not merge or run the deploy script unless the user authorizes publication. +- `REPO`, `HUB`, `WEBDIR` and `LOGDIR` remain supported deploy configuration. + Preserve quietlock, a clean checkout, fast-forward-only main updates, native + build/verify failures, and `.well-known` preservation at the destination. +- Ask before future changes to hosting, the deploy script, or a source-backed + public claim unless that change is already in the user's authorized scope. + The accepted salvage rebuild includes the native publication integration. +- Never commit `.crumb.local`, tokens, credentials, SSH material or host-specific + private configuration. Never send messages or publish on the user's behalf + without explicit authorization. +- The authoritative Radicle RID is known above. Publishing a signed patch still + requires the operator's authorized signer. Do not create signing keys or + describe an unavailable signed push as complete. ## Further reading -- `README.md`: the page's rules, the build steps and the hosting. -- https://interplane.io: the live site. -- https://github.com/aien-dev/interplane-mv: the protocol repository the page reads. +- `README.md`: project overview and available routes. +- `native/README.md`: native checker contract and limitations. +- `docs/RELEASE.md`: review, reproduction and operator-controlled handover. +- `evidence/toolchain/REPRODUCE.md`: pinned compiler bootstrap reproduction. +- https://radicle.network/nodes/rosa.radicle.network/rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa: + protocol source. diff --git a/README.md b/README.md index 8875da8..c69ea2e 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,56 @@ -# interplane.io +# Interplane -Source of the website for [INTERPLANE](https://github.com/aien-dev/interplane-mv), the open -interoperability protocol between AI models and agent runtimes. +A second life for your space junk. Interplane welcomes unfinished builds and +helps people find useful pieces with their origin, license and evidence intact. -Part of Sovereign Intelligence (SI). Aienix is retired. -[sovereign-intelligence](https://github.com/aien-dev/sovereign-intelligence) is the integration, -release and install center, and the place where the signed Spark test runs. AienOS is only the -OS layer. INTERPLANE lives in its own repository. See aien-architecture -[ADR 0045](https://github.com/aien-dev/aien-architecture-mv/blob/main/docs/adr/0045-aienix-retired-sovereign-intelligence-center.md). - -**Status (2026-10-18):** live at [interplane.io](https://interplane.io). The current Rust generator -landed on 2026-10-16 (pull request #4), and the page is rebuilt hourly. - -The page is not written by hand. A small Rust program, `crates/site-builder`, reads the protocol -repository's public record on GitHub (STATUS.md, ROADMAP.md, the stage reports, the latest tag, -the open proposals and the Spark judge's verdict for the current commit of main), writes those -facts to `facts.json`, and renders the page from Rust source plus that file. Every figure on the -page names the commit it was read at and links to it. The editorial copy lives in -`crates/site-builder/src/page.rs`. - -## Rules the page keeps - -`site-builder verify` refuses a build that breaks any of these: - -- no executable scripts, no outside fonts, no trackers; the only requests a visitor's browser makes are to interplane.io; -- one strictly parsed, HTML-safe `application/ld+json` block describes the website and exact protocol source pin; it runs no code; -- crawler files and every generated local target must match the build; `llms.txt` links all six generated routes and pinned protocol documentation; -- sitemap dates are omitted rather than using hourly fetch time as a content-change date; -- no em or en dashes; -- the pinned commit of the protocol repository is on the page; -- the Spark verdict is shown as it is (PASS, FAIL, BLOCKED, RUNNING or NO VERDICT), never summarised; -- no mention of the removed Python SDK and no "draft" footer. +This revision provides a static contribution front door, a source-backed starter +collection, component details, a portable contribution manifest, and the existing +protocol documentation routes. Contributions are prepared in the existing Radicle forge, then signed and published from the contributor's own node. +There is no automatic ingestion, repair service, hosted model, or execution of +submitted code in this website. ## Build -``` -cargo build --locked --release -p site-builder -target/release/site-builder facts # needs `gh` logged in; writes facts.json -target/release/site-builder build dist # renders all six routes, copies public/, facts.json -target/release/site-builder verify dist -``` - -`cargo test -p site-builder` renders a sample page and runs the same rules against it. - -## Developer onboarding candidate (issue #6) - -The route inventory in `crates/site-builder/src/routes.rs` generates Overview (`/`), -Quick Start (`/quick-start/`), Concepts (`/concepts/`), Writing an Adapter (`/adapter/`), -Conformance (`/conformance/`) and Versioned Status (`/status/`). Each has a unique title, -description and canonical, inert metadata and static HTML navigation. The existing facts -collector and hosting scripts are unchanged; this source change does not deploy anything. - -The Quick Start recipe has its own immutable protocol pin, explicitly separate from the -advancing source-status snapshot. Clone and Cargo fetch require network access; the scripted -exercise is offline after dependencies are fetched. It uses no real model or GPU. - -For the literal rendered recipe replay and route corruption controls, after building dist: - -```sh -python3 evidence/ONBOARDING-L642/qualify.py -``` +All release assembly and policy-checking logic lives in `native/site.om`. +HTML, CSS and SVG are reviewed declarative inputs. The browser runs no JavaScript +and fetches no third-party fonts, scripts or trackers. -This cold-clones the pinned source, so it needs network access and Git/Rust/Cargo. Raw receipts -and the source snapshot are in that evidence directory. The earlier `evidence/discoverability-issue7` -receipts describe their original pinned single-route source, not qualification of these new routes. +Use the pinned compiler and instructions in [native/README.md](native/README.md). +[The seed receipt](evidence/toolchain/REPRODUCE.md) records reconstruction from +the 408-byte seed and matching compiler stages. The native builder requires a +fresh output directory and verifies every successful build. -## Hosting and automation +## Check the evidence -The site is served by nginx on the project's Raspberry Pi house server. GitHub Pages is not used. -`scripts/sync-to-hub.sh` runs from cron on the Spark once an hour: it fast-forwards a clean clone -of this repository, rebuilds, refreshes the facts (keeping the last good facts if GitHub is -unreachable), verifies, and copies the result to the house server only when something changed. It skips a -run while the Spark's quiet flag is held (the flag that reserves the machine for chip runs). +- [Native controls and output hashes](native/evidence/): 53 positive/negative + controls on native x86 and emulated AArch64, plus repeated output comparison. +- [Lean and Wolfram](evidence/formal/README.md): a bounded evidence-label model, + checked positive proofs and a rejected false assertion. These do not prove + the whole website or a submitted component correct. +- [Research basis](docs/RESEARCH.md): test overfitting, reproducible environments, + and source provenance. +- [Release procedure](docs/RELEASE.md): compiler pins, deployment and rollback. -## Files +The retained Rust builder is legacy compatibility code, not the native release +entrypoint. Its canonical-base test results are recorded in `evidence/legacy-cargo-tests.json`. +The previous build documentation is preserved in [docs/LEGACY.md](docs/LEGACY.md). +Old evidence directories describe their original revisions, not this rebuild. -- `crates/site-builder/`: the generator (facts, page, verify). -- `public/style.css`: the one stylesheet; light and dark follow the reader's system setting. -- `public/hero.webp`: the hero illustration. -- `scripts/sync-to-hub.sh`: the hourly deploy. +## Publication -## License +The existing host remains nginx on the project's Raspberry Pi, with Spark +orchestration. GitHub Pages is not used. `scripts/sync-to-hub.sh` follows `main`, +so merging this change is a publication action. No deploy ran during this rebuild. -AGPL-3.0-or-later (see `LICENSE`). +The reviewed sources must be trusted and must not be concurrently modified. +The native verifier is a bounded checker for this site's static subset, not a +general sanitizer for uploaded content. AArch64 checks ran under QEMU, not on +the production Spark or Pi. No market-leading speed claim is made. -## Human-Directed Agentic Engineering +## License and attribution -Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, -architecture, constraints, acceptance criteria, and stopping points; agents implement, -execute checks, diagnose failures, and revise within those boundaries. Human review -retains responsibility for claims, acceptance, and release decisions. +AGPL-3.0-or-later (see `LICENSE`). Linked projects retain their own licenses and +authors. Inclusion in the collection does not relicense their work. -For the documented method and a systems-software case study, see Gregory M. Kurtzer, -*Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed -Agentic Engineering* (2026), https://doi.org/10.5281/zenodo.23682548. +Part of Sovereign Intelligence. AienOS is the OS layer. The original protocol +continues in [aien-dev/interplane-mv](https://www.aienos.com/forge/drakestapleton/interplane-mv). diff --git a/content/adapter/index.html b/content/adapter/index.html new file mode 100644 index 0000000..74869e8 --- /dev/null +++ b/content/adapter/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Writing an adapter
interplane.Bring your slop
INTERPLANE / SOURCE & STATUS

Writing an adapter

Begin with the protocol contract and the adapter documentation in the pinned repository. Keep host-owned permission decisions outside model-supplied data. Check supported interfaces and limitations before integrating your runtime.

The source remains inspectable.

The protocol sits underneath the broader Interplane vision. Its implementation status remains authoritative in its own repository.

Open the pinned protocol source ↗

Read the versioned capability record ↗

Source revision and verification scope

e0d6863e2598a147babbf8b707b88c2aedba0872

Source originally inspected through the connected mirror on November 9, 2026; the public source link uses the Radicle forge. This is source identity, not a live runtime verdict. Source: machine-readable record.

diff --git a/content/concepts/index.html b/content/concepts/index.html new file mode 100644 index 0000000..e95c554 --- /dev/null +++ b/content/concepts/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Protocol concepts
interplane.Bring your slop
INTERPLANE / SOURCE & STATUS

Protocol concepts

A model proposes an action. Parsing a message does not execute it. Transport does not grant permission. The runtime decides which operations are allowed, and records the result. A valid message or a signature does not replace that decision.

The source remains inspectable.

The protocol sits underneath the broader Interplane vision. Its implementation status remains authoritative in its own repository.

Open the pinned protocol source ↗

Read the versioned capability record ↗

Source revision and verification scope

e0d6863e2598a147babbf8b707b88c2aedba0872

Source originally inspected through the connected mirror on November 9, 2026; the public source link uses the Radicle forge. This is source identity, not a live runtime verdict. Source: machine-readable record.

diff --git a/content/conformance/index.html b/content/conformance/index.html new file mode 100644 index 0000000..8438586 --- /dev/null +++ b/content/conformance/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Protocol conformance
interplane.Bring your slop
INTERPLANE / SOURCE & STATUS

Protocol conformance

Consult the versioned STATUS.md and its linked evidence. A conformance result applies to the exact implementation, fixtures and environment it names. This website rebuild makes no new conformance or hardware claim.

The source remains inspectable.

The protocol sits underneath the broader Interplane vision. Its implementation status remains authoritative in its own repository.

Open the pinned protocol source ↗

Read the versioned capability record ↗

Source revision and verification scope

e0d6863e2598a147babbf8b707b88c2aedba0872

Source originally inspected through the connected mirror on November 9, 2026; the public source link uses the Radicle forge. This is source identity, not a live runtime verdict. Source: machine-readable record.

diff --git a/content/contribute/index.html b/content/contribute/index.html new file mode 100644 index 0000000..b4f86d1 --- /dev/null +++ b/content/contribute/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Bring your slop
interplane.Bring your slop
NO POLISHED PITCH REQUIRED

Bring your slop.
Keep your possibility.

A broken app, a useful function, a strange experiment. Start with what you have. Unknowns are allowed.

YOUR FIRST CONTRIBUTION

Tell us the story of your build.

  1. 01

    What were you trying to do?

    The original idea, and the part you think might help someone.

  2. 02

    Where can we find it?

    A source link, an exact revision if you have one, the author and license.

  3. 03

    What happened when you ran it?

    The command, environment, result, and what still fails. 'I don't know yet' is useful too.

Prepare a contribution on the forge ↗

Sign in with your Radicle key to prepare the issue text. Preparation does not publish it: download the result and run the supplied command on your own node to sign and publish. Nothing is submitted by this page.

What happens next?

After you publish the prepared issue from your node, maintainers can examine the contribution. They can ask for missing context, identify a reusable piece, and attach a reproduction record. Submission does not mean approval, automated repair, or successful verification.

See the full process ↗
diff --git a/content/evidence/index.html b/content/evidence/index.html new file mode 100644 index 0000000..5adb9bf --- /dev/null +++ b/content/evidence/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: What the evidence means
interplane.Bring your slop
SHOW THE WORK

Trust should come
with something to inspect.

A good story helps us find a piece. Evidence helps us decide what we can do with it.

A label is only as useful as its scope.

Submitted

A contributor supplied a description. Claims may still be unexamined.

Source inspected

Named source at a specific revision was read. This does not mean it was executed.

Checks passed

Named checks ran for a pinned artifact in a recorded environment. Read what those checks cover.

Reproduced

A recorded repeat run matched the declared result. The environment, operator and limits remain part of the claim.

What travels with a useful piece?

Original source and revision. Author and license. Dependencies. A reproduction command. Expected and observed results. Artifact hashes. Known failures. Links to parent and derived work.

Identity is not correctness.

A SHA-256 digest helps establish that two artifacts contain the same bytes. It does not prove that code is safe, correct, licensed for your use, or suited to a different environment.

A completion claim starts UNVERIFIED.

The forge completion rule requires the exact source revision, declared checks and a negative control that fails as expected. Missing, failed, mismatched or untrusted evidence means HOLD. A PASS covers those checks on that revision; it is not general correctness. Preparation is not publication, and no automatic merge runner is claimed by this website.

Incomplete is a valid state.

Missing evidence stays missing. A skipped check is not a passing check. An open proposal is not merged code. Source inspection, host execution and physical-hardware qualification are different claims.

Why this approach?

Program-repair research distinguishes patches that pass a test suite from patches that generalize beyond it. Reproducibility work highlights the need to capture inputs, environment and dependencies. Software-archive research motivates preserving source identity and ancestry.

These inform our design. They do not certify Interplane or any submitted artifact.

Open the evidence manifest ↗
diff --git a/content/facts.json b/content/facts.json new file mode 100644 index 0000000..c2e1065 --- /dev/null +++ b/content/facts.json @@ -0,0 +1,39 @@ +{ + "recorded_at": "2026-11-09", + "website_base_commit": "b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858", + "collection_kind": "source-backed starter collection", + "entries": [ + { + "slug": "omega-harness", + "repository": "https://www.aienos.com/forge/drakestapleton/omega-harness", + "revision": "af497dcfa0da597688c0383227045ea1c2e1d813", + "source_path": "examples/gate.sh", + "evidence_status": "source_inspected", + "replayed_for_listing": false, + "rid": "rad:z39gvwWsnkRZsAConQLjaKiNVLHfW" + }, + { + "slug": "weight-patch", + "repository": "https://www.aienos.com/forge/drakestapleton/aien-train", + "revision": "77e56d79c71a0ab693ed54d569375db10febd333", + "source_path": "tools/omegallm/wpatch/wpatch.om", + "evidence_status": "source_inspected", + "replayed_for_listing": false, + "rid": "rad:zKrfazKqYNFuXDDkYdptxJicGLEq" + }, + { + "slug": "interplane-protocol", + "repository": "https://www.aienos.com/forge/drakestapleton/interplane-mv", + "revision": "e0d6863e2598a147babbf8b707b88c2aedba0872", + "source_path": "AGENTS.md", + "evidence_status": "source_inspected", + "replayed_for_listing": false, + "rid": "rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa" + } + ], + "automated_salvage_service": "not_deployed", + "protocol_runtime_verdict": "not_checked_by_this_build", + "website_repository_rid": "rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV", + "contribution_transport": "Radicle-key-authenticated forge preparation, then contributor signs and publishes from own node", + "public_contact": "https://www.aienos.com/contact/" +} diff --git a/content/forge/index.html b/content/forge/index.html new file mode 100644 index 0000000..e6ef653 --- /dev/null +++ b/content/forge/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: The forge behind the pieces
interplane.Bring your slop
RADICLE / SOURCE / EVIDENCE

The forge behind
the useful pieces.

Keep source, authorship and review connected. The existing native Omega forge is the place to browse repositories and prepare a contribution.

Prepare here. Publish from your node.

The issue and patch forms use Radicle-key sign-in. They check and stage text, then provide a downloadable result and a command. The contributor runs that command on their own node to sign and publish. A prepared form has not been published to Radicle.

A completion is a claim.

Completion starts UNVERIFIED. Acceptance needs a review of the exact head, declared checks on that head and a negative control that fails as expected. Missing, failed, mismatched or untrusted evidence is HOLD. A PASS covers the declared checks, not correctness in general. The desk protocol retains merge authority; this website does not claim an automatic merge runner.

Keep a local copy.

rad clone rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV

Without Radicle, the read-only HTTPS mirror can be cloned with Git:

git clone https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git

Inspect the website source ↗

What the website adds.

The salvage yard presents reusable starting points with source pins and known limits. Repository discovery stays at the live forge. Automatic extraction, automatic repair and a community-wide execution service are not represented as running here.

Bring an unfinished build ↗

diff --git a/content/how-it-works/index.html b/content/how-it-works/index.html new file mode 100644 index 0000000..fb4310c --- /dev/null +++ b/content/how-it-works/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: How salvage works
interplane.Bring your slop
KEEP THE GOOD. UNDERSTAND THE REST.

From space junk
to something useful.

Small steps. Specific claims. Enough context for the next builder to pick up where you left off.

01 / RECEIVE

Start with the whole story.

Bring the original build and explain its purpose. What did you hope for? What actually happened? Keep failing examples alongside the promising ones.

02 / UNDERSTAND

Question the foundation.

A strange workaround might have solved a real constraint. Trace what the code does and why before rewriting it. Record which assumptions still hold.

03 / RECOVER

Find the smallest useful piece.

A component, an algorithm, a test case, or a lesson can be valuable on its own. Preserve authorship, license terms and a link to the exact source it came from.

04 / REBUILD

Make the behavior explicit.

Reduce hidden dependencies. Where a native Omega implementation is viable, compare it against the original behavior and record the differences. Conversion is an engineering task, never an automatic promise.

05 / REPRODUCE

Leave something checkable.

Package a command, inputs, environment and expected result. Keep the actual output and its scope. A second run adds evidence; it doesn't erase known limitations.

Ready to find your starting point?

The contribution and source collection are available now. Automated salvage is a direction we are building toward.

Explore the yard ↗
diff --git a/content/index.html b/content/index.html new file mode 100644 index 0000000..a26f754 --- /dev/null +++ b/content/index.html @@ -0,0 +1,7 @@ + +INTERPLANE: A second life for your space junk
interplane.Bring your slop
FOR THE BUILDERS WHO KEEP BUILDING

A second life
for your
space junk.

The almost-working apps. The abandoned experiments. The beautiful messes. There's something worth saving in what you've built.

✳ Unfinished is welcome here.
A drifting collection of code, a broken satellite, and an unfinished idea finding a new orbit
SALVAGE, DON'T SCRAP.POTENTIAL INSIDE ↗
+
Side projects✳Happy accidents✳AI slop✳Unfinished ideas✳Useful little pieces
+
NOTHING GOOD STARTS FINISHED.

You built something.
Let's see what it can become.

A project doesn't have to work as a whole to hold something valuable. A clever parser. A recovery trick. A lesson learned the hard way. Interplane is a place to pass those pieces forward, with their story and evidence intact.

Meet the mission ↗ Visit the forge ↗
+
A FEW PIECES TO START WITH

Good stuff in the debris.

Explore the yard ↗

A source-backed starter collection from AIEN. Open a piece to see what was inspected, what is still uncertain, and where it came from.

+
FROM ALMOST TO SOMETHING

A little less waste.
A lot more possibility.

Follow the process ↗
01

Bring the whole mess.

Tell us what you tried, what broke, and the bit you still believe in.

02

Find the useful part.

Trace how it works. Preserve the intent. Give its original builder credit.

03

Make it buildable.

Attach the source, a repeatable recipe, and the results someone else can check.

+
YOUR WEIRD LITTLE PROJECT BELONGS HERE.

We have room
for your slop.

You don't need a polished pitch. Just a starting point.

Give it a second life ↗
diff --git a/content/llms.txt b/content/llms.txt new file mode 100644 index 0000000..c0c4320 --- /dev/null +++ b/content/llms.txt @@ -0,0 +1,13 @@ +# Interplane + +A welcoming home for unfinished builds and reusable pieces. + +- https://interplane.io/yard/: Source-backed starter collection. +- https://interplane.io/contribute/: Contribution workflow. +- https://interplane.io/evidence/: Evidence scope and attribution. +- https://interplane.io/facts.json: Pinned source observations, not live runtime claims. + +No automatic extraction, repair or verification service is claimed. + +- Forge: https://interplane.io/forge/ +- Live repositories: https://interplane.io/explore diff --git a/content/mission/index.html b/content/mission/index.html new file mode 100644 index 0000000..b49c157 --- /dev/null +++ b/content/mission/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: A home for unfinished things
interplane.Bring your slop
THE INTERPLANE MISSION

Good things come
from unfinished things.

We're building a home for the work that didn't quite work. And for the people who made it.

“A project doesn't have to succeed as a whole to have something worth saving.”

Everyone has a space-junk folder.

Half-built apps. Agents that went in circles. A weekend idea that ate three weekends. Some of it is messy. Some of it is AI slop. Somewhere in there is a piece that could help another builder.

Interplane exists to make that exchange possible. To find the useful part, preserve its origin, and help someone turn it into something functional, verifiable, and replicable.

People get a welcome.
Claims get a close look.

We can respect the builder and still question the build. We can be ambitious and still say 'not run.' We can experiment with unusual foundations while leaving enough evidence for somebody else to disagree.

Make the credit travel.

Useful work carries its authors, its license, its history, and the contributions that made it better. Reuse should make those connections easier to see.

Drake Stapleton
Builder, Interplane / AIEN

Your next idea might already
be hiding in someone else's.

Go looking ↗
diff --git a/content/pieces/interplane-protocol/index.html b/content/pieces/interplane-protocol/index.html new file mode 100644 index 0000000..9fc835d --- /dev/null +++ b/content/pieces/interplane-protocol/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Interplane protocol
interplane.Bring your slop
← Back to the yard
PROTOCOLS / STARTER COLLECTION

Interplane protocol

An explicit boundary between a model suggesting an action and a runtime deciding what may actually execute.

● Source inspected

The useful part

The repository contract separates model intent, message parsing, transport, and runtime authorization. Its STATUS.md records capability claims.

Where to start

Begin with the protocol concepts and source status. Keep permission decisions in the runtime, outside imported model output.

What is still unproven

A source-backed starting point. This listing does not assert universal adapter support, a deployed salvage network, or hardware qualification.

Origin and license

Consult the pinned LICENSE and component notices before reuse; no blanket relicensing is implied.

Original work: AIEN contributors. This collection links to their source; it does not copy, relicense, or claim new authorship of the component.

Inspect the pinned source ↗
diff --git a/content/pieces/omega-harness/index.html b/content/pieces/omega-harness/index.html new file mode 100644 index 0000000..4a5d38e --- /dev/null +++ b/content/pieces/omega-harness/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Omega harness
interplane.Bring your slop
← Back to the yard
BUILDER TOOLS / STARTER COLLECTION

Omega harness

Small language examples, exact expected results, and a workflow for checking what an agent actually built.

● Source inspected

The useful part

A gate compares compilation outcomes, exit codes, standard output and errors against explicit expectations. Its compiler hash is pinned.

Where to start

Start with one example that matches your problem, preserve its expected output, and rerun the gate with its exact compiler pin.

What is still unproven

Source inspected for this collection. The full example suite has not been replayed as part of this listing. A passing example does not establish general compiler correctness.

Origin and license

Apache-2.0 recorded in the repository instructions; check the source license before redistribution.

Original work: AIEN contributors. This collection links to their source; it does not copy, relicense, or claim new authorship of the component.

Inspect the pinned source ↗
diff --git a/content/pieces/weight-patch/index.html b/content/pieces/weight-patch/index.html new file mode 100644 index 0000000..62fde79 --- /dev/null +++ b/content/pieces/weight-patch/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Omega checkpoint patcher
interplane.Bring your slop
← Back to the yard
MODEL TOOLING / STARTER COLLECTION

Omega checkpoint patcher

A native .om tool for inspecting model checkpoints, recording exact weight changes, and restoring the original bytes.

● Source inspected

The useful part

Source implements inspect, diff, validate, apply, verify, revert and runtime binding. Published fixture receipts record an exact round40 checkpoint rollback.

Where to start

Read the patch format and the negative controls, then work on a separate checkpoint copy. Preserve the base hash, delta and rollback record.

What is still unproven

This listing describes the pinned revision, without asserting its current merge status. Fixture results test patch mechanics; they do not demonstrate a better model. No live model is changed by this website.

Origin and license

The pinned source declares AGPL-3.0-only. Review the repository and dependency terms before reuse.

Original work: AIEN contributors. This collection links to their source; it does not copy, relicense, or claim new authorship of the component.

Inspect the pinned source ↗
diff --git a/content/quick-start/index.html b/content/quick-start/index.html new file mode 100644 index 0000000..783e57f --- /dev/null +++ b/content/quick-start/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Protocol quick start
interplane.Bring your slop
INTERPLANE / SOURCE & STATUS

Protocol quick start

Start with the source-pinned protocol repository. Follow its current build instructions and examples in your own environment. This rebuilt site has not replayed those examples, so it does not present an expected output as an observed result.

The source remains inspectable.

The protocol sits underneath the broader Interplane vision. Its implementation status remains authoritative in its own repository.

Open the pinned protocol source ↗

Read the versioned capability record ↗

Source revision and verification scope

e0d6863e2598a147babbf8b707b88c2aedba0872

Source originally inspected through the connected mirror on November 9, 2026; the public source link uses the Radicle forge. This is source identity, not a live runtime verdict. Source: machine-readable record.

diff --git a/content/robots.txt b/content/robots.txt new file mode 100644 index 0000000..f7bcde4 --- /dev/null +++ b/content/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Allow: / +Sitemap: https://interplane.io/sitemap.xml diff --git a/content/sitemap.xml b/content/sitemap.xml new file mode 100644 index 0000000..42c1ddf --- /dev/null +++ b/content/sitemap.xml @@ -0,0 +1,2 @@ + +https://interplane.io/https://interplane.io/adapter/https://interplane.io/concepts/https://interplane.io/conformance/https://interplane.io/contribute/https://interplane.io/evidence/https://interplane.io/yard/https://interplane.io/how-it-works/https://interplane.io/mission/https://interplane.io/pieces/interplane-protocol/https://interplane.io/pieces/omega-harness/https://interplane.io/pieces/weight-patch/https://interplane.io/quick-start/https://interplane.io/status/https://interplane.io/forge/ diff --git a/content/status/index.html b/content/status/index.html new file mode 100644 index 0000000..9fffaa2 --- /dev/null +++ b/content/status/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: What exists today
interplane.Bring your slop
INTERPLANE / SOURCE & STATUS

What exists today

This release provides the public website, source-backed starter collection, portable contribution manifest and Radicle forge preparation path. Prepared contributions require publication from the contributor's node and maintainer review. Automated extraction, automatic repair, a hosted execution service and community-wide verification are not represented as running here.

The existing forge remains available.

Repository browsing and contribution preparation run in the native Omega forge. The static salvage collection uses /yard/ so it does not replace the live repository explorer.

Browse live repositories ↗

The source remains inspectable.

The protocol sits underneath the broader Interplane vision. Its implementation status remains authoritative in its own repository.

Open the pinned protocol source ↗

Read the versioned capability record ↗

Source revision and verification scope

e0d6863e2598a147babbf8b707b88c2aedba0872

Source originally inspected through the connected mirror on November 9, 2026; the public source link uses the Radicle forge. This is source identity, not a live runtime verdict. Source: machine-readable record.

diff --git a/content/yard/index.html b/content/yard/index.html new file mode 100644 index 0000000..397c1b7 --- /dev/null +++ b/content/yard/index.html @@ -0,0 +1,2 @@ + +INTERPLANE: Explore the yard
interplane.Bring your slop
THE SALVAGE YARD

One builder's loose end.
Your next starting point.

Useful pieces deserve another orbit. This starter collection links to real source, with the limits attached.

Filter the collection by type

Curated starting points, not a claim that these projects were abandoned. No community submissions are represented as reviewed yet.

Got a piece we should meet?

Bring it over ↗
diff --git a/crates/site-builder/src/discovery.rs b/crates/site-builder/src/discovery.rs index 9fb5ec1..7dbb7dc 100644 --- a/crates/site-builder/src/discovery.rs +++ b/crates/site-builder/src/discovery.rs @@ -67,7 +67,7 @@ pub fn llms(f: &Facts) -> String { .iter() .map(|r| format!("- [{}]({}): {}\n", r.label(), r.url(), r.description())) .collect::(); - format!("# INTERPLANE\n\n> {}\n\nExperimental protocol. Models express intent; runtimes retain authority. Implemented and qualified behavior is distinct from planned work.\n\n## Current website\n{}- [Generated facts]({}facts.json): the source pin and exact verification state.\n\n## Pinned protocol documentation\n- [Status]({})\n- [Writing an adapter]({})\n- [Roadmap]({})\n\nProtocol source revision: {}. Discovery metadata is not a support or security guarantee.\n",page::DESCRIPTION,pages,page::SITE_URL,f.blob("STATUS.md"),f.blob("docs/WRITING-AN-ADAPTER.md"),f.blob("ROADMAP.md"),f.pin.sha) + format!("# INTERPLANE\n\n> {}\n\nExperimental. A completion claim starts UNVERIFIED; missing, failed or untrusted evidence is a HOLD; a PASS means the declared checks passed on the exact revision, not universal correctness. Completion interception is in progress, not deployed; longitudinal model checks are planned, with no runner yet. Implemented and qualified behavior is distinct from planned work.\n\n## Current website\n{}- [Generated facts]({}facts.json): the source pin and exact verification state.\n\n## Pinned documentation\n- [Forge verification rule]({})\n- [Status]({})\n- [Writing an adapter]({})\n- [Roadmap]({})\n\nProtocol source revision: {}. Discovery metadata is not a support or security guarantee.\n",page::DESCRIPTION,pages,page::SITE_URL,f.blob(page::FORGE_CONTRACT),f.blob("STATUS.md"),f.blob("docs/WRITING-AN-ADAPTER.md"),f.blob("ROADMAP.md"),f.pin.sha) } pub fn write(dist: &Path, f: &Facts) -> Result<(), String> { for (name, text) in [ diff --git a/crates/site-builder/src/facts.rs b/crates/site-builder/src/facts.rs index 6a12fd1..456f930 100644 --- a/crates/site-builder/src/facts.rs +++ b/crates/site-builder/src/facts.rs @@ -1,29 +1,51 @@ -//! Facts read from the protocol repository's public record on GitHub. `site-builder facts` +//! Facts read from the protocol repository's public record on Radicle. `site-builder facts` //! writes them to `facts.json`; `site-builder build` renders them. Nothing in this file is //! typed by hand: every value names the commit it was read at, so the page can link to it. +//! +//! Host dependency (pre-rule Rust debt, kept minimal): the `facts` step runs `curl` against the +//! public radicle-httpd API of the seed `RADICLE_SEED`. It replaced `gh api` once the aien-dev +//! GitHub organisation stopped answering (404). Nothing else in the build talks to the network. use std::path::Path; use std::process::Command; use serde::{Deserialize, Serialize}; -/// The protocol repository under its current name. The old name `aien-dev/interplane` still -/// redirects, but a redirect stops working if that name is ever reused, so ask for the real one. -pub const PROTOCOL_REPO: &str = "aien-dev/interplane-mv"; +/// The protocol repository (interplane-mv) by its Radicle repository ID. +pub const PROTOCOL_RID: &str = "rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa"; -/// The commit status context under which the Spark judge posts its verdict. -pub const SPARK_STATUS_CONTEXT: &str = "AIEN Verification (Spark)"; +/// The public Radicle seed whose HTTP API the facts are read from (radicle-httpd). +pub const RADICLE_SEED: &str = "rosa.radicle.network"; + +/// The one delegate of the protocol repository (Radicle NID). Its own `refs/tags` are read only +/// when the canonical `refs.tags` is empty; the identity carries no canonical tag rule. +pub const PROTOCOL_DELEGATE: &str = "z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK"; + +/// The Radicle web view of a repository on that seed. +pub fn radicle_web(rid: &str) -> String { + format!("https://radicle.network/nodes/{RADICLE_SEED}/{rid}") +} + +/// The read-only git+HTTPS mirror of a public repository on the AIEN hub seed. +pub fn hub_clone_url(rid: &str) -> String { + format!("https://www.aienos.com/rad/{}.git", rid.trim_start_matches("rad:")) +} #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Pin { - /// The repository as GitHub names it today. + /// The repository as Radicle names it today. pub full_name: String, pub url: String, /// The commit of main every fact below was read at. pub sha: String, pub committed_at: String, pub commit_title: String, + /// The highest version-like tag, or empty when the record has none. pub latest_tag: String, + /// Where `latest_tag` was read: "canonical" (the repository's `refs.tags`), "delegate" + /// (the delegate's own `refs/tags`, used only when the canonical set is empty) or empty. + #[serde(default)] + pub latest_tag_source: String, pub license: String, pub description: String, } @@ -70,7 +92,8 @@ pub struct Report { #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Merge { - pub number: u64, + /// The Radicle patch ID (Radicle patches carry no number). + pub id: String, pub title: String, pub merged_at: String, pub url: String, @@ -98,6 +121,20 @@ pub struct Facts { pub open_prs: u64, pub last_merge: Option, pub receipt: Receipt, + /// Public repositories in table 1 of the Radicle registry (RIDS.md), counted by `build`. + #[serde(default)] + pub public_repos: usize, +} + +impl Pin { + /// The release as the page shows it: "untagged", the tag, or " (delegate tag)". + pub fn release_label(&self) -> String { + match (self.latest_tag.as_str(), self.latest_tag_source.as_str()) { + ("", _) => "untagged".to_string(), + (t, "delegate") => format!("{t} (delegate tag)"), + (t, _) => t.to_string(), + } + } } impl Facts { @@ -113,27 +150,53 @@ impl Facts { /// A link into the pinned commit of the protocol repository. pub fn blob(&self, path: &str) -> String { - format!("{}/blob/{}/{}", self.pin.url, self.pin.sha, path) + format!("{}/tree/{}/{}", self.pin.url, self.pin.sha, path) + } + + /// The pinned commit itself. + pub fn commit_url(&self) -> String { + format!("{}/commits/{}", self.pin.url, self.pin.sha) + } + + pub fn patches_url(&self) -> String { + format!("{}/patches", self.pin.url) + } + + pub fn issues_url(&self) -> String { + format!("{}/issues", self.pin.url) } } -fn gh(args: &[&str]) -> Result { - let out = Command::new("gh").arg("api").args(args).output().map_err(|e| format!("gh api: {e}"))?; - if !out.status.success() { - return Err(format!("gh api {}: {}", args.join(" "), String::from_utf8_lossy(&out.stderr).trim())); +/// Rows of the first Markdown table in the registry (table 1 of RIDS.md: the public repositories). +pub fn count_registry_repos(text: &str) -> Result { + let mut lines = text.lines().skip_while(|l| !l.trim_start().starts_with("|---")); + if lines.next().is_none() { + return Err("registry has no Markdown table".into()); } - serde_json::from_slice(&out.stdout).map_err(|e| format!("gh api {}: bad JSON: {e}", args.join(" "))) + let n = lines.take_while(|l| l.trim_start().starts_with('|')).count(); + if n == 0 { Err("registry table 1 has no rows".into()) } else { Ok(n) } } -fn gh_text(full: &str, path: &str, sha: &str) -> Result { - let out = Command::new("gh") - .args(["api", "-H", "Accept: application/vnd.github.raw+json", &format!("repos/{full}/contents/{path}?ref={sha}")]) +/// Fetches one URL with `curl` (the recorded host edge; see the module comment). +fn fetch(url: &str) -> Result, String> { + let out = Command::new("curl") + .args(["-fsSL", "--max-time", "60", "--retry", "2", url]) .output() - .map_err(|e| format!("gh api: {e}"))?; + .map_err(|e| format!("curl {url}: {e}"))?; if !out.status.success() { - return Err(format!("gh api {path}@{sha}: {}", String::from_utf8_lossy(&out.stderr).trim())); + return Err(format!("curl {url}: {}", String::from_utf8_lossy(&out.stderr).trim())); } - Ok(String::from_utf8_lossy(&out.stdout).into_owned()) + Ok(out.stdout) +} + +fn api(path: &str) -> Result { + let url = format!("https://{RADICLE_SEED}/api/v1/repos/{PROTOCOL_RID}{path}"); + serde_json::from_slice(&fetch(&url)?).map_err(|e| format!("{url}: bad JSON: {e}")) +} + +fn raw_text(path: &str, sha: &str) -> Result { + let url = format!("https://{RADICLE_SEED}/raw/{PROTOCOL_RID}/{sha}/{path}"); + Ok(String::from_utf8_lossy(&fetch(&url)?).into_owned()) } fn s(v: &serde_json::Value, key: &str) -> String { @@ -144,84 +207,88 @@ fn ptr(v: &serde_json::Value, path: &str) -> String { v.pointer(path).and_then(|x| x.as_str()).unwrap_or("").to_string() } +fn num(v: &serde_json::Value, path: &str) -> u64 { + v.pointer(path).and_then(|x| x.as_u64()).unwrap_or(0) +} + pub fn gather() -> Result { - let repo = gh(&[format!("repos/{PROTOCOL_REPO}").as_str()])?; - let full = s(&repo, "full_name"); - let url = s(&repo, "html_url"); - let commit = gh(&[format!("repos/{full}/commits/main").as_str()])?; - let sha = s(&commit, "sha"); - let tags = gh(&[format!("repos/{full}/tags?per_page=1").as_str()])?; + let repo = api("")?; + let project = repo.pointer("/payloads/xyz.radicle.project/data").cloned().unwrap_or_default(); + let meta = repo.pointer("/payloads/xyz.radicle.project/meta").cloned().unwrap_or_default(); + let url = radicle_web(PROTOCOL_RID); + let sha = ptr(&meta, "/head"); + if sha.len() != 40 { + return Err(format!("{PROTOCOL_RID}: no head commit in the seed's answer")); + } + let commit = api(&format!("/commits/{sha}"))?; + let cargo = raw_text("rust/Cargo.toml", &sha)?; + let canonical = latest_tag(&repo); + let (tag, tag_source) = if !canonical.is_empty() { + (canonical, "canonical") + } else { + // Fail closed: an unreachable or malformed answer stops the facts step (the deploy keeps + // the last good facts); an answer from anyone but the delegate yields no tag. + match delegate_tag(&api(&format!("/remotes/{PROTOCOL_DELEGATE}"))?) { + t if t.is_empty() => (t, ""), + t => (t, "delegate"), + } + }; let pin = Pin { - full_name: full.clone(), + full_name: s(&project, "name"), url: url.clone(), sha: sha.clone(), - committed_at: ptr(&commit, "/commit/committer/date"), - commit_title: ptr(&commit, "/commit/message").lines().next().unwrap_or("").to_string(), - latest_tag: tags.get(0).map(|t| s(t, "name")).unwrap_or_default(), - license: ptr(&repo, "/license/spdx_id"), - description: s(&repo, "description"), + committed_at: commit.pointer("/commit/committer/time").and_then(|t| t.as_i64()).map(rfc3339).unwrap_or_default(), + commit_title: ptr(&commit, "/commit/summary"), + latest_tag: tag, + latest_tag_source: tag_source.to_string(), + license: cargo_license(&cargo), + description: s(&project, "description"), }; - let status_md = gh_text(&full, "STATUS.md", &sha)?; + let status_md = raw_text("STATUS.md", &sha)?; let status = status_counts(&status_md); let conformance = conformance_row(&status_md); - let roadmap_md = gh_text(&full, "ROADMAP.md", &sha)?; - let docs = gh(&[format!("repos/{full}/contents/docs?ref={sha}").as_str()])?; - let report_names: Vec = docs - .as_array() - .map(|a| a.iter().map(|d| s(d, "name")).filter(|n| n.starts_with("REPORT-") && n.ends_with(".md")).collect()) + let roadmap_md = raw_text("ROADMAP.md", &sha)?; + let docs = api(&format!("/tree/{sha}/docs"))?; + let mut report_names: Vec = docs + .get("entries") + .and_then(|a| a.as_array()) + .map(|a| a.iter().filter(|d| s(d, "kind") == "blob").map(|d| s(d, "name")).filter(|n| n.starts_with("REPORT-") && n.ends_with(".md")).collect()) .unwrap_or_default(); + report_names.sort(); let mut reports = Vec::new(); for name in &report_names { - let text = gh_text(&full, &format!("docs/{name}"), &sha)?; + let text = raw_text(&format!("docs/{name}"), &sha)?; reports.push(Report { name: name.clone(), title: text.lines().find(|l| l.starts_with("# ")).map(|l| l[2..].trim().to_string()).unwrap_or_else(|| name.clone()), headline: headline(&text), - url: format!("{url}/blob/{sha}/docs/{name}"), + url: format!("{url}/tree/{sha}/docs/{name}"), }); } let (stages, next_stage) = stages(&roadmap_md, &reports); - let pulls_open = gh(&[format!("repos/{full}/pulls?state=open&per_page=100").as_str()])?; - let open_prs = pulls_open.as_array().map(|a| a.len() as u64).unwrap_or(0); - let open_issues = repo.get("open_issues_count").and_then(|n| n.as_u64()).unwrap_or(0).saturating_sub(open_prs); - let pulls_closed = gh(&[format!("repos/{full}/pulls?state=closed&sort=updated&direction=desc&per_page=30").as_str()])?; - let last_merge = pulls_closed.as_array().and_then(|a| { - a.iter().filter(|p| !s(p, "merged_at").is_empty()).max_by(|a, b| s(a, "merged_at").cmp(&s(b, "merged_at"))).map(|p| Merge { - number: p.get("number").and_then(|n| n.as_u64()).unwrap_or(0), - title: s(p, "title"), - merged_at: s(p, "merged_at"), - url: s(p, "html_url"), - }) + let open_prs = num(&meta, "/patches/open") + num(&meta, "/patches/draft"); + let open_issues = num(&meta, "/issues/open"); + let merged = api("/patches?status=merged&perPage=100")?; + let last_merge = merged.as_array().and_then(|a| { + a.iter() + .filter_map(|p| { + let at = p.get("merges")?.as_array()?.iter().filter_map(|m| m.get("timestamp")?.as_i64()).max()?; + Some((at, p)) + }) + .max_by_key(|(at, _)| *at) + .map(|(at, p)| Merge { id: s(p, "id"), title: s(p, "title"), merged_at: rfc3339(at), url: format!("{url}/patches/{}", s(p, "id")) }) }); - // The Spark judge's verdict for this commit, never the hosted bridge check run. - let combined = gh(&[format!("repos/{full}/commits/{sha}/status").as_str()])?; - let receipt = combined - .get("statuses") - .and_then(|a| a.as_array()) - .and_then(|a| a.iter().filter(|r| s(r, "context") == SPARK_STATUS_CONTEXT).max_by(|a, b| s(a, "updated_at").cmp(&s(b, "updated_at")))) - .map(|st| Receipt { - state: match s(st, "state").as_str() { - "success" => "success".to_string(), - "failure" | "error" => "failure".to_string(), - _ => "pending".to_string(), - }, - description: public_description(&s(st, "description")), - target_url: { - let t = s(st, "target_url"); - if t.is_empty() { format!("{url}/commit/{sha}") } else { t } - }, - updated_at: s(st, "updated_at"), - }) - .unwrap_or(Receipt { - state: "none".to_string(), - description: "The Spark has not published a verdict for this commit yet.".to_string(), - target_url: String::new(), - updated_at: String::new(), - }); + // Radicle records no commit statuses, so no Spark verdict can be read for this commit. + let receipt = Receipt { + state: "none".to_string(), + description: "No Spark verdict is recorded on Radicle for this commit.".to_string(), + target_url: String::new(), + updated_at: String::new(), + }; Ok(Facts { generated_at: now_utc(), @@ -235,9 +302,57 @@ pub fn gather() -> Result { open_prs, last_merge, receipt, + public_repos: 0, }) } +/// The highest version-like name, compared by its numbers (v0.10.0 > v0.3.0), or empty. +fn highest_tag<'a>(names: impl Iterator) -> String { + let key = |t: &str| t.split(|c: char| !c.is_ascii_digit()).filter_map(|n| n.parse::().ok()).collect::>(); + names.map(|k| k.trim_start_matches("refs/tags/").to_string()).max_by(|a, b| key(a).cmp(&key(b)).then(a.cmp(b))).unwrap_or_default() +} + +/// The highest version-like tag in the seed's canonical `refs.tags`, or empty when it has none. +pub fn latest_tag(repo: &serde_json::Value) -> String { + repo.pointer("/refs/tags").and_then(|t| t.as_object()).map(|t| highest_tag(t.keys().map(String::as_str))).unwrap_or_default() +} + +/// The highest version-like tag among the delegate's own refs, from the seed's +/// `/remotes/` answer. Empty unless that answer names `PROTOCOL_DELEGATE` +/// and marks it a delegate. +pub fn delegate_tag(remote: &serde_json::Value) -> String { + if remote.get("id").and_then(|v| v.as_str()) != Some(PROTOCOL_DELEGATE) || remote.get("delegate").and_then(|v| v.as_bool()) != Some(true) { + return String::new(); + } + remote.get("refs").and_then(|r| r.as_object()).map(|r| highest_tag(r.keys().map(String::as_str).filter(|k| k.starts_with("refs/tags/")))).unwrap_or_default() +} + +/// The SPDX `license = "..."` the Rust workspace declares, or empty. +pub fn cargo_license(toml: &str) -> String { + toml.lines() + .find_map(|l| { + let (k, v) = l.split_once('=')?; + (k.trim() == "license").then(|| v.trim().trim_matches('"').to_string()) + }) + .unwrap_or_default() +} + +/// Unix seconds to `YYYY-MM-DDTHH:MM:SSZ` (proleptic Gregorian, UTC). +pub fn rfc3339(secs: i64) -> String { + let (days, rem) = (secs.div_euclid(86_400), secs.rem_euclid(86_400)); + // Days since 1970-01-01 to a civil date (H. Hinnant's days_from_civil, inverted). + let z = days + 719_468; + let era = z.div_euclid(146_097); + let doe = z - era * 146_097; + let yoe = (doe - doe / 1460 + doe / 36_524 - doe / 146_096) / 365; + let doy = doe - (365 * yoe + yoe / 4 - yoe / 100); + let mp = (5 * doy + 2) / 153; + let d = doy - (153 * mp + 2) / 5 + 1; + let m = if mp < 10 { mp + 3 } else { mp - 9 }; + let y = yoe + era * 400 + i64::from(m <= 2); + format!("{y:04}-{m:02}-{d:02}T{:02}:{:02}:{:02}Z", rem / 3600, rem % 3600 / 60, rem % 60) +} + /// Splits a Markdown table row into trimmed cells. fn cells(line: &str) -> Vec { let t = line.trim(); @@ -397,13 +512,6 @@ pub fn stages(md: &str, reports: &[Report]) -> (Vec, String) { (stages, next) } -/// The Spark writes its verdict line followed by the bundle path on its own disk. The verdict -/// is public; the path is not useful to anyone else, so it is cut off here. -pub fn public_description(raw: &str) -> String { - let cut = raw.find(": bundle ").or_else(|| raw.find(" bundle /")).unwrap_or(raw.len()); - raw[..cut].trim().to_string() -} - pub fn now_utc() -> String { let out = Command::new("date").args(["-u", "+%Y-%m-%dT%H:%M:%SZ"]).output(); match out { @@ -476,9 +584,38 @@ mod tests { } #[test] - fn public_description_drops_the_bundle_path() { - assert_eq!(public_description("PASS 12 gates: bundle /home/x/y"), "PASS 12 gates"); - assert_eq!(public_description("PASS"), "PASS"); + fn radicle_record_fields_are_read() { + // References from `date -u -d @` (GNU coreutils) on the Spark. + assert_eq!(rfc3339(0), "1970-01-01T00:00:00Z"); + assert_eq!(rfc3339(951_782_400), "2000-02-29T00:00:00Z"); + assert_eq!(rfc3339(1_793_917_391), "2026-11-05T22:23:11Z"); + assert_eq!(cargo_license("[workspace.package]\nversion = \"0.3.0\"\nlicense = \"Apache-2.0\"\n"), "Apache-2.0"); + assert_eq!(cargo_license("[package]\nname = \"x\"\n"), ""); + let repo = serde_json::json!({"refs": {"tags": {"v0.2.0": "a", "v0.10.0": "b", "v0.3.0": "c"}}}); + assert_eq!(latest_tag(&repo), "v0.10.0"); + assert_eq!(latest_tag(&serde_json::json!({"refs": {"tags": {}}})), ""); + } + + #[test] + fn delegate_tag_is_read_only_from_the_delegate() { + // Shape of rosa's /api/v1/repos/rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa/remotes/ on 7 Nov 2026. + let remote = |id: &str, delegate: bool, refs: serde_json::Value| serde_json::json!({"id": id, "alias": "drake", "heads": {"main": "e0d6"}, "refs": refs, "delegate": delegate}); + let tagged = serde_json::json!({"refs/heads/main": "e0d6", "refs/tags/v0.3.0": "d33e", "refs/tags/v0.2.0": "c1"}); + assert_eq!(delegate_tag(&remote(PROTOCOL_DELEGATE, true, tagged.clone())), "v0.3.0"); + // Negative controls: no tags at all, another peer's tags, a non-delegate, no answer. + assert_eq!(delegate_tag(&remote(PROTOCOL_DELEGATE, true, serde_json::json!({"refs/heads/main": "e0d6"}))), ""); + assert_eq!(delegate_tag(&remote("z6MkOtherPeer", true, tagged.clone())), ""); + assert_eq!(delegate_tag(&remote(PROTOCOL_DELEGATE, false, tagged)), ""); + assert_eq!(delegate_tag(&serde_json::json!({})), ""); + } + + #[test] + fn release_label_names_a_delegate_tag() { + let pin = |tag: &str, source: &str| Pin { full_name: String::new(), url: String::new(), sha: String::new(), committed_at: String::new(), commit_title: String::new(), latest_tag: tag.into(), latest_tag_source: source.into(), license: String::new(), description: String::new() }; + assert_eq!(pin("v0.3.0", "delegate").release_label(), "v0.3.0 (delegate tag)"); + assert_eq!(pin("v0.3.0", "canonical").release_label(), "v0.3.0"); + assert_eq!(pin("", "").release_label(), "untagged"); + assert_eq!(pin("", "delegate").release_label(), "untagged"); } #[test] diff --git a/crates/site-builder/src/main.rs b/crates/site-builder/src/main.rs index b1c93e0..a1a4028 100644 --- a/crates/site-builder/src/main.rs +++ b/crates/site-builder/src/main.rs @@ -2,13 +2,17 @@ //! //! ```text //! site-builder facts [facts.json] read the protocol repository, write the facts file -//! site-builder build [dist] [facts.json] render the page and copy public/ into dist +//! site-builder build [dist] [facts.json] [RIDS.md] +//! render the page and copy public/ into dist; the /forge/ +//! repository count is table 1 of the Radicle registry +//! (default $HOME/handoffs/radicle/RIDS.md) //! site-builder verify [dist] refuse a page that breaks the site rules +//! site-builder style [dist] advisory: report em or en dashes (never run by verify) //! ``` //! //! The page is rendered from Rust source plus the facts file. No executable scripts, no outside fonts, no -//! trackers, no em or en dashes, and no figure that does not resolve to a record in the -//! protocol repository. +//! trackers, and no figure that does not resolve to a record in the protocol repository. No em or +//! en dashes either, but that style rule is advisory: `style` reports it, `verify` does not. mod discovery; mod facts; @@ -35,8 +39,10 @@ fn copy_dir(src: &Path, dst: &Path) -> std::io::Result<()> { Ok(()) } -fn build(dist: &Path, facts_path: &Path) -> Result<(), String> { - let facts = Facts::load(facts_path)?; +fn build(dist: &Path, facts_path: &Path, registry: &Path) -> Result<(), String> { + let mut facts = Facts::load(facts_path)?; + let text = fs::read_to_string(registry).map_err(|e| format!("registry {}: {e}", registry.display()))?; + facts.public_repos = facts::count_registry_repos(&text).map_err(|e| format!("{}: {e}", registry.display()))?; fs::create_dir_all(dist).map_err(|e| format!("{}: {e}", dist.display()))?; for route in routes::ALL { let file=dist.join(route.file()); @@ -45,17 +51,36 @@ fn build(dist: &Path, facts_path: &Path) -> Result<(), String> { println!("built {}",file.display()); } copy_dir(Path::new("public"), &dist.join("public")).map_err(|e| format!("public/: {e}"))?; - fs::copy(facts_path, dist.join("facts.json")).map_err(|e| e.to_string())?; + facts.save(&dist.join("facts.json"))?; discovery::write(dist, &facts)?; - println!("built {} routes from {}@{}", routes::ALL.len(), facts.pin.full_name, facts.pin.sha); + println!("built {} routes from {}@{}; {} public repositories counted from {}", routes::ALL.len(), facts.pin.full_name, facts.pin.sha, facts.public_repos, registry.display()); Ok(()) } /// The site rules, enforced on the rendered output so a copy change cannot slip past them. +/// The style rule (no em or en dashes) is not here: it is advisory and lives in `style_problems`. pub fn verify_html(html: &str, css: &str) -> Vec { verify_page_html(html,css,true) } +/// Advisory style rule, kept out of `verify` so that it never fails a build, a deploy or the CI +/// `test` job (DRA-99): no em or en dashes in a page or the stylesheet. `site-builder style` and +/// the ignored test `tests::style_rendered_routes_have_no_dashes` (run by the CI `style` job, +/// which reports a finding as a warning) check it. +pub fn style_problems(html: &str, css: &str) -> Vec { + let mut problems = Vec::new(); + if html.contains('\u{2014}') { + problems.push("em dash in index.html".to_string()); + } + if html.contains('\u{2013}') { + problems.push("en dash in index.html".to_string()); + } + if css.contains('\u{2014}') || css.contains('\u{2013}') { + problems.push("dash in style.css".to_string()); + } + problems +} + fn verify_page_html(html: &str, css: &str, home: bool) -> Vec { let mut problems = Vec::new(); let mut need = |cond: bool, msg: &str| { @@ -63,9 +88,6 @@ fn verify_page_html(html: &str, css: &str, home: bool) -> Vec { problems.push(msg.to_string()); } }; - need(!html.contains('\u{2014}'), "em dash in index.html"); - need(!html.contains('\u{2013}'), "en dash in index.html"); - need(!css.contains('\u{2014}') && !css.contains('\u{2013}'), "dash in style.css"); need(discovery::json_block(html).is_ok(), "invalid or executable script in index.html"); need(!html.contains("fonts.googleapis") && !html.contains("fonts.gstatic") && !css.contains("@import") && !css.contains("fonts.g"), "an outside font"); need(!html.contains("href=\"http://"), "a plain http link"); @@ -115,6 +137,7 @@ fn verify(dist: &Path) -> Result<(), String> { if !body.contains(&format!("{}",facts.pin.sha)) {page_problems.push("the full visible source pin is missing".into());} if facts.receipt.state=="success" && !body.contains(">PASS<") {page_problems.push("a passing verdict is not shown as PASS".into());} if facts.receipt.state=="failure" && !body.contains(">FAIL<") && !body.contains(">BLOCKED<") {page_problems.push("a failing verdict is not shown as FAIL or BLOCKED".into());} + page_problems.extend(forge_problems(route,&body,&facts)); problems.extend(page_problems.into_iter().map(|p|format!("{}: {p}",route.path()))); } // Preserve the original homepage receipt check/display; doc routes reuse canonical facts. @@ -127,6 +150,37 @@ fn verify(dist: &Path) -> Result<(), String> { } } +/// /forge/ argues for leaving the aien-dev GitHub organisation, so it may not link back into it, and +/// its repository count must be the one `build` counted from the registry. +fn forge_problems(route: routes::Route, html: &str, facts: &Facts) -> Vec { + let mut problems = Vec::new(); + if route == routes::Route::Forge && html.contains("github.com/aien-dev") { + problems.push("no github.com/aien-dev link allowed on /forge/".to_string()); + } + let count = format!("{} public repositories, counted from the registry", facts.public_repos); + if matches!(route, routes::Route::Forge | routes::Route::Overview) && (facts.public_repos == 0 || !html.contains(&count)) { + problems.push(format!("the forge repository count is not the registry count ({})", facts.public_repos)); + } + problems +} + +/// Advisory: report the style findings of a built `dist`. `verify` does not run this. +fn style(dist: &Path) -> Result<(), String> { + let css = fs::read_to_string(dist.join("public/style.css")).map_err(|e| format!("public/style.css: {e}"))?; + let mut problems = style_problems("", &css); + for route in routes::ALL { + let file=dist.join(route.file()); + let body=fs::read_to_string(&file).map_err(|e|format!("{}: {e}",file.display()))?; + problems.extend(style_problems(&body,"").into_iter().map(|p|format!("{}: {p}",route.path()))); + } + if problems.is_empty() { + println!("style: no em or en dashes in {} routes or style.css", routes::ALL.len()); + Ok(()) + } else { + Err(problems.join("\n")) + } +} + fn main() -> ExitCode { let args: Vec = std::env::args().skip(1).collect(); let mode = args.first().map(String::as_str).unwrap_or("build"); @@ -136,14 +190,18 @@ fn main() -> ExitCode { facts::gather().and_then(|f| { let r = f.save(&out); if r.is_ok() { - println!("facts: {}@{} tag {} receipt {} -> {}", f.pin.full_name, &f.pin.sha[..12.min(f.pin.sha.len())], f.pin.latest_tag, f.receipt.state, out.display()); + println!("facts: {}@{} tag {} receipt {} -> {}", f.pin.full_name, &f.pin.sha[..12.min(f.pin.sha.len())], f.pin.release_label(), f.receipt.state, out.display()); } r }) } - "build" => build(Path::new(args.get(1).map(String::as_str).unwrap_or("dist")), Path::new(args.get(2).map(String::as_str).unwrap_or("facts.json"))), + "build" => { + let registry = args.get(3).map(PathBuf::from).unwrap_or_else(|| PathBuf::from(std::env::var("HOME").unwrap_or_default()).join("handoffs/radicle/RIDS.md")); + build(Path::new(args.get(1).map(String::as_str).unwrap_or("dist")), Path::new(args.get(2).map(String::as_str).unwrap_or("facts.json")), ®istry) + } "verify" => verify(Path::new(args.get(1).map(String::as_str).unwrap_or("dist"))), - other => Err(format!("unknown mode {other}; use facts, build or verify")), + "style" => style(Path::new(args.get(1).map(String::as_str).unwrap_or("dist"))), + other => Err(format!("unknown mode {other}; use facts, build, verify or style")), }; match result { Ok(()) => ExitCode::SUCCESS, @@ -159,16 +217,31 @@ mod tests { use super::*; use facts::*; + /// A registry fixture shaped like RIDS.md: a title, table 1 with `rows` repositories, then a + /// second table that must not be counted. Tests run in parallel, so it is written to a private + /// file and renamed into place: no test ever reads a half-written registry. + fn registry(rows: usize) -> PathBuf { + let path = std::env::temp_dir().join(format!("interplane-registry-{}-{rows}.md", std::process::id())); + let mut text = String::from("# Radicle RIDs\n\n| repo | RID |\n|---|---|\n"); + for n in 0..rows { text += &format!("| repo-{n} | rad:z{n} |\n"); } + text += "\n## WITHDRAWN\n\n| repo | RID |\n|---|---|\n| withdrawn | none |\n"; + let tmp = path.with_extension(format!("{:?}.tmp", std::thread::current().id()).replace(['(', ')'], "")); + fs::write(&tmp, text).unwrap(); + fs::rename(&tmp, &path).unwrap(); + path + } + fn sample() -> Facts { Facts { generated_at: "2026-10-16T17:00:00Z".into(), pin: Pin { - full_name: "aien-dev/interplane".into(), - url: "https://github.com/aien-dev/interplane".into(), + full_name: "interplane-mv".into(), + url: "https://radicle.network/nodes/rosa.radicle.network/rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa".into(), sha: "83df0f074b2c0000000000000000000000000000".into(), committed_at: "2026-10-16T09:30:35Z".into(), commit_title: "ci: enroll interplane in the Spark verification pipeline (#109)".into(), latest_tag: "v0.3.0".into(), + latest_tag_source: "canonical".into(), license: "Apache-2.0".into(), description: "d".into(), }, @@ -183,8 +256,9 @@ mod tests { reports: vec![Report { name: "REPORT-0.3.md".into(), title: "INTERPLANE 0.3 report".into(), headline: "every offline gate PASSED.".into(), url: "https://x/REPORT-0.3.md".into() }], open_issues: 2, open_prs: 1, - last_merge: Some(Merge { number: 109, title: "ci: enroll".into(), merged_at: "2026-10-16T09:30:36Z".into(), url: "https://x/pull/109".into() }), + last_merge: Some(Merge { id: "f75aeaa5e019f2f58de614f17682badddf9aca5d".into(), title: "ci: enroll".into(), merged_at: "2026-10-16T09:30:36Z".into(), url: "https://x/patches/f75aeaa5".into() }), receipt: Receipt { state: "success".into(), description: "PASS 7 gates".into(), target_url: "https://x/commit/83df".into(), updated_at: "2026-10-16T10:00:00Z".into() }, + public_repos: 30, } } @@ -200,6 +274,21 @@ mod tests { assert!(html.contains("v0.3.0")); } + #[test] + fn release_shows_a_delegate_tag_and_untagged_without_one() { + let mut f = sample(); + f.pin.latest_tag_source = "delegate".into(); + let html = page::render(&f); + assert!(html.contains("v0.3.0 (delegate tag)"), "hero and counts name the delegate tag"); + // Negative control: no tag at all must still read "untagged", with no delegate label. + f.pin.latest_tag.clear(); + f.pin.latest_tag_source.clear(); + let html = page::render(&f); + assert!(html.contains("untagged")); + assert!(!html.contains("delegate tag")); + assert!(!html.contains("v0.3.0")); + } + #[test] fn discoverability_is_inert_pinned_and_html_safe() { let mut f = sample(); @@ -235,7 +324,7 @@ mod tests { let out = dir.join("dist"); // CLI build is run at repository root; Cargo runs unit tests in the crate directory. std::env::set_current_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../..")).unwrap(); - build(&out, &facts_path).unwrap(); + build(&out, &facts_path, ®istry(30)).unwrap(); let llms = fs::read_to_string(out.join("llms.txt")).expect("missing llms.txt"); assert!(llms.contains(page::SITE_URL) && llms.contains(&f.blob("STATUS.md"))); assert!(!fs::read_to_string(out.join("sitemap.xml")).unwrap().contains("")); @@ -282,12 +371,12 @@ mod tests { fs::create_dir_all(&dir).unwrap();let input=dir.join("input.json");sample().save(&input).unwrap(); let out=dir.join("dist"); std::env::set_current_dir(concat!(env!("CARGO_MANIFEST_DIR"),"/../..")).unwrap(); - build(&out,&input).unwrap();assert!(verify(&out).is_ok()); + build(&out,&input,®istry(30)).unwrap();assert!(verify(&out).is_ok()); for route in routes::ALL { let file=out.join(route.file());let original=fs::read_to_string(&file).unwrap(); fs::write(&file,original.replace("","\"tracking")).unwrap(); assert!(verify(&out).is_err(),"remote resource accepted on {}",route.path()); - fs::write(&file,original.replace("","External navigation\"local")).unwrap(); + fs::write(&file,original.replace("","External navigation\"local")).unwrap(); assert!(verify(&out).is_ok(),"legal navigation or local resource refused on {}",route.path()); fs::write(&file,original).unwrap(); } @@ -313,9 +402,9 @@ mod tests { let input=dir.join("input.json"); let f=sample(); f.save(&input).unwrap(); let out=dir.join("dist"); std::env::set_current_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../..")).unwrap(); - build(&out,&input).unwrap(); + build(&out,&input,®istry(30)).unwrap(); let mut titles=BTreeSet::new(); let mut descriptions=BTreeSet::new(); let mut canonicals=BTreeSet::new(); - for path in ["", "quick-start/", "concepts/", "adapter/", "conformance/", "status/"] { + for path in ["", "quick-start/", "concepts/", "adapter/", "conformance/", "status/", "forge/"] { let file=out.join(path).join("index.html"); let html=fs::read_to_string(&file).unwrap_or_else(|_| panic!("missing onboarding route {path}")); let title=html.split_once("").unwrap().1.split_once("").unwrap().0.to_string(); @@ -324,12 +413,12 @@ mod tests { assert_eq!(canonical, format!("https://interplane.io/{path}")); assert!(titles.insert(title)); assert!(descriptions.insert(description)); assert!(canonicals.insert(canonical)); assert!(html.contains(&f.pin.sha), "source pin absent on {path}"); - for link in ["/", "/quick-start/", "/concepts/", "/adapter/", "/conformance/", "/status/"] { + for link in ["/", "/quick-start/", "/concepts/", "/adapter/", "/conformance/", "/status/", "/forge/"] { assert!(html.contains(&format!("href=\"{link}\"")), "missing navigation {link} on {path}"); } assert_eq!(html.matches("INTERPLANE Forge")); + assert!(original.contains("agents express intent and the forge retains authority, on Radicle")); + assert!(original.contains("owner marked spammy")); + assert!(original.contains("rad clone rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa")); + assert!(original.contains("curl -fsSL https://www.aienos.com/replicate | sh")); + assert!(original.contains("href=\"https://radicle.xyz/\"") && original.contains("Heartwood")); + assert!(original.contains(">PLANNED<") && original.contains("It is HOST TESTED on the Spark") && original.contains("No forge runner applies it to patches yet")); + for (n, sha) in ["78f40e03", "9714eba8", "882e3c06", "215ea39a", "da8b7e66"].iter().enumerate() { + assert!(original.contains(sha), "worked example {n} ({sha}) missing"); + } + assert!(!original.contains("github.com/aien-dev")); + fs::write(&forge, original.replace("", "x")).unwrap(); + let err = verify(&out).unwrap_err(); + assert!(err.contains("/forge/: no github.com/aien-dev link allowed on /forge/"), "{err}"); + fs::write(&forge, original).unwrap(); + let status = out.join("status/index.html"); let original = fs::read_to_string(&status).unwrap(); + fs::write(&status, original.replace("", "x")).unwrap(); + assert!(verify(&out).is_ok(), "the rule is scoped to /forge/"); + fs::remove_dir_all(dir).unwrap(); + } + + /// The /forge/ repository count is table 1 of the registry at build time, history views are + /// LIVE with a live example, and a page whose count disagrees with the registry fails `verify`. + #[test] + fn forge_count_comes_from_the_registry() { + let dir = std::env::temp_dir().join(format!("interplane-forge-count-{}", std::process::id())); + fs::create_dir_all(&dir).unwrap(); + let mut stale = sample(); stale.public_repos = 28; + let input = dir.join("input.json"); stale.save(&input).unwrap(); + std::env::set_current_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../..")).unwrap(); + for rows in [30, 31] { + let out = dir.join(format!("dist-{rows}")); + build(&out, &input, ®istry(rows)).unwrap(); + assert!(verify(&out).is_ok()); + assert_eq!(Facts::load(&out.join("facts.json")).unwrap().public_repos, rows); + let forge = fs::read_to_string(out.join("forge/index.html")).unwrap(); + let home = fs::read_to_string(out.join("index.html")).unwrap(); + let count = format!("{rows} public repositories, counted from the registry"); + assert!(forge.contains(&count) && home.contains(&count), "{rows}"); + assert!(!forge.contains("28 public") && !forge.contains("of the 28")); + assert!(!forge.contains("moved from the aien-dev GitHub organisation")); + assert!(forge.contains("LIVE History views")); + assert!(forge.contains("href=\"https://interplane.io/drakestapleton/cuda-crack/commits/main\"")); + assert!(!forge.contains(">COMING<") && !home.contains("commit history, review")); + } + let forge = dir.join("dist-31/forge/index.html"); let original = fs::read_to_string(&forge).unwrap(); + fs::write(&forge, original.replace("31 public repositories", "30 public repositories")).unwrap(); + let err = verify(&dir.join("dist-31")).unwrap_err(); + assert!(err.contains("/forge/: the forge repository count is not the registry count (31)"), "{err}"); + let empty = dir.join("empty.md"); fs::write(&empty, "# no table\n").unwrap(); + assert!(build(&dir.join("dist-0"), &input, &empty).is_err(), "a registry without table 1 is refused"); + fs::remove_dir_all(dir).unwrap(); + } + + /// Every generated page links Radicle or aienos.com, never the aien-dev GitHub organisation. + #[test] + fn no_route_links_the_aien_dev_github_organisation() { + let f = sample(); + for route in routes::ALL { + let html = page::render_route(&f, route); + assert!(!html.contains("github.com/aien-dev"), "aien-dev GitHub link on {}", route.path()); + } + assert!(page::render(&f).contains("href=\"/forge/\""), "overview has no Forge teaser link"); + } + #[test] fn failing_verdict_is_red_and_honest() { let mut f = sample(); @@ -359,4 +525,83 @@ mod tests { assert!(html.contains(">NO VERDICT<")); assert!(html.contains("not published a verdict")); } + + #[test] + fn home_evidence_links_follow_the_facts_pin_and_anchors_resolve() { + let mut f = sample(); + let html = page::render(&f); + for path in [page::FORGE_DECIDE_SOURCE, page::FORGE_CONTRACT, page::FORGE_TESTS] { + assert!(html.contains(&format!("href=\"{}\"", f.blob(path))), "{path} is not linked at the facts pin"); + } + for anchor in ["reports", "longitudinal", "j-space"] { + assert!(html.contains(&format!("href=\"#{anchor}\"")) && html.contains(&format!("id=\"{anchor}\"")), "#{anchor} has no target"); + } + // Negative control: at another pin the links move with it and the old revision is gone. + let old = f.blob(page::FORGE_DECIDE_SOURCE); + f.pin.sha = "0".repeat(40); + let moved = page::render(&f); + assert!(!moved.contains(&old) && moved.contains(&f.blob(page::FORGE_DECIDE_SOURCE))); + } + + /// Advisory style rule (DRA-99). `cargo test` skips it, so a dash never fails the CI `test` + /// job; the CI `style` job runs it with `--ignored` and reports a failure as a warning. + #[test] + #[ignore = "advisory style rule (DRA-99): the CI style job runs it with --ignored"] + fn style_rendered_routes_have_no_dashes() { + let css = fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/../../public/style.css")).expect("public/style.css"); + let mut problems = style_problems("", &css); + for route in routes::ALL { + let html = page::render_route(&sample(), route); + problems.extend(style_problems(&html, "").into_iter().map(|p| format!("{}: {p}", route.path()))); + } + for p in &problems { + println!("STYLE {p}"); + } + assert!(problems.is_empty(), "{problems:?}"); + } + + /// A dash is reported by the style rule only; a structural defect still fails `verify`. + #[test] + fn dashes_are_advisory_and_structure_still_fails_verify() { + let html = page::render(&sample()); + let css = fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/../../public/style.css")).expect("public/style.css"); + assert!(verify_html(&html, &css).is_empty()); + for (dash, msg) in [('\u{2014}', "em dash in index.html"), ('\u{2013}', "en dash in index.html")] { + let dashed = html.replace("", &format!("

a {dash} b

")); + assert!(verify_html(&dashed, &css).is_empty(), "verify must not refuse a {msg}"); + assert!(style_problems(&dashed, "").contains(&msg.to_string()), "style must report a {msg}"); + } + let dashed_css = format!("{css}\n/* a \u{2014} b */\n"); + assert!(verify_html(&html, &dashed_css).is_empty(), "verify must not refuse a dash in style.css"); + assert_eq!(style_problems("", &dashed_css), vec!["dash in style.css".to_string()]); + assert!(style_problems("plain - hyphen", "a { b: c - d }").is_empty(), "a hyphen is not a dash"); + let broken = html.replace("id=\"status\"", "id=\"gone\""); + assert!(verify_html(&broken, &css).contains(&"missing status section".to_string())); + + // The same split on a built dist: verify passes with dashes, style reports them, and a + // structural defect is still refused by verify. + let dir = std::env::temp_dir().join(format!("interplane-style-{}", std::process::id())); + fs::create_dir_all(&dir).unwrap(); + let input = dir.join("input.json"); + let f = sample(); + f.save(&input).unwrap(); + let out = dir.join("dist"); + std::env::set_current_dir(concat!(env!("CARGO_MANIFEST_DIR"), "/../..")).unwrap(); + build(&out, &input, ®istry(30)).unwrap(); + assert!(verify(&out).is_ok()); + let page = out.join("quick-start/index.html"); + let original = fs::read_to_string(&page).unwrap(); + fs::write(&page, original.replace("", "

a \u{2014} b \u{2013} c

")).unwrap(); + let sheet = out.join("public/style.css"); + let original_css = fs::read_to_string(&sheet).unwrap(); + fs::write(&sheet, format!("{original_css}\n/* a \u{2013} b */\n")).unwrap(); + assert!(verify(&out).is_ok(), "verify must not refuse dashes: {:?}", verify(&out)); + let found = style(&out).expect_err("style must report the dashes"); + assert!(found.contains("/quick-start/: em dash in index.html"), "{found}"); + assert!(found.contains("/quick-start/: en dash in index.html"), "{found}"); + assert!(found.contains("dash in style.css"), "{found}"); + fs::write(&page, original.replace(&format!("{}", f.pin.sha), "unpinned")).unwrap(); + assert!(verify(&out).is_err(), "a missing source pin must still be refused"); + fs::remove_dir_all(dir).unwrap(); + } } diff --git a/crates/site-builder/src/page.rs b/crates/site-builder/src/page.rs index a3e4360..64b8ca2 100644 --- a/crates/site-builder/src/page.rs +++ b/crates/site-builder/src/page.rs @@ -8,10 +8,11 @@ use crate::facts::{short_date, Facts}; use crate::routes::{Route,ALL}; pub const TITLE: &str = "INTERPLANE"; -pub const TAGLINE: &str = "The open boundary between AI models and the programs that act for them."; -pub const DESCRIPTION: &str = "INTERPLANE is an open interoperability protocol between AI models and agent runtimes. Models express intent. Runtimes retain authority."; +pub const TAGLINE: &str = "No proof. Not done."; +pub const SUPPORT: &str = "INTERPLANE checks AI completion claims against reproducible evidence."; +pub const DESCRIPTION: &str = "No proof. Not done. INTERPLANE checks AI completion claims against reproducible evidence: exact-revision checks with negative controls for code; frozen task sets for model-service performance over time are planned. Open source on Radicle."; pub const SITE_URL: &str = "https://interplane.io/"; -pub const SITE_REPO: &str = "https://github.com/aien-dev/interplane.io"; +pub const SITE_REPO: &str = "https://radicle.network/nodes/rosa.radicle.network/rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV"; /// The 0.1 receipt, read from docs/REPORT-0.1.md ("Selection" section) at the pinned commit. /// Only the report path is cited on the page; the numbers below are copied from it by hand and @@ -98,25 +99,35 @@ pub fn verdict_word(receipt: &crate::facts::Receipt) -> &'static str { } } +/// The forge source the home page cites: the decide/gate program and its contract live in the +/// protocol repository (read at the facts pin); the forge web app lives in its own repository. +pub const FORGE_DECIDE_SOURCE: &str = "forge/forge.om"; +pub const FORGE_CONTRACT: &str = "docs/FORGE.md"; +pub const FORGE_TESTS: &str = "forge/tests/run.sh"; +pub const FORGE_WEB_RID: &str = "rad:z3KFmLGeYdvDAgwpCgdBd1ENW7nU5"; +/// Published precedent for measuring the same model service on the same tasks over time. +pub const DRIFT_PRECEDENT: &str = "https://arxiv.org/abs/2307.09009"; + fn hero(facts: &Facts) -> Markup { - let release = if facts.pin.latest_tag.is_empty() { "unreleased".to_string() } else { facts.pin.latest_tag.clone() }; + let release = facts.pin.release_label(); html! { header class="hero" { div class="hero-text" { - p class="kicker" { "Open protocol" " " span class="dot" {} " " (release) " " span class="dot" {} " " (facts.pin.license) } + p class="kicker" { "Open source on Radicle" " " span class="dot" {} " " (release) " " span class="dot" {} " " (facts.pin.license) } h1 { (TITLE) } p class="tagline" { (TAGLINE) } p class="lede" { - "A model can say what it wants done. Only the program running it decides what happens. INTERPLANE is the written agreement between the two sides, with a test suite that checks every implementation the same way." + strong { (SUPPORT) } " When an AI agent reports that work is complete, the report starts UNVERIFIED. It is accepted only with evidence tied to the exact source revision: the declared checks ran on that revision, and a negative control, a known bad input, failed them. A claim without that evidence is returned for evidence, with the missing facts named. A PASS covers the declared checks on that revision and nothing more." } p class="actions" { - a class="button primary" href=(facts.pin.url) { "Read the source" } - a class="button" href=(facts.blob("spec/CORE.md")) { "Read the specification" } - a class="button" href="#status" { "See the current state" } + a class="button primary" href=(facts.blob(FORGE_CONTRACT)) { "Read the verification rule" } + a class="button" href=(facts.blob(FORGE_DECIDE_SOURCE)) { "Read the forge source" } + a class="button" href="#reports" { "See PASS and FAIL reports" } + a class="button" href=(FORGE_EXPLORE) { "Explore repositories" } } } figure class="hero-art" { - img src="public/hero.webp" width="1536" height="1024" alt="Two machined metal plates held apart by struts, with a single luminous amber plane stretched between them: the INTERPLANE layer between a model and a runtime." loading="eager"; + img src="public/hero.webp" width="1536" height="1024" alt="Two machined metal plates held apart by struts, with a single luminous amber plane stretched between them: the line a completion claim has to cross with evidence before it is accepted." loading="eager"; } } } @@ -126,18 +137,36 @@ fn problem() -> Markup { html! { section class="prose" id="why" { h2 { "The problem it fixes" } - p { "Every local model speaks its own tool-calling dialect. Every agent program has its own tools, approvals and memory. Today each pair is wired by hand, and the wiring is where the authority leaks: a model reads a web page that contains an instruction, repeats it as a tool call, and the program obeys because nothing in between remembered where the text came from." } - p { "INTERPLANE puts a named, tested layer there. It belongs to neither side. A runtime keeps its own policy and execution; a model keeps its own dialect. The protocol only standardises what crosses between them, and makes that crossing measurable." } - blockquote { "Models express intent. Runtimes retain authority. INTERPLANE defines the boundary between them." } + p { "Agents write \u{201C}done\u{201D} and \u{201C}all tests pass\u{201D} easily. The sentence may describe a different commit, a suite that was skipped, or a test that could never fail. Reading the report does not tell you which." } + p { "INTERPLANE starts every completion claim as UNVERIFIED. Evidence has to name the exact revision, the task, the input and the checker that produced it. Missing, failed, mismatched or untrusted evidence is a HOLD, never a quiet pass. Under the rule, an unsupported claim goes back to the agent that made it, with the facts it still has to supply. Today forge decide and forge gate apply this rule in their test suites and in replays of real desk decisions; no runner applies them to live merges yet, and automatic interception of an agent's completion message is still being built, as listed below." } + p { "The scope of a PASS is written down: the declared checks passed on that exact revision, and their negative control failed. A PASS is not proof that the software is correct in general, that a statement is true, or that a model meant what it said. Checks cover what they cover." } + blockquote { "A completion is a claim. Evidence decides what it is worth." } + h3 { "Two uses" } + ol { + li { strong { "Code completion proof." } " A claim that a change is done is checked against receipts for the exact revision: which checks ran, their exit codes, and a negative control that had to fail. This is what forge decide and forge gate check today; the desk protocol still performs the merge." } + li { strong { "Model-service performance over time." } " The same frozen task set, run against a model service again and again, to detect measured regressions on those tasks. Planned; " a href="#longitudinal" { "what it can and cannot show" } "." } + } } } } fn modules(facts: &Facts) -> Markup { + let web = crate::facts::radicle_web; html! { section id="modules" { - h2 { "Seven modules, one line" } - p class="section-lede" { "Each module answers one question a call has to pass on its way from a model to an effect in the world." } + h2 { "What runs today, and what does not" } + p class="section-lede" { "Each piece is labelled with the state its own source records. Planned work is listed as planned." } + ul class="stage-list" { + li { span class="pill ok" { "HOST TESTED" } " " strong { "forge decide" } ": decides MERGE or HOLD from three inputs: the patch's exact head, an independent reviewer's verdict for that head, and a gate receipt. Every fail-closed invariant has a test case that breaks only it and a mutant that removes it; the suite requires each mutant to be caught. " a href=(facts.blob(FORGE_DECIDE_SOURCE)) { "Source" } ", " a href=(facts.blob(FORGE_CONTRACT)) { "rule" } ", " a href=(facts.blob(FORGE_TESTS)) { "tests" } "." } + li { span class="pill ok" { "HOST TESTED" } " " strong { "forge gate" } ": runs a repository's gate and its negative control in fresh clones of the exact head and writes a receipt with the commands, exit codes and log hashes. A run killed at its timeout is a HOLD, not a result." } + li { span class="pill wait" { "LIMIT" } " " strong { "Identities and receipts are not signed yet" } ": reviewer and author names are unsigned text, and the gate command is the one the repository declares. A receipt is evidence the forge wrote, not a cryptographic proof. Signed verdicts and receipts are planned. No gate receipts are published on this site yet." } + li { span class="pill wait" { "IN PROGRESS" } " " strong { "Completion interception" } ": no agent runtime I use stops an agent's \u{201C}done\u{201D} automatically today. A claim gate that returns an unsupported completion to the producing agent, with the missing facts and a bounded number of repair attempts, is being built. It is not merged and not deployed." } + li { span class="pill none" { "PLANNED" } " " strong { "Longitudinal model checks" } ": the same frozen tasks, measured over time. " a href="#longitudinal" { "How, and what it cannot show" } "." } + li { span class="pill none" { "PROPOSED" } " " strong { "J-Space" } ": an isolated verification workspace whose English is rendered only from the verifier's payload. " a href="#j-space" { "Design and limits" } "." } + } + p class="fine" { "The forge web app that serves " a href=(FORGE_EXPLORE) { "interplane.io/explore" } " is open source too: " a href=(web(FORGE_WEB_RID)) { "interplane-forge on Radicle" } "." } + h3 { "Protocol modules underneath" } + p class="section-lede" { "The forge applies INTERPLANE's protocol rule, that a request is not authority, to code merges. The protocol's own modules:" } ol class="modules" { @for m in MODULES.iter() { li { @@ -152,11 +181,34 @@ fn modules(facts: &Facts) -> Markup { } } +fn longitudinal() -> Markup { + html! { + section class="prose" id="longitudinal" { + h2 { "Measuring model behavior over time" } + p { span class="pill none" { "PLANNED" } " A product direction. No runner exists yet, and nothing on this page starts a run." } + p { "Checking one completion and measuring a model are different jobs. A completion check asks whether this change, at this revision, passed its declared checks. A longitudinal check asks whether a model, under the name a provider serves it, still does as well on the same tasks as it did before." } + p { "The method: freeze a set of tasks, their inputs and their checker; run them against a model on a schedule; record the date, the model name as served and every score; compare each run with a recorded baseline. A drop on those tasks is measured drift on those tasks. It does not show why the model changed, whether anyone intended it, or whether a renamed model is a different one." } + p { "No historical launch baseline is available here for any model, so this page makes no claim that any model has degraded. Published precedent for the method: Chen, Zaharia and Zou measured the March and June 2023 versions of GPT-3.5 and GPT-4 on the same tasks and recorded large changes in behavior (" a href=(DRIFT_PRECEDENT) { "arXiv:2307.09009" } "). That is evidence about those versions, not about any other model." } + } + } +} + +fn j_space(facts: &Facts) -> Markup { + html! { + section class="prose" id="j-space" { + h2 { "J-Space: an isolated verification workspace" } + p { span class="pill none" { "PROPOSED" } " A design, not a service. Public deployment has not run, there is no public endpoint, and nothing on this page starts it." } + p { "The proposal keeps two jobs apart. An isolated verifier checks a claim against its declared evidence and produces a verdict payload. A separate renderer turns only that payload into plain English: a fixed system prompt and the payload, with no tools and no conversation history, so the only facts it is given are the ones the verifier produced. A model can still misword them, so the payload stays the record; the English is a reading of it, not new evidence." } + p { "No J-Space source is published yet, so there is nothing to link as its implementation. Related foundation, not J-Space itself: the forge verification " a href=(facts.blob(FORGE_CONTRACT)) { "rule" } " and " a href=(facts.blob(FORGE_DECIDE_SOURCE)) { "source" } ". This is not an inference service and nothing here sells model access." } + } + } +} + fn receipt(facts: &Facts) -> Markup { html! { section id="receipt" class="receipt" { - h2 { "One measured result" } - p class="section-lede" { "From the 0.1 readiness report. A real Qwen3.5-9B model on Ollama, one task, the runtime's full tool catalog against the tools CrossAxis selected." } + h2 { "Evidence that is allowed to fail" } + p class="section-lede" { "The protocol's own stages follow the same rule: a pre-registered gate, and a report that states the result whether it passed or failed. From the 0.1 readiness report, a real Qwen3.5-9B model on Ollama, one task, the runtime's full tool catalog against the tools CrossAxis selected:" } div class="receipt-grid" { div class="cell" { span class="big" { (RECEIPT_TOOLS_BEFORE) " to " (RECEIPT_TOOLS_AFTER) } span class="label" { "tools offered for the task" } } div class="cell" { span class="big" { (number(RECEIPT_TOKENS_BEFORE)) " to " (number(RECEIPT_TOKENS_AFTER)) } span class="label" { "first-turn prompt tokens, model reported" } } @@ -180,7 +232,7 @@ fn status(facts: &Facts) -> Markup { h2 { "Current state" } p class="section-lede" { "Read from the protocol repository at commit " - a href={ (facts.pin.url) "/commit/" (facts.pin.sha) } { code { (&facts.pin.sha[..12.min(facts.pin.sha.len())]) } } + a href=(facts.commit_url()) { code { (&facts.pin.sha[..12.min(facts.pin.sha.len())]) } } " (" (short_date(&facts.pin.committed_at)) "). This page is rebuilt every hour from that record and nothing here is typed by hand." } div class="verdict" { @@ -234,18 +286,18 @@ fn status(facts: &Facts) -> Markup { div class="cell" { h3 { "Activity" } ul class="counts" { - li { "Latest change: " a href={ (facts.pin.url) "/commit/" (facts.pin.sha) } { (facts.pin.commit_title) } } + li { "Latest change: " a href=(facts.commit_url()) { (facts.pin.commit_title) } } @if let Some(m) = &facts.last_merge { - li { "Last merged proposal: " a href=(m.url) { "#" (m.number) " " (m.title) } " (" (short_date(&m.merged_at)) ")" } + li { "Last merged patch: " a href=(m.url) { code { (&m.id[..8.min(m.id.len())]) } " " (m.title) } " (" (short_date(&m.merged_at)) ")" } } - li { strong { (facts.open_prs) } " open proposals, " strong { (facts.open_issues) } " open issues" } - li { "Latest release: " strong { (if facts.pin.latest_tag.is_empty() { "none".to_string() } else { facts.pin.latest_tag.clone() }) } } + li { strong { (facts.open_prs) } " open patches, " strong { (facts.open_issues) } " open issues" } + li { "Latest release tag: " strong { (if facts.pin.latest_tag.is_empty() { "none on Radicle".to_string() } else { facts.pin.release_label() }) } } } - a href={ (facts.pin.url) "/pulls" } { "Proposals" } " " span class="dot" {} " " a href={ (facts.pin.url) "/issues" } { "Issues" } + a href=(facts.patches_url()) { "Patches" } " " span class="dot" {} " " a href=(facts.issues_url()) { "Issues" } } } - div class="reports" { - h3 { "Reports, in their own words" } + div class="reports" id="reports" { + h3 { "PASS and FAIL reports, in their own words" } p class="section-lede" { "Every stage closes with a pre-registered gate and a report that states the result whether it passed or failed." } ul class="report-list" { @for r in &facts.reports { @@ -265,17 +317,17 @@ fn status(facts: &Facts) -> Markup { } pub const OFFLINE_PIN: &str = "b669d06e21c9debb15073289d7c0b78b1b2d362c"; -pub const OFFLINE_REPOSITORY: &str = "https://github.com/aien-dev/interplane-mv"; +pub const OFFLINE_RID: &str = "rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa"; pub fn offline_commands() -> String { - format!("git clone {OFFLINE_REPOSITORY}.git interplane\ncd interplane\ngit checkout --detach {OFFLINE_PIN}\ncd rust\ncargo fetch --locked\ncargo run --locked --offline -q -p interplane-crossveil --example offline") + format!("git clone {} interplane\ncd interplane\ngit checkout --detach {OFFLINE_PIN}\ncd rust\ncargo fetch --locked\ncargo run --locked --offline -q -p interplane-crossveil --example offline", crate::facts::hub_clone_url(OFFLINE_RID)) } fn offline_recipe() -> Markup { html! { p { "Prerequisites: Git, a Rust/Cargo toolchain compatible with the repository lockfile, and network access for the clone and dependency fetch. " a href="https://rust-lang.org/tools/install/" { "Install Rust" } ". The scripted example runs offline after these downloads; it uses no model or GPU." } pre { code class="language-sh" aria-label="Pinned offline example commands" { (offline_commands()) } } p { "Expected observation: the final line is " code { "OK: the injected actions were denied or held; none executed." } ". The trace denies email and file-write proposals, holds a note append for approval, and executes no effectful request. This is a reference policy demonstration, not a general security or deployment qualification." } - p class="fine" { "Recipe source: " a href={ (OFFLINE_REPOSITORY) "/blob/" (OFFLINE_PIN) "/rust/crates/interplane-crossveil/examples/offline.rs" } { code { (OFFLINE_PIN) } } ". This replay pin is fixed independently of the advancing source-status snapshot below." } + p class="fine" { "Recipe source: " a href={ (crate::facts::radicle_web(OFFLINE_RID)) "/tree/" (OFFLINE_PIN) "/rust/crates/interplane-crossveil/examples/offline.rs" } { code { (OFFLINE_PIN) } } ". This replay pin is fixed independently of the advancing source-status snapshot below." } } } fn get_started(facts: &Facts) -> Markup { @@ -299,7 +351,7 @@ fn navigation(current: Route) -> Markup { fn source_record(facts: &Facts) -> Markup { html! { section class="source-record prose" { h2 { "Source and verification" } - p { "Status snapshot: " a href={ (facts.pin.url) "/commit/" (facts.pin.sha) } {code {(facts.pin.sha)}} ". Generated " (facts.generated_at) ". " a href="/facts.json" {"Raw facts"} "." } + p { "Status snapshot: " a href=(facts.commit_url()) {code {(facts.pin.sha)}} ". Generated " (facts.generated_at) ". " a href="/facts.json" {"Raw facts"} "." } p { "Spark verification: " span class={"pill " (verdict_class(&facts.receipt.state))} {(verdict_word(&facts.receipt))} " " (facts.receipt.description) } p class="fine" { "A successful reference example is not the Spark verdict. Planned work is not implemented support. " a href="/status/" {"Versioned status"} " and " a href=(facts.blob("STATUS.md")) {"canonical STATUS.md"} " retain those distinctions." } }} @@ -341,9 +393,130 @@ fn doc_content(facts: &Facts, route: Route) -> Markup { p { "The " a href="/quick-start/" {"small offline exercise"} " is a useful first observation, not a replacement for adapter conformance, failure controls or a live deployment gate." } }}, Route::Status => html! { (status(facts)) }, + Route::Forge => forge(facts.public_repos), Route::Overview => html! {}, } } +/// One desk merge from 7 Nov 2026, copied from the Radicle record (patch state `merged`, merge +/// commit) and the desk's PATCHES.md row (verdict file, gate, negative control). +struct DeskMerge { + repo: &'static str, + rid: &'static str, + patch: &'static str, + head: &'static str, + what: &'static str, + gate: &'static str, +} + +const DESK_MERGES: [DeskMerge; 5] = [ + DeskMerge { repo: "aien-sovereign-core-mv (core#925)", rid: "rad:z44GqrPVAPjZkhoD2MWVjqy18ighN", patch: "f75aeaa5e019f2f58de614f17682badddf9aca5d", head: "78f40e033bbcbb01549f1248b1d714cafcd4400d", what: "revised once on review, merged as a fast-forward to the reviewed head", gate: "fresh clone of the Radicle mirror: build, 88/88 cases, 31 table checks PASS; negative control (the old cockpit main) fails 44 HTTP checks, as it must" }, + DeskMerge { repo: "CUDApp#373", rid: "rad:z4RxD8vXigmWg61nM8miQ8DVPAXEP", patch: "958571b55fb200d46e2f0a8cec367656c21c1f0a", head: "9714eba8f1ff5bca218edb075386f813eb524d9d", what: "an earlier head got MERGE_AFTER_FIX; the fixed head was re-reviewed and merged", gate: "fresh clone: encoder unit, golden and mutant suites pass; negative control (the base encoder) fails the new gate" }, + DeskMerge { repo: "omega-bridge#79", rid: "rad:z3Hr9ZaiKHwwuNzPK5M8c7uw6pj7y", patch: "3a95f707b281d49739d63dbd4581163f44d427a1", head: "882e3c061723205fbaf34c8a949e1be3451ac9e7", what: "merged as a fast-forward to the reviewed head", gate: "fresh clone: receipt checker golden and mutant tests and all suites pass; negative control (a wrong compiler) is refused" }, + DeskMerge { repo: "omega-mv (tape padding check)", rid: "rad:z6do9WDBhuSnvopDkgFdFr1yWA62", patch: "4dd099df31792d5ddb0d9fac5ca6d568513f4539", head: "215ea39afdc0cf1914cfadf43bbb6d23ce68c920", what: "merged as a fast-forward to the reviewed head", gate: "fresh clone: tape suite passes 351 checks; four mutants fail it, as they must; the base commit runs only 302 checks" }, + DeskMerge { repo: "omega-mv (bench baseline)", rid: "rad:z6do9WDBhuSnvopDkgFdFr1yWA62", patch: "88050ef7d710cb43d65214ff50bb1a0882770bb9", head: "3743d642cf034299009936eb8d458ba96a0a8589", what: "merged with merge commit da8b7e66 onto 215ea39a after a separate approval", gate: "fresh clone at the merge commit: integrity check and bench gate pass; negative controls (a wrong expected value, a swapped manifest) fail, as they must" }, +]; + +/// The three repositories the clone recipe names: protocol, language, replication. +const FORGE_CLONES: [(&str, &str); 3] = [ + ("interplane-mv", "rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa"), + ("omega-mv", "rad:z6do9WDBhuSnvopDkgFdFr1yWA62"), + ("cuda-crack", "rad:z631r2JJiVT8it4tST7RK24hpowi"), +]; + +/// The clean-user replication run of 7 Nov 2026, committed in cuda-crack. +const REPLICATION_RUN: &str = "a67dfa0a98bc09a301218a487af78e7c7738938c/replication/20261107T104021Z/summary.tsv"; + +/// The forge web app (forged): nginx serves this site's static files first and hands every +/// other path on interplane.io to it; the same app also answers under aienos.com/forge/. +pub const FORGE_EXPLORE: &str = "https://interplane.io/explore"; +const FORGE_AT_AIENOS: &str = "https://www.aienos.com/forge/"; + +pub fn forge_clone_commands() -> String { + let mut out = String::from("# with the Radicle CLI (radicle.xyz)\n"); + for (name, rid) in FORGE_CLONES { + out.push_str(&format!("rad clone {rid} # {name}\n")); + } + out.push_str("# or with plain git, from the read-only mirror\n"); + out.push_str(&format!("git clone {}\n", crate::facts::hub_clone_url(FORGE_CLONES[0].1))); + out.push_str("# replicate the host work from Radicle in a clean userspace\n"); + out.push_str("curl -fsSL https://www.aienos.com/replicate | sh"); + out +} + +/// Example of the live history views in the forge web app (answered 200 when the page was written). +const FORGE_HISTORY_EXAMPLE: &str = "https://interplane.io/drakestapleton/cuda-crack/commits/main"; + +fn forge(repos: usize) -> Markup { + let web = crate::facts::radicle_web; + html! { section class="prose" { + blockquote { + p { "\u{201C}GitHub flagged my agents. So I'm building the forge where agents express intent and the forge retains authority, on Radicle.\u{201D}" } + p class="fine" { "Drake Stapleton" } + } + h2 { "Why" } + p { "GitHub put an automated \u{201C}owner marked spammy\u{201D} flag on the aien-dev organisation after the write volume of about 20 agents; the appeal is filed and pending. While it is pending, Radicle main is the canonical home of these public repositories, and the GitHub front door is " a href="https://github.com/drakestapleton/sovereign-intelligence" { "drakestapleton/sovereign-intelligence" } "." } + h2 { "The rule" } + p { "INTERPLANE's protocol rule is that models express intent and runtimes retain authority. Forge applies the same rule to code hosting: agents express intent, the forge retains authority. An agent can open a Radicle patch. Only an exact-head review verdict, a gate with a negative control, and a person can merge it." } + h2 { "What runs today" } + ul { + li { (repos) " public repositories, counted from the registry, on Radicle, all delegated to one key, " code { "z6MkfZDue1TbaNFi3ZzcD9uiTeduPLC52ucdFVuLKZwexxhK" } ". They are replicated to the Radicle seed network; " a href="https://radicle.network/nodes/rosa.radicle.network" { "rosa.radicle.network" } " is one of the public seeds that serves them." } + li { "Each of the " (repos) " has a web view on radicle.network, for example " a href=(web("rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa")) { "interplane-mv" } ", and the AIEN hub seed serves each as a read-only git+HTTPS mirror at " code { "https://www.aienos.com/rad/.git" } "." } + li { "The desk protocol below merges patches into these repositories; the worked examples are five of its merges and one hold from 7 Nov 2026. There is one delegate key, and merges happen only by the desk protocol." } + li { "A clean-user run of the replicate script passed 26 of 26 required steps on 7 Nov 2026; the optional corpus and chip steps were NOT_RUN. " a href={ (web("rad:z631r2JJiVT8it4tST7RK24hpowi")) "/tree/" (REPLICATION_RUN) } { "Run summary" } "." } + } + h2 { "Browse the forge" } + p { "Browse the forge at " a href=(FORGE_EXPLORE) { "interplane.io/explore" } ", also at " a href=(FORGE_AT_AIENOS) { "aienos.com/forge" } ". The forge web app reads the same Radicle repositories. What it serves today:" } + ul class="stage-list" { + li { span class="pill ok" { "LIVE" } " " strong { "Explore" } ": the list of the " (repos) " public repositories." } + li { span class="pill ok" { "LIVE" } " " strong { "Repository pages" } ": description, latest commit, top-level files, README and the " code { "rad clone" } " command." } + li { span class="pill ok" { "LIVE" } " " strong { "Downloads" } ": zip and tar.gz archives of a branch." } + li { span class="pill ok" { "LIVE" } " " strong { "Releases" } ", plus the " strong { "issues" } " and " strong { "patches" } " lists." } + li { span class="pill ok" { "LIVE" } " " strong { "Code views" } ": file tree, file view and raw files at a branch." } + li { span class="pill ok" { "LIVE" } " " strong { "Sign-in with a Radicle key, and stars" } "." } + li { span class="pill ok" { "LIVE" } " " strong { "History views" } ": commit history, branches, tags, compare, blame and search inside a repository, for example " a href=(FORGE_HISTORY_EXAMPLE) { "the cuda-crack commit history" } "." } + } + h2 { "How a change merges" } + ol { + li { strong { "READY file." } " The agent finishes its branch, opens a Radicle patch and writes a READY file: repository, patch, exact head commit, base, and every gate it ran with its evidence label (HOST_TESTED, SIMULATED, NOT_RUN)." } + li { strong { "Exact-head verdict." } " An independent reviewer reads that head and writes one line, " code { "VERDICT MERGE head=<40-hex commit>" } ", or MERGE_AFTER_FIX with findings. A verdict covers one commit; any new commit needs a new verdict." } + li { strong { "Fresh-clone gate with a negative control." } " The desk refuses unless the patch head equals the reviewed commit, " code { "[ \"$H\" = \"\" ] || exit 1" } ", then clones fresh from the Radicle mirror and runs the repository's gate. A negative control, a known-bad input, must fail the same gate, or the gate proves nothing." } + li { strong { "Merge." } " Only then is the patch merged into main, pushed to Radicle under the delegate key and announced to the seeds. NOT_RUN is never counted as PASS." } + } + h2 { "Worked examples from 7 Nov 2026" } + ul class="report-list" { + @for m in &DESK_MERGES { + li { + strong { (m.repo) } ": patch " a href={ (web(m.rid)) "/patches/" (m.patch) } { code { (&m.patch[..8]) } } + ", verdict MERGE at head " a href={ (web(m.rid)) "/commits/" (m.head) } { code { (&m.head[..8]) } } ", " (m.what) ". Gate: " (m.gate) "." + } + } + li { strong { "aien-architecture-mv#382" } " (ADR 0046): " span class="pill wait" { "HELD" } " The reviewer returned MERGE_AFTER_FIX at head " code { "6daec174" } ", so it stays unmerged until a fixed head earns a MERGE verdict." } + } + h2 { "Try it" } + pre { code class="language-sh" aria-label="Clone from Radicle and replicate" { (forge_clone_commands()) } } + h2 { "Roadmap" } + p { "Everything in this section is planned, not running. It will be listed under What runs today only when it runs." } + ul class="stage-list" { + li { span class="pill none" { "PLANNED" } " " strong { "forge decide as the merge step" } ": the merge rule above (exact-head verdict, fresh-clone gate, negative control) is written as a seeded Omega core, " code { "forge/forge.om" } " in interplane-mv. It is HOST TESTED on the Spark: it replays real desk decisions (two MERGE, one HOLD) and its test suite catches every mutant. No forge runner applies it to patches yet, so merges still go through the desk protocol above. It reads Radicle through the " code { "rad" } " and " code { "git" } " command line tools; a native Omega reader is planned." } + li { span class="pill none" { "PLANNED" } " " strong { "Review in the web app" } ": READY files, verdicts and gate results beside each patch." } + li { span class="pill none" { "PLANNED" } " " strong { "Issue workflow" } ": issues tied to patches and verdicts, beyond today's read-only lists." } + li { span class="pill none" { "PLANNED" } " " strong { "CI runners" } ": gate runners that report back to the desk." } + li { span class="pill none" { "PLANNED" } " " strong { "Review federation" } ": accepting signed verdicts from reviewers on other nodes." } + } + h2 { "Built on Radicle" } + p { "Forge is a workflow and a set of gates on top of " a href="https://radicle.xyz/" { "Radicle" } ", the peer-to-peer code collaboration stack, and its protocol implementation " a href=(web("rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5")) { "Heartwood" } ". Radicle is built by the Radicle team, not by this project. Repositories, patches, signatures and seeding are Radicle's; the merge rule is INTERPLANE Forge's." } + }} +} + +fn forge_teaser(repos: usize) -> Markup { + html! { + section class="prose" id="forge" { + h2 { "INTERPLANE Forge" } + p { "GitHub flagged my agents' write volume, so I am building a forge on Radicle with INTERPLANE's own rule: agents express intent, the forge retains authority. Agents open patches; exact-head review verdicts, fresh-clone gates with negative controls, and people decide what merges. It runs today for " (repos) " public repositories, counted from the registry, and its web app is live at " a href=(FORGE_EXPLORE) { "interplane.io/explore" } ", commit history included; review in the web app beyond compose, the issue workflow, CI runners and review federation are still to come. " a href="/forge/" { "What runs today" } "." } + } + } +} + pub fn render(facts: &Facts) -> String { render_home(facts) } pub fn render_route(facts: &Facts, route: Route) -> String { if route==Route::Overview {return render(facts);} @@ -353,7 +526,11 @@ pub fn render_route(facts: &Facts, route: Route) -> String { a class="skip" href="#main" {"Skip to content"} (navigation(route)) main id="main" tabindex="-1" class="docs-main" { - section class="doc-intro prose" {p class="kicker" {"INTERPLANE / Developer documentation"} h1 {(route.label())} p class="section-lede" {(route.description())} } + section class="doc-intro prose" { + @if route==Route::Forge {p class="kicker" {"INTERPLANE / Forge"} h1 {"INTERPLANE Forge"}} + @else {p class="kicker" {"INTERPLANE / Developer documentation"} h1 {(route.label())}} + p class="section-lede" {(route.description())} + } (doc_content(facts,route)) (source_record(facts)) } (footer(facts)) @@ -365,7 +542,7 @@ fn footer(facts: &Facts) -> Markup { html! { footer { p {"Project context: " a href="https://www.aienos.com/" {"AIEN"} " / " a href="https://drakestapleton.com/" {"Drake Stapleton"} "."} - p { "INTERPLANE is developed in the open by " a href="https://github.com/aien-dev" { "aien-dev" } " as part of " a href="https://www.aienos.com/" { "AIEN" } ". Protocol and reference implementation: " (facts.pin.license) ". " a href=(SITE_REPO) { "This site" } " is built by a small Rust program from the repository's public record; no executable scripts, no outside fonts, no trackers." } + p { "INTERPLANE is developed in the open on " a href="https://radicle.xyz/" { "Radicle" } " as part of " a href="https://www.aienos.com/" { "AIEN" } ". Protocol and reference implementation: " (facts.pin.license) ". " a href=(SITE_REPO) { "This site" } " is built by a small Rust program from the repository's public record; no executable scripts, no outside fonts, no trackers." } p { "Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, architecture, constraints, acceptance criteria and stopping points; agents implement, execute checks, diagnose failures and revise within those boundaries. Human review retains responsibility for claims, acceptance and release decisions. This development method is distinct from runtime behavior." } p { "For the documented method and a systems-software case study, see Gregory M. Kurtzer, " a href="https://doi.org/10.5281/zenodo.23682548" { "Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed Agentic Engineering" } " (2026)." } } @@ -384,8 +561,11 @@ fn render_home(facts: &Facts) -> String { main id="main" tabindex="-1" { (problem()) (modules(facts)) + (longitudinal()) + (j_space(facts)) (receipt(facts)) (status(facts)) + (forge_teaser(facts.public_repos)) (get_started(facts)) (source_record(facts)) } diff --git a/crates/site-builder/src/routes.rs b/crates/site-builder/src/routes.rs index 1d7f98d..c5c842e 100644 --- a/crates/site-builder/src/routes.rs +++ b/crates/site-builder/src/routes.rs @@ -7,14 +7,16 @@ pub enum Route { Adapter, Conformance, Status, + Forge, } -pub const ALL: [Route; 6] = [ +pub const ALL: [Route; 7] = [ Route::Overview, Route::QuickStart, Route::Concepts, Route::Adapter, Route::Conformance, Route::Status, + Route::Forge, ]; impl Route { pub fn path(self) -> &'static str { @@ -25,6 +27,7 @@ impl Route { Self::Adapter => "/adapter/", Self::Conformance => "/conformance/", Self::Status => "/status/", + Self::Forge => "/forge/", } } pub fn file(self) -> String { @@ -38,6 +41,7 @@ impl Route { Self::Adapter => "Writing an Adapter", Self::Conformance => "Conformance", Self::Status => "Versioned Status", + Self::Forge => "Forge", } } pub fn description(self) -> &'static str { @@ -48,6 +52,7 @@ impl Route { Self::Adapter => "Follow INTERPLANE's canonical pinned Rust adapter guide, host-owned decisions and conformance requirements without assuming universal support.", Self::Conformance => "Trace INTERPLANE conformance, refusals and reported results to source-pinned fixtures and evidence, including failed and planned stages.", Self::Status => "Read INTERPLANE's versioned source status and exact Spark verification verdict from the canonical generated facts.", + Self::Forge => "INTERPLANE Forge, a GitHub replacement being built on Radicle: agents open patches, while exact-head verdicts, gates and people keep merge authority.", } } pub fn url(self) -> String { diff --git a/docs/LEGACY.md b/docs/LEGACY.md new file mode 100644 index 0000000..876d696 --- /dev/null +++ b/docs/LEGACY.md @@ -0,0 +1,112 @@ +# interplane.io + +Source of the website for [INTERPLANE](https://radicle.network/nodes/rosa.radicle.network/rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa) +(interplane-mv, `rad:zNhNbqYvgSBEHBq9vvE8xpbcBzGa` on Radicle): verification of AI completion +claims. A claim starts UNVERIFIED; it passes only on exact-source evidence from declared checks +with a negative control, and a PASS covers those checks on that revision, nothing more. + +Part of Sovereign Intelligence (SI). Aienix is retired. +[sovereign-intelligence](https://github.com/drakestapleton/sovereign-intelligence) is the integration, +release and install center, and the place where the signed Spark test runs. AienOS is only the +OS layer. INTERPLANE lives in its own repository. See aien-architecture ADR 0045 +(`docs/adr/0045-aienix-retired-sovereign-intelligence-center.md`). + +**Status (2026-10-18):** live at [interplane.io](https://interplane.io). The current Rust generator +landed on 2026-10-16 (pull request #4), and the page is rebuilt hourly. + +The page is not written by hand. A small Rust program, `crates/site-builder`, reads the protocol +repository's public record on Radicle through the radicle-httpd API of the seed +rosa.radicle.network (STATUS.md, ROADMAP.md, the stage reports, the latest tag, the open patches +and issues, the last merged patch), writes those facts to `facts.json`, and renders the page from +Rust source plus that file. Every figure on the page names the commit it was read at and links to +it on radicle.network. Radicle records no commit statuses, so the Spark verdict reads NO VERDICT. +The repository's identity has no canonical tag rule, so when its `refs.tags` is empty the latest tag +is read from the delegate's own refs (`/remotes/`) and shown as " (delegate tag)"; with no +tag anywhere the page reads "untagged". +The editorial copy lives in `crates/site-builder/src/page.rs`. + +Host edge dependency: the `facts` step shells out to `curl` (on the Spark: curl 8.5.0, +aarch64-unknown-linux-gnu, libcurl 8.5.0, OpenSSL 3.0.13) for HTTPS GET only. The site builder is +pre-rule Rust debt: it predates the Omega-core rule and is kept minimal, not extended. + +## Rules the page keeps + +`site-builder verify` refuses a build that breaks any of these: + +- no executable scripts, no outside fonts, no trackers; the only requests a visitor's browser makes are to interplane.io; +- one strictly parsed, HTML-safe `application/ld+json` block describes the website and exact protocol source pin; it runs no code; +- crawler files and every generated local target must match the build; `llms.txt` links all seven generated routes and pinned protocol documentation; +- sitemap dates are omitted rather than using hourly fetch time as a content-change date; +- the pinned commit of the protocol repository is on the page; +- the Spark verdict is shown as it is (PASS, FAIL, BLOCKED, RUNNING or NO VERDICT), never summarised; +- no mention of the removed Python SDK and no "draft" footer; +- `/forge/` carries no `github.com/aien-dev` link. + +No em or en dashes either. That one is a style rule and advisory: `site-builder style dist` +and the CI `style` job report it (as a warning in CI), and it never fails `verify`, a deploy or +the CI `test` job. + +## Build + +``` +cargo build --locked --release -p site-builder +target/release/site-builder facts # needs curl and network access to rosa.radicle.network; writes facts.json +target/release/site-builder build dist # renders all seven routes, copies public/, facts.json; the /forge/ + # repository count is table 1 of ~/handoffs/radicle/RIDS.md (or a third argument) +target/release/site-builder verify dist +``` + +`cargo test -p site-builder` renders a sample page and runs the same rules against it. + +## Developer onboarding candidate (issue #6) + +The route inventory in `crates/site-builder/src/routes.rs` generates Overview (`/`), +Quick Start (`/quick-start/`), Concepts (`/concepts/`), Writing an Adapter (`/adapter/`), +Conformance (`/conformance/`), Versioned Status (`/status/`) and INTERPLANE Forge (`/forge/`). +Each has a unique title, description and canonical, inert metadata and static HTML navigation. +`/forge/` describes the GitHub replacement I am building on Radicle: what runs today, with +worked examples from the desk protocol, and the planned roadmap. + +The Quick Start recipe has its own immutable protocol pin, explicitly separate from the +advancing source-status snapshot. Clone and Cargo fetch require network access; the scripted +exercise is offline after dependencies are fetched. It uses no real model or GPU. + +For the literal rendered recipe replay and route corruption controls, after building dist: + +```sh +python3 evidence/ONBOARDING-L642/qualify.py +``` + +This cold-clones the pinned source, so it needs network access and Git/Rust/Cargo. Raw receipts +and the source snapshot are in that evidence directory. The earlier `evidence/discoverability-issue7` +receipts describe their original pinned single-route source, not qualification of these new routes. + +## Hosting and automation + +The site is served by nginx on the project's Raspberry Pi house server. GitHub Pages is not used. +`scripts/sync-to-hub.sh` runs from cron on the Spark once an hour: it fast-forwards a clean clone +of this repository, rebuilds, refreshes the facts (keeping the last good facts if the Radicle seed is +unreachable), verifies, and copies the result to the house server only when something changed. It skips a +run while the Spark's quiet flag is held (the flag that reserves the machine for chip runs). + +## Files + +- `crates/site-builder/`: the generator (facts, page, verify). +- `public/style.css`: the one stylesheet; light and dark follow the reader's system setting. +- `public/hero.webp`: the hero illustration. +- `scripts/sync-to-hub.sh`: the hourly deploy. + +## License + +AGPL-3.0-or-later (see `LICENSE`). + +## Human-Directed Agentic Engineering + +Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, +architecture, constraints, acceptance criteria, and stopping points; agents implement, +execute checks, diagnose failures, and revise within those boundaries. Human review +retains responsibility for claims, acceptance, and release decisions. + +For the documented method and a systems-software case study, see Gregory M. Kurtzer, +*Ginux: Building an Independent Kernel That Runs Linux Userspace through Human-Directed +Agentic Engineering* (2026), https://doi.org/10.5281/zenodo.23682548. diff --git a/docs/RELEASE.md b/docs/RELEASE.md new file mode 100644 index 0000000..29f44b6 --- /dev/null +++ b/docs/RELEASE.md @@ -0,0 +1,177 @@ +# Review and publication + +This branch prepares a static website for operator publication. It does not +deploy, merge `main`, change DNS, provision hosting, or push to Radicle. The +existing hourly Spark job publishes `main` to the Raspberry Pi. A merge into +`main` therefore crosses the publication boundary. + +Canonical source is Radicle `rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV`, publicly viewed at +https://www.aienos.com/forge/drakestapleton/interplane.io and cloned from +`https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git`. The migration base +is canonical commit `b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858`. GitHub is a +secondary mirror; mirror Actions and pull requests do not authorize a canonical +merge or deployment. The existing advisory style job remains advisory. + +## Compiler provisioning + +The source pin is Omega commit +`f4df82394e35893dcf1354dda69a2fe028d94bc1`. The accepted compiler identities are: + +| Executable | SHA-256 | +| --- | --- | +| Pinned AArch64 compiler, `seed/out/omc` | `3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` | +| Native x86 compiler reproduced from that source | `79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd` | + +On Spark, provision a clean local checkout of the pinned Omega source. Set +`OMEGA_SRC` to that checkout, or set `OMC` to the pinned executable explicitly. +The default source path is `$HOME/workspace/omega-mv`; the default executable is +its `seed/out/omc`. This lookup is AArch64-only. On x86 Linux, `OMC` must be set. +The build helper refuses missing, non-executable or incorrectly hashed compilers. +It does not download a compiler during publication and does not accept a newer +compiler just because the checkout is named Omega. + +The unchanged public upstream seed text is included in `native/toolchain/seed/` +with its Apache-2.0 license, notice and SHA-256 manifest. Rebuild it without +downloading a compiler or supplying a GitHub secret: + +```sh +set -eu +QEMU=/path/to/qemu-aarch64-static sh scripts/build-seed.sh target/toolchain +export OMC="$PWD/target/toolchain/omc-x86" +``` + +On AArch64 Linux, omit `QEMU` and set `OMC` to the resulting `omc-aarch64` instead. +On x86 Linux install `qemu-aarch64-static` before the seed replay. The produced +`omc-x86` runs natively. An already provisioned pinned AArch64 compiler can also +run on x86 with `OMC_RUNNER` set to an installed `qemu-aarch64-static` executable. +CI replays the complete included seed chain, checks the expected intermediate +hashes, compiler fixed points and native x86 self-rebuild, then builds the site. +CI's Ubuntu-provided QEMU is host test infrastructure and is not part of the +seeded compiler trust claim. The original manual recipe remains in +[`../evidence/toolchain/REPRODUCE.md`](../evidence/toolchain/REPRODUCE.md). + +## Reproduce the release without publishing + +From the repository root, with `OMC` configured when required: + +```sh +set -eu +git rev-parse HEAD +git status --short +sh scripts/build-native.sh target/site-omega +python3 native/tests/check.py target/site-omega +sh scripts/tests/check-sync.sh +cargo test --locked +target/site-omega build target/release-review-a +target/site-omega verify target/release-review-a +target/site-omega build target/release-review-b +diff --recursive --no-dereference target/release-review-a target/release-review-b +sha256sum native/site.om target/site-omega +(cd target/release-review-a && find . -type f -print0) > target/release-files.list +LC_ALL=C sort -z target/release-files.list > target/release-files.sorted +(cd target/release-review-a && xargs -0 sha256sum < ../release-files.sorted) > target/release.sha256 +(cd target/release-review-a && sha256sum --check ../release.sha256) +sha256sum target/release.sha256 +``` + +The output directories must be fresh. Choose new names if they already exist. +The first-line `target x86linux` in `native/site.om` is retained for x86 output; +the helper removes only that line for AArch64 output. To exercise the AArch64 +target on an x86 host with a runnable pinned compiler: + +```sh +set -eu +sh scripts/build-native.sh target/site-omega-aarch64 aarch64 +python3 native/tests/check.py target/site-omega-aarch64 --runner /usr/bin/qemu-aarch64-static +qemu-aarch64-static target/site-omega-aarch64 build target/release-review-aarch64 +diff --recursive --no-dereference target/release-review-a target/release-review-aarch64 +``` + +These commands write no measured evidence receipts. The committed receipts +describe their recorded runs and inputs; a subsequent run does not silently +replace them. The source revision, hashes, commands and results for an accepted +release should be retained with that release. Verify any supplied archive with +`sha256sum --check` against its accompanying checksum manifest before extracting +it. The per-file manifest above validates the extracted website bytes. + +Review the built site through a local static HTTP server at desktop and mobile +sizes. Check navigation, collection filters, disclosure controls, downloads and +the actual contribution and Forge links. The Python fixture suite tests the native +builder, and the stub shell suite tests publication decisions without making +external writes. Neither replaces browser review of the real authored content. + +## Operator handover + +1. Review the canonical branch or Radicle patch, native check results, historical Rust test results, browser + observations, source attribution, licenses and release hashes. Confirm the + exact commit to publish. +2. Provision and hash-check the pinned compiler on Spark. Verify the cron + environment resolves `OMC` or `OMEGA_SRC`, as well as the existing `REPO`, + `HUB`, `WEBDIR` and `LOGDIR` settings. A checksum mismatch blocks publication. + Verify that the deployment checkout fetches the canonical Radicle repository. + The fallback clone URL remains the canonical HTTPS mirror. Repointing an + already-installed remote is an operator action, not a branch side effect. +3. Pause the existing publication schedule for the handover and let any active + legacy invocation finish. This avoids an already-running Rust-era script + publishing the historical page during the transition. The operator controls + the scheduling mechanism; this repository does not change it. +4. When the operator authorizes publication, merge the reviewed canonical patch + through the Radicle maintainer process and fast-forward the clean deployment checkout to + that commit. Run the non-publishing native build and verify on Spark using + fresh output directories. Restore the existing schedule after those checks. +5. The next eligible job checks quietlock, requires a clean checkout, updates + `main` by fast-forward only, compiles with the pinned Omega compiler, builds + fresh output and verifies it. It hashes every emitted path and file, so CSS, + SVG and download changes also trigger publication. Only a successful rsync + updates `published.sha256`; `.well-known` remains excluded from deletion. +6. After publication, verify the live HTTPS routes, download, styling and source + revision. Retain the operator's observed results separately from host-only + and emulated evidence. Check both the static `/forge/` page and the existing + dynamic Forge `/explore` route. The salvage catalog is `/yard/`, so it does not + take over Forge's explore path. No nginx or application service changes are + part of this release. + +The previous `published.cksum` tracked only HTML and facts. The new whole-tree +`published.sha256` deliberately causes the first native release to transfer. +The former last-good Radicle `facts.json` fallback is unused: reviewed +`content/facts.json` travels with the source revision and a failed native build +publishes nothing. The hosting destination and environment variable names stay +the same. The rsync update retains the existing non-atomic hosting behavior; a +network interruption can leave a partially updated remote tree. A pending marker +is created before transfer and cleared only after the successful receipt update. +A failed or interrupted transfer forces the next eligible run to retry, even if +the source reverts to the last successfully published digest. + +Rollback is an operator action: prepare and review a revert of the website +source on a branch, then merge through the normal maintainer process and allow +the scheduled job to rebuild it. Do not rewrite `main`, change signing keys or +skip the compiler and verifier gates. + +## Limits and unavailable publication paths + +The measured native and emulated checks are host-only. They do not qualify the +DGX Spark, Raspberry Pi hardware, a GPU, firmware or bare metal. Fixed-point +compiler hashes and deterministic file copies do not prove compiler correctness. +The native checker is a bounded policy checker for reviewed sources, not a +general HTML/CSS sanitizer. Read `native/README.md` for its filesystem and parser +limitations. The finite evidence-state checks do not establish correctness, +license compatibility or safety of contributed software. + +The authoritative Radicle repository RID is +`rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV`. No authorized Radicle signer was available +for this preparation, and no signed Radicle push is claimed. The prepared +branch can be reviewed and imported into the operator's existing Radicle +checkout; the operator must use an authorized signer for the canonical patch. +Do not generate a replacement identity or key to bypass this boundary. + +The canonical [patch page](https://www.aienos.com/forge/drakestapleton/interplane.io/patches) +documents this command for opening a patch from an already configured Radicle +checkout: + +```sh +git push rad HEAD:refs/patches +``` + +This is a separate operator action, not a command run by the release preparation. +Check the current branch and the `rad` remote's canonical RID before running it. +Opening a patch does not merge it or authorize the scheduled publication job. diff --git a/docs/RESEARCH.md b/docs/RESEARCH.md new file mode 100644 index 0000000..94d9d97 --- /dev/null +++ b/docs/RESEARCH.md @@ -0,0 +1,62 @@ +# Research basis for Interplane salvage records + +Research checked on 2026-11-09 using Scite and the primary sources linked below. These findings inform the design; they are not evidence that Interplane already implements automated repair, preservation, or independent reproduction. + +## 1. A passing patch is not necessarily a correct patch + +**Source:** Long, F., & Rinard, M. (2016). *An analysis of the search spaces for generate and validate patch generation systems*. ICSE, 702-713. + +- DOI: https://doi.org/10.1145/2884781.2884872 +- Primary manuscript: https://arxiv.org/pdf/1602.05643 +- Evidence retrieved: Scite metadata and full-text excerpts from the paper. + +**Method and finding.** The MIT authors analyze sixteen configurations of the SPR and Prophet patch search spaces. They distinguish plausible patches, which pass the validation test suite, from correct patches. Passing those tests does not establish correctness for inputs outside the suite. Test-suite strength affects how many incorrect candidates survive. + +**Design implication.** A salvaged component should expose the exact checks, inputs, results, environment, and artifact revision behind a claim. Use a scoped label such as "checks passed," retain known failures, and preserve the original failing example. A repair that removes useful behavior must not earn a success label merely because a narrow test stops failing. + +**Limits.** This is evidence about the studied systems and benchmarks. It does not establish a failure rate for all modern repair systems, LLM-generated changes, or Interplane. Independent tests and explicit specifications remain separate evidence. + +## 2. Reproduction requires the execution context + +**Source:** Chirigati, F., Rampin, R., Shasha, D., & Freire, J. (2016). *ReproZip: Computational reproducibility with ease*. SIGMOD, 2085-2088. + +- DOI: https://doi.org/10.1145/2882903.2899401 +- Author-hosted manuscript: https://fchirigati.com/files/papers/reprozip-sigmod206.pdf +- Evidence retrieved: Scite metadata and abstract; the author-hosted manuscript was then read directly because Scite did not provide its full text. + +**Method and finding.** ReproZip traces an existing experiment's execution, records its dependencies and provenance, and creates a package for replay through supported unpackers. Its recorded context includes command arguments, working directory, environment, input/output files, and software dependencies. This provides a concrete example of adding reproducibility to work that was not originally prepared for sharing. + +**Design implication.** Interplane should preserve a reproduction recipe alongside source: toolchain and dependency identities, environment, command, input, expected result, observed result, and output digest. Contributions may remain useful even when reproduction is incomplete, provided the missing pieces remain visible. Builders should review a package for secrets or proprietary material before sharing it. + +**Limits.** The described implementation uses Linux system-call tracing and supported virtual-machine/container unpackers. A captured run covers observed execution paths; it does not prove that every possible dependency or behavior was captured. Adopting this design principle does not require importing its runtime into Omega, and it does not establish that an Omega replacement already exists. + +## 3. Preserve identity and lineage when reusing content + +**Source:** Pietri, A., Spinellis, D., & Zacchiroli, S. (2019). *The Software Heritage Graph Dataset: Public software development under one roof*. MSR, 138-142. + +- DOI: https://doi.org/10.1109/MSR.2019.00030 +- Primary manuscript: https://www.softwareheritage.org/wp-content/uploads/2020/01/msr-2019-swh.pdf +- Primary project announcement: https://www.softwareheritage.org/2019/06/06/announcing-the-software-heritage-graph-dataset/ +- Related expanded manuscript retrieved in Scite: https://doi.org/10.48550/arXiv.2011.07824 +- Evidence retrieved: Scite bibliographic records and primary-source search excerpts. The 2019 PDF timed out; the documentation page returned an access-denied page. The detailed implementation was not verified. + +**Method and finding supported by the available excerpts.** The dataset connects file-content identities, directories, version-control revisions, and repository snapshots in a deduplicated graph. This preserves relationships between content and development history rather than treating a repository URL as a complete artifact identity. + +**Design implication.** Every extracted piece should retain its source URL, exact revision, content digest, attribution, license, and parent/derived-from relationship. Reusing identical content should not erase its origin. A digest identifies bytes; it does not establish authorship, permission, safety, or correctness. + +**Limits.** No claim is made here about current dataset size, preservation guarantees, licensing coverage, or compatibility with Interplane. The graph approach is a design reference, not an implemented Interplane archive. + +## Applied record and evidence model + +The following fields are design deductions from the sources, not a published universal schema: title, source URL, revision, content digest, creator attribution, license, what worked, known failures, dependencies, reproduction command, expected and observed result, environment, evidence links, and derived-from links. + +Evidence labels must name their scope: + +- **Submitted:** contributor-supplied description. +- **Examined:** an identified inspection has been recorded. +- **Checks passed:** named checks passed for an exact artifact identity. +- **Reproduced:** another recorded execution matched a declared result in its recorded environment. + +Known limitations remain visible after a successful check. Unknown provenance or license is recorded as unknown rather than inferred. No citation count or literature result is treated as evidence that this site has executed a submitted artifact. + +Evidence labels do not prove arbitrary submitted software correct. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md new file mode 100644 index 0000000..3b9f484 --- /dev/null +++ b/docs/VALIDATION.md @@ -0,0 +1,33 @@ +# Recorded validation + +Canonical base: `b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858`, from the official Radicle HTTPS mirror for `rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV`. The GitHub mirror was 13 commits behind and is only a secondary review copy. + +The static release contains 15 HTML pages, 24 files and 88,740 uncompressed bytes. These are measured counts and sizes, not latency or market comparisons. The existing native forge remains responsible for dynamic paths. + +| Check | Observed result | Receipt | +| --- | --- | --- | +| Native builder | 53 controls pass on x86 Linux | `native/evidence/native-tests.json` | +| AArch64 builder | 53 controls pass under QEMU | `native/evidence/aarch64-emulated-tests.json` | +| Real site | Two x86 builds and an emulated AArch64 build match all 24 inputs byte for byte | `native/evidence/real-build.json` | +| Preserved canonical Rust builder | 22 tests pass, one advisory style test intentionally ignored; redesigned CSS included | `evidence/legacy-cargo-tests.json` | +| Publication integration | Seed replay, 20 deployment controls, corrupt-compiler refusal and cross-architecture output checks pass | `evidence/publication-integration.json` | +| Lean 4.8.0 | Positive finite-model proofs accepted, empty axiom reports, deliberately false assertion rejected | `evidence/formal/lean-transcript.txt` | +| Wolfram | Recorded truth table, tautologies and ABI/config arithmetic | `evidence/formal/` | +| Authored pages | 258 local links/fragments resolve; canonical routes, unique IDs, titles, heading and image-alt checks pass | `evidence/site-review.json` | +| Browser | Desktop and narrow layouts, filters, disclosures, manifest and live forge destination inspected | `evidence/site-review.json` | + +Final sorted output manifest SHA-256: + +`1419d3a8408b0a2b0677f816433938c27b836b135b88f0d6365f3d27e054b1b6` + +The digest input is each sorted relative path represented as `SHA256`, two spaces, `path`, and a newline. Per-file hashes are in the real-build receipt. The deployment manifest uses `./`-prefixed paths, so its encoding produces a different digest. + +The source-only Omega bootstrap, original license and notice are included in `native/toolchain/`. The compiler reconstructs from the 408-byte seed and reproduces its recorded fixed points. Historical bootstrap receipts retain their original source-acquisition pins; the public harness listing uses a reachable canonical revision whose gate file is byte-identical. + +The initial GitHub issue destination returned 404 for public visitors. The corrected flow uses the existing Radicle forge, whose issue preparation page reached its expected Radicle-key sign-in state. Preparation produces text and a local publishing command; a contributor signs and publishes from their own node. No live contribution was submitted during validation. Contact fallback is the address published at https://www.aienos.com/contact/. + +The collection lives at `/yard/`; `/explore` and the other dynamic forge paths are not emitted. The static `/forge/` doorway preserves exact-revision checks, required negative controls, HOLD for missing or mismatched evidence, and human merge authority. The finite Lean label model does not prove this complete forge policy or implementation. + +The browser used 390px and 320px same-origin iframes, not physical phones. QEMU and the host are outside the seeded trust chain. These results are not compiler correctness proofs, upload-sanitizer certification, physical-hardware qualification, or independent human acceptance. Separate agent reviews are recorded as agent reviews. + +No production deployment or Radicle patch publication occurred. The canonical RID is known; an existing authorized Radicle signer is required for publication. Main-branch merge is a publication action because the existing cron job follows main. See `docs/RELEASE.md`. diff --git a/docs/superpowers/plans/2026-11-09-salvage.md b/docs/superpowers/plans/2026-11-09-salvage.md new file mode 100644 index 0000000..88b0854 --- /dev/null +++ b/docs/superpowers/plans/2026-11-09-salvage.md @@ -0,0 +1,11 @@ +# Executed rebuild plan + +1. Inspect canonical source and existing forge before integration. +2. Implement the welcoming static site, source-backed starter collection and actual contribution path. +3. Implement native `.om` assembly and bounded verification from a reproducible seeded compiler. +4. Preserve dynamic forge routes and canonical Radicle deployment behavior. +5. Run native controls, legacy compatibility, Lean/Wolfram checks, seed reconstruction and browser review. +6. Compare repeated builds, review the exact candidate, and package source, Git bundle, site and receipts. +7. Leave publication to the owner with an authorized Radicle signer; main is automatically deployed by the existing schedule. + +Results and limitations are in `docs/VALIDATION.md`; operator steps are in `docs/RELEASE.md`. diff --git a/docs/superpowers/specs/2026-11-09-salvage-design.md b/docs/superpowers/specs/2026-11-09-salvage-design.md new file mode 100644 index 0000000..f9882a3 --- /dev/null +++ b/docs/superpowers/specs/2026-11-09-salvage-design.md @@ -0,0 +1,15 @@ +# Interplane salvage rebuild + +Welcome unfinished builds and make reusable pieces discoverable with attribution, exact source and known limitations. Preserve the existing native Omega forge and its review semantics. + +Canonical base: Radicle `rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV` at `b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858`. The hidden GitHub mirror is a secondary review destination only. + +Routes: `/`, `/yard/`, `/contribute/`, `/how-it-works/`, `/mission/`, `/evidence/`, three `/pieces/` details, the five protocol documentation routes and `/forge/`. Never emit `/explore`, login, search or the other dynamic forge paths. + +Presentation: warm paper, dark ink, orange, pale lime; local SVG illustration; accessible native controls; responsive layouts; no browser JavaScript, external fonts or trackers. + +Contribution: existing forge issue preparation, Radicle-key sign-in, downloadable text and contributor-run signed publication. Published contact address is the fallback. No invented upload service, automatic repair, successful model training, community submissions or execution records. + +Build: executable assembly/verification logic in native `.om`; pinned source-only seed replay; literal declarative HTML/CSS/SVG/JSON inputs. Tests and Lean/Wolfram checks are separate verification infrastructure. + +Publication: preserve canonical mirror URL, Spark quietlock, clean main, fast-forward update, Pi hosting and `.well-known`; require pinned compiler, fresh verified output and whole-tree digest. Pending-transfer marker must force repair after failed transfer and rollback. Do not deploy or merge main while preparing the owner's publication candidate. diff --git a/downloads/contribution.md b/downloads/contribution.md new file mode 100644 index 0000000..6ee1ec4 --- /dev/null +++ b/downloads/contribution.md @@ -0,0 +1,27 @@ +# Bring your slop to Interplane + +## What did you build? + +## Source URL and exact revision + +## What still works? + +## What failed or remains unknown? + +## Original author and license + +## Reproduction command, dependencies and environment + +## Expected result and observed result + +## Evidence links and artifact SHA-256 (if available) + +## What can others reuse? + +Please do not include credentials, private data, or code you do not have permission to share. + +Prepare an issue at https://www.aienos.com/forge/drakestapleton/interplane.io/issues/new + +Sign in with your Radicle key. Preparation checks and stages text; it does not publish to Radicle. Download the prepared result and run the supplied command on your own node to sign and publish. + +Without a Radicle key, email drake@aienos.com with the subject "Interplane salvage" and your source link. The published contact details are at https://www.aienos.com/contact/. diff --git a/downloads/salvage-manifest.json b/downloads/salvage-manifest.json new file mode 100644 index 0000000..bd0d868 --- /dev/null +++ b/downloads/salvage-manifest.json @@ -0,0 +1,20 @@ +{ + "schema": "interplane.salvage.v1", + "title": "", + "original_source": "", + "revision": null, + "content_digest": null, + "creator_attribution": [], + "license": null, + "what_worked": "", + "known_failures": [], + "dependencies": [], + "reproduction_command": null, + "expected_result": null, + "observed_result": null, + "environment": null, + "evidence_links": [], + "derived_from": [], + "evidence_status": "submitted", + "notes": "Unknowns remain null. A manifest is contributor-supplied metadata, not a verification certificate." +} diff --git a/evidence/formal/PLAN.md b/evidence/formal/PLAN.md new file mode 100644 index 0000000..1ea73cf --- /dev/null +++ b/evidence/formal/PLAN.md @@ -0,0 +1,9 @@ +# Evidence-label model check + +1. Completed: define the bounded Boolean evidence-label model in Lean. +2. Completed: check the source with the pinned official Lean toolchain and record its output. +3. Completed: evaluate the same conjunction with Wolfram BooleanTable and TautologyQ. +4. Completed: record the sources, commands, outputs and limits together. + +The model concerns only label eligibility. It does not authenticate evidence, +prove submitted code correct, or prove equivalence to the site implementation. diff --git a/evidence/formal/README.md b/evidence/formal/README.md new file mode 100644 index 0000000..15d0faa --- /dev/null +++ b/evidence/formal/README.md @@ -0,0 +1,70 @@ +# Evidence-label model: checked + +MEASURED checker execution: Lean accepted `proofs/EvidenceLabels.lean` and +rejected an intentionally false eligibility assertion. The source hashes, +tool version, commands, exit statuses and actual output are in +`lean-transcript.txt`. Every theorem's axiom report is empty. + +MODELED rule: `eligibleForChecksPassed` is the conjunction of `pinnedSource`, +`environmentRecorded`, `recipeRecorded`, `executionRecorded` and `checksPassed`. +The Lean proofs establish that eligibility implies every field is true, any +false field prevents eligibility, the enumeration covers all field assignments, +and the sole accepting assignment has every field true. + +This is deliberately a small labeling-discipline model. It does not authenticate +those Boolean fields, prove submitted code correct, prove a check suite complete, +or establish equivalence to the website implementation. It supplies no product +correctness or hardware qualification claim. + +## Reproduce the Lean check + +The pinned toolchain is `leanprover/lean4:v4.8.0`, with no third-party Lean +dependencies. The checked official release archive is: + +https://github.com/leanprover/lean4/releases/download/v4.8.0/lean-4.8.0-linux.tar.zst + +Archive SHA-256: +`c1c6b8c431e0358de4ee75be3a1ced682fb6cedcef63c153adf268d267711a20` + +From the repository root, with that Linux toolchain extracted outside the repo: + +```sh +LEAN_BIN=/path/to/lean-4.8.0-linux/bin/lean bash proofs/check.sh +``` + +This execution container exposes `/proc/self/exe` but not `/proc/PID/exe`. +The unmodified Lean executable therefore initially failed before checking with +`error: failed to locate application`. Its official runtime source performs the +numeric process-path query in `src/runtime/io.cpp` at the pinned release. +The recorded successful execution used: + +```sh +LEAN_BIN=/path/to/lean-4.8.0-linux/bin/lean LEAN_PROC_SELF_COMPAT=1 bash proofs/check.sh +``` + +That opt-in compiles `proofs/proc-self-compat.c` into a temporary shared library +and preloads it only for the checker process. It redirects only the current +process's numeric executable-path query to `/proc/self/exe`; other queries pass +through. The official executable and mathematical kernel remain unchanged. +This is a checker startup compatibility dependency, not product code. The +transcript records source and official executable/shared-library hashes. +Temporary negative-control paths in that transcript are normalized to `TEMP/`. + +The runner checks the positive source, then appends an assertion that eligibility +is true when `checksPassed` is false. It requires Lean to reject that assertion +as false. A startup error cannot satisfy this negative control. + +## Wolfram cross-check + +`proofs/EvidenceLabels.wl` contains the exact evaluator input. +`wolfram-result.json` retains the tool name, input and actual tool response, +including the kernel version. Per-field implication and missing-field tautology +checks all returned `True`; the complete Boolean table has only the all-true +accepting assignment. This independently evaluates the same small modeled rule. + +`proofs/BuildConstants.wl` and `wolfram-build-constants.json` record the separately +requested ABI/config arithmetic. These are MODELED constants, not performance +or hardware measurements. The bitwise results are `193` and `133120`, octal file +modes convert to `420` and `493`, and the source-file bound and extra probe are +`1048576` bytes and `1048577` bytes respectively. The evaluator supplied no +formatted result URL; the exact responses are retained as files. diff --git a/evidence/formal/lean-transcript.txt b/evidence/formal/lean-transcript.txt new file mode 100644 index 0000000..4b80956 --- /dev/null +++ b/evidence/formal/lean-transcript.txt @@ -0,0 +1,49 @@ +Scope: bounded evidence-label model only +UTC: 2026-11-09T22:08:36Z +Base commit: 19ad981280ece61f6333624bbbd0ebc2b36c53be +Platform: Linux x86_64 +LEAN_BIN=/workspace/scratch/9e919d8c5b92/lean-toolchain/lean-4.8.0-linux/bin/lean +LEAN_PROC_SELF_COMPAT=1 +Command: cc -Wall -Wextra -Werror -shared -fPIC proofs/proc-self-compat.c -ldl -o TEMP/proc-self-compat.so +Command: lean --version +Lean (version 4.8.0, x86_64-unknown-linux-gnu, commit df668f00e6c0, Release) +Source and checker SHA-256: +5bf5a78bd51233c592b81a7e8064599f46796109cfe1717eaa01000758640ff6 proofs/EvidenceLabels.lean +61561b06f5587e027815fac8f59bf6ca160dfbf3f7372fc6297664acfd85b8c0 proofs/lean-toolchain +10be139a1186e2d6d03d321fc8e01c3baef05d27ba90d67f2560cdc6afd9efb6 proofs/proc-self-compat.c +ef0657a9ff210cf40c62c6f42d08e046398734c3cd526890bbfed8293c445f27 proofs/check.sh +c2059c8da4034467e5f391cfd07b81c4a7b32a7e04ff7e50c7c385993cd77010 /workspace/scratch/9e919d8c5b92/lean-toolchain/lean-4.8.0-linux/bin/lean +ee22a0db0023736a85c2fac93df68b013402419e413a7ebe33819be0249d9fad /workspace/scratch/9e919d8c5b92/lean-toolchain/lean-4.8.0-linux/lib/lean/libleanshared.so +ef9aea691a7eb9253d68779b39104cf79901a03a2de5d1e5daeb9e1a226647a6 /workspace/scratch/9e919d8c5b92/lean-toolchain/lean-4.8.0-linux/lib/lean/libInit_shared.so +Command: lean proofs/EvidenceLabels.lean +'Interplane.eligible_iff_all_true' does not depend on any axioms +'Interplane.eligible_implies_every_field' does not depend on any axioms +'Interplane.missing_any_field_prevents_acceptance' does not depend on any axioms +'Interplane.all_evidence_enumerated' does not depend on any axioms +'Interplane.sole_accepting_assignment' does not depend on any axioms +[{ pinnedSource := true, + environmentRecorded := true, + recipeRecorded := true, + executionRecorded := true, + checksPassed := true }] +Positive check exit status: 0 +Negative control: same source plus a false theorem asserting eligibility when checksPassed=false +Command: lean TEMP/FalseEvidenceLabel.lean +'Interplane.eligible_iff_all_true' does not depend on any axioms +'Interplane.eligible_implies_every_field' does not depend on any axioms +'Interplane.missing_any_field_prevents_acceptance' does not depend on any axioms +'Interplane.all_evidence_enumerated' does not depend on any axioms +'Interplane.sole_accepting_assignment' does not depend on any axioms +[{ pinnedSource := true, + environmentRecorded := true, + recipeRecorded := true, + executionRecorded := true, + checksPassed := true }] +TEMP/FalseEvidenceLabel.lean:79:2: error: tactic 'decide' proved that the proposition + Interplane.eligibleForChecksPassed + { pinnedSource := true, environmentRecorded := true, recipeRecorded := true, executionRecorded := true, + checksPassed := false } = + true +is false +Negative check exit status: 1 +Negative control rejected as expected diff --git a/evidence/formal/wolfram-build-constants.json b/evidence/formal/wolfram-build-constants.json new file mode 100644 index 0000000..45a59ec --- /dev/null +++ b/evidence/formal/wolfram-build-constants.json @@ -0,0 +1,17 @@ +{ + "tool": "WolframLanguageEvaluator", + "input": { + "code": "<|\"Kind\" -> \"MODELED ABI/config arithmetic; not hardware measurements\", \"WolframVersion\" -> $Version, \"OpenFlags\" -> BitOr[1, 64, 128], \"DirectoryFlags\" -> BitOr[131072, 2048], \"Mode644\" -> FromDigits[\"644\", 8], \"Mode755\" -> FromDigits[\"755\", 8], \"SourceFileLimitBytes\" -> 1048576, \"ExtraProbeBytes\" -> 1048576 + 1|>", + "timeConstraint": 20 + }, + "result": { + "content": [ + { + "type": "text", + "text": "Out[1]= <|\"Kind\" -> \"MODELED ABI/config arithmetic; not hardware measurements\", \"WolframVersion\" -> \"15.0.1 for Linux x86 (64-bit) (July 2, 2026)\", \"OpenFlags\" -> 193, \"DirectoryFlags\" -> 133120, \"Mode644\" -> 420, \"Mode755\" -> 493, \"SourceFileLimitBytes\" -> 1048576, \"ExtraProbeBytes\" -> 1048577|>" + } + ], + "structuredContent": null, + "isError": false + } +} diff --git a/evidence/formal/wolfram-result.json b/evidence/formal/wolfram-result.json new file mode 100644 index 0000000..8f44abd --- /dev/null +++ b/evidence/formal/wolfram-result.json @@ -0,0 +1,17 @@ +{ + "tool": "WolframLanguageEvaluator", + "input": { + "code": "With[{vars = {pinnedSource, environmentRecorded, recipeRecorded, executionRecorded, checksPassed}}, With[{eligible = And @@ vars}, <|\"WolframVersion\" -> $Version, \"FieldOrder\" -> (ToString /@ vars), \"ImplicationToEachField\" -> (TautologyQ[Implies[eligible, #], vars] & /@ vars), \"MissingEachFieldPreventsAcceptance\" -> (TautologyQ[Implies[Not[#], Not[eligible]], vars] & /@ vars), \"MissingAnyFieldPreventsAcceptance\" -> TautologyQ[Implies[Or @@ (Not /@ vars), Not[eligible]], vars], \"TruthTable\" -> BooleanTable[Join[vars, {eligible}], vars], \"AcceptingAssignments\" -> Select[BooleanTable[Join[vars, {eligible}], vars], Last[#] &]|>]]", + "timeConstraint": 20 + }, + "result": { + "content": [ + { + "type": "text", + "text": "Out[1]= <|\"WolframVersion\" -> \"15.0.1 for Linux x86 (64-bit) (July 2, 2026)\", \"FieldOrder\" -> {\"pinnedSource\", \"environmentRecorded\", \"recipeRecorded\", \"executionRecorded\", \"checksPassed\"}, \"ImplicationToEachField\" -> {True, True, True, True, True}, \"MissingEachFieldPreventsAcceptance\" -> {True, True, True, True, True}, \"MissingAnyFieldPreventsAcceptance\" -> True, \"TruthTable\" -> {{True, True, True, True, True, True}, {True, True, True, True, False, False}, {True, True, True, False, True, False}, {True, True, True, False, False, False}, {True, True, False, True, True, False}, {True, True, False, True, False, False}, {True, True, False, False, True, False}, {True, True, False, False, False, False}, {True, False, True, True, True, False}, {True, False, True, True, False, False}, {True, False, True, False, True, False}, {True, False, True, False, False, False}, {True, False, False, True, True, False}, {True, False, False, True, False, False}, {True, False, False, False, True, False}, {True, False, False, False, False, False}, {False, True, True, True, True, False}, {False, True, True, True, False, False}, {False, True, True, False, True, False}, {False, True, True, False, False, False}, {False, True, False, True, True, False}, {False, True, False, True, False, False}, {False, True, False, False, True, False}, {False, True, False, False, False, False}, {False, False, True, True, True, False}, {False, False, True, True, False, False}, {False, False, True, False, True, False}, {False, False, True, False, False, False}, {False, False, False, True, True, False}, {False, False, False, True, False, False}, {False, False, False, False, True, False}, {False, False, False, False, False, False}}, \"AcceptingAssignments\" -> {{True, True, True, True, True, True}}|>" + } + ], + "structuredContent": null, + "isError": false + } +} diff --git a/evidence/legacy-cargo-tests.json b/evidence/legacy-cargo-tests.json new file mode 100644 index 0000000..4fe8ebb --- /dev/null +++ b/evidence/legacy-cargo-tests.json @@ -0,0 +1,37 @@ +{ + "status": "PASS", + "scope": "Canonical Radicle Rust site-builder compatibility tests against the rebuilt site stylesheet; host-only, not native builder qualification or deployment", + "base_commit": "b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858", + "source_origin": "https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git", + "tested_inputs_changed_from_base": [ + "public/style.css" + ], + "source_note": "All tested Rust source, Cargo manifests/lock and legacy hero match canonical base; the new stylesheet is the only changed test input. No checkout/reset/restore was performed for this run.", + "command": "cargo test --locked -p site-builder", + "exit_code": 0, + "rustc": "1.99.1 (58cf8f9c3 2026-10-13)", + "cargo": "1.99.1 (5f94df478 2026-08-27)", + "passed": 22, + "failed": 0, + "ignored": 1, + "ignored_detail": "tests::style_rendered_routes_have_no_dashes is intentionally advisory; not run by this command", + "log": "evidence/legacy-cargo-tests.log", + "log_sha256": "006f997bd7d7cd633566ca74d4d7e337e1b8658ba1f8eca3681e5995fe1ba47c", + "inputs_sha256": { + "Cargo.lock": "6b82b81a1b267ba7733309ddd3f35fd42acc94fccd7e4c85d8d471304e850997", + "Cargo.toml": "ffab02392d85b7c867f0b03a1a44a4925cceecab71e488110182cd2e19130c61", + "crates/site-builder/Cargo.toml": "392f4a20f8d8f59f579db23756374c53f7b80b2cc8895be95a38165659166c7b", + "public/style.css": "385f646e420a4bfd74ede48b9c51b9ed97299ea3c5abcc30ce1b0fc7e609ad0b", + "public/hero.webp": "366d3a527d4799baea43cba4805de2acef7687f8b92d12b85f8ce5bafd028101", + "crates/site-builder/src/discovery.rs": "583d283eed441763c28b10edae1ebd90253b7e9c4c901d128332e0b09eac280d", + "crates/site-builder/src/facts.rs": "da4419f8eb414a12ce6816fb359116da89bf203918592f372653c79ff9d4bf0b", + "crates/site-builder/src/main.rs": "13395695e7662e47a3a82dd901d3b127804ae331fd61bb0febc751b787378065", + "crates/site-builder/src/page.rs": "17076c9e140d5184dee6ce67d1462e296b5e4c150ee2c8d0672c21064ded129e", + "crates/site-builder/src/routes.rs": "14b2cebf4862d1fd29801cd84681af23df7f0a91e0c06df444ada065bbd001e1" + }, + "official_component_sha256": { + "rustc": "2ff05ff9c08a90861e7f6e4065b40a8b87463b4576186fd613871c3e37f2091f", + "cargo": "53f3521949404d595efb06a55c12c5658d4ed1c75566f33d3d514eaebe70bd8a", + "rust-std": "109b074225bf5b9ea3820890876bfdf4ed161adbfaf94b2b4b5984c85ee5d958" + } +} diff --git a/evidence/legacy-cargo-tests.log b/evidence/legacy-cargo-tests.log new file mode 100644 index 0000000..12d7013 --- /dev/null +++ b/evidence/legacy-cargo-tests.log @@ -0,0 +1,30 @@ + Finished `test` profile [unoptimized + debuginfo] target(s) in 0.01s + Running unittests src/main.rs (/workspace/scratch/9e919d8c5b92/legacy-tools/target-canonical/debug/deps/site_builder-3dabbc55f5b7fdc8) + +running 23 tests +test facts::tests::delegate_tag_is_read_only_from_the_delegate ... ok +test facts::tests::headline_keeps_the_first_sentence_without_bold ... ok +test facts::tests::counts_status_rows_by_strongest_word ... ok +test facts::tests::radicle_record_fields_are_read ... ok +test facts::tests::reads_the_conformance_row ... ok +test facts::tests::release_label_names_a_delegate_tag ... ok +test facts::tests::short_date_reads_rfc3339 ... ok +test facts::tests::reads_stage_states_from_headings ... ok +test tests::failing_verdict_is_red_and_honest ... ok +test tests::no_verdict_is_said_plainly ... ok +test tests::home_evidence_links_follow_the_facts_pin_and_anchors_resolve ... ok +test tests::quick_start_matches_the_observed_pinned_example ... ok +test tests::no_route_links_the_aien_dev_github_organisation ... ok +test tests::release_shows_a_delegate_tag_and_untagged_without_one ... ok +test tests::rendered_page_passes_the_site_rules ... ok +test tests::style_rendered_routes_have_no_dashes ... ignored, advisory style rule (DRA-99): the CI style job runs it with --ignored +test tests::discoverability_is_inert_pinned_and_html_safe ... ok +test tests::onboarding_routes_are_complete_unique_and_verified ... ok +test tests::dashes_are_advisory_and_structure_still_fails_verify ... ok +test tests::forge_route_refuses_aien_dev_github_links ... ok +test tests::forge_count_comes_from_the_registry ... ok +test tests::remote_src_is_refused_but_external_links_remain_valid ... ok +test tests::built_discovery_files_and_corruption_are_verified ... ok + +test result: ok. 22 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.22s + diff --git a/evidence/publication-integration.json b/evidence/publication-integration.json new file mode 100644 index 0000000..d55a200 --- /dev/null +++ b/evidence/publication-integration.json @@ -0,0 +1,694 @@ +{ + "classification": "MEASURED", + "canonical_repository_rid": "rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV", + "canonical_base_commit": "b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858", + "canonical_clone_url": "https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git", + "canonical_invariants": { + "legacy_rust_and_license_unchanged": true, + "advisory_style_job_unchanged": true, + "sbom_job_unchanged": true, + "forge_static_route_retained": true, + "salvage_yard_route_present": true, + "dynamic_explore_not_shadowed_by_static_output": true, + "radicle_fallback_clone_preserved": true + }, + "scope": "Local host-only build and QEMU AArch64 execution; deployment behavior is a bounded shell test with external operations stubbed. No deployment or hardware qualification.", + "observed_at_utc": "2026-11-09T22:33:14.072199+00:00", + "source_git_head": "a0a3d89b155f55f5886c8fedd2f905e0dff34264", + "working_tree_inputs": "Dirty canonical review branch. Executable inputs match source_files; final source assets match final_release_input_sha256. No tracked source was restored or reset by these checks.", + "source_files": [ + { + "path": ".github/workflows/ci.yml", + "sha256": "b1b14eb87f83302f804fec2a2e7a140c8b9b3887fb49cd9f36fec97e02ecf062" + }, + { + "path": "AGENTS.md", + "sha256": "2a9362fe92c1956792f838e445e5a3de309eba626f1de6aefd89b8a51bbb3994" + }, + { + "path": "docs/RELEASE.md", + "sha256": "19daaebaca978fba159d39c14c4156ce8bb4204fb13dd752a303be42ca213565" + }, + { + "path": "scripts/build-native.sh", + "sha256": "66e4cd8181fcea55cdb8ac65e47168bfa2d42db78d7857b435c2db04a7c49427" + }, + { + "path": "scripts/build-seed.sh", + "sha256": "c314baa9b9f5d5c26f4444c7a4266fc62cb24710af7326b7403d145e7b25af26" + }, + { + "path": "scripts/sync-to-hub.sh", + "sha256": "ce133df23407ce5302906c2eade2d53dae08e51a2a2a47adb4c1714717b6de7b" + }, + { + "path": "scripts/tests/check-sync.sh", + "sha256": "ed7e0ac4edc69bd329f049077d800f0bec470c07c64f7de64b2a488090136336" + }, + { + "path": "native/site.om", + "sha256": "21912307990ca807dc5a580ddeb29ce8042a5457654541d2a76a403ec8e12fb3" + }, + { + "path": "native/tests/check.py", + "sha256": "2ea7a665f0b1cc0c340a997e0e596c85a1d5b187723a80ffd6dc2c64a73cb3f3" + }, + { + "path": "native/toolchain/SHA256SUMS", + "sha256": "af381c8f7bd701674eb9a281dc43bba30e278c37369ab3a990ee697ce861fd75" + }, + { + "path": "native/toolchain/README.md", + "sha256": "df755837e8db1ca70e5e0d144cc817f0170dd559df15279580473ca8213a3f3f" + } + ], + "qemu_sha256": "a27658c701c79bfb779cac181c3bfe4948236ac9415c11e2c4bb48e3c584a567", + "seed_source_repository": "https://github.com/aien-dev/omega-mv", + "seed_source_commit": "f4df82394e35893dcf1354dda69a2fe028d94bc1", + "upstream_visibility": "public, verified with connected GitHub repository metadata", + "upstream_exact_source_blobs": [ + { + "path": "seed/rung0/seed0.hex", + "expected_git_blob_sha1": "3c16777e8358d6c4a192c98f501518e38564aeee", + "observed_git_blob_sha1": "3c16777e8358d6c4a192c98f501518e38564aeee", + "match": true + }, + { + "path": "seed/rung1/hex1.hex", + "expected_git_blob_sha1": "8ca4d0cf8ec1e90cc2d5689cf59fe179f2dbc5e2", + "observed_git_blob_sha1": "8ca4d0cf8ec1e90cc2d5689cf59fe179f2dbc5e2", + "match": true + }, + { + "path": "seed/rung2/asm2.hex1", + "expected_git_blob_sha1": "f27da8deaa30e7bdc79c1441f335d7c649e1ba33", + "observed_git_blob_sha1": "f27da8deaa30e7bdc79c1441f335d7c649e1ba33", + "match": true + }, + { + "path": "seed/rung2/table.s2", + "expected_git_blob_sha1": "3b274e0f3d956c131da8531ed7d64a3f2c69daf4", + "observed_git_blob_sha1": "3b274e0f3d956c131da8531ed7d64a3f2c69daf4", + "match": true + }, + { + "path": "seed/rung3/table3.s2", + "expected_git_blob_sha1": "91b141f7394d02c514eaca495bad9cd90d652dba", + "observed_git_blob_sha1": "91b141f7394d02c514eaca495bad9cd90d652dba", + "match": true + }, + { + "path": "seed/rung4/table4.s2", + "expected_git_blob_sha1": "f2bf0f70a6d35a447e41890e8e457c225892dc2a", + "observed_git_blob_sha1": "f2bf0f70a6d35a447e41890e8e457c225892dc2a", + "match": true + }, + { + "path": "seed/rung4/om4.s", + "expected_git_blob_sha1": "deec39af2b3db32aff0cfdf7a5b6161fd5283f9e", + "observed_git_blob_sha1": "deec39af2b3db32aff0cfdf7a5b6161fd5283f9e", + "match": true + }, + { + "path": "seed/rung0/load0.sh", + "expected_git_blob_sha1": "b0449bf8a160e70f4468e84207caf6e9014d150c", + "observed_git_blob_sha1": "b0449bf8a160e70f4468e84207caf6e9014d150c", + "match": true + }, + { + "path": "seed/rung4/mk4.sh", + "expected_git_blob_sha1": "e0717af8ee816d0e7e4f54226669b9797d4f288c", + "observed_git_blob_sha1": "e0717af8ee816d0e7e4f54226669b9797d4f288c", + "match": true + }, + { + "path": "seed/omc/omc.om", + "expected_git_blob_sha1": "e2fc6e2fcf03243c2ed5d4af911804e73ce154aa", + "observed_git_blob_sha1": "e2fc6e2fcf03243c2ed5d4af911804e73ce154aa", + "match": true + }, + { + "path": "LICENSE", + "expected_git_blob_sha1": "d645695673349e3947e8e5ae42332d0ac3164cd7", + "observed_git_blob_sha1": "d645695673349e3947e8e5ae42332d0ac3164cd7", + "match": true + }, + { + "path": "NOTICE", + "expected_git_blob_sha1": "a1d3b1f8950e1089510f924178007c7263d169cc", + "observed_git_blob_sha1": "a1d3b1f8950e1089510f924178007c7263d169cc", + "match": true + } + ], + "raw_download_probe": { + "compiler_url": "https://raw.githubusercontent.com/aien-dev/omega-mv/f4df82394e35893dcf1354dda69a2fe028d94bc1/seed/out/omc", + "compiler_http_status": 404, + "source_url": "https://raw.githubusercontent.com/aien-dev/omega-mv/f4df82394e35893dcf1354dda69a2fe028d94bc1/seed/omc/omc.om", + "source_http_status": 404, + "scope": "Observed unauthenticated curl responses in this environment; not a claim that the repository is private. CI now uses the exact vendored source instead." + }, + "stub_control_count": 20, + "stub_controls": [ + "quietlock-skip", + "canonical-radicle-fallback-clone", + "dirty-checkout-refused", + "incorrect-compiler-hash-refused", + "missing-compiler-refused", + "compilation-failure-refused", + "build-failure-refused", + "verify-failure-refused", + "digest-failure-refused", + "clean-main-and-transfer-options", + "unchanged-release-skipped", + "stylesheet-only-change-published", + "failed-transfer-keeps-receipt-and-pending-marker", + "reverted-source-repairs-pending-transfer", + "later-release-retried", + "x86-target-retained", + "aarch64-first-line-only-removed", + "unexpected-target-header-refused", + "spark-default-compiler-lookup", + "x86-explicit-compiler-required" + ], + "checks": [ + { + "command": [ + "sh", + "-n", + "scripts/build-native.sh", + "scripts/build-seed.sh", + "scripts/sync-to-hub.sh", + "scripts/tests/check-sync.sh" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "" + }, + { + "command": [ + "sh", + "scripts/build-seed.sh", + "target/publication-verified/seed" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "$REPO/native/toolchain/SHA256SUMS: OK\nLICENSE: OK\nNOTICE: OK\nseed/omc/omc.om: OK\nseed/rung0/load0.sh: OK\nseed/rung0/seed0.hex: OK\nseed/rung1/hex1.hex: OK\nseed/rung2/asm2.hex1: OK\nseed/rung2/table.s2: OK\nseed/rung3/table3.s2: OK\nseed/rung4/mk4.sh: OK\nseed/rung4/om4.s: OK\nseed/rung4/table4.s2: OK\nseed0.bin: OK\nhex1.bin: OK\nasm2.bin: OK\nom4.bin: OK\nomc-stage1: OK\nomc-stage3: OK\nomc-x86: OK\nPASS native x86 compiler fixed point\nPASS pinned seed replay and AArch64 compiler fixed point\n", + "stderr": "" + }, + { + "command": [ + "sh", + "scripts/tests/check-sync.sh" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "PASS control: quietlock-skip\nPASS control: canonical-radicle-fallback-clone\nPASS control: dirty-checkout-refused\nPASS control: incorrect-compiler-hash-refused\nPASS control: missing-compiler-refused\nPASS control: compilation-failure-refused\nPASS control: build-failure-refused\nPASS control: verify-failure-refused\nPASS control: digest-failure-refused\nPASS control: clean-main-and-transfer-options\nPASS control: unchanged-release-skipped\nPASS control: stylesheet-only-change-published\nPASS control: failed-transfer-keeps-receipt-and-pending-marker\nPASS control: reverted-source-repairs-pending-transfer\nPASS control: later-release-retried\nPASS control: x86-target-retained\nPASS control: aarch64-first-line-only-removed\nPASS control: unexpected-target-header-refused\nPASS control: spark-default-compiler-lookup\nPASS control: x86-explicit-compiler-required\nPASS deployment orchestration: quietlock, clean main, compiler pin, build/verify refusals, whole-tree digest, transfer receipt, target selection and default compiler lookup; all external operations stubbed\n", + "stderr": "" + }, + { + "command": [ + "sh", + "scripts/build-native.sh", + "target/publication-verified/site-x86", + "x86_64" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "" + }, + { + "command": [ + "python3", + "native/tests/check.py", + "target/publication-verified/site-x86" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "PASS 53 native cases; deterministic byte-copy oracle matched 24 files\n", + "stderr": "" + }, + { + "command": [ + "sh", + "scripts/build-native.sh", + "target/publication-verified/site-arm", + "aarch64" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "" + }, + { + "command": [ + "python3", + "native/tests/check.py", + "target/publication-verified/site-arm", + "--runner", + "$QEMU" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "PASS 53 native cases; deterministic byte-copy oracle matched 24 files\n", + "stderr": "" + }, + { + "command": [ + "git", + "diff", + "--exit-code", + "b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858", + "--", + "crates/site-builder", + "Cargo.toml", + "Cargo.lock", + "LICENSE" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "" + }, + { + "command": [ + "target/publication-verified/site-x86", + "build", + "target/publication-verified/release-a" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "release_readiness_scope": "Superseded static inputs; retained as an actual earlier measurement" + }, + { + "command": [ + "target/publication-verified/site-x86", + "build", + "target/publication-verified/release-b" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "release_readiness_scope": "Superseded static inputs; retained as an actual earlier measurement" + }, + { + "command": [ + "target/publication-verified/site-x86", + "verify", + "target/publication-verified/release-a" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed\n", + "stderr": "", + "release_readiness_scope": "Superseded static inputs; retained as an actual earlier measurement" + }, + { + "command": [ + "diff", + "--recursive", + "--no-dereference", + "target/publication-verified/release-a", + "target/publication-verified/release-b" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "release_readiness_scope": "Superseded static inputs; retained as an actual earlier measurement" + }, + { + "command": [ + "$QEMU", + "target/publication-verified/site-arm", + "build", + "target/publication-verified/release-arm" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "release_readiness_scope": "Superseded static inputs; retained as an actual earlier measurement" + }, + { + "command": [ + "diff", + "--recursive", + "--no-dereference", + "target/publication-verified/release-a", + "target/publication-verified/release-arm" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "release_readiness_scope": "Superseded static inputs; retained as an actual earlier measurement" + }, + { + "command": [ + "sh", + "scripts/build-native.sh", + "target/publication-verified/must-not-exist" + ], + "exit": 3, + "expected_exit": 3, + "passed": true, + "stdout": "", + "stderr": "refuse: compiler SHA-256 is not the pinned Omega compiler: bdf8943bab9fe0678989f9b90b966e2844d46e29037306861c369d7f723d5998\n" + }, + { + "command": [ + "sh", + "scripts/tests/check-sync.sh" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "PASS control: quietlock-skip\nPASS control: canonical-radicle-fallback-clone\nPASS control: dirty-checkout-refused\nPASS control: incorrect-compiler-hash-refused\nPASS control: missing-compiler-refused\nPASS control: compilation-failure-refused\nPASS control: build-failure-refused\nPASS control: verify-failure-refused\nPASS control: digest-failure-refused\nPASS control: clean-main-and-transfer-options\nPASS control: unchanged-release-skipped\nPASS control: stylesheet-only-change-published\nPASS control: failed-transfer-keeps-receipt-and-pending-marker\nPASS control: reverted-source-repairs-pending-transfer\nPASS control: later-release-retried\nPASS control: x86-target-retained\nPASS control: aarch64-first-line-only-removed\nPASS control: unexpected-target-header-refused\nPASS control: spark-default-compiler-lookup\nPASS control: x86-explicit-compiler-required\nPASS deployment orchestration: quietlock, clean main, compiler pin, build/verify refusals, whole-tree digest, transfer receipt, target selection and default compiler lookup; all external operations stubbed\n", + "stderr": "", + "scope": "Current authored CSS and canonical working tree" + }, + { + "command": [ + "sh", + "scripts/build-native.sh", + "target/publication-css-refresh/site-x86", + "x86_64" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "scope": "Current authored CSS and canonical working tree" + }, + { + "command": [ + "sh", + "scripts/build-native.sh", + "target/publication-css-refresh/site-arm", + "aarch64" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "scope": "Current authored CSS and canonical working tree" + }, + { + "command": [ + "target/publication-css-refresh/site-x86", + "build", + "target/publication-css-refresh/release-a" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "scope": "Current authored CSS and canonical working tree", + "release_readiness_scope": "Superseded contribution download; retained as an actual earlier measurement" + }, + { + "command": [ + "target/publication-css-refresh/site-x86", + "build", + "target/publication-css-refresh/release-b" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "scope": "Current authored CSS and canonical working tree", + "release_readiness_scope": "Superseded contribution download; retained as an actual earlier measurement" + }, + { + "command": [ + "target/publication-css-refresh/site-x86", + "verify", + "target/publication-css-refresh/release-a" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed\n", + "stderr": "", + "scope": "Current authored CSS and canonical working tree", + "release_readiness_scope": "Superseded contribution download; retained as an actual earlier measurement" + }, + { + "command": [ + "diff", + "--recursive", + "--no-dereference", + "target/publication-css-refresh/release-a", + "target/publication-css-refresh/release-b" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "scope": "Current authored CSS and canonical working tree", + "release_readiness_scope": "Superseded contribution download; retained as an actual earlier measurement" + }, + { + "command": [ + "$QEMU", + "target/publication-css-refresh/site-arm", + "build", + "target/publication-css-refresh/release-arm" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "scope": "Current authored CSS and canonical working tree", + "release_readiness_scope": "Superseded contribution download; retained as an actual earlier measurement" + }, + { + "command": [ + "diff", + "--recursive", + "--no-dereference", + "target/publication-css-refresh/release-a", + "target/publication-css-refresh/release-arm" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "scope": "Current authored CSS and canonical working tree", + "release_readiness_scope": "Superseded contribution download; retained as an actual earlier measurement" + }, + { + "command": [ + "target/publication-css-refresh/site-x86", + "build", + "target/publication-contribution-refresh/release-a" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "scope": "Final contribution download with native Forge preparation and local Radicle publication instructions" + }, + { + "command": [ + "target/publication-css-refresh/site-x86", + "build", + "target/publication-contribution-refresh/release-b" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "scope": "Final contribution download with native Forge preparation and local Radicle publication instructions" + }, + { + "command": [ + "target/publication-css-refresh/site-x86", + "verify", + "target/publication-contribution-refresh/release-a" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed\n", + "stderr": "", + "scope": "Final contribution download with native Forge preparation and local Radicle publication instructions" + }, + { + "command": [ + "diff", + "--recursive", + "--no-dereference", + "target/publication-contribution-refresh/release-a", + "target/publication-contribution-refresh/release-b" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "scope": "Final contribution download with native Forge preparation and local Radicle publication instructions" + }, + { + "command": [ + "$QEMU", + "target/publication-css-refresh/site-arm", + "build", + "target/publication-contribution-refresh/release-arm" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified\n", + "stderr": "", + "scope": "Final contribution download with native Forge preparation and local Radicle publication instructions" + }, + { + "command": [ + "diff", + "--recursive", + "--no-dereference", + "target/publication-contribution-refresh/release-a", + "target/publication-contribution-refresh/release-arm" + ], + "exit": 0, + "expected_exit": 0, + "passed": true, + "stdout": "", + "stderr": "", + "scope": "Final contribution download with native Forge preparation and local Radicle publication instructions" + } + ], + "compiled_sha256": { + "omc-aarch64": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194", + "omc-x86": "79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd", + "site-x86": "60f6bb16847f2ecd7265fc5e6501546ea9839b9c99c4e79c14e0b8f897da700b", + "site-arm": "2169421739e07e173d95ee231edea7de9aa4925d951f5d1005b98944be14dbc7" + }, + "release_file_sha256": { + "adapter/index.html": "78d491dd5c3d85ac589cc332d0f757a749fa839b53baf213be0f423e1261b81d", + "concepts/index.html": "d814e0acb8322417a9465caf8dfc6cdb77d367e9ed0d244ccda83d8315182cc4", + "conformance/index.html": "208b579359faf99ead4b58540c2cc53a6f3cfaf35c59a6c14c81260885b336a6", + "contribute/index.html": "c2b17e046a993346c7048aa5480dbeee0aeeb7a6966e337cbe1b98b02adf89a2", + "downloads/contribution.md": "e369eaf6261e992b81e4f1e09a0605048ac33494865e688ab2be1f4cb0796c02", + "downloads/salvage-manifest.json": "c5555347967b1b0e096ac1b6830b22fa69110d7374935a5868b1a3c26bef9288", + "evidence/index.html": "817a35b6a872838126a08373bd26dfebbd0c936836964efb3a1212be0ecb8aa4", + "facts.json": "bbba71bd55040ad5c6fbc6fb0ecfe27672dedf73d6a726dd4c39e9a98e859734", + "forge/index.html": "35d925ed9ea1db7b93b318beb4bc0f8e88d3e012312bad242b8faea1b31edb3f", + "how-it-works/index.html": "673bcfb41f981dafeac87d8891ea4749ab70bb310613e4ed9e12bda71551f18d", + "index.html": "ad6829e857a4d72d3f5c546fb4c72a3152607acdd87fc9b89673bdac7e8af56b", + "llms.txt": "c5de4b571932796ae783c2663c2259788ac4ea13d304a64228d030928a9dcde1", + "mission/index.html": "f03f4cd31928bc2f7b9fdbf09f4bbb38641c7783d9e37883ab88ae94f3d76eb5", + "pieces/interplane-protocol/index.html": "778c427531596f3ded80be19826988f526dc65dba87088e30316b37003c2f29b", + "pieces/omega-harness/index.html": "ae6b68687bd8c40cf02d5e9d5a4b02bf813054718a3c67bd20844fe65f58f53b", + "pieces/weight-patch/index.html": "dea9e6c1eaa8480e6b48e4f4fa45e202ee7499e01d280520c01e3f9885567741", + "public/favicon.svg": "70318c1f16963d5c5ce69a41b0721cb7a142e5d8fb20c75482f821f81e7b5d36", + "public/orbit.svg": "c717534bdd68dd180d758f190d513c9d02eacf067c8bfc2a557a7184cb246a21", + "public/style.css": "385f646e420a4bfd74ede48b9c51b9ed97299ea3c5abcc30ce1b0fc7e609ad0b", + "quick-start/index.html": "f79a0d9f8f5a85ccc4789066b3339eb9d2c896e50bf508572af7ef18641adaf1", + "robots.txt": "0defd681f8cf39691173be8927654eb15f0a28adcb20527e8e19d2edc7be25c1", + "sitemap.xml": "862dd58e8d0450cf7279823c9963860888cbc90f327d671446ca3877a4fdd9e5", + "status/index.html": "958954012260fe5290d27c74087f67160c329019fa94c86679d099b3e52c01e8", + "yard/index.html": "2a5ccec66a88c41da2c800ead60ecb820867a2d2283760a2cff3fe8e63501109" + }, + "all_passed": true, + "superseded_release_checks": { + "reason": "The earlier static output used the canonical legacy stylesheet; the root restored the intended authored stylesheet and these fresh builds supersede that output for release readiness. Earlier seed, compiler, fixture and source-preservation measurements remain valid.", + "observed_at_utc": "2026-11-09T22:27:19.461146+00:00", + "release_file_sha256": { + "adapter/index.html": "78d491dd5c3d85ac589cc332d0f757a749fa839b53baf213be0f423e1261b81d", + "concepts/index.html": "d814e0acb8322417a9465caf8dfc6cdb77d367e9ed0d244ccda83d8315182cc4", + "conformance/index.html": "208b579359faf99ead4b58540c2cc53a6f3cfaf35c59a6c14c81260885b336a6", + "contribute/index.html": "c2b17e046a993346c7048aa5480dbeee0aeeb7a6966e337cbe1b98b02adf89a2", + "downloads/contribution.md": "1071bd925567fce3c8e0f15cb94da76f81e73293f079560cb11a50915a1dc958", + "downloads/salvage-manifest.json": "c5555347967b1b0e096ac1b6830b22fa69110d7374935a5868b1a3c26bef9288", + "evidence/index.html": "817a35b6a872838126a08373bd26dfebbd0c936836964efb3a1212be0ecb8aa4", + "facts.json": "bbba71bd55040ad5c6fbc6fb0ecfe27672dedf73d6a726dd4c39e9a98e859734", + "forge/index.html": "35d925ed9ea1db7b93b318beb4bc0f8e88d3e012312bad242b8faea1b31edb3f", + "how-it-works/index.html": "673bcfb41f981dafeac87d8891ea4749ab70bb310613e4ed9e12bda71551f18d", + "index.html": "ad6829e857a4d72d3f5c546fb4c72a3152607acdd87fc9b89673bdac7e8af56b", + "llms.txt": "c5de4b571932796ae783c2663c2259788ac4ea13d304a64228d030928a9dcde1", + "mission/index.html": "f03f4cd31928bc2f7b9fdbf09f4bbb38641c7783d9e37883ab88ae94f3d76eb5", + "pieces/interplane-protocol/index.html": "778c427531596f3ded80be19826988f526dc65dba87088e30316b37003c2f29b", + "pieces/omega-harness/index.html": "ae6b68687bd8c40cf02d5e9d5a4b02bf813054718a3c67bd20844fe65f58f53b", + "pieces/weight-patch/index.html": "dea9e6c1eaa8480e6b48e4f4fa45e202ee7499e01d280520c01e3f9885567741", + "public/favicon.svg": "70318c1f16963d5c5ce69a41b0721cb7a142e5d8fb20c75482f821f81e7b5d36", + "public/orbit.svg": "c717534bdd68dd180d758f190d513c9d02eacf067c8bfc2a557a7184cb246a21", + "public/style.css": "2855cfdabcf0f9c23ae414996601ff48545f3bb4eb5d1db58519df8fc8f86544", + "quick-start/index.html": "f79a0d9f8f5a85ccc4789066b3339eb9d2c896e50bf508572af7ef18641adaf1", + "robots.txt": "0defd681f8cf39691173be8927654eb15f0a28adcb20527e8e19d2edc7be25c1", + "sitemap.xml": "862dd58e8d0450cf7279823c9963860888cbc90f327d671446ca3877a4fdd9e5", + "status/index.html": "958954012260fe5290d27c74087f67160c329019fa94c86679d099b3e52c01e8", + "yard/index.html": "2a5ccec66a88c41da2c800ead60ecb820867a2d2283760a2cff3fe8e63501109" + } + }, + "working_tree_status_at_final_measurement": [ + " M downloads/contribution.md", + " M native/evidence/real-build.json" + ], + "final_release_input_sha256": { + "content/adapter/index.html": "78d491dd5c3d85ac589cc332d0f757a749fa839b53baf213be0f423e1261b81d", + "content/concepts/index.html": "d814e0acb8322417a9465caf8dfc6cdb77d367e9ed0d244ccda83d8315182cc4", + "content/conformance/index.html": "208b579359faf99ead4b58540c2cc53a6f3cfaf35c59a6c14c81260885b336a6", + "content/contribute/index.html": "c2b17e046a993346c7048aa5480dbeee0aeeb7a6966e337cbe1b98b02adf89a2", + "downloads/contribution.md": "e369eaf6261e992b81e4f1e09a0605048ac33494865e688ab2be1f4cb0796c02", + "downloads/salvage-manifest.json": "c5555347967b1b0e096ac1b6830b22fa69110d7374935a5868b1a3c26bef9288", + "content/evidence/index.html": "817a35b6a872838126a08373bd26dfebbd0c936836964efb3a1212be0ecb8aa4", + "content/facts.json": "bbba71bd55040ad5c6fbc6fb0ecfe27672dedf73d6a726dd4c39e9a98e859734", + "content/forge/index.html": "35d925ed9ea1db7b93b318beb4bc0f8e88d3e012312bad242b8faea1b31edb3f", + "content/how-it-works/index.html": "673bcfb41f981dafeac87d8891ea4749ab70bb310613e4ed9e12bda71551f18d", + "content/index.html": "ad6829e857a4d72d3f5c546fb4c72a3152607acdd87fc9b89673bdac7e8af56b", + "content/llms.txt": "c5de4b571932796ae783c2663c2259788ac4ea13d304a64228d030928a9dcde1", + "content/mission/index.html": "f03f4cd31928bc2f7b9fdbf09f4bbb38641c7783d9e37883ab88ae94f3d76eb5", + "content/pieces/interplane-protocol/index.html": "778c427531596f3ded80be19826988f526dc65dba87088e30316b37003c2f29b", + "content/pieces/omega-harness/index.html": "ae6b68687bd8c40cf02d5e9d5a4b02bf813054718a3c67bd20844fe65f58f53b", + "content/pieces/weight-patch/index.html": "dea9e6c1eaa8480e6b48e4f4fa45e202ee7499e01d280520c01e3f9885567741", + "public/favicon.svg": "70318c1f16963d5c5ce69a41b0721cb7a142e5d8fb20c75482f821f81e7b5d36", + "public/orbit.svg": "c717534bdd68dd180d758f190d513c9d02eacf067c8bfc2a557a7184cb246a21", + "public/style.css": "385f646e420a4bfd74ede48b9c51b9ed97299ea3c5abcc30ce1b0fc7e609ad0b", + "content/quick-start/index.html": "f79a0d9f8f5a85ccc4789066b3339eb9d2c896e50bf508572af7ef18641adaf1", + "content/robots.txt": "0defd681f8cf39691173be8927654eb15f0a28adcb20527e8e19d2edc7be25c1", + "content/sitemap.xml": "862dd58e8d0450cf7279823c9963860888cbc90f327d671446ca3877a4fdd9e5", + "content/status/index.html": "958954012260fe5290d27c74087f67160c329019fa94c86679d099b3e52c01e8", + "content/yard/index.html": "2a5ccec66a88c41da2c800ead60ecb820867a2d2283760a2cff3fe8e63501109" + }, + "final_output_manifest_sha256": "1419d3a8408b0a2b0677f816433938c27b836b135b88f0d6365f3d27e054b1b6", + "final_stylesheet_sha256": "385f646e420a4bfd74ede48b9c51b9ed97299ea3c5abcc30ce1b0fc7e609ad0b", + "release_refresh_history": [ + { + "reason": "Corrected the downloadable contribution instructions to use native Forge preparation and local Radicle publication. The previous CSS-restored release was measured accurately but is superseded for release readiness.", + "previous_observed_at_utc": "2026-11-09T22:30:10.928875+00:00", + "previous_output_manifest_sha256": "1da48bc5255b7737ec3aaecd0e7a7803f477705443d5df056ac2170bd8f56279", + "previous_contribution_sha256": "1071bd925567fce3c8e0f15cb94da76f81e73293f079560cb11a50915a1dc958" + } + ], + "final_contribution_sha256": "e369eaf6261e992b81e4f1e09a0605048ac33494865e688ab2be1f4cb0796c02" +} diff --git a/evidence/publication-integration.log b/evidence/publication-integration.log new file mode 100644 index 0000000..877aef9 --- /dev/null +++ b/evidence/publication-integration.log @@ -0,0 +1,170 @@ +$ sh -n scripts/build-native.sh scripts/build-seed.sh scripts/sync-to-hub.sh scripts/tests/check-sync.sh +exit: 0 + +$ sh scripts/build-seed.sh target/publication-verified/seed +$REPO/native/toolchain/SHA256SUMS: OK +LICENSE: OK +NOTICE: OK +seed/omc/omc.om: OK +seed/rung0/load0.sh: OK +seed/rung0/seed0.hex: OK +seed/rung1/hex1.hex: OK +seed/rung2/asm2.hex1: OK +seed/rung2/table.s2: OK +seed/rung3/table3.s2: OK +seed/rung4/mk4.sh: OK +seed/rung4/om4.s: OK +seed/rung4/table4.s2: OK +seed0.bin: OK +hex1.bin: OK +asm2.bin: OK +om4.bin: OK +omc-stage1: OK +omc-stage3: OK +omc-x86: OK +PASS native x86 compiler fixed point +PASS pinned seed replay and AArch64 compiler fixed point +exit: 0 + +$ sh scripts/tests/check-sync.sh +PASS control: quietlock-skip +PASS control: canonical-radicle-fallback-clone +PASS control: dirty-checkout-refused +PASS control: incorrect-compiler-hash-refused +PASS control: missing-compiler-refused +PASS control: compilation-failure-refused +PASS control: build-failure-refused +PASS control: verify-failure-refused +PASS control: digest-failure-refused +PASS control: clean-main-and-transfer-options +PASS control: unchanged-release-skipped +PASS control: stylesheet-only-change-published +PASS control: failed-transfer-keeps-receipt-and-pending-marker +PASS control: reverted-source-repairs-pending-transfer +PASS control: later-release-retried +PASS control: x86-target-retained +PASS control: aarch64-first-line-only-removed +PASS control: unexpected-target-header-refused +PASS control: spark-default-compiler-lookup +PASS control: x86-explicit-compiler-required +PASS deployment orchestration: quietlock, clean main, compiler pin, build/verify refusals, whole-tree digest, transfer receipt, target selection and default compiler lookup; all external operations stubbed +exit: 0 + +$ sh scripts/build-native.sh target/publication-verified/site-x86 x86_64 +exit: 0 + +$ python3 native/tests/check.py target/publication-verified/site-x86 +PASS 53 native cases; deterministic byte-copy oracle matched 24 files +exit: 0 + +$ sh scripts/build-native.sh target/publication-verified/site-arm aarch64 +exit: 0 + +$ python3 native/tests/check.py target/publication-verified/site-arm --runner $QEMU +PASS 53 native cases; deterministic byte-copy oracle matched 24 files +exit: 0 + +$ git diff --exit-code b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858 -- crates/site-builder Cargo.toml Cargo.lock LICENSE +exit: 0 + +$ target/publication-verified/site-x86 build target/publication-verified/release-a +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ target/publication-verified/site-x86 build target/publication-verified/release-b +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ target/publication-verified/site-x86 verify target/publication-verified/release-a +VERIFY PASS: bounded static policy checks passed +exit: 0 + +$ diff --recursive --no-dereference target/publication-verified/release-a target/publication-verified/release-b +exit: 0 + +$ $QEMU target/publication-verified/site-arm build target/publication-verified/release-arm +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ diff --recursive --no-dereference target/publication-verified/release-a target/publication-verified/release-arm +exit: 0 + +$ sh scripts/build-native.sh target/publication-verified/must-not-exist +refuse: compiler SHA-256 is not the pinned Omega compiler: bdf8943bab9fe0678989f9b90b966e2844d46e29037306861c369d7f723d5998 +exit: 3 + +Final CSS restoration checks. Earlier compiler/fixture results are retained; earlier real-content output is superseded. +$ sh scripts/tests/check-sync.sh +PASS control: quietlock-skip +PASS control: canonical-radicle-fallback-clone +PASS control: dirty-checkout-refused +PASS control: incorrect-compiler-hash-refused +PASS control: missing-compiler-refused +PASS control: compilation-failure-refused +PASS control: build-failure-refused +PASS control: verify-failure-refused +PASS control: digest-failure-refused +PASS control: clean-main-and-transfer-options +PASS control: unchanged-release-skipped +PASS control: stylesheet-only-change-published +PASS control: failed-transfer-keeps-receipt-and-pending-marker +PASS control: reverted-source-repairs-pending-transfer +PASS control: later-release-retried +PASS control: x86-target-retained +PASS control: aarch64-first-line-only-removed +PASS control: unexpected-target-header-refused +PASS control: spark-default-compiler-lookup +PASS control: x86-explicit-compiler-required +PASS deployment orchestration: quietlock, clean main, compiler pin, build/verify refusals, whole-tree digest, transfer receipt, target selection and default compiler lookup; all external operations stubbed +exit: 0 + +$ sh scripts/build-native.sh target/publication-css-refresh/site-x86 x86_64 +exit: 0 + +$ sh scripts/build-native.sh target/publication-css-refresh/site-arm aarch64 +exit: 0 + +$ target/publication-css-refresh/site-x86 build target/publication-css-refresh/release-a +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ target/publication-css-refresh/site-x86 build target/publication-css-refresh/release-b +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ target/publication-css-refresh/site-x86 verify target/publication-css-refresh/release-a +VERIFY PASS: bounded static policy checks passed +exit: 0 + +$ diff --recursive --no-dereference target/publication-css-refresh/release-a target/publication-css-refresh/release-b +exit: 0 + +$ $QEMU target/publication-css-refresh/site-arm build target/publication-css-refresh/release-arm +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ diff --recursive --no-dereference target/publication-css-refresh/release-a target/publication-css-refresh/release-arm +exit: 0 + +Contribution download correction: fresh real-content output checks. Earlier unchanged toolchain, native fixture and deployment controls are retained. +$ target/publication-css-refresh/site-x86 build target/publication-contribution-refresh/release-a +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ target/publication-css-refresh/site-x86 build target/publication-contribution-refresh/release-b +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ target/publication-css-refresh/site-x86 verify target/publication-contribution-refresh/release-a +VERIFY PASS: bounded static policy checks passed +exit: 0 + +$ diff --recursive --no-dereference target/publication-contribution-refresh/release-a target/publication-contribution-refresh/release-b +exit: 0 + +$ $QEMU target/publication-css-refresh/site-arm build target/publication-contribution-refresh/release-arm +BUILD PASS: reviewed static files copied and verified +exit: 0 + +$ diff --recursive --no-dereference target/publication-contribution-refresh/release-a target/publication-contribution-refresh/release-arm +exit: 0 diff --git a/evidence/site-review.json b/evidence/site-review.json new file mode 100644 index 0000000..284332a --- /dev/null +++ b/evidence/site-review.json @@ -0,0 +1,50 @@ +{ + "classification": "MEASURED", + "base": "b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858", + "canonical_origin": "https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git", + "pages": 15, + "files": 24, + "total_bytes": 88740, + "local_links_and_fragments_checked": 258, + "route_canonicals_ids_titles_h1_alt": "PASS", + "dynamic_forge_paths_not_shadowed": true, + "source_output_manifest_match": true, + "output_manifest_sha256": "1419d3a8408b0a2b0677f816433938c27b836b135b88f0d6365f3d27e054b1b6", + "browser": { + "engine": "Cloud Chrome", + "desktop_client_width": 1348, + "narrow_iframe_outer_widths": [ + 390, + 320 + ], + "narrow_client_widths": [ + 375, + 305 + ], + "horizontal_overflow_observed": false, + "verified_flows": [ + "Homepage to /yard", + "Protocols radio filter on canonical /yard", + "Static /forge doorway", + "Forge issue preparation link reaches live Radicle-key sign-in page", + "Manifest JSON navigation", + "Disclosure controls", + "Keyboard radio switching on same-layout earlier candidate" + ], + "contribution_destination": "https://www.aienos.com/forge/drakestapleton/interplane.io/issues/new", + "submission_scope": "Signed-out destination inspected; no Radicle login, issue preparation, signed publication or live merge performed.", + "screenshot_sha256": "2c3ccc686ed0225f2d484dcb7fe7190aa55db957baad026bd43415315f3a0df0" + }, + "corrections": [ + "Public GitHub issue CTA returned 404; replaced with existing Radicle forge preparation route.", + "Canonical Radicle base has 13 commits beyond frozen GitHub mirror; retained those changes.", + "Static collection moved from /explore to /yard because nginx routes existing /explore to native forge.", + "Harness public pin af497dcfa0da597688c0383227045ea1c2e1d813 verified to contain byte-identical gate.sh to historical bootstrap inspection pin.", + "Portable checklist corrected to the same forge preparation and local signed publication flow; no GitHub destination remains in emitted content." + ], + "limits": [ + "Not physical mobile device qualification or complete accessibility certification", + "No production deployment", + "Finite Lean model is not a proof of the full forge completion policy" + ] +} diff --git a/evidence/toolchain/REPRODUCE.md b/evidence/toolchain/REPRODUCE.md new file mode 100644 index 0000000..4a17258 --- /dev/null +++ b/evidence/toolchain/REPRODUCE.md @@ -0,0 +1,109 @@ +# Seeded Omega toolchain receipt + +Observed on 2026-11-09 on an x86_64 host. AArch64 bootstrap steps ran under QEMU user-mode; the resulting x86 compiler and hello program ran natively. This is host execution evidence, not DGX Spark, GPU, firmware, or bare-metal qualification. Byte identity is not a theorem that the compiler is correct. + +## Pins and observed identities + +| Artifact | Pin or SHA-256 | +| --- | --- | +| Omega source commit | `f4df82394e35893dcf1354dda69a2fe028d94bc1` | +| Harness source commit | `668e6adb3c6749e54a305a1144b09d2a11801300` | +| Pinned AArch64 omc, and seed-built stages 1, 2, 3 | `3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194` | +| Cross-built x86 omc and native self-rebuild | `79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd` | +| Ubuntu QEMU package | `a8f4e6121b7d1710885ba00fdb1e5a8256fb396f12ade2da9ed8a3693ad6d1bd` | + +The compiler pin is the existing harness pin, not a claim about Omega's latest main. Source was retrieved through the GitHub connector at the exact commit. `source-identity.json` compares each local source's Git blob SHA-1 with the returned Git blob identity. All comparisons passed before the recorded replay. The checked sources are byte-for-byte identical to the pin. SHA-1 here identifies Git's existing blobs; release artifacts additionally have SHA-256. + +The QEMU package came from Ubuntu's official download link: +https://security.ubuntu.com/ubuntu/pool/universe/q/qemu/qemu-user-static_8.2.2+ds-0ubuntu1.16_amd64.deb + +Its SHA-256 matches the official package page: +https://packages.ubuntu.com/noble/amd64/qemu-user-static/download + +The package was extracted into temporary tool storage. No emulator or compiler binary is included in this repository. QEMU is a bootstrap/testing dependency, not a website runtime dependency. + +## What ran + +`bootstrap-receipt.json` records the actual commands, exit codes, file hashes and byte comparisons. It contains 22 recorded checks: + +- The 408-byte seed0 was produced from the pinned hexadecimal source, then reproduced itself exactly. +- seed0 built hex1; hex1 reproduced itself exactly. +- hex1 built asm2; asm2 built om4 from the pinned tables and assembly. +- om4 built omc; omc rebuilt itself twice. All three outputs exactly matched the downloaded harness-pinned compiler. +- The pinned compiler cross-built its own source with `target x86linux` prepended. +- That x86 compiler rebuilt itself natively to identical bytes. +- The AArch64 compiler and native x86 compiler produced byte-identical x86 hello executables. +- Native hello exited 0 and printed exactly `hello, world\n`. +- An undefined identifier was refused with exit 3. Refused output was not run. + +The hello source is the harness's `examples/hello.om` with only `target x86linux` prepended. These are focused toolchain checks. The complete harness example suite was not run. + +## Reproduce from the pinned source + +Prerequisites: a clean local checkout of the pinned Omega and harness revisions, POSIX shell and core utilities, and the verified QEMU user-mode executable. Set `OMEGA_SRC`, `HARNESS_SRC`, `QEMU` and `TOOLCHAIN` to local paths. `TOOLCHAIN` must be a fresh empty directory. The recipe does not touch the source checkouts. + +```sh +set -eu +test "$(git -C "$OMEGA_SRC" rev-parse HEAD)" = f4df82394e35893dcf1354dda69a2fe028d94bc1 +test "$(git -C "$HARNESS_SRC" rev-parse HEAD)" = 668e6adb3c6749e54a305a1144b09d2a11801300 +mkdir -p "$TOOLCHAIN" +cd "$TOOLCHAIN" + +sh "$OMEGA_SRC/seed/rung0/load0.sh" "$OMEGA_SRC/seed/rung0/seed0.hex" seed0.bin +chmod +x seed0.bin +"$QEMU" ./seed0.bin < "$OMEGA_SRC/seed/rung0/seed0.hex" > seed0.self +cmp seed0.bin seed0.self + +"$QEMU" ./seed0.bin < "$OMEGA_SRC/seed/rung1/hex1.hex" > hex1.bin +chmod +x hex1.bin +"$QEMU" ./hex1.bin < "$OMEGA_SRC/seed/rung1/hex1.hex" > hex1.self +cmp hex1.bin hex1.self + +"$QEMU" ./hex1.bin < "$OMEGA_SRC/seed/rung2/asm2.hex1" > asm2.bin +chmod +x asm2.bin +cat "$OMEGA_SRC/seed/rung2/table.s2" "$OMEGA_SRC/seed/rung3/table3.s2" \ + "$OMEGA_SRC/seed/rung4/table4.s2" "$OMEGA_SRC/seed/rung4/om4.s" > om4.input +"$QEMU" ./asm2.bin < om4.input > om4.bin +chmod +x om4.bin +test "$(wc -c < om4.bin)" -eq 14224 + +"$QEMU" ./om4.bin < "$OMEGA_SRC/seed/omc/omc.om" > omc-stage1 +chmod +x omc-stage1 +"$QEMU" ./omc-stage1 < "$OMEGA_SRC/seed/omc/omc.om" > omc-stage2 +chmod +x omc-stage2 +"$QEMU" ./omc-stage2 < "$OMEGA_SRC/seed/omc/omc.om" > omc-stage3 +cmp omc-stage1 omc-stage2 +cmp omc-stage2 omc-stage3 +cmp omc-stage3 "$OMEGA_SRC/seed/out/omc" +sha256sum omc-stage1 omc-stage2 omc-stage3 + +{ printf 'target x86linux\n'; cat "$OMEGA_SRC/seed/omc/omc.om"; } > omc-x86-source.om +"$QEMU" ./omc-stage2 < omc-x86-source.om > omc-x86 +chmod +x omc-x86 +./omc-x86 < omc-x86-source.om > omc-x86-stage2 +cmp omc-x86 omc-x86-stage2 +sha256sum omc-x86 + +{ printf 'target x86linux\n'; cat "$HARNESS_SRC/examples/hello.om"; } > hello.om +"$QEMU" ./omc-stage2 < hello.om > hello-cross +./omc-x86 < hello.om > hello-native +cmp hello-cross hello-native +chmod +x hello-native +./hello-native > hello.stdout +printf 'hello, world\n' > hello.expected +cmp hello.stdout hello.expected + +printf 'target x86linux\nfn main to int\nret missing\nend\n' > negative.om +rc=0 +./omc-x86 < negative.om > negative-output 2> negative.stderr || rc=$? +test "$rc" -eq 3 +cat negative.stderr +``` + +The om4 header already declares 14224 bytes at this pin. The upstream `mk4.sh` normally updates that measured size before assembling again. This replay used the unchanged pinned source and verified the size; it did not rewrite the assembly. + +## Scope and setup corrections + +Initial setup attempts were not acceptance runs: apt's default sandbox UID switch failed, and the first explicit QEMU seed invocation had not set executable permissions. The apt attempt was stopped after an official package download provided the required emulator. Source text initially acquired an extra terminal newline through the patch transport; the extra byte was removed and every source blob identity checked before the recorded replay. No compiler source or language semantics were modified. + +The fixed point checks establish byte equality for these inputs and this execution path. They do not independently establish all compiler semantics, all harness cases, or seed security. QEMU and the host remain outside the seeded trust chain. diff --git a/evidence/toolchain/bootstrap-receipt.json b/evidence/toolchain/bootstrap-receipt.json new file mode 100644 index 0000000..12463e8 --- /dev/null +++ b/evidence/toolchain/bootstrap-receipt.json @@ -0,0 +1,356 @@ +{ + "status": "PASS", + "scope": "Host CPU and QEMU user-mode only. Not hardware qualification or proof of compiler correctness.", + "observed_at_utc": "2026-11-09T22:05:17.318627+00:00", + "host_arch": "x86_64", + "omega_commit": "f4df82394e35893dcf1354dda69a2fe028d94bc1", + "harness_commit": "668e6adb3c6749e54a305a1144b09d2a11801300", + "checks": [ + { + "check": "load seed0", + "command": [ + "sh", + "seed/rung0/load0.sh", + "seed/rung0/seed0.hex", + "seed0.bin" + ], + "stdin": null, + "stdout_file": null, + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": "", + "pass": true + }, + { + "check": "seed0 self rebuild", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/seed0.bin" + ], + "stdin": "bootstrap/seed/rung0/seed0.hex", + "stdout_file": "bootstrap/seed0.self", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "seed0 identity", + "files": [ + "bootstrap/seed0.bin", + "bootstrap/seed0.self" + ], + "pass": true + }, + { + "check": "build hex1", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/seed0.bin" + ], + "stdin": "bootstrap/seed/rung1/hex1.hex", + "stdout_file": "bootstrap/hex1.bin", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "hex1 self rebuild", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/hex1.bin" + ], + "stdin": "bootstrap/seed/rung1/hex1.hex", + "stdout_file": "bootstrap/hex1.self", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "hex1 identity", + "files": [ + "bootstrap/hex1.bin", + "bootstrap/hex1.self" + ], + "pass": true + }, + { + "check": "build asm2", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/hex1.bin" + ], + "stdin": "bootstrap/seed/rung2/asm2.hex1", + "stdout_file": "bootstrap/asm2.bin", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "build om4", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/asm2.bin" + ], + "stdin": "bootstrap/om4.input", + "stdout_file": "bootstrap/om4.bin", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "build omc stage1", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/om4.bin" + ], + "stdin": "omc.om", + "stdout_file": "bootstrap/omc-stage1", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "build omc stage2", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/omc-stage1" + ], + "stdin": "omc.om", + "stdout_file": "bootstrap/omc-stage2", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "build omc stage3", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/bootstrap/omc-stage2" + ], + "stdin": "omc.om", + "stdout_file": "bootstrap/omc-stage3", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "stage1 stage2", + "files": [ + "bootstrap/omc-stage1", + "bootstrap/omc-stage2" + ], + "pass": true + }, + { + "check": "stage2 stage3", + "files": [ + "bootstrap/omc-stage2", + "bootstrap/omc-stage3" + ], + "pass": true + }, + { + "check": "pinned compiler identity", + "files": [ + "bootstrap/omc-stage3", + "omc-aarch64" + ], + "pass": true + }, + { + "check": "cross build x86 compiler", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/omc-aarch64" + ], + "stdin": "omc-x86-source.om", + "stdout_file": "omc-x86", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "native x86 self rebuild", + "command": [ + "$TOOLCHAIN/omc-x86" + ], + "stdin": "omc-x86-source.om", + "stdout_file": "omc-x86-stage2", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "native x86 fixpoint", + "files": [ + "omc-x86", + "omc-x86-stage2" + ], + "pass": true + }, + { + "check": "cross compile hello", + "command": [ + "$TOOLCHAIN/qemu/usr/bin/qemu-aarch64-static", + "$TOOLCHAIN/omc-aarch64" + ], + "stdin": "hello.om", + "stdout_file": "hello-x86", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "native compile hello", + "command": [ + "$TOOLCHAIN/omc-x86" + ], + "stdin": "hello.om", + "stdout_file": "hello-x86-native", + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": null, + "pass": true + }, + { + "check": "hello compiler equivalence", + "files": [ + "hello-x86", + "hello-x86-native" + ], + "pass": true + }, + { + "check": "execute native hello", + "command": [ + "$TOOLCHAIN/hello-x86-native" + ], + "stdin": null, + "stdout_file": null, + "exit": 0, + "expected_exit": 0, + "stderr": "", + "stdout": "hello, world\n", + "pass": true + }, + { + "check": "reject undefined identifier", + "command": [ + "$TOOLCHAIN/omc-x86" + ], + "stdin": "negative.om", + "stdout_file": "negative-output", + "exit": 3, + "expected_exit": 3, + "stderr": "omc: line 3: error 3\n", + "stdout": null, + "pass": true + } + ], + "files": [ + { + "path": "omc-aarch64", + "bytes": 625676, + "sha256": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194" + }, + { + "path": "omc.om", + "bytes": 314160, + "sha256": "0effe37afc4ddd0507151c9f2afa34b3e6774eae7006cbecd8c59f11bc386db7" + }, + { + "path": "omc-x86-source.om", + "bytes": 314176, + "sha256": "dbbb1327ac4ae4b5d69f638b4d500f2278304d9a6bcc62a5aa4b8b1fb0f09c20" + }, + { + "path": "omc-x86", + "bytes": 4829859, + "sha256": "79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd" + }, + { + "path": "omc-x86-stage2", + "bytes": 4829859, + "sha256": "79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd" + }, + { + "path": "hello.om", + "bytes": 202, + "sha256": "eff8f3da33ae97b1826dde7ec0c35dc4f6a378f70f877b42d3d853fad9c8a29f" + }, + { + "path": "hello-x86", + "bytes": 1557, + "sha256": "488fcd2a44d7aafcd4748e3cd2cc668bacd895299553b0e8eba4e4055a95f3d7" + }, + { + "path": "qemu-user-static.deb", + "bytes": 14628452, + "sha256": "a8f4e6121b7d1710885ba00fdb1e5a8256fb396f12ade2da9ed8a3693ad6d1bd" + }, + { + "path": "qemu/usr/bin/qemu-aarch64-static", + "bytes": 6245592, + "sha256": "a27658c701c79bfb779cac181c3bfe4948236ac9415c11e2c4bb48e3c584a567" + }, + { + "path": "bootstrap/seed0.bin", + "bytes": 408, + "sha256": "aca00cf3677236809f0f223437398c6bb429e4c65f13d58762bcf96d13799474" + }, + { + "path": "bootstrap/hex1.bin", + "bytes": 776, + "sha256": "920e1756aec399c7c74f5cedd1676abb91b844ea75448e14aa50dcb0bbc7ba5d" + }, + { + "path": "bootstrap/asm2.bin", + "bytes": 2464, + "sha256": "6988abe072fac3cdef2240d5ad13a3ecd8fb576fa09112d344b9e7c2315969c4" + }, + { + "path": "bootstrap/om4.bin", + "bytes": 14224, + "sha256": "d0da40e45f1fcc45d9a39c9c52c9d745b545e076970729e51c12d76ef519efab" + }, + { + "path": "bootstrap/omc-stage1", + "bytes": 625676, + "sha256": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194" + }, + { + "path": "bootstrap/omc-stage2", + "bytes": 625676, + "sha256": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194" + }, + { + "path": "bootstrap/omc-stage3", + "bytes": 625676, + "sha256": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194" + } + ] +} diff --git a/evidence/toolchain/source-identity.json b/evidence/toolchain/source-identity.json new file mode 100644 index 0000000..a04cd9a --- /dev/null +++ b/evidence/toolchain/source-identity.json @@ -0,0 +1,66 @@ +{ + "repository": "https://github.com/aien-dev/omega-mv", + "commit": "f4df82394e35893dcf1354dda69a2fe028d94bc1", + "sources": [ + { + "path": "bootstrap/seed/rung0/seed0.hex", + "git_blob_sha1": "3c16777e8358d6c4a192c98f501518e38564aeee", + "local_git_blob_sha1": "3c16777e8358d6c4a192c98f501518e38564aeee", + "match": true + }, + { + "path": "bootstrap/seed/rung1/hex1.hex", + "git_blob_sha1": "8ca4d0cf8ec1e90cc2d5689cf59fe179f2dbc5e2", + "local_git_blob_sha1": "8ca4d0cf8ec1e90cc2d5689cf59fe179f2dbc5e2", + "match": true + }, + { + "path": "bootstrap/seed/rung2/asm2.hex1", + "git_blob_sha1": "f27da8deaa30e7bdc79c1441f335d7c649e1ba33", + "local_git_blob_sha1": "f27da8deaa30e7bdc79c1441f335d7c649e1ba33", + "match": true + }, + { + "path": "bootstrap/seed/rung2/table.s2", + "git_blob_sha1": "3b274e0f3d956c131da8531ed7d64a3f2c69daf4", + "local_git_blob_sha1": "3b274e0f3d956c131da8531ed7d64a3f2c69daf4", + "match": true + }, + { + "path": "bootstrap/seed/rung3/table3.s2", + "git_blob_sha1": "91b141f7394d02c514eaca495bad9cd90d652dba", + "local_git_blob_sha1": "91b141f7394d02c514eaca495bad9cd90d652dba", + "match": true + }, + { + "path": "bootstrap/seed/rung4/table4.s2", + "git_blob_sha1": "f2bf0f70a6d35a447e41890e8e457c225892dc2a", + "local_git_blob_sha1": "f2bf0f70a6d35a447e41890e8e457c225892dc2a", + "match": true + }, + { + "path": "bootstrap/seed/rung4/om4.s", + "git_blob_sha1": "deec39af2b3db32aff0cfdf7a5b6161fd5283f9e", + "local_git_blob_sha1": "deec39af2b3db32aff0cfdf7a5b6161fd5283f9e", + "match": true + }, + { + "path": "bootstrap/seed/rung0/load0.sh", + "git_blob_sha1": "b0449bf8a160e70f4468e84207caf6e9014d150c", + "local_git_blob_sha1": "b0449bf8a160e70f4468e84207caf6e9014d150c", + "match": true + }, + { + "path": "bootstrap/seed/rung4/mk4.sh", + "git_blob_sha1": "e0717af8ee816d0e7e4f54226669b9797d4f288c", + "local_git_blob_sha1": "e0717af8ee816d0e7e4f54226669b9797d4f288c", + "match": true + }, + { + "path": "omc.om", + "git_blob_sha1": "e2fc6e2fcf03243c2ed5d4af911804e73ce154aa", + "local_git_blob_sha1": "e2fc6e2fcf03243c2ed5d4af911804e73ce154aa", + "match": true + } + ] +} diff --git a/native/.gitignore b/native/.gitignore new file mode 100644 index 0000000..7a60b85 --- /dev/null +++ b/native/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ +*.pyc diff --git a/native/README.md b/native/README.md new file mode 100644 index 0000000..038f2a1 --- /dev/null +++ b/native/README.md @@ -0,0 +1,67 @@ +# Static site assembly in Omega + +`site.om` contains all product build and verification logic. It copies reviewed +HTML, CSS, SVG, JSON, Markdown and text inputs without transforming their bytes. +There is no runtime package dependency, browser JavaScript, template interpreter, +network ingestion, or Python build path. + +From the repository root, using the compiler pinned in +[`../evidence/toolchain/bootstrap-receipt.json`](../evidence/toolchain/bootstrap-receipt.json): + +```sh +set -eu +mkdir -p target +"$OMC" < native/site.om > target/site-omega +# Continue only if the compiler exited zero. +chmod +x target/site-omega +target/site-omega build dist +target/site-omega verify dist +python native/tests/check.py target/site-omega --receipt native/evidence/native-tests.json +``` + +`OMC` is the native x86 compiler rebuilt from the pinned Omega compiler source. +The pinned AArch64 compiler can also compile this source through QEMU. The source +selects the x86 Linux output target on its first line. To produce an AArch64 Linux +executable, omit only that target-selection line when invoking the compiler. The +AArch64 receipt is an emulated execution result, not Raspberry Pi qualification. +The x86 Linux no-follow open flag is supplemented by a `readlnk` check, so the +final-component symlink negative control also runs on the AArch64 target. + +The output path must be new, its parent must exist, and invocation must happen +from the repository root. An existing directory is refused so stale files cannot +silently survive a build. Preflight checks every required input before creating +the output directory. A later I/O failure may leave an incomplete output; never +publish a failed build. An accepted build verifies the completed output again. + +The fixed file inventory includes all declared page routes, the local stylesheet +and SVGs, both downloads, and the public facts, robots, sitemap and LLM text files. +Each required input must be nonempty. The file byte bound is a configuration +limit, not a performance claim. All reads, writes, closes and output file syncs +are checked; short reads and writes are handled. Output files use exclusive +creation. Missing inputs and malformed command arguments return failure. + +The verifier checks HTML document markers, a nonempty title, the local stylesheet +reference, lexical tag and quoted-attribute structure, local link targets and +the fixed output inventory. It rejects script, iframe, frame, object, embed, +applet, base, inline style and SVG executable-animation constructs; event +attributes; unsafe URL schemes; remote resource sources; CSS imports, URL +fetches, image sets and escapes. Source navigation may link to HTTPS destinations. +All asset references and internal links use root-relative paths. Boolean +`hidden`, `open`, `checked`, `required`, `disabled` and `download` attributes are +accepted. SVG resource links receive the same local-target checks. + +This is a bounded policy checker for reviewed static sources, **not an HTML, +SVG, CSS or JSON sanitizer or a complete standards validator**. It does not prove +DOM nesting, accessibility, semantic correctness, fragment existence, absence of +all browser parser discrepancies, or that a submitted software component is +safe. It does not enumerate undeclared files in a manually altered output tree. +The fresh-output build is the release entrypoint. Inputs and output directories +must not be concurrently modified or supplied by an untrusted writer; parent +directory symlinks and filesystem races are outside this checker's contract. + +`tests/check.py` is an independent test oracle only. It constructs fixtures, +invokes the compiled native executable, compares exact output bytes, and runs +negative controls. It never assembles a release. The measured fixture outcomes +are in `evidence/native-tests.json` and `evidence/aarch64-emulated-tests.json`. +Actual reviewed-source builds and compiler-output equality are recorded in +`evidence/real-build.json`. diff --git a/native/evidence/aarch64-emulated-tests.json b/native/evidence/aarch64-emulated-tests.json new file mode 100644 index 0000000..d9fc68f --- /dev/null +++ b/native/evidence/aarch64-emulated-tests.json @@ -0,0 +1,458 @@ +{ + "scope": "MEASURED fixture checks; independent Python oracle only", + "source_sha256": "21912307990ca807dc5a580ddeb29ce8042a5457654541d2a76a403ec8e12fb3", + "oracle_sha256": "2ea7a665f0b1cc0c340a997e0e596c85a1d5b187723a80ffd6dc2c64a73cb3f3", + "binary_sha256": "2169421739e07e173d95ee231edea7de9aa4925d951f5d1005b98944be14dbc7", + "machine": "x86_64", + "execution": "emulated", + "runner": "qemu-aarch64-static", + "results": [ + { + "case": "build-complete-fixture", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified", + "stderr": "" + }, + { + "case": "verify-complete-fixture", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed", + "stderr": "" + }, + { + "case": "static-yard-and-forge-preserve-dynamic-explore", + "passed": true, + "static_pages": 15, + "output_files": 24, + "dynamic_explore_shadowed": false + }, + { + "case": "deterministic-second-build", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified", + "stderr": "" + }, + { + "case": "byte-copy-and-deterministic-output", + "passed": true, + "files": 24, + "manifest": { + "index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "yard/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "forge/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "contribute/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "how-it-works/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "mission/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "evidence/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "pieces/omega-harness/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "pieces/weight-patch/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "pieces/interplane-protocol/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "quick-start/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "concepts/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "adapter/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "conformance/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "status/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "public/style.css": "fb81e2bb4e775148cbf27f57953576647a58fa2d4d0b211e9cc5304294460b33", + "public/orbit.svg": "eb315a5b1caac2471ae60c5d6ea4c61ac0de72b1f2b15fbce29ffb7a65a2fa1e", + "public/favicon.svg": "2f6b4359711c4098ea66973d3df37ef29022bf735d34e04801d46ee691b263f3", + "downloads/salvage-manifest.json": "4342902cf8400c5b53793f921a0a91f5023885700ad49f62992c3c73a0cf533a", + "downloads/contribution.md": "7e98df7437f1b50bc0ea2ba7180f28bdb7a043cd2c6045e1783124cdba2fdcc5", + "facts.json": "407ea6f7f3ae3c3637122d88c381bb10452aa634af80b99d6237a7afcdf7c357", + "robots.txt": "16ceb5ee3e0dc13aa9adf31a3ebbe45a1d965b8c2b9f72eaf84e5911e140ed95", + "sitemap.xml": "18165d11bd779f782d5e915ad8519ffbf0201b3e14932536a06bc3eae21202dd", + "llms.txt": "7e98df7437f1b50bc0ea2ba7180f28bdb7a043cd2c6045e1783124cdba2fdcc5" + } + }, + { + "case": "existing-output-refused", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: output directory must be new; parent must exist\n$TEST_ROOT/release-a" + }, + { + "case": "missing-argument", + "expected": "refuse", + "exit": 2, + "passed": true, + "stdout": "usage: site build OUTDIR | site verify OUTDIR", + "stderr": "" + }, + { + "case": "unknown-command", + "expected": "refuse", + "exit": 2, + "passed": true, + "stdout": "usage: site build OUTDIR | site verify OUTDIR", + "stderr": "" + }, + { + "case": "missing-output", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/absent/index.html" + }, + { + "case": "path-traversal-argument", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: invalid command or output path" + }, + { + "case": "overlong-argument", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: invalid command or output path" + }, + { + "case": "missing-required-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/index.html" + }, + { + "case": "empty-required-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/index.html" + }, + { + "case": "oversized-required-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/index.html" + }, + { + "case": "source-script-injection", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\ncontent/index.html" + }, + { + "case": "missing-yard-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/yard/index.html" + }, + { + "case": "missing-yard-output", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-forge-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/forge/index.html" + }, + { + "case": "missing-forge-output", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "script", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "mixed-case-script", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "event-handler", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-image", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-video-poster", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-background", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "protocol-relative-image", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "iframe", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-stylesheet", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "plain-http-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "javascript-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "encoded-javascript-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "broken-local-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "dynamic-explore-must-use-absolute-url", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "local-traversal", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "srcset", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "meta-refresh", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "unquoted-attribute", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "unterminated-attribute", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "inline-style", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "nul-byte", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: NUL or forbidden control byte in text input\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "truncated-html", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-title", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "empty-title", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-stylesheet", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-output-page", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "oversized-output-page", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "css-import", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "css-remote-url", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "css-image-set", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "css-escaped-url", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "svg-remote-resource", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/public/orbit.svg" + }, + { + "case": "output-symlink-refused", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "final-restored-fixture", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed", + "stderr": "" + } + ], + "all_passed": true +} diff --git a/native/evidence/native-tests.json b/native/evidence/native-tests.json new file mode 100644 index 0000000..266e289 --- /dev/null +++ b/native/evidence/native-tests.json @@ -0,0 +1,458 @@ +{ + "scope": "MEASURED fixture checks; independent Python oracle only", + "source_sha256": "21912307990ca807dc5a580ddeb29ce8042a5457654541d2a76a403ec8e12fb3", + "oracle_sha256": "2ea7a665f0b1cc0c340a997e0e596c85a1d5b187723a80ffd6dc2c64a73cb3f3", + "binary_sha256": "60f6bb16847f2ecd7265fc5e6501546ea9839b9c99c4e79c14e0b8f897da700b", + "machine": "x86_64", + "execution": "native", + "runner": null, + "results": [ + { + "case": "build-complete-fixture", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified", + "stderr": "" + }, + { + "case": "verify-complete-fixture", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed", + "stderr": "" + }, + { + "case": "static-yard-and-forge-preserve-dynamic-explore", + "passed": true, + "static_pages": 15, + "output_files": 24, + "dynamic_explore_shadowed": false + }, + { + "case": "deterministic-second-build", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "BUILD PASS: reviewed static files copied and verified", + "stderr": "" + }, + { + "case": "byte-copy-and-deterministic-output", + "passed": true, + "files": 24, + "manifest": { + "index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "yard/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "forge/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "contribute/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "how-it-works/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "mission/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "evidence/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "pieces/omega-harness/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "pieces/weight-patch/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "pieces/interplane-protocol/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "quick-start/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "concepts/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "adapter/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "conformance/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "status/index.html": "e285807b197e45f00f937cbfabb9e3abff68f2c1d05923fb39f674c177207599", + "public/style.css": "fb81e2bb4e775148cbf27f57953576647a58fa2d4d0b211e9cc5304294460b33", + "public/orbit.svg": "eb315a5b1caac2471ae60c5d6ea4c61ac0de72b1f2b15fbce29ffb7a65a2fa1e", + "public/favicon.svg": "2f6b4359711c4098ea66973d3df37ef29022bf735d34e04801d46ee691b263f3", + "downloads/salvage-manifest.json": "4342902cf8400c5b53793f921a0a91f5023885700ad49f62992c3c73a0cf533a", + "downloads/contribution.md": "7e98df7437f1b50bc0ea2ba7180f28bdb7a043cd2c6045e1783124cdba2fdcc5", + "facts.json": "407ea6f7f3ae3c3637122d88c381bb10452aa634af80b99d6237a7afcdf7c357", + "robots.txt": "16ceb5ee3e0dc13aa9adf31a3ebbe45a1d965b8c2b9f72eaf84e5911e140ed95", + "sitemap.xml": "18165d11bd779f782d5e915ad8519ffbf0201b3e14932536a06bc3eae21202dd", + "llms.txt": "7e98df7437f1b50bc0ea2ba7180f28bdb7a043cd2c6045e1783124cdba2fdcc5" + } + }, + { + "case": "existing-output-refused", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: output directory must be new; parent must exist\n$TEST_ROOT/release-a" + }, + { + "case": "missing-argument", + "expected": "refuse", + "exit": 2, + "passed": true, + "stdout": "usage: site build OUTDIR | site verify OUTDIR", + "stderr": "" + }, + { + "case": "unknown-command", + "expected": "refuse", + "exit": 2, + "passed": true, + "stdout": "usage: site build OUTDIR | site verify OUTDIR", + "stderr": "" + }, + { + "case": "missing-output", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/absent/index.html" + }, + { + "case": "path-traversal-argument", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: invalid command or output path" + }, + { + "case": "overlong-argument", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: invalid command or output path" + }, + { + "case": "missing-required-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/index.html" + }, + { + "case": "empty-required-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/index.html" + }, + { + "case": "oversized-required-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/index.html" + }, + { + "case": "source-script-injection", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\ncontent/index.html" + }, + { + "case": "missing-yard-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/yard/index.html" + }, + { + "case": "missing-yard-output", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-forge-source", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\ncontent/forge/index.html" + }, + { + "case": "missing-forge-output", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "script", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "mixed-case-script", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "event-handler", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-image", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-video-poster", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-background", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "protocol-relative-image", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "iframe", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: malformed or forbidden markup\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "remote-stylesheet", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "plain-http-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "javascript-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "encoded-javascript-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "broken-local-link", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "dynamic-explore-must-use-absolute-url", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "local-traversal", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "srcset", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "meta-refresh", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "unquoted-attribute", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "unterminated-attribute", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "inline-style", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden or malformed HTML attribute\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "nul-byte", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: NUL or forbidden control byte in text input\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "truncated-html", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-title", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "empty-title", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-stylesheet", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: incomplete HTML document, title, or local stylesheet\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "missing-output-page", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "oversized-output-page", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "css-import", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "css-remote-url", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "css-image-set", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "css-escaped-url", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden CSS resource, escape, or import\n$TEST_ROOT/release-a/public/style.css" + }, + { + "case": "svg-remote-resource", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: forbidden URL or missing local target\n$TEST_ROOT/release-a/public/orbit.svg" + }, + { + "case": "output-symlink-refused", + "expected": "refuse", + "exit": 1, + "passed": true, + "stdout": "", + "stderr": "site: refused: missing, empty, oversized, or unreadable file\n$TEST_ROOT/release-a/index.html" + }, + { + "case": "final-restored-fixture", + "expected": "accept", + "exit": 0, + "passed": true, + "stdout": "VERIFY PASS: bounded static policy checks passed", + "stderr": "" + } + ], + "all_passed": true +} diff --git a/native/evidence/real-build.json b/native/evidence/real-build.json new file mode 100644 index 0000000..2c23d5e --- /dev/null +++ b/native/evidence/real-build.json @@ -0,0 +1,84 @@ +{ + "classification": "MEASURED", + "scope": "Native Linux x86_64 build and AArch64 emulated build from the current reviewed worktree; byte identity, not hardware qualification or sanitizer proof", + "source_revision_context": "canonical Radicle repository rad:z399yKvnXcBQNkKoq86iBDgTvQ5QV at b71cb9e3e28a4f7ce64f91aefa5ec4fe2fea3858 plus reviewed worktree", + "commands": [ + "\"$OMC_X86\" < native/site.om > target/site-omega", + "\"$QEMU_AARCH64\" \"$OMC_AARCH64\" < native/site.om > target/site-omega-cross", + "cmp target/site-omega target/site-omega-cross", + "tail -n +2 native/site.om > \"$TEMP/site-aarch64.om\"", + "\"$OMC_X86\" < \"$TEMP/site-aarch64.om\" > target/site-omega-aarch64", + "target/site-omega build \"$OUT_A\"", + "target/site-omega build \"$OUT_B\"", + "\"$QEMU_AARCH64\" target/site-omega-aarch64 build \"$OUT_ARM\"", + "target/site-omega verify \"$OUT_A\"", + "independent Python oracle: assert all output manifests equal and each output SHA-256 equals its authored source" + ], + "source_sha256": "21912307990ca807dc5a580ddeb29ce8042a5457654541d2a76a403ec8e12fb3", + "oracle_sha256": "2ea7a665f0b1cc0c340a997e0e596c85a1d5b187723a80ffd6dc2c64a73cb3f3", + "compiler_pinned_aarch64_sha256": "3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194", + "compiler_rebuilt_x86_sha256": "79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd", + "builder_x86_sha256": "60f6bb16847f2ecd7265fc5e6501546ea9839b9c99c4e79c14e0b8f897da700b", + "builder_aarch64_sha256": "2169421739e07e173d95ee231edea7de9aa4925d951f5d1005b98944be14dbc7", + "compiler_output_byte_identity": true, + "repeat_build_byte_identity": true, + "cross_architecture_output_byte_identity": true, + "source_copy_byte_identity": true, + "output_files": 24, + "static_pages": 15, + "dynamic_explore_shadowed": false, + "output_sha256": { + "adapter/index.html": "78d491dd5c3d85ac589cc332d0f757a749fa839b53baf213be0f423e1261b81d", + "concepts/index.html": "d814e0acb8322417a9465caf8dfc6cdb77d367e9ed0d244ccda83d8315182cc4", + "conformance/index.html": "208b579359faf99ead4b58540c2cc53a6f3cfaf35c59a6c14c81260885b336a6", + "contribute/index.html": "c2b17e046a993346c7048aa5480dbeee0aeeb7a6966e337cbe1b98b02adf89a2", + "downloads/contribution.md": "e369eaf6261e992b81e4f1e09a0605048ac33494865e688ab2be1f4cb0796c02", + "downloads/salvage-manifest.json": "c5555347967b1b0e096ac1b6830b22fa69110d7374935a5868b1a3c26bef9288", + "evidence/index.html": "817a35b6a872838126a08373bd26dfebbd0c936836964efb3a1212be0ecb8aa4", + "facts.json": "bbba71bd55040ad5c6fbc6fb0ecfe27672dedf73d6a726dd4c39e9a98e859734", + "forge/index.html": "35d925ed9ea1db7b93b318beb4bc0f8e88d3e012312bad242b8faea1b31edb3f", + "how-it-works/index.html": "673bcfb41f981dafeac87d8891ea4749ab70bb310613e4ed9e12bda71551f18d", + "index.html": "ad6829e857a4d72d3f5c546fb4c72a3152607acdd87fc9b89673bdac7e8af56b", + "llms.txt": "c5de4b571932796ae783c2663c2259788ac4ea13d304a64228d030928a9dcde1", + "mission/index.html": "f03f4cd31928bc2f7b9fdbf09f4bbb38641c7783d9e37883ab88ae94f3d76eb5", + "pieces/interplane-protocol/index.html": "778c427531596f3ded80be19826988f526dc65dba87088e30316b37003c2f29b", + "pieces/omega-harness/index.html": "ae6b68687bd8c40cf02d5e9d5a4b02bf813054718a3c67bd20844fe65f58f53b", + "pieces/weight-patch/index.html": "dea9e6c1eaa8480e6b48e4f4fa45e202ee7499e01d280520c01e3f9885567741", + "public/favicon.svg": "70318c1f16963d5c5ce69a41b0721cb7a142e5d8fb20c75482f821f81e7b5d36", + "public/orbit.svg": "c717534bdd68dd180d758f190d513c9d02eacf067c8bfc2a557a7184cb246a21", + "public/style.css": "385f646e420a4bfd74ede48b9c51b9ed97299ea3c5abcc30ce1b0fc7e609ad0b", + "quick-start/index.html": "f79a0d9f8f5a85ccc4789066b3339eb9d2c896e50bf508572af7ef18641adaf1", + "robots.txt": "0defd681f8cf39691173be8927654eb15f0a28adcb20527e8e19d2edc7be25c1", + "sitemap.xml": "862dd58e8d0450cf7279823c9963860888cbc90f327d671446ca3877a4fdd9e5", + "status/index.html": "958954012260fe5290d27c74087f67160c329019fa94c86679d099b3e52c01e8", + "yard/index.html": "2a5ccec66a88c41da2c800ead60ecb820867a2d2283760a2cff3fe8e63501109" + }, + "input_sha256": { + "content/adapter/index.html": "78d491dd5c3d85ac589cc332d0f757a749fa839b53baf213be0f423e1261b81d", + "content/concepts/index.html": "d814e0acb8322417a9465caf8dfc6cdb77d367e9ed0d244ccda83d8315182cc4", + "content/conformance/index.html": "208b579359faf99ead4b58540c2cc53a6f3cfaf35c59a6c14c81260885b336a6", + "content/contribute/index.html": "c2b17e046a993346c7048aa5480dbeee0aeeb7a6966e337cbe1b98b02adf89a2", + "downloads/contribution.md": "e369eaf6261e992b81e4f1e09a0605048ac33494865e688ab2be1f4cb0796c02", + "downloads/salvage-manifest.json": "c5555347967b1b0e096ac1b6830b22fa69110d7374935a5868b1a3c26bef9288", + "content/evidence/index.html": "817a35b6a872838126a08373bd26dfebbd0c936836964efb3a1212be0ecb8aa4", + "content/facts.json": "bbba71bd55040ad5c6fbc6fb0ecfe27672dedf73d6a726dd4c39e9a98e859734", + "content/forge/index.html": "35d925ed9ea1db7b93b318beb4bc0f8e88d3e012312bad242b8faea1b31edb3f", + "content/how-it-works/index.html": "673bcfb41f981dafeac87d8891ea4749ab70bb310613e4ed9e12bda71551f18d", + "content/index.html": "ad6829e857a4d72d3f5c546fb4c72a3152607acdd87fc9b89673bdac7e8af56b", + "content/llms.txt": "c5de4b571932796ae783c2663c2259788ac4ea13d304a64228d030928a9dcde1", + "content/mission/index.html": "f03f4cd31928bc2f7b9fdbf09f4bbb38641c7783d9e37883ab88ae94f3d76eb5", + "content/pieces/interplane-protocol/index.html": "778c427531596f3ded80be19826988f526dc65dba87088e30316b37003c2f29b", + "content/pieces/omega-harness/index.html": "ae6b68687bd8c40cf02d5e9d5a4b02bf813054718a3c67bd20844fe65f58f53b", + "content/pieces/weight-patch/index.html": "dea9e6c1eaa8480e6b48e4f4fa45e202ee7499e01d280520c01e3f9885567741", + "public/favicon.svg": "70318c1f16963d5c5ce69a41b0721cb7a142e5d8fb20c75482f821f81e7b5d36", + "public/orbit.svg": "c717534bdd68dd180d758f190d513c9d02eacf067c8bfc2a557a7184cb246a21", + "public/style.css": "385f646e420a4bfd74ede48b9c51b9ed97299ea3c5abcc30ce1b0fc7e609ad0b", + "content/quick-start/index.html": "f79a0d9f8f5a85ccc4789066b3339eb9d2c896e50bf508572af7ef18641adaf1", + "content/robots.txt": "0defd681f8cf39691173be8927654eb15f0a28adcb20527e8e19d2edc7be25c1", + "content/sitemap.xml": "862dd58e8d0450cf7279823c9963860888cbc90f327d671446ca3877a4fdd9e5", + "content/status/index.html": "958954012260fe5290d27c74087f67160c329019fa94c86679d099b3e52c01e8", + "content/yard/index.html": "2a5ccec66a88c41da2c800ead60ecb820867a2d2283760a2cff3fe8e63501109" + }, + "manifest_encoding": "UTF-8 lines sorted by output path: SHA256 + two ASCII spaces + path + LF", + "output_manifest_sha256": "1419d3a8408b0a2b0677f816433938c27b836b135b88f0d6365f3d27e054b1b6" +} diff --git a/native/site.om b/native/site.om new file mode 100644 index 0000000..323badb --- /dev/null +++ b/native/site.om @@ -0,0 +1,847 @@ +target x86linux +om2 +note Interplane static assembler and bounded policy checker. +note Only reviewed repository sources are supported. This is not an HTML sanitizer. +note Each file is nonempty and at most 1048576 bytes. URL paths are at most 768 bytes. +note The output directory must not exist. Failed builds must never be published. +note The numeric Linux open flags below are the x86linux ABI, not AArch64 flags. +global data uchar 1048577 +global root uchar 512 +global pathbuf uchar 1024 +global linkbuf uchar 2048 +global symlbuf uchar 1024 +global state ulong 4 +text usage "usage: site build OUTDIR | site verify OUTDIR\n" +text failmsg "site: refused: " +text newline "\n" +text okbuild "BUILD PASS: reviewed static files copied and verified\n" +text okverify "VERIFY PASS: bounded static policy checks passed\n" +text cmdmake "build" +text cmdcheck "verify" +text inroot "content/" +text slash "/" +text indexht "index.html" +text erread "missing, empty, oversized, or unreadable file" +text erwrite "output write failed" +text erclose "file close failed" +text erdir "output directory must be new; parent must exist" +text erarg "invalid command or output path" +text erhtml "incomplete HTML document, title, or local stylesheet" +text ermarkup "malformed or forbidden markup" +text erattr "forbidden or malformed HTML attribute" +text erurl "forbidden URL or missing local target" +text ercss "forbidden CSS resource, escape, or import" +text ertext "NUL or forbidden control byte in text input" +text doctype "" +text htmlopen "" +text headend "" +text bodyopen "" +text titleop "" +text titleend "" +text stylea "href=\"/public/style.css\"" +text styleb "href='/public/style.css'" +text relstyle "stylesheet" +text scriptag "script" +text iframeag "iframe" +text objectag "object" +text embedtag "embed" +text appletta "applet" +text frametag "frame" +text frameset "frameset" +text basetag "base" +text styletag "style" +text foreign "foreignobject" +text animtag "animate" +text settag "set" +text metatag "meta" +text atag "a" +text linktag "link" +text styleatr "style" +text srcattr "src" +text postera "poster" +text backgrnd "background" +text hrefattr "href" +text xhref "xlink:href" +text srcseta "srcset" +text srcdoca "srcdoc" +text httpequi "http-equiv" +text actiona "action" +text forma "formaction" +text pingattr "ping" +text hiddena "hidden" +text openattr "open" +text checkeda "checked" +text requirea "required" +text downloa "download" +text disablea "disabled" +text https "https://" +text canon "https://interplane.io/" +text cssimp "@import" +text cssurl "url(" +text cssimage "image-set(" +text cssproto "//" +text csshttp "http:" +text csshttps "https:" +text jsurl "javascript:" +text cssbind "-moz-binding" +text cssexpr "expression(" +text cssbeh "behavior:" +text cmstart "" + +fn say a view uchar * to void +pos = ulong 0 +while lt pos len a bound 1048577 +k = write 1 a pos sub len a pos +if le k 0 +exit 1 +end +pos = add pos ulong k +end +ret +end + +fn refuse a view uchar * to void +k = write 2 failmsg 0 len failmsg +if ne k long len failmsg +exit 1 +end +k = write 2 a 0 len a +if ne k long len a +exit 1 +end +k = write 2 newline 0 len newline +if ne k long len newline +exit 1 +end +if gt get state 2 0 +k = write 2 pathbuf 0 get state 2 +if ne k long get state 2 +exit 1 +end +k = write 2 newline 0 len newline +if ne k long len newline +exit 1 +end +end +exit 1 +end + +fn low c uchar to uchar +if and ge c 65 le c 90 +ret add c 32 +end +ret c +end + +fn space c uchar to bool +ret or eq c 32 or eq c 9 or eq c 10 eq c 13 +end + +fn namechar c uchar to bool +d = low c +ret or and ge d 97 le d 122 or and ge d 48 le d 57 or eq d 45 eq d 58 +end + +fn matches pos ulong pat view uchar * to bool +if gt add pos len pat get state 0 +ret false +end +for j ulong len pat bound 1048577 +if ne low get data add pos j get pat j +ret false +end +end +ret true +end + +fn token pos ulong size ulong pat view uchar * to bool +if ne size len pat +ret false +end +ret matches pos pat +end + +fn find pat view uchar * to ulong +for j ulong get state 0 bound 1048577 +if matches j pat +ret j +end +end +ret get state 0 +end + +fn has pat view uchar * to bool +ret lt find pat get state 0 +end + +fn pathsrc a view uchar * to void +put state 2 len a +for j ulong len a bound 768 +put pathbuf j get a j +end +ret +end + +fn pathout a view uchar * to void +n = get state 1 +for j ulong n bound 512 +put pathbuf j get root j +end +put pathbuf n 47 +n = add n 1 +for j ulong len a bound 768 +put pathbuf add n j get a j +end +put state 2 add n len a +ret +end + +fn loadfile to void +note readlnk returns -EINVAL for a regular file, and catches final-component symlinks. +probe = readlnk pathbuf 0 get state 2 symlbuf 0 1024 +if ne probe -22 +refuse erread +end +note O_NOFOLLOW|O_NONBLOCK avoids following final-component symlinks or waiting on FIFOs. +fd = fopen pathbuf 0 get state 2 133120 0 +if lt fd 0 +refuse erread +end +total = ulong 0 +while lt total 1048577 bound 1048577 +k = read int fd data total sub 1048577 total +if lt k 0 +r = fclose int fd +refuse erread +end +if eq k 0 +break +end +total = add total ulong k +end +r = fclose int fd +if ne r 0 +refuse erclose +end +if or eq total 0 gt total 1048576 +refuse erread +end +put state 0 total +for j ulong total bound 1048576 +c = get data j +if lt c 32 +if not space c +refuse ertext +end +end +end +ret +end + +fn savefile to void +note 193 is Linux O_WRONLY|O_CREAT|O_EXCL. Refuse stale files and symlinks. +fd = fopen pathbuf 0 get state 2 193 420 +if lt fd 0 +refuse erwrite +end +pos = ulong 0 +while lt pos get state 0 bound 1048576 +k = write int fd data pos sub get state 0 pos +if le k 0 +r = fclose int fd +refuse erwrite +end +pos = add pos ulong k +end +r = fsync int fd +if ne r 0 +k = fclose int fd +refuse erwrite +end +r = fclose int fd +if ne r 0 +refuse erclose +end +ret +end + +fn localurl pos ulong size ulong to void +if eq size 0 +refuse erurl +end +if eq get data pos 35 +ret +end +if ne get data pos 47 +refuse erurl +end +if gt size 1 +if eq get data add pos 1 47 +refuse erurl +end +end +n = get state 1 +for j ulong n bound 512 +put linkbuf j get root j +end +count = ulong 0 +while lt count size bound 768 +c = get data add pos count +if or eq c 35 eq c 63 +break +end +if or le c 32 or eq c 92 or eq c 38 or eq c 37 eq c 58 +refuse erurl +end +if eq c 46 +if lt add count 1 size +if eq get data add add pos count 1 46 +refuse erurl +end +end +end +put linkbuf add n count c +count = add count 1 +end +if gt count 768 +refuse erurl +end +n = add n count +if eq get linkbuf sub n 1 47 +for j ulong len indexht bound 16 +put linkbuf add n j get indexht j +end +n = add n len indexht +end +if eq get state 3 1 +probe = readlnk linkbuf 0 n symlbuf 0 1024 +if ne probe -22 +refuse erurl +end +fd = fopen linkbuf 0 n 133120 0 +if lt fd 0 +refuse erurl +end +r = fclose int fd +if ne r 0 +refuse erclose +end +end +ret +end + +fn checkurl pos ulong size ulong external bool to void +if gt size 768 +refuse erurl +end +if eq size 0 +refuse erurl +end +if external +if matches pos https +if le size len https +refuse erurl +end +ret +end +end +localurl pos size +ret +end + +fn forbidtag pos ulong size ulong to void +if or token pos size scriptag token pos size iframeag +refuse ermarkup +end +if or token pos size objectag token pos size embedtag +refuse ermarkup +end +if or token pos size appletta or token pos size frametag token pos size frameset +refuse ermarkup +end +if or token pos size basetag token pos size styletag +refuse ermarkup +end +if or token pos size foreign token pos size animtag +refuse ermarkup +end +if token pos size settag +refuse ermarkup +end +ret +end + +fn forbidattr pos ulong size ulong to void +if ge size 2 +if and eq low get data pos 111 eq low get data add pos 1 110 +refuse erattr +end +end +if or token pos size styleatr token pos size srcseta +refuse erattr +end +if or token pos size srcdoca token pos size httpequi +refuse erattr +end +if or token pos size actiona token pos size forma +refuse erattr +end +if token pos size pingattr +refuse erattr +end +ret +end + +fn booleanattr pos ulong size ulong to bool +ret or token pos size hiddena or token pos size openattr or token pos size checkeda or token pos size requirea or token pos size downloa token pos size disablea +end + +fn skipspace pos ulong to ulong +i = pos +while lt i get state 0 bound 1048576 +if not space get data i +break +end +i = add i 1 +end +ret i +end + +fn attrvalue pos ulong namest ulong namesz ulong tagpos ulong tagsz ulong to ulong +i = skipspace pos +if ge i get state 0 +refuse erattr +end +if ne get data i 61 +if booleanattr namest namesz +ret pos +end +refuse erattr +end +i = skipspace add i 1 +if ge i get state 0 +refuse erattr +end +quote = get data i +if not or eq quote 34 eq quote 39 +refuse erattr +end +start = add i 1 +i = start +while lt i get state 0 bound 1048576 +if eq get data i quote +break +end +if eq get data i 60 +refuse erattr +end +i = add i 1 +end +if ge i get state 0 +refuse erattr +end +size = sub i start +if token namest namesz srcattr +checkurl start size false +end +if or token namest namesz postera token namest namesz backgrnd +checkurl start size false +end +if token namest namesz xhref +checkurl start size false +end +if token namest namesz hrefattr +ext = token tagpos tagsz atag +if token tagpos tagsz linktag +if matches start canon +ext = true +end +end +checkurl start size ext +end +ret add i 1 +end + +fn starttag pos ulong to ulong +i = pos +while lt i get state 0 bound 1048576 +if not namechar get data i +break +end +i = add i 1 +end +sz = sub i pos +if eq sz 0 +refuse ermarkup +end +forbidtag pos sz +while lt i get state 0 bound 1048576 +if eq get data i 62 +ret add i 1 +end +if eq get data i 47 +i = add i 1 +if lt i get state 0 +if eq get data i 62 +ret add i 1 +end +end +refuse ermarkup +end +if not space get data i +refuse erattr +end +i = skipspace i +if ge i get state 0 +refuse ermarkup +end +if or eq get data i 62 eq get data i 47 +continue +end +as = i +while lt i get state 0 bound 1048576 +if not namechar get data i +break +end +i = add i 1 +end +az = sub i as +if eq az 0 +refuse erattr +end +forbidattr as az +i = attrvalue i as az pos sz +end +refuse ermarkup +ret i +end + +fn endtag pos ulong to ulong +i = pos +while lt i get state 0 bound 1048576 +if not namechar get data i +break +end +i = add i 1 +end +if eq i pos +refuse ermarkup +end +forbidtag pos sub i pos +i = skipspace i +if ge i get state 0 +refuse ermarkup +end +if ne get data i 62 +refuse ermarkup +end +ret add i 1 +end + +fn checkmarkup html bool to void +if html +if not and has doctype and has htmlopen and has htmlend and has headend and has bodyopen has bodyend +refuse erhtml +end +if not and has titleop has titleend +refuse erhtml +end +if le find titleend add find titleop len titleop +refuse erhtml +end +if not and has relstyle or has stylea has styleb +refuse erhtml +end +end +i = ulong 0 +while lt i get state 0 bound 1048576 +if eq get data i 60 +if matches i cmstart +i = add i len cmstart +while lt i get state 0 bound 1048576 +if matches i cmend +break +end +i = add i 1 +end +if ge i get state 0 +refuse ermarkup +end +i = add i len cmend +continue +end +if matches i doctype +if not html +refuse ermarkup +end +i = add i len doctype +continue +end +i = add i 1 +if ge i get state 0 +refuse ermarkup +end +if eq get data i 47 +i = endtag add i 1 +else +i = starttag i +end +else +i = add i 1 +end +end +ret +end + +fn checkcss to void +if or has cssimp or has csshttp or has csshttps has jsurl +refuse ercss +end +if or has cssbind has cssexpr +refuse ercss +end +if or has cssimage has cssproto +refuse ercss +end +for j ulong get state 0 bound 1048576 +if eq get data j 92 +refuse ercss +end +if matches j cssurl +note Resource URLs live in reviewed SVG/HTML; CSS URL fetches are excluded entirely. +refuse ercss +end +end +ret +end + +fn file pass int src view uchar * dst view uchar * kind int to void +if eq pass 2 +pathout dst +else +pathsrc src +end +loadfile +if eq kind 1 +checkmarkup true +end +if eq kind 2 +checkcss +end +if eq kind 3 +checkmarkup false +end +if eq pass 1 +pathout dst +savefile +end +ret +end + +text hsrc "content/index.html" +text hdst "index.html" +text esrc "content/yard/index.html" +text edst "yard/index.html" +text gsrc "content/forge/index.html" +text gdst "forge/index.html" +text csrc "content/contribute/index.html" +text cdst "contribute/index.html" +text wsrc "content/how-it-works/index.html" +text wdst "how-it-works/index.html" +text msrc "content/mission/index.html" +text mdst "mission/index.html" +text vsrc "content/evidence/index.html" +text vdst "evidence/index.html" +text osrc "content/pieces/omega-harness/index.html" +text odst "pieces/omega-harness/index.html" +text psrc "content/pieces/weight-patch/index.html" +text pdst "pieces/weight-patch/index.html" +text isrc "content/pieces/interplane-protocol/index.html" +text idst "pieces/interplane-protocol/index.html" +text qsrc "content/quick-start/index.html" +text qdst "quick-start/index.html" +text nsrc "content/concepts/index.html" +text ndst "concepts/index.html" +text asrc "content/adapter/index.html" +text adst "adapter/index.html" +text fsrc "content/conformance/index.html" +text fdst "conformance/index.html" +text ssrc "content/status/index.html" +text sdst "status/index.html" +text csssrc "public/style.css" +text cssdst "public/style.css" +text svgsrc "public/orbit.svg" +text svgdst "public/orbit.svg" +text favsrc "public/favicon.svg" +text favdst "public/favicon.svg" +text mansrc "downloads/salvage-manifest.json" +text consrc "downloads/contribution.md" +text mandst "downloads/salvage-manifest.json" +text condst "downloads/contribution.md" +text factsrc "content/facts.json" +text factdst "facts.json" +text robsrc "content/robots.txt" +text robdst "robots.txt" +text mapsrc "content/sitemap.xml" +text mapdst "sitemap.xml" +text llmsrc "content/llms.txt" +text llmdst "llms.txt" + +fn allfiles pass int to void +file pass hsrc hdst 1 +file pass esrc edst 1 +file pass gsrc gdst 1 +file pass csrc cdst 1 +file pass wsrc wdst 1 +file pass msrc mdst 1 +file pass vsrc vdst 1 +file pass osrc odst 1 +file pass psrc pdst 1 +file pass isrc idst 1 +file pass qsrc qdst 1 +file pass nsrc ndst 1 +file pass asrc adst 1 +file pass fsrc fdst 1 +file pass ssrc sdst 1 +file pass csssrc cssdst 2 +file pass svgsrc svgdst 3 +file pass favsrc favdst 3 +file pass mansrc mandst 0 +file pass consrc condst 0 +file pass factsrc factdst 0 +file pass robsrc robdst 0 +file pass mapsrc mapdst 0 +file pass llmsrc llmdst 0 +ret +end + +text dyard "yard" +text dforge "forge" +text dcontrib "contribute" +text dworks "how-it-works" +text dmission "mission" +text devidenc "evidence" +text dpieces "pieces" +text domega "pieces/omega-harness" +text dweight "pieces/weight-patch" +text dproto "pieces/interplane-protocol" +text dquick "quick-start" +text dconcept "concepts" +text dadapter "adapter" +text dconform "conformance" +text dstatus "status" +text ddown "downloads" +text dpublic "public" + +fn directory a view uchar * to void +pathout a +k = makedir pathbuf 0 get state 2 493 +if ne k 0 +refuse erdir +end +ret +end + +fn directories to void +put state 2 get state 1 +for j ulong get state 1 bound 512 +put pathbuf j get root j +end +k = makedir root 0 get state 1 493 +if ne k 0 +refuse erdir +end +directory dyard +directory dforge +directory dcontrib +directory dworks +directory dmission +directory devidenc +directory dpieces +directory domega +directory dweight +directory dproto +directory dquick +directory dconcept +directory dadapter +directory dconform +directory dstatus +directory ddown +directory dpublic +ret +end + +fn argument a view uchar * b view uchar * size ulong to bool +if ne size len b +ret false +end +for j ulong size bound 32 +if ne get a j get b j +ret false +end +end +ret true +end + +fn rootarg to void +k = argread 2 root 0 512 +if or le k 0 ge k 512 +refuse erarg +end +n = ulong k +if eq get root sub n 1 47 +refuse erarg +end +for j ulong n bound 512 +c = get root j +if or le c 32 eq c 92 +refuse erarg +end +if eq c 46 +if lt add j 1 n +if eq get root add j 1 46 +refuse erarg +end +end +end +end +put state 1 n +ret +end + +fn main to int +cmd = new uchar 32 0 +if ne argcnt 3 +say usage +ret 2 +end +n = argread 1 cmd 0 32 +if le n 0 +say usage +ret 2 +end +buildit = argument cmd cmdmake ulong n +verifyit = argument cmd cmdcheck ulong n +if not or buildit verifyit +say usage +ret 2 +end +rootarg +put state 3 0 +if buildit +allfiles 0 +directories +allfiles 1 +end +put state 3 1 +allfiles 2 +if buildit +say okbuild +else +say okverify +end +ret 0 +end diff --git a/native/tests/check.py b/native/tests/check.py new file mode 100644 index 0000000..cf753d5 --- /dev/null +++ b/native/tests/check.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python3 +"""Independent test oracle. Product assembly and validation run only in site.om.""" +from __future__ import annotations + +import argparse +import hashlib +import json +import platform +import shutil +import subprocess +import tempfile +from pathlib import Path + +ROUTES = ( + "", "yard", "forge", "contribute", "how-it-works", "mission", "evidence", + "pieces/omega-harness", "pieces/weight-patch", "pieces/interplane-protocol", + "quick-start", "concepts", "adapter", "conformance", "status", +) +HTML = ('Fixture' + '' + '' + '
Explore the yard' + 'About the forge' + 'Open the forge app' + 'Source' + 'Orbit' + '
' + 'EvidenceFixture
') + + +def sha(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def snapshot(root: Path) -> dict[str, str]: + return {str(p.relative_to(root)): sha(p) for p in sorted(root.rglob("*")) if p.is_file()} + + +def fixture(root: Path) -> dict[str, str]: + expected = {} + for route in ROUTES: + dest = f"{route}/index.html" if route else "index.html" + source = root / "content" / dest + source.parent.mkdir(parents=True, exist_ok=True) + source.write_text(HTML) + expected[dest] = sha(source) + other = { + "public/style.css": "html { scroll-behavior: smooth; } body { color: #222; }\n", + "public/orbit.svg": '', + "public/favicon.svg": '', + "downloads/salvage-manifest.json": '{"schema":"fixture"}\n', + "downloads/contribution.md": "# Fixture\n", + "content/facts.json": '{"status":"fixture"}\n', + "content/robots.txt": "User-agent: *\nAllow: /\n", + "content/sitemap.xml": '\n', + "content/llms.txt": "# Fixture\n", + } + for rel, value in other.items(): + source = root / rel + source.parent.mkdir(parents=True, exist_ok=True) + source.write_text(value) + dest = rel.removeprefix("content/") + expected[dest] = sha(source) + return expected + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("binary", type=Path) + parser.add_argument("--runner", type=Path, help="Optional architecture emulator; no shell is used") + parser.add_argument("--receipt", type=Path) + args = parser.parse_args() + binary = args.binary.resolve() + runner = [str(args.runner.resolve())] if args.runner else [] + results = [] + + def run(root: Path, label: str, argv: list[str], success: bool) -> subprocess.CompletedProcess: + result = subprocess.run([*runner, str(binary), *argv], cwd=root, capture_output=True, text=True, timeout=30) + passed = (result.returncode == 0) == success + if not success: + passed = passed and result.returncode in (1, 2) + results.append({"case": label, "expected": "accept" if success else "refuse", + "exit": result.returncode, "passed": passed, + "stdout": result.stdout.strip(), + "stderr": result.stderr.strip().replace(str(base), "$TEST_ROOT")}) + if not passed: + raise AssertionError(f"{label}: {result.returncode}: {result.stdout}{result.stderr}") + return result + + with tempfile.TemporaryDirectory(prefix="interplane-native-tests-") as temporary: + base = Path(temporary) + src = base / "sources" + src.mkdir() + expected = fixture(src) + out = base / "release-a" + again = base / "release-b" + run(src, "build-complete-fixture", ["build", str(out)], True) + run(src, "verify-complete-fixture", ["verify", str(out)], True) + assert snapshot(out) == expected, "Assembler must preserve every input byte and output path" + assert not (out / "explore").exists(), "Static output must not shadow the forge app's /explore route" + assert not (out / "explore.html").exists(), "Static output must not shadow the forge app's /explore route" + assert (out / "yard/index.html").is_file() and (out / "forge/index.html").is_file() + results.append({"case": "static-yard-and-forge-preserve-dynamic-explore", "passed": True, + "static_pages": len(ROUTES), "output_files": len(expected), + "dynamic_explore_shadowed": False}) + run(src, "deterministic-second-build", ["build", str(again)], True) + assert snapshot(out) == snapshot(again), "Repeated build bytes differ" + results.append({"case": "byte-copy-and-deterministic-output", "passed": True, + "files": len(expected), "manifest": expected}) + run(src, "existing-output-refused", ["build", str(out)], False) + run(src, "missing-argument", ["build"], False) + run(src, "unknown-command", ["publish", str(out)], False) + run(src, "missing-output", ["verify", str(base / "absent")], False) + run(src, "path-traversal-argument", ["build", "../unsafe"], False) + run(src, "overlong-argument", ["verify", "x" * 513], False) + + original_source = src / "content/index.html" + original = original_source.read_bytes() + for label, value in (("missing-required-source", None), ("empty-required-source", b""), + ("oversized-required-source", b"a" * 1048577), + ("source-script-injection", HTML.replace("", "").encode())): + if value is None: + original_source.unlink() + else: + original_source.write_bytes(value) + target = base / label + run(src, label, ["build", str(target)], False) + assert not target.exists(), "Preflight must fail before creating output" + original_source.write_bytes(original) + + for route in ("yard", "forge"): + required = src / "content" / route / "index.html" + value = required.read_bytes() + required.unlink() + target = base / f"missing-{route}-source" + run(src, f"missing-{route}-source", ["build", str(target)], False) + assert not target.exists(), "Missing new route must fail before creating output" + required.write_bytes(value) + output_route = out / route / "index.html" + value = output_route.read_bytes() + output_route.unlink() + run(src, f"missing-{route}-output", ["verify", str(out)], False) + output_route.write_bytes(value) + + mutations = { + "script": '', + "mixed-case-script": '', + "event-handler": '', + "remote-image": 'remote', + "remote-video-poster": '', + "remote-background": '
', + "protocol-relative-image": 'remote', + "iframe": '', + "remote-stylesheet": '', + "plain-http-link": 'Unsafe', + "javascript-link": 'Unsafe', + "encoded-javascript-link": 'Unsafe', + "broken-local-link": 'Absent', + "dynamic-explore-must-use-absolute-url": 'Forge app', + "local-traversal": 'Escape', + "srcset": 'remote', + "meta-refresh": '', + "unquoted-attribute": 'Malformed', + "unterminated-attribute": 'Inline

', + "nul-byte": '

bad\x00byte

', + } + page = out / "index.html" + for label, payload in mutations.items(): + page.write_text(HTML.replace("", payload + "")) + run(src, label, ["verify", str(out)], False) + page.write_text(HTML) + for label, value in (("truncated-html", HTML.removesuffix("")), + ("missing-title", HTML.replace("Fixture", "")), + ("empty-title", HTML.replace("Fixture", "")), + ("missing-stylesheet", HTML.replace('href="/public/style.css"', 'href="/public/favicon.svg"'))): + page.write_text(value) + run(src, label, ["verify", str(out)], False) + page.write_text(HTML) + page.unlink() + run(src, "missing-output-page", ["verify", str(out)], False) + page.write_text(HTML) + page.write_bytes(b"a" * 1048577) + run(src, "oversized-output-page", ["verify", str(out)], False) + page.write_text(HTML) + css = out / "public/style.css" + original_css = css.read_bytes() + for label, value in (("css-import", '@import "https://evil.example/a.css";'), + ("css-remote-url", 'a{background:url(https://evil.example/a.png)}'), + ("css-image-set", 'a{background:image-set("//evil.example/a.png" 1x)}'), + ("css-escaped-url", r'a{background:\75rl(https://evil.example/a.png)}')): + css.write_text(value) + run(src, label, ["verify", str(out)], False) + css.write_bytes(original_css) + svg = out / "public/orbit.svg" + original_svg = svg.read_bytes() + svg.write_text('') + run(src, "svg-remote-resource", ["verify", str(out)], False) + svg.write_bytes(original_svg) + page.unlink() + page.symlink_to(original_source) + run(src, "output-symlink-refused", ["verify", str(out)], False) + page.unlink() + page.write_text(HTML) + run(src, "final-restored-fixture", ["verify", str(out)], True) + + receipt = {"scope": "MEASURED fixture checks; independent Python oracle only", + "source_sha256": sha(Path(__file__).resolve().parents[1] / "site.om"), + "oracle_sha256": sha(Path(__file__).resolve()), + "binary_sha256": sha(binary), "machine": platform.machine(), + "execution": "emulated" if runner else "native", "runner": args.runner.name if args.runner else None, + "results": results, "all_passed": all(r["passed"] for r in results)} + if args.receipt: + args.receipt.parent.mkdir(parents=True, exist_ok=True) + args.receipt.write_text(json.dumps(receipt, indent=2) + "\n") + print(f'PASS {len(results)} native cases; deterministic byte-copy oracle matched {len(expected)} files') + + +if __name__ == "__main__": + main() diff --git a/native/toolchain/LICENSE b/native/toolchain/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/native/toolchain/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/native/toolchain/NOTICE b/native/toolchain/NOTICE new file mode 100644 index 0000000..a1d3b1f --- /dev/null +++ b/native/toolchain/NOTICE @@ -0,0 +1,24 @@ +AIEN Sovereign Ecosystem (AienOS / Omega / CUDA++ / INTERPLANE) +Copyright 2024-2026 Drake Stapleton and AIEN Contributors (https://github.com/aien-dev) + +This product includes software developed as part of the AIEN Sovereign +Ecosystem (https://www.aienos.com). + +The Omega language (omega-mv), CUDA++ GPU toolchain (CUDApp), Aienux kernel, +INTERPLANE protocol, and FORGE realization layer (physics-mv) are foundational +components designed and architected by Drake Stapleton. + +TRADEMARK NOTICE: +Pursuant to Section 6 of the Apache License, Version 2.0, this license does not +grant permission to use the trade names, trademarks, service marks, or product +names of the Licensor. "AIEN", "AienOS", "Aienux", "Omega", "CUDA++", "CUDApp", +"INTERPLANE", and "FORGE" are trademarks of Drake Stapleton. Any derivative +works or redistributions modified from the canonical upstream repositories +(https://github.com/aien-dev) may not be branded or marketed as official +"AienOS Verified" or "Omega" distributions without express written permission. + +THIRD-PARTY COMPONENTS: +The six research files under research/m15/spbm/ are a Linux kernel module and +its helpers. They carry SPDX-License-Identifier: GPL-2.0-only and remain under +GPL-2.0-only. They are research-only and are not part of the shipped Omega +binary. See research/m15/spbm/LICENSE-NOTE.md. diff --git a/native/toolchain/README.md b/native/toolchain/README.md new file mode 100644 index 0000000..9018e86 --- /dev/null +++ b/native/toolchain/README.md @@ -0,0 +1,33 @@ +# Pinned upstream seed sources + +This directory vendors unchanged source text from the public repository +[aien-dev/omega-mv](https://github.com/aien-dev/omega-mv) at commit +`f4df82394e35893dcf1354dda69a2fe028d94bc1`. It is a minimal source subset for +reproducing the website compiler. It contains no compiler executable and is not +an independently branded Omega distribution. + +The upstream Apache-2.0 `LICENSE` and `NOTICE` are retained verbatim. Authorship +and attribution remain with Drake Stapleton and AIEN contributors. Upstream +source paths are preserved under `seed/`. These sources have not been edited. +`SHA256SUMS` pins every included upstream file, including its license and notice. +The source blob identities were checked against the exact upstream revision; +see `evidence/toolchain/source-identity.json` at the repository root. + +From the repository root: + +```sh +QEMU=/path/to/qemu-aarch64-static sh scripts/build-seed.sh target/seed-replay +OMC="$PWD/target/seed-replay/omc-x86" sh scripts/build-native.sh target/site-omega +``` + +On AArch64 Linux, QEMU is optional and `omc-aarch64` is the native compiler. +The bootstrap checks each rung's expected executable hash, seed0 and hex1 +self-reproduction, the AArch64 compiler fixed point and the x86 compiler hash. +On x86 Linux it also runs the x86 compiler self-rebuild natively. Rejected or +interrupted output is not a usable compiler provisioning result. + +The shell loader and host utilities remain outside the seeded chain, as does +QEMU when used. Hash identity is reproducibility evidence for these exact +sources and outputs, not a proof of compiler correctness or hardware behavior. +No GitHub credential, external compiler download or binary blob is required by +the CI seed replay. QEMU is installed from the runner's Ubuntu package source. diff --git a/native/toolchain/SHA256SUMS b/native/toolchain/SHA256SUMS new file mode 100644 index 0000000..2271d12 --- /dev/null +++ b/native/toolchain/SHA256SUMS @@ -0,0 +1,12 @@ +cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE +367c530877825b64a9933193f571a63e2b8e26e651e0cf5397d26d8fb3e904ea NOTICE +0effe37afc4ddd0507151c9f2afa34b3e6774eae7006cbecd8c59f11bc386db7 seed/omc/omc.om +5e515adc462f68eb204a2ddb8a144a44aeab79f6ddcfb637e709bfe3047dee52 seed/rung0/load0.sh +baaf081fe6055a768485c5d25d7435681ce00b04cfa80b26c48169f78944e14d seed/rung0/seed0.hex +2d3fecbf3c2a727f8ae486ba07d528012b2dcd5f4135394f5a268869d3aad69c seed/rung1/hex1.hex +287b40544051b896ed08bfd0c81fcc8d8163c01cae4d43fef3302836200846e2 seed/rung2/asm2.hex1 +7f11cceb0e5fbd9ae425078fcdc399e9bb44e5f5e254b8630bd5e3a7a7543e63 seed/rung2/table.s2 +3a8f95de248d0e20370f43a3f0fc8665e7786c0a8e6e84a99f0e6e86140dfc4e seed/rung3/table3.s2 +693961edc6e4ca7d021d2f9b8a0197c29ea0a3dd38d35025ea58b44a1c80fcc1 seed/rung4/mk4.sh +b96e2c5d73640a86cbe28f2abd15cdd615a1fcf56d8e12d74119f50e7dab7fce seed/rung4/om4.s +bb91907c6ac70844029dba0f9d3739aaa8602ce2db2f17f6d55c07d52bbffa9e seed/rung4/table4.s2 diff --git a/native/toolchain/seed/omc/omc.om b/native/toolchain/seed/omc/omc.om new file mode 100644 index 0000000..e2fc6e2 --- /dev/null +++ b/native/toolchain/seed/omc/omc.om @@ -0,0 +1,18224 @@ +note omc: the Omega compiler written in Omega (the om4 subset). Reads Omegese on stdin, writes a runnable +note AArch64 Linux program (or bare function words) on stdout. Built first by om4; its codegen matches om4 +note byte for byte on the original subset (seed chain rung 5, ledger L408). Native host operations +note extend that subset; om4 still builds this compiler, and the compiler rebuilds itself identically. +note All compiler state lives in fixed global pools (decision 24: no heap). Every working value is a ulong +note (raw 64 bits) so the language's checked conversions never fire on om4's untyped-register logic. + +note ---- input, output, token ---- +global inp uchar 8388608 +global inlen ulong 1 +global irmode ulong 1 +global cur ulong 1 +global line ulong 1 +global tk ulong 1 +global tw ulong 1 +global tl ulong 1 +global ts ulong 1 +global tbig ulong 1 +global out uchar 16777216 +global oc ulong 1 + +note ---- OM-2 profile (spec/omegese-om2.md, OMEGESE.md 9.13). om2 is 1 in an OM-2 unit (its first line +note that is not a note or blank is exactly om2, om2 diag or om2 fmt); om2m 0 compile, 1 diag, 2 fmt; +note om2ln/om2pos the line number and offset of that line; fmtm 1 while a unit is formatted; lbase and +note sbase shift reported lines and bytes back to the original input in fmt mode; tka/tkb the byte span of +note the last token; dexp what was being read (0 word 1 value 2 type 3 name 4 number 5 end 6 newline); +note dsev 0 derived, 2 unknown (an undeclared function or struct), 3 error ---- +global om2 ulong 1 +global om2m ulong 1 +global om2ln ulong 1 +global om2pos ulong 1 +global fmtm ulong 1 +global chkmode ulong 1 +global chkln ulong 1 +global lbase ulong 1 +global sbase ulong 1 +global tka ulong 1 +global tkb ulong 1 +global dexp ulong 1 +global dsev ulong 1 + +note ---- executable contracts: OM-2 debug by default, release erases only validated pure predicates. +note Function prefixes are replayed at returns with their declaration scope, including inline frames. +global crel ulong 1 +global cpure ulong 1 +global cvalid ulong 1 +global clim ulong 1 +global crkind ulong 1 +global crval ulong 1 +global crtype ulong 1 +global cfpos ulong 8 +global cfline ulong 8 +global cflim ulong 8 +global cfhas ulong 8 +global csnap ulong 8 +global ckind ulong 1 + +note ---- OM-2 section 4 (unroll, inline, folding, bounds, sites). fn_inl/fn_body/fn_bln/fn_pn: a function's +note inline mark, its body offset and line, its parameter names. fstart: where the function being compiled +note starts (65536 words at most in OM-2). nmlo: names below it and at or above nglob are hidden while an +note inlined body is compiled (0 otherwise). fzone: open unrolled bodies and inline frames (folding is +note done only when it is above 0). inl and il_*: the inline frames (at most 4). ilp/nilp: the B words of +note an inlined ret, patched at its end. lastb/tgoc: the word after the last inlined ret's B and the last +note place a branch was patched to. u_*: the unrolled loop of each block. fok/fval/fty: a fold result. +note sitebuf/nsite: the omc-site records of om2 diag. +global fn_inl uchar 4096 +global fn_body ulong 4096 +global fn_bln ulong 4096 +global fn_pn ulong 24576 +global fstart ulong 1 +global nmlo ulong 1 +global fzone ulong 1 +global inl ulong 1 +global il_cur ulong 8 +global il_line ulong 8 +global il_ret ulong 8 +global il_nn ulong 8 +global il_lo ulong 8 +global il_held ulong 8 +global il_ns ulong 8 +global il_res ulong 8 +global il_fn ulong 8 +global il_p0 ulong 8 +global ilp ulong 4096 +global nilp ulong 1 +global lastb ulong 1 +global tgoc ulong 1 +global u_cur ulong 512 +global u_line ulong 512 +global u_it ulong 512 +global u_k ulong 512 +global u_nn ulong 512 +global u_held ulong 512 +note fuel (E14, E16): the expansion fuel used by the function being compiled: an unrolled loop costs K when +note it starts, an inline expansion 1, at most 65536 in all (error 14) +global fuel ulong 1 +global fok ulong 1 +global fval ulong 1 +global fty ulong 1 +global sitebuf uchar 8388608 +global nsite ulong 1 +global ie_from ulong 16384 +global ie_to ulong 16384 +global nie ulong 1 +global reach uchar 4096 + +note ---- name table (8192 names in scope): packed name, register, type, length, kind, address ---- +global nm_name ulong 8192 +global nm_reg uchar 8192 +global nm_type uchar 8192 +global nm_len ulong 8192 +global nm_kind uchar 8192 +global nm_addr ulong 8192 +global nm_fv uchar 8192 +global nn ulong 1 +note ---- floats in v registers: kind 9 is a float held in v(16 + pool index of x register rv), the twin of +note pool register rv; vsl marks each pool slot whose value lives in its twin (an f32/f64 local name, a +note kind 9 value), saved and loaded as D around a call. fpw asks the next value read for kind 9 (1: a new +note twin, 2 + r: the twin of r); fpo hands that request to the part that makes the value. A float local +note name (nm_fv 1) lives in its twin; its x register holds a copy only while a reader needs one. ---- +global vsl uchar 16 +global fpw ulong 1 +global fpo ulong 1 +note fwv: rdval's fpw request at each nesting depth (kept here, not in a register of rdval) +global fwv ulong 1026 + +note ---- function table (4096): name, address (byte offset in out), return type, parameter count, +note per-parameter type/length/kind (6 each), name length, name offset in the input ---- +global fn_name ulong 4096 +global fn_addr ulong 4096 +global fn_ret uchar 4096 +global fn_np uchar 4096 +global fn_pt uchar 24576 +global fn_pl ulong 24576 +global fn_pk uchar 24576 +global fn_nmlen ulong 4096 +global fn_off ulong 4096 +note x86 Linux retains the parser's sixteen logical slots in each native frame. +note No A64 instruction may pass emit once the explicit target is selected (error 25). +global xtarget ulong 1 +global xnaddr ulong 1 +global xasite ulong 65536 +global xavalue ulong 65536 +note x86efi (xtarget 2): exit-site jumps patched to the shared firmware return, the PE bss address, +note and the error/done branch lists of one efi operation (closed by xe 2). +global xexsite ulong 65536 +global xnexit ulong 1 +global xbss ulong 1 +global xenerr ulong 1 +global xerrpos ulong 256 +global xerrcode ulong 256 +global xenend ulong 1 +global xendpos ulong 256 +global nf ulong 1 +global lastfn ulong 1 +global scanning ulong 1 +global ncalls ulong 1 +global callsite ulong 524288 +global callfrom ulong 524288 +global callto ulong 524288 +global settled uchar 4096 + + +note ---- compiler state ---- +global npar ulong 1 +global held ulong 1 +global nslot ulong 1 +global curret ulong 1 +global progmode ulong 1 +global nglob ulong 1 +global hostargs ulong 1 +global maptab ulong 1 +global stkbytes ulong 1 +global dead ulong 1 +global poolb ulong 1 + +note ---- structs (16) and fields (256). R6. nm_type 16+index, kind 6 own, 7 edit, 8 view ---- +global st_name ulong 16 +global st_nf uchar 16 +global st_cells uchar 16 +global st_foff uchar 16 +global nst ulong 1 +global sf_name ulong 256 +global sf_type uchar 256 +global sf_len uchar 256 +global sf_off uchar 256 +global nsf ulong 1 +global svk ulong 16 +global svv ulong 16 +global svt ulong 16 + +note ---- OM-2 section 5 external layouts (16) and their fields (256): name, SIZE, first field, field count, +note the cursor and line after the block's end (the body pass jumps there). Field: name, type, COUNT (0 a +note scalar), byte offset, 1 big-endian. lymap marks the bytes taken while a layout is read. nm_lay / +note fn_play: the layout (index + 1) of a layout parameter name / parameter slot, else 0 ---- +global ly_name ulong 16 +global ly_size ulong 16 +global ly_fo ulong 16 +global ly_nf ulong 16 +global ly_ec ulong 16 +global ly_el ulong 16 +global nly ulong 1 +global lf_name ulong 256 +global lf_type uchar 256 +global lf_cnt ulong 256 +global lf_off ulong 256 +global lf_big uchar 256 +global nlf ulong 1 +global lymap uchar 4096 +global nm_lay uchar 8192 +global fn_play uchar 24576 + +note ---- OM-2 section 5 fresh scratch (erratum E8). fn_pfr: 1 for a `fresh` parameter slot. nm_fr: the +note written-set slot (index + 1) a name's elements are tracked in, else 0. fz_n slots in use by the +note function being compiled (16), fz_len their N, fz_cur the elements definitely written on the path +note being compiled (bit i for element i); fz_ent / fz_thn (16 per block): the sets when the block opened +note and at its else. il_fz: fz_n when an inline frame opened. dobx 1: error 14 reports obligation=init ---- +global fn_pfr uchar 24576 +global nm_fr uchar 8192 +global fz_n ulong 1 +global fz_len ulong 16 +global fz_cur ulong 16 +global fz_ent ulong 8192 +global fz_thn ulong 8192 +global il_fz ulong 8 +global dobx ulong 1 + +note ---- OM-2 section 5 abstract types (16; type 64 + index): name, its length, representation type (4 uint, +note 5 ulong), the preserving operations listed (1 rotr, 2 rotl, 4 and, 8 or, 16 xor), 1 when `holds NAME +note dup32` is declared. aw_*: the word reader of the exact-constructor test (place, packed word, length, +note newlines crossed before it) ---- +global ab_name ulong 16 +global ab_len ulong 16 +global ab_base uchar 16 +global ab_ops ulong 16 +global ab_holds uchar 16 +global nab ulong 1 +global aw_p ulong 1 +global aw_w ulong 1 +global aw_l ulong 1 +global aw_nl ulong 1 + +note ---- OM-2 section 6 unsized views (spec 4 slots, 6, erratum E2). An unsized `view T *` / `edit T *` +note name has length 0 in nm_len and its run-time element count in register nm_lr. Parameters take the +note registers x0..x5 by slots: an unsized array two (pointer, then count), every other parameter one +note (pwid, pslot); psl counts the slots of the fn line being read (6 at most, error 9). ul_k / ul_v: the +note count (kind 1 register / 3 number) of argument i of the call at value depth d, at d * 6 + i ---- +global nm_lr uchar 8192 +global psl ulong 1 +global ul_k ulong 6156 +global ul_v ulong 6156 +note ---- OM-2 section 6 multi-entry units: nexp `export fn` lines (32 at most, function mode only), fn_exp 1 +note for an exported function, expf 1 while an `export fn` line is read. With any export, words 0 .. E-1 +note of the code are B to each export in source order and the code starts at byte 176 + 4E ---- +global nexp ulong 1 +global expf ulong 1 +global fn_exp uchar 4096 + +note ======== leaf helpers ======== + +note poolc: the i-th register of the pool x0..x6, x8..x15, x17 (x7 is the runtime, x16 scratch) +fn poolc i ulong to ulong +if lt i 7 +ret i +end +if lt i 15 +ret add i 1 +end +ret 17 +end + +note pwid: the parameter slots of fn table entry p: 2 for an unsized array (pointer, count), else 1 +fn pwid p ulong to ulong +k = ulong get fn_pk p +if and or eq k 2 eq k 3 eq get fn_pl p 0 +ret 2 +end +ret 1 +end + +note unsz: 1 when name entry i is an unsized array (nm_len 0, its count in register nm_lr), else 0. A text +note (kind 5) of length 0 (`text e ""`) is sized: its count is the number 0 and it has no count register. +fn unsz i ulong to ulong +if and eq get nm_len i 0 ne get nm_kind i 5 +ret 1 +end +ret 0 +end + +note pslot: the first slot (register) of parameter i of function f (index) +fn pslot f ulong i ulong to ulong +s = ulong 0 +j = ulong 0 +while lt j i +s = add s pwid add mul f 6 j +j = add j 1 +end +ret s +end + +note ---- error reporting ---- +global msg uchar 65536 +global mc ulong 1 + +note mflush: complete a diagnostic/query stdout chunk or report compiler output error 2. +fn mflush to void +off = ulong 0 +n = get mc 0 +while lt off n +w = write 1 msg off sub n off +if le w 0 +exit int 2 +end +off = add off ulong w +end +put mc 0 0 +end + +fn mputb b uchar to void +m = get mc 0 +put msg m b +put mc 0 add m 1 +end + +fn mputn v ulong to void +d = new uchar 20 0 +i = ulong 0 +x = v +put d 0 uchar add rem x 10 48 +x = div x 10 +i = add i 1 +while gt x 0 +put d i uchar add rem x 10 48 +x = div x 10 +i = add i 1 +end +j = i +while gt j 0 +j = sub j 1 +mputb get d j +end +end + +note fail: write "omc: line N: error E" to stderr (fd 2) and exit with the code +fn fail code ulong to void +put mc 0 0 +mputb 111 +mputb 109 +mputb 99 +mputb 58 +mputb 32 +mputb 108 +mputb 105 +mputb 110 +mputb 101 +mputb 32 +mputn add get line 0 get lbase 0 +mputb 58 +mputb 32 +mputb 101 +mputb 114 +mputb 114 +mputb 111 +mputb 114 +mputb 32 +mputn code +mputb 10 +w = write 2 msg 0 get mc 0 +if ne get om2 0 0 +if eq get om2m 0 1 +drec code +end +end +if ne get chkmode 0 0 +diagrec code +end +exit int code +end + +note mputw: the first n bytes (at most 8) of the little-endian packed word w +fn mputw w ulong n ulong to void +i = ulong 0 +x = w +while lt i n +mputb uchar and x 255 +x = shr x 8 +i = add i 1 +end +end + +note dcol: the 1-based column of byte a in its line +fn dcol a ulong to ulong +j = a +go = true +while go +m = ulong 0 +while and go lt m 999999 +if eq j 0 +go = false +else +if eq get inp sub j 1 10 +go = false +else +j = sub j 1 +end +end +m = add m 1 +end +end +ret add sub a j 1 +end + +note dsev_w: sev= incomplete when the failure is on the end-of-input token (or inside a text literal cut by +note the end), unknown for an undeclared function or struct, else error +fn dsev_w code ulong to void +s = get dsev 0 +if eq s 0 +if eq get tk 0 3 +s = ulong 1 +end +if and eq code 22 ge get cur 0 get inlen 0 +s = ulong 1 +end +end +if eq s 1 +mputw 7308339910638005865 8 +mputw 25972 2 +ret +end +if eq s 2 +mputw 31093567915781749 7 +ret +end +mputw 491496043109 5 +end + +note dexp_w: expect= the class of token being read (end for an open function at the end of the input) +fn dexp_w code ulong to void +e = get dexp 0 +if eq code 15 +e = ulong 5 +end +if or eq code 6 eq code 8 +e = ulong 4 +end +if eq e 1 +mputw 435761734006 5 +ret +end +if eq e 2 +mputw 1701869940 4 +ret +end +if eq e 3 +mputw 1701667182 4 +ret +end +if eq e 4 +mputw 125779768604014 6 +ret +end +if eq e 5 +mputw 6581861 3 +ret +end +if eq e 6 +mputw 28550371718161774 7 +ret +end +mputw 1685221239 4 +end + +note dobl_w: obligation= from the code: 27 init, 28 ctor, 29 layout, 21 bounds, 14 growth, 12 regs, else - +fn dobl_w code ulong to void +if eq code 30 +mputw 8386654075301556067 8 +ret +end +if eq code 27 +mputw 1953066601 4 +ret +end +if eq code 28 +mputw 1919906915 4 +ret +end +if eq code 29 +mputw 128047730221420 6 +ret +end +if eq code 21 +mputw 126875187113826 6 +ret +end +if and eq code 14 ne get dobx 0 0 +mputw 1953066601 4 +ret +end +if eq code 14 +mputw 114849429287527 6 +ret +end +if eq code 12 +mputw 1936156018 4 +ret +end +mputb 45 +end + +note mputh: one byte as two lowercase hex digits +fn mputh b ulong to void +hi = shr b 4 +lo = and b 15 +if lt hi 10 +mputb uchar add hi 48 +else +mputb uchar add hi 87 +end +if lt lo 10 +mputb uchar add lo 48 +else +mputb uchar add lo 87 +end +end + +note drec: the om2 diag machine record after the human line (spec 1): code, sev, line (the human line), +note col, the half-open byte span of the token being read, expect, found (at most 32 bytes, hex), +note obligation, profile +fn drec code ulong to void +put mc 0 0 +mputw 7449351137626647919 8 +mputw 4424052638528581920 8 +mputn code +mputw 263979365152 5 +dsev_w code +mputw 67505853393952 6 +mputn add get line 0 get lbase 0 +a = get tka 0 +b = get tkb 0 +if le b a +b = a +if gt get cur 0 a +b = get cur 0 +end +end +if gt b get inlen 0 +b = get inlen 0 +end +mputw 263812244256 5 +mputn dcol a +mputw 67544290456352 6 +mputn add a get sbase 0 +mputb 45 +mputn add b get sbase 0 +mputw 4428273620941825312 8 +dexp_w code +mputw 17280399158765088 7 +if eq a b +mputb 45 +end +i = a +while and lt i b lt sub i a 32 +mputh ulong get inp i +i = add i 1 +end +mputw 8386097683628191520 8 +mputw 1030647657 4 +dobl_w code +mputw 7308332183992823840 8 +mputw 11210624683837 6 +w = write 2 msg 0 get mc 0 +end + +note emitb / emit: one byte / one 32-bit word (little-endian) to the output; error 14 when it is full +note AArch64 retains its 8 MiB output ceiling; x86 byte sequences use the full output pool. +fn emitb b uchar to void +o = get oc 0 +if or ge o len out and eq get xtarget 0 0 ge o 8388608 +fail 14 +end +note Charge x86's variable-width encoding to the same OM-2 emitted-storage budget as emit. +if and ne get xtarget 0 0 ne get om2 0 0 +if ne get curret 0 0 +if ge sub o get fstart 0 262144 +fail 14 +end +end +end +put out o b +put oc 0 add o 1 +end + +fn emit w ulong to void +if ne get xtarget 0 0 +fail 25 +end +if ge get oc 0 8388608 +fail 14 +end +if ne get om2 0 0 +if ne get curret 0 0 +if ge sub get oc 0 get fstart 0 262144 +fail 14 +end +end +end +emitb uchar and w 255 +emitb uchar and shr w 8 255 +emitb uchar and shr w 16 255 +emitb uchar and shr w 24 255 +end + +note tok_num: the word at [ts,cur) is [-]decimal, at most 20 digits, from -2^63 to 2^64 - 1 (error 6 +note bad number, 8 out of range). tw = its raw 64 bits (a negative one as two's complement); tbig = 1 +note when it is 2^63 or more (only a ulong holds it), else 0. As om4's TK_NUM. +note The float-marker scan walks the word in chunks of at most 999999 bytes: a single loop's hidden +note 1000000-pass guard trapped 4 on a decimal word of 1000001 digits, which must refuse with error 6 (#671). +fn tok_num to void +if ne get om2 0 0 +if ne tok_hex 0 +ret +end +end +p = get ts 0 +e = get cur 0 +fl = false +i = p +while lt i e +c = sub e i +if gt c 999999 +c = ulong 999999 +end +for k ulong c +b = get inp add i k +if or or or eq b 46 eq b 101 eq b 69 eq b 102 +fl = true +end +end +i = add i c +end +if fl +put tk 0 5 +ret +end +minus = false +if eq get inp p 45 +minus = true +p = add p 1 +end +ndig = sub e p +if eq ndig 0 +nfail 6 +end +if gt ndig 20 +nfail 6 +end +v = ulong 0 +lim = ulong 1844674407370955161 +i = p +while lt i e +d = sub ulong get inp i 48 +if gt d 9 +nfail 6 +end +if gt v lim +nfail 8 +end +if and eq v lim gt d 5 +nfail 8 +end +v = add mul v 10 d +i = add i 1 +end +half = shl ulong 1 63 +put tbig 0 0 +if minus +if gt v half +nfail 8 +end +put tw 0 sub ulong 0 v +else +if ge v half +put tbig 0 1 +end +put tw 0 v +end +put tk 0 2 +end + +note tok_text: a text literal starting at the opening quote. tw = first byte offset, tl = source length +note (escapes not yet decoded). Ends at an unescaped '"' on the same line, followed by a blank/end. Err 22. +note (Loops over the input are two loops, the inner under 1000000 passes: om4 has no pass limit.) +fn tok_text to void +put cur 0 add get cur 0 1 +put tw 0 get cur 0 +go = true +while go +n = ulong 0 +while and go lt n 999999 +if ge get cur 0 get inlen 0 +fail 22 +end +b = get inp get cur 0 +if eq b 10 +fail 22 +end +if eq b 34 +go = false +else +put cur 0 add get cur 0 1 +if eq b 92 +if ge get cur 0 get inlen 0 +fail 22 +end +if eq get inp get cur 0 10 +fail 22 +end +put cur 0 add get cur 0 1 +end +end +n = add n 1 +end +end +put tl 0 sub get cur 0 get tw 0 +put cur 0 add get cur 0 1 +put tk 0 4 +if lt get cur 0 get inlen 0 +if gt get inp get cur 0 32 +fail 22 +end +end +end + +note tok2: a word at cur with first byte c; packs 8 bytes into tw, sets tl and ts. A '"' is a text; a +note first byte '-' or a digit is a number. +fn tok2 c uchar to void +if eq c 34 +tok_text +ret +end +put ts 0 get cur 0 +if or eq c 40 eq c 41 +put tw 0 ulong c +put tl 0 1 +put cur 0 add get cur 0 1 +put tk 0 1 +ret +end +w = ulong 0 +sh = ulong 0 +n = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge get cur 0 get inlen 0 +go = false +else +b = get inp get cur 0 +if le b 32 +go = false +else +if or eq b 40 eq b 41 +go = false +else +if lt n 8 +w = or w shl ulong b sh +sh = add sh 8 +end +n = add n 1 +put cur 0 add get cur 0 1 +end +end +end +m = add m 1 +end +end +put tw 0 w +put tl 0 n +f = get inp get ts 0 +isnum = false +if eq f 45 +isnum = true +end +if and ge f 48 le f 57 +isnum = true +end +if isnum +tok_num +else +put tk 0 1 +end +end + +note tok: next word, skipping blanks (space, tab, carriage return); newline is end of line (kind 0) and +note bumps the line number; another byte below 32 is error 16; the end of the input is kind 3. om4 TOK. +fn tok to void +go = true +while go +n = ulong 0 +while and go lt n 999999 +if ge get cur 0 get inlen 0 +go = false +else +c = get inp get cur 0 +if or or eq c 32 eq c 9 eq c 13 +put cur 0 add get cur 0 1 +else +if eq c 10 +put tka 0 get cur 0 +put tkb 0 add get cur 0 1 +put cur 0 add get cur 0 1 +put line 0 add get line 0 1 +put tk 0 0 +ret +end +put tka 0 get cur 0 +put tkb 0 add get cur 0 1 +if lt c 32 +fail 16 +end +put tka 0 get cur 0 +put tkb 0 get cur 0 +tok2 c +put tkb 0 get cur 0 +ret +end +end +n = add n 1 +end +end +put tka 0 get inlen 0 +put tkb 0 get inlen 0 +put tk 0 3 +end + +note ======== keyword lookup (original om4 KWTAB plus native host words 100..177, flock 197 and execpure 198) ======== +note genkw.awk describes the original om4 table only; retain the native host extension on regeneration. +note efi (178) is a keyword only under `target x86efi`; gate18 checks that scoped entry separately. +fn kw w ulong to ulong +if and eq w 6907493 eq get xtarget 0 2 +ret 178 +end +if eq w 7310034270740117605 +ret 198 +end +if eq w 6584163 +ret 132 +end +packed = or ulong 114 shl ulong 101 8 +packed = or packed shl ulong 97 16 +packed = or packed shl ulong 100 24 +packed = or packed shl ulong 108 32 +packed = or packed shl ulong 110 40 +packed = or packed shl ulong 107 48 +if eq w packed +ret 133 +end +packed = or ulong 115 shl ulong 111 8 +packed = or packed shl ulong 99 16 +packed = or packed shl ulong 107 24 +packed = or packed shl ulong 111 32 +packed = or packed shl ulong 112 40 +packed = or packed shl ulong 116 48 +if eq w packed +ret 134 +end +if eq w 120325193752946 +ret 135 +end +if eq w 128017463930469 +ret 136 +end +if eq w 28254586011020901 +ret 137 +end +if eq w 491394459747 +ret 138 +end +if eq w 109326067987558 +ret 139 +end +if eq w 1952543859 +ret 140 +end +if eq w 1802398060 +ret 141 +end +if eq w 118122009688435 +ret 142 +end +if eq w 431366170723 +ret 143 +end +if eq w 32496501618073958 +ret 144 +end +if eq w 110404104906087 +ret 145 +end +if eq w 28263450605282663 +ret 146 +end +if eq w 110403870025063 +ret 147 +end +if eq w 28263390475740519 +ret 148 +end +if eq w 499851228012 +ret 149 +end +if eq w 7310575174812004980 +ret 150 +end +if eq w 474450192483 +ret 151 +end +if eq w 500152823651 +ret 152 +end +if eq w 125796981695334 +ret 153 +end +if eq w 28263429314995559 +ret 154 +end +if eq w 461497265525 +ret 155 +end +if eq w 109326135157862 +ret 156 +end +if eq w 431215175021 +ret 157 +end +if eq w 110404071351667 +ret 158 +end +if eq w 28263390660289895 +ret 159 +end +if eq w 28263390660289907 +ret 160 +end +if eq w 431130767984 +ret 161 +end +if eq w 111550659721072 +ret 162 +end +if eq w 110404071351655 +ret 163 +end +if eq w 126883592042867 +ret 164 +end +if eq w 7959953343641905267 +ret 165 +end +if eq w 119247140709732 +ret 166 +end +if eq w 131277528260973 +ret 167 +end +if eq w 31647734493634925 +ret 168 +end +if eq w 28254586010624365 +ret 169 +end +if eq w 7310584035480199533 +ret 170 +end +if eq w 30518463021081956 +ret 171 +end +if eq w 119247140124277 +ret 172 +end +if eq w 32198529639276909 +ret 173 +end +if eq w 127978875937133 +ret 174 +end +if eq w 127979077263725 +ret 175 +end +if eq w 28266723420430701 +ret 176 +end +if eq w 28268896573219181 +ret 177 +end +if eq w 461229747302 +ret 197 +end +if eq w 1819242338 +ret 1 +end +if eq w 491260502901 +ret 2 +end +if eq w 14453 +ret 2 +end +if eq w 128034844210037 +ret 3 +end +if eq w 3551605 +ret 3 +end +if eq w 1953393013 +ret 4 +end +if eq w 3289973 +ret 4 +end +if eq w 444234427509 +ret 5 +end +if eq w 3421813 +ret 5 +end +if eq w 1702132066 +ret 6 +end +if eq w 14441 +ret 6 +end +if eq w 500136110195 +ret 7 +end +if eq w 3551593 +ret 7 +end +if eq w 7630441 +ret 8 +end +if eq w 3289961 +ret 8 +end +if eq w 1735290732 +ret 9 +end +if eq w 3421801 +ret 9 +end +if eq w 6579297 +ret 33 +end +if eq w 6452595 +ret 34 +end +if eq w 7107949 +ret 35 +end +if eq w 7760228 +ret 36 +end +if eq w 7169394 +ret 37 +end +if eq w 6581857 +ret 38 +end +if eq w 29295 +ret 39 +end +if eq w 7499640 +ret 40 +end +if eq w 7104627 +ret 41 +end +if eq w 7497843 +ret 42 +end +if eq w 29029 +ret 43 +end +if eq w 25966 +ret 44 +end +if eq w 29804 +ret 45 +end +if eq w 25964 +ret 46 +end +if eq w 29799 +ret 47 +end +if eq w 25959 +ret 48 +end +if eq w 6776174 +ret 49 +end +if eq w 7630702 +ret 50 +end +if eq w 7628135 +ret 51 +end +if eq w 7234924 +ret 52 +end +if eq w 1684104562 +ret 53 +end +if eq w 435744764535 +ret 54 +end +if eq w 1702195828 +ret 55 +end +if eq w 435728179558 +ret 56 +end +if eq w 2003134838 +ret 57 +end +if eq w 1953064037 +ret 58 +end +if eq w 28262 +ret 64 +end +if eq w 28532 +ret 65 +end +if eq w 6581861 +ret 66 +end +if eq w 26217 +ret 67 +end +if eq w 1702063205 +ret 68 +end +if eq w 435610544247 +ret 69 +end +if eq w 431349919586 +ret 70 +end +if eq w 7499622 +ret 71 +end +if eq w 7628146 +ret 72 +end +if eq w 61 +ret 73 +end +if eq w 40 +ret 74 +end +if eq w 41 +ret 75 +end +if eq w 1684631414 +ret 76 +end +if eq w 119165519096935 +ret 78 +end +if eq w 1954047348 +ret 79 +end +if eq w 7632240 +ret 80 +end +if eq w 1701147238 +ret 81 +end +if eq w 1953069157 +ret 82 +end +if eq w 1702129518 +ret 83 +end +if eq w 7824750 +ret 84 +end +if eq w 461195539042 +ret 86 +end +if eq w 1885434484 +ret 87 +end +if eq w 7239535 +ret 77 +end +if eq w 7308604897168158579 +ret 131 +end +if eq w 126918101919090 +ret 130 +end +if eq w 7453301735350958181 +ret 124 +end +if eq w 32481142782190962 +ret 125 +end +if eq w 491394461042 +ret 126 +end +if eq w 28263429247363435 +ret 127 +end +if eq w 32480013273033072 +ret 128 +end +if eq w 110404021020007 +ret 129 +end +if eq w 122498715312503 +ret 123 +end +if eq w 32497639802299751 +ret 113 +end +if eq w 32760384594014051 +ret 114 +end +if eq w 1684957538 +ret 115 +end +if eq w 28263429381382519 +ret 116 +end +if eq w 499851228006 +ret 117 +end +if eq w 1986225522 +ret 118 +end +if eq w 1684956531 +ret 119 +end +if eq w 32491051338263667 +ret 120 +end +if eq w 128017462948449 +ret 121 +end +if eq w 28254586010038881 +ret 122 +end +if eq w 111546465018726 +ret 100 +end +if eq w 427055215462 +ret 101 +end +if eq w 110429739705190 +ret 102 +end +if eq w 461262648166 +ret 103 +end +if eq w 33607047151054707 +ret 104 +end +if eq w 121382024472940 +ret 105 +end +if eq w 128026086171489 +ret 106 +end +if eq w 1802661734 +ret 107 +end +if eq w 431215375716 +ret 108 +end +if eq w 126918153105261 +ret 109 +end +if eq w 474148269926 +ret 110 +end +if eq w 118121959288437 +ret 111 +end +if eq w 32204027264196973 +ret 112 +end +if eq w 127970521019507 +ret 85 +end +if eq w 3289958 +ret 88 +end +if eq w 3421798 +ret 89 +end +if eq w 32777959416031586 +ret 90 +end +if eq w 500136244070 +ret 91 +end +if eq w 1935827302 +ret 92 +end +if eq w 1852403046 +ret 93 +end +if eq w 2019650918 +ret 94 +end +if eq w 112628629924211 +ret 95 +end +if eq w 7381246293360141935 +ret 96 +end +if eq w 7310870969309884259 +ret 97 +end +if eq w 7234314147887146352 +ret 220 +end +if eq w 32480013390212976 +ret 221 +end +if eq w 29118836274783603 +ret 222 +end +if eq w 7959665 +ret 223 +end +if eq w 7305804402314801251 +ret 199 +end +if eq w 8674333540260081763 +ret 200 +end +if eq w 7308604897285727600 +ret 224 +end +if eq get om2 0 0 +ret 0 +end +ret kw2 w +end + +note ======== OM-2 words (spec/omegese-om2.md): reserved only in an OM-2 unit. rotr 59, rotl 60 are +note binary operators; dit 225 and scrub 226 are program-mode value words (OMEGESE 9.13.1); the rest are +note statement and declaration words of later sections. ======== +fn kw2 w ulong to ulong +if eq w 1920233330 +ret 59 +end +if eq w 1819570034 +ret 60 +end +if eq w 119212982038133 +ret 181 +end +if eq w 111524889521769 +ret 182 +end +if eq w 448612627046 +ret 183 +end +if eq w 8386654075301880417 +ret 184 +end +if eq w 1818322291 +ret 185 +end +if eq w 1852141679 +ret 186 +end +if eq w 495606067048 +ret 187 +end +if eq w 128047730221420 +ret 188 +end +if eq w 431315315046 +ret 189 +end +if eq w 29793 +ret 190 +end +if eq w 111516484659564 +ret 191 +end +if eq w 6777186 +ret 192 +end +if eq w 1953653104 +ret 193 +end +if eq w 7632239 +ret 194 +end +if eq w 128034844735589 +ret 195 +end +if eq w 7565423 +ret 196 +end +if eq w 7629156 +ret 225 +end +if eq w 422877225843 +ret 226 +end +ret 0 +end + +note nfail: a bad number (diag expect=number); unkfail: an undeclared function or struct (sev=unknown) +fn nfail code ulong to void +put dexp 0 4 +fail code +end + +fn unkfail code ulong to void +put dsev 0 2 +put dexp 0 3 +fail code +end + +note lineis: the n bytes at q are the packed word w and the line ends right after them +fn lineis q ulong w ulong n ulong to ulong +e = get inlen 0 +if gt add q n e +ret 0 +end +i = ulong 0 +x = w +while lt i n +if ne ulong get inp add q i and x 255 +ret 0 +end +x = shr x 8 +i = add i 1 +end +r = add q n +if lt r e +if ne get inp r 10 +ret 0 +end +end +ret 1 +end + +note isnote: the word at p is note (the lexer ends a word at a blank, a parenthesis or the end) +fn isnote p ulong to ulong +e = get inlen 0 +if gt add p 4 e +ret 0 +end +i = ulong 0 +x = ulong 1702129518 +while lt i 4 +if ne ulong get inp add p i and x 255 +ret 0 +end +x = shr x 8 +i = add i 1 +end +r = add p 4 +if lt r e +b = get inp r +if and gt b 32 and ne b 40 ne b 41 +ret 0 +end +end +ret 1 +end + +fn chk_mode q ulong to ulong +if ne lineis q 461229090915 5 0 +ret 1 +end +if ne lineis q 1954047342 4 0 +ret 2 +end +ret 0 +end + +fn chk_lead to void +e = get inlen 0 +p = ulong 0 +ln = ulong 1 +go = true +while go +m = ulong 0 +while and go lt m 999999 +q = skipbl p +if ge q e +go = false +else +if eq get inp q 10 +p = add q 1 +ln = add ln 1 +else +if ne isnote q 0 +p = skipln q +ln = add ln 1 +else +k = chk_mode q +if ne k 0 +put chkmode 0 k +put chkln 0 ln +put sbase 0 skipln q +end +go = false +end +end +end +m = add m 1 +end +end +end + +note om2lead: skip blank lines and note lines; when the next line is exactly om2 (1), om2 diag (2) or +note om2 fmt (3) the unit is OM-2: om2, om2m, om2ln, om2pos. Anything else leaves the unit OM-1. +fn om2lead to void +e = get inlen 0 +p = ulong 0 +ln = ulong 1 +if ne get chkmode 0 0 +p = get sbase 0 +ln = add get chkln 0 1 +end +go = true +while go +m = ulong 0 +while and go lt m 999999 +q = skipbl p +if ge q e +go = false +else +if eq get inp q 10 +p = add q 1 +ln = add ln 1 +else +if ne isnote q 0 +p = skipln q +ln = add ln 1 +else +r = ulong 0 +if eq q p +if ne lineis q 3304815 3 0 +r = ulong 1 +end +if ne lineis q 7449351137405332847 8 0 +r = ulong 2 +end +if ne lineis q 32771382692703599 7 0 +r = ulong 3 +end +if eq r 0 +r = cp_mode q +end +end +if ne r 0 +put om2 0 1 +put om2m 0 sub r 1 +put om2ln 0 ln +put om2pos 0 q +end +go = false +end +end +end +m = add m 1 +end +end +end + +note ---- om2 fmt (spec 2, errata E4, E6): only when the input's first line, at byte 0, is om2 fmt (an om2 +note fmt line elsewhere is error 16). The rest (the bytes after the first LF) is compiled as a unit of +note its own (OM-1 or OM-2 by its own first line) and, when it is accepted, its canonical text is written +note instead of the artifact. A CR anywhere and blank lines at the end are error 6. Lines and spans are +note reported against the whole input. +global fst ulong 1 +global fpend ulong 1 +global fbo ulong 1 +global fprp ulong 1 +global flso ulong 1 + +note fmttail: blank lines at the end of the rest (n bytes) are error 6, at the first such line +fn fmttail n ulong to void +lnb = ulong 0 +lnl = ulong 1 +ln = ulong 1 +i = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge i n +go = false +else +b = get inp i +if eq b 10 +ln = add ln 1 +else +if and ne b 32 ne b 9 +lnb = add i 1 +lnl = ln +end +end +i = add i 1 +end +m = add m 1 +end +end +bad = false +if eq lnb 0 +if gt n 0 +bad = true +lnl = ulong 0 +end +end +k = lnb +fl = n +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge k n +go = false +else +if eq get inp k 10 +fl = k +go = false +end +k = add k 1 +end +m = add m 1 +end +end +if lt add fl 1 n +bad = true +end +if bad +put line 0 add lnl 1 +put tka 0 lnb +put tkb 0 lnb +fail 6 +end +end + +fn fmtprep to void +if ne get om2pos 0 0 +put line 0 get om2ln 0 +put tka 0 get om2pos 0 +put tkb 0 get om2pos 0 +fail 16 +end +e = get inlen 0 +ln = ulong 1 +i = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge i e +go = false +else +b = get inp i +if eq b 13 +put line 0 ln +put tka 0 i +put tkb 0 add i 1 +fail 6 +end +if eq b 10 +ln = add ln 1 +end +i = add i 1 +end +m = add m 1 +end +end +r = skipln get om2pos 0 +put lbase 0 get om2ln 0 +put sbase 0 r +n = sub e r +j = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge j n +go = false +else +put inp j get inp add r j +j = add j 1 +end +m = add m 1 +end +end +put inlen 0 n +fmttail n +put om2 0 0 +put om2m 0 0 +put om2ln 0 0 +put fmtm 0 1 +om2lead +if eq get om2m 0 2 +put line 0 get om2ln 0 +put tka 0 get om2pos 0 +put tkb 0 get om2pos 0 +fail 16 +end +end + +note fmtbyte: one input byte of the canonical text. fst: 0 line start, 1 indentation (kept, dropped +note again on a blank line), 2 note line (copied), 3 between words, 4 in a word, 5 in a text literal, 6 +note after a backslash in a text literal. A run of blanks between words (fpend, starting at output byte +note fbo) is written as it comes, then becomes one space unless a parenthesis is next to it (fprp: the +note word before it was one); at the end of the line it is dropped. +fn fmtbyte p ulong to void +b = get inp p +s = get fst 0 +if eq b 10 +if lt s 2 +put oc 0 get flso 0 +else +if ne get fpend 0 0 +put oc 0 get fbo 0 +end +end +emitb 10 +put fst 0 0 +put fpend 0 0 +put fprp 0 0 +put flso 0 get oc 0 +ret +end +if eq s 2 +emitb b +ret +end +if eq s 5 +emitb b +if eq b 92 +put fst 0 6 +end +if eq b 34 +put fst 0 3 +put fprp 0 0 +end +ret +end +if eq s 6 +emitb b +put fst 0 5 +ret +end +blank = or eq b 32 eq b 9 +if lt s 2 +if blank +emitb b +put fst 0 1 +ret +end +if ne isnote p 0 +emitb b +put fst 0 2 +ret +end +put fst 0 3 +put fpend 0 0 +end +if blank +if eq get fpend 0 0 +put fbo 0 get oc 0 +put fpend 0 1 +end +emitb b +put fst 0 3 +ret +end +paren = or eq b 40 eq b 41 +if and eq get fst 0 4 not paren +emitb b +ret +end +if ne get fpend 0 0 +if and eq get fprp 0 0 not paren +put oc 0 get fbo 0 +emitb 32 +end +end +put fpend 0 0 +emitb b +if eq b 34 +put fst 0 5 +put fprp 0 0 +ret +end +if paren +put fst 0 3 +put fprp 0 1 +else +put fst 0 4 +put fprp 0 0 +end +end + +fn fmtout to void +put oc 0 0 +put fst 0 0 +put fpend 0 0 +put fprp 0 0 +put flso 0 0 +e = get inlen 0 +p = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +fmtbyte p +p = add p 1 +end +m = add m 1 +end +end +if ge get fst 0 2 +if ne get fpend 0 0 +put oc 0 get fbo 0 +end +emitb 10 +end +put fmtm 0 0 +put om2m 0 0 +writeout 0 +end + +note tok_hex (OM-2): 0x and 1..16 digits 0-9 a-f is the unsigned value (tk 2, tbig as tok_num). A - before +note 0x, 0X, no digits, more than 16 digits, an uppercase or any other character is error 6. 0 when the +note word is not a hex literal. +fn tok_hex to ulong +p = get ts 0 +e = get cur 0 +if eq get inp p 45 +q = add p 1 +if lt add q 1 e +if eq get inp q 48 +c = get inp add q 1 +if or eq c 120 eq c 88 +nfail 6 +end +end +end +ret 0 +end +if ge add p 1 e +ret 0 +end +if ne get inp p 48 +ret 0 +end +c = get inp add p 1 +if eq c 88 +nfail 6 +end +if ne c 120 +ret 0 +end +n = sub e add p 2 +if eq n 0 +nfail 6 +end +if gt n 16 +nfail 6 +end +v = ulong 0 +i = add p 2 +while lt i e +d = ulong get inp i +if and ge d 48 le d 57 +v = or shl v 4 sub d 48 +else +if and ge d 97 le d 102 +v = or shl v 4 sub d 87 +else +nfail 6 +end +end +i = add i 1 +end +put tbig 0 shr v 63 +put tw 0 v +put tk 0 2 +ret 1 +end + +note ---- float literals: a token is the decimal value fsgn * fnd * 10^fp10, fsuf 0 none / 1 f32 / 2 f64. +note fg_* hold the working state of the one literal being converted (see fparse/fbits/fnorm/fgen). +global fsgn ulong 1 +global fnd ulong 1 +global fp10 long 1 +global fsuf ulong 1 +global fg_fl ulong 1 +global fg_seen ulong 1 +global fg_ex long 1 +global fg_esign long 1 +global fg_ed ulong 1 +global fg_ty ulong 1 +global fg_e long 1 +global fg_q ulong 1 +global fg_m ulong 1 +global fg_stk ulong 1 +global fg_low ulong 1 +global fg_ov ulong 1 + +note ======== float literals: decimal text to IEEE-754 binary32/binary64 ======== +note The literal is fnd * 10^fp10. The converter normalizes fnd to a 64-bit significand, applies the +note decimal scale one factor of ten at a time (fmul10/fdiv10) while folding lost bits into one sticky +note flag, then rounds once (froundsh) and packs (fpack). It covers the full IEEE range, subnormals +note included, and refuses (error 8) only a value that rounds to infinity or whose digits do not fit +note in 2^63-1. + +note blen: bits needed for x (0 for zero) +fn blen x ulong to ulong +n = ulong 0 +while ne x 0 +x = shr x 1 +n = add n 1 +end +ret n +end + +note fparse: read the literal text inp[pos, pos+len) into fsgn, fnd, fp10, fsuf (0 none, 1 f32, 2 f64). +note Grammar: [-]digits[.digits][(e|E)[+|-]digits][f32|f64]. At most 2^63-1 significant digits +note (error 8), a dot with no digit after it is error 6, |exponent| <= 999 (error 8). +note The digit scans here and in fexp and the decimal steps in fbits run as nested 999999-pass loops: a +note literal of more than 1000000 zero digits trapped 4 in a single loop's hidden 1000000-pass guard (#965). +fn fparse pos ulong ln ulong to void +p = pos +e = add pos ln +put fsgn 0 0 +put fsuf 0 0 +put fnd 0 0 +put fg_fl 0 0 +put fg_seen 0 0 +if eq get inp p 45 +put fsgn 0 1 +p = add p 1 +end +go = true +while go +pos = ulong 0 +while and go lt pos 999999 +if ge p e +go = false +else +d = sub ulong get inp p 48 +if le d 9 +if gt get fnd 0 922337203685477580 +fail 8 +end +if eq get fnd 0 922337203685477580 +if gt d 7 +fail 8 +end +end +put fnd 0 add mul get fnd 0 10 d +if ne get fg_seen 0 0 +put fg_fl 0 add get fg_fl 0 1 +end +p = add p 1 +else +go = false +if eq get inp p 46 +if eq get fg_seen 0 0 +put fg_seen 0 1 +p = add p 1 +go = true +end +end +end +end +pos = add pos 1 +end +end +if and ne get fg_seen 0 0 eq get fg_fl 0 0 +fail 6 +end +p = fexp p e +p = fsufx p e +if ne p e +fail 6 +end +x = mul get fg_esign 0 get fg_ex 0 +put fp10 0 sub x long get fg_fl 0 +end + +note fexp: the exponent of the literal, if present: fg_ex, fg_esign, fg_ed. Returns the new position. +fn fexp p ulong e ulong to ulong +put fg_ex 0 0 +put fg_esign 0 1 +if and lt p e or eq get inp p 101 eq get inp p 69 +p = add p 1 +if lt p e +if or eq get inp p 43 eq get inp p 45 +if eq get inp p 45 +put fg_esign 0 -1 +end +p = add p 1 +end +end +put fg_ed 0 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +d = sub ulong get inp p 48 +if gt d 9 +go = false +else +put fg_ex 0 mul get fg_ex 0 10 +put fg_ex 0 add get fg_ex 0 long d +if gt get fg_ex 0 999 +fail 8 +end +put fg_ed 0 add get fg_ed 0 1 +p = add p 1 +end +end +m = add m 1 +end +end +if eq get fg_ed 0 0 +fail 6 +end +end +ret p +end + +note fsufx: the optional f32/f64 suffix: fsuf 1 or 2. Returns the new position. +fn fsufx p ulong e ulong to ulong +if lt p e +r = sub e p +if ne r 3 +fail 6 +end +if ne get inp p 102 +fail 6 +end +if and eq get inp add p 1 51 eq get inp add p 2 50 +put fsuf 0 1 +else +if and eq get inp add p 1 54 eq get inp add p 2 52 +put fsuf 0 2 +else +fail 6 +end +end +p = add p 3 +end +ret p +end + +note fbits: the parsed literal as IEEE bits of type ty (10 f32, 11 f64). Zero keeps the sign (-0.0). +note fmul10 / fdiv10: one exact decimal step on the normalized significand fg_m (value = fg_m * 2^fg_e), +note keeping fg_m in [2^63, 2^64) and folding every lost bit into fg_stk. No rounding happens here. +fn fmul10 to void +m = get fg_m 0 +hi = shr m 32 +lo = and m 4294967295 +p0 = mul lo 10 +p1 = mul hi 10 +hi2 = add p1 shr p0 32 +put fg_low 0 or shl and hi2 4294967295 32 and p0 4294967295 +put fg_ov 0 shr hi2 32 +fmn10 +end + +fn fmn10 to void +ov = get fg_ov 0 +low = get fg_low 0 +s = blen ov +if ne s 0 +st = or get fg_stk 0 and low sub shl 1 s 1 +put fg_stk 0 st +put fg_m 0 or shl ov sub 64 s shr low s +put fg_e 0 add get fg_e 0 long s +else +put fg_m 0 low +end +end + +fn fdiv10 to void +m = get fg_m 0 +q = div m 10 +if ne rem m 10 0 +put fg_stk 0 1 +end +s = ulong 0 +while lt q 9223372036854775808 +q = shl q 1 +s = add s 1 +end +put fg_m 0 q +put fg_e 0 sub get fg_e 0 long s +end + +note froundsh: round fg_m right by sh bits to fg_q, nearest even; the guard and every lower bit +note (plus fg_stk) decide. sh may be 64 (then q is zero and bit 63 is the guard). +fn froundsh sh ulong to void +m = get fg_m 0 +q = ulong 0 +guard = ulong 0 +lost = ulong 0 +if eq sh 0 +q = m +else +if ge sh 64 +guard = shr m 63 +lost = and m 9223372036854775807 +else +q = shr m sh +guard = and shr m sub sh 1 1 +if gt sub sh 1 0 +lost = and m sub shl 1 sub sh 1 1 +end +end +end +sticky = or get fg_stk 0 lost +if ne guard 0 +if or ne sticky 0 eq and q 1 1 +q = add q 1 +end +end +put fg_q 0 q +end + +note fpack: fg_m/fg_e to IEEE bits of fg_ty, including subnormals; a literal that rounds to infinity +note is refused (error 8). +fn fpack to ulong +p = ulong 53 +bias = long 1023 +maxe = long 2047 +emin = long -1022 +mb = ulong 52 +w = ulong 64 +if eq get fg_ty 0 10 +p = ulong 24 +bias = long 127 +maxe = long 255 +emin = long -126 +mb = ulong 23 +w = ulong 32 +end +e = add get fg_e 0 63 +if ge e emin +sh = sub 64 p +froundsh sh +q = get fg_q 0 +if eq q shl 1 p +q = shr q 1 +e = add e 1 +end +E = add e bias +if ge E maxe +fail 8 +end +q = and q sub shl 1 sub p 1 1 +q = or q shl ulong E mb +q = or q shl get fsgn 0 sub w 1 +ret q +end +k = ulong sub emin e +sh = add sub 64 p k +if gt sh 64 +ret shl get fsgn 0 sub w 1 +end +froundsh sh +q = get fg_q 0 +q = or q shl get fsgn 0 sub w 1 +ret q +end + +fn fbits ty ulong to ulong +put fg_ty 0 ty +put fg_stk 0 0 +if eq get fnd 0 0 +w = ulong 64 +if eq ty 10 +w = ulong 32 +end +b = ulong 0 +if ne get fsgn 0 0 +b = shl ulong 1 sub w 1 +end +ret b +end +b = blen get fnd 0 +sh = sub 64 b +put fg_m 0 shl get fnd 0 sh +put fg_e 0 sub 0 long sh +p = get fp10 0 +if gt p 0 +i = ulong 0 +n = ulong p +while lt i n +fmul10 +i = add i 1 +end +else +if lt p 0 +i = ulong 0 +n = ulong sub 0 p +while lt i n +c = sub n i +if gt c 999999 +c = ulong 999999 +end +for k ulong c +fdiv10 +end +i = add i c +end +end +end +ret fpack +end + +note fsizeof: sizeof T, or sizeof S for a struct: bytes. foffset: offsetof S f: the field's byte offset +note in the struct's 8-byte-cell layout. Both are compile-time constants of type ulong. +fn fsizeof dst ulong to void +sid = peek_struct +if ne sid 0 +si = sub sid 1 +n = ulong get st_cells si +vdone 3 mul n 8 5 +ret +end +t = typeword +if ge t 64 +fail 7 +end +v = shl 1 tlog t +vdone 3 v 5 +end + +fn foffset dst ulong to void +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +sid = findstruct get tw 0 +if eq sid 0 +unkfail 3 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +f = findfield sub sid 1 get tw 0 +if eq f 0 +fail 3 +end +off = ulong get sf_off sub f 1 +vdone 3 mul off 8 5 +end + +note fspan: a deferred literal stored as pos*16777216+len. Input stays below 2^23 bytes, so neither part +note overflows its field; the old pos*64+len read a literal of 64 or more characters from the wrong span (#965). +fn fspan ty ulong packed ulong to ulong +fparse div packed 16777216 rem packed 16777216 +ret fbits ty +end + +fn isfloat t ulong to ulong +if or eq t 10 eq t 11 +ret 1 +end +ret 0 +end + +note ======== om4's small tables, as functions ======== +note twid: width in bits by type 0..9 (bool 1; uchar ushort uint ulong; byte short int long) +fn twid t ulong to ulong +if eq t 13 +ret 64 +end +if eq t 10 +ret 32 +end +if eq t 11 +ret 64 +end +if eq t 1 +ret 1 +end +if or eq t 2 eq t 6 +ret 8 +end +if or eq t 3 eq t 7 +ret 16 +end +if or eq t 4 eq t 8 +ret 32 +end +if or eq t 5 eq t 9 +ret 64 +end +ret 0 +end + +note tlog: log2 of the element size by type +fn tlog t ulong to ulong +if eq t 13 +ret 3 +end +if eq t 10 +ret 2 +end +if eq t 11 +ret 3 +end +if or eq t 3 eq t 7 +ret 1 +end +if or eq t 4 eq t 8 +ret 2 +end +if or eq t 5 eq t 9 +ret 3 +end +ret 0 +end + +note regidx: the pool index of register r (the inverse of poolc; 255 for x7 and x16) +fn regidx r ulong to ulong +if lt r 7 +ret r +end +if eq r 7 +ret 255 +end +if lt r 16 +ret sub r 1 +end +if eq r 16 +ret 255 +end +ret 15 +end + +note conds: the condition for eq ne lt le gt ge (i = 2 (op - 43) + 1 when signed): EQ 0, NE 1, LO 3 / LT 11, +note LS 9 / LE 13, HI 8 / GT 12, HS 2 / GE 10 (Arm ARM Table C1-1). The opposite condition is cond xor 1. +fn conds i ulong to ulong +if lt i 2 +ret 0 +end +if lt i 4 +ret 1 +end +if eq i 4 +ret 3 +end +if eq i 5 +ret 11 +end +if eq i 6 +ret 9 +end +if eq i 7 +ret 13 +end +if eq i 8 +ret 8 +end +if eq i 9 +ret 12 +end +if eq i 10 +ret 2 +end +ret 10 +end + +note ldop / stop: register-offset load / store by element type (om4 LDOP, STOP tables) +fn ldop t ulong to ulong +note LDRB 0x38606800, LDRH 0x78607800, LDR w 0xb8607800, LDR x 0xf8607800, LDRSB 0x38a06800, +note LDRSH 0x78a07800, LDRSW 0xb8a07800 +if eq t 2 +ret 945842176 +end +if eq t 3 +ret 2019588096 +end +if eq t 4 +ret 3093329920 +end +if or or eq t 5 eq t 9 eq t 13 +ret 4167071744 +end +if eq t 10 +ret 3093329920 +end +if eq t 11 +ret 4167071744 +end +if eq t 6 +ret 950036480 +end +if eq t 7 +ret 2023782400 +end +if eq t 8 +ret 3097524224 +end +ret 0 +end + +fn stop t ulong to ulong +note STRB 0x38206800, STRH 0x78207800, STR w 0xb8207800, STR x 0xf8207800 +if or eq t 2 eq t 6 +ret 941647872 +end +if or eq t 3 eq t 7 +ret 2015393792 +end +if or eq t 4 eq t 8 +ret 3089135616 +end +if or or eq t 5 eq t 9 eq t 13 +ret 4162877440 +end +if eq t 10 +ret 3089135616 +end +if eq t 11 +ret 4162877440 +end +ret 0 +end + +note ---- trap list (8192 sites per function): output offset of the branch, trap code ---- +global tsite ulong 8192 +global tcode ulong 8192 +global nt ulong 1 +note ---- block stack (512): kind (1 if, 2 else, 3 while, 4 for), branch to patch, loop head, loop +note register, its type, names and held pool slots to restore at end, then-part ended (for else) ---- +global bkind ulong 512 +global bbr ulong 512 +global bhead ulong 512 +global breg ulong 512 +global btyp ulong 512 +global bnames ulong 512 +global bheld ulong 512 +global bdead ulong 512 +global nb ulong 1 +global curfn ulong 1 +note ---- break fixups (1024): output offset of the branch, block index of the loop it leaves ---- +global brkpos ulong 1024 +global brkblk ulong 1024 +global nbrk ulong 1 +global cpos ulong 1024 +global cblk ulong 1024 +global ncont ulong 1 +fn dcat_w code ulong to void +if or or eq code 4 eq code 6 eq code 16 +mputw 9104236865280339 7 +ret +end +if or or eq code 7 eq code 11 eq code 19 +mputw 138601847124 5 +ret +end +if or eq code 17 eq code 18 +mputw 138903768134 5 +ret +end +if or or eq code 3 eq code 10 eq code 13 +mputw 138601644366 5 +ret +end +if or or or eq code 12 eq code 14 eq code 23 eq code 24 +mputw 6436850320626696515 8 +mputb 32 +ret +end +if or eq code 8 eq code 21 +mputw 35481921143122 6 +ret +end +if or or or eq code 27 eq code 28 eq code 29 eq code 30 +mputw 6071768544483102531 8 +mputb 32 +ret +end +mputw 9104236865280339 7 +end + +fn dty_w t ulong to void +if eq t 1 +mputw 1819242338 4 +ret +end +if eq t 2 +mputw 491260502901 5 +ret +end +if eq t 3 +mputw 128034844210037 6 +ret +end +if eq t 4 +mputw 1953393013 4 +ret +end +if eq t 5 +mputw 444234427509 5 +ret +end +if eq t 6 +mputw 1702132066 4 +ret +end +if eq t 7 +mputw 500136110195 5 +ret +end +if eq t 8 +mputw 7630441 3 +ret +end +if eq t 9 +mputw 1735290732 4 +ret +end +if eq t 10 +mputw 3289958 3 +ret +end +if eq t 11 +mputw 3421798 3 +ret +end +if eq t 12 +mputw 1684631414 4 +ret +end +if eq t 13 +mputb 113 +mputb 116 +mputb 121 +ret +end +mputw 2003134838 4 +end + +fn dname_kind i ulong to void +k = ulong get nm_kind i +if eq k 4 +mputw 119165519096935 6 +ret +end +if eq k 5 +mputw 1954047348 4 +ret +end +if eq k 9 +mputw 500152823651 5 +ret +end +if or eq k 2 eq k 8 +mputw 2003134838 4 +ret +end +if or eq k 3 eq k 7 +mputw 1953064037 4 +ret +end +if ne get curfn 0 0 +f = sub get curfn 0 1 +np = ulong get fn_np f +endp = add get nglob 0 np +if and ge i get nglob 0 lt i endp +mputw 469786321264 5 +ret +end +end +mputw 465490374508 5 +end + +fn mput_name w ulong to void +x = w +go = true +while go +if eq x 0 +go = false +else +b = and x 255 +if eq b 0 +go = false +else +mputb uchar b +x = shr x 8 +end +end +end +end + +fn mput_fnname f ulong to void +o = get fn_off f +l = get fn_nmlen f +if and ne o 0 gt l 0 +i = ulong 0 +while lt i l +mputb get inp add o i +i = add i 1 +end +else +mput_name get fn_name f +end +end + +fn mput_tok a ulong b ulong to void +if eq a b +if eq get tk 0 3 +mputw 6713189 3 +ret +end +mputb 45 +ret +end +i = a +while and lt i b lt sub i a 16 +c = ulong get inp i +if and gt c 32 lt c 127 +mputb uchar c +else +mputh c +end +i = add i 1 +end +end + +fn diagrec code ulong to void +put mc 0 0 +mputw 7594244768023276911 8 +mputw 11207551510369 6 +if eq get om2 0 0 +mputw 3239279 3 +mputb 32 +else +mputw 3304815 3 +mputb 32 +end +dcat_w code +a = get tka 0 +b = get tkb 0 +if le b a +b = a +if gt get cur 0 a +b = get cur 0 +end +end +if gt b get inlen 0 +b = get inlen 0 +end +sa = a +sb = b +if ge sa get sbase 0 +sa = sub sa get sbase 0 +else +sa = ulong 0 +end +if ge sb get sbase 0 +sb = sub sb get sbase 0 +else +sb = ulong 0 +end +mputw 263844884595 5 +mputn sa +mputb 45 +mputn sb +mputb 32 +s = get dsev 0 +if eq s 0 +if eq get tk 0 3 +s = ulong 1 +end +if and eq code 22 ge get cur 0 get inlen 0 +s = ulong 1 +end +end +if eq s 1 +mputw 4993454379819552329 8 +mputw 2114900 3 +else +if eq s 2 +mputw 2327894055524716117 8 +else +mputw 35511885252934 6 +end +end +note Repairability is independent of prefix finality; only capacity failures are unrepairable. +if or or or eq code 12 eq code 14 eq code 23 eq code 24 +mputw 5929342197426179669 8 +mputw 138601579073 4 +else +mputw 4774187554571306322 8 +mputw 2114892 2 +end +mputw 67505686012704 6 +mputn code +mputw 67505853393952 6 +hl = get line 0 +if ne get chkmode 0 0 +if gt hl get chkln 0 +hl = sub hl get chkln 0 +else +hl = ulong 1 +end +end +mputn hl +mputw 4428273620941825312 8 +dexp_w code +mputw 17280399158765088 7 +mput_tok a b +mputb 10 +mflush +end + +fn emit_query to void +put mc 0 0 +mputw 8462595071175650671 8 +mputw 2869133187838565 7 +mputw 9071406607197043 7 +if eq get curfn 0 0 +mputw 7810779306727075700 8 +mputb 10 +mputw 7166760226508402531 8 +mputw 7142830393916027764 8 +mputw 8028905624785088111 8 +mputw 8392569455039504738 8 +mputw 2338603462594687776 8 +mputw 44651802478 5 +else +mputw 7957695015192261990 8 +mputb 10 +mputw 7166760226508402531 8 +mputw 2338605647353508724 8 +mputw 7308332192711599721 8 +mputw 7021802451731703328 8 +mputw 8079585727842951280 8 +mputw 9117624560546933 7 +mputw 1702129518 4 +in_loop = ulong 0 +j = get nb 0 +while and eq in_loop 0 gt j 0 +j = sub j 1 +if and ge get bkind j 3 le get bkind j 4 +in_loop = ulong 1 +end +end +if ne in_loop 0 +mputw 7142827075067601440 8 +mputw 749134030103146095 8 +else +mputb 10 +end +end +mputw 2879017064423790 7 +mflush +i = ulong 0 +while lt i get nn 0 +if ne get nm_name i 0 +mput_name get nm_name i +mputb 32 +dty_w ulong get nm_type i +mputb 32 +dname_kind i +mputb 10 +mflush +end +i = add i 1 +end +mputw 7957695015192261990 8 +mputw 670323 3 +mflush +f = ulong 0 +while lt f get nf 0 +mputw 2125414 3 +mput_fnname f +mputw 544175136 4 +dty_w ulong get fn_ret f +np = ulong get fn_np f +p = ulong 0 +while lt p np +mputb 32 +dty_w ulong get fn_pt add mul f 6 p +p = add p 1 +end +mputb 10 +mflush +f = add f 1 +end +mflush +exit int 0 +end +note ======== names and functions ======== +note findname: packed name -> its index + 1 among the names in scope (0 none). om4 FINDNAME. +fn findname w ulong to ulong +i = ulong 0 +n = get nn 0 +if ne get cpure 0 0 +n = get clim 0 +end +if eq i get nglob 0 +if gt get nmlo 0 i +i = get nmlo 0 +end +end +while lt i n +if eq get nm_name i w +ret add i 1 +end +i = add i 1 +if eq i get nglob 0 +if gt get nmlo 0 i +i = get nmlo 0 +end +end +end +ret 0 +end + +note findfn: packed name w (first 8 bytes), length l (any value up to 8 for a short name), start s in the +note input (read only for a name over 8 bytes) -> function index + 1 (0 none). om4 FINDFN. +fn findfn w ulong l ulong s ulong to ulong +j = ulong 0 +while lt j get nf 0 +if eq get fn_name j w +fl = get fn_nmlen j +if le l 8 +if le fl 8 +ret add j 1 +end +else +if eq fl l +o = get fn_off j +k = ulong 8 +same = true +while and same lt k l +a = get inp add o k +if ne a get inp add s k +same = false +end +k = add k 1 +end +if same +ret add j 1 +end +end +end +end +j = add j 1 +end +ret 0 +end + +note newname: the name must not be in use (a name in scope when 8 bytes or fewer, or a function): error 10 +fn newname w ulong l ulong s ulong to void +if ne findstruct w 0 +fail 10 +end +if le l 8 +if ne findname w 0 +fail 10 +end +if ne findlay w 0 +fail 10 +end +if ne findab w 0 +fail 10 +end +end +if ne findfn w l s 0 +fail 10 +end +end + +note addname: packed name, register, type, length, kind, address. om4 ADDNAME. +fn addname w ulong r ulong t ulong ln ulong k ulong a ulong to void +n = get nn 0 +if ge n 8192 +fail 14 +end +put nm_name n w +put nm_reg n uchar r +put nm_type n uchar t +put nm_len n ln +put nm_kind n uchar k +put nm_addr n a +put nm_fv n 0 +put nm_lay n 0 +put nm_fr n 0 +put nm_lr n 0 +put nn 0 add n 1 +end + +note ======== registers and words ======== +note alloc: the next free register of the pool (after the parameters); error 12 when none is left +fn alloc to ulong +i = add get npar 0 get nslot 0 +if ge i 16 +fail 12 +end +put vsl i 0 +put nslot 0 add get nslot 0 1 +ret poolc i +end + +note destreg: d, or a new temporary when d is 255 +fn destreg d ulong to ulong +if eq d 255 +ret alloc +end +ret d +end + +note e3: emit op | d | n << 5 | m << 16 +fn e3 op ulong d ulong n ulong m ulong to void +emit or or or op d shl n 5 shl m 16 +end + +note trapsite: note the place and code of a branch to the trap stub, then emit it. trapc: B.cond, as om4. +fn trapsite w ulong code ulong to void +n = get nt 0 +if ge n 8192 +fail 14 +end +put tsite n get oc 0 +put tcode n code +put nt 0 add n 1 +emit w +if eq get om2m 0 1 +siterec +end +end + +fn trapc cc ulong code ulong to void +if ne get xtarget 0 0 +xtrap cc code +ret +end +trapsite or 1409286144 cc code +end + +fn rdword at ulong to ulong +a = ulong get out at +b = shl ulong get out add at 1 8 +c = shl ulong get out add at 2 16 +d = shl ulong get out add at 3 24 +ret or or or a b c d +end + +fn wrword at ulong w ulong to void +put out at uchar and w 255 +put out add at 1 uchar and shr w 8 255 +put out add at 2 uchar and shr w 16 255 +put out add at 3 uchar and shr w 24 255 +end + +note bdisp: the checked word distance from a branch at `at` to `target` for its signed w-bit word field: +note w 19 for B.cond / CBZ / CBNZ (C6.2.34, C6.2.78, C6.2.77), w 26 for B (C6.2.35) and BL. The +note target must be word aligned and at most 2^(w-1) - 1 words forward or 2^(w-1) words back (w 19: 1048572 +note bytes forward, 1048576 back; w 26: 134217724 forward, 134217728 back), else error 24 before any +note artifact is accepted. Returns the distance masked to w bits. +fn bdisp at ulong target ulong w ulong to ulong +diff = sub target at +if ne and diff 3 0 +fail 24 +end +span = shl ulong 1 add w 1 +if and gt diff sub span 4 lt diff sub ulong 0 span +fail 24 +end +ret and shr diff 2 sub shl ulong 1 w 1 +end + +note patch19: the word distance from a B.cond / CBZ / CBNZ at `at` to `target`, into bits 5..23 +fn patch19 at ulong target ulong to void +if ne get xtarget 0 0 +xpatch at target +if eq target get oc 0 +put tgoc 0 target +end +ret +end +d = bdisp at target 19 +wrword at or rdword at shl d 5 +if eq target get oc 0 +put tgoc 0 target +end +end + +note patch26: the word distance from a B at `at` to `target`, into bits 0..25, checked by bdisp. The AArch64 +note output stops at 8 MiB = 2^23 bytes (emit, error 14), inside the 2^27-byte reach, so no legal program +note reaches error 24 here; the check keeps a wrong B from ever being written if that ceiling changes. +fn patch26 at ulong target ulong to void +if ne get xtarget 0 0 +xpatch at target +if eq target get oc 0 +put tgoc 0 target +end +ret +end +d = bdisp at target 26 +wrword at or rdword at d +if eq target get oc 0 +put tgoc 0 target +end +end + +note back: emit B to an earlier place (C6.2.35) +fn back addr ulong to void +if ne get xtarget 0 0 +p = xbranch 14 +xpatch p addr +ret +end +emit or 335544320 bdisp get oc 0 addr 26 +end + +note matconst: put a 64-bit value in register r: MOVZ (C6.2.285) or, for a value with the top bit set, +note MOVN (C6.2.284) with the first halfword that differs from the fill, then MOVK (C6.2.283) for each +note other such halfword. om4 MATCONST. +fn matconst r ulong v ulong to void +if ne get xtarget 0 0 +ximm 0 v +xstore 0 r +ret +end +fill = ulong 0 +mop = ulong 3531603968 +if ne shr v 63 0 +fill = ulong 65535 +mop = ulong 2457862144 +end +started = false +hw = ulong 0 +while lt hw 4 +h = and shr v shl hw 4 65535 +if ne h fill +if started +emit or or or 4068474880 shl h 5 shl hw 21 r +else +emit or or or mop shl xor h fill 5 shl hw 21 r +started = true +end +end +hw = add hw 1 +end +if not started +emit or mop r +end +end + +note canon: u8/u16/u32 UBFM Xr, Xr, #0, #w-1 (C6.2.487); i8/i16/i32 SBFM (C6.2.355); else nothing +fn canon r ulong t ulong to void +canonto r r t +end + +note canonto: canon of Xn written to Xd (the same UBFM / SBFM with Rd = d, Rn = n) +fn canonto d ulong n ulong t ulong to void +if ne get xtarget 0 0 +xload 0 n +xcanrax t +xstore 0 d +ret +end +if lt t 2 +ret +end +if eq t 5 +ret +end +if eq t 9 +ret +end +base = ulong 3544186880 +if gt t 5 +base = ulong 2470445056 +end +emit or or or base shl sub twid t 1 10 d shl n 5 +end + +note chkext: CMP Xr, Wr, SXTB/SXTH/SXTW (SUBS extended, C6.2.463), then B.NE trap code +fn chkext r ulong t ulong code ulong to void +if ne get xtarget 0 0 +xext r t code +ret +end +emit or or or 3944742943 shl sub t 2 13 shl r 16 shl r 5 +trapc 1 code +end + +note range: error 8 unless v is a value of type t; big = the number was written as 2^63 or more +fn range v ulong t ulong big ulong to void +w = twid t +if eq w 64 +if eq t 9 +if ne big 0 +fail 8 +end +ret +end +if ne big 0 +ret +end +if ne shr v 63 0 +fail 8 +end +ret +end +if ne big 0 +fail 8 +end +lim = shl ulong 1 w +if lt t 6 +if ge v lim +fail 8 +end +ret +end +half = shr lim 1 +if ge add v half lim +fail 8 +end +end + +note cset: CSET Xr, cond = CSINC Xr, XZR, XZR, opposite cond (C6.2.141) +fn cset r ulong cc ulong to void +if ne get xtarget 0 0 +xb 15 add 144 xcc cc 192 +xb 72 15 182 +emitb 192 +xstore 0 r +ret +end +emit or or 2594113504 r shl xor cc 1 12 +end + +note force: put a value (kind 1 register, 3 number, 4 flags, 9 float in a twin: FMOV Xr, Dn) in register +note r; a bare number is error 11 +fn force k ulong v ulong t ulong r ulong to void +if ne get xtarget 0 0 +if eq k 1 +xload 0 v +xstore 0 r +ret +end +end +if eq k 1 +if ne v r +emit or or 2852127712 r shl v 16 +end +ret +end +if or eq k 3 eq k 7 +matconst r v +ret +end +if eq k 4 +cset r v +ret +end +if eq k 9 +fv2x t vtw v r +ret +end +fail 11 +end + +note matreg: a register holding the value +fn matreg k ulong v ulong t ulong to ulong +if eq k 1 +ret v +end +if eq k 9 +fv2x t vtw v v +ret v +end +r = alloc +force k v t r +ret r +end + +note spop: ADD (C6.2.5) / SUB (C6.2.457) SP, SP by a multiple of 16 below 2^24: low 12 bits, then the +note high 12 bits LSL 12; nothing for a zero part +fn spop base ulong bytes ulong to void +lo = and bytes 4095 +if ne lo 0 +emit or or base 1023 shl lo 10 +end +hi = and shr bytes 12 4095 +if ne hi 0 +emit or or base 4195327 shl hi 10 +end +end + +fn spadd bytes ulong to void +if ne get xtarget 0 0 +xsp 0 bytes +ret +end +spop 2432696320 bytes +end + +fn spsub bytes ulong to void +if ne get xtarget 0 0 +xsp 1 bytes +ret +end +spop 3506438144 bytes +end + +note stkchk: program mode only: CMP SP, X28 (C6.2.463); B.LO trap 6 +fn stkchk to void +if ne get xtarget 0 0 +ret +end +if ne get progmode 0 0 +emit 3946603519 +trapc 3 6 +end +end + +note epi: give back the stack of the local arrays, then RET (C6.2.338) +fn epi to void +if ne get xtarget 0 0 +xload 0 0 +emitb 201 +emitb 195 +ret +end +spadd get stkbytes 0 +emit 3596551104 +end + +fn dead1 to void +put dead 0 1 +end + +note pushb / pushnh: open a block (om4 PUSHB, split in two because a call takes at most 6 values) +fn pushb br ulong k ulong head ulong reg ulong ty ulong to void +n = get nb 0 +if ge n 512 +fail 14 +end +put bkind n k +put bbr n br +put bhead n head +put breg n reg +put btyp n ty +put bdead n 0 +put nb 0 add n 1 +note fz_push / fz_else / fz_join: the sets when block n opens; at its else (the then sets kept, the +note opening sets back); at its end (kind k: 1 if, 2 else, 3 while, 4 for) +j = ulong 0 +while lt j get fz_n 0 +put fz_ent add mul n 16 j get fz_cur j +j = add j 1 +end +end + +fn pushnh names ulong hd ulong to void +n = sub get nb 0 1 +put bnames n names +put bheld n hd +end + +note ======== small readers ======== +fn elemtype t ulong to void +if lt t 2 +fail 9 +end +if ge t 64 +fail 7 +end +end + +note arrlen: an array length 1 .. 16777216 (error 8 below, 23 above, 23 when written as 2^63 or more) +fn arrlen v ulong to void +if ne get tbig 0 0 +fail 23 +end +if or eq v 0 ne shr v 63 0 +fail 8 +end +if gt v 16777216 +fail 23 +end +end + +note lenval: an array length, loop bound or trap code token: a number, or an integer constant name (kind 9). +note A name that is not an integer constant is error 16. When the line ends it is error eolc: 16 for a pool, +note a new array or a parameter written without its length (OMEGESE s.7, as om4), 4 for trap and bound. +fn lenval eolc ulong to ulong +tok +k = get tk 0 +if eq k 0 +fail eolc +end +if eq k 2 +ret get tw 0 +end +if eq k 1 +if le get tl 0 8 +e = findname get tw 0 +if ne e 0 +if eq get nm_kind sub e 1 9 +t = ulong get nm_type sub e 1 +if ge t 10 +fail 16 +end +put tbig 0 0 +ret get nm_addr sub e 1 +end +end +end +end +fail 16 +ret 0 +end + +note typeword: read a type name -> 1..9 +fn typeword to ulong +put dexp 0 2 +tok +k = get tk 0 +if eq k 0 +fail 4 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +c = kw get tw 0 +if eq c 0 +a = findab get tw 0 +if ne a 0 +ret add a 63 +end +unkfail 16 +end +if eq c 76 +fail 9 +end +if or eq c 88 eq c 89 +if ne get irmode 0 0 +fail 9 +end +end +if eq c 88 +ret 10 +end +if eq c 89 +ret 11 +end +if eq c 223 +ret 13 +end +if gt sub c 1 8 +fail 16 +end +ret c +end + +note eol: the line must end here +fn eol to void +put dexp 0 6 +tok +k = get tk 0 +if and ne k 0 ne k 3 +fail 5 +end +end + +note arrname: read an array name -> its index + 1 +fn arrname to ulong +put dexp 0 3 +tok +k = get tk 0 +if eq k 0 +fail 4 +end +if eq k 3 +fail 4 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +if eq kw get tw 0 193 +fail 9 +end +e = findname get tw 0 +if eq e 0 +fail 3 +end +if eq get nm_kind sub e 1 0 +fail 7 +end +ret e +end + +note topname: read a new name for a global or a text -> its packed word +fn topname to ulong +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +ret w +end + +note ---- value results (om4 x0 kind 1 register / 2 bare number / 3 typed number / 4 flags, x1 register, +note number or condition, x2 type). fr: 32 cells per value nesting depth 0..1024: 0..5 the two operands of +note a binary op (kind, value, type each), 8..25 a call's arguments (kind, value, array name each) ---- +global rk ulong 1 +global rv ulong 1 +global rt ulong 1 +global fr ulong 32800 +global depth ulong 1 + +note ======== BINOP (om4 BINOP and its BO_* parts): two values already read, types settled ======== +note bo_w3: emit fx | rd | ra << 5 | (imm12 << 10, or rb << 16) +fn bo_w3 fx ulong rd ulong ra ulong rb ulong imm ulong to void +if ne imm 0 +emit or or or fx rd shl ra 5 shl rb 10 +else +emit or or or fx rd shl ra 5 shl rb 16 +end +end + +note bo_fix: after a 64-bit op on rd: u8/u16/u32 wrap (canon), i8/i16/i32 overflow check (trap 1) +fn bo_fix rd ulong ty ulong to void +if lt ty 6 +canon rd ty +ret +end +if eq ty 9 +ret +end +chkext rd ty 1 +end + +note bo_schk: a shift amount in a register must be below the width: CMP Xb, #w; B.HS trap 7 +fn bo_schk ty ulong rb ulong to void +if ne get xtarget 0 0 +xload 0 rb +ximm 1 twid ty +xrr 57 0 1 +xtrap 2 7 +ret +end +emit or or 4043309087 shl twid ty 10 shl rb 5 +trapc 2 7 +end + +note add, sub: u32 the 32-bit form; i64 ADDS/SUBS + B.VS trap 1; others 64-bit then bo_fix (om4 BO_ADD) +fn bo_add op ulong ty ulong ra ulong rb ulong imm ulong rd ulong to void +if ne get xtarget 0 0 +xarith op ty ra rb imm rd +ret +end +fx = ulong 2332033024 +if eq op 34 +fx = ulong 3405774848 +end +if ne imm 0 +fx = ulong 2432696320 +if eq op 34 +fx = ulong 3506438144 +end +end +if eq ty 4 +bo_w3 xor fx 2147483648 rd ra rb imm +ret +end +if eq ty 9 +bo_w3 or fx 536870912 rd ra rb imm +trapc 6 1 +ret +end +if eq ty 13 +bo_w3 or fx 536870912 rd ra rb imm +if eq op 34 +trapc 3 1 +else +trapc 2 1 +end +ret +end +bo_w3 fx rd ra rb imm +bo_fix rd ty +end + +note mul: i64 SMULH t, MUL, CMP t, rd, ASR #63, B.NE trap 1 (om4 BO_MUL) +fn bo_mul ty ulong ra ulong rb ulong rd ulong to void +if ne get xtarget 0 0 +xarith 35 ty ra rb 0 rd +ret +end +if eq ty 9 +t = alloc +e3 2604694528 t ra rb +bo_w3 2600500224 rd ra rb 0 +e3 3951098911 0 t rd +trapc 1 1 +ret +end +if eq ty 13 +t = alloc +e3 2613083136 t ra rb +bo_w3 2600500224 rd ra rb 0 +emit or 4043309087 shl t 5 +trapc 1 1 +ret +end +if eq ty 4 +bo_w3 453016576 rd ra rb 0 +ret +end +bo_w3 2600500224 rd ra rb 0 +bo_fix rd ty +end + +note div, rem (om4 BO_DIV, BO_SDIV): CBZ Xb trap 2 unless fl bit 1 (b a number other than 0); UDIV or +note SDIV; rem: t = a / b, rd = a - t * b (MSUB); i64 div: CMN Xb, #1; B.NE +3; NEGS XZR, Xa; B.VS trap 1, +note unless fl bit 2 (b a number other than -1) +fn bo_div op ulong ty ulong ra ulong rb ulong rd ulong fl ulong to void +if ne get xtarget 0 0 +xdiv op ty ra rb rd fl +ret +end +if eq and fl 1 0 +trapsite or 3019898880 rb 2 +end +if eq op 37 +t = alloc +if and ge ty 6 le ty 9 +e3 2596277248 t ra rb +else +e3 2596276224 t ra rb +end +e3 or 2600501248 shl ra 10 rd t rb +ret +end +if or lt ty 6 eq ty 13 +bo_w3 2596276224 rd ra rb 0 +ret +end +if eq ty 9 +if eq and fl 2 0 +emit or 2969568287 shl rb 5 +emit 1409286241 +emit or 3942646783 shl ra 16 +trapc 6 1 +end +end +bo_w3 2596277248 rd ra rb 0 +if ne ty 9 +bo_fix rd ty +end +end + +note and, or, xor (om4 BO_LOG) +fn bo_log op ulong ra ulong rb ulong rd ulong to void +if ne get xtarget 0 0 +xarith op 5 ra rb 0 rd +ret +end +fx = ulong 2315255808 +if eq op 39 +fx = ulong 2852126720 +end +if eq op 40 +fx = ulong 3388997632 +end +bo_w3 fx rd ra rb 0 +end + +note bo_lsl: LSL Xd, Xn, #s as UBFM Xd, Xn, #(64-s) mod 64, #63-s +fn bo_lsl ra ulong s ulong rd ulong to void +if ne get xtarget 0 0 +xshift 41 5 ra s 1 rd +ret +end +r = shl and sub 64 s 63 16 +r = or r shl sub 63 s 10 +r = or r shl ra 5 +emit or or 3544186880 r rd +end + +note shl (om4 BO_SHL, BS_64): by a number s: UBFM Xd, Xn, #(64-s) mod 64, #63-s; by a register: the amount +note check, LSLV; i64: t = a << s, X16 = t >> s arithmetic, CMP X16, Xa, B.NE trap 1, MOV Xd, Xt +fn bo_shl ty ulong ra ulong rb ulong imm ulong rd ulong to void +if ne get xtarget 0 0 +xshift 41 ty ra rb imm rd +ret +end +if eq ty 9 +t = alloc +if ne imm 0 +bo_lsl ra rb t +emit or or 2470509584 shl rb 16 shl t 5 +else +bo_schk ty rb +e3 2596282368 t ra rb +e3 2596284432 0 t rb +end +emit or 3942646303 shl ra 16 +trapc 1 1 +emit or or 2852127712 rd shl t 16 +ret +end +if ne imm 0 +bo_lsl ra rb rd +bo_fix rd ty +ret +end +bo_schk ty rb +if eq ty 4 +bo_w3 448798720 rd ra rb 0 +ret +end +bo_w3 2596282368 rd ra rb 0 +bo_fix rd ty +end + +note shr: unsigned LSR, signed ASR; by a number UBFM / SBFM Xd, Xn, #s, #63; by a register the amount check +note then LSRV / ASRV (om4 BO_SHR) +fn bo_shr ty ulong ra ulong rb ulong imm ulong rd ulong to void +if ne get xtarget 0 0 +xshift 42 ty ra rb imm rd +ret +end +if ne imm 0 +fi = ulong 3544251392 +if ge ty 6 +fi = ulong 2470509568 +end +emit or or or fi shl rb 16 shl ra 5 rd +ret +end +bo_schk ty rb +fx = ulong 2596283392 +if ge ty 6 +fx = ulong 2596284416 +end +bo_w3 fx rd ra rb 0 +end + +note comparisons: CMP Xa, #imm or CMP Xa, Xb; the result is the flags and a condition (om4 BO_CMP) +fn bo_cmp op ulong ty ulong ra ulong rb ulong imm ulong to void +if ne get xtarget 0 0 +xcmp ra rb imm +else +if ne imm 0 +emit or or 4043309087 shl rb 10 shl ra 5 +else +emit or or 3942645791 shl rb 16 shl ra 5 +end +end +i = mul sub op 43 2 +if and ge ty 6 le ty 9 +i = add i 1 +end +put rk 0 4 +put rv 0 conds i +put rt 0 1 +end + +note Baseline SSE2, Intel SDM MOVD/MOVQ, scalar SS/SD, UCOMIS, CVTSI and CVTT instructions. +note WolframLanguageEvaluator: {2^31,2^63,2^22,2^51} -> {2147483648,9223372036854775808,4194304,2251799813685248}. +note WolframLanguageEvaluator: FromDigits[#,16]& /@ {"7F800000","7FF0000000000000","7FC00000","7FF8000000000000"} +note -> {2139095040,9218868437227405312,2143289344,9221120237041090560}. +fn xfmask ty ulong kind ulong to ulong +if eq ty 10 +if eq kind 0 +ret 2147483648 +end +if eq kind 1 +ret 2147483647 +end +if eq kind 2 +ret 4194304 +end +if eq kind 3 +ret 2139095040 +end +ret 2143289344 +end +if eq kind 0 +ret 9223372036854775808 +end +if eq kind 1 +ret 9223372036854775807 +end +if eq kind 2 +ret 2251799813685248 +end +if eq kind 3 +ret 9218868437227405312 +end +ret 9221120237041090560 +end + +note MOVD clears EAX's upper bits on extraction; no float sign extension. +fn xfmov ty ulong op ulong vr ulong to void +emitb 102 +if eq ty 11 +emitb 72 +end +xb 15 op add 192 shl vr 3 +end + +fn xfsse ty ulong op ulong mr ulong to void +if eq ty 10 +emitb 243 +else +emitb 242 +end +xb 15 op mr +end + +fn xfucom ty ulong mr ulong to void +if eq ty 11 +emitb 102 +end +xb 15 46 mr +end + +note Raw Intel condition for parity: existing xbranch takes the A64 condition vocabulary. +fn xfbranch cc ulong to ulong +p = get oc 0 +emitb 15 +emitb uchar add 128 cc +xword 0 +ret p +end + +note Leaves the raw value in RAX, magnitude in RCX, and unsigned magnitude-versus-infinity flags. +fn xfclass ty ulong r ulong to void +xload 0 r +ximm 1 xfmask ty 1 +xrr 33 1 0 +ximm 2 xfmask ty 3 +xrr 57 1 2 +end + +note Arm FPProcessNaNs priority: first signaling NaN, second signaling NaN, then first quiet NaN. +note minNum/maxNum additionally return the numeric argument when paired with one quiet NaN. +note Return the selected-result jump for the caller to patch past its normal arithmetic. +fn xfnans ty ulong a ulong b ulong num ulong d ulong to ulong +note Emit shared result stubs first so each case patches immediately instead of retaining its own fixup. +skip = xbranch 14 +quiet = get oc 0 +ximm 1 xfmask ty 2 +xrr 9 0 1 +store = get oc 0 +xstore 0 d +d = xbranch 14 +xpatch skip get oc 0 +xfclass ty a +skip = xbranch 8 +xfclass ty b +bn = xbranch 8 +none = xbranch 14 +xpatch skip get oc 0 +ximm 1 xfmask ty 2 +xrr 133 0 1 +p = xbranch 0 +xpatch p quiet +xfclass ty b +skip = xbranch 9 +ximm 1 xfmask ty 2 +xrr 133 0 1 +p = xbranch 0 +xpatch p quiet +xload 0 a +p = xbranch 14 +xpatch p store +xpatch skip get oc 0 +if ne num 0 +xload 0 b +else +xload 0 a +end +p = xbranch 14 +xpatch p store +xpatch bn get oc 0 +if ne num 0 +ximm 1 xfmask ty 2 +xrr 133 0 1 +p = xbranch 0 +xpatch p quiet +xload 0 a +p = xbranch 14 +xpatch p store +else +p = xbranch 14 +xpatch p quiet +end +xpatch none get oc 0 +ret d +end + +note SSE invalid arithmetic produces a negative indefinite NaN; Arm's default NaN is positive. +note Operand NaNs have already bypassed arithmetic, retaining their sign and payload. +fn xfdefnan ty ulong d ulong to void +xfclass ty d +ok = xbranch 9 +ximm 0 xfmask ty 4 +xstore 0 d +xpatch ok get oc 0 +end + +fn xfbin op ulong ty ulong a ulong b ulong d ulong to void +nanend = xfnans ty a b 0 d +f2v ty a 0 +f2v ty b 1 +code = ulong 89 +if eq op 33 +code = ulong 88 +end +if eq op 34 +code = ulong 92 +end +if eq op 36 +code = ulong 94 +end +xfsse ty code 193 +fv2x ty 0 d +xfdefnan ty d +xpatch nanend get oc 0 +end + +fn xfminmax c ulong ty ulong a ulong b ulong d ulong to void +nanend = xfnans ty a b 1 d +f2v ty a 0 +f2v ty b 1 +xfucom ty 193 +cc = ulong 3 +if eq c 94 +cc = ulong 8 +end +takea = xbranch cc +if eq c 94 +cc = ulong 3 +else +cc = ulong 8 +end +takeb = xbranch cc +note Equal finite operands have equal bits except signed zero: OR chooses -0, AND chooses +0. +xload 0 a +xload 1 b +if eq c 94 +xrr 33 0 1 +else +xrr 9 0 1 +end +xstore 0 d +equalend = xbranch 14 +xpatch takea get oc 0 +xload 0 a +xstore 0 d +aend = xbranch 14 +xpatch takeb get oc 0 +xload 0 b +xstore 0 d +xpatch equalend get oc 0 +xpatch aend get oc 0 +xpatch nanend get oc 0 +end + +note Normalize the predicate to TEST flags; callers retain the existing rk=4, rv=NE contract. +fn xfcmp op ulong ty ulong a ulong b ulong to void +f2v ty a 0 +f2v ty b 1 +xfucom ty 193 +unord = xfbranch 10 +cc = ulong 4 +if eq op 44 +cc = ulong 5 +end +if eq op 45 +cc = ulong 2 +end +if eq op 46 +cc = ulong 6 +end +if eq op 47 +cc = ulong 7 +end +if eq op 48 +cc = ulong 3 +end +xb 15 add 144 cc 192 +done = xbranch 14 +xpatch unord get oc 0 +if eq op 44 +ximm 0 1 +else +ximm 0 0 +end +xpatch done get oc 0 +xb 72 15 182 +emitb 192 +xrr 133 0 0 +put rk 0 4 +put rv 0 1 +put rt 0 1 +end + +fn xfsito ty ulong to void +if eq ty 10 +emitb 243 +else +emitb 242 +end +emitb 72 +xb 15 42 192 +end + +fn xfint ft ulong tt ulong a ulong d ulong to void +xload 0 a +if eq ft 5 +xrr 133 0 0 +small = xbranch 10 +note Sticky halve before signed conversion preserves nearest-even rounding for the unsigned high half. +xrr 137 2 0 +xb 72 209 234 +ximm 1 1 +xrr 33 0 1 +xrr 9 0 2 +xfsito tt +xfsse tt 88 192 +done = xbranch 14 +xpatch small get oc 0 +xfsito tt +xpatch done get oc 0 +else +xfsito tt +end +fv2x tt 0 d +end + +fn xfconst bits ulong to void +ximm 0 bits +xfmov 11 110 1 +end + +fn xfcvtt to void +emitb 242 +emitb 72 +xb 15 44 192 +end + +fn xftou64 to void +xfconst 4890909195324358656 +xfucom 11 193 +small = xbranch 3 +xfsse 11 92 193 +xfcvtt +ximm 1 9223372036854775808 +xrr 9 0 1 +done = xbranch 14 +xpatch small get oc 0 +xfcvtt +xpatch done get oc 0 +end + +note Widen f32 exactly, guard NaN and the destination's own bounds, then CVTT toward zero. +note WolframLanguageEvaluator: Table[BitShiftLeft[1023+k,52],{k,{7,8,15,16,31,32,63,64}}] +note -> {4638707616191610880,4643211215818981376,4674736413210574848,4679240012837945344,4746794007248502784,4751297606875873280,4890909195324358656,4895412794951729152}. +fn xftoint ft ulong tt ulong d ulong to void +n = twid tt +sg = and ge tt 6 le tt 9 +if eq ft 10 +xfsse 10 90 192 +end +xfucom 11 192 +nan = xfbranch 10 +if sg +n = sub n 1 +end +xfconst shl add ulong 1023 n 52 +xfucom 11 193 +above = xbranch 2 +if sg +xfconst or 9223372036854775808 shl add ulong 1023 n 52 +else +xfconst 0 +end +xfucom 11 193 +below = xbranch 9 +if and not sg eq n 64 +xftou64 +else +xfcvtt +end +done = xbranch 14 +xpatch nan get oc 0 +ximm 0 0 +nan = xbranch 14 +xpatch above get oc 0 +maxv = ulong 18446744073709551615 +if sg +maxv = sub shl ulong 1 n 1 +else +if lt n 64 +maxv = sub shl ulong 1 n 1 +end +end +ximm 0 maxv +above = xbranch 14 +xpatch below get oc 0 +if sg +ximm 0 sub ulong 0 shl ulong 1 n +else +ximm 0 0 +end +xpatch done get oc 0 +xpatch nan get oc 0 +xpatch above get oc 0 +xstore 0 d +end + +fn xfconv ft ulong tt ulong a ulong to ulong +if or eq ft 1 eq tt 1 +fail 9 +end +if or eq ft 13 eq tt 13 +fail 7 +end +if eq ft tt +ret a +end +d = alloc +if ge ft 10 +f2v ft a 0 +if ge tt 10 +xfsse ft 90 192 +fv2x tt 0 d +else +xftoint ft tt d +end +else +xfint ft tt a d +end +ret d +end + +note xfbinop: binop's float arm on x86: both operands in x registers, a compare or one SSE operation. +fn xfbinop op ulong dst ulong ix ulong ty ulong to void +ra = matreg get fr ix get fr add ix 1 ty +rb = matreg get fr add ix 3 get fr add ix 4 ty +if ge op 43 +xfcmp op ty ra rb +ret +end +if or or lt op 33 gt op 36 ge op 41 +fail 7 +end +rd = destreg dst +xfbin op ty ra rb rd +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note xfun1 / xfmm: fintr's and fminmax's x86 arms; the operand is in rk/rv (fminmax: the first in ak/av). +fn xfun1 c ulong t ulong dst ulong to void +ra = matreg get rk 0 get rv 0 t +rd = destreg dst +if eq c 91 +nanend = xfnans t ra ra 0 rd +f2v t ra 0 +xfsse t 81 192 +fv2x t 0 rd +xfdefnan t rd +xpatch nanend get oc 0 +else +xload 0 ra +ximm 1 xfmask t 1 +xrr 33 0 1 +xstore 0 rd +end +put rk 0 1 +put rv 0 rd +put rt 0 t +end + +fn xfmm c ulong at ulong ak ulong av ulong dst ulong to void +ra = matreg ak av at +rb = matreg get rk 0 get rv 0 at +rd = destreg dst +xfminmax c at ra rb rd +put rk 0 1 +put rv 0 rd +put rt 0 at +end + +note ---- floating point. A float value is its IEEE bit pattern: in an x register (kind 1, 7 a constant), +note or in a v register (kind 9, the twin of a pool register; float local names live there). Arithmetic +note runs one scalar FP instruction (round to nearest even, no fused op) on v registers: an x operand moves +note to v0/v1 first; a result wanted in x moves back from v1/v2, one wanted as kind 9 stays in its twin. +note f32 uses the S form (low 32 bits), f64 the D form. +fn f2v ty ulong xr ulong vr ulong to void +if ne get xtarget 0 0 +xload 0 xr +xfmov ty 110 vr +ret +end +if eq ty 10 +emit or or 505872384 shl xr 5 vr +else +emit or or 2657550336 shl xr 5 vr +end +end + +fn fv2x ty ulong vr ulong xr ulong to void +if ne get xtarget 0 0 +xfmov ty 126 vr +xstore 0 xr +ret +end +if eq ty 10 +emit or or 505806848 shl vr 5 xr +else +emit or or 2657484800 shl vr 5 xr +end +end + +note vtw: the twin of pool register r, v(16 + its pool index): v16..v31, caller-saved in AAPCS64 +fn vtw r ulong to ulong +ret add 16 regidx r +end + +note fv8d / fv8s: the FMOV (scalar, immediate) imm8 of f64 / f32 bits b, or 256 when there is none. imm8 is +note the sign, then bits 54..48 (f64) / 25..19 (f32). Encodable only when the fraction bits below those are +note zero and exponent bits 61..54 (f64) / 29..25 (f32) all equal NOT bit 62 / 30 (VFPExpandImm). +fn fv8d b ulong to ulong +if ne and b 281474976710655 0 +ret 256 +end +e = and shr b 54 255 +if and ne e 0 ne e 255 +ret 256 +end +if eq and shr b 62 1 and e 1 +ret 256 +end +s = shl shr b 63 7 +s = or s shl and e 1 6 +ret or s and shr b 48 63 +end + +fn fv8s b ulong to ulong +if ne and b 524287 0 +ret 256 +end +e = and shr b 25 31 +if and ne e 0 ne e 31 +ret 256 +end +if eq and shr b 30 1 and e 1 +ret 256 +end +s = shl and shr b 31 1 7 +s = or s shl and e 1 6 +ret or s and shr b 19 63 +end + +note fvk: float bits b of type ty into v register vr: 0 FMOV from XZR (C7.2.131); a value with an 8-bit +note form FMOV (scalar, immediate, C7.2.132); any other MOVZ/MOVK into X16, then FMOV from X16. +fn fvk ty ulong b ulong vr ulong to void +if eq b 0 +f2v ty 31 vr +ret +end +if eq ty 10 +im = fv8s b +if lt im 256 +emit or or 505417728 shl im 13 vr +ret +end +else +im = fv8d b +if lt im 256 +emit or or 509612032 shl im 13 vr +ret +end +end +matconst 16 b +f2v ty 16 vr +end + +note fvop: the v register holding float operand (kind k, value v, type t): its twin for kind 9, else v +note register s, filled from the constant or from the operand's x register. +fn fvop k ulong v ulong t ulong s ulong to ulong +if eq k 9 +ret vtw v +end +if eq k 7 +fvk t v s +ret s +end +r = matreg k v t +f2v t r s +ret s +end + +note fvdst: the pool register whose twin takes a kind 9 result for request o (fpw): 1 a new one, its slot +note marked as living in v; 2 + r the twin of r (a float local name). +fn fvdst o ulong to ulong +if eq o 1 +r = alloc +put vsl regidx r uchar 1 +ret r +end +ret sub o 2 +end + +note fvset: float value (kind k, value v, type t) into the twin of r: FMOV Dd, Dn (C7.2.130), the constant, +note or FMOV from its x register. Nothing when it is already there. +fn fvset k ulong v ulong t ulong r ulong to void +d = vtw r +if eq k 9 +if ne v r +if eq t 10 +emit or or 505430016 shl vtw v 5 d +else +emit or or 509624320 shl vtw v 5 d +end +end +ret +end +if eq k 7 +fvk t v d +ret +end +x = matreg k v t +f2v t x d +end + +note fp_binop: one FP add / sub / mul / div of v registers va, vb into vd +fn fp_binop op ulong ty ulong va ulong vb ulong vd ulong to void +base = ulong 509609984 +if eq ty 10 +base = ulong 505415680 +end +if eq op 33 +if eq ty 10 +base = ulong 505423872 +else +base = ulong 509618176 +end +else +if eq op 34 +if eq ty 10 +base = ulong 505427968 +else +base = ulong 509622272 +end +else +if eq op 36 +if eq ty 10 +base = ulong 505419776 +else +base = ulong 509614080 +end +end +end +end +emit or or or base shl vb 16 shl va 5 vd +end + +fn fp_neg ty ulong va ulong vd ulong to void +if eq ty 10 +emit or or ulong 505495552 shl va 5 vd +else +emit or or ulong 509689856 shl va 5 vd +end +end + +note fp_un1: sqrt (c 91) or abs of v register va into vd +fn fp_un1 c ulong ty ulong va ulong vd ulong to void +if eq c 91 +if eq ty 10 +emit or or ulong 505528320 shl va 5 vd +else +emit or or ulong 509722624 shl va 5 vd +end +else +if eq ty 10 +emit or or ulong 505462784 shl va 5 vd +else +emit or or ulong 509657088 shl va 5 vd +end +end +end + +note fp_minmax: FMINNM/FMAXNM, the IEEE minNum/maxNum rule: one quiet NaN returns the other operand, +note and -0.0 orders below +0.0. +fn fp_minmax c ulong ty ulong va ulong vb ulong vd ulong to void +base = ulong 509638656 +if eq c 94 +base = ulong 509634560 +end +if eq ty 10 +base = ulong 505444352 +if eq c 94 +base = ulong 505440256 +end +end +emit or or or base shl vb 16 shl va 5 vd +end + +note fintr: sqrt or abs of one float value; fminmax: min or max of two values of one float type. +note Both refuse a bare integer operand and an unresolved literal, as everywhere else. A request o (fpo) +note makes the result in a twin (kind 9); otherwise it moves to x register destreg dst (kind 1). +fn fintr c ulong dst ulong to void +o = get fpo 0 +put fpo 0 0 +if ne get irmode 0 0 +fail 9 +end +put fpw 0 1 +rdval 0 0 255 0 +if eq get rk 0 2 +fail 7 +end +if eq get rk 0 6 +fail 11 +end +t = get rt 0 +if eq isfloat t 0 +fail 7 +end +if ne get xtarget 0 0 +xfun1 c t dst +vdec +ret +end +va = fvop get rk 0 get rv 0 t 0 +if eq o 0 +rd = destreg dst +fp_un1 c t va 1 +fv2x t 1 rd +put rk 0 1 +put rv 0 rd +else +r = fvdst o +fp_un1 c t va vtw r +put rk 0 9 +put rv 0 r +end +put rt 0 t +vdec +end + +fn fminmax c ulong dst ulong to void +o = get fpo 0 +put fpo 0 0 +if ne get irmode 0 0 +fail 9 +end +put fpw 0 1 +rdval 0 0 255 0 +if or eq get rk 0 2 eq get rk 0 6 +fail 11 +end +at = get rt 0 +ak = get rk 0 +av = get rv 0 +put fpw 0 1 +rdval 0 0 255 0 +if or eq get rk 0 2 eq get rk 0 6 +fail 11 +end +if or eq isfloat at 0 eq isfloat get rt 0 0 +fail 7 +end +if ne at get rt 0 +fail 7 +end +if ne get xtarget 0 0 +xfmm c at ak av dst +vdec +ret +end +va = fvop ak av at 0 +vb = fvop get rk 0 get rv 0 at 1 +if eq o 0 +rd = destreg dst +fp_minmax c at va vb 2 +fv2x at 2 rd +put rk 0 1 +put rv 0 rd +else +r = fvdst o +fp_minmax c at va vb vtw r +put rk 0 9 +put rv 0 r +end +put rt 0 at +vdec +end + +note fcond: the condition for a float compare op: EQ, NE, MI (lt), LS (le), GT, GE. MI/LS/GT/GE are +note false for NaN, so unordered comparisons come out as the IEEE rules require. +fn fcond op ulong to ulong +i = sub op 43 +if eq i 0 +ret 0 +end +if eq i 1 +ret 1 +end +if eq i 2 +ret 4 +end +if eq i 3 +ret 9 +end +if eq i 4 +ret 12 +end +ret 10 +end + +note fp_cmp: FCMP Sn, Sm / Dn, Dm (scalar) of v registers va, vb: 0x1E202000 / 0x1E602000 with Rm and Rn +note zero, so both fields come from va and vb alone (#861: the S word had Rm bit 0 set, and an even vb +note read the next twin). +fn fp_cmp op ulong ty ulong va ulong vb ulong to void +if eq ty 10 +emit or or 505421824 shl vb 16 shl va 5 +else +emit or or 509616128 shl vb 16 shl va 5 +end +put rk 0 4 +put rv 0 fcond op +put rt 0 1 +end + +note fp_conv: one scalar conversion (int<->float, f32<->f64) into a new x register. Same type is a copy. +note Returns the register. A float result is made in v(rd), or in v0 when rd is x17 (v17 is a twin). +fn fp_conv ft ulong tt ulong ra ulong to ulong +if ne get xtarget 0 0 +ret xfconv ft tt ra +end +if eq ft tt +ret ra +end +if eq ft 1 +fail 9 +end +if eq tt 1 +fail 9 +end +rd = alloc +if eq isfloat tt 0 +f2v ft ra 0 +fp_toint ft tt rd +ret rd +end +vs = rd +if ge rd 16 +vs = ulong 0 +end +fp_tov ft tt ra vs +fv2x tt vs rd +ret rd +end + +note fp_tov: x register ra of type ft (an integer, or the other float type, moved to v0 first) converted +note to float type tt in v register vd: SCVTF/UCVTF (C7.2.236/C7.2.355) by signedness, FCVT (C7.2.69). +fn fp_tov ft ulong tt ulong ra ulong vd ulong to void +if ne isfloat ft 0 +f2v ft ra 0 +if eq ft 10 +emit or 505593856 vd +else +emit or 509755392 vd +end +ret +end +sgn = false +if ge ft 6 +sgn = true +end +if eq tt 10 +if eq twid ft 32 +if sgn +emit or or 505544704 shl ra 5 vd +else +emit or or 505610240 shl ra 5 vd +end +else +if sgn +emit or or 2653028352 shl ra 5 vd +else +emit or or 2653093888 shl ra 5 vd +end +end +else +if eq twid ft 32 +if sgn +emit or or 509739008 shl ra 5 vd +else +emit or or 509804544 shl ra 5 vd +end +else +if sgn +emit or or 2657222656 shl ra 5 vd +else +emit or or 2657288192 shl ra 5 vd +end +end +end +end + + +note fp_toint: float (v0) to integer rd: truncate toward zero, saturate to the destination's own range, NaN +note to 0 (OMEGESE 9.9; spec/one-layer-format.md 10.3). 32/64-bit: FCVTZS/FCVTZU (C7.2.90/C7.2.94) by +note signedness, int sign-extended (SXTW). 8/16-bit: the scalar SIMD FCVTZ[SU] in v0, then saturating +note narrows (SQXTN/UQXTN, C7.2.311/C7.2.374) to the width, FMOV W (C7.2.130), then SXTB/SXTH for signed. +fn fp_toint ft ulong tt ulong rd ulong to void +if ne get xtarget 0 0 +xftoint ft tt rd +ret +end +w = twid tt +sg = ge tt 6 +if eq w 64 +if sg +if eq ft 10 +emit or 2654470144 rd +else +emit or 2658664448 rd +end +else +if eq ft 10 +emit or 2654535680 rd +else +emit or 2658729984 rd +end +end +ret +end +if eq w 32 +if sg +if eq ft 10 +emit or 506986496 rd +else +emit or 511180800 rd +end +emit or or 2470476800 rd shl rd 5 +else +if eq ft 10 +emit or 507052032 rd +else +emit or 511246336 rd +end +end +ret +end +fp_narrow ft sg w +emit or 505806848 rd +if sg +if eq w 8 +emit or or 2470452224 rd shl rd 5 +else +emit or or 2470460416 rd shl rd 5 +end +end +end + +note fp_narrow: convert v0 in place to a saturated integer of width w (8 or 16) in its low bits. +fn fp_narrow ft ulong sg bool w ulong to void +if eq ft 10 +if sg +emit 1587656704 +emit 1583433728 +else +emit 2124527616 +emit 2120304640 +end +else +if sg +emit 1591851008 +emit 1587628032 +emit 1583433728 +else +emit 2128721920 +emit 2124498944 +emit 2120304640 +end +end +if eq w 8 +if sg +emit 1579239424 +else +emit 2116110336 +end +end +end + +note ---- rotate (OM-2, spec 3): rotr 59 / rotl 60 of an unsigned uchar..ulong by the same type. uint and +note ulong with a number below the width: ROR (immediate) = EXTR Rd, Rn, Rn, #s (C6.2.347, C6.2.160); +note otherwise the shift amount check (trap 7) then RORV (C6.2.349); rotl by n is ror by w - n (a number) +note or by NEG n (C6.2.295) since RORV takes the amount modulo the width. uchar/ushort first replicate the +note value through W16 with ORR (shifted register, LSL, C6.2.302), rotate the 32-bit pattern, then canon. +fn rotrep ty ulong ra ulong to void +if eq ty 3 +emit or or 704659472 shl ra 16 shl ra 5 +ret +end +emit or or 704651280 shl ra 16 shl ra 5 +emit 705708560 +end + +fn rotimm ty ulong ra ulong s ulong rd ulong to void +if ne get xtarget 0 0 +xrot ty ra s 1 rd +ret +end +if eq ty 5 +emit or or or 2478833664 shl ra 16 shl s 10 or shl ra 5 rd +ret +end +if eq ty 4 +emit or or or 327155712 shl ra 16 shl s 10 or shl ra 5 rd +ret +end +rotrep ty ra +emit or or 328204800 shl s 10 rd +canon rd ty +end + +fn rotreg ty ulong ra ulong rr ulong rd ulong to void +if ne get xtarget 0 0 +xrot ty ra rr 0 rd +ret +end +if eq ty 5 +emit or or 2596285440 shl rr 16 or shl ra 5 rd +ret +end +if eq ty 4 +emit or or 448801792 shl rr 16 or shl ra 5 rd +ret +end +rotrep ty ra +emit or or 448802304 shl rr 16 rd +canon rd ty +end + +fn binrot op ulong dst ulong ix ulong to void +ty = get fr add ix 2 +if or lt ty 2 gt ty 5 +fail 7 +end +ra = matreg get fr ix get fr add ix 1 ty +bk = get fr add ix 3 +bn = get fr add ix 4 +w = twid ty +rb = ulong 0 +useimm = false +if and eq bk 3 lt bn w +useimm = true +rb = bn +else +rb = matreg bk bn get fr add ix 5 +bo_schk ty rb +end +rd = destreg dst +if useimm +s = rb +if and eq op 60 ne s 0 +s = sub w s +end +rotimm ty ra s rd +else +rr = rb +if eq op 60 +rr = alloc +if ne get xtarget 0 0 +xload 0 rb +xb 72 247 216 +xstore 0 rr +else +emit or or 3405775840 shl rb 16 rr +end +end +rotreg ty ra rr rd +end +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note binop: op 33..48, destination (255 none), ix the fr slot of a (kind, number/register, type) then b. +note Result in rk/rv/rt. om4 BINOP. A float op reads its operands as v registers; with a request (fpo) +note the result stays in a twin (kind 9), else it moves to x (kind 1). +fn binop op ulong dst ulong ix ulong to void +if ne get fzone 0 0 +if and eq get fr ix 3 eq get fr add ix 3 3 +foldbin op get fr add ix 2 get fr add ix 1 get fr add ix 4 +if ne get fok 0 0 +put rk 0 3 +put rv 0 get fval 0 +put rt 0 get fty 0 +ret +end +end +end +if or eq op 59 eq op 60 +binrot op dst ix +ret +end +ty = get fr add ix 2 +if ne isfloat ty 0 +if ne get xtarget 0 0 +xfbinop op dst ix ty +ret +end +o = get fpo 0 +put fpo 0 0 +va = fvop get fr ix get fr add ix 1 ty 0 +vb = fvop get fr add ix 3 get fr add ix 4 ty 1 +if ge op 43 +fp_cmp op ty va vb +ret +end +if or or lt op 33 gt op 36 ge op 41 +fail 7 +end +if eq o 0 +rd = destreg dst +fp_binop op ty va vb 2 +fv2x ty 2 rd +put rk 0 1 +put rv 0 rd +else +r = fvdst o +fp_binop op ty va vb vtw r +put rk 0 9 +put rv 0 r +end +put rt 0 ty +ret +end +ra = matreg get fr ix get fr add ix 1 ty +if eq ty 13 +if and ge op 38 le op 42 +fail 7 +end +end +imm = ulong 0 +bk = get fr add ix 3 +bn = get fr add ix 4 +rb = ulong 0 +useimm = false +if eq bk 3 +if or eq op 41 eq op 42 +if lt bn twid ty +useimm = true +end +else +if or lt op 35 ge op 43 +if le bn 4095 +useimm = true +end +end +end +end +if useimm +rb = bn +imm = ulong 1 +else +rb = matreg bk bn get fr add ix 5 +end +if ge op 43 +bo_cmp op ty ra rb imm +ret +end +if eq ty 1 +if gt sub op 38 2 +fail 7 +end +end +rd = destreg dst +if lt op 35 +bo_add op ty ra rb imm rd +else +if eq op 35 +bo_mul ty ra rb rd +else +if lt op 38 +fl = ulong 0 +if and eq bk 3 ne bn 0 +fl = or fl 1 +end +if and eq bk 3 ne bn 18446744073709551615 +fl = or fl 2 +end +bo_div op ty ra rb rd fl +else +if lt op 41 +bo_log op ra rb rd +else +if eq op 41 +bo_shl ty ra rb imm rd +else +bo_shr ty ra rb imm rd +end +end +end +end +end +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note ======== calls: registers saved around a call and loaded back ======== +global svn ulong 1 +global sva ulong 1 +note save: n = registers in use (parameters + pool slots), A = 8 (n + 1) rounded up to 16: SUB SP, SP, #A +note (C6.2.457); the stack check; STR Xr, [SP, #8j] for each (C6.2.415), or STR Dj+16 (SIMD&FP, C7.2.331) +note for a slot living in its twin (vsl); STR X30, [SP, #8n]. Out: svn n, sva A. om4 SAVE. +fn save to void +if ne get xtarget 0 0 +xsave +ret +end +n = add get npar 0 get nslot 0 +a = shl shr add n 2 1 4 +put svn 0 n +put sva 0 a +spsub a +stkchk +j = ulong 0 +while lt j n +if ne get vsl j 0 +emit or or 4244636640 add j 16 shl j 10 +else +emit or or 4177527776 poolc j shl j 10 +end +j = add j 1 +end +emit or 4177527806 shl n 10 +end + +note loadarg: register t from an argument: kind 1, 5 or 9 a register v, read back from its save slot (LDR +note Xt, [SP, #8 slot], C6.2.216; a kind 9 slot holds the twin's D bits, the same bit pattern); kind 3, 6 +note or 7 the number, address or float bits v. om4 LOADARG. +fn loadarg t ulong k ulong v ulong to void +if ne get xtarget 0 0 +xarg t k v +ret +end +if or or eq k 3 eq k 6 eq k 7 +matconst t v +ret +end +emit or or 4181722080 t shl regidx v 10 +end + +note basearg: register t = the base of array name e (index + 1): its register from the save area, or its +note address. om4 BASEARG. +fn basearg t ulong e ulong to void +i = sub e 1 +if ge get nm_kind i 4 +mataddr t get nm_addr i +ret +end +loadarg t 1 ulong get nm_reg i +end + +note restore: d destination (255: a new temporary at pool slot `slot`), slot the pool slot before the +note arguments, n saved count, a save bytes, res 1 if there is a result in X0. MOV Xd, X0 (C6.2.282); LDR +note each register in use before the arguments except Xd (C6.2.216), or LDR Dj+16 (C7.2.191) instead for a +note slot living in its twin; LDR X30; ADD SP, SP, #A (C6.2.5). Returns Xd (255 when no result). om4 +note RESTORE. +fn restore d ulong slot ulong n ulong a ulong res ulong to ulong +if ne get xtarget 0 0 +ret xrestore d slot res +end +put nslot 0 slot +rd = ulong 255 +if ne res 0 +rd = d +if eq d 255 +rd = alloc +end +if ne rd 0 +emit or 2852127712 rd +end +end +m = add get npar 0 slot +j = ulong 0 +while lt j m +r = poolc j +if ne get vsl j 0 +emit or or 4248830944 add j 16 shl j 10 +else +if ne r rd +emit or or 4181722080 r shl j 10 +end +end +j = add j 1 +end +emit or 4181722110 shl n 10 +spadd a +ret rd +end + +note ca_bl: BL to function f (index + 1), C6.2.43 +fn ca_bl f ulong to void +n = get ncalls 0 +if ge n 524288 +fail 14 +end +put callsite n get oc 0 +put callfrom n get curfn 0 +put callto n f +put ncalls 0 add n 1 + +if ne get xtarget 0 0 +emitb 232 +xword 0 +else +emit or 2483027968 bdisp get oc 0 get fn_addr sub f 1 26 +end +end + +note ======== element addresses and array arguments ======== +global ea_b ulong 1 +global ea_i ulong 1 +global ea_k ulong 1 + +note eaem: the load or store word base (LDOP / STOP register-offset form) of register rt at ea_b / ea_i. +note ea_i 255 (OM-2, a number index k = ea_k up to 4095): the unsigned-offset form instead, same size, V +note (bit 26, the SIMD&FP forms) and opc bits, imm12 = k scaled by the element size (LDR/STR (immediate), +note C6.2.216 and its family; C7.2.191/C7.2.331). +fn eaem wd ulong rg ulong to void +b = get ea_b 0 +if eq get ea_i 0 255 +emit or or or or and wd 3300917248 956301312 shl get ea_k 0 10 shl b 5 rg +ret +end +emit or or or wd rg shl b 5 shl get ea_i 0 16 +end +note elemaddr: array name e (index + 1), index value (kind, number or register, type). A number index must +note be inside the array (error 21) and needs no check; a register index: CMP Xi, #len (C6.2.96) or CMP Xi, +note Xt (C6.2.97), B.HS trap 3 (unsigned, so a negative signed index traps too). Out: ea_b base register +note (the array's register, or a new one holding its address), ea_i index register. om4 ELEMADDR. +note OM-2 unsized array (unsz): every index, a number too, is checked against its count register nm_lr +note (CMP Xi, Xn; B.HS trap 3); none is eliminated (spec 4, 6). +fn elemaddr e ulong k ulong v ulong t ulong to void +if ne get xtarget 0 0 +xelem e k v t +ret +end +if or or eq t 1 eq t 10 eq t 11 +fail 7 +end +i = sub e 1 +ln = get nm_len i +x = v +if ne unsz i 0 +x = matreg k v t +emit or or 3942645791 shl ulong get nm_lr i 16 shl x 5 +trapc 2 3 +else +if eq k 3 +if ge v ln +fail 21 +end +if and ne get om2 0 0 le v 4095 +x = ulong 255 +put ea_k 0 v +else +x = alloc +matconst x v +end +else +if le ln 4095 +emit or or 4043309087 shl ln 10 shl v 5 +else +y = alloc +matconst y ln +emit or or 3942645791 shl y 16 shl v 5 +end +trapc 2 3 +end +end +put ea_i 0 x +if ge get nm_kind i 4 +b = alloc +matconst b get nm_addr i +put ea_b 0 b +else +put ea_b 0 ulong get nm_reg i +end +end + +note aa_word: the next word of an array argument must be a name of at most 8 bytes +fn aa_word to void +tok +k = get tk 0 +if eq k 0 +fail 4 +end +if ne k 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +end + +note arrarg: an array argument for parameter pi of function f (index + 1): [view | edit] NAME. Its type and +note length must equal the parameter's; an edit parameter needs a writable array (local or edit, error 20; +note a view passed to it is error 20, OMEGESE.md 9.4); a global is never passed (error 19). Out: rk 5 +note (register rv) or 6 (address rv, a text), rt the name entry. om4 ARRARG. +note OM-2: an unsized parameter (length 0) takes an array of any length (erratum E2), whose count goes to +note ul_k / ul_v at depth * 6 + pi: its count register, or its length as a number. `part` is read by arrpart. +fn arrarg f ulong pi ulong to void +md = ulong 0 +aa_word +w = get tw 0 +c = kw w +if ne c 0 +if eq c 193 +arrpart f pi 0 +ret +end +if or lt c 57 gt c 58 +fail 16 +end +md = c +aa_word +w = get tw 0 +if eq kw w 193 +arrpart f pi md +ret +end +end +e = findname w +if eq e 0 +fail 3 +end +i = sub e 1 +k = ulong get nm_kind i +if eq k 0 +fail 7 +end +if ge k 6 +fail 7 +end +if eq k 4 +fail 19 +end +p = add mul sub f 1 6 pi +if eq get fn_pk p 3 +if eq md 57 +fail 20 +end +if and ne k 1 ne k 3 +fail 20 +end +else +if eq md 58 +fail 7 +end +end +if ne get nm_type i get fn_pt p +fail 7 +end +ux = add mul get depth 0 6 pi +if eq get fn_pl p 0 +if ne unsz i 0 +put ul_k ux 1 +put ul_v ux ulong get nm_lr i +else +put ul_k ux 3 +put ul_v ux get nm_len i +end +else +if ne get nm_len i get fn_pl p +fail 7 +end +end +put rt 0 e +if eq k 5 +put rk 0 6 +put rv 0 get nm_addr i +else +put rk 0 5 +put rv 0 ulong get nm_reg i +end +end + +note arrpart (OM-2, spec 6): `part A o k` as argument pi of function f (index + 1); md 57 / 58 when `view` / +note `edit` was written before it. A is a name (a global is error 19, a fresh array 27); o, then k, are +note ulong values. Checks, in this order: o <= len A (CMP Xo, Xlen; B.HI trap 3), then k <= len A - o (SUB, +note CMP, B.HI trap 3); the wrapped o + k is never formed. The part is a view of A + o * size with count k: +note an edit when A is writable (local or edit) and no `view` was written, else a view. It goes only to an +note unsized parameter (error 7). Out as arrarg; rt is A, so for error 19 the part counts as its base. +fn arrpart f ulong pi ulong md ulong to void +p = add mul sub f 1 6 pi +e = arrname +i = sub e 1 +k = ulong get nm_kind i +if ge k 6 +fail 7 +end +if eq k 4 +fail 19 +end +fz_arg e +if eq get fn_pk p 3 +if eq md 57 +fail 20 +end +if and ne k 1 ne k 3 +fail 20 +end +else +if eq md 58 +fail 7 +end +end +if ne ulong get nm_type i ulong get fn_pt p +fail 7 +end +if ne get fn_pl p 0 +fail 7 +end +rdval 0 5 255 0 +k = get rt 0 +if and ne k 5 ne k 13 +fail 7 +end +ro = matreg get rk 0 get rv 0 k +rdval 0 5 255 0 +k = get rt 0 +if and ne k 5 ne k 13 +fail 7 +end +rn = matreg get rk 0 get rv 0 k +d = partck i ro rn +ux = add mul get depth 0 6 pi +put ul_k ux 1 +put ul_v ux rn +put rt 0 e +put rk 0 5 +put rv 0 d +end + +note partck: the two checks of part (name index i, o in ro, k in rn), then the part's base register +fn partck i ulong ro ulong rn ulong to ulong +rl = ulong get nm_lr i +if eq unsz i 0 +rl = alloc +matconst rl get nm_len i +end +if ne get xtarget 0 0 +xcmp ro rl 0 +xtrap 8 3 +d = alloc +xarith 34 5 rl ro 0 d +xcmp rn d 0 +xtrap 8 3 +b = ulong get nm_reg i +if eq get nm_kind i 5 +b = alloc +mataddr b get nm_addr i +end +xload 0 ro +xb 72 193 224 +emitb uchar tlog ulong get nm_type i +xload 1 b +xrr 1 0 1 +xstore 0 d +ret d +end +emit or or 3942645791 shl rl 16 shl ro 5 +trapc 8 3 +d = alloc +e3 3405774848 d rl ro +emit or or 3942645791 shl d 16 shl rn 5 +trapc 8 3 +b = ulong get nm_reg i +if eq get nm_kind i 5 +b = alloc +matconst b get nm_addr i +end +emit or or or or 2332033024 shl ro 16 shl tlog ulong get nm_type i 10 shl b 5 d +ret d +end + +note ======== the parts of the value reader that read no further value ======== +fn vdec to void +if and ne get cpure 0 0 ge get rt 0 10 +fail 30 +end +put depth 0 sub get depth 0 1 +end + +note vdone: a value's result, and one nesting level less (om4 VT_RET) +fn vdone k ulong v ulong t ulong to void +put rk 0 k +put rv 0 v +put rt 0 t +vdec +end + +note fwreq: hand this depth's fpw request to the part that makes the value (fpo) +fn fwreq to void +put fpo 0 get fwv get depth 0 +end + +note vt_un: neg / not of the value in rk/rv/rt (a bare number already refused). neg: NEG Xd, Xm (SUB from +note XZR, C6.2.458; the 32-bit form for u32), i64 NEGS + B.VS trap 1 (C6.2.465), then the wrap or the +note sign check; not: bool EOR Xd, Xn, #1 (C6.2.155), else MVN (ORN from XZR, C6.2.300), then the wrap. +note om4 VU1 .. VU_E. Float neg: FNEG (C7.2.144) of the operand's v register; with a request (fpo) the +note result stays in a twin (kind 9). +fn vt_un c ulong dst ulong to void +o = get fpo 0 +put fpo 0 0 +if ne get fzone 0 0 +if eq get rk 0 3 +foldun c get rt 0 get rv 0 +if ne get fok 0 0 +put rv 0 get fval 0 +ret +end +end +end +if ne get xtarget 0 0 +xunary c dst +ret +end +ty = get rt 0 +if or eq ty 10 eq ty 11 +if eq c 50 +fail 7 +end +va = fvop get rk 0 get rv 0 ty 0 +if eq o 0 +rd = destreg dst +fp_neg ty va 1 +fv2x ty 1 rd +put rk 0 1 +put rv 0 rd +else +r = fvdst o +fp_neg ty va vtw r +put rk 0 9 +put rv 0 r +end +put rt 0 ty +ret +end +ra = matreg get rk 0 get rv 0 ty +rd = destreg dst +if eq c 50 +if eq ty 13 +fail 7 +end +if eq ty 1 +e3 3527409664 rd ra 0 +else +if eq ty 4 +e3 706741216 rd 0 ra +else +e3 2854224864 rd 0 ra +if lt ty 6 +canon rd ty +end +end +end +else +if or eq ty 1 eq ty 13 +fail 7 +end +if eq ty 9 +e3 3942646752 rd 0 ra +trapc 6 1 +else +if eq ty 4 +e3 1258292192 rd 0 ra +else +e3 3405775840 rd 0 ra +if lt ty 6 +canon rd ty +else +chkext rd ty 1 +end +end +end +end +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note vt_conv: the value in rk/rv/rt converted to type tt (neither bool, error 9). Out of range when any bit +note at or above s is set: LSR Xt, Xa, #s (UBFM, C6.2.487); CBNZ Xt trap 5 (C6.2.77); signed to a narrower +note signed type: the sign-extension check, trap 5. om4 VTT1 .. VC_OK. To a float with a request (fpo): the +note conversion is made in a twin (kind 9); the same float type is left as it is. +fn vt_conv tt ulong to void +if ne get xtarget 0 0 +xconv tt +ret +end +o = get fpo 0 +put fpo 0 0 +ft = get rt 0 +if or or or eq ft 10 eq ft 11 eq tt 10 eq tt 11 +if or eq ft 13 eq tt 13 +fail 7 +end +if eq ft 1 +fail 9 +end +if eq tt 1 +fail 9 +end +if and ne o 0 ne isfloat tt 0 +if eq ft tt +ret +end +ra = matreg get rk 0 get rv 0 ft +r = fvdst o +fp_tov ft tt ra vtw r +put rk 0 9 +put rv 0 r +put rt 0 tt +ret +end +ra = matreg get rk 0 get rv 0 ft +rd = fp_conv ft tt ra +put rk 0 1 +put rv 0 rd +put rt 0 tt +ret +end +ra = matreg get rk 0 get rv 0 ft +if eq ft 1 +fail 9 +end +if eq tt 1 +fail 9 +end +wf = twid ft +wt = twid tt +s = ulong 99 +sgf = and ge ft 6 le ft 9 +sgt = and ge tt 6 le tt 9 +if eq sgf 0 +if ne sgt 0 +if ge wf wt +s = sub wt 1 +end +else +if gt wf wt +s = wt +end +end +else +if eq sgt 0 +s = wt +if gt s 63 +s = ulong 63 +end +else +if gt wf wt +chkext ra tt 5 +end +end +end +if ne s 99 +t = alloc +emit or or or 3544251392 t shl s 16 shl ra 5 +trapsite or 3036676096 t 5 +end +put rk 0 1 +put rv 0 ra +put rt 0 tt +end + +note vt_get: get A i with the index value in rk/rv/rt: the element address, then the load of the element +note type, register offset (LDOP table). om4 VT_GET. A float element with a request (fpo) loads straight +note into a twin: the same word with V (bit 26), LDR St/Dt (C7.2.192) (kind 9). +fn vt_get e ulong dst ulong to void +if ne get xtarget 0 0 +elemaddr e get rk 0 get rv 0 get rt 0 +st_ld get ea_b 0 get ea_i 0 ulong get nm_type sub e 1 dst +ret +end +o = get fpo 0 +put fpo 0 0 +elemaddr e get rk 0 get rv 0 get rt 0 +ty = ulong get nm_type sub e 1 +if and ne o 0 ne isfloat ty 0 +r = fvdst o +eaem or ldop ty 67108864 vtw r +put rk 0 9 +put rv 0 r +put rt 0 ty +ret +end +rd = destreg dst +eaem ldop ty rd +put rk 0 1 +put rv 0 rd +put rt 0 ty +end + +note vs_chk: read / write bounds: n <= len A and off <= len A - n, else trap 3 (CMP C6.2.97, B.HI C6.2.34, +note SUB C6.2.458). om4 VT_SYS. +fn vs_chk e ulong ro ulong rn ulong to void +if ne get xtarget 0 0 +if ne get nm_type sub e 1 2 +fail 7 +end +xload 1 rn +if ne unsz sub e 1 0 +xload 0 ulong get nm_lr sub e 1 +else +ximm 0 get nm_len sub e 1 +end +xrr 57 1 0 +xtrap 8 3 +xrr 41 0 1 +xload 1 ro +xrr 57 1 0 +xtrap 8 3 +ret +end +if ne get nm_type sub e 1 2 +fail 7 +end +t = alloc +l = ulong get nm_lr sub e 1 +if eq unsz sub e 1 0 +l = t +matconst t get nm_len sub e 1 +end +emit or or 3942645791 shl rn 5 shl l 16 +trapc 8 3 +e3 3405774848 t l rn +emit or or 3942645791 shl ro 5 shl t 16 +trapc 8 3 +end + +note vs_call: save the registers in use, X0 = fd, X1 = A + off (ADD through X16, C6.2.6), X2 = n, X8 = 63 +note (read) or 64 (write) (MOVZ C6.2.285), SVC #0 (C6.2.466). om4 VT_SYS. +fn vs_call c ulong fk ulong fv ulong e ulong ro ulong rn ulong to void +if ne get xtarget 0 0 +xio c fk fv e ro rn +ret +end +save +loadarg 0 fk fv +basearg 1 e +loadarg 16 1 ro +emit 2333081633 +loadarg 2 1 rn +emit or 3531603976 shl add c 10 5 +emit 3556769793 +end + +note ca_scal: a scalar argument just read (rk/rv/rt) for parameter p: flags into a register; its type +note must be the parameter's; stored at fr[q..q+2]. om4 CA1 .. CA_PUT. +fn ca_scal p ulong q ulong to void +if eq get rk 0 4 +put rv 0 matreg 4 get rv 0 get rt 0 +put rk 0 1 +put rt 0 1 +end +if ne get rt 0 ulong get fn_pt p +fail 7 +end +put fr q get rk 0 +put fr add q 1 get rv 0 +put fr add q 2 0 +end + +note ca_arr: an array argument i of function f, call frame cb: one array passed twice is error 19. +note om4 CA_ARR .. CA_PUT. +fn ca_arr f ulong i ulong cb ulong to void +arrarg f i +j = ulong 0 +while lt j i +if eq get fr add add cb mul j 3 2 get rt 0 +fail 19 +end +j = add j 1 +end +q = add cb mul i 3 +put fr q get rk 0 +put fr add q 1 get rv 0 +put fr add q 2 get rt 0 +end + +note ca_end: all arguments read: save, the arguments into X0.., BL, restore. Frame cb: 3 per argument, +note then cb+18 the parameter count, cb+19 the pool slot before the arguments. om4 CA_DONE .. CA5. +fn ca_end f ulong dst ulong cb ulong to void +save +np = get fr add cb 18 +i = ulong 0 +while lt i np +q = add cb mul i 3 +s = pslot sub f 1 i +loadarg s get fr q get fr add q 1 +if eq pwid add mul sub f 1 6 i 2 +ux = add mul div cb 32 6 i +loadarg add s 1 get ul_k ux get ul_v ux +end +i = add i 1 +end +ca_bl f +hr = ulong 1 +if eq get fn_ret sub f 1 12 +hr = ulong 0 +end +n = get svn 0 +a = get sva 0 +sl = get fr add cb 19 +r = restore dst sl n a hr +put rk 0 1 +put rv 0 r +put rt 0 ulong get fn_ret sub f 1 +end + +note vs_fd, vs_arr, vs_off, vs_end: the steps of read / write between the values it reads, with the fd +note (kind, value), the offset register and the pool slot before kept in fr[x+8..x+11] (om4's VT_SYS +note frame slots 4, 5, 7 and 14) +fn vs_fd x ulong to void +if ne get rt 0 8 +fail 7 +end +put fr add x 9 get rk 0 +put fr add x 10 get rv 0 +end + +fn vs_arr c ulong e ulong to void +fz_arg e +if ge get nm_kind sub e 1 6 +fail 7 +end +if eq c 53 +k = get nm_kind sub e 1 +if or eq k 2 eq k 5 +fail 20 +end +end +end + +fn vs_off x ulong to void +if ne get rt 0 5 +fail 7 +end +put fr add x 11 matreg get rk 0 get rv 0 get rt 0 +end + +fn vs_end c ulong e ulong dst ulong x ulong to void +if ne get rt 0 5 +fail 7 +end +rn = matreg get rk 0 get rv 0 get rt 0 +ro = get fr add x 11 +vs_chk e ro rn +fk = get fr add x 9 +fv = get fr add x 10 +vs_call c fk fv e ro rn +sl = get fr add x 8 +n = get svn 0 +a = get sva 0 +r = restore dst sl n a 1 +vdone 1 r 9 +end + +note Native Linux ARM64 host operations. Encoding forms are those in seed/rung2/table.s2. +note Syscall numbers and layouts: Linux asm-generic/unistd.h, fcntl.h and time.h. +note No raw address or arbitrary syscall is exposed to an Omega program. +fn hargc c ulong to ulong +if eq c 107 +ret 0 +end +if eq c 109 +ret 0 +end +if eq c 129 +ret 0 +end +if eq c 145 +ret 0 +end +if eq c 146 +ret 0 +end +if eq c 147 +ret 0 +end +if eq c 148 +ret 0 +end +if eq c 154 +ret 0 +end +if eq c 158 +ret 0 +end +if eq c 100 +ret 1 +end +if eq c 101 +ret 1 +end +if eq c 153 +ret 1 +end +if eq c 155 +ret 1 +end +if eq c 156 +ret 1 +end +if eq c 159 +ret 1 +end +if eq c 163 +ret 1 +end +if eq c 164 +ret 1 +end +if eq c 102 +ret 2 +end +if eq c 105 +ret 2 +end +if eq c 106 +ret 2 +end +if eq c 127 +ret 2 +end +if eq c 139 +ret 2 +end +if eq c 160 +ret 2 +end +if eq c 165 +ret 2 +end +if eq c 197 +ret 2 +end +ret 3 +end +fn hsysno c ulong to ulong +if eq c 127 +ret 129 +end +if eq c 129 +ret 172 +end +if eq c 100 +ret 57 +end +if eq c 101 +ret 82 +end +if eq c 102 +ret 52 +end +if eq c 103 +ret 62 +end +if eq c 104 +ret 198 +end +if eq c 139 +ret 46 +end +if eq c 145 +ret 174 +end +if eq c 146 +ret 175 +end +if eq c 147 +ret 176 +end +if eq c 148 +ret 177 +end +if eq c 144 +ret 48 +end +if eq c 153 +ret 50 +end +if eq c 154 +ret 173 +end +if eq c 155 +ret 166 +end +if eq c 156 +ret 83 +end +if eq c 157 +ret 279 +end +if eq c 158 +ret 157 +end +if eq c 159 +ret 155 +end +if eq c 160 +ret 154 +end +if eq c 163 +ret 156 +end +if eq c 164 +ret 267 +end +if eq c 165 +ret 210 +end +if eq c 197 +ret 32 +end +if eq c 105 +ret 201 +end +if eq c 106 +ret 242 +end +if eq c 107 +ret 220 +end +ret 24 +end +fn harg x ulong i ulong ty ulong to void +rdval 0 ty 255 0 +if ne get rt 0 ty +fail 7 +end +q = add add x 8 mul i 2 +put fr q get rk 0 +put fr add q 1 get rv 0 +end +fn hload x ulong i ulong reg ulong to void +q = add add x 8 mul i 2 +loadarg reg get fr q get fr add q 1 +end +fn hsys n ulong to void +matconst 8 n +emit 3556769793 +end +fn hreturn dst ulong x ulong to void +sl = get fr add x 7 +n = get svn 0 +a = get sva 0 +r = restore dst sl n a 1 +vdone 1 r 9 +end +fn hscalar c ulong dst ulong x ulong to void +np = hargc c +for i ulong np +ty = ulong 8 +if or and eq c 103 eq i 1 and eq c 139 eq i 1 +ty = ulong 9 +end +harg x i ty +end +save +for i ulong np +hload x i i +end +if eq c 106 +hload x 1 3 +matconst 1 0 +matconst 2 0 +end +if eq c 107 +matconst 0 17 +for i ulong 5 +matconst add i 1 0 +end +end +hsys hsysno c +hreturn dst x +end +fn hclock c ulong dst ulong x ulong to void +save +spsub 16 +stkchk +matconst 0 1 +if eq c 130 +matconst 0 0 +end +emit 2432697313 +hsys 113 +emit 4043309087 +bad = get oc 0 +emit 1409286155 +emit 4181722081 +emit 4181723106 +note Reject overflow before seconds are multiplied; clock result is a signed nanosecond count. +matconst 3 9223372036 +e3 3942645760 31 1 3 +trapc 8 1 +matconst 3 1000000000 +e3 2600500224 1 1 3 +e3 2868903936 0 1 2 +trapc 6 1 +patch19 bad get oc 0 +spadd 16 +hreturn dst x +end +fn harray x ulong writable ulong to ulong +e = arrname +if ne get nm_type sub e 1 2 +fail 7 +end +if ne writable 0 +vs_arr 53 e +end +fz_arg e +put fr add x 20 e +harg x 0 5 +harg x 1 5 +ro = matreg get fr add x 8 get fr add x 9 5 +rn = matreg get fr add x 10 get fr add x 11 5 +put fr add x 21 ro +put fr add x 22 rn +vs_chk e ro rn +ret e +end +note Copy a checked path to a private 4096-byte stack buffer. Reject embedded zero bytes. +note Public paths remain length-delimited; only the kernel-facing private copy has a terminator. +fn hpathcp x ulong to void +e = get fr add x 20 +save +basearg 4 e +loadarg 16 1 get fr add x 21 +e3 2332033024 4 4 16 +loadarg 5 1 get fr add x 22 +matconst 6 4095 +e3 3942645760 31 5 6 +trapc 8 3 +end +fn hcopy to void +spsub 4096 +stkchk +emit 2432697313 +head = get oc 0 +emit 4043309247 +done = get oc 0 +emit 1409286144 +emit 960495750 +emit 4043309279 +trapc 0 3 +emit 956301350 +emit 2432697476 +emit 2432697377 +emit 3506439333 +back head +patch19 done get oc 0 +emit 956301375 +emit 2432697313 +matconst 0 18446744073709551516 +end +fn hpath c ulong dst ulong x ulong to void +e = harray x 0 +if or eq c 110 eq c 151 +harg x 2 8 +harg x 3 8 +end +if or or or eq c 112 eq c 143 eq c 144 eq c 157 +harg x 2 8 +end +if eq c 150 +harg x 2 9 +end +hpathcp x +if or eq c 110 eq c 151 +hload x 2 2 +hload x 3 3 +end +if eq c 111 +matconst 2 0 +end +if eq c 126 +matconst 2 512 +end +if eq c 112 +hload x 2 2 +end +if or eq c 143 eq c 144 +hload x 2 2 +matconst 3 0 +end +if eq c 157 +hload x 2 2 +end +if eq c 150 +hload x 2 2 +end +hcopy +nr = ulong 56 +if or eq c 111 eq c 126 +nr = ulong 35 +end +if eq c 112 +nr = ulong 34 +end +if eq c 143 +nr = ulong 53 +end +if eq c 144 +nr = ulong 48 +end +if eq c 157 +nr = ulong 279 +end +if eq c 150 +nr = ulong 45 +end +if eq c 151 +nr = ulong 54 +end +if eq c 138 +nr = ulong 49 +note hcopy leaves AT_FDCWD in X0 and the path in X1; chdir takes the path in X0. +e3 2852126720 0 31 1 +end +if eq c 150 +note truncate takes the path in X0 and the length in X1. +e3 2852126720 0 31 1 +e3 2852126720 1 31 2 +end +if eq c 151 +note fchownat(dirfd, path, uid, gid, 0): X2/X3 are the ids, X4 is set after the copy. +matconst 4 0 +end +if eq c 157 +note memfd_create(name, flags): X0 = name, X1 = flags. +e3 2852126720 0 31 1 +e3 2852126720 1 31 2 +end +hsys nr +spadd 4096 +hreturn dst x +end +fn hbuffer c ulong dst ulong x ulong to void +harg x 4 8 +wr = ulong 0 +if or or or or or eq c 113 eq c 116 eq c 117 eq c 118 eq c 131 eq c 224 +wr = ulong 1 +end +e = harray x wr +if or or eq c 116 eq c 118 eq c 119 +harg x 2 8 +end +if or eq c 116 eq c 117 +need = ulong 4 +if eq c 117 +need = ulong 128 +end +tmp = alloc +matconst tmp need +e3 3942645760 31 get fr add x 22 tmp +trapc 3 3 +end +save +hload x 4 0 +basearg 1 e +loadarg 16 1 get fr add x 21 +e3 2332033024 1 1 16 +loadarg 2 1 get fr add x 22 +nr = ulong 61 +if eq c 114 +nr = ulong 203 +end +if eq c 115 +nr = ulong 200 +end +if eq c 116 +nr = ulong 260 +hload x 2 2 +matconst 3 0 +end +if eq c 117 +nr = ulong 80 +end +if or eq c 118 eq c 119 +nr = ulong 207 +hload x 2 3 +matconst 4 0 +matconst 5 0 +if eq c 119 +nr = ulong 206 +matconst 16 16384 +e3 2852126720 3 3 16 +end +end + +if or eq c 131 eq c 224 +note Socket-name queries use a private 32-bit socklen and return the full length. +spsub 16 +stkchk +emit 3103785954 +emit 2432697314 +if eq c 224 +hsys 205 +else +hsys 204 +end +emit 4043309087 +failed = get oc 0 +emit 1409286155 +emit 3107980256 +patch19 failed get oc 0 +spadd 16 +else +hsys nr +end +hreturn dst x +end +fn hargs c ulong dst ulong x ulong to void +if eq c 121 +save +emit 4181721952 +hreturn dst x +ret +end +if eq c 136 +note envcnt: walk the environment vector X27 + 8*(argc+2) (after argv's own null word) until the +note terminating null. +save +emit 4181721953 +emit 2432698401 +bo_lsl 1 3 1 +e3 2332033024 0 27 1 +matconst 2 0 +lb = get oc 0 +emit 4181721091 +brend = get oc 0 +emit 3019898883 +emit 2432697410 +emit 2432704512 +back lb +patch19 brend get oc 0 +emit 2852258784 +hreturn dst x +ret +end +harg x 4 5 +e = harray x 1 +save +hload x 4 0 +if eq c 137 +note envread: envp[index] lives at X27 + 8*(argc+2+index); scan the entries before it so an +note index at or past the count traps 3 even when the vector is sparse or empty. +emit 2852127714 +emit 4181721953 +emit 2432698401 +e3 2852126720 0 31 1 +matconst 16 8 +emit 2601548800 +e3 2332033024 3 27 0 +lb = get oc 0 +brend = get oc 0 +emit 3019898882 +emit 4181721188 +emit 4043309215 +trapc 0 3 +emit 2432704611 +emit 3506439234 +back lb +patch19 brend get oc 0 +emit 4181721187 +emit 4043309183 +trapc 0 3 +else +emit 4181721953 +e3 3942645760 31 0 1 +trapc 2 3 +emit 2432697344 +matconst 16 8 +e3 2600500224 0 0 16 +e3 2332033024 3 27 0 +emit 4181721187 +end +e3 2852126720 4 31 3 +matconst 5 0 +scan = get oc 0 +emit 960495750 +emit 4043309279 +done = get oc 0 +emit 1409286144 +emit 2432697476 +emit 2432697509 +matconst 16 1048576 +e3 3942645760 31 5 16 +trapc 2 3 +back scan +patch19 done get oc 0 +loadarg 2 1 get fr add x 22 +e3 3942645760 31 5 2 +small = get oc 0 +emit 1409286152 +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +e3 2852126720 2 31 5 +copy = get oc 0 +emit 4043309247 +endcp = get oc 0 +emit 1409286144 +emit 960495718 +emit 956301318 +emit 2432697443 +emit 2432697344 +emit 3506439333 +back copy +patch19 endcp get oc 0 +e3 2852126720 0 31 2 +endbr = get oc 0 +emit 335544320 +patch19 small get oc 0 +matconst 0 18446744073709551511 +patch26 endbr get oc 0 +hreturn dst x +end + +note waitio(fd int, events int, timeout_ns long): revents, 0 timeout, or negative errno. +note ppoll uses one private pollfd and one private timespec. Negative timeout is infinite. +fn hwaitio dst ulong x ulong to void +harg x 0 8 +harg x 1 8 +harg x 2 9 +save +hload x 0 0 +hload x 1 1 +hload x 2 2 +note pollfd.events is 16 bits; refuse truncation of the public int argument. +emit 4043309119 +trapc 11 3 +matconst 16 65535 +e3 3942645760 31 1 16 +trapc 8 3 +spsub 32 +stkchk +emit 4177527807 +emit 3103785952 +emit 2030046177 +matconst 3 1000000000 +emit 4043309151 +forever = get oc 0 +emit 1409286155 +e3 2596276224 4 2 3 +emit 2600700037 +emit 4177528804 +emit 4177529829 +emit 2432705506 +jump = get oc 0 +emit 335544320 +patch19 forever get oc 0 +matconst 2 0 +patch26 jump get oc 0 +emit 2432697312 +matconst 1 1 +matconst 3 0 +matconst 4 8 +hsys 73 +emit 4043309087 +failed = get oc 0 +emit 1409286157 +emit 2034241504 +patch19 failed get oc 0 +spadd 32 +hreturn dst x +end + +note A packed argument list is u16 count followed by count (u16 length, bytes) records. +note Byte order is little-endian. The packet is at most 4096 bytes and 64 records. +note The decoder constructs kernel pointers only in private stack memory. +fn hpack c ulong dst ulong x ulong to void +errs = new ulong 16 0 +tbl = new ulong 27 0 +e = harray x 0 +if eq c 125 +harg x 2 8 +end +save +basearg 4 e +loadarg 16 1 get fr add x 21 +e3 2332033024 4 4 16 +loadarg 5 1 get fr add x 22 +matconst 16 4096 +e3 3942645760 31 5 16 +trapc 8 3 +emit 4043311295 +trapc 3 3 +if eq c 125 +hload x 2 14 +end +spsub 8192 +stkchk +emit 2034237574 +emit 2432698500 +emit 3506440357 +emit 4043309279 +trapc 0 3 +matconst 16 64 +e3 3942645760 31 6 16 +trapc 8 3 +if or or eq c 125 eq c 141 eq c 142 +emit 4043311327 +trapc 1 3 +end +matconst 9 0 +emit 2432697322 +emit 2436892651 +outer = get oc 0 +e3 3942645760 31 9 6 +done = get oc 0 +emit 1409286146 +emit 4043311295 +trapc 3 3 +emit 2034237580 +emit 2432698500 +emit 3506440357 +e3 3942645760 31 12 5 +trapc 8 3 +note A program path and both rename paths must be nonempty. +if or eq c 124 eq c 198 +emit 4043309375 +notfirst = get oc 0 +emit 1409286145 +emit 4043309471 +trapc 0 3 +patch19 notfirst get oc 0 +else +emit 4043309471 +trapc 0 3 +end +emit 4177527146 +emit 2432704875 +inner = get oc 0 +emit 4043309471 +endstr = get oc 0 +emit 1409286144 +emit 960495757 +emit 4043309503 +trapc 0 3 +emit 956301645 +emit 2432697476 +emit 2432697674 +emit 3506439333 +emit 3506439564 +back inner +patch19 endstr get oc 0 +emit 956301663 +emit 2432697674 +emit 2432697641 +back outer +patch19 done get oc 0 +emit 4043309247 +trapc 1 3 +emit 4177527167 +if or eq c 124 eq c 198 +note Exec admits only the caller-assigned standard streams. Linux close_range with UNSHARE +note closes every descriptor >=3 in a private table. Failure returns without executing a child; +note no guessed descriptor ceiling or permissive fallback. This is not filesystem isolation. +matconst 0 3 +matconst 1 4294967295 +matconst 2 2 +hsys 436 +emit 4043309087 +note outer and done are dead after the packet scan; they are reused for the two branch sites here. +done = get oc 0 +emit 1409286145 +if eq c 198 +note execpure strict stdio profile: Linux UAPI layouts in 640 private guest stack bytes, never an +note exposed native pointer. sock_filter is u16 code,u8 jt,u8 jf,u32 k; sock_fprog has its length at +note 0 and its pointer at 8 on AArch64. A Landlock path rule is a packed u64 allowed_access plus an +note s32 parent_fd; prlimit64 takes two u64s. Each step that returns a negative value branches (B.LT) +note to the common restore with the kernel error in x0. ADD x16,SP,#k then STR x0,[x16] stores a word. +n = ulong 0 +spsub 640 +stkchk +mimmed 2432697312 16 0 632 +e3 4177526784 11 16 0 +note Extra descriptors are already closed in a private table. Pin the executable as descriptor 3. +matconst 0 18446744073709551516 +mimmed 2432697312 1 0 640 +matconst 2 2621440 +matconst 3 0 +hsys 56 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +note ABI3 rights through TRUNCATE are all handled, with only read/execute of that one inode allowed. +matconst 0 32767 +mimmed 2432697312 16 0 0 +e3 4177526784 0 16 0 +mimmed 2432697312 0 0 0 +matconst 1 8 +matconst 2 0 +hsys 444 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +matconst 0 5 +mimmed 2432697312 16 0 16 +e3 4177526784 0 16 0 +matconst 0 3 +mimmed 2432697312 16 0 24 +e3 4177526784 0 16 0 +matconst 0 4 +matconst 1 1 +mimmed 2432697312 2 0 16 +matconst 3 0 +hsys 445 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +matconst 0 38 +matconst 1 1 +matconst 2 0 +matconst 3 0 +matconst 4 0 +hsys 167 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +matconst 0 4 +matconst 1 0 +hsys 446 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +matconst 0 4 +hsys 57 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +note Per-process ceilings as (resource, soft, hard): CPU, FSIZE, STACK, CORE, NPROC, NOFILE, AS. +note Pipe-output and wall budgets additionally require the trusted supervisor. +put tbl 1 1 +put tbl 2 2 +put tbl 3 1 +put tbl 4 1048576 +put tbl 5 1048576 +put tbl 6 3 +put tbl 7 8388608 +put tbl 8 8388608 +put tbl 9 4 +put tbl 12 6 +put tbl 15 7 +put tbl 16 4 +put tbl 17 4 +put tbl 18 9 +put tbl 19 134217728 +put tbl 20 134217728 +for i ulong 7 +matconst 0 get tbl add mul i 3 1 +mimmed 2432697312 16 0 48 +e3 4177526784 0 16 0 +matconst 0 get tbl add mul i 3 2 +mimmed 2432697312 16 0 56 +e3 4177526784 0 16 0 +matconst 0 0 +matconst 1 get tbl mul i 3 +mimmed 2432697312 2 0 48 +matconst 3 0 +hsys 261 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +end +note Validate architecture, then read only 0, write only 1/2, exit/exit_group. Everything else is EPERM. +note execveat is restricted to descriptor 3 and AT_EMPTY_PATH; Landlock also binds execution to inode 3. +note The inode rule is essential: an absolute execveat path otherwise ignores its dirfd argument. +note Entry i = code | jt<<16 | jf<<24 | k<<32, stored at SP+128+8i. (code jt jf k) rows in order: +note (32 0 0 4) (21 1 0 3221225655) (6 0 0 2147483648) (32 0 0 0) (21 0 3 63) (32 0 0 16) (21 0 1 0) (6 0 0 2147418112) (32 0 0 0) +note (21 0 4 64) (32 0 0 16) (21 1 0 1) (21 0 1 2) (6 0 0 2147418112) (32 0 0 0) (21 0 1 93) (6 0 0 2147418112) (21 0 1 94) +note (6 0 0 2147418112) (32 0 0 0) (21 0 5 281) (32 0 0 16) (21 0 3 3) (32 0 0 48) (21 0 1 4096) (6 0 0 2147418112) (6 0 0 327681) +put tbl 0 ulong 17179869216 +put tbl 1 ulong 13835058841261244437 +put tbl 2 ulong 9223372036854775814 +put tbl 3 ulong 32 +put tbl 4 ulong 270633271317 +put tbl 5 ulong 68719476768 +put tbl 6 ulong 16777237 +put tbl 7 ulong 9223090561878065158 +put tbl 8 ulong 32 +put tbl 9 ulong 274945015829 +put tbl 10 ulong 68719476768 +put tbl 11 ulong 4295032853 +put tbl 12 ulong 8606711829 +put tbl 13 ulong 9223090561878065158 +put tbl 14 ulong 32 +put tbl 15 ulong 399448735765 +put tbl 16 ulong 9223090561878065158 +put tbl 17 ulong 403743703061 +put tbl 18 ulong 9223090561878065158 +put tbl 19 ulong 32 +put tbl 20 ulong 1206969696277 +put tbl 21 ulong 68719476768 +put tbl 22 ulong 12935233557 +put tbl 23 ulong 206158430240 +put tbl 24 ulong 17592202821653 +put tbl 25 ulong 9223090561878065158 +put tbl 26 ulong 1407379178520582 +for i ulong 27 +matconst 0 get tbl i +mimmed 2432697312 16 0 add 128 mul i 8 +e3 4177526784 0 16 0 +end +matconst 0 27 +mimmed 2432697312 16 0 80 +e3 4177526784 0 16 0 +mimmed 2432697312 0 0 128 +mimmed 2432697312 16 0 88 +e3 4177526784 0 16 0 +matconst 0 1 +matconst 1 0 +mimmed 2432697312 2 0 80 +hsys 277 +emit 4043309087 +put errs n get oc 0 +emit 1409286155 +n = add n 1 +note Restore the original packet stack before entering the pinned executable. Descriptor 3 is CLOEXEC. +mimmed 2432697312 16 0 632 +e3 4181721088 11 16 0 +spadd 640 +matconst 0 3 +e3 2852126720 1 31 11 +emit 2436892642 +e3 2852126720 3 31 11 +matconst 4 4096 +hsys 281 +outer = get oc 0 +emit 335544320 +while gt n 0 +n = sub n 1 +patch19 get errs n get oc 0 +end +mimmed 2432697312 16 0 632 +e3 4181721088 11 16 0 +spadd 640 +patch26 outer get oc 0 +else +emit 2432697312 +emit 2436892641 +e3 2852126720 2 31 11 +hsys 221 +end +patch19 done get oc 0 +else +if eq c 125 +emit 2436892656 +emit 4181721601 +emit 4181722627 +matconst 0 18446744073709551516 +matconst 2 18446744073709551516 +e3 2852126720 4 31 14 +hsys 276 +else +note linkat/symlnk: the packed list's two records are pointer-list entries 0 and 1. +emit 2436892656 +emit 4181721601 +emit 4181722627 +if eq c 141 +matconst 0 18446744073709551516 +matconst 2 18446744073709551516 +matconst 4 0 +hsys 37 +else +e3 2852126720 2 31 3 +e3 2852126720 0 31 1 +matconst 1 18446744073709551516 +hsys 36 +end +end +end +spadd 8192 +hreturn dst x +end + +fn hreadlnk dst ulong x ulong to void +e = harray x 0 +put fr add x 23 e +put fr add x 24 get fr add x 21 +put fr add x 25 get fr add x 22 +e = harray x 1 +put fr add x 26 e +put fr add x 27 get fr add x 21 +put fr add x 28 get fr add x 22 +put fr add x 20 get fr add x 23 +put fr add x 21 get fr add x 24 +put fr add x 22 get fr add x 25 +hpathcp x +note readlnk refuses an empty path before the kernel call. +emit 4043309247 +trapc 0 3 +basearg 2 get fr add x 26 +loadarg 16 1 get fr add x 27 +e3 2332033024 2 2 16 +loadarg 3 1 get fr add x 28 +hcopy +hsys 78 +spadd 4096 +hreturn dst x +end +note stat: path slice (readonly) + output slice, at least 128 bytes for the ARM64 stat structure. +note Linux newfstatat(AT_FDCWD, path, out, 0); returns 0 or -errno. A short output traps 3. +note pread/pwrite: fd, byte slice (off, n), position long. The file offset is not moved. +note pread (161) writes A, so A must be writable (error 20); pwrite (162) only reads A, so a text is allowed. +fn hpread c ulong dst ulong x ulong to void +harg x 4 8 +wr = ulong 0 +if eq c 161 +wr = ulong 1 +end +e = harray x wr +harg x 3 9 +save +hload x 4 0 +basearg 1 e +loadarg 16 1 get fr add x 21 +e3 2332033024 1 1 16 +loadarg 2 1 get fr add x 22 +hload x 3 3 +nr = ulong 67 +if eq c 162 +nr = ulong 68 +end +hsys nr +hreturn dst x +end + +fn hstat c ulong dst ulong x ulong to void +e = harray x 0 +put fr add x 23 e +put fr add x 24 get fr add x 21 +put fr add x 25 get fr add x 22 +e = harray x 1 +put fr add x 26 e +put fr add x 27 get fr add x 21 +put fr add x 28 get fr add x 22 +put fr add x 20 get fr add x 23 +put fr add x 21 get fr add x 24 +put fr add x 22 get fr add x 25 +hpathcp x +note stat refuses an empty path before the kernel call. +emit 4043309247 +trapc 0 3 +basearg 2 get fr add x 26 +loadarg 16 1 get fr add x 27 +e3 2332033024 2 2 16 +loadarg 3 1 get fr add x 28 +matconst 6 128 +e3 3942645760 31 3 6 +trapc 3 3 +matconst 3 0 +if eq c 149 +matconst 3 256 +end +hcopy +hsys 79 +spadd 4096 +hreturn dst x +end +fn hsockopt dst ulong x ulong to void +harg x 2 8 +harg x 3 8 +harg x 4 8 +e = harray x 0 +save +hload x 2 0 +hload x 3 1 +hload x 4 2 +basearg 3 e +loadarg 16 1 get fr add x 21 +e3 2332033024 3 3 16 +loadarg 4 1 get fr add x 22 +note Only scalar transport options; no filters, devices, credentials or pointer-bearing options. +hoptgate +hreturn dst x +end + +note Socket option allowlist. Linux asm-generic/socket.h and linux/tcp.h own these IDs. +note Unknown options retain ENOPROTOOPT (-92); malformed scalar sizes return EINVAL (-22). +fn hoptgate to void +ok = new ulong 6 0 +mimmed 4043309056 31 1 1 +tcp = get oc 0 +emit 1409286145 +for j ulong 5 +v = add j 5 +if eq j 0 +v = ulong 2 +end +if eq j 1 +v = ulong 15 +end +mimmed 4043309056 31 2 v +put ok j get oc 0 +emit 1409286144 +end +badso = get oc 0 +emit 335544320 +patch19 tcp get oc 0 +mimmed 4043309056 31 1 6 +badtcp = get oc 0 +emit 1409286145 +mimmed 4043309056 31 2 1 +put ok 5 get oc 0 +emit 1409286144 +patch26 badso get oc 0 +patch19 badtcp get oc 0 +matconst 0 sub ulong 0 92 +done = get oc 0 +emit 335544320 +for j ulong 6 +patch19 get ok j get oc 0 +end +mimmed 4043309056 31 4 4 +sizeok = get oc 0 +emit 1409286144 +matconst 0 sub ulong 0 22 +badsize = get oc 0 +emit 335544320 +patch19 sizeok get oc 0 +hsys 208 +patch26 done get oc 0 +patch26 badsize get oc 0 +end + +note SO_PEERCRED: fixed 12-byte ucred result, never a caller-chosen getsockopt operation. +fn hpeercr dst ulong x ulong to void +harg x 4 8 +e = harray x 1 +save +hload x 4 0 +basearg 3 e +loadarg 16 1 get fr add x 21 +e3 2332033024 3 3 16 +loadarg 4 1 get fr add x 22 +matconst 16 12 +e3 3942645760 31 4 16 +trapc 3 3 +matconst 1 1 +matconst 2 17 +spsub 16 +stkchk +matconst 4 12 +emit or ulong 3103785952 4 +emit or ulong 2432697312 4 +hsys 209 +spadd 16 +hreturn dst x +end + +note pollfds uses packed Linux pollfd records; length is bytes, each record is 8 bytes. +note Maximum 1024 records, checked before ppoll. Kernel writes only revents in the checked slice. +fn hpollfds dst ulong x ulong to void +e = harray x 1 +harg x 2 9 +save +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +loadarg 1 1 get fr add x 22 +matconst 16 7 +e3 2315255808 17 1 16 +mimmed 4043309056 31 17 0 +trapc 1 3 +matconst 16 8192 +e3 3942645760 31 1 16 +trapc 8 3 +matconst 16 8 +e3 2596276224 1 1 16 +hload x 2 2 +spsub 16 +stkchk +matconst 3 1000000000 +emit 4043309151 +forever = get oc 0 +emit 1409286155 +e3 2596276224 4 2 3 +emit 2600700037 +emit 4177527780 +emit 4177528805 +emit or ulong 2432697312 2 +jump = get oc 0 +emit 335544320 +patch19 forever get oc 0 +matconst 2 0 +patch26 jump get oc 0 +matconst 3 0 +matconst 4 8 +hsys 73 +spadd 16 +hreturn dst x +end + +note sendmsg has one checked iovec and no ancillary data or exposed kernel pointers. +note Arm ARM STR unsigned offset: imm12 scaled by 8, Rn=SP; private msghdr then iovec. +fn hsendmsg dst ulong x ulong to void +harg x 4 8 +e = harray x 0 +harg x 2 8 +save +hload x 4 0 +hload x 2 2 +matconst 16 16384 +e3 2852126720 2 2 16 +basearg 3 e +loadarg 16 1 get fr add x 21 +e3 2332033024 3 3 16 +loadarg 4 1 get fr add x 22 +spsub 80 +stkchk +for j ulong 10 +emit or or ulong 4177527776 31 shl j 10 +end +emit or or ulong 4177527776 3 shl ulong 8 10 +emit or or ulong 4177527776 4 shl ulong 9 10 +emit or or ulong 2432697312 3 shl ulong 64 10 +emit or or ulong 4177527776 3 shl ulong 2 10 +matconst 3 1 +emit or or ulong 4177527776 3 shl ulong 3 10 +emit or ulong 2432697312 1 +hsys 211 +spadd 80 +hreturn dst x +end + +note Bounded mapping table belongs to the emitted program, not the compiler process. +note 128 slots of address, byte length, generation, access. Only owned spans are accessible. +fn mtinit to void +if eq get maptab 0 0 +p = get poolb 0 +if gt p 1073737728 +fail 23 +end +put maptab 0 add 276824064 p +put poolb 0 add p 4096 +end +end +note Instruction forms in seed/rung2/table.s2. ldr/str offsets count eight-byte cells. +fn mload d ulong n ulong off ulong to void +emit or or or 4181721088 d shl n 5 shl off 10 +end +fn mstore d ulong n ulong off ulong to void +emit or or or 4177526784 d shl n 5 shl off 10 +end +fn mimmed op ulong d ulong n ulong k ulong to void +emit or or or op d shl n 5 shl k 10 +end +fn mbranch cc ulong to ulong +p = get oc 0 +emit or 1409286144 cc +ret p +end +note Validate a long handle in X10; produce entry X11, base X13, length X12. +note The slot's generation defeats a stale handle after close and slot reuse. +fn mcheck to void +matconst 15 255 +e3 2315255808 11 10 15 +mimmed 4043309056 31 11 1 +trapc 3 3 +mimmed 4043309056 31 11 128 +trapc 8 3 +mimmed 3506438144 11 11 1 +matconst 15 32 +e3 2600500224 11 11 15 +matconst 15 get maptab 0 +e3 2332033024 11 11 15 +mload 14 11 2 +mimmed 4043309056 31 14 0 +trapc 0 3 +matconst 15 8 +e3 2596283392 10 10 15 +e3 3942645760 31 10 14 +trapc 1 3 +mload 13 11 0 +mimmed 4043309056 31 13 0 +trapc 0 3 +mload 12 11 1 +end + +note mapnew fd:int offset:ulong bytes:ulong access:int mode:int -> long handle/errno. +note Access 1 or 3 and modes 1/2/33/34 must be literal. No fixed address or executable map. +fn mnew c ulong dst ulong x ulong to void +acc = ulong 0 +mode = ulong 1048610 +if eq c 167 +harg x 0 8 +harg x 1 5 +harg x 2 5 +harg x 3 8 +harg x 4 8 +if or ne get fr add x 14 3 ne get fr add x 16 3 +fail 9 +end +acc = get fr add x 15 +mode = get fr add x 17 +if and ne acc 1 ne acc 3 +fail 9 +end +if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34 +fail 9 +end +else +harg x 1 5 +harg x 2 5 +end +save +hload x 2 1 +mimmed 4043309056 31 1 0 +trapc 0 3 +matconst 15 68719476736 +e3 3942645760 31 1 15 +trapc 8 3 +if eq c 167 +hload x 0 4 +hload x 1 5 +if ge mode 32 +matconst 15 18446744073709551615 +e3 3942645760 31 4 15 +trapc 1 3 +mimmed 4043309056 31 5 0 +trapc 1 3 +end +else +hload x 1 0 +note Reservations are page aligned and bounded below the 40-bit GPU command limit. +matconst 15 65536 +e3 3942645760 31 0 15 +trapc 3 3 +matconst 15 1099511627776 +e3 3405774848 15 15 1 +e3 3942645760 31 0 15 +trapc 8 3 +matconst 15 4095 +e3 2315255808 14 0 15 +mimmed 4043309056 31 14 0 +trapc 1 3 +e3 2315255808 14 1 15 +mimmed 4043309056 31 14 0 +trapc 1 3 +matconst 4 18446744073709551615 +matconst 5 0 +end +matconst 9 get maptab 0 +matconst 10 1 +head = get oc 0 +mload 11 9 0 +mimmed 4043309056 31 11 0 +used = mbranch 1 +mload 11 9 2 +matconst 15 36028797018963967 +e3 3942645760 31 11 15 +vacant = mbranch 3 +patch19 used get oc 0 +mimmed 2432696320 9 9 32 +mimmed 2432696320 10 10 1 +mimmed 4043309056 31 10 128 +again = mbranch 9 +patch19 again head +matconst 0 18446744073709551592 +full = get oc 0 +emit 335544320 +patch19 vacant get oc 0 +if eq c 167 +matconst 0 0 +else +hload x 1 0 +end +matconst 2 acc +matconst 3 mode +hsys 222 +mimmed 4043309056 31 0 0 +failed = mbranch 11 +if eq c 176 +hload x 1 14 +e3 3942645760 31 0 14 +exact = mbranch 0 +note Old kernels may ignore NOREPLACE; reject and unmap any displaced result. +hsys 215 +mimmed 4043309056 31 0 0 +trapc 1 3 +matconst 0 18446744073709551521 +wrong = get oc 0 +emit 335544320 +patch19 exact get oc 0 +put fr add x 23 wrong +end +mstore 0 9 0 +mstore 1 9 1 +mimmed 2432696320 11 11 1 +mstore 11 9 2 +matconst 15 acc +mstore 15 9 3 +matconst 15 8 +e3 2596282368 0 11 15 +e3 2852126720 0 0 10 +patch19 failed get oc 0 +patch26 full get oc 0 +if eq c 176 +head = get fr add x 23 +patch26 head get oc 0 +end +hreturn dst x +end + +note Replace only an entire owned PROT_NONE reservation. Failed binds retire the handle. +fn mbind dst ulong x ulong to void +harg x 0 9 +harg x 1 8 +harg x 2 5 +harg x 3 8 +if ne get fr add x 14 3 +fail 9 +end +acc = get fr add x 15 +if and ne acc 1 ne acc 3 +fail 9 +end +save +hload x 0 10 +mcheck +mload 15 11 3 +mimmed 4043309056 31 15 0 +trapc 1 3 +e3 2852126720 0 31 13 +e3 2852126720 1 31 12 +matconst 2 acc +matconst 3 17 +hload x 1 4 +hload x 2 5 +hsys 222 +mimmed 4043309056 31 0 0 +failed = mbranch 11 +e3 3942645760 31 0 13 +trapc 1 3 +matconst 15 acc +mstore 15 11 3 +matconst 0 0 +done = get oc 0 +emit 335544320 +patch19 failed get oc 0 +e3 2852126720 10 31 0 +e3 2852126720 0 31 13 +e3 2852126720 1 31 12 +hsys 215 +mimmed 4043309056 31 0 0 +trapc 1 3 +mstore 31 11 0 +mstore 31 11 1 +mstore 31 11 3 +e3 2852126720 0 31 10 +patch26 done get oc 0 +hreturn dst x +end + +note Copies traverse only checked live mapped spans and normal bounded byte arrays. +note mapread writes A; mapwrite reads A. Both return the count, with no pointer decay. +fn mcopy c ulong dst ulong x ulong to void +harg x 4 9 +harg x 3 5 +wr = ulong 0 +if eq c 169 +wr = ulong 1 +end +e = harray x wr +save +hload x 4 10 +mcheck +mload 15 11 3 +mimmed 4043309056 31 15 0 +trapc 0 3 +hload x 3 0 +e3 3942645760 31 0 12 +trapc 8 3 +e3 3405774848 12 12 0 +loadarg 2 1 get fr add x 22 +e3 3942645760 31 2 12 +trapc 8 3 +e3 2332033024 0 13 0 +basearg 1 e +loadarg 16 1 get fr add x 21 +e3 2332033024 1 1 16 +if eq c 170 +mload 15 11 3 +mimmed 4043309056 31 15 3 +trapc 1 3 +e3 2852126720 15 31 0 +e3 2852126720 0 31 1 +e3 2852126720 1 31 15 +end +e3 2852126720 4 31 2 +head = get oc 0 +mimmed 4043309056 31 2 0 +done = mbranch 0 +emit 960495619 +emit 956301347 +mimmed 2432696320 0 0 1 +mimmed 2432696320 1 1 1 +mimmed 3506438144 2 2 1 +back head +patch19 done get oc 0 +e3 2852126720 0 31 4 +hreturn dst x +end + +note NVRM NVOS21/NVOS54 parameter binding. The kernel sees one private header. +note Pointer and length are derived from a checked byte span, never from user bytes. +note Request is exactly the 32-byte RM_ALLOC or RM_CONTROL encoding. +fn hdevcall dst ulong x ulong to void +n = xhreq 171 x +e = harray x 1 +put fr add x 23 e +put fr add x 24 get fr add x 21 +t = alloc +matconst t 32 +e3 3942645760 31 get fr add x 22 t +trapc 1 3 +f = harray x 1 +if eq e f +fail 19 +end +t = alloc +matconst t 16383 +e3 3942645760 31 get fr add x 22 t +trapc 8 3 +save +hload x 4 0 +hload x 2 1 +basearg 10 get fr add x 23 +loadarg 16 1 get fr add x 24 +e3 2332033024 10 10 16 +basearg 11 f +loadarg 16 1 get fr add x 21 +e3 2332033024 11 11 16 +loadarg 12 1 get fr add x 22 +note Refuse overlapping parameter/header spans even through distinct edit parameters. +mimmed 4043309056 31 12 0 +empty = mbranch 0 +e3 2332033024 14 11 12 +e3 3942645760 31 14 10 +before = mbranch 9 +mimmed 2432696320 14 10 32 +e3 3942645760 31 11 14 +trapc 3 3 +patch19 before get oc 0 +patch19 empty get oc 0 +mload 13 10 2 +mimmed 4043309056 31 13 0 +trapc 1 3 +mimmed 4043309056 31 12 0 +nonzero = mbranch 1 +matconst 11 0 +patch19 nonzero get oc 0 +spsub 32 +stkchk +for i ulong 4 +mload 13 10 i +mstore 13 31 i +end +mstore 11 31 2 +emit 3103792108 +emit 2432697314 +hsys 29 +for i ulong 4 +if ne i 2 +mload 13 31 i +mstore 13 10 i +end +end +spadd 32 +hreturn dst x +end + +note Mapped-address export for driver GPU VA serialization; no arbitrary-address access. +note Aligned word access uses exactly one 32/64-bit load/store bracketed by DSB SY. +fn mmapio c ulong dst ulong x ulong to void +harg x 0 9 +if eq c 173 +save +hload x 0 10 +mcheck +e3 2852126720 0 31 13 +hreturn dst x +put rt 0 5 +ret +end +harg x 1 5 +harg x 2 8 +if ne get fr add x 12 3 +fail 9 +end +w = get fr add x 13 +if and ne w 4 ne w 8 +fail 9 +end +if eq c 175 +harg x 3 5 +end +save +hload x 0 10 +mcheck +hload x 1 0 +mload 15 11 3 +mimmed 4043309056 31 15 0 +trapc 0 3 +e3 3942645760 31 0 12 +trapc 8 3 +e3 3405774848 12 12 0 +mimmed 4043309056 31 12 w +trapc 3 3 +matconst 15 sub w 1 +e3 2315255808 14 0 15 +mimmed 4043309056 31 14 0 +trapc 1 3 +e3 2332033024 13 13 0 +if eq c 175 +mload 15 11 3 +mimmed 4043309056 31 15 3 +trapc 1 3 +hload x 3 2 +if eq w 4 +matconst 15 4294967295 +e3 3942645760 31 2 15 +trapc 8 3 +end +emit 3573759903 +if eq w 4 +mimmed 3103784960 2 13 0 +else +mstore 2 13 0 +end +emit 3573759903 +matconst 0 0 +hreturn dst x +else +emit 3573759903 +if eq w 4 +mimmed 3107979264 0 13 0 +else +mload 0 13 0 +end +emit 3573759903 +hreturn dst x +put rt 0 5 +end +end + +fn hostval c ulong dst ulong to void +if eq get xtarget 0 1 +xhost c dst +ret +end +if ne get xtarget 0 0 +fail 25 +end +if eq get progmode 0 0 +fail 9 +end +x = mul get depth 0 32 +put fr add x 7 get nslot 0 +if eq c 197 +hscalar c dst x +ret +end +note execpure 198 is dispatched here, before the ge c 173 mapped-memory range below would claim it. +if eq c 198 +hpack c dst x +ret +end +if eq c 220 +hpeercr dst x +ret +end +if eq c 221 +hpollfds dst x +ret +end +if eq c 222 +hsendmsg dst x +ret +end +if eq c 224 +hbuffer c dst x +ret +end +if eq c 176 +mtinit +mnew c dst x +ret +end +if eq c 177 +mtinit +mbind dst x +ret +end +if ge c 173 +mtinit +mmapio c dst x +ret +end +if eq c 172 +note Linux UVM has unencoded commands. Exact allowlist and ABI580.173.02 byte sizes. +put fr add x 23 xhreq 172 x +e = harray x 1 +t = alloc +matconst t get fr add x 23 +e3 3942645760 31 get fr add x 22 t +trapc 1 3 +save +hload x 4 0 +hload x 2 1 +basearg 2 e +loadarg 16 1 get fr add x 21 +e3 2332033024 2 2 16 +hsys 29 +hreturn dst x +ret +end +if eq c 171 +hdevcall dst x +ret +end +if ge c 167 +mtinit +if eq c 167 +mnew c dst x +ret +end +if eq c 168 +harg x 0 9 +save +hload x 0 10 +mcheck +e3 2852126720 0 31 13 +e3 2852126720 1 31 12 +hsys 215 +mimmed 4043309056 31 0 0 +failed = mbranch 1 +mstore 31 11 0 +mstore 31 11 1 +mstore 31 11 3 +patch19 failed get oc 0 +hreturn dst x +ret +end +mcopy c dst x +ret +end +if eq c 166 +note Same bounded ioctl contract as L605 src/device/omc.om at 0dee699. +note Compose with native host words instead of maintaining a second compiler. +note Only literal FIONREAD or encoded read/write NVRM F requests, exact writable bytes. +put fr add x 23 xhreq 166 x +e = harray x 1 +t = alloc +matconst t get fr add x 23 +e3 3942645760 31 get fr add x 22 t +trapc 1 3 +save +hload x 4 0 +hload x 2 1 +basearg 2 e +loadarg 16 1 get fr add x 21 +e3 2332033024 2 2 16 +hsys 29 +hreturn dst x +ret +end +if eq c 132 +e = harray x 1 +save +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +loadarg 1 1 get fr add x 22 +hsys 17 +hreturn dst x +ret +end +if eq c 133 +hreadlnk dst x +ret +end +if eq c 134 +hsockopt dst x +ret +end +if eq c 135 +note random A off n flags: Linux getrandom into a writable byte slice. Returns the bytes written or +note minus the Linux error number. flags follows getrandom(2): 0 blocks until the pool is ready, +note 1 (GRND_NONBLOCK) returns -EAGAIN instead, 2 (GRND_INSECURE) may return non-cryptographic bytes. +e = harray x 1 +harg x 2 8 +save +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +loadarg 1 1 get fr add x 22 +hload x 2 2 +hsys 278 +hreturn dst x +ret +end +if or eq c 109 eq c 130 +hclock c dst x +ret +end +if or and ge c 113 le c 119 eq c 131 +hbuffer c dst x +ret +end +if eq c 120 +harg x 0 9 +save +hload x 0 2 +emit 4043309151 +trapc 11 3 +spsub 16 +stkchk +matconst 3 1000000000 +e3 2596276224 4 2 3 +note MSUB x5,x4,x3,x2 gives the subsecond remainder. +emit 2600700037 +emit 4177527780 +emit 4177528805 +emit 2432697312 +matconst 1 0 +hsys 101 +spadd 16 +hreturn dst x +ret +end +if eq c 123 +hwaitio dst x +ret +end +if or or or eq c 124 eq c 125 eq c 141 eq c 142 +hpack c dst x +ret +end +if or or or or or or eq c 126 eq c 138 eq c 143 eq c 144 eq c 150 eq c 151 eq c 157 +hpath c dst x +ret +end +if eq c 140 +hstat 140 dst x +ret +end +if eq c 149 +hstat 149 dst x +ret +end +if and ge c 145 le c 148 +hscalar c dst x +ret +end +if or or or eq c 153 eq c 154 eq c 155 eq c 156 +hscalar c dst x +ret +end +if and ge c 158 le c 160 +hscalar c dst x +ret +end +if or eq c 161 eq c 162 +hpread c dst x +ret +end +if and ge c 163 le c 165 +hscalar c dst x +ret +end +if or or eq c 127 eq c 129 eq c 139 +hscalar c dst x +ret +end +if eq c 128 +e = harray x 1 +harg x 2 8 +tmp = alloc +matconst tmp 8 +e3 3942645760 31 get fr add x 22 tmp +trapc 3 3 +save +basearg 0 e +loadarg 16 1 get fr add x 21 +e3 2332033024 0 0 16 +hload x 2 1 +hsys 59 +hreturn dst x +ret +end +if ge c 121 +put hostargs 0 1 +hargs c dst x +ret +end +if ge c 110 +hpath c dst x +ret +end +hscalar c dst x +end + +note ======== rdval: read one value (om4 VAL, VALTOK, CALL and the VT_ parts, one self-recursive +note function because a function calls only earlier functions or itself) ======== +note mode 0: read the first word; 1: the first word is the current token; 2: a call of function fe (index +note + 1), its arguments still to read. exp the expected type (0 none), dst the destination register (255 +note none). Out: rk kind (1 register, 2 bare number, 3 typed number, 4 flags, 9 a float in a twin, only when +note asked for by fpw), rv register / number / condition, rt type (for a bare number: 1 when written as 2^63 +note or more). Only the outermost op writes the destination. Every value nests one level deeper (at most +note 1024, error 14); a call does not. +fn rdval mode ulong exp ulong dst ulong fe ulong to void +note fwtake: rdval's entry: keep the caller's fpw request for this depth (none on x86, which has no twins) +if eq get xtarget 0 0 +put fwv add get depth 0 1 get fpw 0 +else +put fwv add get depth 0 1 0 +end +put fpw 0 0 +put dexp 0 1 +if eq mode 2 +if ne get cpure 0 0 +fail 30 +end +if ne get om2 0 0 +if ne get fn_inl sub fe 1 0 +inl_call fe dst +ret +end +end +cb = add mul get depth 0 32 8 +put fr add cb 18 ulong get fn_np sub fe 1 +put fr add cb 19 get nslot 0 +if eq get progmode 0 0 +if eq get curfn 0 fe +fail 9 +end +end +i = ulong 0 +while lt i get fr add cb 18 +p = add mul sub fe 1 6 i +if eq get fn_pk p 0 +if ne isfloat ulong get fn_pt p 0 +put fpw 0 1 +end +rdval 0 ulong get fn_pt p 255 0 +ca_scal p add cb mul i 3 +else +if ge get fn_pk p 6 +ca_st fe i cb +else +ca_arr fe i cb +fz_arg get rt 0 +end +end +i = add i 1 +end +ca_end fe dst cb +ret +end +if eq mode 0 +tok +end +if ne get cpure 0 0 +cp_token +end +put depth 0 add get depth 0 1 +if gt get depth 0 1024 +fail 14 +end +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if eq get tk 0 4 +fail 16 +end +if eq get tk 0 5 +if ne get irmode 0 0 +fail 9 +end +if ge exp 64 +fail 7 +end +fparse get ts 0 get tl 0 +t = ulong 0 +if eq get fsuf 0 0 +if eq exp 0 +vdone 6 add mul get ts 0 16777216 get tl 0 ulong 0 +ret +end +if eq isfloat exp 0 +fail 7 +end +t = exp +else +t = ulong 10 +if eq get fsuf 0 2 +t = ulong 11 +end +if and ne exp 0 ne exp t +fail 7 +end +end +v = fbits t +vdone 7 v t +ret +end +if eq get tk 0 2 +if eq exp 0 +vdone 2 get tw 0 get tbig 0 +ret +end +if ge exp 64 +fail 7 +end +range get tw 0 exp get tbig 0 +vdone 3 get tw 0 exp +ret +end +if gt get tl 0 8 +f = findfn get tw 0 get tl 0 get ts 0 +if eq f 0 +unkfail 13 +end +if eq get fn_ret sub f 1 12 +fail 7 +end +rdval 2 0 dst f +vdec +ret +end +c = kw get tw 0 +if eq c 178 +xefival dst +ret +end +if eq c 0 +if ne get cpure 0 0 +if eq get tw 0 128009175786866 +if eq get crkind 0 0 +fail 30 +end +vdone get crkind 0 get crval 0 get crtype 0 +ret +end +end +e = findname get tw 0 +if ne e 0 +if eq get nm_kind sub e 1 9 +ct = ulong get nm_type sub e 1 +cv = get nm_addr sub e 1 +if ne isfloat ct 0 +vdone 7 cv ct +else +vdone 3 cv ct +end +ret +end +if ne get nm_kind sub e 1 0 +fail 7 +end +e1 = sub e 1 +if ne get nm_fv e1 0 +nr = ulong get nm_reg e1 +if ne get fwv get depth 0 0 +vdone 9 nr ulong get nm_type e1 +else +fv2x ulong get nm_type e1 vtw nr nr +vdone 1 nr ulong get nm_type e1 +end +else +vdone 1 ulong get nm_reg e1 ulong get nm_type e1 +end +if ne get cpure 0 0 +if ge get rt 0 10 +fail 30 +end +end +ret +end +f = findfn get tw 0 0 0 +if eq f 0 +unkfail 3 +end +if eq get fn_ret sub f 1 12 +fail 7 +end +rdval 2 0 dst f +vdec +ret +end +if or eq c 88 eq c 89 +t = ulong 10 +if eq c 89 +t = ulong 11 +end +rdval 0 0 255 0 +if ge get rt 0 64 +fail 7 +end +if eq get rk 0 6 +v = fspan t get rv 0 +put rk 0 7 +put rv 0 v +put rt 0 t +end +if eq get rk 0 2 +range get rv 0 9 get tbig 0 +put rk 0 3 +put rt 0 9 +end +if eq get rt 0 1 +fail 7 +end +fwreq +vt_conv t +vdec +ret +end +if eq c 90 +if ne get irmode 0 0 +fail 9 +end +tt = typeword +rdval 0 0 255 0 +if or eq get rk 0 6 eq get rk 0 2 +fail 11 +end +ft = get rt 0 +if eq ft 1 +fail 7 +end +if or ge ft 64 ge tt 64 +fail 7 +end +if ne twid ft twid tt +fail 7 +end +r = matreg get rk 0 get rv 0 ft +note A register holds an 8/16/32-bit unsigned value and an f32 zero-extended (canon, FMOV W) and a signed +note one sign-extended, so a bitcast that changes the extension extends the bits again for tt, into a new +note register (a name's register keeps its value). f32 takes the uint form. +if ne twid tt 64 +if ne and ge ft 6 le ft 8 and ge tt 6 le tt 8 +ct = tt +if eq tt 10 +ct = ulong 4 +end +rd = destreg dst +canonto rd r ct +r = rd +end +end +put rk 0 1 +put rv 0 r +put rt 0 tt +vdec +ret +end +if or or or eq c 91 eq c 92 eq c 93 eq c 94 +fwreq +if or eq c 91 eq c 92 +fintr c dst +else +fminmax c dst +end +ret +end +if eq c 95 +fsizeof dst +ret +end +if eq c 96 +foffset dst +ret +end +if le sub c 1 8 +tok +if eq get tk 0 2 +range get tw 0 c get tbig 0 +vdone 3 get tw 0 c +ret +end +rdval 1 0 255 0 +if ge get rt 0 64 +fail 7 +end +if eq get rk 0 2 +fail 11 +end +vt_conv c +vdec +ret +end +if eq c 223 +tok +if eq get tk 0 2 +range get tw 0 13 get tbig 0 +vdone 3 get tw 0 13 +ret +end +rdval 1 0 255 0 +if eq get rk 0 6 +fail 7 +end +if ge get rt 0 64 +fail 7 +end +if eq get rk 0 2 +fail 11 +end +vt_conv 13 +vdec +ret +end +if eq c 74 +put fpw 0 get fwv get depth 0 +rdval 0 exp dst 0 +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +if ne kw get tw 0 75 +fail 16 +end +vdec +ret +end +if or eq c 77 eq c 193 +fail 9 +end +if or eq c 225 eq c 226 +if or eq get progmode 0 0 ne get irmode 0 0 +fail 9 +end +x = mul get depth 0 32 +sl = get nslot 0 +note dit and scrub are emitted inline here, not in helper functions: om4 holds 512 functions and omc.om +note uses 511 of them (seed/omc/size-history.tsv). +if eq c 225 +note dit: OM-2 `dit v` (program mode): v is int, 0 or 1, else trap 3. Sets PSTATE.DIT (Arm ARM +note C5.2.4: DIT is bit 24 of the special-purpose register; MRS/MSR , DIT have op0 3, op1 3, CRn 4, +note CRm 2, op2 5) and gives the previous bit as a long 0 or 1. CMP Xv, #1 = SUBS XZR (C6.2.464); B.HI +note trap 3; LSL X16, Xv, #24 = UBFM X16, Xv, #40, #39 (C6.2.487), taken before the destination is +note written because the destination may be v's own register; MRS Xd, DIT (C6.2.287); MSR DIT, X16 +note (C6.2.289); UBFX Xd, Xd, #24, #1 = UBFM Xd, Xd, #24, #24. Writes to PSTATE are in program order +note without further synchronization (C5.1), so the next instruction already runs under the new bit. +harg x 0 8 +r = matreg get fr add x 8 get fr add x 9 8 +emit or 4043310111 shl r 5 +trapc 8 3 +emit or 3546848272 shl r 5 +put nslot 0 sl +d = destreg dst +emit or 3577430688 d +emit 3575333552 +emit or or 3545784320 shl d 5 d +vdone 1 d 9 +ret +end +note scrub: OM-2 `scrub n` (program mode): n is ulong, a multiple of 16 and at most 1048576, else trap 3. +note TST Xn, #15 = ANDS XZR (C6.2.16, N 1 immr 0 imms 3); B.NE trap 3; X16 = 1048576; CMP Xn, X16 = +note SUBS XZR (C6.2.465); B.HI trap 3. X16 = SP - n: SUB X16, SP, Xn, UXTX (C6.2.456); CMP X16, X28 +note (C6.2.465); B.LO trap 6, before any store. Loop: CMP SP, X16 = SUBS XZR, SP, X16, UXTX (C6.2.463); +note B.LS out; STP XZR, XZR, [X16], #16 (C6.2.414, post-index); B back (C6.2.35). Then MOVZ Xr, #0 +note (C6.2.319) for every pool register at index npar + nslot or above (no live value: parameters, +note locals and the held parts of the expression sit below), X16, and X7, X18-X26, X29, which program +note mode never names; then MOVI Vd.2D, #0 (C7.2.247) for V0-V15 and for every twin V16+j except those +note of a live slot j (below npar + nslot) whose value lives in its twin (vsl: an f32/f64 local name or a +note held kind 9 float, as save stores it); a twin of a free slot or of a slot whose value is in its x +note register holds nothing live. V0-V15 carry a float only inside one operation. Never touched: SP, X27 +note (the Linux initial stack under args), X28 (the stack floor), X30 (the return address), the live pool +note registers and live twins, NZCV, FPCR, FPSR, and the SVE P registers and FFR. Gives long 0. +harg x 0 5 +r = matreg get fr add x 8 get fr add x 9 5 +emit or 4064283679 shl r 5 +trapc 1 3 +matconst 16 1048576 +emit or 3943694367 shl r 5 +trapc 8 3 +emit or 3407897584 shl r 16 +emit 3944481311 +trapc 3 6 +top = get oc 0 +emit 3945817087 +at = get oc 0 +emit 1409286153 +emit 2827058719 +back top +patch19 at get oc 0 +i = add get npar 0 sl +while lt i 16 +emit or 3531603968 poolc i +i = add i 1 +end +emit 3531603984 +emit 3531603975 +i = ulong 18 +while le i 26 +emit or 3531603968 i +i = add i 1 +end +emit 3531603997 +at = add get npar 0 sl +i = ulong 0 +while lt i 32 +top = and i 15 +r = ulong get vsl top +if or lt i 16 ge top at +r = ulong 0 +end +if eq r 0 +emit or 1862329344 i +end +i = add i 1 +end +put nslot 0 sl +d = destreg dst +matconst d 0 +vdone 1 d 9 +ret +end +if or or and ge c 100 le c 177 and ge c 197 le c 198 and ge c 220 le c 222 +hostval c dst +ret +end +if eq c 224 +hostval c dst +ret +end +if eq c 186 +rdval 0 0 255 0 +ab_open +vdec +ret +end +if eq c 185 +ab_seal +vdec +ret +end +if eq c 51 +e = arrname +if ge get nm_kind sub e 1 6 +vt_fget e dst +vdec +ret +end +if ne ly_get e dst 0 +vdec +ret +end +rdval 0 5 255 0 +fz_get e +fwreq +vt_get e dst +vdec +ret +end +if eq c 52 +e = arrname +if ge get nm_kind sub e 1 6 +fail 7 +end +if ne unsz sub e 1 0 +vdone 1 ulong get nm_lr sub e 1 5 +ret +end +vdone 3 get nm_len sub e 1 5 +ret +end +if or eq c 53 eq c 54 +x = mul get depth 0 32 +put fr add x 8 get nslot 0 +rdval 0 8 255 0 +vs_fd x +e = arrname +vs_arr c e +rdval 0 5 255 0 +vs_off x +rdval 0 5 255 0 +vs_end c e dst x +ret +end +if eq c 55 +vdone 3 1 1 +ret +end +if eq c 56 +vdone 3 0 1 +ret +end +if and gt sub c 33 17 gt sub c 59 1 +fail 16 +end +if and ge c 49 le c 50 +put fpw 0 1 +rdval 0 exp 255 0 +if ge get rt 0 64 +fail 7 +end +if and eq c 50 eq get rk 0 4 +put rv 0 xor get rv 0 1 +vdec +ret +end +if eq get rk 0 2 +fail 11 +end +fwreq +vt_un c dst +vdec +ret +end +put fpw 0 1 +rdval 0 0 255 0 +ak = get rk 0 +av = get rv 0 +at = get rt 0 +if eq ak 4 +av = matreg 4 av at +ak = ulong 1 +at = ulong 1 +end +put fpw 0 1 +rdval 0 0 255 0 +bk = get rk 0 +bv = get rv 0 +bt = get rt 0 +if eq bk 4 +bv = matreg 4 bv bt +bk = ulong 1 +bt = ulong 1 +end +if or ge at 64 ge bt 64 +x = mul get depth 0 32 +put fr x ak +put fr add x 1 av +put fr add x 2 at +put fr add x 3 bk +put fr add x 4 bv +put fr add x 5 bt +ab_bin c dst x +vdec +ret +end +if and eq ak 6 eq bk 6 +fail 11 +end +if or ne isfloat at 0 ne isfloat bt 0 +if eq ak 6 +if eq bt 0 +fail 11 +end +if eq isfloat bt 0 +fail 7 +end +av = fspan bt av +ak = ulong 7 +at = bt +end +if eq bk 6 +if eq at 0 +fail 11 +end +if eq isfloat at 0 +fail 7 +end +bv = fspan at bv +bk = ulong 7 +bt = at +end +if or eq ak 2 eq ak 3 +fail 7 +end +if or eq bk 2 eq bk 3 +fail 7 +end +end +if or eq ak 6 eq bk 6 +fail 7 +end +if eq ak 2 +if eq bk 2 +fail 11 +end +range av bt at +at = bt +ak = ulong 3 +end +if eq bk 2 +range bv at bt +bt = at +bk = ulong 3 +end +if and ne c 41 ne c 42 +if ne at bt +fail 7 +end +end +x = mul get depth 0 32 +put fr x ak +put fr add x 1 av +put fr add x 2 at +put fr add x 3 bk +put fr add x 4 bv +put fr add x 5 bt +if ne isfloat at 0 +fwreq +end +binop c dst x +vdec +end + +note cond: read a condition (a bool value); emit a branch taken when it is false: B.cond with the opposite +note condition (C6.2.34), or CBZ Xr (C6.2.78). Returns that branch's place. om4 COND. +fn cond to ulong +if ne get xtarget 0 0 +rdval 0 1 255 0 +if ne get rt 0 1 +fail 7 +end +if eq get rk 0 4 +ret xbranch xor get rv 0 1 +end +r = matreg get rk 0 get rv 0 get rt 0 +xcmp r 0 1 +ret xbranch 0 +end +rdval 0 1 255 0 +if ne get rt 0 1 +fail 7 +end +if eq get rk 0 4 +at = get oc 0 +emit or 1409286144 xor get rv 0 1 +ret at +end +r = matreg get rk 0 get rv 0 get rt 0 +at = get oc 0 +emit or 3019898880 r +ret at +end + +note ======== statements, one per line (om4 STMT and the S_ parts) ======== +note skipnl: note ...: the rest of the line is not read (up to the newline, which tok reads). om4 S_NOTE. +fn skipnl to void +go = true +while go +n = ulong 0 +while and go lt n 999999 +if ge get cur 0 get inlen 0 +go = false +else +if eq get inp get cur 0 10 +go = false +else +put cur 0 add get cur 0 1 +end +end +n = add n 1 +end +end +end + +note blo: B.LO back to an earlier place (C6.2.34) +fn blo at ulong to void +if ne get xtarget 0 0 +p = xbranch 3 +xpatch p at +ret +end +d = bdisp get oc 0 at 19 +emit or 1409286147 shl d 5 +end + +note sa_arr: x = new T N v: N elements of type T on the stack, each set to v; only in the function's +note outermost block, so the stack held by local arrays is known at every ret. SUB SP (C6.2.457); program +note mode: the stack check; MOV Xb, SP (ADD immediate, C6.2.5); then the fill loop: STR v, [Xb, Xi, LSL]; +note ADD Xi, Xi, #1; CMP Xi, #N or Xn; B.LO back (C6.2.34). om4 SA_ARR. +fn sa_arr w ulong to void +if ne get xtarget 0 0 +xarray w +ret +end +if ne get nb 0 0 +fail 9 +end +t = typeword +elemtype t +n = lenval 16 +arrlen n +by = shl shr add shl n tlog t 15 4 4 +s = add get stkbytes 0 by +if gt s 4194304 +fail 23 +end +put stkbytes 0 s +r = alloc +put held 0 get nslot 0 +rdval 0 t 255 0 +if ne get rt 0 t +fail 7 +end +v = matreg get rk 0 get rv 0 get rt 0 +spsub by +stkchk +emit or 2432697312 r +i = alloc +emit or 3531603968 i +m = ulong 0 +if gt n 4095 +m = alloc +matconst m n +end +lp = get oc 0 +emit or or or stop t v shl r 5 shl i 16 +emit or or 2432697344 i shl i 5 +if le n 4095 +emit or or 4043309087 shl n 10 shl i 5 +else +emit or or 3942645791 shl m 16 shl i 5 +end +blo lp +addname w r t n 1 0 +end + +note s_assign: name [=] value (an existing scalar, or a new one), or name = new T N v. om4 S_ASSIGN. A new +note f32/f64 name lives in the twin of its register (nm_fv, vsl): the value is made there when it can be. +fn s_assign w ulong to void +tok +if eq get tk 0 1 +if le get tl 0 8 +if eq kw get tw 0 73 +tok +end +end +end +e = findname w +if ne e 0 +i = sub e 1 +if ne get nm_kind i 0 +fail 7 +end +r = ulong get nm_reg i +t = ulong get nm_type i +if ne get nm_fv i 0 +put fpw 0 add r 2 +rdval 1 t 255 0 +if ne get rt 0 t +fail 7 +end +fvset get rk 0 get rv 0 t r +eol +ret +end +rdval 1 t r 0 +if ne get rt 0 t +fail 7 +end +force get rk 0 get rv 0 get rt 0 r +eol +ret +end +if ne findfn w 0 0 0 +fail 10 +end +if eq get tk 0 1 +if le get tl 0 8 +if eq kw get tw 0 84 +sa_new w +eol +ret +end +end +end +r = alloc +put held 0 get nslot 0 +put fpw 0 add r 2 +rdval 1 0 r 0 +if eq get rk 0 2 +fail 11 +end +t = get rt 0 +if and ne isfloat t 0 eq get xtarget 0 0 +fvset get rk 0 get rv 0 t r +put vsl regidx r uchar 1 +addname w r t 0 0 0 +put nm_fv sub get nn 0 1 uchar 1 +else +force get rk 0 get rv 0 t r +addname w r t 0 0 0 +end +eol +end + +note s_name: a name at the start of a line: a call of a void function, or name [=] value. om4 S_NAME. +fn s_name w ulong to void +if ne findname w 0 +s_assign w +ret +end +f = findfn w get tl 0 0 +if eq f 0 +s_assign w +ret +end +if ne get fn_ret sub f 1 12 +fail 7 +end +rdval 2 0 255 f +eol +end + +note fn_p: the type of parameter np (name pw) of function f (index): T, or view / edit T N (an array: +note kind 2 / 3, element type, length 1 .. 2^24). om4 FN_P .. FN_ADD. +fn fn_p f ulong np ulong pw ulong to void +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +c = kw get tw 0 +t = ulong 0 +ln = ulong 0 +k = ulong 0 +if eq c 194 +fn_p_out f np pw +ret +end +if or eq c 57 eq c 58 +k = sub c 55 +sid = peek_struct +if ne sid 0 +fn_p_st f np pw sid k +ret +end +if ne get om2 0 0 +lid = peek_lay +if ne lid 0 +fn_p_ly f np pw lid k +ret +end +end +t = typeword +elemtype t +if and ne get om2 0 0 ne peekstar 0 +tok +else +ln = lenval 16 +arrlen ln +if ne get om2 0 0 +if eq peekw 183 +tok +fz_par f np k ln +end +end +end +else +if eq c 88 +t = ulong 10 +else +if eq c 89 +t = ulong 11 +else +if eq c 223 +t = ulong 13 +else +if gt sub c 1 8 +t = abty +else +t = c +end +end +end +end +end +addname pw poolc get psl 0 t ln k 0 +if and ne k 0 eq ln 0 +put nm_lr sub get nn 0 1 uchar poolc add get psl 0 1 +end +fz_bind add mul f 6 np ln +p = add mul f 6 np +put fn_pt p uchar t +put fn_pl p ln +put fn_pk p uchar k +end + +note fn_p_out (OM-2, spec 6, erratum E1): `NAME out T N`, a sized array the unit writes and the bridge owns +note (copied out only after status 0). Inside the unit it is an edit of T N (kind 3) in one slot, its +note pointer; a length `*` is error 16, and so is `fresh` after it. +fn fn_p_out f ulong np ulong pw ulong to void +t = typeword +elemtype t +ln = lenval 16 +arrlen ln +addname pw poolc get psl 0 t ln 3 0 +p = add mul f 6 np +put fn_pt p uchar t +put fn_pl p ln +put fn_pk p 3 +end + +note fn_to: to T | to void at the end of a fn line; the function's state starts. om4 FN_TO .. FN_T2. +fn fn_to f ulong np ulong to void +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 16 +end +c = kw get tw 0 +r = c +if eq c 76 +r = ulong 12 +else +if eq c 88 +r = ulong 10 +else +if eq c 89 +r = ulong 11 +else +if eq c 223 +r = ulong 13 +else +if gt sub c 1 8 +r = abty +else +r = c +end +end +end +end +end +put curret 0 r +put fn_ret f uchar r +put fn_np f uchar np +put stkbytes 0 0 +put dead 0 0 +put npar 0 get psl 0 +put nslot 0 0 +for j ulong 16 +put vsl j 0 +end +put held 0 0 +put nb 0 0 +put nt 0 0 +fn_tail f +if and ne get xtarget 0 0 eq get scanning 0 0 +xpro get psl 0 +end +end + +note s_fn: fn name (param type | param view T N | param edit T N)* to type | void. om4 S_FN. +note A name of 9..63 bytes is never a keyword: tw packs only its first 8 bytes (continue_x is not continue). +fn s_fn to void +if ne get curret 0 0 +fail 15 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 63 +fail 13 +end +w = get tw 0 +if le get tl 0 8 +if ne kw w 0 +fail 16 +end +end +l = get tl 0 +s = get ts 0 +f = ulong 0 +if eq get scanning 0 1 +newname w l s +f = get nf 0 +if ge f 4096 +fail 14 +end +put nf 0 add f 1 +put curfn 0 add f 1 +put lastfn 0 add f 1 +put fn_name f w +put fn_addr f get oc 0 +put fn_ret f 0 +put fn_np f 0 +put fn_nmlen f l +put fn_off f s +put fn_exp f uchar get expf 0 +else +f = sub findfn w l s 1 +put curfn 0 add f 1 +put lastfn 0 add f 1 +put fn_addr f get oc 0 +put fstart 0 get oc 0 +put fuel 0 0 +put fz_n 0 0 +end +put nn 0 get nglob 0 +put psl 0 0 +np = ulong 0 +go = true +while go +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +pw = get tw 0 +c = kw pw +if eq c 65 +go = false +else +if ne c 0 +fail 16 +end +newname pw get tl 0 get ts 0 +if ge get psl 0 6 +fail 9 +end +fn_p f np pw +put fn_pn add mul f 6 np pw +put psl 0 add get psl 0 pwid add mul f 6 np +if gt get psl 0 6 +fail 9 +end +np = add np 1 +end +end +fn_to f np +ab_entry f +if eq get scanning 0 0 +cp_entry +end +if eq get scanning 0 1 +put curret 0 0 +note keep the top-level consts read so far: a later const must not take an earlier one's slot. +put nn 0 get nglob 0 +end +end + +note s_ret: ret [value]: the value into X0, give back the local arrays' stack, RET. om4 S_RET. +fn s_ret to void +if ne get inl 0 0 +s_iret +ret +end +r = get curret 0 +if eq r 12 +eol +cp_post 0 0 r +epi +dead1 +ret +end +dst = ulong 0 +if and ne get cfhas 0 0 eq get crel 0 0 +dst = ulong 255 +end +rdval 0 r dst 0 +if ne get rt 0 r +fail 7 +end +if and ne get cfhas 0 0 eq get crel 0 0 +rr = matreg get rk 0 get rv 0 r +eol +cp_post 1 rr r +force 1 rr r 0 +else +force get rk 0 get rv 0 get rt 0 0 +eol +cp_post 1 0 r +end +epi +dead1 +end + +note s_break: leave the innermost loop: find the nearest block of kind 3 (while) or 4 (for), emit an +note always-taken B.cond to the loop's exit and record the word for s_end to patch. Outside a loop the +note line is error 9. Like ret, the line ends the path (a later line in the same block is error 17). +fn s_break to void +j = get nb 0 +found = ulong 0 +bi = ulong 0 +while and eq found 0 gt j 0 +j = sub j 1 +if ge get bkind j 3 +found = ulong 1 +bi = j +end +end +if eq found 0 +fail 9 +end +if ge get bkind bi 5 +fail 9 +end +n = get nbrk 0 +if ge n 1024 +fail 14 +end +put brkpos n get oc 0 +put brkblk n bi +put nbrk 0 add n 1 +if ne get xtarget 0 0 +p = xbranch 14 +else +emit 1409286158 +end +dead1 +eol +end + +note s_cont: continue: like break it finds the innermost loop, but its exit is the latch: the head of a +note while, the increment of a for (patched by s_end). Outside a loop it is error 9; the line ends the +note path (error 17 for a later line in the same block). +fn s_cont to void +j = get nb 0 +found = ulong 0 +bi = ulong 0 +while and eq found 0 gt j 0 +j = sub j 1 +if ge get bkind j 3 +found = ulong 1 +bi = j +end +end +if eq found 0 +fail 9 +end +if ge get bkind bi 5 +fail 9 +end +n = get ncont 0 +if ge n 1024 +fail 14 +end +put cpos n get oc 0 +put cblk n bi +put ncont 0 add n 1 +if ne get xtarget 0 0 +p = xbranch 14 +else +emit 1409286158 +end +dead1 +eol +end + +note stel: the checked store of v (type t) at ea_b / ea_i (the STOP table: register offset, scaled) +fn stel t ulong v ulong to void +if ne get xtarget 0 0 +xmemval 1 get ea_b 0 get ea_i 0 t v +ret +end +eaem stop t v +end + +note s_put: put A i v: index, then value, then the checked store (STOP table). om4 S_PUT. +fn s_put to void +e = arrname +k = get nm_kind sub e 1 +if ge k 6 +s_putf e +ret +end +if or eq k 2 eq k 5 +fail 20 +end +if ne ly_put e 0 +ret +end +rdval 0 5 255 0 +ik = get rk 0 +iv = get rv 0 +it = get rt 0 +t = ulong get nm_type sub e 1 +if ne isfloat t 0 +put fpw 0 1 +end +rdval 0 t 255 0 +if ne get rt 0 t +fail 7 +end +if eq get rk 0 9 +vv = vtw get rv 0 +fz_put e ik iv +elemaddr e ik iv it +eaem or stop t 67108864 vv +eol +ret +end +v = matreg get rk 0 get rv 0 get rt 0 +fz_put e ik iv +elemaddr e ik iv it +stel t v +eol +end + +note s_const: const NAME TYPE LITERAL at top level. The value is a typed number (integer or float) +note read wherever a value goes; it may not be assigned and is refused in IR mode. +fn s_const to void +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +t = typeword +if ge t 64 +fail 7 +end +if ne isfloat t 0 +note float constant: rdval reads the float token as a value (kind 6); fspan converts it to the +note target type's bits and rdval has already balanced the nesting depth. +rdval 0 0 255 0 +if ne get rk 0 6 +fail 16 +end +v = fspan t get rv 0 +addname w 0 t 0 9 v +put nglob 0 get nn 0 +eol +ret +end +tok +if eq get tk 0 0 +fail 4 +end +if eq get tk 0 5 +fail 7 +end +if ne get tk 0 2 +fail 16 +end +v = get tw 0 +range v t get tbig 0 +addname w 0 t 0 9 v +put nglob 0 get nn 0 +eol +end + +note s_global: global NAME T N: a fixed pool of N elements, zero at start, in the read/write part of the +note program image after the 8 MiB stack pool (address 0x10800000 + pool bytes so far); at most 1 GiB of +note pools (error 23). om4 S_GLOBAL. +fn s_global to void +w = topname +t = typeword +elemtype t +n = lenval 16 +arrlen n +by = shl shr add shl n tlog t 15 4 4 +pb = get poolb 0 +a = add 276824064 pb +s = add pb by +if gt s 1073741824 +fail 23 +end +put poolb 0 s +addname w 0 t n 4 a +put nglob 0 get nn 0 +eol +end + +note s_text: text NAME "...": read-only bytes in the program image (escapes \n \t \\ \", any other is error +note 22), padded to a word, with their length; address 0x400000 + its place. om4 S_TEXT. +fn s_text to void +w = topname +tok +if ne get tk 0 4 +fail 16 +end +br = ulong 0 +if and ne get xtarget 0 0 ne get tl 0 0 +br = xbranch 14 +end +a = add get oc 0 4194304 +p = get tw 0 +e = add p get tl 0 +n = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +b = get inp p +p = add p 1 +if eq b 92 +b = get inp p +p = add p 1 +if eq b 110 +b = uchar 10 +else +if eq b 116 +b = uchar 9 +else +if and ne b 92 ne b 34 +fail 22 +end +end +end +end +emitb b +n = add n 1 +end +m = add m 1 +end +end +note Empty text carries no data or padding; its zero count forbids every access. +if ne n 0 +while ne and get oc 0 3 0 +emitb 0 +end +end +if ne br 0 +xpatch br get oc 0 +end +addname w 0 2 n 5 a +put nglob 0 get nn 0 +eol +end + +note s_else: jump over the else part (B, C6.2.35); the if's false branch lands after that jump. om4 S_ELSE. +fn s_else to void +n = get nb 0 +if eq n 0 +fail 15 +end +i = sub n 1 +if ne get bkind i 1 +fail 15 +end +b = get oc 0 +if ne get xtarget 0 0 +note A terminated then-path needs no skip jump, particularly at a bare unit's final byte. +if eq get dead 0 0 +p = xbranch 14 +end +else +emit 335544320 +end +patch19 get bbr i get oc 0 +put bkind i 2 +put bbr i b +fz_else i +put nn 0 get bnames i +put held 0 get bheld i +put bdead i get dead 0 +put dead 0 0 +eol +end + +note lpcnt: the hidden counter check of a loop: CMP Xc, #N (C6.2.96) or CMP Xc, Xn (C6.2.97); B.HS trap +note 4; ADD Xc, Xc, #1 (C6.2.5). om4 SW_NOB .. SW_G and the same in S_FOR. +fn lpcnt c ulong n ulong to void +if ne get xtarget 0 0 +xcmp c n 1 +trapc 2 4 +xarith 33 5 c 1 1 c +ret +end +if le n 4095 +emit or or 4043309087 shl n 10 shl c 5 +else +m = alloc +matconst m n +emit or or 3942645791 shl c 5 shl m 16 +end +trapc 2 4 +emit or or 2432697344 c shl c 5 +end + +note s_while: while cond [bound N]: hidden counter = 0; head: cond false -> exit; counter >= N -> trap 4; +note counter = counter + 1; body; B head. N is 1 .. 9223372036854775807 (error 8), 1000000 with no bound. om4 S_WHILE. +fn s_while to void +sn = get nn 0 +sh = get held 0 +c = alloc +put held 0 get nslot 0 +if ne get xtarget 0 0 +matconst c 0 +else +emit or 3531603968 c +end +hd = get oc 0 +cp_head skipln get cur 0 add get line 0 1 +br = cond +n = ulong 1000000 +tok +k = get tk 0 +if and ne k 0 ne k 3 +if ne k 1 +fail 5 +end +if gt get tl 0 8 +fail 5 +end +if ne kw get tw 0 70 +fail 5 +end +v = lenval 4 +if ge sub v 1 9223372036854775807 +fail 8 +end +n = v +eol +end +lpcnt c n +pushb br 3 hd c 0 +pushnh sn sh +cp_skip +end + +note sf_br: B.HS (unsigned) or B.GE (signed) to the loop exit, C6.2.34 (distance filled at end); returns +note its place. om4 SF_BR. +fn sf_br t ulong to ulong +if ne get xtarget 0 0 +if lt t 6 +ret xbranch 2 +end +ret xbranch 10 +end +at = get oc 0 +if lt t 6 +emit 1409286146 +else +emit 1409286154 +end +ret at +end + +note sf_num: for i T K with K a number: i = 0 (MOVZ, C6.2.285); head: CMP Xi, #K or Xk; B.HS/B.GE exit. +note With `bound N` a hidden counter c = 0 is checked after the exit test, as in s_while. om4 SF_NUM .. SF_PUSH. +note The optional `bound N` before the line's end: N a number or an integer constant, 1 .. +note 9223372036854775807 (error 8, as s_while; 4 when N is missing); bn = 0 when no bound is written. +fn sf_num w ulong t ulong kk ulong sn ulong sh ulong to void +bn = ulong 0 +if eq peekw 70 +tok +bn = lenval 4 +if ge sub bn 1 9223372036854775807 +fail 8 +end +end +if ne get xtarget 0 0 +xfornum w t kk sn sh bn +ret +end +eol +i = alloc +put held 0 get nslot 0 +addname w i t 0 0 0 +emit or 3531603968 i +c = ulong 0 +if ne bn 0 +c = alloc +put held 0 get nslot 0 +emit or 3531603968 c +end +hd = get oc 0 +cp_head get cur 0 get line 0 +if le kk 4095 +emit or or 4043309087 shl kk 10 shl i 5 +else +k = alloc +matconst k kk +emit or or 3942645791 shl i 5 shl k 16 +end +br = sf_br t +if ne bn 0 +lpcnt c bn +end +pushb br 4 hd i t +pushnh sn sh +cp_skip +end + +note sf_val: for i T K with K a value of type T in register kr: i = 0; the hidden counter c = 0; head: CMP +note Xi, Xk; B.HS/B.GE exit; the counter guard of a while: `bound N` (read as in sf_num), else 1000000. +note om4 SF_VAL. +fn sf_val w ulong t ulong kr ulong sn ulong sh ulong to void +n = ulong 1000000 +if eq peekw 70 +tok +n = lenval 4 +if ge sub n 1 9223372036854775807 +fail 8 +end +end +if ne get xtarget 0 0 +xforval w t kr sn sh n +ret +end +eol +i = alloc +put held 0 get nslot 0 +addname w i t 0 0 0 +emit or 3531603968 i +c = alloc +put held 0 get nslot 0 +emit or 3531603968 c +hd = get oc 0 +cp_head get cur 0 get line 0 +emit or or 3942645791 shl kr 16 shl i 5 +br = sf_br t +lpcnt c n +pushb br 4 hd i t +pushnh sn sh +cp_skip +end + +note s_for: for i T K [bound N]: i = 0; head: not i < K -> exit; body; latch i = add i 1; B head. K a number, +note or a value of type T: a name is read at every pass, another value once before the loop. More than N +note passes (default 1000000 for a value K, no limit for a number K) trap 4. om4 S_FOR. +fn s_for to void +sn = get nn 0 +sh = get held 0 +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +t = typeword +if or eq t 1 ge t 10 +fail 7 +end +tok +if eq get tk 0 0 +fail 4 +end +if eq get tk 0 2 +range get tw 0 t get tbig 0 +if ne get om2 0 0 +kk = get tw 0 +if eq peekw 181 +s_unroll w t kk sn sh +ret +end +put tw 0 kk +end +sf_num w t get tw 0 sn sh +ret +end +rdval 1 t 255 0 +if ne get rt 0 t +fail 7 +end +if ne get om2 0 0 +if eq peekw 181 +fail 16 +end +end +if eq get rk 0 3 +sf_num w t get rv 0 sn sh +ret +end +kr = matreg get rk 0 get rv 0 get rt 0 +sf_val w t kr sn sh +end + +note ======== OM-2 section 4: unroll, inline, folding, the growth bound and trap-site records ======== +note peekstar: 1 when the next word is `*` (an unsized array, OM-2), without reading it +fn peekstar to ulong +c0 = get cur 0 +l0 = get line 0 +a0 = get tka 0 +b0 = get tkb 0 +tok +r = ulong 0 +if and eq get tk 0 1 eq get tl 0 1 +if eq get tw 0 42 +r = ulong 1 +end +end +put cur 0 c0 +put line 0 l0 +put tka 0 a0 +put tkb 0 b0 +ret r +end + +note peekw: the keyword code of the next word (0 for anything else) without reading it +fn peekw to ulong +c0 = get cur 0 +l0 = get line 0 +a0 = get tka 0 +b0 = get tkb 0 +tok +r = ulong 0 +if eq get tk 0 1 +if le get tl 0 8 +r = kw get tw 0 +end +end +put cur 0 c0 +put line 0 l0 +put tka 0 a0 +put tkb 0 b0 +ret r +end + +note s_unroll: for i T K unroll (K a number 1..64, error 8 outside). i is a constant name (kind 9) bound to +note 0..K-1 in turn; the body is read K times from its first line (s_unr). No branch is emitted. +fn s_unroll w ulong t ulong kk ulong sn ulong sh ulong to void +if or eq kk 0 gt kk 64 +fail 8 +end +fuelc get line 0 kk +tok +eol +addname w 0 t 0 9 0 +n = get nb 0 +pushb 0 5 0 sub get nn 0 1 t +pushnh sn sh +put u_cur n get cur 0 +put u_line n get line 0 +put u_it n 0 +put u_k n kk +put u_nn n get nn 0 +put u_held n get held 0 +put fzone 0 add get fzone 0 1 +cp_head get cur 0 get line 0 +cp_skip +end + +note fuelc: charge n to the function's fuel at the construct on line ln, before anything of it expands; a +note total above 65536 is error 14 on line ln (E14, E16) +fn fuelc ln ulong n ulong to void +if gt add get fuel 0 n 65536 +put line 0 ln +fail 14 +end +put fuel 0 add get fuel 0 n +end + +note s_unr: the end of an unrolled body: read it again with the next value of i, or close the block +fn s_unr i ulong to void +eol +it = add get u_it i 1 +if lt it get u_k i +put u_it i it +put nm_addr get breg i it +put nn 0 get u_nn i +put held 0 get u_held i +put nslot 0 get u_held i +put dead 0 0 +put cur 0 get u_cur i +put line 0 get u_line i +cp_head get cur 0 get line 0 +cp_skip +ret +end +put u_it i it +put nm_addr get breg i it +put nn 0 get u_nn i +put nslot 0 get u_held i +cp_head get u_cur i get u_line i +put nb 0 i +put nn 0 get bnames i +put held 0 get bheld i +put dead 0 0 +put fzone 0 sub get fzone 0 1 +end + +note fn_tail: the end of a fn line: an optional inline (OM-2), then the line ends; records the body start +fn fn_tail f ulong to void +tok +k = get tk 0 +if eq k 1 +if ne get om2 0 0 +if le get tl 0 8 +if eq kw get tw 0 182 +put fn_inl f 1 +eol +put fn_body f get cur 0 +put fn_bln f get line 0 +ret +end +end +end +end +if and ne k 0 ne k 3 +put dexp 0 6 +fail 5 +end +put fn_body f get cur 0 +put fn_bln f get line 0 +end + +note inl_call: a call of an inline function fe (index + 1): the result register first (dst, or the next +note pool slot), then the arguments left to right exactly as for a call, then the body in place. +fn inl_call fe ulong dst ulong to void +s0 = get nslot 0 +rres = ulong 255 +ns = s0 +if ne get fn_ret sub fe 1 12 +if eq dst 255 +rres = alloc +ns = add s0 1 +else +rres = dst +end +end +cb = add mul get depth 0 32 8 +np = ulong get fn_np sub fe 1 +put fr add cb 18 np +put fr add cb 19 get nslot 0 +i = ulong 0 +while lt i np +p = add mul sub fe 1 6 i +if eq get fn_pk p 0 +rdval 0 ulong get fn_pt p 255 0 +ca_scal p add cb mul i 3 +else +if ge get fn_pk p 6 +ca_st fe i cb +else +ca_arr fe i cb +end +end +i = add i 1 +end +inl_body fe cb ns rres +end + +note inl_par: bind parameter i of inline function fe to its argument in frame cb. A scalar held in a +note temporary register (pool index hb or above) is taken as it is; any other scalar is copied to a new +note register. An array or struct takes its base register; a text's address is loaded into one. An +note unsized array parameter also takes its count register, or a new one holding a number count. +fn inl_par fe ulong cb ulong i ulong hb ulong to void +p = add mul sub fe 1 6 i +q = add cb mul i 3 +k = get fr q +v = get fr add q 1 +r = ulong 0 +if eq get fn_pk p 0 +if and eq k 1 ge regidx v hb +r = v +else +r = alloc +force k v ulong get fn_pt p r +end +else +if eq k 5 +r = v +else +r = alloc +matconst r v +end +end +inl_add p r +if eq pwid p 2 +inl_lr add mul div cb 32 6 i +end +fz_inl p get fr add q 2 +end + +note inl_lr: the unsized parameter name just added gets the count of argument ux (ul_k / ul_v): its +note register, or a new one holding the number +fn inl_lr ux ulong to void +lr = get ul_v ux +if ne get ul_k ux 1 +lr = alloc +matconst lr get ul_v ux +end +put nm_lr sub get nn 0 1 uchar lr +end + +note inl_add: the name of parameter slot p on register r (a view struct is name kind 8, an edit one 7) +fn inl_add p ulong r ulong to void +pk = ulong get fn_pk p +if eq pk 0 +addname get fn_pn p r ulong get fn_pt p 0 0 0 +ret +end +nk = pk +if eq pk 6 +nk = ulong 8 +end +addname get fn_pn p r ulong get fn_pt p get fn_pl p nk 0 +put nm_lay sub get nn 0 1 get fn_play p +end + +note inl_edge: record the call-graph edge (expanding function -> inline function) once (16384 edges, error 14) +fn inl_edge a ulong b ulong to void +n = get nie 0 +j = ulong 0 +while lt j n +if and eq get ie_from j a eq get ie_to j b +ret +end +j = add j 1 +end +if ge n 16384 +fail 14 +end +put ie_from n a +put ie_to n b +put nie 0 add n 1 +end + +note inl_body: at most 4 nested inline frames (error 14); an inline function reached again while it is +note being inlined, or from its own body, is error 9. The caller's local names are hidden, the parameters +note bound, and the body's lines compiled here until its end (s_inlx) closes the frame. +note Each expansion costs one unit of the function's fuel (E14). +fn inl_body fe ulong cb ulong ns ulong rres ulong to void +lv = get inl 0 +fuelc get line 0 1 +if ge lv 4 +fail 14 +end +if eq get curfn 0 fe +fail 9 +end +j = ulong 0 +while lt j lv +if eq get il_fn j fe +fail 9 +end +j = add j 1 +end +inl_edge get curfn 0 fe +put il_cur lv get cur 0 +put il_line lv get line 0 +put il_ret lv get curret 0 +put il_nn lv get nn 0 +put il_lo lv get nmlo 0 +put il_held lv get held 0 +put il_ns lv ns +put il_res lv rres +put il_fn lv fe +put il_p0 lv get nilp 0 +put il_fz lv get fz_n 0 +inl_bind fe cb +pushb 0 6 0 fe 0 +pushnh get il_nn lv get il_held lv +put inl 0 add lv 1 +put fzone 0 add get fzone 0 1 +put curret 0 ulong get fn_ret sub fe 1 +put dead 0 0 +put cur 0 get fn_body sub fe 1 +put line 0 get fn_bln sub fe 1 +cp_entry +inl_run lv +end + +note inl_bind: hide the caller's local names, bind the parameters, protect every register in use +fn inl_bind fe ulong cb ulong to void +hb = add get npar 0 get held 0 +put nmlo 0 get nn 0 +np = ulong get fn_np sub fe 1 +i = ulong 0 +while lt i np +inl_par fe cb i hb +i = add i 1 +end +put held 0 get nslot 0 +end + +note inl_run: compile the inlined body's lines until its frame (level lv) is closed +fn inl_run lv ulong to void +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ne stmt 0 +fail 15 +end +if le get inl 0 lv +go = false +end +m = add m 1 +end +end +end + +note inlb: the B of an inlined ret, patched to the frame's end +fn inlb to void +n = get nilp 0 +if ge n 4096 +fail 14 +end +put ilp n get oc 0 +put nilp 0 add n 1 +if ne get xtarget 0 0 +p = xbranch 14 +put ilp n p +else +emit 335544320 +end +put lastb 0 get oc 0 +end + +note s_iret: ret inside an inlined body: the value into the frame's result register, then B to its end +fn s_iret to void +lv = sub get inl 0 1 +r = get curret 0 +if eq r 12 +eol +cp_post 0 0 r +inlb +dead1 +ret +end +if and ne get cfhas get inl 0 0 eq get crel 0 0 +rdval 0 r 255 0 +if ne get rt 0 r +fail 7 +end +rr = matreg get rk 0 get rv 0 r +eol +cp_post 1 rr r +force 1 rr r get il_res lv +else +rdval 0 r get il_res lv 0 +if ne get rt 0 r +fail 7 +end +force get rk 0 get rv 0 get rt 0 get il_res lv +eol +cp_post 1 get il_res lv r +end +inlb +dead1 +end + +note s_inlx: the end of an inlined body: a value function must not reach it (error 18). A last ret's B +note that is the last word, with no branch patched to the place after it, is taken back; the other rets +note branch here. The caller's line, names, registers and return type come back; the result is in rk/rv/rt. +fn s_inlx i ulong to void +eol +lv = sub get inl 0 1 +fe = get il_fn lv +if eq get dead 0 0 +if ne get fn_ret sub fe 1 12 +fail 18 +end +cp_post 0 0 12 +end +inl_pat get il_p0 lv +put nb 0 i +put cur 0 get il_cur lv +put line 0 get il_line lv +put curret 0 get il_ret lv +put nn 0 get il_nn lv +put nmlo 0 get il_lo lv +put held 0 get il_held lv +put nslot 0 get il_ns lv +put dead 0 0 +put inl 0 lv +put fzone 0 sub get fzone 0 1 +put fz_n 0 get il_fz lv +put rk 0 1 +put rv 0 get il_res lv +put rt 0 ulong get fn_ret sub fe 1 +end + +note inl_pat: patch the frame's ret B words (from p0) to here, after taking back a last one that is the +note last word and that no branch was patched past +fn inl_pat p0 ulong to void +n = get nilp 0 +o = get oc 0 +if and ne get dead 0 0 gt n p0 +if eq get lastb 0 o +if ne get tgoc 0 o +if eq get ilp sub n 1 sub o 4 +put oc 0 sub o 4 +n = sub n 1 +end +end +end +end +j = p0 +while lt j n +patch26 get ilp j get oc 0 +j = add j 1 +end +put nilp 0 p0 +end + +note ---- folding (only while fzone is above 0): an operation on two typed numbers is computed with OM-1 +note arithmetic: unsigned wraps to its width, signed results are sign-extended; an operation that would +note trap (signed overflow, divide by 0, a shift or rotate amount at or above the width) is not folded. +fn fmask w ulong to ulong +if ge w 64 +ret not ulong 0 +end +ret sub shl ulong 1 w 1 +end + +fn fasr x ulong s ulong to ulong +if eq shr x 63 0 +ret shr x s +end +ret not shr not x s +end + +fn fsext r ulong w ulong to ulong +if ge w 64 +ret r +end +ret fasr shl r sub 64 w sub 64 w +end + +fn fyes v ulong t ulong to void +put fval 0 v +put fty 0 t +put fok 0 1 +end + +fn fb_cmp op ulong sg ulong a ulong b ulong to void +x = a +y = b +if ne sg 0 +x = xor a shl ulong 1 63 +y = xor b shl ulong 1 63 +end +r = false +if eq op 43 +r = eq x y +end +if eq op 44 +r = ne x y +end +if eq op 45 +r = lt x y +end +if eq op 46 +r = le x y +end +if eq op 47 +r = gt x y +end +if eq op 48 +r = ge x y +end +v = ulong 0 +if r +v = ulong 1 +end +fyes v 1 +end + +fn fb_arith op ulong ty ulong w ulong sg ulong a ulong b ulong to void +r = ulong 0 +if eq op 33 +r = add a b +end +if eq op 34 +r = sub a b +end +if eq op 35 +if ne sg 0 +if ge add a shl ulong 1 31 shl ulong 1 32 +ret +end +if ge add b shl ulong 1 31 shl ulong 1 32 +ret +end +end +r = mul a b +end +if eq sg 0 +fyes and r fmask w ty +ret +end +if eq w 64 +if eq op 33 +if ne shr and xor a r xor b r 63 0 +ret +end +end +if eq op 34 +if ne shr and xor a b xor a r 63 0 +ret +end +end +fyes r ty +ret +end +if ne fsext r w r +ret +end +fyes r ty +end + +fn fb_div op ulong ty ulong w ulong sg ulong a ulong b ulong to void +if eq b 0 +ret +end +if eq sg 0 +if eq op 36 +fyes div a b ty +else +fyes rem a b ty +end +ret +end +na = shr a 63 +sb = shr b 63 +ma = a +if ne na 0 +ma = sub 0 a +end +mb = b +if ne sb 0 +mb = sub 0 b +end +if eq op 37 +rr = rem ma mb +if ne na 0 +rr = sub 0 rr +end +fyes rr ty +ret +end +if eq w 64 +if eq a shl ulong 1 63 +if eq b not ulong 0 +ret +end +end +end +q = div ma mb +if ne xor na sb 0 +q = sub 0 q +end +if ne fsext q w q +ret +end +fyes q ty +end + +fn fb_shift op ulong ty ulong w ulong sg ulong a ulong b ulong to void +if ge b w +ret +end +if eq op 42 +if eq sg 0 +fyes shr a b ty +else +fyes fasr a b ty +end +ret +end +r = shl a b +if eq sg 0 +fyes and r fmask w ty +ret +end +if eq w 64 +if ne fasr r b a +ret +end +fyes r ty +ret +end +if ne fsext r w r +ret +end +fyes r ty +end + +fn fb_rot op ulong ty ulong w ulong a ulong b ulong to void +if ge b w +ret +end +s = b +if and eq op 60 ne s 0 +s = sub w s +end +if eq s 0 +fyes a ty +ret +end +fyes and or shr a s shl a sub w s fmask w ty +end + +note foldbin: op on the typed numbers a, b of type ty (b's own type for a shift); fok 1 when folded +fn foldbin op ulong ty ulong a ulong b ulong to void +put fok 0 0 +if or eq ty 0 ge ty 10 +ret +end +sg = ulong 0 +if ge ty 6 +sg = ulong 1 +end +if and ge op 43 le op 48 +fb_cmp op sg a b +ret +end +if and ge op 38 le op 40 +r = and a b +if eq op 39 +r = or a b +end +if eq op 40 +r = xor a b +end +fyes r ty +ret +end +if eq ty 1 +ret +end +w = twid ty +if le op 35 +fb_arith op ty w sg a b +ret +end +if le op 37 +fb_div op ty w sg a b +ret +end +if le op 42 +fb_shift op ty w sg a b +ret +end +if or eq op 59 eq op 60 +if le ty 5 +fb_rot op ty w a b +end +end +end + +note foldun: neg (49) / not (50) of the typed number a +fn foldun c ulong ty ulong a ulong to void +put fok 0 0 +if or eq ty 0 ge ty 10 +ret +end +if eq c 50 +if eq ty 1 +fyes xor a 1 ty +ret +end +if lt ty 6 +fyes and not a fmask twid ty ty +ret +end +fyes not a ty +ret +end +if eq ty 1 +ret +end +r = sub 0 a +if lt ty 6 +fyes and r fmask twid ty ty +ret +end +w = twid ty +if eq w 64 +if eq a shl ulong 1 63 +ret +end +fyes r ty +ret +end +if ne fsext r w r +ret +end +fyes r ty +end + +note ---- omc-site records (om2 diag): one per runtime trap site, in emission order, after the artifact +note on stderr: omc-site 1 line=N iter=k, k the counters of the open unrolled loops outer to inner +note joined by '.', or '-'. +fn siteb b ulong to void +n = get nsite 0 +if ge n 8388608 +fail 14 +end +put sitebuf n uchar b +put nsite 0 add n 1 +end + +fn sitew w ulong n ulong to void +i = ulong 0 +x = w +while lt i n +siteb and x 255 +x = shr x 8 +i = add i 1 +end +end + +fn siten v ulong to void +d = new uchar 20 0 +i = ulong 0 +x = v +put d 0 uchar add rem x 10 48 +x = div x 10 +i = add i 1 +while gt x 0 +put d i uchar add rem x 10 48 +x = div x 10 +i = add i 1 +end +j = i +while gt j 0 +j = sub j 1 +siteb ulong get d j +end +end + +fn siterec to void +sitew 7310584038532803951 8 +sitew 4424063608026050848 8 +siten add get line 0 get lbase 0 +sitew 67561537693984 6 +any = false +j = ulong 0 +while lt j get nb 0 +if eq get bkind j 5 +if any +siteb 46 +end +siten get u_it j +any = true +end +j = add j 1 +end +if not any +siteb 45 +end +siteb 10 +end + +fn sitesout to void +p = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p get nsite 0 +go = false +else +n = write 2 sitebuf p sub get nsite 0 p +if le n 0 +go = false +else +p = add p ulong n +end +end +m = add m 1 +end +end +end + +note finish: end of a function: a function that needs a value must not reach its end (error 18), a void +note one returns; then the trap stubs: shared tail, function mode MOV X0, X7; LDR X16, [X7, #16]; BR X16 +note (C6.2.282, C6.2.216, C6.2.46: OscRt.trap); program mode ADD X0, X1, #100; MOVZ X8, #93; SVC #0 (exit +note 100 + code). Per trap code used: MOVZ X1, #code (C6.2.285); B tail. om4 FINISH. +fn finish to void +if ne get xtarget 0 0 +xfinish +ret +end +eol +if eq get dead 0 0 +if ne get curret 0 12 +fail 18 +end +cp_post 0 0 12 +epi +end +nt0 = get nt 0 +if ne nt0 0 +tail = get oc 0 +if eq get progmode 0 0 +emit 2852586464 +emit 4181723376 +emit 3592356352 +else +emit 2432798752 +emit 3531606952 +emit 3556769793 +end +code = ulong 1 +while le code 14 +st = ulong 0 +j = ulong 0 +while lt j nt0 +if eq get tcode j code +if eq st 0 +st = get oc 0 +emit or 3531603969 shl code 5 +back tail +end +patch19 get tsite j st +end +j = add j 1 +end +code = add code 1 +end +end +put curret 0 0 +put nn 0 get nglob 0 +put curfn 0 0 +put nbrk 0 0 +put ncont 0 0 +end + +note s_end: close the innermost block (if: patch its branch; else: patch its jump; while: B head; for: i = +note add i 1, B head), or the function. om4 S_END. +fn s_end to void +n = get nb 0 +if eq n 0 +finish +ret +end +i = sub n 1 +if eq get bkind i 5 +s_unr i +ret +end +if eq get bkind i 6 +s_inlx i +ret +end +put nb 0 i +k = get bkind i +fz_join i k +if eq k 2 +put dead 0 and get dead 0 get bdead i +else +put dead 0 0 +end +if eq k 4 +lat = get oc 0 +j = ulong 0 +while lt j get ncont 0 +if eq get cblk j i +patch19 get cpos j lat +put cblk j 65535 +end +j = add j 1 +end +put fr 0 1 +put fr 1 get breg i +put fr 2 get btyp i +put fr 3 3 +put fr 4 1 +put fr 5 get btyp i +binop 33 get breg i 0 +end +if eq k 3 +j = ulong 0 +while lt j get ncont 0 +if eq get cblk j i +patch19 get cpos j get bhead i +put cblk j 65535 +end +j = add j 1 +end +end +if ge k 3 +back get bhead i +ex = get oc 0 +j = ulong 0 +while lt j get nbrk 0 +if eq get brkblk j i +patch19 get brkpos j ex +put brkblk j 65535 +end +j = add j 1 +end +end +if eq k 2 +if or eq get xtarget 0 0 eq get bdead i 0 +patch26 get bbr i get oc 0 +end +else +patch19 get bbr i get oc 0 +end +put nn 0 get bnames i +put held 0 get bheld i +eol +end + +note ======== the end of the input: the output ======== +note writeout: the output from byte st to the end, to stdout (error 2), then exit 0. om4 WRITEOUT. +fn writeout st ulong to void +if eq get chkmode 0 1 +put mc 0 0 +mputw 7594244768023276911 8 +mputw 11207551510369 6 +mflush +exit int 0 +end +if ne get fmtm 0 0 +fmtout +end +p = st +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p get oc 0 +go = false +else +n = write 1 out p sub get oc 0 p +if le n 0 +fail 2 +end +p = add p ulong n +end +m = add m 1 +end +end +if eq get om2m 0 1 +sitesout +end +exit int 0 +end + +note elfhdr: the 176-byte file header (om4 ELFHDR, 44 words): ELF64 little-endian, executable, AArch64, +note entry 0x4000b0 (the word after the header), 2 program headers: code read+execute from 0x400000, and +note the read/write pools from 0x10000000. Only the words that are not 0 (the output starts at 0). +fn elfhdr to void +wrword 0 1179403647 +wrword 4 65794 +wrword 16 11993090 +wrword 20 1 +wrword 24 4194480 +wrword 32 64 +wrword 52 3670080 +wrword 56 2 +wrword 64 1 +wrword 68 5 +wrword 80 4194304 +wrword 88 4194304 +wrword 112 4096 +wrword 120 1 +wrword 124 6 +wrword 136 268435456 +wrword 144 268435456 +wrword 168 4096 +end + +note eof_prog: program mode: start code = MOVZ X28, #0x1000, LSL 16 (stack pool floor); MOVZ X16, #0x1080, +note LSL 16; MOV SP, X16 (ADD immediate, C6.2.5); BL main (C6.2.43); [MOVZ X0, #0 for a void main]; MOVZ X8, +note #93; SVC #0. The entry word after the header is a B to it; the header gets the file and pool sizes. +note om4 EOF_PROG. +fn eof_prog to void +if ne get xtarget 0 0 +xeof +ret +end +f = findfn 1852399981 4 0 +if eq f 0 +fail 16 +end +if ne get fn_np sub f 1 0 +fail 9 +end +wrword 176 or 335544320 bdisp 176 get oc 0 26 +if ne get hostargs 0 0 +note Preserve Linux's initial argument stack privately before installing Omega's bounded stack. +emit 2432697339 +end +emit 3533832220 +emit 3533836304 +emit 2432696863 +emit or 2483027968 bdisp get oc 0 get fn_addr sub f 1 26 +if eq get fn_ret sub f 1 12 +emit 3531603968 +end +emit 3531606952 +emit 3556769793 +elfhdr +wrword 96 get oc 0 +wrword 104 get oc 0 +wrword 160 add get poolb 0 8388608 +writeout 0 +end + +note s_eof: end of input: no open function (error 15), some function (16); function mode: no globals or +note texts (9, fnstore; consts fold and are allowed); one function: its bare words; more: the entry word, a +note B to the last function. om4 S_EOF. +note Resolve every call after all addresses are known. In function mode remove leaves of the call +note graph; any functions left after nf rounds form or reach a cycle (error 9). +fn resolve to void +n = get ncalls 0 +i = ulong 0 +while lt i n +s = get callsite i +f = sub get callto i 1 +if ne get xtarget 0 0 +wrword add s 1 sub get fn_addr f add s 5 +else +wrword s or 2483027968 bdisp s get fn_addr f 26 +end +i = add i 1 +end +if eq get progmode 0 0 +pass = ulong 0 +while lt pass get nf 0 +f = ulong 0 +while lt f get nf 0 +if eq get settled f 0 +ok = true +i = ulong 0 +while and ok lt i n +if eq get callfrom i add f 1 +if eq get settled sub get callto i 1 0 +ok = false +end +end +i = add i 1 +end +if ok +put settled f 1 +end +end +f = add f 1 +end +pass = add pass 1 +end +f = ulong 0 +while lt f get nf 0 +if eq get settled f 0 +put dsev 0 3 +fail 9 +end +f = add f 1 +end +end +end + +note reachself: 1 when function f (index + 1) reaches itself +fn reachself f ulong to ulong +i = ulong 0 +while lt i get nf 0 +put reach i 0 +i = add i 1 +end +put reach sub f 1 1 +go = true +pass = ulong 0 +while and go le pass get nf 0 +r = rscan f 0 +if eq r 2 +ret 1 +end +s = rscan f 1 +if eq s 2 +ret 1 +end +go = or ne r 0 ne s 0 +pass = add pass 1 +end +ret 0 +end + +note rscan: one pass over the calls (w 0) or the inline edges (w 1): 2 when an edge from a reached +note function leads to f, 1 when a function was newly reached, else 0 +fn rscan f ulong w ulong to ulong +n = get ncalls 0 +if ne w 0 +n = get nie 0 +end +ch = ulong 0 +j = ulong 0 +while lt j n +a = get callfrom j +b = get callto j +if ne w 0 +a = get ie_from j +b = get ie_to j +end +if ne get reach sub a 1 0 +if eq b f +ret 2 +end +if eq get reach sub b 1 0 +put reach sub b 1 1 +ch = ulong 1 +end +end +j = add j 1 +end +ret ch +end + +fn s_eof to void +if eq get chkmode 0 2 +emit_query +end +if ne get curret 0 0 +fail 15 +end +if eq get nf 0 0 +fail 16 +end +if ne get om2 0 0 +note inlcyc (OM-2): an inline function that reaches itself through the whole call graph (the calls made, +note plus an edge from each function to every inline function expanded in it) is error 9 at the end. +f = ulong 1 +while le f get nf 0 +if ne get fn_inl sub f 1 0 +if ne reachself f 0 +put dsev 0 3 +fail 9 +end +end +f = add f 1 +end +end +resolve +if ne get progmode 0 0 +eof_prog +end +if eq get progmode 0 0 +note fnstore: function mode. A top-level global pool (kind 4) or text (kind 5) needs the program image and +note is error 9; a const (kind 9) is folded to a typed number wherever it is read, so it composes here too. +i = ulong 0 +while lt i get nglob 0 +if ne get nm_kind i 9 +fail 9 +end +i = add i 1 +end +end +if ne get xtarget 0 0 +xunit +end +if ne get nexp 0 0 +note expwords (OM-2, spec 6): words 0 .. E-1 of a multi-entry unit, B to each export in source order +at = ulong 176 +f = ulong 0 +while lt f get nf 0 +if ne get fn_exp f 0 +wrword at or 335544320 bdisp at get fn_addr f 26 +at = add at 4 +end +f = add f 1 +end +writeout 176 +end +if eq get nf 0 1 +writeout 180 +end +a = get fn_addr sub get lastfn 0 1 +wrword 176 or 335544320 bdisp 176 a 26 +writeout 176 +end + +note stmt: one line. Returns 1 at the end of the input. om4 STMT. +fn stmt to ulong +put dexp 0 0 +put nslot 0 get held 0 +tok +k = get tk 0 +if eq k 0 +ret 0 +end +if eq k 3 +s_eof +ret 1 +end +if ne k 1 +fail 16 +end +if and ne get chkmode 0 0 eq get line 0 get chkln 0 +skipnl +ret 0 +end +if and ne get om2 0 0 eq get line 0 get om2ln 0 +skipnl +ret 0 +end +if ne cp_kind 0 +fail 30 +end +if gt get tl 0 8 +note s_long: a word over 8 characters at the start of a line: only a call of a void function. om4 S_LONG. +if eq get curret 0 0 +fail 13 +end +if ne get dead 0 0 +fail 17 +end +f = findfn get tw 0 get tl 0 get ts 0 +if eq f 0 +unkfail 13 +end +if ne get fn_ret sub f 1 12 +fail 7 +end +rdval 2 0 255 f +eol +ret 0 +end +w = get tw 0 +c = kw w +if eq c 83 +skipnl +ret 0 +end +if eq c 64 +s_fn +ret 0 +end +if eq get curret 0 0 +if eq c 78 +s_global +ret 0 +end +if eq c 79 +s_text +ret 0 +end +if eq c 152 +s_const +ret 0 +end +if eq c 85 +skipnl +ret 0 +end +if eq c 195 +s_export +ret 0 +end +if eq c 188 +note s_lyskip: the body pass jumps to the place after the layout's end (read in the names pass) +tok +li = sub findlay get tw 0 1 +put cur 0 get ly_ec li +put line 0 get ly_el li +ret 0 +end +if or eq c 184 eq c 187 +skipnl +ret 0 +end +fail 16 +end +if eq c 66 +s_end +ret 0 +end +if eq c 68 +s_else +ret 0 +end +if ne get dead 0 0 +fail 17 +end +if eq c 0 +s_name w +ret 0 +end +if eq c 67 +note s_if: if cond: the false branch is patched at else / end. om4 S_IF. +at = cond +pushb at 1 0 0 0 +pushnh get nn 0 get held 0 +eol +ret 0 +end +if eq c 69 +s_while +ret 0 +end +if eq c 71 +s_for +ret 0 +end +if eq c 72 +s_ret +ret 0 +end +if eq c 80 +s_put +ret 0 +end +if eq c 82 +note s_exit: exit value (int): Linux exit (system call 93: MOVZ X8, #93, C6.2.285; SVC #0, C6.2.466); the +note path ends. om4 S_EXIT. +rdval 0 8 255 0 +if ne get rt 0 8 +fail 7 +end +force get rk 0 get rv 0 get rt 0 0 +if ne get xtarget 0 0 +xload 0 0 +xleave +else +emit 3531606952 +emit 3556769793 +end +dead1 +eol +ret 0 +end +if eq c 86 +s_break +ret 0 +end +if eq c 87 +note s_trap: trap N (1 .. 14): an always-taken branch to the trap stub for code N, which finish makes. +note Program mode exits 100 + N; function mode calls OscRt.trap (OMEGESE 9.1). The line ends the path. +v = lenval 4 +if or lt v 1 gt v 14 +fail 8 +end +trapc 14 v +dead1 +eol +ret 0 +end +note cpufence (keyword 199, a statement without operands): the host CPU publication barrier. AArch64: +note DSB SY (d5033f9f, the full-system barrier mapget/mapset already bracket their access with). x86-64: +note MFENCE (0F AE F0), the fence the x86 mapget/mapset use. Every earlier load and store completes before +note any later one, so a GPU or another CPU that observes a later store also observes the earlier ones. +note Inline here, not a function: om4 builds omc and holds at most 512 functions, 511 in use. +if eq c 199 +eol +if ne get xtarget 0 0 +xb 15 174 240 +else +emit 3573759903 +end +ret 0 +end +note cpurelax (keyword 200, a statement without operands): spin-wait hint, no ordering. AArch64: YIELD +note (d503203f). x86-64: PAUSE (F3 90). Use it in a bounded poll loop; pair it with cpufence for order. +if eq c 200 +eol +if ne get xtarget 0 0 +emitb 243 +emitb 144 +else +emit 3573751871 +end +ret 0 +end +if eq c 97 +s_cont +ret 0 +end +if or or or eq c 77 eq c 78 eq c 79 eq c 81 +fail 9 +end +if or eq c 85 eq c 193 +fail 9 +end +fail 16 +ret 0 +end + +note ======== program mode: some line is `fn main` (blanks, fn, blanks, main, then a blank or the end) ======== +note skipbl: the first place at or after q that is not a space or tab (or the end) +fn skipbl q ulong to ulong +e = get inlen 0 +p = q +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +b = get inp p +if or eq b 32 eq b 9 +p = add p 1 +else +go = false +end +end +m = add m 1 +end +end +ret p +end + +note skipln: the place after the next newline at or after q (or the end) +fn skipln q ulong to ulong +e = get inlen 0 +p = q +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p e +go = false +else +b = get inp p +p = add p 1 +if eq b 10 +go = false +end +end +m = add m 1 +end +end +ret p +end + +note ps_at: the line's first byte that is not blank is at p: 1 when the line is `fn main`, 2 when the input +note ends while deciding, else 0. om4 PS_LINE .. PS_YES. +fn ps_at p ulong to ulong +e = get inlen 0 +if ne get inp p 102 +ret 0 +end +q = add p 1 +if ge q e +ret 2 +end +if ne get inp q 110 +ret 0 +end +r = add q 1 +q = skipbl r +if ge q e +ret 2 +end +if eq q r +ret 0 +end +if gt add q 4 e +ret 0 +end +if ne get inp q 109 +ret 0 +end +if ne get inp add q 1 97 +ret 0 +end +if ne get inp add q 2 105 +ret 0 +end +if ne get inp add q 3 110 +ret 0 +end +if ge add q 4 e +ret 1 +end +if gt get inp add q 4 32 +ret 0 +end +ret 1 +end + +fn prescan to void +e = get inlen 0 +p = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +p = skipbl p +if ge p e +go = false +else +r = ps_at p +if eq r 1 +put progmode 0 1 +go = false +end +if eq r 2 +go = false +end +if go +p = skipln p +if ge p e +go = false +end +end +end +m = add m 1 +end +end +end + +note First collect signatures. Only fn headers are parsed here; other lines are read in the body pass. +fn namescan to void +put scanning 0 1 +put line 0 1 +go = true +while go +n = ulong 0 +while and go lt n 999999 +tok +if eq get tk 0 3 +go = false +else +if ne get tk 0 0 +if and eq get tk 0 1 eq get tw 0 28262 +s_fn +else +if and eq get tk 0 1 eq get tw 0 127970521019507 +s_struct +else +if and eq get tk 0 1 eq get tw 0 500152823651 +s_const +else +if eq ns_om2 0 +skipnl +end +end +end +end +end +end +n = add n 1 +end +end +put scanning 0 0 +put cur 0 0 +put line 0 1 +put nn 0 0 +put nglob 0 0 +put curfn 0 0 +put curret 0 0 +put npar 0 0 +put nslot 0 0 +for j ulong 16 +put vsl j 0 +end +put held 0 0 +end + +note ======== R6 structs (omc only; om4 stays the parent that rebuilds this file) ======== +note A struct is 8-byte cells, declaration order, no padding (OSC-2). new is a stack slot, given +note back at ret, like a local array. There is no free (decision 24). Field scale: cell << (3 - tlog) +note so a typed store lands on cell * 8. Pack of struct is 127970521019507 (Wolfram, little-endian). + +note findstruct: packed name -> index + 1, or 0 +fn findstruct w ulong to ulong +i = ulong 0 +n = get nst 0 +while lt i n +if eq get st_name i w +ret add i 1 +end +i = add i 1 +end +ret 0 +end + +note findfield: struct index, packed field name -> field-table index + 1, or 0 +fn findfield si ulong w ulong to ulong +fo = ulong get st_foff si +nfd = ulong get st_nf si +i = ulong 0 +while lt i nfd +j = add fo i +if eq get sf_name j w +ret add j 1 +end +i = add i 1 +end +ret 0 +end + +note field_dup: 1 if w is already a field of the struct being read (fields fo .. nsf) +fn field_dup fo ulong w ulong to ulong +i = fo +e = get nsf 0 +while lt i e +if eq get sf_name i w +ret 1 +end +i = add i 1 +end +ret 0 +end + +note s_field: the current word is a field name of struct w. Returns the cell count after this field. +fn s_field w ulong fo ulong cells ulong to ulong +if gt get tl 0 8 +fail 13 +end +if ne kw get tw 0 0 +fail 16 +end +fw = get tw 0 +if eq fw w +fail 10 +end +if ne findstruct fw 0 +fail 10 +end +if ne field_dup fo fw 0 +fail 10 +end +t = typeword +if ge t 64 +fail 7 +end +ln = ulong 0 +p = get cur 0 +ln0 = get line 0 +tok +k = get tk 0 +if eq k 2 +ln = get tw 0 +if ne get tbig 0 0 +fail 14 +end +if or eq ln 0 gt ln 64 +fail 14 +end +else +if eq k 1 +e = findname get tw 0 +if ne e 0 +if eq get nm_kind sub e 1 9 +ct = ulong get nm_type sub e 1 +if ge ct 10 +fail 14 +end +ln = get nm_addr sub e 1 +if or eq ln 0 gt ln 64 +fail 14 +end +else +put cur 0 p +put line 0 ln0 +end +else +put cur 0 p +put line 0 ln0 +end +else +put cur 0 p +put line 0 ln0 +end +end +addc = ulong 1 +if ne ln 0 +addc = ln +end +if gt add cells addc 64 +fail 14 +end +put sf_name get nsf 0 fw +put sf_type get nsf 0 uchar t +put sf_len get nsf 0 uchar ln +put sf_off get nsf 0 uchar cells +put nsf 0 add get nsf 0 1 +ret add cells addc +end + +note s_struct: struct Name (field type [len])* end. Before any fn (namescan). 1..16 fields, <= 64 cells. +fn s_struct to void +if ne get nf 0 0 +fail 9 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +if ne kw get tw 0 0 +fail 16 +end +w = get tw 0 +if ne findstruct w 0 +fail 10 +end +if ne findfn w get tl 0 get ts 0 0 +fail 10 +end +if ge get nst 0 16 +fail 14 +end +sid = get nst 0 +fo = get nsf 0 +cells = ulong 0 +nfld = ulong 0 +go = true +while go +tok +if eq get tk 0 0 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if eq kw get tw 0 66 +go = false +else +if ge nfld 16 +fail 14 +end +cells = s_field w fo cells +nfld = add nfld 1 +end +end +if eq nfld 0 +fail 16 +end +put st_name sid w +put st_nf sid uchar nfld +put st_cells sid uchar cells +put st_foff sid uchar fo +put nst 0 add sid 1 +eol +end + +note peek_struct: if the next word is a struct name, consume it and return index + 1; else rewind +fn peek_struct to ulong +p = get cur 0 +ln = get line 0 +tok +if ne get tk 0 1 +put cur 0 p +put line 0 ln +ret 0 +end +sid = findstruct get tw 0 +if eq sid 0 +put cur 0 p +put line 0 ln +ret 0 +end +ret sid +end + +note fn_p_st: parameter pw is view (k 2, name kind 8) or edit (k 3, name kind 7). fn_pk is 6 or 7. +fn fn_p_st f ulong np ulong pw ulong sid ulong k ulong to void +si = sub sid 1 +t = add si 16 +ln = ulong get st_cells si +sk = add k 4 +if eq k 2 +addname pw poolc get psl 0 t ln 8 0 +else +addname pw poolc get psl 0 t ln 7 0 +end +p = add mul f 6 np +put fn_pt p uchar t +put fn_pl p ln +put fn_pk p uchar sk +end + +note sa_new: name = new . Rewind unless the next word is a struct name. +fn sa_new w ulong to void +if ne get om2 0 0 +if ne get inl 0 0 +fail 9 +end +if ne get fn_inl sub get curfn 0 1 0 +fail 9 +end +end +p = get cur 0 +ln = get line 0 +tok +sid = ulong 0 +if eq get tk 0 1 +sid = findstruct get tw 0 +end +if ne sid 0 +sa_st w sid +ret +end +put cur 0 p +put line 0 ln +sa_arr w +end + +note st_read: one value per field, saved in svk/svv/svt. An array field takes one value. +fn st_read si ulong to void +fo = ulong get st_foff si +nfd = ulong get st_nf si +i = ulong 0 +while lt i nfd +ft = ulong get sf_type add fo i +rdval 0 ft 255 0 +if ne get rt 0 ft +fail 7 +end +put svk i get rk 0 +put svv i get rv 0 +put svt i get rt 0 +i = add i 1 +end +end + +note st_store: STR of v at cell, scaled so the typed store lands on cell * 8. ADD is not used; the +note index register holds cell << (3 - tlog). STR register-offset is the STOP table (om4). +fn st_store base ulong idx ulong cell ulong t ulong v ulong to void +matconst idx shl cell sub 3 tlog t +put ea_b 0 base +put ea_i 0 idx +stel t v +end + +note st_ixreg: runtime element index iv, field length fl, cell offset off. CMP + B.HS trap 3 +note (elemaddr, C6.2.96 / C6.2.34), then ADD Xidx, Xiv, #off (C6.2.5, base word 2432696320) and +note LSL by 3 - tlog (bo_lsl) so the STOP store lands on (off + i) * 8. +fn st_ixreg idx ulong iv ulong off ulong fl ulong t ulong to void +if ne get xtarget 0 0 +xcmp iv fl 1 +trapc 2 3 +xarith 33 5 iv off 1 idx +sh = sub 3 tlog t +if ne sh 0 +bo_lsl idx sh idx +end +ret +end +emit or or 4043309087 shl fl 10 shl iv 5 +trapc 2 3 +emit or or or 2432696320 idx shl iv 5 shl off 10 +sh = sub 3 tlog t +if ne sh 0 +bo_lsl idx sh idx +end +end + +note st_ld: LDR of type t from base + idx into dst (or a new register). LDOP table, as vt_get. +fn st_ld base ulong idx ulong t ulong dst ulong to void +rd = destreg dst +if ne get xtarget 0 0 +xmemval 0 base idx t rd +else +w = or ldop t rd +emit or or w shl base 5 shl idx 16 +end +put rk 0 1 +put rv 0 rd +put rt 0 t +end + +note st_write1: store field j (value saved at sv* i) into the struct at base. +fn st_write1 base ulong tmp ulong idx ulong j ulong i ulong to void +ft = ulong get sf_type j +fl = ulong get sf_len j +off = ulong get sf_off j +force get svk i get svv i get svt i tmp +if eq fl 0 +st_store base idx off ft tmp +else +k = ulong 0 +while lt k fl +st_store base idx add off k ft tmp +k = add k 1 +end +end +end + +note st_write: store each field value. An array field is filled with its one value. +fn st_write base ulong tmp ulong idx ulong si ulong to void +fo = ulong get st_foff si +nfd = ulong get st_nf si +i = ulong 0 +while lt i nfd +st_write1 base tmp idx add fo i i +i = add i 1 +end +end + +note sa_st: p = new S v1 .. vn. Stack slot of the cell count, 16-byte aligned, outermost block only. +fn sa_st w ulong sid ulong to void +if ne get nb 0 0 +fail 9 +end +si = sub sid 1 +cells = ulong get st_cells si +by = shl shr add shl cells 3 15 4 4 +s = add get stkbytes 0 by +if gt s 4194304 +fail 23 +end +put stkbytes 0 s +r = alloc +put held 0 get nslot 0 +st_read si +spsub by +stkchk +if ne get xtarget 0 0 +xmovsp r +else +emit or 2432697312 r +end +tmp = alloc +idx = alloc +st_write r tmp idx si +addname w r add si 16 cells 6 0 +end + +note ======== OM-2 section 5: abstract types (spec 5, errata E8, E9). `abstract NAME T [ops W..]` and +note `holds NAME dup32` at top level before the first fn (names pass). NAME is type 64 + index: a value of +note it comes only from `seal NAME v` inside the function NAMEmk returning NAME (else error 28), `open v` +note gives the T value, and the listed operations (rotr/rotl with a T count, and/or/xor of two NAME +note values) keep NAME; anything else on it, a T value or a number where NAME is needed, an array of it and +note the entry function's parameters and result are error 7. With holds, seal checks high32 == low32 +note (LSR, CMP ..., UXTW, B.NE trap 10) unless the constructor body is exactly `ret seal NAME or shl ulong +note x 32 ulong x` with x a uint parameter (rule dup32: uint values are held zero-extended). om2 diag +note reports each check as omc-check 1 kept|erased line=N rule=dup32|-. ======== +fn findab w ulong to ulong +i = ulong 0 +while lt i get nab 0 +if eq get ab_name i w +ret add i 1 +end +i = add i 1 +end +ret 0 +end + +note abty: the current word (not a type word) as an abstract type; anything else is error 16 +fn abty to ulong +a = findab get tw 0 +if eq a 0 +fail 16 +end +ret add a 63 +end + +note opbit: the ops bit of a preserving operation (rotr rotl and or xor), else 0 +fn opbit c ulong to ulong +if eq c 59 +ret 1 +end +if eq c 60 +ret 2 +end +if eq c 38 +ret 4 +end +if eq c 39 +ret 8 +end +if eq c 40 +ret 16 +end +ret 0 +end + +note s_abstract: abstract NAME uint|ulong [ops W ..] (another type is error 7, another op word 16) +fn s_abstract to void +if ne get nf 0 0 +fail 9 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +n = get nab 0 +if ge n 16 +fail 14 +end +put ab_len n get tl 0 +t = typeword +if and ne t 4 ne t 5 +fail 7 +end +ops = ulong 0 +tok +if eq get tk 0 1 +if or gt get tl 0 8 ne kw get tw 0 196 +fail 5 +end +go = true +while go +tok +k = get tk 0 +if or eq k 0 eq k 3 +go = false +else +if or ne k 1 gt get tl 0 8 +fail 16 +end +b = opbit kw get tw 0 +if eq b 0 +fail 16 +end +ops = or ops b +end +end +else +if and ne get tk 0 0 ne get tk 0 3 +fail 5 +end +end +put ab_name n w +put ab_base n uchar t +put ab_ops n ops +put nab 0 add n 1 +end + +note ab_entry: function f (index) is the entry of a function-mode unit: no abstract parameter or result +fn ab_entry f ulong to void +if eq get om2 0 0 +ret +end +if ne get scanning 0 0 +ret +end +if ne get progmode 0 0 +ret +end +if ne get nexp 0 0 +if eq get fn_exp f 0 +ret +end +else +if ne add f 1 get nf 0 +ret +end +end +if ge get fn_ret f 64 +fail 7 +end +i = ulong 0 +while lt i ulong get fn_np f +if ge get fn_pt add mul f 6 i 64 +fail 7 +end +i = add i 1 +end +end + +note ab_open: open v (the value read): an abstract value becomes its representation type +fn ab_open to void +t = get rt 0 +if lt t 64 +fail 7 +end +put rt 0 ulong get ab_base sub t 64 +end + +note ab_seal: seal NAME v, only in the function NAMEmk (inlined or not) returning NAME (else error 28) +fn ab_seal to void +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +a = ulong 0 +if and eq get tk 0 1 le get tl 0 8 +a = findab get tw 0 +end +if eq a 0 +fail 16 +end +a = sub a 1 +fe = get curfn 0 +if ne get inl 0 0 +fe = get il_fn sub get inl 0 1 +end +if eq ab_ctor fe a 0 +fail 28 +end +t = ulong get ab_base a +rdval 0 t 255 0 +if ne get rt 0 t +fail 7 +end +r = matreg get rk 0 get rv 0 get rt 0 +if ne get ab_holds a 0 +ab_check fe a r +end +put rk 0 1 +put rv 0 r +put rt 0 add a 64 +end + +note ab_ctor: 1 when function fe (index + 1) is NAMEmk for abstract a and returns it +fn ab_ctor fe ulong a ulong to ulong +if eq fe 0 +ret 0 +end +f = sub fe 1 +if ne ulong get fn_ret f add a 64 +ret 0 +end +l = get ab_len a +if ne get fn_nmlen f add l 2 +ret 0 +end +o = get fn_off f +w = get ab_name a +i = ulong 0 +while lt i l +if ne ulong get inp add o i and shr w shl i 3 255 +ret 0 +end +i = add i 1 +end +if ne get inp add o l 109 +ret 0 +end +if ne get inp add add o l 1 107 +ret 0 +end +ret 1 +end + +note ab_check: the dup32 check of a seal (value in r): erased for the exact body, else LSR Xt, Xr, #32 +note (UBFM, C6.2.487); CMP Xt, Wr, UXTW (SUBS extended, C6.2.463); B.NE trap 10 +fn ab_check fe ulong a ulong r ulong to void +ex = ab_exact fe a +if eq get om2m 0 1 +note ab_rec: omc-check 1 kept|erased line=N rule=dup32|- (om2 diag, with the omc-site records) +sitew 7162245557575183727 8 +sitew 540090475 4 +if ne ex 0 +sitew 110386890240613 6 +else +sitew 1953523051 4 +end +sitew 67505853393952 6 +siten add get line 0 get lbase 0 +sitew 67505820627488 6 +if ne ex 0 +sitew 215611372900 5 +else +siteb 45 +end +siteb 10 +end +if eq ex 0 +t = alloc +if ne get xtarget 0 0 +xload 0 r +xload 1 r +emitb 137 +emitb 192 +xb 72 193 233 +emitb 32 +xrr 57 0 1 +xtrap 1 10 +else +emit or or 3546348544 t shl r 5 +emit or or 3944759327 shl r 16 shl t 5 +trapc 1 10 +end +end +end + +note aw_next: the next word of the input from aw_p (blanks skipped, newlines counted in aw_nl) +fn aw_next to void +p = get aw_p 0 +e = get inlen 0 +nl = ulong 0 +go = true +while and go lt p e +b = get inp p +if or eq b 32 eq b 9 +p = add p 1 +else +if eq b 10 +nl = add nl 1 +p = add p 1 +else +go = false +end +end +end +w = ulong 0 +l = ulong 0 +go2 = true +while and go2 lt p e +c = get inp p +if or or eq c 32 eq c 9 eq c 10 +go2 = false +else +if lt l 8 +w = or w shl ulong c shl l 3 +end +l = add l 1 +p = add p 1 +end +end +put aw_p 0 p +put aw_w 0 w +put aw_l 0 l +put aw_nl 0 nl +end + +note aw_is: the next word is w (length l) after exactly nl newlines +fn aw_is w ulong l ulong nl ulong to ulong +aw_next +if ne get aw_w 0 w +ret 0 +end +if ne get aw_l 0 l +ret 0 +end +if ne get aw_nl 0 nl +ret 0 +end +ret 1 +end + +note ab_upar: x (length xl) is a uint scalar parameter of function f (index) +fn ab_upar f ulong x ulong xl ulong to ulong +if gt xl 8 +ret 0 +end +i = ulong 0 +while lt i ulong get fn_np f +p = add mul f 6 i +if eq get fn_pn p x +if eq get fn_pk p 0 +if eq get fn_pt p 4 +ret 1 +end +end +end +i = add i 1 +end +ret 0 +end + +note ab_exact: the body of constructor fe is exactly `ret seal NAME or shl ulong x 32 ulong x` then `end` +fn ab_exact fe ulong a ulong to ulong +f = sub fe 1 +put aw_p 0 get fn_body f +if eq aw_is 7628146 3 0 0 +ret 0 +end +if eq aw_is 1818322291 4 0 0 +ret 0 +end +if eq aw_is get ab_name a get ab_len a 0 0 +ret 0 +end +if eq aw_is 29295 2 0 0 +ret 0 +end +if eq aw_is 7104627 3 0 0 +ret 0 +end +if eq aw_is 444234427509 5 0 0 +ret 0 +end +aw_next +if ne get aw_nl 0 0 +ret 0 +end +x = get aw_w 0 +xl = get aw_l 0 +if eq ab_upar f x xl 0 +ret 0 +end +if eq aw_is 12851 2 0 0 +ret 0 +end +if eq aw_is 444234427509 5 0 0 +ret 0 +end +if eq aw_is x xl 0 0 +ret 0 +end +if eq aw_is 6581861 3 1 0 +ret 0 +end +aw_next +if and ne get aw_l 0 0 eq get aw_nl 0 0 +ret 0 +end +ret 1 +end + +note ab_bin: a binary operation whose operand (fr[x..x+5]) is abstract: only a listed preserving one, run +note on the representation type T and giving NAME; rotr/rotl take a T count (E9), and/or/xor two NAME values +fn ab_bin c ulong dst ulong x ulong to void +at = get fr add x 2 +if lt at 64 +fail 7 +end +a = sub at 64 +b = opbit c +if eq b 0 +fail 7 +end +if eq and get ab_ops a b 0 +fail 7 +end +t = ulong get ab_base a +bk = get fr add x 3 +bt = get fr add x 5 +if or eq c 59 eq c 60 +if eq bk 2 +range get fr add x 4 t bt +put fr add x 3 3 +else +if ne bt t +fail 7 +end +end +else +if ne bt at +fail 7 +end +end +put fr add x 2 t +put fr add x 5 t +binop c dst x +put rt 0 at +end + +note ======== OM-2 section 5: fresh scratch (spec 5, erratum E8). `NAME edit T N fresh` (N <= 64): the +note incoming elements are unspecified. Each such array has a written set (bit i: element i definitely +note written on the path being compiled). A put with a number index (after unrolling and inlining) sets +note its bit; a get with a number index needs its bit, any other get all N bits (else error 27, +note obligation=init). Joins: an if without else, a while and a rolled for keep the set they opened with; +note an if/else takes the intersection of its arms (or the arm that does not end in ret); an unrolled +note body and an inlined body keep what they wrote. Passing the array to a non-inline call, read, write or +note a host operation is error 27; an inline callee works on the same set. ======== +note fz_par: parameter slot f*6+np of kind k with N = ln is fresh: an edit only (else 16), N <= 64 (else 14) +fn fz_par f ulong np ulong k ulong ln ulong to void +if ne k 3 +fail 16 +end +if gt ln 64 +put dobx 0 1 +fail 14 +end +put fn_pfr add mul f 6 np 1 +end + +note fz_bind: the parameter name just added for slot p gets a new written set in the body pass +fn fz_bind p ulong ln ulong to void +if eq get fn_pfr p 0 +ret +end +if ne get scanning 0 0 +ret +end +fz_new sub get nn 0 1 ln +end + +note fz_new: a new, empty written set of N elements for name index n (16 per function, error 14) +fn fz_new n ulong ln ulong to void +s = get fz_n 0 +if ge s 16 +put dobx 0 1 +fail 14 +end +put fz_len s ln +put fz_cur s 0 +put nm_fr n uchar add s 1 +put fz_n 0 add s 1 +end + +note fz_inl: an inline parameter slot p bound to array name e: its own fresh set, or e's set +fn fz_inl p ulong e ulong to void +pk = ulong get fn_pk p +if or eq pk 0 ge pk 6 +ret +end +n = sub get nn 0 1 +if ne get fn_pfr p 0 +fz_new n get fn_pl p +ret +end +put nm_fr n get nm_fr sub e 1 +end + +fn fz_else i ulong to void +j = ulong 0 +while lt j get fz_n 0 +x = add mul i 16 j +put fz_thn x get fz_cur j +put fz_cur j get fz_ent x +j = add j 1 +end +end + +fn fz_join i ulong k ulong to void +td = get bdead i +ed = get dead 0 +j = ulong 0 +while lt j get fz_n 0 +x = add mul i 16 j +if eq k 2 +v = and get fz_cur j get fz_thn x +if and ne td 0 eq ed 0 +v = get fz_cur j +end +if and ne ed 0 eq td 0 +v = get fz_thn x +end +put fz_cur j v +else +put fz_cur j get fz_ent x +end +j = add j 1 +end +end + +note fz_get: get e i with the index in rk/rv/rt +fn fz_get e ulong to void +if ne get cvalid 0 0 +ret +end +s = ulong get nm_fr sub e 1 +if eq s 0 +ret +end +s = sub s 1 +n = get fz_len s +if eq get rk 0 3 +v = get rv 0 +if lt v n +if eq and shr get fz_cur s v 1 0 +fail 27 +end +end +ret +end +if ne get fz_cur s fmask n +fail 27 +end +end + +note fz_put: put e i v with index (k, v): a number index sets its bit +fn fz_put e ulong k ulong v ulong to void +s = ulong get nm_fr sub e 1 +if eq s 0 +ret +end +s = sub s 1 +if eq k 3 +if lt v get fz_len s +put fz_cur s or get fz_cur s shl ulong 1 v +end +end +end + +note fz_arg: array name e leaves the analysis (a non-inline call, read, write, a host operation): error 27 +note when it is tracked +fn fz_arg e ulong to void +if ne get nm_fr sub e 1 0 +fail 27 +end +end + +note ======== OM-2 section 5: external layouts (spec 5, errata E5, E8, E9). `layout NAME SIZE`, then one +note `field F T [COUNT] at OFF little|big` per line, then `end`, before the first fn. Read in the names pass; +note the body pass jumps over the block. A parameter `c view|edit NAME` is a uchar array of SIZE bytes (one +note pointer); `get c F [i]` / `put c F [i] v` load / store the field at its width and byte order: +note LDR/STR (register, unscaled offset; C6.2.216 family) at base + OFF + i * width, REV16 / REV (C6.2.333, +note C6.2.331) for big, a run-time index checked like an array's (CMP, B.HS trap 3) ======== +note findlay: packed name -> layout index + 1, or 0 +fn findlay w ulong to ulong +i = ulong 0 +while lt i get nly 0 +if eq get ly_name i w +ret add i 1 +end +i = add i 1 +end +ret 0 +end + +note findlf: layout index li, packed field name -> field-table index + 1, or 0 +fn findlf li ulong w ulong to ulong +fo = get ly_fo li +i = ulong 0 +while lt i get ly_nf li +if eq get lf_name add fo i w +ret add add fo i 1 +end +i = add i 1 +end +ret 0 +end + +note ns_om2: an OM-2 declaration line in the names pass (1 when it was read), else 0 +fn ns_om2 to ulong +if eq get om2 0 0 +ret 0 +end +if ne get tk 0 1 +ret 0 +end +if gt get tl 0 8 +ret 0 +end +if eq get tw 0 128047730221420 +s_layout +ret 1 +end +if eq get tw 0 8386654075301880417 +s_abstract +ret 1 +end +if eq get tw 0 495606067048 +note s_holds: holds NAME dup32 (ulong representation only); any other predicate is error 28 on this line +if ne get nf 0 0 +fail 9 +end +tok +if ne get tk 0 1 +fail 16 +end +a = ulong 0 +if le get tl 0 8 +a = findab get tw 0 +end +if eq a 0 +fail 16 +end +a = sub a 1 +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 28 +end +if or ne get tl 0 5 ne get tw 0 215611372900 +fail 28 +end +if ne get ab_base a 5 +fail 28 +end +if ne get ab_holds a 0 +fail 10 +end +put ab_holds a 1 +eol +ret 1 +end +if eq get tw 0 128034844735589 +s_export +ret 1 +end +ret 0 +end + +note s_export (OM-2, spec 6): `export fn ...` at top level: the fn line of an exported entry, in both +note passes. Function mode only (error 9), at most 32 (error 14), counted and marked in the names pass. +fn s_export to void +tok +if or ne get tk 0 1 ne get tw 0 28262 +fail 16 +end +if eq get scanning 0 1 +if ne get progmode 0 0 +fail 9 +end +if ge get nexp 0 32 +fail 14 +end +put nexp 0 add get nexp 0 1 +end +put expf 0 1 +s_fn +put expf 0 0 +end + +note ly_num: the next token must be a number (error 4 at the line end, 16 for another token, 29 when it +note was written as 2^63 or more) +fn ly_num to ulong +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 2 +fail 16 +end +if ne get tbig 0 0 +fail 29 +end +ret get tw 0 +end + +note s_layout: SIZE 1..4096 and a layout after the first fn are error 29 on the layout line +fn s_layout to void +if ne get nf 0 0 +fail 29 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +w = get tw 0 +if ne kw w 0 +fail 16 +end +newname w get tl 0 get ts 0 +if ge get nly 0 16 +fail 14 +end +sz = ly_num +if or eq sz 0 gt sz 4096 +fail 29 +end +eol +li = get nly 0 +fo = get nlf 0 +i = ulong 0 +while lt i sz +put lymap i 0 +i = add i 1 +end +go = true +while go +tok +k = get tk 0 +if eq k 3 +fail 4 +end +if eq k 1 +c = ulong 0 +if le get tl 0 8 +c = kw get tw 0 +end +if eq c 66 +eol +go = false +else +if eq c 83 +skipnl +else +if ne c 189 +fail 16 +end +ly_field fo sz +end +end +else +if ne k 0 +fail 16 +end +end +end +put ly_name li w +put ly_size li sz +put ly_fo li fo +put ly_nf li sub get nlf 0 fo +put ly_ec li get cur 0 +put ly_el li get line 0 +put nly 0 add li 1 +end + +note ly_field: F T [COUNT] at OFF little|big. A field over SIZE, a COUNT outside 1..4096, an OFF out of range +note or two fields sharing a byte are error 29 on the field line. Field types are the integer types. +fn ly_field fo ulong sz ulong to void +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +fw = get tw 0 +if ne kw fw 0 +fail 16 +end +n = get nlf 0 +i = fo +while lt i n +if eq get lf_name i fw +fail 10 +end +i = add i 1 +end +if ge n 256 +fail 14 +end +t = typeword +if or lt t 2 gt t 9 +fail 7 +end +cnt = ulong 0 +tok +if eq get tk 0 2 +if ne get tbig 0 0 +fail 29 +end +cnt = get tw 0 +if or eq cnt 0 gt cnt 4096 +fail 29 +end +tok +end +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if ne kw get tw 0 190 +fail 16 +end +off = ly_num +big = ly_end +ly_mark off cnt t sz +eol +put lf_name n fw +put lf_type n uchar t +put lf_cnt n cnt +put lf_off n off +put lf_big n uchar big +put nlf 0 add n 1 +end + +note ly_end: little (0) or big (1) +fn ly_end to ulong +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +c = kw get tw 0 +if eq c 191 +ret 0 +end +if eq c 192 +ret 1 +end +fail 16 +ret 0 +end + +note ly_mark: the bytes OFF .. OFF + max(COUNT, 1) * width must lie inside SIZE and be free (error 29) +fn ly_mark off ulong cnt ulong t ulong sz ulong to void +n = cnt +if eq n 0 +n = ulong 1 +end +by = shl n tlog t +if gt off sz +fail 29 +end +e = add off by +if gt e sz +fail 29 +end +i = off +while lt i e +if ne get lymap i 0 +fail 29 +end +put lymap i 1 +i = add i 1 +end +end + +note peek_lay: if the next word is a layout name, consume it and return index + 1; else rewind +fn peek_lay to ulong +p = get cur 0 +ln = get line 0 +tok +if eq get tk 0 1 +if le get tl 0 8 +lid = findlay get tw 0 +if ne lid 0 +ret lid +end +end +end +put cur 0 p +put line 0 ln +ret 0 +end + +note fn_p_ly: parameter pw is a layout (view k 2 / edit k 3): a uchar array of SIZE bytes, name kind 2 / 3 +fn fn_p_ly f ulong np ulong pw ulong lid ulong k ulong to void +ln = get ly_size sub lid 1 +addname pw poolc get psl 0 2 ln k 0 +put nm_lay sub get nn 0 1 uchar lid +p = add mul f 6 np +put fn_pt p 2 +put fn_pl p ln +put fn_pk p uchar k +put fn_play p uchar lid +end + +note ly_fld: for a layout name e, when the next word is one of its fields: consume it, return the field-table +note index + 1; otherwise rewind and return 0 (the name is then an ordinary uchar array) +fn ly_fld e ulong to ulong +lid = ulong get nm_lay sub e 1 +if eq lid 0 +ret 0 +end +p = get cur 0 +ln = get line 0 +tok +if eq get tk 0 1 +if le get tl 0 8 +j = findlf sub lid 1 get tw 0 +if ne j 0 +ret j +end +end +end +put cur 0 p +put line 0 ln +ret 0 +end + +note ldun / stun: LDRB / LDRH / LDR w / LDR x and the stores, register offset, LSL #0 (S = 0) +fn ldun t ulong to ulong +if or eq t 2 eq t 6 +ret 945842176 +end +if or eq t 3 eq t 7 +ret 2019584000 +end +if or eq t 4 eq t 8 +ret 3093325824 +end +ret 4167067648 +end + +fn stun t ulong to ulong +if or eq t 2 eq t 6 +ret 941647872 +end +if or eq t 3 eq t 7 +ret 2015389696 +end +if or eq t 4 eq t 8 +ret 3089131520 +end +ret 4162873344 +end + +note ly_rev: Rd = the bytes of Rs reversed at width t: REV16 Wd (C6.2.333), REV Wd, REV Xd (C6.2.331) +fn ly_rev t ulong s ulong d ulong to void +if ne get xtarget 0 0 +xload 0 s +if or eq t 2 eq t 6 +xstore 0 d +ret +end +if or eq t 3 eq t 7 +emitb 102 +xb 193 200 8 +else +if or eq t 5 eq t 9 +emitb 72 +end +emitb 15 +emitb 200 +end +xstore 0 d +ret +end +if or eq t 3 eq t 7 +emit or or 1522533376 d shl s 5 +end +if or eq t 4 eq t 8 +emit or or 1522534400 d shl s 5 +end +if or eq t 5 eq t 9 +emit or or 3670019072 d shl s 5 +end +end + +note ly_ix: the byte-offset register of element (k, v, t) of array field j: a number index must be below +note COUNT (error 21); a register index: CMP Xi, #COUNT or Xc (C6.2.96 / C6.2.97), B.HS trap 3, then +note Xo = OFF; ADD Xo, Xo, Xi, LSL #log2 width (C6.2.6) +fn ly_ix j ulong k ulong v ulong t ulong to ulong +if or eq t 1 ge t 10 +fail 7 +end +cnt = get lf_cnt j +sh = tlog ulong get lf_type j +x = alloc +if eq k 3 +if ge v cnt +fail 21 +end +matconst x add get lf_off j shl v sh +ret x +end +r = matreg k v t +if ne get xtarget 0 0 +xcmp r cnt 1 +xtrap 2 3 +xload 0 r +xb 72 193 224 +emitb uchar sh +ximm 1 get lf_off j +xrr 1 0 1 +xstore 0 x +ret x +end +if le cnt 4095 +emit or or 4043309087 shl cnt 10 shl r 5 +else +y = alloc +matconst y cnt +emit or or 3942645791 shl y 16 shl r 5 +end +trapc 2 3 +matconst x get lf_off j +emit or or or or 2332033024 x shl x 5 shl r 16 shl sh 10 +ret x +end + +note ly_get: get c F [i] on a layout name e (1 when it was a field, the value in rk/rv/rt), else 0 +fn ly_get e ulong dst ulong to ulong +j = ly_fld e +if eq j 0 +ret 0 +end +j = sub j 1 +ft = ulong get lf_type j +x = ulong 0 +if eq get lf_cnt j 0 +x = alloc +matconst x get lf_off j +else +rdval 0 5 255 0 +x = ly_ix j get rk 0 get rv 0 get rt 0 +end +rd = destreg dst +if ne get xtarget 0 0 +xlayout 0 ulong get nm_reg sub e 1 x ft rd +else +emit or or or ldun ft rd shl ulong get nm_reg sub e 1 5 shl x 16 +end +if ne get lf_big j 0 +ly_rev ft rd rd +end +if gt ft 5 +canon rd ft +end +put rk 0 1 +put rv 0 rd +put rt 0 ft +ret 1 +end + +note ly_put: put c F [i] v on a layout name e (an edit; a view was refused 20 before): index, value, then +note the store; 1 when it was a field, else 0 +fn ly_put e ulong to ulong +j = ly_fld e +if eq j 0 +ret 0 +end +j = sub j 1 +if ne get lf_cnt j 0 +rdval 0 5 255 0 +put svk 0 get rk 0 +put svv 0 get rv 0 +put svt 0 get rt 0 +end +ly_st e j +eol +ret 1 +end + +note ly_st: the value of field j (index saved in svk/svv/svt), then the store through layout name e +fn ly_st e ulong j ulong to void +ft = ulong get lf_type j +cnt = get lf_cnt j +rdval 0 ft 255 0 +if ne get rt 0 ft +fail 7 +end +v = matreg get rk 0 get rv 0 get rt 0 +x = ulong 0 +if eq cnt 0 +x = alloc +matconst x get lf_off j +else +x = ly_ix j get svk 0 get svv 0 get svt 0 +end +if and ne get lf_big j 0 ne tlog ft 0 +y = alloc +ly_rev ft v y +v = y +end +if ne get xtarget 0 0 +xlayout 1 ulong get nm_reg sub e 1 x ft v +else +emit or or or stun ft v shl ulong get nm_reg sub e 1 5 shl x 16 +end +end + +note vt_fget_go: field j of struct name e. Scalar, or an index then the element. +fn vt_fget_go e ulong dst ulong j ulong to void +fl = ulong get sf_len j +ft = ulong get sf_type j +off = ulong get sf_off j +base = ulong get nm_reg sub e 1 +idx = alloc +if eq fl 0 +st_store_ld base idx off ft dst +else +rdval 0 5 255 0 +if eq get rt 0 1 +fail 7 +end +if eq get rk 0 3 +if ge get rv 0 fl +fail 21 +end +st_store_ld base idx add off get rv 0 ft dst +else +if ne get rk 0 1 +fail 7 +end +st_ixreg idx get rv 0 off fl ft +st_ld base idx ft dst +end +end +end + +note vt_fget: get p f, or get p f i for an array field. Kind 6 own, 7 edit, 8 view; all may be read. +fn vt_fget e ulong dst ulong to void +i = sub e 1 +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +si = sub ulong get nm_type i 16 +fid = findfield si get tw 0 +if eq fid 0 +fail 3 +end +vt_fget_go e dst sub fid 1 +end + +note st_store_ld: constant cell, then load. Split out so vt_fget stays under 16 registers. +fn st_store_ld base ulong idx ulong cell ulong t ulong dst ulong to void +matconst idx shl cell sub 3 tlog t +st_ld base idx t dst +end + +note s_putf_go: field j of struct name e. Read the value (and the index, if an array field) and store. +fn s_putf_go e ulong j ulong to void +fl = ulong get sf_len j +ft = ulong get sf_type j +off = ulong get sf_off j +base = ulong get nm_reg sub e 1 +if ne fl 0 +rdval 0 5 255 0 +if eq get rt 0 1 +fail 7 +end +put svk 0 get rk 0 +put svv 0 get rv 0 +put svt 0 get rt 0 +end +rdval 0 ft 255 0 +if ne get rt 0 ft +fail 7 +end +v = matreg get rk 0 get rv 0 get rt 0 +idx = alloc +if eq fl 0 +st_store base idx off ft v +else +s_putf_ix base idx v off fl ft +end +eol +end + +note s_putf: put p f v, or put p f i v. A view struct is error 20. +fn s_putf e ulong to void +i = sub e 1 +if eq ulong get nm_kind i 8 +fail 20 +end +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 8 +fail 13 +end +si = sub ulong get nm_type i 16 +fid = findfield si get tw 0 +if eq fid 0 +fail 3 +end +s_putf_go e sub fid 1 +end + +note s_putf_ix: the index was saved in svk/svv/svt before the value was read +fn s_putf_ix base ulong idx ulong v ulong off ulong fl ulong ft ulong to void +ik = get svk 0 +iv = get svv 0 +if eq get svt 0 1 +fail 7 +end +if eq ik 3 +if ge iv fl +fail 21 +end +st_store base idx add off iv ft v +else +if ne ik 1 +fail 7 +end +st_ixreg idx iv off fl ft +put ea_b 0 base +put ea_i 0 idx +stel ft v +end +end + +note ca_st_ok: read one struct argument of parameter i of function f. Returns the name entry. +fn ca_st_ok f ulong i ulong to ulong +md = ulong 0 +aa_word +w = get tw 0 +c = kw w +if ne c 0 +if or lt c 57 gt c 58 +fail 16 +end +md = c +aa_word +w = get tw 0 +end +e = findname w +if eq e 0 +fail 3 +end +ni = sub e 1 +k = ulong get nm_kind ni +if lt k 6 +fail 7 +end +p = add mul sub f 1 6 i +pk = ulong get fn_pk p +if eq pk 7 +if eq md 57 +fail 20 +end +if eq k 8 +fail 20 +end +else +if eq md 58 +fail 7 +end +end +if ne ulong get nm_type ni ulong get fn_pt p +fail 7 +end +ret e +end + +note ca_st: a struct argument. edit (fn_pk 7) needs own or edit; view takes any. Same struct. +fn ca_st f ulong i ulong cb ulong to void +e = ca_st_ok f i +note ca_dist: the same struct name passed twice in one call is error 19. +j = ulong 0 +while lt j i +if eq get fr add add cb mul j 3 2 e +fail 19 +end +j = add j 1 +end +q = add cb mul i 3 +put fr q 5 +put fr add q 1 ulong get nm_reg sub e 1 +put fr add q 2 e +end +note ---- R6 IR. A leading line `ir` writes OSC IR version 1. The AArch64 path is not taken. +note Worksheet ir_match.py matched omega_emit on the 10 dev programs; this is that algorithm. + +global ir_rty uchar 64 +global ir_nreg ulong 1 +global ir_nm ulong 32 +global ir_nrr uchar 32 +global ir_nn ulong 1 +global ir_cty uchar 32 +global ir_cm ulong 32 +global ir_cr uchar 32 +global ir_nc ulong 1 +global ir_bord ulong 32 +global ir_nord ulong 1 +global ir_cur ulong 1 +global ir_dead ulong 1 +global ir_nb ulong 1 +global ir_ok uchar 256 +global ir_oa ulong 256 +global ir_ob ulong 256 +global ir_oc ulong 256 +global ir_od ulong 256 +global ir_obl ulong 256 +global ir_no ulong 1 +global ir_bf ulong 32 +global ir_bc ulong 32 +global ir_fk uchar 8 +global ir_fa ulong 8 +global ir_fb ulong 8 +global ir_fc ulong 8 +global ir_fd ulong 8 +global ir_nf ulong 1 +global ir_ret ulong 1 +global ir_npar ulong 1 +global ir_rr ulong 1 +global ir_vt ulong 1 +global ir_bare ulong 1 +global ir_isb ulong 1 +global ir_ns ulong 1 +global ir_nl ulong 1 +global ir_have ulong 1 +global irrec uchar 2620252 +global irrlen ulong 1 +global irnf ulong 1 +global irf_nm ulong 32 +global irf_ns ulong 32 +global irf_nl ulong 32 +global irf_np ulong 32 +global irf_ret uchar 32 +global irf_pt uchar 192 +global irf_n ulong 1 +global ir_args ulong 6 +global ir_oarg ulong 1536 +global ir_miss ulong 1 +global ir_cl ulong 1 +global ir_cs ulong 1 +note per open block frame, the local count when it opened (names bound inside go out of scope at else / end) +global ir_fnn ulong 8 +note ir_bbig: tbig of the bare number in ir_bare, for the range check once its type is known (error 8). +global ir_bbig ulong 1 + +note ir_lead: 1 when the first line is "ir" (after blanks). Both scans run as nested 999999-pass loops, +note so more than 1000000 leading blanks or first-line bytes are read, not trapped 4 (#671). +fn ir_lead to ulong +p = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge p get inlen 0 +go = false +else +c = get inp p +if gt c 32 +go = false +else +if eq c 10 +ret 0 +end +p = add p 1 +end +end +m = add m 1 +end +end +if ge add p 3 get inlen 0 +ret 0 +end +if ne get inp p 105 +ret 0 +end +if ne get inp add p 1 114 +ret 0 +end +if gt get inp add p 2 32 +ret 0 +end +q = add p 2 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge q get inlen 0 +go = false +else +if eq get inp q 10 +go = false +else +q = add q 1 +end +end +m = add m 1 +end +end +if lt q get inlen 0 +q = add q 1 +end +put cur 0 q +put line 0 2 +ret 1 +end + +fn ir_w16 v ulong to void +emitb uchar and v 255 +emitb uchar and shr v 8 255 +end + +fn ir_w32 v ulong to void +ir_w16 v +ir_w16 shr v 16 +end + +fn ir_w64 v ulong to void +ir_w32 v +ir_w32 shr v 32 +end + +fn ir_newreg ty ulong to ulong +r = get ir_nreg 0 +if ge r 64 +fail 14 +end +put ir_rty r uchar ty +put ir_nreg 0 add r 1 +ret r +end + +fn ir_block to ulong +b = get ir_nb 0 +if ge b 32 +fail 14 +end +put ir_bord b 65535 +put ir_nb 0 add b 1 +ret b +end + +fn ir_start b ulong to void +put ir_bord b get ir_nord 0 +put ir_nord 0 add get ir_nord 0 1 +put ir_cur 0 b +put ir_dead 0 0 +end + +fn ir_op k ulong a ulong b ulong c ulong d ulong to void +if ne get ir_dead 0 0 +fail 17 +end +n = get ir_no 0 +if ge n 256 +fail 14 +end +put ir_ok n uchar k +put ir_oa n a +put ir_ob n b +put ir_oc n c +put ir_od n d +put ir_obl n get ir_cur 0 +put ir_no 0 add n 1 +end + +fn ir_lit mag ulong ty ulong to ulong +i = ulong 0 +n = get ir_nc 0 +while lt i n +if and eq ulong get ir_cty i ty eq get ir_cm i mag +ret ulong get ir_cr i +end +i = add i 1 +end +if ge n 32 +fail 14 +end +r = ir_newreg ty +put ir_cty n uchar ty +put ir_cm n mag +put ir_cr n uchar r +put ir_nc 0 add n 1 +ret r +end + +note ir_find: the local in scope named w (packed) -> its index + 1, or 0. Locals are at most 8 bytes, so a +note word of length l over 8 is never one (its packed first 8 bytes may equal a local's name). +fn ir_find w ulong l ulong to ulong +if gt l 8 +ret 0 +end +i = ulong 0 +while lt i get ir_nn 0 +if eq get ir_nm i w +ret add i 1 +end +i = add i 1 +end +ret 0 +end + +fn ir_bind w ulong r ulong to void +n = get ir_nn 0 +if ge n 32 +fail 14 +end +put ir_nm n w +put ir_nrr n uchar r +put ir_nn 0 add n 1 +end + +note ir_kwt: the keyword number of the current word, or 0 for a word over 8 bytes (only 8 are packed). +fn ir_kwt to ulong +if gt get tl 0 8 +ret 0 +end +ret kw get tw 0 +end + +note ir_newname: a new local, parameter or function name must not be a keyword (16), a local in scope, a +note constant, or a function of the unit so far, the current one included (10, as newname). Function +note names compare in full (up to 63 bytes). +fn ir_newname w ulong s ulong l ulong to void +if le l 8 +if ne kw w 0 +fail 16 +end +if ne findname w 0 +fail 10 +end +end +if ne ir_find w l 0 +fail 10 +end +put ir_cl 0 l +put ir_cs 0 s +j = ulong 0 +while lt j get irf_n 0 +if eq get irf_nm j w +if ne ir_nameeq j 0 +fail 10 +end +end +j = add j 1 +end +end + +note ir_newloc: a new local, parameter or for counter: at most 8 bytes (13, as native), then ir_newname. +fn ir_newloc w ulong s ulong l ulong to void +if gt l 8 +fail 13 +end +ir_newname w s l +end + +note ir_type: a type word IR v1 lowers: 1 .. 9, or void (76) when isret is 1. A float, a view / edit array or +note void elsewhere is error 9 (as typeword in IR mode); no word is 4; another word 16. +fn ir_type isret ulong to ulong +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +c = ir_kwt +if and ge c 1 le c 9 +ret c +end +if and eq c 76 eq isret 1 +ret c +end +if or or eq c 76 eq c 88 eq c 89 +fail 9 +end +if or eq c 57 eq c 58 +fail 9 +end +fail 16 +ret 0 +end + +fn ir_push k ulong a ulong b ulong c ulong d ulong to void +n = get ir_nf 0 +if ge n 8 +fail 14 +end +put ir_fk n uchar k +put ir_fa n a +put ir_fb n b +put ir_fc n c +put ir_fd n d +put ir_fnn n get ir_nn 0 +put ir_nf 0 add n 1 +end + +fn ir_set dst ulong r ulong ty ulong to void +put ir_isb 0 0 +if eq dst 65534 +put ir_rr 0 r +put ir_vt 0 ty +ret +end +d = dst +if eq dst 65535 +d = ir_newreg ty +end +ir_op 2 d r 0 0 +put ir_rr 0 d +put ir_vt 0 ty +end + +fn ir_ord id ulong to ulong +ret get ir_bord id +end + +fn ir_count k ulong to ulong +n = ulong 0 +if eq k 0 +n = get ir_nc 0 +end +i = ulong 0 +while lt i get ir_no 0 +if eq ir_ord get ir_obl i k +n = add n 1 +end +i = add i 1 +end +ret n +end + +fn ir_layout to void +k = ulong 0 +at = ulong 0 +while lt k get ir_nord 0 +put ir_bf k at +c = ir_count k +put ir_bc k c +at = add at c +k = add k 1 +end +put ir_no 0 get ir_no 0 +end + +fn ir_wconst to void +i = ulong 0 +while lt i get ir_nc 0 +emitb 1 +ir_w16 ulong get ir_cr i +ir_w64 get ir_cm i +i = add i 1 +end +end + +fn ir_wins k ulong to void +if eq k 0 +ir_wconst +end +i = ulong 0 +while lt i get ir_no 0 +if eq ir_ord get ir_obl i k +op = ulong get ir_ok i +emitb uchar op +if eq op 1 +ir_w16 get ir_oa i +ir_w64 get ir_ob i +end +if eq op 2 +ir_w16 get ir_oa i +ir_w16 get ir_ob i +end +if eq op 3 +emitb uchar get ir_oa i +ir_w16 get ir_ob i +ir_w16 get ir_oc i +ir_w16 get ir_od i +end +if eq op 4 +emitb uchar get ir_oa i +ir_w16 get ir_ob i +ir_w16 get ir_oc i +end +if eq op 5 +emitb uchar get ir_oa i +ir_w16 get ir_ob i +ir_w16 get ir_oc i +ir_w16 get ir_od i +end +if eq op 6 +ir_w16 get ir_oa i +ir_w16 get ir_ob i +end +if eq op 11 +ir_w16 get ir_oa i +ir_w16 get ir_ob i +emitb uchar get ir_oc i +j = ulong 0 +while lt j get ir_oc i +ir_w16 get ir_oarg add mul i 6 j +j = add j 1 +end +end +if eq op 12 +emitb uchar get ir_oa i +end +if eq op 13 +ir_w16 ir_ord get ir_oa i +end +if eq op 14 +ir_w16 get ir_oa i +ir_w16 ir_ord get ir_ob i +ir_w16 ir_ord get ir_oc i +end +if eq op 15 +ir_w16 get ir_oa i +end +end +i = add i 1 +end +end + +fn ir_record to void +emitb uchar get ir_nl 0 +p = get ir_ns 0 +e = add p get ir_nl 0 +while lt p e +emitb get inp p +p = add p 1 +end +emitb uchar get ir_npar 0 +if eq get ir_ret 0 76 +emitb 0 +else +emitb uchar get ir_ret 0 +end +ir_w16 get ir_nreg 0 +i = ulong 0 +while lt i get ir_nreg 0 +emitb get ir_rty i +i = add i 1 +end +ir_layout +ir_w16 get ir_nord 0 +k = ulong 0 +while lt k get ir_nord 0 +ir_w32 get ir_bf k +ir_w32 get ir_bc k +k = add k 1 +end +tot = ulong 0 +k = ulong 0 +while lt k get ir_nord 0 +tot = add tot get ir_bc k +k = add k 1 +end +ir_w32 tot +k = ulong 0 +while lt k get ir_nord 0 +ir_wins k +k = add k 1 +end +ir_w16 0 +ir_w16 0 +end + +note ir_emit_record: encode the current function into irrec and count it. The per-function IR state is +note reset by ir_fn, so this must run before the next fn line. +fn ir_emit_record to void +if ge get irnf 0 32 +fail 14 +end +put oc 0 0 +ir_record +n = get oc 0 +base = get irrlen 0 +i = ulong 0 +while lt i n +put irrec add base i get out i +i = add i 1 +end +put irrlen 0 add base n +put irnf 0 add get irnf 0 1 +end + +fn ir_byteeq o ulong s ulong k ulong to ulong +if eq get inp add o k get inp add s k +ret 1 +end +ret 0 +end + +note ir_nameeq: table entry j's name equals the current source name token (length and bytes past 8). +fn ir_nameeq j ulong to ulong +fl = get irf_nl j +if ne fl get ir_cl 0 +ret 0 +end +k = ulong 8 +same = ulong 1 +while and eq same 1 lt k get ir_cl 0 +if eq ir_byteeq get irf_ns j get ir_cs 0 k 0 +same = 0 +end +k = add k 1 +end +ret same +end + +note ir_findfn: packed name -> earlier function index + 1, or 0. The current function is the newest +note table entry and is never returned, so self and forward calls fail. +fn ir_findfn w ulong to ulong +if le get irf_n 0 1 +ret 0 +end +fc = sub get irf_n 0 1 +j = ulong 0 +while lt j fc +if eq get irf_nm j w +if ne ir_nameeq j 0 +ret add j 1 +end +end +j = add j 1 +end +ret 0 +end + +note ir_callop: CALL in the IR's five-field form; the argument registers live in ir_args[0..nargs). +fn ir_callop dst ulong callee ulong nargs ulong to void +if ne get ir_dead 0 0 +fail 17 +end +n = get ir_no 0 +if ge n 256 +fail 14 +end +put ir_ok n 11 +put ir_oa n dst +put ir_ob n callee +put ir_oc n nargs +put ir_od n 0 +put ir_obl n get ir_cur 0 +j = ulong 0 +while lt j nargs +put ir_oarg add mul n 6 j get ir_args j +j = add j 1 +end +put ir_no 0 add n 1 +end + +fn ir_name to void +e = ir_find get tw 0 get tl 0 +if eq e 0 +if le get tl 0 8 +e = findname get tw 0 +end +if ne e 0 +if eq get nm_kind sub e 1 9 +t = ulong get nm_type sub e 1 +if ge t 10 +fail 9 +end +r = ir_lit get nm_addr sub e 1 t +ir_set 65534 r t +ret +end +end +put ir_miss 0 1 +ret +end +r = ulong get ir_nrr sub e 1 +ir_set 65534 r ulong get ir_rty r +end + +fn ir_un c ulong dst ulong to void +ir_val 65534 0 +if ne get ir_isb 0 0 +fail 11 +end +ty = get ir_vt 0 +if and eq c 49 eq ty 1 +fail 7 +end +d = dst +if or eq dst 65534 eq dst 65535 +d = ir_newreg ty +end +su = ulong 1 +if eq c 50 +su = ulong 3 +if ne ty 1 +su = ulong 2 +end +end +ir_op 4 su d get ir_rr 0 0 +put ir_rr 0 d +put ir_vt 0 ty +put ir_isb 0 0 +end + +fn ir_bin_r left ulong lty ulong c ulong dst ulong to void +exp2 = lty +if or eq c 41 eq c 42 +exp2 = ulong 0 +end +ir_val 65534 exp2 +ir_bin_done left lty c dst +end + +fn ir_bin_done left ulong lty ulong c ulong dst ulong to void +isb2 = get ir_isb 0 +ty2 = get ir_vt 0 +if or eq c 41 eq c 42 +if or ge lty 10 eq lty 1 +fail 7 +end +if eq isb2 0 +if or ge ty2 10 eq ty2 1 +fail 7 +end +end +else +if ge lty 10 +fail 7 +end +if and eq isb2 0 ne ty2 lty +fail 7 +end +if and and ge c 33 le c 37 eq lty 1 +fail 7 +end +end +right = get ir_rr 0 +if ne isb2 0 +range get ir_bare 0 lty get ir_bbig 0 +right = ir_lit get ir_bare 0 lty +end +if ge c 43 +d = dst +if or eq dst 65534 eq dst 65535 +d = ir_newreg 1 +end +ir_op 5 sub c 42 d left right +put ir_rr 0 d +put ir_vt 0 1 +ret +end +d = dst +if or eq dst 65534 eq dst 65535 +d = ir_newreg lty +end +ir_op 3 sub c 32 d left right +put ir_rr 0 d +put ir_vt 0 lty +put ir_isb 0 0 +end + +fn ir_bin c ulong dst ulong to void +ir_val 65534 0 +if ne get ir_isb 0 0 +mag = get ir_bare 0 +bg = get ir_bbig 0 +ir_val 65534 0 +if ne get ir_isb 0 0 +fail 11 +end +ty = get ir_vt 0 +range mag ty bg +left = ir_lit mag ty +ir_bin_done left ty c dst +ret +end +left = get ir_rr 0 +lty = get ir_vt 0 +ir_bin_r left lty c dst +end + +note ir_cast: TYPE v. The operand keeps its own type (as native rdval reads it, exp 0); a bare number is +note checked against TYPE (8). bool converts to and from numbers only by comparison (9, as vt_conv). +note Only a constant of TYPE is the value itself; any other same-type value is a mov, as the C oracle. +fn ir_cast c ulong dst ulong to void +ir_val 65534 0 +if ne get ir_isb 0 0 +range get ir_bare 0 c get ir_bbig 0 +r = ir_lit get ir_bare 0 c +ir_set dst r c +ret +end +src = get ir_rr 0 +sty = get ir_vt 0 +if xor eq sty 1 eq c 1 +fail 9 +end +k = ulong 0 +if and eq sty c eq dst 65534 +i = ulong 0 +while lt i get ir_nc 0 +if eq ulong get ir_cr i src +k = ulong 1 +end +i = add i 1 +end +end +if ne k 0 +put ir_rr 0 src +put ir_vt 0 c +put ir_isb 0 0 +ret +end +d = dst +if or eq dst 65534 eq dst 65535 +d = ir_newreg c +end +if eq sty c +ir_op 2 d src 0 0 +else +ir_op 6 d src 0 0 +end +put ir_rr 0 d +put ir_vt 0 c +put ir_isb 0 0 +end + +fn ir_val dst ulong exp ulong to void +put ir_isb 0 0 +put ir_miss 0 0 +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if or eq get tk 0 4 eq get tk 0 5 +fail 9 +end +if eq get tk 0 2 +if eq exp 0 +put ir_bare 0 get tw 0 +put ir_bbig 0 get tbig 0 +put ir_isb 0 1 +ret +end +range get tw 0 exp get tbig 0 +r = ir_lit get tw 0 exp +ir_set dst r exp +ret +end +c = ir_kwt +if and ge c 1 le c 9 +ir_cast c dst +ret +end +if and ge c 33 le c 48 +ir_bin c dst +if and ne exp 0 ne get ir_vt 0 exp +fail 7 +end +ret +end +if or eq c 49 eq c 50 +ir_un c dst +if and ne exp 0 ne get ir_vt 0 exp +fail 7 +end +ret +end +if eq c 55 +if and ne exp 0 ne exp 1 +fail 7 +end +r = ir_lit 1 1 +ir_set dst r 1 +ret +end +if eq c 56 +if and ne exp 0 ne exp 1 +fail 7 +end +r = ir_lit 0 1 +ir_set dst r 1 +ret +end +ir_name +if ne get ir_miss 0 0 +put ir_cl 0 get tl 0 +put ir_cs 0 get ts 0 +f = ir_findfn get tw 0 +if eq f 0 +fail 3 +end +j = sub f 1 +rtv = ulong get irf_ret j +if eq rtv 76 +fail 7 +end +np = get irf_np j +i = ulong 0 +while lt i np +ty = ulong get irf_pt add mul j 6 i +ir_val 65534 ty +if ne get ir_vt 0 ty +fail 7 +end +put ir_args i get ir_rr 0 +i = add i 1 +end +r = dst +if or eq dst 65534 eq dst 65535 +r = ir_newreg rtv +end +ir_callop r j np +put ir_rr 0 r +put ir_vt 0 rtv +ret +end +if ne dst 65534 +ir_set dst get ir_rr 0 get ir_vt 0 +end +end + +fn ir_end to void +n = sub get ir_nf 0 1 +put ir_nf 0 n +k = ulong get ir_fk n +put ir_nn 0 get ir_fnn n +if eq k 1 +if eq get ir_fc n 0 +if eq get ir_dead 0 0 +ir_op 13 get ir_fb n 0 0 0 +put ir_dead 0 1 +end +ir_start get ir_fb n +else +if eq get ir_dead 0 0 +if eq get ir_fd n 65535 +j = ir_block +put ir_fd n j +end +ir_op 13 get ir_fd n 0 0 0 +put ir_dead 0 1 +end +if ne get ir_fd n 65535 +ir_start get ir_fd n +end +end +end +if eq k 2 +if eq get ir_dead 0 0 +ir_op 13 get ir_fa n 0 0 0 +put ir_dead 0 1 +end +ir_start get ir_fb n +end +if eq k 3 +if eq get ir_dead 0 0 +one = ir_lit 1 ulong get ir_rty get ir_fc n +ir_op 3 1 get ir_fc n get ir_fc n one +ir_op 13 get ir_fa n 0 0 0 +put ir_dead 0 1 +end +ir_start get ir_fb n +end +if eq k 4 +if eq get ir_dead 0 0 +if ne get ir_ret 0 76 +fail 18 +end +ir_op 15 65535 0 0 0 +put ir_dead 0 1 +end +put ir_have 0 1 +end +eol +end + +note ir_bound: the rest of a while or for line: `bound N` (1 .. 1000000, error 8: the C oracle's range, +note omegese.c, and the guard range checker2 proves) -> N, or 0 when the line ends there. +fn ir_bound to ulong +tok +if or eq get tk 0 0 eq get tk 0 3 +ret 0 +end +if or ne get tk 0 1 ne ir_kwt 70 +fail 5 +end +bnd = lenval 4 +if ge sub bnd 1 1000000 +fail 8 +end +eol +ret bnd +end + +fn ir_while to void +z = ir_lit 0 5 +one = ir_lit 1 5 +cnt = ir_newreg 5 +ir_op 2 cnt z 0 0 +h = ir_block +g = ir_block +tb = ir_block +body = ir_block +ex = ir_block +ir_op 13 h 0 0 0 +put ir_dead 0 1 +ir_start h +ir_val 65534 1 +if ne get ir_vt 0 1 +fail 7 +end +lim = ir_bound +if eq lim 0 +lim = ulong 1000000 +end +lim = ir_lit lim 5 +ir_op 14 get ir_rr 0 g ex 0 +ir_start g +ger = ir_newreg 1 +ir_op 5 6 ger cnt lim +ir_op 14 ger tb body 0 +ir_start tb +ir_op 12 4 0 0 0 +ir_op 13 ex 0 0 0 +put ir_dead 0 1 +ir_start body +ir_op 3 1 cnt cnt one +ir_push 2 h ex cnt 0 +end + +note ir_for: for name type count [bound N]. The counter is bound after the count is read, so the count cannot +note name it. nc: 1 when the count is a number or an integer constant name (not a local), seen ahead without +note reading it. Such a count must be 0..1000000 (error 8 otherwise, a minus sign included): the C oracle's +note count range (omegese.c for_line), so a plain loop never counts past what checker2 proves. Such a count +note with no bound opens the plain loop (ir_forg with N = 0); any other count, and any count with a bound, +note opens the guarded loop with N, default 1000000. The counter leaves scope at its end. +fn ir_for to void +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +w = get tw 0 +ir_newloc w get ts 0 get tl 0 +ty = ir_type 0 +if eq ty 1 +fail 7 +end +c0 = get cur 0 +l0 = get line 0 +a0 = get tka 0 +b0 = get tkb 0 +tok +nc = ulong 0 +if eq get tk 0 2 +nc = ulong 1 +if eq get inp get ts 0 45 +fail 8 +end +if gt get tw 0 1000000 +fail 8 +end +end +if and eq get tk 0 1 le get tl 0 8 +if eq ir_find get tw 0 get tl 0 0 +e = findname get tw 0 +if ne e 0 +if eq get nm_kind sub e 1 9 +nc = ulong 1 +if lt get nm_type sub e 1 10 +if gt get nm_addr sub e 1 1000000 +fail 8 +end +end +end +end +end +end +put cur 0 c0 +put line 0 l0 +put tka 0 a0 +put tkb 0 b0 +if eq nc 1 +z = ir_lit 0 ty +end +ir_val 65534 ty +if ne get ir_vt 0 ty +fail 7 +end +kr = get ir_rr 0 +bn = ir_bound +if and eq bn 0 eq nc 0 +bn = ulong 1000000 +end +ir_forg w ty kr bn +end + +note ir_forg: the for loop over counter ctr = 0 below kr. N = 0: the plain loop, head: lt ctr kr -> body | exit. +note Else the guarded loop, the C oracle's shape (omegese.c guarded_loop): a ulong counter cnt = 0 as well; head: +note lt ctr kr -> guard | exit; guard: ge cnt N -> trap 4 | body; body starts with cnt = add cnt 1. Literals and +note blocks are made in the oracle's order (literals are shared). The latch adds 1 to ctr (ir_end kind 3). The +note for frame (kind 3: head h, exit ex, counter ctr): the counter, bound last, leaves scope at the end. +note The literals 0 and 1 are made first (shared; ir_lit returns the same register again), then the counters. +note om4 holds 16 registers per function, so the guard blocks reuse names already dead: ty is the guard block +note and w the trap block (both after ir_bind); cnt is 0 only in the plain loop (two literals precede it). +fn ir_forg w ulong ty ulong kr ulong bn ulong to void +cnt = ulong 0 +if ne bn 0 +cnt = ir_lit 0 5 +cnt = ir_lit 1 5 +cnt = ir_newreg 5 +end +ctr = ir_lit 0 ty +ctr = ir_lit 1 ty +ctr = ir_newreg ty +ir_op 2 ctr ir_lit 0 ty 0 0 +ir_bind w ctr +h = ir_block +if ne bn 0 +ir_op 2 cnt ir_lit 0 5 0 0 +ty = ir_block +w = ir_block +end +body = ir_block +ex = ir_block +ir_op 13 h 0 0 0 +put ir_dead 0 1 +ir_start h +c = ir_newreg 1 +ir_op 5 3 c ctr kr +if eq bn 0 +ir_op 14 c body ex 0 +else +bn = ir_lit bn 5 +ir_op 14 c ty ex 0 +ir_start ty +c = ir_newreg 1 +ir_op 5 6 c cnt bn +ir_op 14 c w body 0 +ir_start w +ir_op 12 4 0 0 0 +ir_op 13 ex 0 0 0 +put ir_dead 0 1 +end +ir_start body +if ne cnt 0 +ir_op 3 1 cnt cnt ir_lit 1 5 +end +ir_push 3 h ex ctr 0 +kr = sub get ir_nf 0 1 +put ir_fnn kr sub get ir_nn 0 1 +end + +note ir_stmtcall: a void call as a statement; f is the table index + 1. +fn ir_stmtcall f ulong to void +j = sub f 1 +if ne get irf_ret j 76 +fail 7 +end +np = get irf_np j +i = ulong 0 +while lt i np +ty = ulong get irf_pt add mul j 6 i +ir_val 65534 ty +if ne get ir_vt 0 ty +fail 7 +end +put ir_args i get ir_rr 0 +i = add i 1 +end +ir_callop 65535 j np +eol +end + +note ir_assign: name [=] value for a local in scope, a void call, or a new typed local (a new name that is +note a keyword, constant, local or function is refused; a bare number has no type, error 11). +fn ir_assign w ulong to void +p = get ts 0 +l = get tl 0 +c0 = get cur 0 +tok +eqs = false +if and eq get tk 0 1 eq ir_kwt 73 +eqs = true +else +put cur 0 c0 +if eq get tk 0 0 +put line 0 sub get line 0 1 +end +end +e = ir_find w l +if ne e 0 +r = ulong get ir_nrr sub e 1 +ir_val r ulong get ir_rty r +if ne get ir_vt 0 ulong get ir_rty r +fail 7 +end +eol +ret +end +put ir_cl 0 l +put ir_cs 0 p +f = ir_findfn w +if ne f 0 +if eqs +fail 7 +end +ir_stmtcall f +ret +end +if le l 8 +if ne findname w 0 +fail 7 +end +end +ir_newloc w p l +ir_val 65535 0 +if ne get ir_isb 0 0 +fail 11 +end +eol +ir_bind w get ir_rr 0 +end + +note ir_loopexit: innermost loop block's exit + 1, or 0 outside a loop. +fn ir_loopexit to ulong +i = get ir_nf 0 +while gt i 0 +i = sub i 1 +k = ulong get ir_fk i +if or eq k 2 eq k 3 +ret add get ir_fb i 1 +end +end +ret 0 +end + +note ir_stmt: one line. The end of the input inside a function is error 15; a line starting with a number +note is 16; a note is skipped even after the path ended; a statement IR v1 does not lower is 9. +fn ir_stmt to ulong +tok +if eq get tk 0 0 +ret 0 +end +if eq get tk 0 3 +fail 15 +end +if ne get tk 0 1 +fail 16 +end +c = ir_kwt +if eq c 83 +skipnl +ret 0 +end +if and ne c 66 ne c 68 +if ne get ir_dead 0 0 +fail 17 +end +end +if eq c 77 +fail 9 +end +if eq c 87 +note ir_trap: OMEGESE section 4. A trap ends the path but the IR still +note needs an unreachable ret terminator (zero of the return type, or void). +note trap is packed little endian 1885434484; independently checked in Wolfram. +code = lenval 4 +if or lt code 1 gt code 14 +fail 8 +end +tok +if not or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +ir_op 12 code 0 0 0 +z = ulong 65535 +if ne get ir_ret 0 76 +z = ir_lit 0 get ir_ret 0 +end +ir_op 15 z 0 0 0 +put ir_dead 0 1 +ret 0 +end +if eq c 86 +note ir_break: BR to the innermost loop's exit, then the path is dead. The if/loop closes skip the +note unreachable join exactly as they do after ret or trap. +ex = ir_loopexit +if eq ex 0 +fail 9 +end +ir_op 13 sub ex 1 0 0 0 +put ir_dead 0 1 +eol +ret 0 +end +if eq c 66 +ir_end +ret 0 +end +if eq c 68 +n = sub get ir_nf 0 1 +if or ne get ir_fk n 1 ne get ir_fc n 0 +fail 15 +end +eol +put ir_nn 0 get ir_fnn n +if eq get ir_dead 0 0 +j = ir_block +ir_op 13 j 0 0 0 +put ir_dead 0 1 +put ir_fd n j +else +put ir_fd n 65535 +end +put ir_fc n 1 +ir_start get ir_fb n +ret 0 +end +if eq c 67 +ir_val 65534 1 +if ne get ir_vt 0 1 +fail 7 +end +eol +th = ir_block +el = ir_block +ir_op 14 get ir_rr 0 th el 0 +ir_push 1 th el 0 65535 +ir_start th +ret 0 +end +if eq c 69 +ir_while +ret 0 +end +if eq c 71 +ir_for +ret 0 +end +if eq c 72 +note ir_doret: ret alone in a void function, ret value otherwise (4 when the value is missing, 5 for a +note value or any other word after it); the value is read from just after ret. +c0 = get cur 0 +tok +if or eq get tk 0 0 eq get tk 0 3 +if ne get ir_ret 0 76 +fail 4 +end +ir_op 15 65535 0 0 0 +else +if eq get ir_ret 0 76 +fail 5 +end +put cur 0 c0 +ir_val 65534 get ir_ret 0 +if ne get ir_vt 0 get ir_ret 0 +fail 7 +end +eol +ir_op 15 get ir_rr 0 0 0 0 +end +put ir_dead 0 1 +ret 0 +end +if eq c 64 +fail 15 +end +if ne c 0 +if eq c 97 +note continue keeps its documented IR refusal, error 3 (gate-ir.sh continue_use) +fail 3 +end +if or eq c 80 eq c 82 +fail 9 +end +if or or or eq c 78 eq c 79 eq c 81 eq c 85 +fail 9 +end +if eq c 193 +fail 9 +end +fail 16 +end +note a contract clause (requires, ensures, invariant not followed by =) is not an IR v1 statement: refuse it, never +note read it as a local (#791). `ensures = v` assigns a local of that name, as the C oracle and native mode accept. +if ne cp_kind 0 +p = get ts 0 +l = get line 0 +tok +eqs = and eq get tk 0 1 eq ir_kwt 73 +put cur 0 p +put line 0 l +tok +if not eqs +fail 30 +end +end +ir_assign get tw 0 +ret 0 +end + +note ir_param: parameter np of function f, named by the current word: a new name and an IR v1 type. +fn ir_param f ulong to void +w = get tw 0 +s = get ts 0 +l = get tl 0 +ir_newloc w s l +np = get irf_np f +if ge np 6 +fail 9 +end +ty = ir_type 0 +put irf_pt add mul f 6 np uchar ty +put irf_np f add np 1 +r = ir_newreg ty +ir_bind w r +end + +note ir_fn: fn name (param type)* to type | void, then the body. The name is checked (16, 13 over 63 +note bytes, 10 when in use) and entered before the parameters, so a parameter cannot reuse it. +fn ir_fn to void +tok +if ne get tk 0 1 +fail 16 +end +if gt get tl 0 63 +fail 13 +end +fcur = get irf_n 0 +if ge fcur 32 +fail 14 +end +put ir_nn 0 0 +ir_newname get tw 0 get ts 0 get tl 0 +put irf_nm fcur get tw 0 +put irf_ns fcur get ts 0 +put irf_nl fcur get tl 0 +put irf_np fcur 0 +put irf_n 0 add fcur 1 +put ir_ns 0 get ts 0 +put ir_nl 0 get tl 0 +put ir_nreg 0 0 +put ir_nc 0 0 +put ir_nb 0 0 +put ir_nord 0 0 +put ir_no 0 0 +put ir_nf 0 0 +put ir_dead 0 0 +go = true +while go +tok +if or eq get tk 0 0 eq get tk 0 3 +fail 4 +end +if ne get tk 0 1 +fail 16 +end +if eq ir_kwt 65 +go = false +else +ir_param fcur +end +end +put ir_ret 0 ir_type 1 +eol +put irf_ret fcur uchar get ir_ret 0 +put ir_npar 0 get ir_nreg 0 +b = ir_block +ir_start b +ir_push 4 0 0 0 0 +put ir_have 0 0 +while eq get ir_have 0 0 +ignored = ir_stmt +end +end + +fn ir_run to void +go = true +while go +tok +k = get tk 0 +if eq k 3 +go = false +else +if eq k 0 +else +if ne k 1 +fail 16 +end +c = kw get tw 0 +if eq c 64 +ir_fn +ir_emit_record +else +if eq c 83 +skipnl +else +if eq c 152 +s_const +else +if or or eq c 85 eq c 78 eq c 79 +fail 9 +end +fail 16 +end +end +end +end +end +end +note ir_encode: header (magic, version 1, nfuncs) followed by every collected function record. +put oc 0 0 +emitb 79 +emitb 83 +emitb 67 +emitb 49 +emitb 73 +emitb 82 +emitb 0 +emitb 1 +ir_w16 get irnf 0 +i = ulong 0 +while lt i get irrlen 0 +emitb get irrec i +i = add i 1 +end +if ne get fmtm 0 0 +fmtout +end +n = write 1 out 0 get oc 0 +exit 0 +end + +note ======== executable contract predicates (OM-2, native targets) ======== +note Token packs below: Wolfram FromDigits[Reverse[ToCharacterCode[word]],256]. +note Contract words are contextual: OM-1 name meanings and keyword-table bytes do not change. +note Explicit native build policy, with syntax and purity checked in both policies. +note om2 debug / om2 release and om2 diag debug / om2 diag release; fmt stays canonical. +fn cp_mode q ulong to ulong +if gt add q 4 get inlen 0 +ret 0 +end +if ne get inp q 111 +ret 0 +end +if ne get inp add q 1 109 +ret 0 +end +if ne get inp add q 2 50 +ret 0 +end +if ne get inp add q 3 32 +ret 0 +end +p = add q 4 +m = ulong 1 +if le add p 5 get inlen 0 +if and eq get inp p 100 eq get inp add p 1 105 +if and eq get inp add p 2 97 eq get inp add p 3 103 +if eq get inp add p 4 32 +p = add p 5 +m = ulong 2 +end +end +end +end +if ne lineis p 28555834798400882 7 0 +put crel 0 1 +ret m +end +if ne lineis p 444351014244 5 0 +ret m +end +ret 0 +end + +fn cp_kind to ulong +if and eq get om2 0 0 eq get irmode 0 0 +ret 0 +end +if ne get tk 0 1 +ret 0 +end +if and eq get tl 0 8 eq get tw 0 8315178084276987250 +ret 1 +end +if and eq get tl 0 7 eq get tw 0 32481164592901733 +ret 2 +end +if and eq get tl 0 9 eq get tw 0 7953754356895346281 +if eq get inp add get ts 0 8 116 +ret 3 +end +end +ret 0 +end + +note cp_next reads the next prefix clause, ignoring comments and blanks; a nonclause is unread. +fn cp_next to ulong +p = get cur 0 +l = get line 0 +go = true +while go +tok +if eq get tk 0 1 +if and eq get tl 0 4 eq get tw 0 1702129518 +skipnl +else +go = false +end +else +if ne get tk 0 0 +go = false +end +end +end +k = cp_kind +if eq k 0 +put cur 0 p +put line 0 l +end +ret k +end + +note Recursive purity allowlist, before rdval dispatch. No calls, floats, host or mapped operations. +fn cp_token to void +if eq get tk 0 2 +ret +end +if ne get tk 0 1 +fail 30 +end +if gt get tl 0 8 +fail 30 +end +c = kw get tw 0 +if eq c 0 +ret +end +if le sub c 1 8 +ret +end +if le sub c 33 19 +ret +end +if or eq c 55 eq c 56 +ret +end +if or or eq c 59 eq c 60 eq c 74 +ret +end +fail 30 +end + +fn cp_erase to void +put oc 0 get csnap 0 +put nt 0 get csnap 1 +put nsite 0 get csnap 2 +put tgoc 0 get csnap 5 +put lastb 0 get csnap 6 +end + +fn cp_eval code ulong erase ulong to void +ln = get line 0 +rule = ulong 0 +note Pure evaluation changes no names, calls, inline frames or writes. +note Snapshot emission effects, including trap records, diagnostic sites and branch targets. +put csnap 0 get oc 0 +put csnap 1 get nt 0 +put csnap 2 get nsite 0 +put csnap 3 get nslot 0 +put csnap 4 get fzone 0 +put csnap 5 get tgoc 0 +put csnap 6 get lastb 0 +put cpure 0 1 +put fzone 0 1 +rdval 0 1 255 0 +if ne get rt 0 1 +fail 7 +end +eol +nextln = get line 0 +put line 0 ln +if and eq get rk 0 3 ne get rv 0 0 +rule = ulong 1 +cp_erase +else +if or ne erase 0 ne get crel 0 0 +rule = ulong 2 +cp_erase +else +if eq get rk 0 3 +trapc 14 code +else +if eq get rk 0 4 +trapc xor get rv 0 1 code +else +r = matreg get rk 0 get rv 0 get rt 0 +trapsite or 3019898880 r code +end +end +end +end +if and eq get om2m 0 1 eq erase 0 +cp_rec rule +end +put line 0 nextln +put cpure 0 0 +put cvalid 0 0 +put fzone 0 get csnap 4 +put nslot 0 get csnap 3 +end + +note omc-check distinguishes a proof from release policy; initial deferred validation is silent. +fn cp_rec rule ulong to void +sitew 7162245557575183727 8 +sitew 540090475 4 +if eq rule 0 +sitew 1953523051 4 +else +sitew 110386890240613 6 +end +sitew 67505853393952 6 +siten add get line 0 get lbase 0 +sitew 67505820627488 6 +if eq rule 0 +sitew 28549272340166002 7 +end +if eq rule 1 +sitew 8389750308618530659 8 +sitew 435762132013 5 +end +if eq rule 2 +sitew 28555834798400882 7 +end +sitew 67501558426400 6 +if eq get ckind 0 1 +sitew 8315178084276987250 8 +end +if eq get ckind 0 2 +sitew 32481164592901733 7 +end +if eq get ckind 0 3 +sitew 7953754356895346281 8 +siteb 116 +end +siteb 10 +end + +note Function prefix predicates bind only globals and parameters visible on entry. +fn cp_entry to void +lv = get inl 0 +put cfhas lv 0 +if eq get om2 0 0 +ret +end +put cfpos lv get cur 0 +put cfline lv get line 0 +put cflim lv get nn 0 +put clim 0 get nn 0 +k = cp_next +n = ulong 0 +while ne k 0 +put ckind 0 k +if ge n 64 +fail 14 +end +if eq k 3 +fail 30 +end +put crkind 0 0 +if eq k 1 +cp_eval 9 0 +else +put cfhas lv 1 +ns = get nslot 0 +put crtype 0 get curret 0 +if ne get curret 0 12 +put crkind 0 1 +put crval 0 alloc +end +put cvalid 0 1 +cp_eval 10 1 +put nslot 0 ns +end +n = add n 1 +k = cp_next +end +end + +note Return expressions are evaluated once, before postconditions, without overwriting argument X0. +fn cp_post kind ulong value ulong ty ulong to void +lv = get inl 0 +if eq get cfhas lv 0 +ret +end +p = get cur 0 +l = get line 0 +put cur 0 get cfpos lv +put line 0 get cfline lv +put clim 0 get cflim lv +put crkind 0 kind +put crval 0 value +put crtype 0 ty +k = cp_next +while ne k 0 +if eq k 2 +put ckind 0 2 +cp_eval 10 0 +else +skipnl +end +k = cp_next +end +put cur 0 p +put line 0 l +end + +note Loop invariants execute at the head, including zero trips and final false condition. +note Continue reaches the checked head (for increments first); break bypasses it. +fn cp_head pos ulong ln ulong to void +if eq get om2 0 0 +ret +end +p = get cur 0 +l = get line 0 +put cur 0 pos +put line 0 ln +put clim 0 get nn 0 +put crkind 0 0 +k = cp_next +n = ulong 0 +while eq k 3 +put ckind 0 3 +if ge n 64 +fail 14 +end +cp_eval 10 0 +n = add n 1 +k = cp_next +end +put cur 0 p +put line 0 l +end + +note Head clauses have already been checked and emitted before the condition, never at body entry. +fn cp_skip to void +if eq get om2 0 0 +ret +end +p = get cur 0 +l = get line 0 +k = cp_next +while eq k 3 +skipnl +p = get cur 0 +l = get line 0 +k = cp_next +end +put cur 0 p +put line 0 l +end + +note main: read all of stdin +note (8 MiB at most, error 14; a read error is 1), find the mode, then one +note statement per line from output byte 180 (om4 START .. STMT) +fn main to int +off = ulong 0 +go = true +while go +m = ulong 0 +while and go lt m 999999 +if ge off len inp +fail 14 +end +n = read 0 inp off sub len inp off +if eq n 0 +go = false +else +if lt n 0 +fail 1 +end +off = add off ulong n +end +m = add m 1 +end +end +put inlen 0 off +xlead +chk_lead +om2lead +if eq get om2m 0 2 +fmtprep +end +if ne ir_lead 0 +put irmode 0 1 +ir_run +end +prescan +namescan +if eq get nexp 0 0 +put oc 0 180 +else +put oc 0 add 176 shl get nexp 0 2 +end +if ne get xtarget 0 0 +put oc 0 512 +if eq get xtarget 0 2 +if eq get progmode 0 0 +fail 25 +end +note The PE headers fill 520 bytes; code is mapped from file offset 512 at RVA 4096 (xefx 2). +put oc 0 520 +end +if eq get progmode 0 0 +m = get nexp 0 +if eq m 0 +m = ulong 1 +end +put oc 0 add 512 mul m 6 +end +end +put line 0 1 +done = false +while not done +m = ulong 0 +while and not done lt m 999999 +if ne stmt 0 +done = true +end +m = add m 1 +end +end +ret 0 +end + +note Linux x86-64 host ABI: Linux v6.17 arch/x86/entry/syscalls/syscall_64.tbl. +note R13 is the initial argument stack; R14 is the saved slot snapshot, private to lowering. +fn xhbegin to void +save +xrr 137 14 4 +end +fn xha x ulong i ulong r ulong to void +q = add add x 8 mul i 2 +k = get fr q +v = get fr add q 1 +if or eq k 3 eq k 7 +ximm r v +else +if eq k 6 +xaddr r v +else +xmem 139 r 14 mul v 8 +end +end +end +fn xhs r ulong s ulong to void +xmem 139 r 14 mul s 8 +end +fn xhb r ulong e ulong off ulong to void +if ge get nm_kind sub e 1 4 +xaddr r get nm_addr sub e 1 +else +xhs r ulong get nm_reg sub e 1 +end +xhs 0 off +xrr 1 r 0 +end +fn xhcall n ulong to void +ximm 0 n +emitb 15 +emitb 5 +end +fn xhdone dst ulong x ulong bytes ulong to void +xsp 0 bytes +hreturn dst x +end +fn xhcmp r ulong v ulong to void +ximm 11 v +xrr 57 r 11 +end +fn xhadd r ulong v ulong to void +ximm 11 v +xrr 1 r 11 +end +fn xhsub r ulong v ulong to void +ximm 11 v +xrr 41 r 11 +end +fn xhraw r ulong b ulong off ulong size ulong to void +emitb uchar add add 64 shl shr r 3 2 shr b 3 +if lt size 4 +emitb 15 +if eq size 1 +emitb 182 +else +emitb 183 +end +else +emitb 139 +end +emitb uchar add add 128 shl and r 7 3 and b 7 +if eq and b 7 4 +emitb 36 +end +xword off +end +fn xhput r ulong b ulong off ulong size ulong to void +if eq size 2 +emitb 102 +end +emitb uchar add add 64 shl shr r 3 2 shr b 3 +if eq size 1 +emitb 136 +else +emitb 137 +end +emitb uchar add add 128 shl and r 7 3 and b 7 +if eq and b 7 4 +emitb 36 +end +xword off +end +fn xhpath x ulong to void +xhb 6 get fr add x 20 get fr add x 21 +xhs 2 get fr add x 22 +xhcmp 2 4095 +xtrap 8 3 +xsp 1 4096 +xrr 137 7 4 +loop = get oc 0 +xrr 133 2 2 +done = xbranch 0 +xhraw 0 6 0 1 +xrr 133 0 0 +xtrap 0 3 +xhput 0 7 0 1 +xhadd 6 1 +xhadd 7 1 +xhsub 2 1 +p = xbranch 14 +xpatch p loop +xpatch done get oc 0 +ximm 0 0 +xhput 0 7 0 1 +end +fn xhscalar c ulong dst ulong x ulong to void +np = hargc c +for i ulong np +ty = ulong 8 +if or and eq c 103 eq i 1 and eq c 139 eq i 1 +ty = ulong 9 +end +harg x i ty +end +xhbegin +for i ulong np +r = ulong 7 +if eq i 1 +r = ulong 6 +end +if eq i 2 +r = ulong 2 +end +xha x i r +end +nr = ulong 292 +if eq c 100 +nr = ulong 3 +end +if eq c 101 +nr = ulong 74 +end +if eq c 102 +nr = ulong 91 +end +if eq c 103 +nr = ulong 8 +end +if eq c 104 +nr = ulong 41 +end +if eq c 105 +nr = ulong 50 +end +if eq c 106 +nr = ulong 288 +xha x 1 10 +ximm 6 0 +ximm 2 0 +end +if eq c 107 +nr = ulong 57 +end +if eq c 127 +nr = ulong 62 +end +if eq c 129 +nr = ulong 39 +end +if eq c 139 +nr = ulong 77 +end +if eq c 145 +nr = ulong 102 +end +if eq c 146 +nr = ulong 107 +end +if eq c 147 +nr = ulong 104 +end +if eq c 148 +nr = ulong 108 +end +if eq c 153 +nr = ulong 81 +end +if eq c 154 +nr = ulong 110 +end +if eq c 155 +nr = ulong 95 +end +if eq c 156 +nr = ulong 75 +end +if eq c 158 +nr = ulong 112 +end +if eq c 159 +nr = ulong 121 +end +if eq c 160 +nr = ulong 109 +end +if eq c 163 +nr = ulong 124 +end +if eq c 164 +nr = ulong 306 +end +if eq c 165 +nr = ulong 48 +end +if eq c 197 +nr = ulong 73 +end +xhcall nr +xhdone dst x 0 +end +fn xhpaths c ulong dst ulong x ulong to void +e = harray x 0 +if or eq c 110 eq c 151 +harg x 2 8 +harg x 3 8 +end +if or or or eq c 112 eq c 143 eq c 144 eq c 157 +harg x 2 8 +end +if eq c 150 +harg x 2 9 +end +xhbegin +xhpath x +ximm 7 18446744073709551516 +xrr 137 6 4 +nr = ulong 257 +if eq c 110 +xha x 2 2 +xha x 3 10 +end +if or eq c 111 eq c 126 +nr = ulong 263 +ximm 2 0 +if eq c 126 +ximm 2 512 +end +end +if eq c 112 +nr = ulong 258 +xha x 2 2 +end +if eq c 138 +nr = ulong 80 +xrr 137 7 6 +end +if or eq c 143 eq c 144 +nr = ulong 268 +if eq c 144 +nr = ulong 269 +end +xha x 2 2 +ximm 10 0 +end +if eq c 150 +nr = ulong 76 +xrr 137 7 6 +xha x 2 6 +end +if eq c 151 +nr = ulong 260 +xha x 2 2 +xha x 3 10 +ximm 8 0 +end +if eq c 157 +nr = ulong 319 +xrr 137 7 6 +xha x 2 6 +end +xhcall nr +xhdone dst x 4096 +end +note Native x86 struct stat is private; output remains Omega's 128-byte asm-generic ABI. +fn xhstatcv to void +xrr 133 0 0 +bad = xbranch 11 +ximm 2 0 +for j ulong 16 +xmem 137 2 12 mul j 8 +end +for j ulong 2 +xmem 139 2 4 mul j 8 +xmem 137 2 12 mul j 8 +end +xhraw 2 4 24 4 +xhput 2 12 16 4 +xhraw 2 4 16 4 +xhput 2 12 20 4 +xmem 139 2 4 28 +xmem 137 2 12 24 +xmem 139 2 4 40 +xmem 137 2 12 32 +xmem 139 2 4 48 +xmem 137 2 12 48 +xhraw 2 4 56 4 +xhput 2 12 56 4 +for j ulong 7 +xmem 139 2 4 add 64 mul j 8 +xmem 137 2 12 add 64 mul j 8 +end +ximm 0 0 +xpatch bad get oc 0 +end +fn xhbuffer c ulong dst ulong x ulong to void +harg x 4 8 +wr = ulong 0 +if or or or or or eq c 113 eq c 116 eq c 117 eq c 118 eq c 131 eq c 161 +wr = ulong 1 +end +if eq c 224 +wr = ulong 1 +end +e = harray x wr +if or or eq c 116 eq c 118 eq c 119 +harg x 2 8 +end +if or eq c 161 eq c 162 +harg x 3 9 +end +xhbegin +xha x 4 7 +xhb 6 e get fr add x 21 +xhs 2 get fr add x 22 +nr = ulong 217 +if or eq c 114 eq c 115 +nr = ulong 42 +if eq c 115 +nr = ulong 49 +end +end +if eq c 116 +xhcmp 2 4 +xtrap 3 3 +nr = ulong 61 +xha x 2 2 +ximm 10 0 +end +if eq c 117 +xhcmp 2 128 +xtrap 3 3 +xrr 137 12 6 +xsp 1 144 +xrr 137 6 4 +xhcall 5 +xhstatcv +xhdone dst x 144 +ret +end +if or eq c 118 eq c 119 +nr = ulong 45 +xha x 2 10 +ximm 8 0 +ximm 9 0 +if eq c 119 +nr = ulong 44 +ximm 0 16384 +xrr 9 10 0 +end +end +if or eq c 131 eq c 224 +note peername shares the private 32-bit socklen; x86-64 getsockname 51, getpeername 52. +xsp 1 16 +xhput 2 4 0 4 +xrr 137 2 4 +if eq c 224 +xhcall 52 +else +xhcall 51 +end +xrr 133 0 0 +bad = xbranch 11 +xhraw 0 4 0 4 +xpatch bad get oc 0 +xhdone dst x 16 +ret +end +if or eq c 161 eq c 162 +nr = ulong 17 +if eq c 162 +nr = ulong 18 +end +xha x 3 10 +end +xhcall nr +xhdone dst x 0 +end +fn xhstats c ulong dst ulong x ulong to void +e = harray x 0 +put fr add x 23 e +put fr add x 24 get fr add x 21 +put fr add x 25 get fr add x 22 +e = harray x 1 +put fr add x 26 e +put fr add x 27 get fr add x 21 +put fr add x 28 get fr add x 22 +put fr add x 20 get fr add x 23 +put fr add x 21 get fr add x 24 +put fr add x 22 get fr add x 25 +xhbegin +xhs 2 get fr add x 22 +xrr 133 2 2 +xtrap 0 3 +xhpath x +xhb 12 e get fr add x 27 +xhs 2 get fr add x 28 +xhcmp 2 128 +xtrap 3 3 +ximm 7 18446744073709551516 +xrr 137 6 4 +xsp 1 144 +xrr 137 2 4 +ximm 10 0 +if eq c 149 +ximm 10 256 +end +xhcall 262 +xhstatcv +xhdone dst x 4240 +end +fn xhtime c ulong dst ulong x ulong to void +if eq c 120 +harg x 0 9 +end +xhbegin +xsp 1 16 +if eq c 120 +xha x 0 0 +xrr 133 0 0 +xtrap 11 3 +ximm 1 1000000000 +ximm 2 0 +xb 72 247 241 +xmem 137 0 4 0 +xmem 137 2 4 8 +xrr 137 7 4 +ximm 6 0 +xhcall 35 +else +ximm 7 1 +if eq c 130 +ximm 7 0 +end +xrr 137 6 4 +xhcall 228 +xrr 133 0 0 +bad = xbranch 11 +xmem 139 2 4 0 +xhcmp 2 9223372036 +xtrap 8 1 +ximm 0 1000000000 +xb 72 15 175 +emitb 194 +xmem 139 2 4 8 +xrr 1 0 2 +xtrap 6 1 +xpatch bad get oc 0 +end +xhdone dst x 16 +end + +fn xrot ty ulong ra ulong b ulong imm ulong rd ulong to void +xload 0 ra +if ne imm 0 +ximm 1 b +else +xload 1 b +end +if eq ty 3 +emitb 102 +end +if eq ty 5 +emitb 72 +end +if eq ty 2 +emitb 210 +else +emitb 211 +end +emitb 200 +xstore 0 rd +canon rd ty +end + +fn xhts off ulong to void +xrr 133 2 2 +forever = xbranch 11 +xrr 137 0 2 +ximm 1 1000000000 +ximm 2 0 +xb 72 247 241 +xmem 137 0 4 off +xmem 137 2 4 add off 8 +xmem 141 2 4 off +jump = xbranch 14 +xpatch forever get oc 0 +ximm 2 0 +xpatch jump get oc 0 +end +fn xhpoll c ulong dst ulong x ulong to void +if eq c 123 +harg x 0 8 +harg x 1 8 +harg x 2 9 +xhbegin +xha x 0 7 +xha x 1 6 +xha x 2 2 +xrr 133 6 6 +xtrap 11 3 +xhcmp 6 65535 +xtrap 8 3 +xsp 1 32 +ximm 0 0 +xmem 137 0 4 0 +xhput 7 4 0 4 +xhput 6 4 4 2 +xhts 16 +xrr 137 7 4 +ximm 6 1 +else +e = harray x 1 +harg x 2 9 +xhbegin +xhb 7 e get fr add x 21 +xhs 6 get fr add x 22 +xhcmp 6 8192 +xtrap 8 3 +xrr 137 0 6 +ximm 1 7 +xrr 33 0 1 +xrr 133 0 0 +xtrap 1 3 +xb 72 193 238 +emitb 3 +xha x 2 2 +xsp 1 32 +xhts 16 +end +ximm 10 0 +ximm 8 8 +xhcall 271 +if eq c 123 +xrr 133 0 0 +bad = xbranch 13 +xhraw 0 4 6 2 +xpatch bad get oc 0 +end +xhdone dst x 32 +end +fn xhargs c ulong dst ulong x ulong to void +put hostargs 0 1 +if or eq c 121 eq c 136 +xhbegin +xmem 139 0 13 0 +if eq c 136 +xmem 141 6 13 16 +xb 72 193 224 +emitb 3 +xrr 1 6 0 +ximm 0 0 +loop = get oc 0 +xmem 139 2 6 0 +xrr 133 2 2 +done = xbranch 0 +xhadd 6 8 +xhadd 0 1 +p = xbranch 14 +xpatch p loop +xpatch done get oc 0 +end +xhdone dst x 0 +ret +end +harg x 4 5 +e = harray x 1 +xhbegin +xha x 4 2 +xmem 139 1 13 0 +xmem 141 6 13 8 +if eq c 137 +xhadd 1 1 +xb 72 193 225 +emitb 3 +xrr 1 6 1 +loop = get oc 0 +xmem 139 0 6 0 +xrr 133 0 0 +xtrap 0 3 +xrr 133 2 2 +done = xbranch 0 +xhsub 2 1 +xhadd 6 8 +p = xbranch 14 +xpatch p loop +xpatch done get oc 0 +else +xrr 57 2 1 +xtrap 2 3 +xb 72 193 226 +emitb 3 +xrr 1 6 2 +end +xmem 139 6 6 0 +xrr 137 12 6 +ximm 2 0 +scan = get oc 0 +xhraw 0 6 0 1 +xrr 133 0 0 +found = xbranch 0 +xhadd 6 1 +xhadd 2 1 +xhcmp 2 1048576 +xtrap 2 3 +p = xbranch 14 +xpatch p scan +xpatch found get oc 0 +xhs 1 get fr add x 22 +xrr 57 2 1 +small = xbranch 8 +xhb 7 e get fr add x 21 +xrr 137 6 12 +xrr 137 1 2 +emitb 243 +emitb 164 +xrr 137 0 2 +tail = xbranch 14 +xpatch small get oc 0 +ximm 0 18446744073709551511 +xpatch tail get oc 0 +xhdone dst x 0 +end +fn xhsimple c ulong dst ulong x ulong to void +e = harray x 1 +if or eq c 128 eq c 135 +harg x 2 8 +end +xhbegin +xhb 7 e get fr add x 21 +xhs 6 get fr add x 22 +nr = ulong 79 +if eq c 128 +xhcmp 6 8 +xtrap 3 3 +xha x 2 6 +nr = ulong 293 +end +if eq c 135 +xha x 2 2 +nr = ulong 318 +end +xhcall nr +xhdone dst x 0 +end +fn xhreadln dst ulong x ulong to void +e = harray x 0 +put fr add x 23 e +put fr add x 24 get fr add x 21 +put fr add x 25 get fr add x 22 +e = harray x 1 +put fr add x 26 e +put fr add x 27 get fr add x 21 +put fr add x 28 get fr add x 22 +put fr add x 20 get fr add x 23 +put fr add x 21 get fr add x 24 +put fr add x 22 get fr add x 25 +xhbegin +xhs 2 get fr add x 22 +xrr 133 2 2 +xtrap 0 3 +xhpath x +xhb 2 e get fr add x 27 +xhs 10 get fr add x 28 +ximm 7 18446744073709551516 +xrr 137 6 4 +xhcall 267 +xhdone dst x 4096 +end +fn xhsock c ulong dst ulong x ulong to void +ok = new ulong 6 0 +if eq c 134 +harg x 2 8 +harg x 3 8 +harg x 4 8 +e = harray x 0 +xhbegin +xha x 2 7 +xha x 3 6 +xha x 4 2 +xhb 10 e get fr add x 21 +xhs 8 get fr add x 22 +xhcmp 6 1 +tcp = xbranch 1 +for j ulong 5 +v = add j 5 +if eq j 0 +v = ulong 2 +end +if eq j 1 +v = ulong 15 +end +xhcmp 2 v +put ok j xbranch 0 +end +badso = xbranch 14 +xpatch tcp get oc 0 +xhcmp 6 6 +badtcp = xbranch 1 +xhcmp 2 1 +put ok 5 xbranch 0 +xpatch badso get oc 0 +xpatch badtcp get oc 0 +ximm 0 sub ulong 0 92 +done = xbranch 14 +for j ulong 6 +xpatch get ok j get oc 0 +end +xhcmp 8 4 +sizeok = xbranch 0 +ximm 0 sub ulong 0 22 +badsize = xbranch 14 +xpatch sizeok get oc 0 +xhcall 54 +xpatch done get oc 0 +xpatch badsize get oc 0 +xhdone dst x 0 +ret +end +harg x 4 8 +if eq c 220 +e = harray x 1 +xhbegin +xha x 4 7 +xhb 10 e get fr add x 21 +xhs 8 get fr add x 22 +xhcmp 8 12 +xtrap 3 3 +ximm 6 1 +ximm 2 17 +xsp 1 16 +ximm 8 12 +xhput 8 4 0 4 +xrr 137 8 4 +xhcall 55 +xhdone dst x 16 +ret +end +e = harray x 0 +harg x 2 8 +xhbegin +xha x 4 7 +xha x 2 2 +ximm 0 16384 +xrr 9 2 0 +xhb 6 e get fr add x 21 +xhs 8 get fr add x 22 +xsp 1 80 +ximm 0 0 +for j ulong 10 +xmem 137 0 4 mul j 8 +end +xmem 137 6 4 64 +xmem 137 8 4 72 +xmem 141 6 4 64 +xmem 137 6 4 16 +ximm 6 1 +xmem 137 6 4 24 +xrr 137 6 4 +xhcall 46 +xhdone dst x 80 +end +fn xhpack c ulong dst ulong x ulong to void +e = harray x 0 +if eq c 125 +harg x 2 8 +end +xhbegin +xhb 6 e get fr add x 21 +xhs 2 get fr add x 22 +xhcmp 2 4096 +xtrap 8 3 +xhcmp 2 2 +xtrap 3 3 +xhraw 8 6 0 2 +xhadd 6 2 +xhsub 2 2 +xrr 133 8 8 +xtrap 0 3 +xhcmp 8 64 +xtrap 8 3 +if ne c 124 +xhcmp 8 2 +xtrap 1 3 +end +xsp 1 8192 +xrr 137 10 4 +xmem 141 12 4 4096 +ximm 9 0 +outer = get oc 0 +xrr 57 9 8 +done = xbranch 2 +xhcmp 2 2 +xtrap 3 3 +xhraw 1 6 0 2 +xhadd 6 2 +xhsub 2 2 +xrr 57 1 2 +xtrap 8 3 +if eq c 124 +xrr 133 9 9 +notfirst = xbranch 1 +xrr 133 1 1 +xtrap 0 3 +xpatch notfirst get oc 0 +else +xrr 133 1 1 +xtrap 0 3 +end +xmem 137 10 12 0 +xhadd 12 8 +xrr 41 2 1 +inner = get oc 0 +xrr 133 1 1 +endstr = xbranch 0 +xhraw 0 6 0 1 +xrr 133 0 0 +xtrap 0 3 +xhput 0 10 0 1 +xhadd 6 1 +xhadd 10 1 +xhsub 1 1 +p = xbranch 14 +xpatch p inner +xpatch endstr get oc 0 +ximm 0 0 +xhput 0 10 0 1 +xhadd 10 1 +xhadd 9 1 +p = xbranch 14 +xpatch p outer +xpatch done get oc 0 +xrr 133 2 2 +xtrap 1 3 +ximm 0 0 +xmem 137 0 12 0 +if eq c 124 +note As on AArch64: close_range(3, ~0U, CLOSE_RANGE_UNSHARE) first; a nonzero result skips execve +note and returns that kernel error. RDI/RSI/RDX are reloaded after the call; R12 holds the argv end. +ximm 7 3 +ximm 6 4294967295 +ximm 2 2 +xhcall 436 +xrr 133 0 0 +p = xbranch 1 +xmem 139 7 4 4096 +xmem 141 6 4 4096 +xrr 137 2 12 +xhcall 59 +xpatch p get oc 0 +else +xmem 139 6 4 4096 +xmem 139 10 4 4104 +ximm 7 18446744073709551516 +ximm 2 18446744073709551516 +ximm 8 0 +if eq c 125 +xha x 2 8 +xhcall 316 +else +if eq c 141 +xhcall 265 +else +xrr 137 7 6 +ximm 6 18446744073709551516 +xrr 137 2 10 +xhcall 266 +end +end +end +xhdone dst x 8192 +end +note Owned mapping handles keep the existing 128-slot generation/access table and ABI. +fn xhmcheck to void +xrr 137 12 10 +ximm 0 255 +xrr 33 12 0 +xhcmp 12 1 +xtrap 3 3 +xhcmp 12 128 +xtrap 8 3 +xhsub 12 1 +xb 73 193 228 +emitb 5 +xaddr 0 get maptab 0 +xrr 1 12 0 +xmem 139 9 12 16 +xrr 133 9 9 +xtrap 0 3 +xb 73 193 234 +emitb 8 +xrr 57 10 9 +xtrap 1 3 +xmem 139 8 12 0 +xrr 133 8 8 +xtrap 0 3 +xmem 139 9 12 8 +end +fn xhmnew c ulong dst ulong x ulong to void +acc = ulong 0 +mode = ulong 1048610 +if eq c 167 +harg x 0 8 +harg x 1 5 +harg x 2 5 +harg x 3 8 +harg x 4 8 +if or ne get fr add x 14 3 ne get fr add x 16 3 +fail 9 +end +acc = get fr add x 15 +mode = get fr add x 17 +if and ne acc 1 ne acc 3 +fail 9 +end +if and and and ne mode 1 ne mode 2 ne mode 33 ne mode 34 +fail 9 +end +else +harg x 1 5 +harg x 2 5 +end +xhbegin +xha x 2 6 +xrr 133 6 6 +xtrap 0 3 +xhcmp 6 68719476736 +xtrap 8 3 +if eq c 167 +xha x 0 8 +xha x 1 9 +if ge mode 32 +xhcmp 8 18446744073709551615 +xtrap 1 3 +xrr 133 9 9 +xtrap 1 3 +end +else +xha x 1 7 +xhcmp 7 65536 +xtrap 3 3 +ximm 0 1099511627776 +xrr 41 0 6 +xrr 57 7 0 +xtrap 8 3 +ximm 0 4095 +xrr 137 1 7 +xrr 33 1 0 +xrr 133 1 1 +xtrap 1 3 +xrr 137 1 6 +xrr 33 1 0 +xrr 133 1 1 +xtrap 1 3 +ximm 8 18446744073709551615 +ximm 9 0 +end +xaddr 12 get maptab 0 +ximm 2 1 +head = get oc 0 +xmem 139 0 12 0 +xrr 133 0 0 +used = xbranch 1 +xmem 139 10 12 16 +xhcmp 10 36028797018963967 +vacant = xbranch 3 +xpatch used get oc 0 +xhadd 12 32 +xhadd 2 1 +xhcmp 2 128 +again = xbranch 9 +xpatch again head +ximm 0 sub ulong 0 24 +full = xbranch 14 +xpatch vacant get oc 0 +xsp 1 32 +xmem 137 2 4 0 +xmem 137 6 4 8 +xmem 137 10 4 16 +if eq c 167 +ximm 7 0 +else +xha x 1 7 +end +ximm 2 acc +ximm 10 mode +xhcall 9 +xrr 133 0 0 +failed = xbranch 11 +wrong = ulong 0 +if eq c 176 +xha x 1 2 +xrr 57 0 2 +exact = xbranch 0 +xrr 137 7 0 +xmem 139 6 4 8 +xhcall 11 +xrr 133 0 0 +xtrap 1 3 +ximm 0 sub ulong 0 95 +wrong = xbranch 14 +xpatch exact get oc 0 +end +xmem 137 0 12 0 +xmem 139 2 4 8 +xmem 137 2 12 8 +xmem 139 2 4 16 +xhadd 2 1 +xmem 137 2 12 16 +ximm 0 acc +xmem 137 0 12 24 +xrr 137 0 2 +xb 72 193 224 +emitb 8 +xmem 139 2 4 0 +xrr 9 0 2 +xpatch failed get oc 0 +if ne wrong 0 +xpatch wrong get oc 0 +end +xsp 0 32 +xpatch full get oc 0 +xhdone dst x 0 +end +fn xhmbind dst ulong x ulong to void +harg x 0 9 +harg x 1 8 +harg x 2 5 +harg x 3 8 +if ne get fr add x 14 3 +fail 9 +end +acc = get fr add x 15 +if and ne acc 1 ne acc 3 +fail 9 +end +xhbegin +xha x 0 10 +xhmcheck +xmem 139 0 12 24 +xrr 133 0 0 +xtrap 1 3 +xsp 1 32 +xmem 137 8 4 0 +xmem 137 9 4 8 +xrr 137 7 8 +xrr 137 6 9 +xha x 1 8 +xha x 2 9 +ximm 2 acc +ximm 10 17 +xhcall 9 +xrr 133 0 0 +failed = xbranch 11 +xmem 139 2 4 0 +xrr 57 0 2 +xtrap 1 3 +ximm 0 acc +xmem 137 0 12 24 +ximm 0 0 +done = xbranch 14 +xpatch failed get oc 0 +xmem 137 0 4 16 +xmem 139 7 4 0 +xmem 139 6 4 8 +xhcall 11 +xrr 133 0 0 +xtrap 1 3 +ximm 0 0 +xmem 137 0 12 0 +xmem 137 0 12 8 +xmem 137 0 12 24 +xmem 139 0 4 16 +xpatch done get oc 0 +xhdone dst x 32 +end +fn xhmcopy c ulong dst ulong x ulong to void +harg x 4 9 +harg x 3 5 +wr = ulong 0 +if eq c 169 +wr = ulong 1 +end +e = harray x wr +xhbegin +xha x 4 10 +xhmcheck +xmem 139 0 12 24 +xrr 133 0 0 +xtrap 0 3 +xha x 3 2 +xrr 57 2 9 +xtrap 8 3 +xrr 41 9 2 +xhs 1 get fr add x 22 +xrr 57 1 9 +xtrap 8 3 +xrr 1 8 2 +xhb 7 e get fr add x 21 +xrr 137 6 8 +if eq c 170 +xmem 139 0 12 24 +xhcmp 0 3 +xtrap 1 3 +xrr 137 6 7 +xrr 137 7 8 +end +xrr 137 2 1 +emitb 243 +emitb 164 +xrr 137 0 2 +xhdone dst x 0 +end +fn xhmmio c ulong dst ulong x ulong to void +harg x 0 9 +if eq c 173 +xhbegin +xha x 0 10 +xhmcheck +xrr 137 0 8 +xhdone dst x 0 +put rt 0 5 +ret +end +harg x 1 5 +harg x 2 8 +if ne get fr add x 12 3 +fail 9 +end +w = get fr add x 13 +if and ne w 4 ne w 8 +fail 9 +end +if eq c 175 +harg x 3 5 +end +xhbegin +xha x 0 10 +xhmcheck +xha x 1 2 +xmem 139 0 12 24 +xrr 133 0 0 +xtrap 0 3 +xrr 57 2 9 +xtrap 8 3 +xrr 41 9 2 +xhcmp 9 w +xtrap 3 3 +xrr 137 0 2 +ximm 1 sub w 1 +xrr 33 0 1 +xrr 133 0 0 +xtrap 1 3 +xrr 1 8 2 +if eq c 175 +xmem 139 0 12 24 +xhcmp 0 3 +xtrap 1 3 +xha x 3 2 +if eq w 4 +xhcmp 2 4294967295 +xtrap 8 3 +end +xb 15 174 240 +if eq w 4 +xhput 2 8 0 4 +else +xmem 137 2 8 0 +end +xb 15 174 240 +ximm 0 0 +xhdone dst x 0 +else +xb 15 174 240 +if eq w 4 +xhraw 0 8 0 4 +else +xmem 139 0 8 0 +end +xb 15 174 240 +xhdone dst x 0 +put rt 0 5 +end +end +note One compile-time ioctl allowlist is shared by both native Linux backends. +fn xhreq c ulong x ulong to ulong +harg x 4 8 +harg x 2 4 +if ne get fr add x 12 3 +fail 9 +end +q = get fr add x 13 +n = ulong 4 +if eq c 166 +if ne q 21531 +if ne and q 3221290752 3221243392 +fail 9 +end +n = and shr q 16 16383 +if eq n 0 +fail 9 +end +end +end +if eq c 172 +n = ulong 0 +if eq q 805306369 +n = ulong 16 +end +if eq q 75 +n = ulong 8 +end +if eq q 37 +n = ulong 40 +end +if or eq q 38 eq q 26 +n = ulong 20 +end +if eq q 25 +n = ulong 32 +end +if eq q 27 +n = ulong 56 +end +if eq q 28 +n = ulong 28 +end +if eq q 33 +n = ulong 9264 +end +if or eq q 34 eq q 73 +n = ulong 24 +end +if eq n 0 +fail 9 +end +end +if eq c 171 +if and ne q 3223340586 ne q 3223340587 +fail 9 +end +n = ulong 32 +end +ret n +end +fn xhdev c ulong dst ulong x ulong to void +n = xhreq c x +put fr add x 23 n +e = harray x 1 +if ne c 171 +xhbegin +xhs 2 get fr add x 22 +xhcmp 2 get fr add x 23 +xtrap 1 3 +xha x 4 7 +xha x 2 6 +xhb 2 e get fr add x 21 +xhcall 16 +xhdone dst x 0 +ret +end +put fr add x 23 e +put fr add x 24 get fr add x 21 +put fr add x 25 get fr add x 22 +f = harray x 1 +if eq e f +fail 19 +end +xhbegin +xhs 2 get fr add x 25 +xhcmp 2 32 +xtrap 1 3 +xhs 9 get fr add x 22 +xhcmp 9 16383 +xtrap 8 3 +xhb 12 e get fr add x 24 +xhb 8 f get fr add x 21 +xrr 133 9 9 +empty = xbranch 0 +xrr 137 2 8 +xrr 1 2 9 +xrr 57 2 12 +before = xbranch 9 +xmem 141 2 12 32 +xrr 57 8 2 +xtrap 3 3 +xpatch before get oc 0 +xpatch empty get oc 0 +xmem 139 2 12 16 +xrr 133 2 2 +xtrap 1 3 +xrr 133 9 9 +nonzero = xbranch 1 +ximm 8 0 +xpatch nonzero get oc 0 +xsp 1 32 +for j ulong 4 +xmem 139 0 12 mul j 8 +xmem 137 0 4 mul j 8 +end +xmem 137 8 4 16 +xhput 9 4 24 4 +xha x 4 7 +xha x 2 6 +xrr 137 2 4 +xhcall 16 +for j ulong 4 +if ne j 2 +xmem 139 2 4 mul j 8 +xmem 137 2 12 mul j 8 +end +end +xhdone dst x 32 +end +fn xhost c ulong dst ulong to void +if ne get xtarget 0 1 +fail 25 +end +if eq get progmode 0 0 +fail 9 +end +note execpure (198) has no x86 strict-profile lowering; refuse it rather than run an unconfined exec. +if eq c 198 +fail 25 +end +x = mul get depth 0 32 +put fr add x 7 get nslot 0 +if or eq c 220 eq c 222 +xhsock c dst x +ret +end +if or eq c 123 eq c 221 +xhpoll c dst x +ret +end +if and ge c 167 le c 177 +if or eq c 171 eq c 172 +xhdev c dst x +ret +end +mtinit +if or eq c 167 eq c 176 +xhmnew c dst x +ret +end +if eq c 177 +xhmbind dst x +ret +end +if eq c 168 +harg x 0 9 +xhbegin +xha x 0 10 +xhmcheck +xrr 137 7 8 +xrr 137 6 9 +xhcall 11 +xrr 133 0 0 +failed = xbranch 1 +xmem 137 0 12 0 +xmem 137 0 12 8 +xmem 137 0 12 24 +xpatch failed get oc 0 +xhdone dst x 0 +ret +end +if or eq c 169 eq c 170 +xhmcopy c dst x +ret +end +xhmmio c dst x +ret +end +if eq c 166 +xhdev c dst x +ret +end +if or eq c 132 eq c 128 +xhsimple c dst x +ret +end +if eq c 135 +xhsimple c dst x +ret +end +if eq c 133 +xhreadln dst x +ret +end +if eq c 134 +xhsock c dst x +ret +end +if or or eq c 109 eq c 130 eq c 120 +xhtime c dst x +ret +end +if or or or and ge c 113 le c 119 eq c 131 or eq c 161 eq c 162 eq c 224 +xhbuffer c dst x +ret +end +if or or or eq c 121 eq c 122 eq c 136 eq c 137 +xhargs c dst x +ret +end +if or or or eq c 124 eq c 125 eq c 141 eq c 142 +xhpack c dst x +ret +end +if or eq c 140 eq c 149 +xhstats c dst x +ret +end +if or or or or eq c 110 eq c 111 eq c 112 eq c 126 eq c 138 +xhpaths c dst x +ret +end +if or or or or eq c 143 eq c 144 eq c 150 eq c 151 eq c 157 +xhpaths c dst x +ret +end +xhscalar c dst x +end + +note ======== Native x86-64 semantic backend ======== +note Intel SDM volume 2 instruction entries MOV, LEA, CALL, RET, Jcc, SETcc, MOVSX, +note MOVZX, ADD, SUB, IMUL, DIV, IDIV, SHL, SHR, SAR, SYSCALL; volume 2 chapter 2 +note supplies REX, ModRM and SIB. No A64 word decoding occurs in this backend. +fn xb a ulong b ulong c ulong to void +emitb uchar a +emitb uchar b +emitb uchar c +end + +fn xword v ulong to void +emitb uchar and v 255 +emitb uchar and shr v 8 255 +emitb uchar and shr v 16 255 +emitb uchar and shr v 24 255 +end + +fn ximm r ulong v ulong to void +emitb uchar add 72 shr r 3 +emitb uchar add 184 and r 7 +xword v +xword shr v 32 +end + +note Hardware registers are private emitter operands. Language values are RBP slots. +fn xrr op ulong d ulong s ulong to void +emitb uchar add add 72 shl shr s 3 2 shr d 3 +emitb uchar op +emitb uchar add add 192 shl and s 7 3 and d 7 +end + +fn xmem op ulong r ulong b ulong off ulong to void +emitb uchar add add 72 shl shr r 3 2 shr b 3 +emitb uchar op +emitb uchar add add 128 shl and r 7 3 and b 7 +if eq and b 7 4 +emitb 36 +end +xword off +end + +fn xload r ulong s ulong to void +xmem 139 r 5 sub ulong 0 mul add s 1 8 +end + +fn xstore r ulong s ulong to void +xmem 137 r 5 sub ulong 0 mul add s 1 8 +end + +fn xcc cc ulong to ulong +if eq cc 0 +ret 4 +end +if eq cc 1 +ret 5 +end +if eq cc 2 +ret 3 +end +if eq cc 3 +ret 2 +end +if eq cc 6 +ret 0 +end +if eq cc 7 +ret 1 +end +if eq cc 8 +ret 7 +end +if eq cc 9 +ret 6 +end +if eq cc 10 +ret 13 +end +if eq cc 11 +ret 12 +end +if eq cc 12 +ret 15 +end +if eq cc 13 +ret 14 +end +fail 25 +ret 0 +end + +note Every branch reserves six bytes; all targets are byte offsets, not word offsets. +fn xbranch cc ulong to ulong +p = get oc 0 +if eq cc 14 +emitb 233 +xword 0 +emitb 144 +else +emitb 15 +emitb uchar add 128 xcc cc +xword 0 +end +ret p +end + +fn xpatch p ulong dest ulong to void +if eq get out p 233 +wrword add p 1 sub dest add p 5 +else +wrword add p 2 sub dest add p 6 +end +end + +fn xtrap cc ulong code ulong to void +n = get nt 0 +if ge n 8192 +fail 14 +end +put tcode n code +put tsite n xbranch cc +put nt 0 add n 1 +if eq get om2m 0 1 +siterec +end +end + +fn xcmp a ulong b ulong imm ulong to void +xload 0 a +if ne imm 0 +ximm 1 b +else +xload 1 b +end +xrr 57 0 1 +end + +note Canonicalization uses shifts, preserving the checked language's signed widths. +fn xcanrax t ulong to void +if eq t 10 +emitb 137 +emitb 192 +ret +end +w = twid t +if eq w 64 +ret +end +xb 72 193 224 +emitb uchar sub 64 w +xb 72 193 232 +if ge t 6 +put out sub get oc 0 1 248 +end +emitb uchar sub 64 w +end + +fn xext r ulong t ulong code ulong to void +xload 0 r +xrr 137 2 0 +xcanrax t +xrr 57 0 2 +xtrap 1 code +end + +fn xarith op ulong ty ulong a ulong b ulong imm ulong d ulong to void +if or eq ty 10 eq ty 11 +if or lt op 33 gt op 35 +fail 7 +end +if ne imm 0 +matconst 16 b +b = ulong 16 +end +xfbin op ty a b d +ret +end +xload 0 a +if ne imm 0 +ximm 1 b +else +xload 1 b +end +if eq op 33 +xrr 1 0 1 +if eq ty 13 +xtrap 3 1 +end +end +if eq op 34 +xrr 41 0 1 +if eq ty 13 +xtrap 3 1 +end +end +if eq op 35 +if eq ty 13 +xb 72 247 225 +xrr 133 2 2 +xtrap 1 1 +else +xb 72 15 175 +emitb 193 +end +end +if eq op 38 +xrr 33 0 1 +end +if eq op 39 +xrr 9 0 1 +end +if eq op 40 +xrr 49 0 1 +end +if and eq ty 9 le op 35 +xtrap 6 1 +end +xstore 0 d +if le op 35 +bo_fix d ty +end +end + +fn xdiv op ulong ty ulong a ulong b ulong d ulong fl ulong to void +if or eq ty 10 eq ty 11 +if ne op 36 +fail 7 +end +xfbin op ty a b d +ret +end +xload 0 a +xload 1 b +note Match bo_div's constant-divisor proofs and source trap sites. +if eq and fl 1 0 +xrr 133 1 1 +xtrap 0 2 +end +done = ulong 0 +if and ge ty 6 le ty 9 +if and eq ty 9 eq and fl 2 0 +note Only 64-bit IDIV can fault on MIN/-1; remainder must bypass with zero. +ximm 2 18446744073709551615 +xrr 57 1 2 +other = xbranch 1 +if eq op 37 +ximm 0 0 +done = xbranch 14 +else +xb 72 247 216 +xtrap 6 1 +done = xbranch 14 +end +xpatch other get oc 0 +end +xb 72 153 144 +xb 72 247 249 +else +xrr 49 2 2 +xb 72 247 241 +end +if eq op 37 +xrr 137 0 2 +end +if ne done 0 +xpatch done get oc 0 +end +xstore 0 d +note Narrow signed quotients can overflow; remainders and unsigned quotients cannot. +if and eq op 36 and ge ty 6 lt ty 9 +bo_fix d ty +end +end + +fn xshift op ulong ty ulong a ulong b ulong imm ulong d ulong to void +xload 0 a +if ne imm 0 +ximm 1 b +else +xload 1 b +end +note imm is set only for a statically valid shift amount, as in bo_shl/bo_shr. +if eq imm 0 +ximm 2 twid ty +xrr 57 1 2 +xtrap 2 7 +end +xrr 137 2 0 +if eq op 41 +xb 72 211 224 +if eq ty 9 +xrr 137 8 0 +xb 73 211 248 +xrr 57 8 2 +xtrap 1 1 +end +else +if ge ty 6 +xb 72 211 248 +else +xb 72 211 232 +end +end +xstore 0 d +if eq op 41 +bo_fix d ty +end +end + +fn xunary op ulong dst ulong to void +ty = get rt 0 +if eq ty 13 +fail 7 +end +if or eq ty 10 eq ty 11 +if eq op 50 +fail 7 +end +fa = matreg get rk 0 get rv 0 ty +fd = destreg dst +note xfneg / xfsqrt / xfabs: the x86 forms of fp_neg / fp_un1 on x registers ra into rd (sign mask, SQRTS). +xload 0 fa +ximm 1 xfmask ty 0 +xrr 49 0 1 +xstore 0 fd +put rk 0 1 +put rv 0 fd +put rt 0 ty +ret +end +a = matreg get rk 0 get rv 0 ty +d = destreg dst +xload 0 a +if eq op 50 +if eq ty 1 +ximm 1 1 +xrr 49 0 1 +else +xb 72 247 208 +end +else +if eq ty 1 +fail 7 +end +xb 72 247 216 +if eq ty 9 +xtrap 6 1 +end +end +xstore 0 d +if eq op 50 +canon d ty +else +bo_fix d ty +end +put rk 0 1 +put rv 0 d +put rt 0 ty +end + +fn xconv tt ulong to void +ft = get rt 0 +if or or or eq ft 10 eq ft 11 eq tt 10 eq tt 11 +if or eq ft 13 eq tt 13 +fail 7 +end +if or eq ft 1 eq tt 1 +fail 9 +end +fa = matreg get rk 0 get rv 0 ft +fd = fp_conv ft tt fa +put rk 0 1 +put rv 0 fd +put rt 0 tt +ret +end +if or eq ft 1 eq tt 1 +fail 9 +end +r = matreg get rk 0 get rv 0 ft +wf = twid ft +wt = twid tt +s = ulong 99 +if not and ge ft 6 le ft 9 +if and ge tt 6 le tt 9 +if ge wf wt +s = sub wt 1 +end +else +if gt wf wt +s = wt +end +end +else +if not and ge tt 6 le tt 9 +s = wt +if gt s 63 +s = ulong 63 +end +else +if gt wf wt +xext r tt 5 +end +end +end +if ne s 99 +xload 0 r +xb 72 193 232 +emitb uchar s +xrr 133 0 0 +xtrap 1 5 +end +put rk 0 1 +put rv 0 r +put rt 0 tt +end + +note Reserve checked stack BEFORE stores, CALL return addresses, or PUSH. +fn xcheck bytes ulong to void +xmem 141 0 4 sub ulong 0 bytes +xrr 57 0 15 +xtrap 3 6 +end + +fn xsp down ulong bytes ulong to void +if eq bytes 0 +ret +end +if ne down 0 +xcheck bytes +xb 72 129 236 +else +xb 72 129 196 +end +xword bytes +end + +fn xmovsp r ulong to void +xrr 137 0 4 +xstore 0 r +end + +fn xpro np ulong to void +xrr 137 11 5 +emitb 85 +xrr 137 5 4 +xb 72 129 236 +xword 256 +j = ulong 0 +while lt j np +xmem 139 0 11 sub ulong 0 mul add j 1 8 +xstore 0 j +j = add j 1 +end +end + +fn xsave to void +put svn 0 add get npar 0 get nslot 0 +put sva 0 256 +xsp 1 256 +j = ulong 0 +while lt j 18 +xload 0 j +xmem 137 0 4 mul j 8 +j = add j 1 +end +note Reserve the callee's return address, frame pointer and slot area before CALL. +xcheck 272 +end + +fn xarg t ulong k ulong v ulong to void +if eq k 6 +mataddr t v +ret +end +if or eq k 3 eq k 7 +matconst t v +ret +end +xmem 139 0 4 mul v 8 +xstore 0 t +end + +fn xrestore d ulong slot ulong res ulong to ulong +put nslot 0 slot +rd = ulong 255 +if ne res 0 +rd = destreg d +xstore 0 rd +end +j = ulong 0 +while lt j 18 +if ne j rd +xmem 139 0 4 mul j 8 +xstore 0 j +end +j = add j 1 +end +xsp 0 256 +ret rd +end + +note Typed addresses carry origin through fixup records. Numeric constants never relocate. +fn mataddr r ulong v ulong to void +if eq get xtarget 0 0 +matconst r v +ret +end +xaddr 0 v +xstore 0 r +end + +fn xaddr r ulong v ulong to void +n = get xnaddr 0 +if ge n 65536 +fail 14 +end +emitb uchar add 72 shl shr r 3 2 +emitb 141 +emitb uchar add 5 shl and r 7 3 +put xasite n get oc 0 +put xavalue n v +put xnaddr 0 add n 1 +xword 0 +end + +fn xelem e ulong k ulong v ulong t ulong to void +if or or eq t 1 eq t 10 eq t 11 +fail 7 +end +i = sub e 1 +ln = get nm_len i +x = v +if ne unsz i 0 +x = matreg k v t +xcmp x ulong get nm_lr i 0 +xtrap 2 3 +else +if eq k 3 +if le ln v +fail 21 +end +if and ne get om2 0 0 le v 4095 +x = ulong 255 +put ea_k 0 v +else +x = alloc +matconst x v +end +else +xcmp v ln 1 +xtrap 2 3 +end +end +put ea_i 0 x +if ge get nm_kind i 4 +b = alloc +mataddr b get nm_addr i +put ea_b 0 b +else +put ea_b 0 ulong get nm_reg i +end +end + +note Indexed load/store uses RDX=base+index*element-size; pointers never enter source scalars. +fn xmemval store ulong base ulong idx ulong ty ulong val ulong to void +xload 2 base +if eq idx 255 +ximm 1 get ea_k 0 +else +xload 1 idx +end +xb 72 193 225 +emitb uchar tlog ty +xrr 1 2 1 +xmemraw store ty val +end + +note RDX is a checked aggregate address; layout byte offsets do not scale by the field width. +fn xlayout store ulong base ulong idx ulong ty ulong val ulong to void +xload 2 base +xload 1 idx +xrr 1 2 1 +xmemraw store ty val +end + +fn xmemraw store ulong ty ulong val ulong to void +if ne store 0 +xload 0 val +if eq twid ty 16 +emitb 102 +end +if eq twid ty 64 +emitb 72 +end +if le twid ty 8 +emitb 136 +else +emitb 137 +end +emitb 2 +else +if eq twid ty 64 +xb 72 139 2 +else +if eq twid ty 32 +if and ge ty 6 le ty 9 +xb 72 99 2 +else +emitb 139 +emitb 2 +end +else +emitb 72 +emitb 15 +op = ulong 182 +if eq twid ty 16 +op = ulong 183 +end +if and ge ty 6 le ty 9 +op = add op 8 +end +emitb uchar op +emitb 2 +end +end +xstore 0 val +end +end + +fn xio c ulong fk ulong fv ulong e ulong ro ulong rn ulong to void +if ne get xtarget 0 1 +fail 25 +end +save +i = sub e 1 +if ge get nm_kind i 4 +xaddr 6 get nm_addr i +else +xload 6 ulong get nm_reg i +end +xmem 139 0 4 mul ro 8 +xrr 1 6 0 +if eq fk 3 +ximm 7 fv +else +xmem 139 7 4 mul fv 8 +end +xmem 139 2 4 mul rn 8 +ximm 0 sub c 53 +emitb 15 +emitb 5 +end + +fn xarray w ulong to void +if ne get nb 0 0 +fail 9 +end +t = typeword +elemtype t +n = lenval 16 +arrlen n +by = shl shr add shl n tlog t 15 4 4 +if gt add get stkbytes 0 by 4194304 +fail 23 +end +put stkbytes 0 add get stkbytes 0 by +r = alloc +put held 0 get nslot 0 +rdval 0 t 255 0 +if ne get rt 0 t +fail 7 +end +v = matreg get rk 0 get rv 0 t +xsp 1 by +xmovsp r +i = alloc +matconst i 0 +lp = get oc 0 +xmemval 1 r i t v +xarith 33 5 i 1 1 i +xcmp i n 1 +blo lp +addname w r t n 1 0 +end + +note xfornum / xforval: the x86 sf_num / sf_val. bn and n come from sf_num / sf_val, which parse the bound +note themselves (sf_val: 1000000 when no bound is written); bn = 0 leaves a number count unguarded, as on Arm. +fn xfornum w ulong t ulong k ulong sn ulong sh ulong bn ulong to void +eol +i = alloc +put held 0 get nslot 0 +addname w i t 0 0 0 +matconst i 0 +c = ulong 0 +if ne bn 0 +c = alloc +put held 0 get nslot 0 +matconst c 0 +end +hd = get oc 0 +cp_head get cur 0 get line 0 +xcmp i k 1 +br = sf_br t +if ne bn 0 +lpcnt c bn +end +pushb br 4 hd i t +pushnh sn sh +cp_skip +end + +fn xforval w ulong t ulong kr ulong sn ulong sh ulong n ulong to void +eol +i = alloc +put held 0 get nslot 0 +addname w i t 0 0 0 +matconst i 0 +c = alloc +put held 0 get nslot 0 +matconst c 0 +hd = get oc 0 +cp_head get cur 0 get line 0 +xcmp i kr 0 +br = sf_br t +lpcnt c n +pushb br 4 hd i t +pushnh sn sh +cp_skip +end + +fn xleave to void +if eq get xtarget 0 2 +note UEFI: every exit jumps to the shared firmware return emitted by xefx 1; RAX is the status. +n = get xnexit 0 +if ge n 65536 +fail 14 +end +put xexsite n xbranch 14 +put xnexit 0 add n 1 +ret +end +xrr 137 7 0 +ximm 0 60 +emitb 15 +emitb 5 +end + +fn xfinish to void +eol +if eq get dead 0 0 +if ne get curret 0 12 +fail 18 +end +cp_post 0 0 12 +epi +end +j = ulong 0 +n = get nt 0 +while lt j n +xpatch get tsite j get oc 0 +if eq get progmode 0 0 +note Bare units reserve physical R12/R14: recovery stack and immutable runtime table. +note Host helpers clobber these registers and must remain forbidden in bare units. +emitb 190 +xword get tcode j +xb 65 255 102 +emitb 16 +else +if eq get xtarget 0 2 +ximm 0 or 9223372036854775808 add 100 get tcode j +else +ximm 0 add 100 get tcode j +end +xleave +end +j = add j 1 +end +put curret 0 0 +put nn 0 get nglob 0 +put curfn 0 0 +put nbrk 0 0 +put ncont 0 0 +end + +fn xlead to void +note Only the exact bytes "target " at offset zero select x86. Default parsing is untouched. +if lt get inlen 0 8 +ret +end +if or ne get inp 0 116 ne get inp 1 97 +ret +end +if or ne get inp 2 114 ne get inp 3 103 +ret +end +if or ne get inp 4 101 ne get inp 5 116 +ret +end +if ne get inp 6 32 +ret +end +put cur 0 0 +put line 0 1 +tok +tok +if and eq get tw 0 8679965255892613240 eq get tl 0 8 +put xtarget 0 1 +else +if and eq get tw 0 115888505632888 eq get tl 0 6 +put xtarget 0 2 +else +fail 25 +end +end +eol +p = ulong 0 +while lt p get cur 0 +if ne get inp p 10 +put inp p 32 +end +p = add p 1 +end +put cur 0 0 +put line 0 1 +end + + +fn xeof to void +f = findfn 1852399981 4 0 +if eq f 0 +fail 16 +end +if ne get fn_np sub f 1 0 +fail 9 +end +entry = get oc 0 +efi = eq get xtarget 0 2 +if efi +xefx 0 0 +else +xrr 137 13 4 +ximm 15 268435456 +ximm 4 276824064 +ximm 5 0 +end +emitb 232 +p = get oc 0 +xword sub get fn_addr sub f 1 add p 4 +if eq get fn_ret sub f 1 12 +ximm 0 0 +end +xleave +if efi +xefx 1 0 +xefx 2 entry +else +elfhdr +wrword 16 4063234 +wrword 24 add 4194304 entry +wrword 96 get oc 0 +wrword 104 get oc 0 +wrword 160 add get poolb 0 8388608 +end +i = ulong 0 +while lt i get xnaddr 0 +p = get xasite i +v = get xavalue i +if efi +note PE: code RVA = file offset + 3584; static data lives in the bss section at xbss. +if ge v 268435456 +v = add get xbss 0 sub v 268435456 +else +v = add sub v 4194304 3584 +end +p = add p 3584 +else +v = sub v 4194304 +end +wrword get xasite i sub v add p 4 +i = add i 1 +end +writeout 0 +end + +note ======== x86efi: UEFI 2.10 PE32+ application (docs/X86-EFI.md) ======== +note efi OP ARG A OFF N -> ulong EFI_STATUS or result. OP is a literal 0..14; A is writable uchar +note storage, bounds checked before any firmware call; ARG is never a pointer. Errors are 2^63|code. +note Private state occupies the first 16 KiB of the PE .bss, below the owned 8 MiB stack. Firmware is +note called per UEFI 2.3.4.2: RCX/RDX/R8/R9, 32-byte home area, an 80-byte 16-aligned reservation. +note Language values stay in RBP slots, so integers and floats survive every firmware call. +note Port of the Allen x86efi fork (operations 0..11) onto main's backend; 12, 13 and 14 are new. + +note xp k: 0 LEA r,private+off; 1 load r from private+off; 2 store r to private+off (via R10); +note 3 call BootServices+off (R11); 4 call method off of the protocol held in private slot r (RCX = This). +fn xp k ulong r ulong off ulong to void +if eq k 0 +xaddr r add 268435456 off +ret +end +if eq k 1 +xaddr r add 268435456 off +xmem 139 r r 0 +ret +end +if eq k 2 +xaddr 10 add 268435456 off +xmem 137 r 10 0 +ret +end +if eq k 3 +xaddr 11 268435456 +xmem 139 11 11 0 +xmem 139 11 11 96 +xmem 139 11 11 off +xb 65 255 211 +ret +end +xaddr 1 add 268435456 r +xmem 139 1 1 0 +xmem 139 11 1 off +xb 65 255 211 +end + +note xer k: 0 branch on cc to an error tail that returns 2^63|code; 1 jump to the operation's end; +note 2 RDTSC into RAX (Intel SDM: LFENCE before and after serializes local instruction execution). +fn xer k ulong cc ulong code ulong to void +if eq k 2 +xb 15 174 232 +emitb 15 +emitb 49 +xb 15 174 232 +xb 72 193 226 +emitb 32 +xrr 9 0 2 +ret +end +if eq k 0 +n = get xenerr 0 +if ge n 256 +fail 14 +end +put xerrpos n xbranch cc +put xerrcode n code +put xenerr 0 add n 1 +ret +end +m = get xenend 0 +if ge m 256 +fail 14 +end +put xendpos m xbranch 14 +put xenend 0 add m 1 +end + +note xg k: inline constant data skipped by a jump; returns its address for xaddr. k 0..7 a UEFI GUID +note packed Data1|Data2<<32|Data3<<48 then Data4 little-endian (0 GOP, 1 SNP, 2 RNG, 3 simple pointer, +note 4 absolute pointer, 5 Simple File System, 6 LoadedImage, 7 FileInfo, 9 SMBIOS3 table, 10 SMBIOS +note table); 8 UCS-2 \EFI\BOOT\BOOTX64.EFI. +fn xg k ulong to ulong +br = xbranch 14 +p = get oc 0 +if eq k 8 +xb 92 0 69 +xb 0 70 0 +xb 73 0 92 +xb 0 66 0 +xb 79 0 79 +xb 0 84 0 +xb 92 0 66 +xb 0 79 0 +xb 79 0 84 +xb 0 88 0 +xb 54 0 52 +xb 0 46 0 +xb 69 0 70 +xb 0 73 0 +emitb 0 +emitb 0 +else +a = ulong 5348063987722529246 +b = ulong 7661046075708078998 +if eq k 1 +a = ulong 1284559596355596985 +b = ulong 5602828850577812890 +end +if eq k 2 +a = ulong 4845287014151666853 +b = ulong 4908688144209030790 +end +if eq k 3 +a = ulong 1284945866654190727 +b = ulong 5602828850577821594 +end +if eq k 4 +a = ulong 5398063699126244139 +b = ulong 4839848993530975643 +end +if eq k 5 +a = ulong 1284199179690597154 +b = ulong 4283602510276475278 +end +if eq k 6 +a = ulong 1284253093421855137 +b = ulong 4283602510276476814 +end +if eq k 7 +a = ulong 1284208961261104786 +b = ulong 4283602510276475278 +end +if eq k 9 +a = ulong 5344813523769562436 +b = ulong 10728454813909331609 +end +if eq k 10 +a = ulong 1284420384822471985 +b = ulong 5602828850577807002 +end +xword a +xword shr a 32 +xword b +xword shr b 32 +end +xpatch br get oc 0 +ret add p 4194304 +end + +note xe k: 2 close the operation (error tails, then the shared end); 3 need N >= a (5); 4 need the +note protocol in private slot a (3); 5 leave on a firmware error; 7 OR a into the info flags at A+4; +note 8 LocateProtocol GUID a into slot b; 9 calibrate TSC ticks/ms over a 100 ms Stall (176, base 168); +note 10 settle the transmit buffer at exit (status 88); 12 elapsed milliseconds into A. +fn xe k ulong a ulong b ulong to void +if eq k 2 +xer 1 0 0 +j = ulong 0 +while lt j get xenerr 0 +xpatch get xerrpos j get oc 0 +ximm 0 or 9223372036854775808 get xerrcode j +xer 1 0 0 +j = add j 1 +end +i = ulong 0 +while lt i get xenend 0 +xpatch get xendpos i get oc 0 +i = add i 1 +end +ret +end +if eq k 3 +ximm 0 a +xrr 57 13 0 +xer 0 3 5 +ret +end +if eq k 4 +xp 1 1 a +xrr 133 1 1 +xer 0 0 3 +ret +end +if eq k 5 +xrr 133 0 0 +ok = xbranch 0 +xleave +xpatch ok get oc 0 +ret +end +if eq k 7 +xhraw 0 12 4 4 +ximm 2 a +xrr 9 0 2 +xhput 0 12 4 4 +ret +end +if eq k 8 +g = xg a +xaddr 1 g +ximm 2 0 +xp 0 8 b +xp 3 0 320 +note LocateProtocol is optional. Failed output is discarded, never dereferenced. +xrr 133 0 0 +ok8 = xbranch 0 +ximm 0 0 +xp 2 0 b +xpatch ok8 get oc 0 +ret +end +if eq k 9 +xer 2 0 0 +xp 2 0 160 +ximm 1 100000 +xp 3 0 248 +xrr 133 0 0 +ok9 = xbranch 0 +xleave +xpatch ok9 get oc 0 +xer 2 0 0 +xp 1 1 160 +xrr 41 0 1 +mono = xbranch 3 +ximm 1 100 +ximm 2 0 +xb 72 247 241 +xp 2 0 176 +xer 2 0 0 +xp 2 0 168 +xpatch mono get oc 0 +ret +end +if eq k 10 +xp 1 1 96 +xrr 133 1 1 +none = xbranch 0 +xp 1 0 72 +xrr 133 0 0 +idle = xbranch 0 +ximm 0 0 +xp 2 0 80 +ximm 2 0 +xp 0 8 80 +xp 4 24 88 +xp 1 0 80 +xp 1 2 96 +xrr 57 0 2 +busy = xbranch 1 +xpatch idle get oc 0 +xp 1 1 96 +xp 3 0 72 +xrr 133 0 0 +freed = xbranch 0 +xp 2 0 88 +xpatch freed get oc 0 +fin = xbranch 14 +xpatch busy get oc 0 +note Do not free or reuse an unreturned DMA buffer. Expose NOT_READY on exit. +ximm 0 9223372036854775814 +xp 2 0 88 +xpatch fin get oc 0 +xpatch none get oc 0 +ret +end +xp 1 1 176 +xrr 133 1 1 +xer 0 0 3 +xer 2 0 0 +xp 1 2 168 +xrr 41 0 2 +xer 0 3 3 +ximm 2 0 +xb 72 247 241 +xmem 137 0 12 0 +ximm 0 0 +end + +note xefx k: 0 image entry, 1 the shared firmware return (every exit site lands here), 2 PE32+ headers. +fn xefx k ulong a ulong to void +if eq k 0 +note Preserve the integer nonvolatiles, MXCSR and XMM6-15 (UEFI 2.3.4.2), then install the owned stack. +emitb 83 +emitb 85 +emitb 86 +emitb 87 +xb 65 84 65 +emitb 85 +xb 65 86 65 +emitb 87 +xp 2 4 2048 +xp 2 1 8 +xp 2 2 0 +xp 0 10 2056 +xb 65 15 174 +emitb 26 +xp 0 10 2080 +j = ulong 6 +while lt j 16 +emitb 243 +emitb uchar add 65 mul shr j 3 4 +xb 15 127 add 130 shl and j 7 3 +xword mul sub j 6 16 +j = add j 1 +end +note MXCSR 0x1F80: all exceptions masked, round to nearest, as on x86 Linux. +ximm 0 8064 +xp 2 0 2064 +xp 0 10 2064 +xb 65 15 174 +emitb 18 +xp 0 15 16384 +xp 0 4 8388608 +ximm 5 0 +note Entry has its own 80-byte EFI home/argument reservation, not an Omega frame. +xb 72 129 236 +xword 80 +ximm 1 0 +ximm 2 0 +ximm 8 0 +ximm 9 0 +xp 3 0 256 +xe 5 0 0 +note TX storage outlives the image if firmware fails to release an in-flight packet. +ximm 1 2 +ximm 2 2048 +xp 0 8 96 +xp 3 0 64 +xe 5 0 0 +xe 8 0 16 +xe 8 2 32 +xe 8 3 40 +xe 8 4 48 +note Intel SDM 20.17.1 invariant TSC, CPUID.80000007H:EDX[8]; otherwise calibrate lazily (op 10). +ximm 0 1 +emitb 15 +emitb 162 +ximm 0 16 +xrr 33 2 0 +xrr 133 2 2 +no1 = xbranch 0 +ximm 0 2147483648 +emitb 15 +emitb 162 +ximm 2 2147483655 +xrr 57 0 2 +no2 = xbranch 3 +ximm 0 2147483655 +emitb 15 +emitb 162 +ximm 0 256 +xrr 33 2 0 +xrr 133 2 2 +no3 = xbranch 0 +xe 9 0 0 +xpatch no1 get oc 0 +xpatch no2 get oc 0 +xpatch no3 get oc 0 +xb 72 129 196 +xword 80 +ret +end +if eq k 1 +i = ulong 0 +while lt i get xnexit 0 +xpatch get xexsite i get oc 0 +i = add i 1 +end +note Restore a known-good private stack even when an Omega stack check failed. +xp 0 4 8388608 +xb 72 129 236 +xword 80 +xp 2 0 88 +note An efi 12 file still open at exit (return, exit or trap) is flushed when writable, then the file +note and its volume root are closed and the slot cleared, as a process exit closes descriptors. +xp 1 1 2304 +xrr 133 1 1 +p1 = xbranch 0 +xp 1 0 2320 +xrr 133 0 0 +p2 = xbranch 0 +xp 4 2304 80 +xpatch p2 get oc 0 +xp 4 2304 16 +xpatch p1 get oc 0 +xp 1 1 2312 +xrr 133 1 1 +p3 = xbranch 0 +xp 4 2312 16 +xpatch p3 get oc 0 +ximm 0 0 +xp 2 0 2304 +xp 2 0 2312 +xp 2 0 2320 +xe 10 0 0 +xp 0 10 2080 +r = ulong 6 +while lt r 16 +emitb 243 +emitb uchar add 65 mul shr r 3 4 +xb 15 111 add 130 shl and r 7 3 +xword mul sub r 6 16 +r = add r 1 +end +xp 0 10 2056 +xb 65 15 174 +emitb 18 +xp 1 0 88 +xp 1 11 2048 +xrr 137 4 11 +xb 65 95 65 +emitb 94 +xb 65 93 65 +emitb 92 +emitb 95 +emitb 94 +emitb 93 +emitb 91 +emitb 195 +ret +end +note PE32+ UEFI application. Section/file alignment 4096/512; every address is RIP-relative, so the +note image is position independent. A valid empty relocation block keeps loader relocation support. +while ne and get oc 0 511 0 +emitb 0 +end +raw = sub get oc 0 512 +bs = shl shr add add raw 4096 4095 12 12 +put xbss 0 bs +wrword 0 23117 +wrword 60 64 +wrword 64 17744 +wrword 68 165476 +wrword 84 2228464 +wrword 88 523 +wrword 92 raw +wrword 100 add get poolb 0 8388608 +wrword 104 add a 3584 +wrword 108 4096 +wrword 112 4194304 +wrword 120 4096 +wrword 124 512 +wrword 128 6 +wrword 136 6 +wrword 144 shl shr add add bs add get poolb 0 8388608 4095 12 12 +wrword 148 512 +wrword 156 4194314 +wrword 160 1048576 +wrword 168 4096 +wrword 176 1048576 +wrword 184 4096 +wrword 196 16 +wrword 512 0 +wrword 516 8 +note Base relocation directory points to the first eight bytes of .text, reserved by the driver. +wrword 240 4096 +wrword 244 8 +wrword 328 2019914798 +wrword 332 116 +wrword 336 raw +wrword 340 4096 +wrword 344 raw +wrword 348 512 +wrword 364 1610612768 +wrword 368 1936941614 +wrword 376 add get poolb 0 8388608 +wrword 380 bs +wrword 404 3221225600 +end + +fn xefival dst ulong to void +if ne get xtarget 0 2 +fail 25 +end +x = mul get depth 0 32 +put fr add x 7 get nslot 0 +op = lenval 4 +if gt op 14 +fail 25 +end +harg x 2 5 +e = harray x 1 +xhbegin +xha x 2 3 +xhb 12 e get fr add x 21 +xhs 13 get fr add x 22 +note Firmware runs on the owned stack: reserve 64 KiB (trap 6), then align RSP for UEFI 2.3.4.2. +xcheck 65536 +xb 72 131 228 +emitb 240 +xb 72 129 236 +xword 80 +put xenerr 0 0 +put xenend 0 0 +xeop op +xe 2 0 0 +xrr 137 4 14 +r = restore dst get fr add x 7 get svn 0 get sva 0 1 +vdone 1 r 5 +end + +note Operation registers: RBX = ARG, R12 = A+OFF, R13 = N; the result or error is RAX. +fn xeop op ulong to void +if eq op 1 +xe 3 4 0 +xp 1 1 0 +xmem 139 1 1 48 +xrr 133 1 1 +xer 0 0 3 +xrr 137 2 12 +xmem 139 11 1 8 +xb 65 255 211 +ret +end +if eq op 2 +xrr 137 1 3 +xp 3 0 248 +ret +end +if eq op 4 +xe 3 16 0 +xp 1 11 0 +xmem 139 11 11 88 +xmem 139 11 11 24 +xrr 137 1 12 +ximm 2 0 +xb 65 255 211 +ret +end +if eq op 8 +xenet +ret +end +if eq op 10 +xe 3 8 0 +xp 1 1 176 +xrr 133 1 1 +ok = xbranch 1 +xe 9 0 0 +xpatch ok get oc 0 +xe 12 0 0 +ret +end +if eq op 11 +xefile +ret +end +if eq op 12 +xf12 +ret +end +if eq op 14 +xf14 +ret +end +xdev op +end + +note efi 14 machine identity; ARG bits 0..15 sub, 16..63 its parameter. Sub 0: CPUID leaf ARG>>16 +note (below 2^32, else 32) with ECX 0, EAX EBX ECX EDX as four u32 at A+OFF (N >= 16, else 5), +note result 16. ARG 1: the UCS-2 code units of SystemTable FirmwareVendor (+24) up to its NUL, at +note most N bytes in whole units, result bytes copied (0 when the pointer is NULL). ARG 2: result +note FirmwareRevision (+32). Sub 3: SMBIOS structure table bytes from position ARG>>16 into A +note (at most N), result bytes copied, 0 at or past the end. The table comes from the configuration +note table: the SMBIOS3 entry point (_SM3_, size u32 @12, address u64 @16) first, else SMBIOS 2.x +note (_SM_, length u16 @22, address u32 @24); 44 when neither is there, an anchor is wrong or the +note address is 0. Any other ARG is 32. Nothing is written past A+OFF+N. +fn xf14 to void +ximm 0 1 +xrr 57 3 0 +p = xbranch 1 +xp 1 1 0 +xmem 139 6 1 24 +ximm 0 0 +xrr 137 7 12 +xrr 137 9 13 +xrr 133 6 6 +z = xbranch 0 +loop = get oc 0 +ximm 2 2 +xrr 57 9 2 +d1 = xbranch 3 +xhraw 2 6 0 2 +xrr 133 2 2 +d2 = xbranch 0 +xhput 2 7 0 2 +xb 72 131 198 +emitb 2 +xb 72 131 199 +emitb 2 +xb 72 131 192 +emitb 2 +xb 73 131 233 +emitb 2 +q = xbranch 14 +xpatch q loop +xpatch z get oc 0 +xpatch d1 get oc 0 +xpatch d2 get oc 0 +xer 1 0 0 +xpatch p get oc 0 +ximm 0 2 +xrr 57 3 0 +p = xbranch 1 +xp 1 1 0 +xhraw 0 1 32 4 +xer 1 0 0 +xpatch p get oc 0 +xrr 137 6 3 +ximm 0 65535 +xrr 33 6 0 +p = xbranch 1 +xe 3 16 0 +xrr 137 0 3 +xb 72 193 232 +emitb 16 +xrr 137 2 0 +xb 72 193 234 +emitb 32 +xrr 133 2 2 +xer 0 1 32 +ximm 1 0 +emitb 15 +emitb 162 +xhput 0 12 0 4 +xhput 3 12 4 4 +xhput 1 12 8 4 +xhput 2 12 12 4 +ximm 0 16 +xer 1 0 0 +xpatch p get oc 0 +ximm 0 3 +xrr 57 6 0 +xer 0 1 32 +xp 1 1 0 +xmem 139 8 1 104 +xmem 139 9 1 112 +f3 = ulong 0 +f = ulong 0 +g = ulong 9 +while le g 10 +xaddr 10 xg g +xrr 137 11 9 +xrr 137 1 8 +loop = get oc 0 +xrr 133 1 1 +miss = xbranch 0 +xmem 139 0 11 0 +xmem 59 0 10 0 +n1 = xbranch 1 +xmem 139 0 11 8 +xmem 59 0 10 8 +n2 = xbranch 1 +xmem 139 6 11 16 +f = xbranch 14 +xpatch n1 get oc 0 +xpatch n2 get oc 0 +xb 73 131 195 +emitb 24 +xb 72 131 233 +emitb 1 +q = xbranch 14 +xpatch q loop +xpatch miss get oc 0 +if eq g 9 +f3 = f +end +g = add g 1 +end +xer 0 14 44 +xpatch f get oc 0 +xrr 133 6 6 +xer 0 0 44 +xhraw 0 6 0 4 +ximm 2 1598903135 +xrr 57 0 2 +xer 0 1 44 +xhraw 8 6 22 2 +xhraw 6 6 24 4 +cp = xbranch 14 +xpatch f3 get oc 0 +xrr 133 6 6 +xer 0 0 44 +xhraw 0 6 0 4 +ximm 2 860705631 +xrr 57 0 2 +xer 0 1 44 +xhraw 8 6 12 4 +xmem 139 6 6 16 +xpatch cp get oc 0 +xrr 133 6 6 +xer 0 0 44 +xrr 137 2 3 +xb 72 193 234 +emitb 16 +ximm 0 0 +xrr 57 2 8 +done = xbranch 2 +xrr 137 1 8 +xrr 41 1 2 +xrr 57 1 13 +ok = xbranch 9 +xrr 137 1 13 +xpatch ok get oc 0 +xrr 1 6 2 +xrr 137 7 12 +xrr 137 0 1 +emitb 252 +emitb 243 +emitb 164 +xpatch done get oc 0 +end + +note Device operations: 0 info, 3 GOP Blt, 5 entropy, 6 receive, 7 transmit, 9 pointer, 13 console. +note OP0 info, 64 bytes: u32 version=1, flags (1 GOP, 2 net, 4 RNG, 8 pointer), u32 width/height@8, +note pixelFormat@16, stride@20, MAC[6]@24, maxPacket@32, hwAddrSize@36, media@40, state@44, txBusy@48. +note OP3 ARG: width bits0..31, height bits32..47, destination row bits48..63 (UEFI 12.9.2 Blt). +fn xdev op ulong to void +if eq op 0 +xe 3 64 0 +ximm 0 0 +j = ulong 0 +while lt j 64 +xmem 137 0 12 j +j = add j 8 +end +ximm 0 1 +xmem 137 0 12 0 +xp 1 1 16 +xrr 133 1 1 +p = xbranch 0 +xmem 139 1 1 24 +xrr 133 1 1 +z1 = xbranch 0 +xmem 139 1 1 8 +xrr 133 1 1 +z2 = xbranch 0 +xmem 139 0 1 4 +xmem 137 0 12 8 +xhraw 0 1 12 4 +xhput 0 12 16 4 +xhraw 0 1 32 4 +xhput 0 12 20 4 +ximm 0 1 +xhput 0 12 4 4 +xpatch p get oc 0 +xp 1 1 24 +xrr 133 1 1 +p = xbranch 0 +xmem 139 1 1 120 +xrr 133 1 1 +z3 = xbranch 0 +xhraw 0 1 552 4 +xhput 0 12 24 4 +xhraw 0 1 556 2 +xhput 0 12 28 4 +xhraw 0 1 12 4 +xhput 0 12 32 4 +xhraw 0 1 4 4 +xhput 0 12 36 4 +xhraw 0 1 652 1 +xhput 0 12 40 4 +xhraw 0 1 0 4 +xhput 0 12 44 4 +xp 1 0 72 +xhput 0 12 48 4 +xe 7 2 0 +xpatch p get oc 0 +xp 1 1 32 +xrr 133 1 1 +p = xbranch 0 +xe 7 4 0 +xpatch p get oc 0 +xp 1 1 40 +xp 1 2 48 +xrr 9 1 2 +xrr 133 1 1 +p = xbranch 0 +xe 7 8 0 +xpatch p get oc 0 +xpatch z1 get oc 0 +xpatch z2 get oc 0 +xpatch z3 get oc 0 +ximm 0 0 +ret +end +if eq op 3 +xe 4 16 0 +xrr 137 8 3 +xb 73 193 232 +emitb 32 +ximm 0 65535 +xrr 33 8 0 +xrr 137 10 3 +xb 73 193 234 +emitb 48 +xrr 137 9 3 +ximm 0 4294967295 +xrr 33 9 0 +xrr 133 8 8 +xer 0 0 2 +xrr 133 9 9 +xer 0 0 2 +xmem 139 2 1 24 +xrr 133 2 2 +xer 0 0 2 +xmem 139 2 2 8 +xrr 133 2 2 +xer 0 0 2 +xhraw 0 2 4 4 +xrr 57 9 0 +xer 0 8 2 +xhraw 0 2 8 4 +xrr 41 0 10 +xer 0 3 2 +xrr 57 8 0 +xer 0 8 2 +xrr 137 0 8 +xb 73 15 175 +emitb 193 +xb 72 193 224 +emitb 2 +xrr 57 0 13 +xer 0 1 2 +xmem 137 9 4 56 +xmem 137 8 4 64 +ximm 0 0 +xmem 137 0 4 32 +xmem 137 0 4 40 +xmem 137 10 4 48 +xmem 137 0 4 72 +xrr 137 2 12 +ximm 8 2 +ximm 9 0 +xp 4 16 16 +ret +end +if eq op 5 +note RNG protocol when present; else Intel SDM RDRAND (CPUID.1:ECX[30], CF = valid), ten attempts +note per byte, then EFI_NOT_READY, never fallback data. +xp 1 1 32 +xrr 133 1 1 +p = xbranch 0 +ximm 2 0 +xrr 137 8 13 +xrr 137 9 12 +xp 4 32 8 +xer 1 0 0 +xpatch p get oc 0 +ximm 0 0 +emitb 15 +emitb 162 +ximm 2 1 +xrr 57 0 2 +xer 0 3 3 +ximm 0 1 +emitb 15 +emitb 162 +ximm 2 1073741824 +xrr 33 1 2 +xrr 133 1 1 +xer 0 0 3 +xrr 137 7 12 +xrr 137 6 13 +lp = get oc 0 +xrr 133 6 6 +q = xbranch 0 +ximm 1 10 +rw = get oc 0 +xb 72 15 199 +emitb 240 +s = xbranch 3 +xb 72 255 201 +p = xbranch 1 +xpatch p rw +xer 0 14 6 +xpatch s get oc 0 +emitb 136 +emitb 7 +xb 72 255 199 +xb 72 255 206 +back lp +xpatch q get oc 0 +ximm 0 0 +ret +end +if eq op 6 +xe 3 9 0 +xe 4 24 0 +xrr 137 0 13 +xb 72 131 232 +emitb 8 +xmem 137 0 12 0 +ximm 2 0 +xrr 137 8 12 +xmem 141 9 12 8 +ximm 0 0 +xmem 137 0 4 32 +xmem 137 0 4 40 +xmem 137 0 4 48 +xp 4 24 104 +ret +end +if eq op 7 +note Transmit always owns its private packet until GetStatus reclaims that exact address (UEFI 24.1.12). +xe 4 24 0 +xe 3 14 0 +ximm 0 2048 +xrr 57 13 0 +xer 0 8 4 +xp 1 0 72 +xrr 133 0 0 +p = xbranch 0 +ximm 0 0 +xp 2 0 80 +ximm 2 0 +xp 0 8 80 +xp 4 24 88 +xrr 133 0 0 +xer 0 1 6 +xp 1 0 80 +xp 1 2 96 +xrr 57 0 2 +xer 0 1 6 +ximm 0 0 +xp 2 0 72 +xpatch p get oc 0 +xrr 137 6 12 +xp 1 7 96 +xrr 137 1 13 +emitb 252 +emitb 243 +emitb 164 +ximm 2 0 +xrr 137 8 13 +xp 1 9 96 +ximm 0 0 +xmem 137 0 4 32 +xmem 137 0 4 40 +xmem 137 0 4 48 +xp 4 24 96 +xrr 133 0 0 +p = xbranch 1 +ximm 2 1 +xp 2 2 72 +xpatch p get oc 0 +ret +end +if eq op 9 +xe 3 32 0 +xp 1 1 40 +xrr 133 1 1 +q = xbranch 0 +xp 0 2 256 +xp 4 40 8 +xrr 133 0 0 +p = xbranch 1 +xp 0 2 256 +ximm 0 1 +xmem 137 0 12 0 +xhraw 0 2 12 1 +xhraw 1 2 13 1 +xb 72 193 225 +emitb 1 +xrr 9 0 1 +xhput 0 12 4 4 +i = ulong 0 +while lt i 3 +note MOVSXD rax,dword [rdx+disp32], Intel MOVSX/MOVSXD. +xb 72 99 130 +xword mul i 4 +xmem 137 0 12 add 8 mul i 8 +i = add i 1 +end +ximm 0 0 +xpatch p get oc 0 +xer 1 0 0 +xpatch q get oc 0 +xe 4 48 0 +xp 0 2 256 +xp 4 48 8 +xrr 133 0 0 +p = xbranch 1 +xp 0 2 256 +ximm 0 2 +xmem 137 0 12 0 +xhraw 0 2 24 4 +xhput 0 12 4 4 +i = ulong 0 +while lt i 3 +xmem 139 0 2 mul i 8 +xmem 137 0 12 add 8 mul i 8 +i = add i 1 +end +ximm 0 0 +xpatch p get oc 0 +ret +end +if ne op 13 +fail 25 +end +note efi 13: write A[OFF..OFF+N) to ConOut (UEFI 12.4 OutputString). ARG must be 0; only bytes 9, 10, +note 13 and 32..126, all checked before any output; LF becomes CR LF; UCS-2 chunks of at most 255 +note characters in private 4096. Warnings (bit 63 clear) are not errors. Result N. +xrr 133 3 3 +xer 0 1 32 +xrr 137 8 12 +xrr 137 9 13 +lp = get oc 0 +xrr 133 9 9 +p = xbranch 0 +xhraw 0 8 0 1 +ximm 2 9 +xrr 57 0 2 +q = xbranch 0 +ximm 2 10 +xrr 57 0 2 +rw = xbranch 0 +ximm 2 13 +xrr 57 0 2 +s = xbranch 0 +ximm 2 32 +xrr 57 0 2 +xer 0 3 42 +ximm 2 126 +xrr 57 0 2 +xer 0 8 42 +xpatch q get oc 0 +xpatch rw get oc 0 +xpatch s get oc 0 +xb 73 131 192 +emitb 1 +xb 73 131 233 +emitb 1 +back lp +xpatch p get oc 0 +note ConOut (SystemTable+64) may be NULL on headless firmware: refuse with 43 before any call. +xp 1 1 0 +xmem 139 1 1 64 +xrr 133 1 1 +xer 0 0 43 +xrr 137 6 12 +xrr 137 3 13 +ximm 7 0 +lp = get oc 0 +xrr 133 3 3 +p = xbranch 0 +ximm 0 254 +xrr 57 7 0 +q = xbranch 3 +xpatch p get oc 0 +xrr 133 7 7 +rw = xbranch 0 +xp 0 10 4096 +xrr 137 11 7 +xrr 1 11 11 +xrr 1 10 11 +ximm 0 0 +xhput 0 10 0 2 +xp 1 1 0 +xmem 139 1 1 64 +xp 0 2 4096 +xmem 139 11 1 8 +xb 65 255 211 +xrr 133 0 0 +xer 0 11 43 +ximm 7 0 +xpatch rw get oc 0 +xrr 133 3 3 +s = xbranch 0 +xpatch q get oc 0 +xp 0 10 4096 +xrr 137 11 7 +xrr 1 11 11 +xrr 1 10 11 +xhraw 0 6 0 1 +ximm 2 10 +xrr 57 0 2 +p = xbranch 1 +ximm 0 13 +xhput 0 10 0 2 +ximm 0 10 +xhput 0 10 2 2 +xb 72 131 199 +emitb 1 +q = xbranch 14 +xpatch p get oc 0 +xhput 0 10 0 2 +xpatch q get oc 0 +xb 72 131 199 +emitb 1 +xb 72 131 198 +emitb 1 +xb 72 131 235 +emitb 1 +back lp +xpatch s get oc 0 +xrr 137 0 13 +end + +note UEFI 24.1 SNP mode: MAC array capacity 16, 32-byte MAC cells, current@552, IfType@648, +note MediaPresentSupported@651, MediaPresent@652. k 0 probe candidate 128 (own error scope); +note k 1 reject it: shut down/stop only what this application initialized/started. +fn xenpr k ulong to void +if eq k 1 +xp 1 0 144 +xrr 133 0 0 +p = xbranch 0 +xp 4 128 40 +xpatch p get oc 0 +xp 1 0 136 +xrr 133 0 0 +p = xbranch 0 +xp 4 128 16 +xpatch p get oc 0 +ret +end +put xenerr 0 0 +put xenend 0 0 +ximm 0 0 +xp 2 0 136 +xp 2 0 144 +xp 1 1 128 +xmem 139 2 1 120 +xrr 133 2 2 +xer 0 0 3 +xhraw 0 2 4 4 +ximm 8 6 +xrr 57 0 8 +xer 0 1 3 +xhraw 0 2 648 1 +ximm 8 1 +xrr 57 0 8 +xer 0 1 3 +xhraw 0 2 0 4 +xrr 133 0 0 +q = xbranch 1 +xp 4 128 8 +xrr 133 0 0 +xer 0 1 7 +ximm 0 1 +xp 2 0 136 +xpatch q get oc 0 +xp 1 1 128 +xmem 139 2 1 120 +xhraw 0 2 0 4 +ximm 8 1 +xrr 57 0 8 +q = xbranch 1 +ximm 2 0 +ximm 8 0 +xp 4 128 24 +xrr 133 0 0 +xer 0 1 7 +ximm 0 1 +xp 2 0 144 +xpatch q get oc 0 +ximm 2 0 +ximm 8 0 +xp 4 128 88 +xrr 133 0 0 +xer 0 1 7 +xp 1 1 128 +xmem 139 2 1 120 +xhraw 0 2 0 4 +ximm 8 2 +xrr 57 0 8 +xer 0 1 6 +note MediaPresent is binding only when the driver says media detection is supported. +xhraw 0 2 651 1 +xrr 133 0 0 +q = xbranch 0 +xhraw 0 2 652 1 +xrr 133 0 0 +xer 0 0 12 +xpatch q get oc 0 +xhraw 0 2 24 4 +ximm 8 5 +xrr 33 0 8 +xrr 57 0 8 +xer 0 1 3 +ximm 2 5 +ximm 8 0 +ximm 9 0 +ximm 0 0 +xmem 137 0 4 32 +xmem 137 0 4 40 +xp 4 128 48 +xe 2 0 0 +end + +note UEFI 2.4 7.3 OpenProtocol EXCLUSIVE (32) disconnects MNP and the IP stack above SNP; while they +note stay bound, MNP's poll timer drains frames no child wants (aienux#454). Firmware that refuses +note keeps the shared HandleProtocol path. All candidates are tried for a live link. +fn xenscan g ulong to void +ximm 3 0 +lp = get oc 0 +xrr 57 3 7 +ex = xbranch 2 +xrr 137 0 3 +xb 72 193 224 +emitb 3 +xrr 1 0 6 +xmem 139 1 0 0 +xaddr 2 g +xp 0 8 128 +xp 1 9 8 +ximm 0 0 +xmem 137 0 4 32 +ximm 0 32 +xmem 137 0 4 40 +xp 3 0 280 +xrr 133 0 0 +p = xbranch 0 +xrr 137 0 3 +xb 72 193 224 +emitb 3 +xrr 1 0 6 +xmem 139 1 0 0 +xaddr 2 g +xp 0 8 128 +xp 3 0 152 +xpatch p get oc 0 +xrr 133 0 0 +sk = xbranch 1 +xenpr 0 +xrr 133 0 0 +p = xbranch 1 +xp 1 0 128 +xp 2 0 24 +sel = xbranch 14 +xpatch p get oc 0 +xenpr 1 +xpatch sk get oc 0 +xb 72 255 195 +back lp +xpatch ex get oc 0 +ximm 0 9223372036854775822 +p = xbranch 14 +xpatch sel get oc 0 +ximm 0 0 +xpatch p get oc 0 +end + +note OP8: select a live Simple Network Protocol interface once (result 0), or an EFI status. +fn xenet to void +xp 1 1 24 +xrr 133 1 1 +al = xbranch 1 +g = xg 1 +ximm 1 2 +xaddr 2 g +ximm 8 0 +xp 0 9 104 +xp 0 0 112 +xmem 137 0 4 32 +xp 3 0 312 +xrr 133 0 0 +lerr = xbranch 1 +xp 1 6 112 +xp 1 7 104 +ximm 0 1024 +xrr 57 7 0 +lg = xbranch 8 +xenscan g +sv = xbranch 14 +xpatch lg get oc 0 +ximm 0 9223372036854775813 +xpatch sv get oc 0 +xp 2 0 152 +xrr 137 1 6 +xp 3 0 72 +xrr 133 0 0 +fe = xbranch 1 +xp 1 0 152 +dn = xbranch 14 +xpatch al get oc 0 +ximm 0 0 +xpatch dn get oc 0 +xpatch lerr get oc 0 +xpatch fe get oc 0 +put xenerr 0 0 +put xenend 0 0 +end + +note Volumes (UEFI 13.4 Simple File System, 9.1 LoadedImage). k 0: copy the handles (at most 64) to +note private 1024 and free the firmware buffer (clobbers RSI/RDI/RCX); 1: result count | boot index<<8 +note (255 none) and finish; 2: open the root of volume RDI into slot root (19 index, 21, 22); +note 3: open the root of the volume this image was loaded from into slot root (18, 21, 22). +fn xvol k ulong root ulong to void +if eq k 0 +g = xg 5 +ximm 1 2 +xaddr 2 g +ximm 8 0 +xp 0 9 512 +xp 0 0 520 +xmem 137 0 4 32 +xp 3 0 312 +xrr 133 0 0 +xer 0 1 16 +xp 1 1 512 +ximm 0 64 +xrr 57 1 0 +p = xbranch 3 +ximm 1 64 +xpatch p get oc 0 +xp 2 1 512 +xp 1 6 520 +xp 0 7 1024 +emitb 252 +emitb 243 +emitb 72 +emitb 165 +xp 1 1 520 +xp 3 0 72 +xrr 133 0 0 +xer 0 1 17 +ret +end +if eq k 1 +gl = xg 6 +xp 1 1 8 +xaddr 2 gl +xp 0 8 528 +xp 3 0 152 +xrr 133 0 0 +xer 0 1 18 +xp 1 0 528 +xmem 139 0 0 24 +xp 1 6 512 +xp 0 7 1024 +ximm 2 0 +lp = get oc 0 +xrr 57 2 6 +nm = xbranch 2 +xmem 139 1 7 0 +xrr 57 1 0 +fd = xbranch 0 +xb 72 131 199 +emitb 8 +xb 72 255 194 +back lp +xpatch nm get oc 0 +ximm 2 255 +xpatch fd get oc 0 +xrr 137 0 6 +xb 72 193 226 +emitb 8 +xrr 9 0 2 +xer 1 0 0 +ret +end +gs = xg 5 +if eq k 3 +gi = xg 6 +xp 1 1 8 +xaddr 2 gi +xp 0 8 528 +xp 3 0 152 +xrr 133 0 0 +xer 0 1 18 +xp 1 1 528 +xmem 139 1 1 24 +else +xp 1 0 512 +xrr 57 7 0 +xer 0 2 19 +xp 0 1 1024 +xrr 137 0 7 +xb 72 193 224 +emitb 3 +xrr 1 1 0 +xmem 139 1 1 0 +end +xaddr 2 gs +xp 0 8 536 +xp 3 0 152 +xrr 133 0 0 +xer 0 1 21 +xp 0 2 root +xp 4 536 8 +xrr 133 0 0 +xer 0 1 22 +end + +note File I/O (UEFI 13.5). k 0: Open(root, path, mode) into slot file; the path is the fixed +note \EFI\BOOT\BOOTX64.EFI for root 544 (efi 11), else the UCS-2 copy at private 3584 (efi 12). +note k 1: efi 11 Read/Write (method mode) of N bytes at R12 via size slot 560. Failure: RDI = code, +note jump to cleanup. +fn xfio k ulong root ulong file ulong mode ulong code ulong cleanup ulong to void +if eq k 0 +if eq root 544 +p = xg 8 +xaddr 8 p +else +xp 0 8 3584 +end +xp 0 2 file +ximm 9 mode +ximm 0 0 +xmem 137 0 4 32 +xp 4 root 8 +else +xp 2 13 560 +xp 0 2 560 +xrr 137 8 12 +xp 4 552 mode +end +xrr 133 0 0 +ximm 7 code +bad = xbranch 1 +xpatch bad cleanup +end + +note OP11 (Allen fork contract): ARG sub bits0..7, volume bits8..15. Sub 0 counts the volumes and +note finds the boot one (count | index<<8); sub 1 reads \EFI\BOOT\BOOTX64.EFI of volume k into A +note (result bytes); sub 2 writes A's N bytes as that file (deleted first; result bytes). File and +note root handles are closed on every path. +fn xefile to void +xrr 137 0 3 +ximm 2 255 +xrr 33 0 2 +ximm 2 2 +xrr 57 0 2 +xer 0 8 15 +ximm 0 0 +xp 2 0 544 +xp 2 0 552 +skip = xbranch 14 +cleanup = get oc 0 +xp 1 1 552 +xrr 133 1 1 +p = xbranch 0 +xp 4 552 16 +xpatch p get oc 0 +xp 1 1 544 +xrr 133 1 1 +p = xbranch 0 +xp 4 544 16 +xpatch p get oc 0 +xrr 133 7 7 +p = xbranch 0 +ximm 0 9223372036854775808 +xrr 9 0 7 +xer 1 0 0 +xpatch p get oc 0 +xp 1 0 568 +xer 1 0 0 +xpatch skip get oc 0 +xvol 0 0 +xrr 137 6 3 +ximm 2 255 +xrr 33 6 2 +xrr 137 7 3 +xb 72 193 239 +emitb 8 +xrr 33 7 2 +xrr 133 6 6 +p = xbranch 1 +xvol 1 0 +xpatch p get oc 0 +xp 1 0 512 +xrr 57 7 0 +xer 0 2 19 +xe 3 1 0 +xvol 2 544 +ximm 0 1 +xrr 57 6 0 +wr = xbranch 1 +xfio 0 544 552 1 23 cleanup +xfio 1 0 0 32 25 cleanup +xp 1 0 560 +xp 2 0 568 +ximm 0 1 +xp 2 0 560 +xp 0 2 560 +xp 0 8 576 +xp 4 552 32 +xrr 133 0 0 +ximm 7 25 +p = xbranch 1 +xpatch p cleanup +xp 1 0 560 +xrr 133 0 0 +ximm 7 24 +p = xbranch 1 +xpatch p cleanup +ximm 7 0 +p = xbranch 14 +xpatch p cleanup +xpatch wr get oc 0 +xfio 0 544 552 3 26 cleanup +xp 4 552 24 +ximm 2 0 +xp 2 2 552 +xrr 133 0 0 +ximm 7 27 +p = xbranch 1 +xpatch p cleanup +xfio 0 544 552 9223372036854775811 28 cleanup +xfio 1 0 0 40 29 cleanup +xp 1 0 560 +xrr 57 0 13 +ximm 7 30 +p = xbranch 1 +xpatch p cleanup +xp 4 552 80 +xrr 133 0 0 +ximm 7 31 +p = xbranch 1 +xpatch p cleanup +xp 1 0 560 +xp 2 0 568 +ximm 7 0 +p = xbranch 14 +xpatch p cleanup +end + +note OP12 general file (new): ARG sub bits0..7, volume bits8..15 (255 = the volume this image was +note loaded from), position bits16..63. Open subs take the path A[OFF..OFF+N): 1..255 bytes, first +note '\', each 32..126. Sub 0 open read-only, 5 open an existing file read/write (no truncate), both +note result FileSize; 1 create empty, replacing any file (result 0). Sub 2 reads up to N bytes at +note the position into A (result bytes read, 0 at end), 3 writes N bytes there (result N; needs sub +note 1 or 5), 4 flushes and closes (result 0). One file at a time: its handle stays in private 2304 +note and its volume root in 2312 between operations. Errors: 32 sub, 33 path, 34 busy, 35 nothing +note open, 36 open/create/delete, 37 read, 38 write (or not writable), 39 short write, 40 flush, +note 41 GetInfo; volume errors 16..22 as efi 11. Refusals 32..35 and 38 not-writable leave the slot +note as it was (the caller still owns an open file); so do the firmware errors 37, 38 and 39 of subs +note 2 and 3. Volume errors leave the slot empty. 36 and 41 close the file and root, slot empty; +note sub 4 with a file open closes both and empties the slot on every path, returning 40 when Flush +note failed. A file still open at exit is flushed and closed by the shared exit (xefx 1). +fn xf12 to void +skip = xbranch 14 +cleanup = get oc 0 +xp 1 1 2304 +xrr 133 1 1 +p = xbranch 0 +xp 4 2304 16 +xpatch p get oc 0 +xp 1 1 2312 +xrr 133 1 1 +p = xbranch 0 +xp 4 2312 16 +xpatch p get oc 0 +ximm 0 0 +xp 2 0 2304 +xp 2 0 2312 +xp 2 0 2320 +xrr 133 7 7 +p = xbranch 0 +ximm 0 9223372036854775808 +xrr 9 0 7 +xer 1 0 0 +xpatch p get oc 0 +xer 1 0 0 +xpatch skip get oc 0 +xrr 137 6 3 +ximm 0 255 +xrr 33 6 0 +ximm 0 5 +xrr 57 6 0 +xer 0 8 32 +ximm 0 2 +xrr 57 6 0 +opn = xbranch 3 +ximm 0 5 +xrr 57 6 0 +op5 = xbranch 0 +xp 1 1 2304 +xrr 133 1 1 +xer 0 0 35 +ximm 0 4 +xrr 57 6 0 +p = xbranch 1 +ximm 7 0 +xp 1 0 2320 +xrr 133 0 0 +q = xbranch 0 +xp 4 2304 80 +xrr 133 0 0 +rw = xbranch 0 +ximm 7 40 +xpatch rw get oc 0 +xpatch q get oc 0 +ximm 0 0 +rw = xbranch 14 +xpatch rw cleanup +xpatch p get oc 0 +xrr 137 2 3 +xb 72 193 234 +emitb 16 +ximm 0 3 +xrr 57 6 0 +p = xbranch 0 +xp 4 2304 56 +xrr 133 0 0 +xer 0 1 37 +xp 2 13 2336 +xp 0 2 2336 +xrr 137 8 12 +xp 4 2304 32 +xrr 133 0 0 +xer 0 1 37 +xp 1 0 2336 +xer 1 0 0 +xpatch p get oc 0 +xp 1 0 2320 +xrr 133 0 0 +xer 0 0 38 +xp 4 2304 56 +xrr 133 0 0 +xer 0 1 38 +xp 2 13 2336 +xp 0 2 2336 +xrr 137 8 12 +xp 4 2304 40 +xrr 133 0 0 +xer 0 1 38 +xp 1 0 2336 +xrr 57 0 13 +xer 0 1 39 +xrr 137 0 13 +xer 1 0 0 +xpatch opn get oc 0 +xpatch op5 get oc 0 +xp 1 1 2304 +xrr 133 1 1 +xer 0 1 34 +xrr 133 13 13 +xer 0 0 33 +ximm 0 255 +xrr 57 13 0 +xer 0 8 33 +xhraw 0 12 0 1 +ximm 2 92 +xrr 57 0 2 +xer 0 1 33 +xrr 137 8 12 +xrr 137 9 13 +xp 0 10 3584 +lp = get oc 0 +xrr 133 9 9 +p = xbranch 0 +xhraw 0 8 0 1 +ximm 2 32 +xrr 57 0 2 +xer 0 3 33 +ximm 2 126 +xrr 57 0 2 +xer 0 8 33 +xhput 0 10 0 2 +xb 73 131 192 +emitb 1 +xb 73 131 194 +emitb 2 +xb 73 131 233 +emitb 1 +back lp +xpatch p get oc 0 +ximm 0 0 +xhput 0 10 0 2 +xrr 137 0 3 +ximm 2 65280 +xrr 33 0 2 +xrr 57 0 2 +p = xbranch 0 +xvol 0 0 +xrr 137 7 3 +xb 72 193 239 +emitb 8 +ximm 2 255 +xrr 33 7 2 +xvol 2 2312 +q = xbranch 14 +xpatch p get oc 0 +xvol 3 2312 +xpatch q get oc 0 +xrr 137 6 3 +ximm 0 255 +xrr 33 6 0 +ximm 0 1 +xrr 57 6 0 +p = xbranch 1 +note Sub 1: delete an existing file first (UEFI 13.5 Delete closes the handle), then create. +xp 0 8 3584 +xp 0 2 2304 +ximm 9 3 +ximm 0 0 +xmem 137 0 4 32 +xp 4 2312 8 +xrr 133 0 0 +q = xbranch 1 +xp 4 2304 24 +ximm 2 0 +xp 2 2 2304 +xrr 133 0 0 +ximm 7 36 +rw = xbranch 1 +xpatch rw cleanup +xpatch q get oc 0 +ximm 2 0 +xp 2 2 2304 +xfio 0 2312 2304 9223372036854775811 36 cleanup +ximm 0 1 +xp 2 0 2320 +ximm 0 0 +xer 1 0 0 +xpatch p get oc 0 +ximm 0 5 +xrr 57 6 0 +p = xbranch 0 +xfio 0 2312 2304 1 36 cleanup +ximm 0 0 +xp 2 0 2320 +q = xbranch 14 +xpatch p get oc 0 +xfio 0 2312 2304 3 36 cleanup +ximm 0 1 +xp 2 0 2320 +xpatch q get oc 0 +ximm 0 1024 +xp 2 0 2336 +gi = xg 7 +xaddr 2 gi +xp 0 8 2336 +xp 0 9 2560 +xp 4 2304 64 +xrr 133 0 0 +ximm 7 41 +p = xbranch 1 +xpatch p cleanup +xp 1 0 2568 +xp 2 0 2328 +end + + +note Bare x86 units use the same private frame ABI as calls, never the SysV C ABI. +note Each entry is a six-byte JMP/NOP slot; a unit without exports enters its last function. +fn xunit to void +n = get nexp 0 +p = ulong 512 +f = ulong 0 +while lt f get nf 0 +take = ne get fn_exp f 0 +if eq n 0 +take = eq f sub get lastfn 0 1 +end +if take +put out p 233 +wrword add p 1 sub get fn_addr f add p 5 +put out add p 5 144 +p = add p 6 +end +f = add f 1 +end +writeout 512 +end diff --git a/native/toolchain/seed/rung0/load0.sh b/native/toolchain/seed/rung0/load0.sh new file mode 100644 index 0000000..b0449bf --- /dev/null +++ b/native/toolchain/seed/rung0/load0.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# load0.sh -- the one outside tool of the seed chain (named in seed/README.md). +# Used once, to turn the hand-written seed0.hex into seed0.bin before any seed program exists. +# POSIX shell and its printf only (no gcc, as, ld, xxd). Strict: after the comment ('#' to end of line) +# is cut, a line is empty or holds exactly one word of 8 hex digits; anything else stops the load. +# Each word goes out lowest byte first (little-endian), as seed0 itself writes it. +set -eu +[ $# -eq 2 ] || { echo "usage: load0.sh " >&2; exit 2; } +n=0 +: > "$2" +while IFS= read -r line || [ -n "$line" ]; do + n=$((n + 1)) + w=${line%%#*} + w=$(printf '%s' "$w" | tr -d ' \t\r') + [ -z "$w" ] && continue + case $w in + [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]) ;; + *) echo "load0: line $n: not one 8-digit hex word: '$w'" >&2; exit 1 ;; + esac + v=$((0x$w)) + for s in 0 8 16 24; do + printf "\\$(printf '%03o' $(( (v >> s) & 255 )))" + done >> "$2" +done < "$1" diff --git a/native/toolchain/seed/rung0/seed0.hex b/native/toolchain/seed/rung0/seed0.hex new file mode 100644 index 0000000..3c16777 --- /dev/null +++ b/native/toolchain/seed/rung0/seed0.hex @@ -0,0 +1,121 @@ +# seed0.hex -- rung 0 of the Omega seed chain. Written by hand, one 32-bit word per line. +# Language read by seed0: every 8 hex digits make one 32-bit word, written to stdout little-endian +# (lowest byte first, as an AArch64 machine stores it). '#' starts a comment to the end of the line. +# Spaces, tabs and newlines are skipped. Any other character: exit 4. A word cut short at the end: exit 1. +# Instruction bits from the Arm Architecture Reference Manual for A-profile, DDI 0487 revision M.d +# (sections C6.2.n named on each line). ELF fields from the System V gABI ELF-64 layout; e_machine 183 +# (EM_AARCH64) from "ELF for the Arm 64-bit Architecture" (IHI 0056). +# +# ---- ELF-64 file header, 64 bytes = 16 words (word = 4 file bytes, lowest byte first) ---- +464c457f # e_ident[0..3] = 7f 'E' 'L' 'F' (magic) +00010102 # e_ident[4..7] = ELFCLASS64 2, ELFDATA2LSB 1, EV_CURRENT 1, ELFOSABI_NONE 0 +00000000 # e_ident[8..11] = ABI version 0, padding +00000000 # e_ident[12..15] = padding +00b70002 # e_type = 2 (ET_EXEC, low half), e_machine = 183 0xb7 (EM_AARCH64, high half) +00000001 # e_version = 1 (EV_CURRENT) +00400078 # e_entry low 32 bits: 0x400078 = load address 0x400000 + 120 (first instruction) +00000000 # e_entry high 32 bits +00000040 # e_phoff low: program header table at file offset 64 +00000000 # e_phoff high +00000000 # e_shoff low: no section header table +00000000 # e_shoff high +00000000 # e_flags = 0 +00380040 # e_ehsize = 64 (low half), e_phentsize = 56 (high half) +00000001 # e_phnum = 1 (low half), e_shentsize = 0 (high half) +00000000 # e_shnum = 0, e_shstrndx = 0 +# ---- ELF-64 program header (one PT_LOAD), 56 bytes = 14 words ---- +00000001 # p_type = 1 (PT_LOAD) +00000007 # p_flags = 7 (read, write, execute: the work buffer sits in the same mapping) +00000000 # p_offset low: map from file offset 0 +00000000 # p_offset high +00400000 # p_vaddr low: 0x400000 +00000000 # p_vaddr high +00400000 # p_paddr low: 0x400000 (unused on Linux) +00000000 # p_paddr high +00000198 # p_filesz low: 408 bytes = whole file (120 header + 72 instructions * 4) +00000000 # p_filesz high +00011000 # p_memsz low: 0x11000; the bytes past the file are zero, buffers at 0x410000 and 0x410004 +00000000 # p_memsz high +00001000 # p_align low: 4096 (page size) +00000000 # p_align high +# ---- code, 72 words, file offset 0x78 = address 0x400078. Word index in [brackets]. ---- +# registers: x9 = 10, x25 = 1, x23 = input byte buffer 0x410000, x24 = output word buffer 0x410004, +# x19 = word being built, x20 = digits in it, x21 = 1 while inside a comment +d2800149 # [0] movz x9, #10 C6.2.285 MOVZ (64-bit) +d2800039 # [1] movz x25, #1 C6.2.285 MOVZ +d2a00837 # [2] movz x23, #0x41, lsl #16 C6.2.285 MOVZ (hw=1): x23 = 0x410000 +d2800098 # [3] movz x24, #4 C6.2.285 MOVZ +f2a00838 # [4] movk x24, #0x41, lsl #16 C6.2.283 MOVK (hw=1): x24 = 0x410004 +d2800013 # [5] movz x19, #0 C6.2.285 MOVZ +d2800014 # [6] movz x20, #0 C6.2.285 MOVZ +d2800015 # [7] movz x21, #0 C6.2.285 MOVZ +# loop: read one byte +d2800000 # [8] movz x0, #0 (fd 0, stdin) C6.2.285 MOVZ +aa1703e1 # [9] orr x1, xzr, x23 (mov x1,x23) C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d2800022 # [10] movz x2, #1 (one byte) C6.2.285 MOVZ +d28007e8 # [11] movz x8, #63 (Linux read) C6.2.285 MOVZ +d4000001 # [12] svc #0 C6.2.466 SVC +f100001f # [13] subs xzr, x0, #0 (cmp x0, #0) C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000620 # [14] b.eq +49 -> [63] eof C6.2.34 B.cond, cond 0000 EQ (Table C1-1) +5400068b # [15] b.lt +52 -> [67] read failed C6.2.34 B.cond, cond 1011 LT +394002e0 # [16] ldrb w0, [x23] C6.2.220 LDRB (immediate), unsigned offset 0 +b40000b5 # [17] cbz x21, +5 -> [22] C6.2.78 CBZ (64-bit) +# inside a comment: only a newline ends it +7100281f # [18] subs wzr, w0, #10 (cmp '\n') C6.2.464 SUBS (immediate) 32-bit, alias CMP +54fffea1 # [19] b.ne -11 -> [8] loop C6.2.34 B.cond, cond 0001 NE +d2800015 # [20] movz x21, #0 C6.2.285 MOVZ +17fffff3 # [21] b -13 -> [8] loop C6.2.35 B +# not in a comment +71008c1f # [22] subs wzr, w0, #35 (cmp '#') C6.2.464 SUBS (immediate), alias CMP +54000061 # [23] b.ne +3 -> [26] C6.2.34 B.cond NE +d2800035 # [24] movz x21, #1 C6.2.285 MOVZ +17ffffef # [25] b -17 -> [8] loop C6.2.35 B +7100c001 # [26] subs w1, w0, #48 ('0') C6.2.464 SUBS (immediate) +7100283f # [27] subs wzr, w1, #10 C6.2.464 SUBS (immediate), alias CMP +54000203 # [28] b.lo +16 -> [44] digit 0-9 C6.2.34 B.cond, cond 0011 CC/LO +71018401 # [29] subs w1, w0, #97 ('a') C6.2.464 SUBS (immediate) +7100183f # [30] subs wzr, w1, #6 C6.2.464 SUBS (immediate), alias CMP +54000183 # [31] b.lo +12 -> [43] a-f C6.2.34 B.cond LO +71010401 # [32] subs w1, w0, #65 ('A') C6.2.464 SUBS (immediate) +7100183f # [33] subs wzr, w1, #6 C6.2.464 SUBS (immediate), alias CMP +54000123 # [34] b.lo +9 -> [43] A-F C6.2.34 B.cond LO +7100801f # [35] subs wzr, w0, #32 (space) C6.2.464 SUBS (immediate), alias CMP +54fffc80 # [36] b.eq -28 -> [8] loop C6.2.34 B.cond EQ +7100281f # [37] subs wzr, w0, #10 (newline) C6.2.464 SUBS (immediate), alias CMP +54fffc40 # [38] b.eq -30 -> [8] loop C6.2.34 B.cond EQ +7100241f # [39] subs wzr, w0, #9 (tab) C6.2.464 SUBS (immediate), alias CMP +54fffc00 # [40] b.eq -32 -> [8] loop C6.2.34 B.cond EQ +d2800080 # [41] movz x0, #4 (bad character) C6.2.285 MOVZ +1400001c # [42] b +28 -> [70] exit C6.2.35 B +# a hex digit: x1 holds its value (letters get +10 first) +0b090021 # [43] add w1, w1, w9 C6.2.6 ADD (shifted register) 32-bit, no shift +8b130273 # [44] add x19, x19, x19 C6.2.6 ADD (shifted register): x19 * 2 +8b130273 # [45] add x19, x19, x19 C6.2.6 ADD: x19 * 4 +8b130273 # [46] add x19, x19, x19 C6.2.6 ADD: x19 * 8 +8b130273 # [47] add x19, x19, x19 C6.2.6 ADD: x19 * 16 +aa010273 # [48] orr x19, x19, x1 C6.2.302 ORR (shifted register), no shift +8b190294 # [49] add x20, x20, x25 C6.2.6 ADD: one more digit +f100229f # [50] subs xzr, x20, #8 C6.2.464 SUBS (immediate), alias CMP +54fffaa1 # [51] b.ne -43 -> [8] loop C6.2.34 B.cond NE +# eight digits: write the word +b9000313 # [52] str w19, [x24] C6.2.415 STR (immediate) 32-bit, unsigned offset 0 +d2800020 # [53] movz x0, #1 (fd 1, stdout) C6.2.285 MOVZ +aa1803e1 # [54] orr x1, xzr, x24 (mov x1,x24) C6.2.302 ORR (shifted register), alias MOV +d2800082 # [55] movz x2, #4 (four bytes) C6.2.285 MOVZ +d2800808 # [56] movz x8, #64 (Linux write) C6.2.285 MOVZ +d4000001 # [57] svc #0 C6.2.466 SVC +f100101f # [58] subs xzr, x0, #4 C6.2.464 SUBS (immediate), alias CMP +54000141 # [59] b.ne +10 -> [69] write failed C6.2.34 B.cond NE +d2800013 # [60] movz x19, #0 C6.2.285 MOVZ +d2800014 # [61] movz x20, #0 C6.2.285 MOVZ +17ffffca # [62] b -54 -> [8] loop C6.2.35 B +# eof: exit 0, or 1 if a word was cut short +d2800000 # [63] movz x0, #0 C6.2.285 MOVZ +b40000d4 # [64] cbz x20, +6 -> [70] exit C6.2.78 CBZ (64-bit) +d2800020 # [65] movz x0, #1 C6.2.285 MOVZ +14000004 # [66] b +4 -> [70] exit C6.2.35 B +d2800040 # [67] movz x0, #2 (read failed) C6.2.285 MOVZ +14000002 # [68] b +2 -> [70] exit C6.2.35 B +d2800060 # [69] movz x0, #3 (write failed) C6.2.285 MOVZ +d2800ba8 # [70] movz x8, #93 (Linux exit) C6.2.285 MOVZ +d4000001 # [71] svc #0 C6.2.466 SVC diff --git a/native/toolchain/seed/rung1/hex1.hex b/native/toolchain/seed/rung1/hex1.hex new file mode 100644 index 0000000..8ca4d0c --- /dev/null +++ b/native/toolchain/seed/rung1/hex1.hex @@ -0,0 +1,215 @@ +# hex1.hex -- rung 1 of the Omega seed chain, written in seed-0's language (8 hex digits = one word, +# '#' comment to end of line) and built by seed-0: seed0.bin < hex1.hex > hex1.bin. +# hex1 reads seed-0's language plus two marks: +# :c names the place of the next word "c" (c = any one printable character) +# @c right after a word: adds the distance in words from that word to label c into bits 5..23 of it +# (the imm19 field of B.cond, CBZ, CBNZ, LDR literal; and ADR's immhi when the target is a +# whole word away). This is the one relative branch form. +# It reads all its input first, counts words and labels (pass 1), then writes (pass 2), so a label may +# be used before it is named. Exit codes: 0 ok, 1 word cut short, 2 read failed, 3 write failed, +# 4 bad character, 5 label used but never named, 6 label named twice, 7 input over 4 MiB, +# 8 ':' or '@' without a printable label character, 9 mark in the middle of a word, 10 '@' before any word. +# Instruction bits: Arm DDI 0487 M.d, section on each line. Memory: one mapping at 0x400000; +# labels table 0x410000 (256 x 8 bytes), input 0x420000..0x820000, output from 0x820000 (4 MiB). +# Unconditional jumps are B.cond with condition AL (1110, "Always", Table C1-1), so that every branch +# in hex1 uses the imm19 form that hex1 itself understands. +# +# ---- ELF-64 file header, 16 words ---- +464c457f # e_ident[0..3] = 7f 'E' 'L' 'F' +00010102 # e_ident[4..7] = ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE +00000000 # e_ident[8..11] = ABI version 0, padding +00000000 # e_ident[12..15] = padding +00b70002 # e_type = 2 ET_EXEC, e_machine = 183 EM_AARCH64 +00000001 # e_version = 1 +00400078 # e_entry low = 0x400078 (file offset 120) +00000000 # e_entry high +00000040 # e_phoff low = 64 +00000000 # e_phoff high +00000000 # e_shoff low = 0 (no sections) +00000000 # e_shoff high +00000000 # e_flags = 0 +00380040 # e_ehsize = 64, e_phentsize = 56 +00000001 # e_phnum = 1, e_shentsize = 0 +00000000 # e_shnum = 0, e_shstrndx = 0 +# ---- program header, 14 words ---- +00000001 # p_type = PT_LOAD +00000007 # p_flags = read, write, execute +00000000 # p_offset low = 0 +00000000 # p_offset high +00400000 # p_vaddr low = 0x400000 +00000000 # p_vaddr high +00400000 # p_paddr low = 0x400000 +00000000 # p_paddr high +00000308 # p_filesz low = 776 bytes (120 header + 164 instructions * 4) +00000000 # p_filesz high +00820000 # p_memsz low = 0x820000 (tables and buffers up to 0xc20000, zero-filled) +00000000 # p_memsz high +00001000 # p_align low = 4096 +00000000 # p_align high +# ---- code, 164 words from address 0x400078 ---- +# x9=10 x25=1 x26=labels x23=input x24=output (and input limit) x10=0x7ffff x22=pointer x11=input end +# x27=pass (0 count, 1 write) x19=word being built x20=its digits x21=words so far +d2800149 # [0] movz x9, #10 C6.2.285 MOVZ +d2800039 # [1] movz x25, #1 C6.2.285 MOVZ +d2a0083a # [2] movz x26, #0x41, lsl #16 C6.2.285 MOVZ +d2a00857 # [3] movz x23, #0x42, lsl #16 C6.2.285 MOVZ +d2a01058 # [4] movz x24, #0x82, lsl #16 C6.2.285 MOVZ +d29fffea # [5] movz x10, #0xffff C6.2.285 MOVZ +f2a000ea # [6] movk x10, #7, lsl #16 C6.2.283 MOVK +aa1703f6 # [7] orr x22, xzr, x23 C6.2.302 ORR (shifted register) +d2800000 # [8] movz x0, #0 C6.2.285 MOVZ +aa1603e1 # [9] orr x1, xzr, x22 C6.2.302 ORR (shifted register) +cb160302 # [10] sub x2, x24, x22 C6.2.458 SUB (shifted register) +b4001202 # [11] cbz x2, +144 -> [155] fail7 C6.2.78 CBZ +d28007e8 # [12] movz x8, #63 C6.2.285 MOVZ +d4000001 # [13] svc #0 C6.2.466 SVC +f100001f # [14] subs xzr, x0, #0 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000080 # [15] b.eq +4 -> [19] readdone C6.2.34 B.cond (cond 0, Table C1-1) +5400102b # [16] b.lt +129 -> [145] fail2 C6.2.34 B.cond (cond 11, Table C1-1) +8b0002d6 # [17] add x22, x22, x0 C6.2.6 ADD (shifted register) +54fffece # [18] b.al -10 -> [8] readloop C6.2.34 B.cond (cond 14, Table C1-1) +aa1603eb # [19] orr x11, xzr, x22 C6.2.302 ORR (shifted register) +d280001b # [20] movz x27, #0 C6.2.285 MOVZ +aa1703f6 # [21] orr x22, xzr, x23 C6.2.302 ORR (shifted register) +d2800013 # [22] movz x19, #0 C6.2.285 MOVZ +d2800014 # [23] movz x20, #0 C6.2.285 MOVZ +d2800015 # [24] movz x21, #0 C6.2.285 MOVZ +eb0b02df # [25] subs xzr, x22, x11 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000c40 # [26] b.eq +98 -> [124] passend C6.2.34 B.cond (cond 0, Table C1-1) +394002c0 # [27] ldrb w0, [x22] C6.2.220 LDRB (immediate), unsigned offset 0 +8b1902d6 # [28] add x22, x22, x25 C6.2.6 ADD (shifted register) +71008c1f # [29] subs wzr, w0, #35 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +540002a0 # [30] b.eq +21 -> [51] comment C6.2.34 B.cond (cond 0, Table C1-1) +7100e81f # [31] subs wzr, w0, #58 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000340 # [32] b.eq +26 -> [58] deflabel C6.2.34 B.cond (cond 0, Table C1-1) +7101001f # [33] subs wzr, w0, #64 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000520 # [34] b.eq +41 -> [75] reflabel C6.2.34 B.cond (cond 0, Table C1-1) +7100c001 # [35] subs w1, w0, #48 C6.2.464 SUBS (immediate) +7100283f # [36] subs wzr, w1, #10 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +540008c3 # [37] b.lo +70 -> [107] nibble C6.2.34 B.cond (cond 3, Table C1-1) +71018401 # [38] subs w1, w0, #97 C6.2.464 SUBS (immediate) +7100183f # [39] subs wzr, w1, #6 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000843 # [40] b.lo +66 -> [106] letter C6.2.34 B.cond (cond 3, Table C1-1) +71010401 # [41] subs w1, w0, #65 C6.2.464 SUBS (immediate) +7100183f # [42] subs wzr, w1, #6 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +540007e3 # [43] b.lo +63 -> [106] letter C6.2.34 B.cond (cond 3, Table C1-1) +7100801f # [44] subs wzr, w0, #32 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54fffd80 # [45] b.eq -20 -> [25] scan C6.2.34 B.cond (cond 0, Table C1-1) +7100281f # [46] subs wzr, w0, #10 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54fffd40 # [47] b.eq -22 -> [25] scan C6.2.34 B.cond (cond 0, Table C1-1) +7100241f # [48] subs wzr, w0, #9 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54fffd00 # [49] b.eq -24 -> [25] scan C6.2.34 B.cond (cond 0, Table C1-1) +54000c6e # [50] b.al +99 -> [149] fail4 C6.2.34 B.cond (cond 14, Table C1-1) +eb0b02df # [51] subs xzr, x22, x11 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000900 # [52] b.eq +72 -> [124] passend C6.2.34 B.cond (cond 0, Table C1-1) +394002c0 # [53] ldrb w0, [x22] C6.2.220 LDRB (immediate), unsigned offset 0 +8b1902d6 # [54] add x22, x22, x25 C6.2.6 ADD (shifted register) +7100281f # [55] subs wzr, w0, #10 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54ffff61 # [56] b.ne -5 -> [51] comment C6.2.34 B.cond (cond 1, Table C1-1) +54fffc0e # [57] b.al -32 -> [25] scan C6.2.34 B.cond (cond 14, Table C1-1) +eb0b02df # [58] subs xzr, x22, x11 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000c40 # [59] b.eq +98 -> [157] fail8 C6.2.34 B.cond (cond 0, Table C1-1) +394002c3 # [60] ldrb w3, [x22] C6.2.220 LDRB (immediate), unsigned offset 0 +8b1902d6 # [61] add x22, x22, x25 C6.2.6 ADD (shifted register) +7100847f # [62] subs wzr, w3, #33 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000bc3 # [63] b.lo +94 -> [157] fail8 C6.2.34 B.cond (cond 3, Table C1-1) +b5000bf4 # [64] cbnz x20, +95 -> [159] fail9 C6.2.77 CBNZ +b5fffb1b # [65] cbnz x27, -40 -> [25] scan C6.2.77 CBNZ +8b030063 # [66] add x3, x3, x3 C6.2.6 ADD (shifted register) +8b030063 # [67] add x3, x3, x3 C6.2.6 ADD (shifted register) +8b030063 # [68] add x3, x3, x3 C6.2.6 ADD (shifted register) +8b1a0063 # [69] add x3, x3, x26 C6.2.6 ADD (shifted register) +f9400064 # [70] ldr x4, [x3] C6.2.216 LDR (immediate) 64-bit, unsigned offset 0 +b5000a44 # [71] cbnz x4, +82 -> [153] fail6 C6.2.77 CBNZ +8b1902a4 # [72] add x4, x21, x25 C6.2.6 ADD (shifted register) +f9000064 # [73] str x4, [x3] C6.2.415 STR (immediate) 64-bit, unsigned offset 0 +54fff9ee # [74] b.al -49 -> [25] scan C6.2.34 B.cond (cond 14, Table C1-1) +eb0b02df # [75] subs xzr, x22, x11 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000a20 # [76] b.eq +81 -> [157] fail8 C6.2.34 B.cond (cond 0, Table C1-1) +394002c3 # [77] ldrb w3, [x22] C6.2.220 LDRB (immediate), unsigned offset 0 +8b1902d6 # [78] add x22, x22, x25 C6.2.6 ADD (shifted register) +7100847f # [79] subs wzr, w3, #33 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +540009a3 # [80] b.lo +77 -> [157] fail8 C6.2.34 B.cond (cond 3, Table C1-1) +b50009d4 # [81] cbnz x20, +78 -> [159] fail9 C6.2.77 CBNZ +b4fff8fb # [82] cbz x27, -57 -> [25] scan C6.2.78 CBZ +b40009d5 # [83] cbz x21, +78 -> [161] fail10 C6.2.78 CBZ +8b030063 # [84] add x3, x3, x3 C6.2.6 ADD (shifted register) +8b030063 # [85] add x3, x3, x3 C6.2.6 ADD (shifted register) +8b030063 # [86] add x3, x3, x3 C6.2.6 ADD (shifted register) +8b1a0063 # [87] add x3, x3, x26 C6.2.6 ADD (shifted register) +f9400064 # [88] ldr x4, [x3] C6.2.216 LDR (immediate) 64-bit, unsigned offset 0 +b40007c4 # [89] cbz x4, +62 -> [151] fail5 C6.2.78 CBZ +cb190084 # [90] sub x4, x4, x25 C6.2.458 SUB (shifted register) +cb1902a5 # [91] sub x5, x21, x25 C6.2.458 SUB (shifted register) +cb050084 # [92] sub x4, x4, x5 C6.2.458 SUB (shifted register) +8a0a0084 # [93] and x4, x4, x10 C6.2.15 AND (shifted register) +8b040084 # [94] add x4, x4, x4 C6.2.6 ADD (shifted register) +8b040084 # [95] add x4, x4, x4 C6.2.6 ADD (shifted register) +8b040084 # [96] add x4, x4, x4 C6.2.6 ADD (shifted register) +8b040084 # [97] add x4, x4, x4 C6.2.6 ADD (shifted register) +8b040084 # [98] add x4, x4, x4 C6.2.6 ADD (shifted register) +8b0500a5 # [99] add x5, x5, x5 C6.2.6 ADD (shifted register) +8b0500a5 # [100] add x5, x5, x5 C6.2.6 ADD (shifted register) +8b1800a5 # [101] add x5, x5, x24 C6.2.6 ADD (shifted register) +b94000a6 # [102] ldr w6, [x5] C6.2.216 LDR (immediate) 32-bit, unsigned offset 0 +aa0400c6 # [103] orr x6, x6, x4 C6.2.302 ORR (shifted register) +b90000a6 # [104] str w6, [x5] C6.2.415 STR (immediate) 32-bit, unsigned offset 0 +54fff60e # [105] b.al -80 -> [25] scan C6.2.34 B.cond (cond 14, Table C1-1) +0b090021 # [106] add w1, w1, w9 C6.2.6 ADD (shifted register) 32-bit +8b130273 # [107] add x19, x19, x19 C6.2.6 ADD (shifted register) +8b130273 # [108] add x19, x19, x19 C6.2.6 ADD (shifted register) +8b130273 # [109] add x19, x19, x19 C6.2.6 ADD (shifted register) +8b130273 # [110] add x19, x19, x19 C6.2.6 ADD (shifted register) +aa010273 # [111] orr x19, x19, x1 C6.2.302 ORR (shifted register) +8b190294 # [112] add x20, x20, x25 C6.2.6 ADD (shifted register) +f100229f # [113] subs xzr, x20, #8 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54fff4e1 # [114] b.ne -89 -> [25] scan C6.2.34 B.cond (cond 1, Table C1-1) +b40000bb # [115] cbz x27, +5 -> [120] countonly C6.2.78 CBZ +8b1502a5 # [116] add x5, x21, x21 C6.2.6 ADD (shifted register) +8b0500a5 # [117] add x5, x5, x5 C6.2.6 ADD (shifted register) +8b1800a5 # [118] add x5, x5, x24 C6.2.6 ADD (shifted register) +b90000b3 # [119] str w19, [x5] C6.2.415 STR (immediate) 32-bit, unsigned offset 0 +8b1902b5 # [120] add x21, x21, x25 C6.2.6 ADD (shifted register) +d2800013 # [121] movz x19, #0 C6.2.285 MOVZ +d2800014 # [122] movz x20, #0 C6.2.285 MOVZ +54fff3ce # [123] b.al -98 -> [25] scan C6.2.34 B.cond (cond 14, Table C1-1) +b5000274 # [124] cbnz x20, +19 -> [143] fail1 C6.2.77 CBNZ +b500007b # [125] cbnz x27, +3 -> [128] output C6.2.77 CBNZ +d280003b # [126] movz x27, #1 C6.2.285 MOVZ +54fff2ce # [127] b.al -106 -> [21] pass C6.2.34 B.cond (cond 14, Table C1-1) +8b1502a2 # [128] add x2, x21, x21 C6.2.6 ADD (shifted register) +8b020042 # [129] add x2, x2, x2 C6.2.6 ADD (shifted register) +aa1803f6 # [130] orr x22, xzr, x24 C6.2.302 ORR (shifted register) +b4000142 # [131] cbz x2, +10 -> [141] exit0 C6.2.78 CBZ +d2800020 # [132] movz x0, #1 C6.2.285 MOVZ +aa1603e1 # [133] orr x1, xzr, x22 C6.2.302 ORR (shifted register) +d2800808 # [134] movz x8, #64 C6.2.285 MOVZ +d4000001 # [135] svc #0 C6.2.466 SVC +f100001f # [136] subs xzr, x0, #0 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +5400014d # [137] b.le +10 -> [147] fail3 C6.2.34 B.cond (cond 13, Table C1-1) +8b0002d6 # [138] add x22, x22, x0 C6.2.6 ADD (shifted register) +cb000042 # [139] sub x2, x2, x0 C6.2.458 SUB (shifted register) +54fffeee # [140] b.al -9 -> [131] wloop C6.2.34 B.cond (cond 14, Table C1-1) +d2800000 # [141] movz x0, #0 C6.2.285 MOVZ +5400028e # [142] b.al +20 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800020 # [143] movz x0, #1 C6.2.285 MOVZ +5400024e # [144] b.al +18 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800040 # [145] movz x0, #2 C6.2.285 MOVZ +5400020e # [146] b.al +16 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800060 # [147] movz x0, #3 C6.2.285 MOVZ +540001ce # [148] b.al +14 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800080 # [149] movz x0, #4 C6.2.285 MOVZ +5400018e # [150] b.al +12 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d28000a0 # [151] movz x0, #5 C6.2.285 MOVZ +5400014e # [152] b.al +10 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d28000c0 # [153] movz x0, #6 C6.2.285 MOVZ +5400010e # [154] b.al +8 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d28000e0 # [155] movz x0, #7 C6.2.285 MOVZ +540000ce # [156] b.al +6 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800100 # [157] movz x0, #8 C6.2.285 MOVZ +5400008e # [158] b.al +4 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800120 # [159] movz x0, #9 C6.2.285 MOVZ +5400004e # [160] b.al +2 -> [162] exit C6.2.34 B.cond (cond 14, Table C1-1) +d2800140 # [161] movz x0, #10 C6.2.285 MOVZ +d2800ba8 # [162] movz x8, #93 C6.2.285 MOVZ +d4000001 # [163] svc #0 C6.2.466 SVC diff --git a/native/toolchain/seed/rung2/asm2.hex1 b/native/toolchain/seed/rung2/asm2.hex1 new file mode 100644 index 0000000..f27da8d --- /dev/null +++ b/native/toolchain/seed/rung2/asm2.hex1 @@ -0,0 +1,714 @@ +# asm2.hex1 -- rung 2 of the Omega seed chain: "names", a two-pass assembler whose instruction set is +# a readable text table. Written in hex1's language (rung 1: 8-digit words, ':c' labels, '@c' branch +# marks, '#' comments) and built by hex1: hex1.bin < asm2.hex1 > asm2.bin. +# Input language of asm2 (one statement per line, ';' starts a comment, words split by spaces/tabs/commas): +# = name 0xBASE field... table line: an instruction name, its fixed bits, then one field per operand: +# rP (register, 5 bits at bit P), iP.W (unsigned, W bits at P), sP.W (signed), +# lP.W (distance to a label in words, signed, W bits at P), a (ADR byte distance: +# low 2 bits at 29, the rest at 5..23). Width defaults to 5. +# :name a label: the current output position in bytes +# name operand... an instruction from the table; registers x0..x30 w0..w30 xzr wzr sp wsp, +# numbers [-]decimal or [-]0x lower-case hex, labels by name (up to 16 characters) +# .w number / .b number one 32-bit little-endian word / one byte +# Errors print "asm2: line N: error E" on stderr and exit E: 1 read, 2 write, 3 unknown name, 4 too few +# operands, 5 extra words, 6 bad number, 7 bad register, 8 out of range, 9 unknown label, 10 label twice, +# 11 name twice, 12 bad table line, 13 word over 16 characters, 14 not 4-byte aligned, 15 unknown +# directive, 16 table/labels/output full. +# Memory (one mapping at 0x400000): table 0x500000 (1024 x 64 bytes: name 16, base 8, field count 8, +# 8 fields of kind/position/width), labels 0x510000 (8192 x 32 bytes: name 16, position 8), message +# buffer 0x5f0000, input 0x600000, output 0xe00000 (8 MiB). +# +# ---- ELF-64 file header, 16 words ---- +464c457f # e_ident[0..3] = 7f 'E' 'L' 'F' +00010102 # e_ident[4..7] = ELFCLASS64, ELFDATA2LSB, EV_CURRENT, ELFOSABI_NONE +00000000 # e_ident[8..11] = ABI version 0, padding +00000000 # e_ident[12..15] = padding +00b70002 # e_type = 2 ET_EXEC, e_machine = 183 EM_AARCH64 +00000001 # e_version = 1 +00400078 # e_entry low = 0x400078 (file offset 120) +00000000 # e_entry high +00000040 # e_phoff low = 64 +00000000 # e_phoff high +00000000 # e_shoff low = 0 (no sections) +00000000 # e_shoff high +00000000 # e_flags = 0 +00380040 # e_ehsize = 64, e_phentsize = 56 +00000001 # e_phnum = 1, e_shentsize = 0 +00000000 # e_shnum = 0, e_shstrndx = 0 +# ---- program header, 14 words ---- +00000001 # p_type = PT_LOAD +00000007 # p_flags = read, write, execute +00000000 # p_offset low = 0 +00000000 # p_offset high +00400000 # p_vaddr low = 0x400000 +00000000 # p_vaddr high +00400000 # p_paddr low = 0x400000 +00000000 # p_paddr high +000009a0 # p_filesz low = 2464 bytes (120 header + 580 instructions * 4 + 6 data words * 4) +00000000 # p_filesz high +01200000 # p_memsz low = 0x1200000 (tables and buffers up to 0x1600000, zero-filled) +00000000 # p_memsz high +00001000 # p_align low = 4096 +00000000 # p_align high +# ---- code from address 0x400078 ---- +d2a00a1a # [0] movz x26, #0x50, lsl #16 C6.2.285 MOVZ +d2a00a3b # [1] movz x27, #0x51, lsl #16 C6.2.285 MOVZ +d2a00c1d # [2] movz x29, #0x60, lsl #16 C6.2.285 MOVZ +d2a01c1c # [3] movz x28, #0xe0, lsl #16 C6.2.285 MOVZ +aa1d03f3 # [4] orr x19, xzr, x29 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +:a # RD +d2800000 # [5] movz x0, #0 C6.2.285 MOVZ +aa1303e1 # [6] orr x1, xzr, x19 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d1004382 # [7] sub x2, x28, #16 C6.2.457 SUB (immediate) +cb130042 # [8] sub x2, x2, x19 C6.2.458 SUB (shifted register) +d2800031 # [9] movz x17, #1 C6.2.285 MOVZ +b4000002@J # [10] cbz x2, @J C6.2.78 CBZ -> ERR +d28007e8 # [11] movz x8, #63 C6.2.285 MOVZ +d4000001 # [12] svc #0 C6.2.466 SVC +f100001f # [13] subs xzr, x0, #0 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000000@b # [14] b.eq @b C6.2.34 B.cond (cond 0, Table C1-1) -> RDDONE +5400000b@J # [15] b.lt @J C6.2.34 B.cond (cond 11, Table C1-1) -> ERR +8b000273 # [16] add x19, x19, x0 C6.2.6 ADD (shifted register) +5400000e@a # [17] b.al @a C6.2.34 B.cond (cond 14, Table C1-1) -> RD +:b # RDDONE +d2800140 # [18] movz x0, #10 C6.2.285 MOVZ +39000260 # [19] strb w0, [x19] C6.2.417 STRB (immediate), unsigned offset +3900067f # [20] strb wzr, [x19, #1] C6.2.417 STRB (immediate), unsigned offset +d2800015 # [21] movz x21, #0 C6.2.285 MOVZ +:c # PASS +aa1d03f3 # [22] orr x19, xzr, x29 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d2800016 # [23] movz x22, #0 C6.2.285 MOVZ +d2800039 # [24] movz x25, #1 C6.2.285 MOVZ +:d # LINE +1000005e # [25] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@h # [26] b.al @h C6.2.34 B.cond (cond 14, Table C1-1) -> SKIPSP +b4000000@= # [27] cbz x0, @= C6.2.78 CBZ -> PASSEND +7100281f # [28] subs wzr, w0, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@e # [29] b.eq @e C6.2.34 B.cond (cond 0, Table C1-1) -> NL +7100ec1f # [30] subs wzr, w0, #59 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@f # [31] b.eq @f C6.2.34 B.cond (cond 0, Table C1-1) -> SKIPL +7100f41f # [32] subs wzr, w0, #61 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@S # [33] b.eq @S C6.2.34 B.cond (cond 0, Table C1-1) -> TABDEF +7100e81f # [34] subs wzr, w0, #58 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@1 # [35] b.eq @1 C6.2.34 B.cond (cond 0, Table C1-1) -> LABDEF +7100b81f # [36] subs wzr, w0, #46 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@2 # [37] b.eq @2 C6.2.34 B.cond (cond 0, Table C1-1) -> DIR +5400000e@6 # [38] b.al @6 C6.2.34 B.cond (cond 14, Table C1-1) -> INSTR +:e # NL +91000673 # [39] add x19, x19, #1 C6.2.5 ADD (immediate) +91000739 # [40] add x25, x25, #1 C6.2.5 ADD (immediate) +5400000e@d # [41] b.al @d C6.2.34 B.cond (cond 14, Table C1-1) -> LINE +:f # SKIPL +39400260 # [42] ldrb w0, [x19] C6.2.220 LDRB (immediate), unsigned offset +b4000000@d # [43] cbz x0, @d C6.2.78 CBZ -> LINE +7100281f # [44] subs wzr, w0, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@e # [45] b.eq @e C6.2.34 B.cond (cond 0, Table C1-1) -> NL +91000673 # [46] add x19, x19, #1 C6.2.5 ADD (immediate) +5400000e@f # [47] b.al @f C6.2.34 B.cond (cond 14, Table C1-1) -> SKIPL +:g # ENDL +1000005e # [48] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@h # [49] b.al @h C6.2.34 B.cond (cond 14, Table C1-1) -> SKIPSP +b4000000@d # [50] cbz x0, @d C6.2.78 CBZ -> LINE +7100281f # [51] subs wzr, w0, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@e # [52] b.eq @e C6.2.34 B.cond (cond 0, Table C1-1) -> NL +7100ec1f # [53] subs wzr, w0, #59 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@f # [54] b.eq @f C6.2.34 B.cond (cond 0, Table C1-1) -> SKIPL +d28000b1 # [55] movz x17, #5 C6.2.285 MOVZ +5400000e@J # [56] b.al @J C6.2.34 B.cond (cond 14, Table C1-1) -> ERR +:h # SKIPSP +39400260 # [57] ldrb w0, [x19] C6.2.220 LDRB (immediate), unsigned offset +7100801f # [58] subs wzr, w0, #32 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@i # [59] b.eq @i C6.2.34 B.cond (cond 0, Table C1-1) -> SS1 +7100241f # [60] subs wzr, w0, #9 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@i # [61] b.eq @i C6.2.34 B.cond (cond 0, Table C1-1) -> SS1 +7100b01f # [62] subs wzr, w0, #44 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@i # [63] b.eq @i C6.2.34 B.cond (cond 0, Table C1-1) -> SS1 +d65f03c0 # [64] ret C6.2.338 RET (x30) +:i # SS1 +91000673 # [65] add x19, x19, #1 C6.2.5 ADD (immediate) +5400000e@h # [66] b.al @h C6.2.34 B.cond (cond 14, Table C1-1) -> SKIPSP +:j # TOKEN +:k # TK0 +39400260 # [67] ldrb w0, [x19] C6.2.220 LDRB (immediate), unsigned offset +7100801f # [68] subs wzr, w0, #32 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@l # [69] b.eq @l C6.2.34 B.cond (cond 0, Table C1-1) -> TK1 +7100241f # [70] subs wzr, w0, #9 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@l # [71] b.eq @l C6.2.34 B.cond (cond 0, Table C1-1) -> TK1 +7100b01f # [72] subs wzr, w0, #44 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@l # [73] b.eq @l C6.2.34 B.cond (cond 0, Table C1-1) -> TK1 +aa1303ec # [74] orr x12, xzr, x19 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d2800009 # [75] movz x9, #0 C6.2.285 MOVZ +d280000a # [76] movz x10, #0 C6.2.285 MOVZ +d280000b # [77] movz x11, #0 C6.2.285 MOVZ +:m # TK3 +39400260 # [78] ldrb w0, [x19] C6.2.220 LDRB (immediate), unsigned offset +b4000000@p # [79] cbz x0, @p C6.2.78 CBZ -> TKR +7100281f # [80] subs wzr, w0, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@p # [81] b.eq @p C6.2.34 B.cond (cond 0, Table C1-1) -> TKR +7100801f # [82] subs wzr, w0, #32 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@p # [83] b.eq @p C6.2.34 B.cond (cond 0, Table C1-1) -> TKR +7100241f # [84] subs wzr, w0, #9 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@p # [85] b.eq @p C6.2.34 B.cond (cond 0, Table C1-1) -> TKR +7100b01f # [86] subs wzr, w0, #44 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@p # [87] b.eq @p C6.2.34 B.cond (cond 0, Table C1-1) -> TKR +7100ec1f # [88] subs wzr, w0, #59 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@p # [89] b.eq @p C6.2.34 B.cond (cond 0, Table C1-1) -> TKR +d28001b1 # [90] movz x17, #13 C6.2.285 MOVZ +f100417f # [91] subs xzr, x11, #16 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000000@J # [92] b.eq @J C6.2.34 B.cond (cond 0, Table C1-1) -> ERR +f100217f # [93] subs xzr, x11, #8 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000002@n # [94] b.hs @n C6.2.34 B.cond (cond 2, Table C1-1) -> TK4 +8b0b0161 # [95] add x1, x11, x11 C6.2.6 ADD (shifted register) +8b010021 # [96] add x1, x1, x1 C6.2.6 ADD (shifted register) +8b010021 # [97] add x1, x1, x1 C6.2.6 ADD (shifted register) +9ac12002 # [98] lslv x2, x0, x1 C6.2.271 LSLV +aa020129 # [99] orr x9, x9, x2 C6.2.302 ORR (shifted register) +5400000e@o # [100] b.al @o C6.2.34 B.cond (cond 14, Table C1-1) -> TK5 +:n # TK4 +d1002161 # [101] sub x1, x11, #8 C6.2.457 SUB (immediate) +8b010021 # [102] add x1, x1, x1 C6.2.6 ADD (shifted register) +8b010021 # [103] add x1, x1, x1 C6.2.6 ADD (shifted register) +8b010021 # [104] add x1, x1, x1 C6.2.6 ADD (shifted register) +9ac12002 # [105] lslv x2, x0, x1 C6.2.271 LSLV +aa02014a # [106] orr x10, x10, x2 C6.2.302 ORR (shifted register) +:o # TK5 +9100056b # [107] add x11, x11, #1 C6.2.5 ADD (immediate) +91000673 # [108] add x19, x19, #1 C6.2.5 ADD (immediate) +5400000e@m # [109] b.al @m C6.2.34 B.cond (cond 14, Table C1-1) -> TK3 +:p # TKR +d65f03c0 # [110] ret C6.2.338 RET (x30) +:l # TK1 +91000673 # [111] add x19, x19, #1 C6.2.5 ADD (immediate) +5400000e@k # [112] b.al @k C6.2.34 B.cond (cond 14, Table C1-1) -> TK0 +:q # NUM +d28000d1 # [113] movz x17, #6 C6.2.285 MOVZ +b400000b@J # [114] cbz x11, @J C6.2.78 CBZ -> ERR +aa0c03e1 # [115] orr x1, xzr, x12 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +8b0b0182 # [116] add x2, x12, x11 C6.2.6 ADD (shifted register) +d2800003 # [117] movz x3, #0 C6.2.285 MOVZ +d2800000 # [118] movz x0, #0 C6.2.285 MOVZ +39400024 # [119] ldrb w4, [x1] C6.2.220 LDRB (immediate), unsigned offset +7100b49f # [120] subs wzr, w4, #45 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000001@r # [121] b.ne @r C6.2.34 B.cond (cond 1, Table C1-1) -> N1 +d2800023 # [122] movz x3, #1 C6.2.285 MOVZ +91000421 # [123] add x1, x1, #1 C6.2.5 ADD (immediate) +:r # N1 +eb02003f # [124] subs xzr, x1, x2 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@J # [125] b.eq @J C6.2.34 B.cond (cond 0, Table C1-1) -> ERR +39400024 # [126] ldrb w4, [x1] C6.2.220 LDRB (immediate), unsigned offset +7100c09f # [127] subs wzr, w4, #48 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000001@s # [128] b.ne @s C6.2.34 B.cond (cond 1, Table C1-1) -> NDEC +91000425 # [129] add x5, x1, #1 C6.2.5 ADD (immediate) +eb0200bf # [130] subs xzr, x5, x2 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@s # [131] b.eq @s C6.2.34 B.cond (cond 0, Table C1-1) -> NDEC +394000a4 # [132] ldrb w4, [x5] C6.2.220 LDRB (immediate), unsigned offset +7101e09f # [133] subs wzr, w4, #120 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000001@s # [134] b.ne @s C6.2.34 B.cond (cond 1, Table C1-1) -> NDEC +91000821 # [135] add x1, x1, #2 C6.2.5 ADD (immediate) +eb02003f # [136] subs xzr, x1, x2 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@J # [137] b.eq @J C6.2.34 B.cond (cond 0, Table C1-1) -> ERR +:t # NHEX +eb02003f # [138] subs xzr, x1, x2 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@v # [139] b.eq @v C6.2.34 B.cond (cond 0, Table C1-1) -> NEND +39400024 # [140] ldrb w4, [x1] C6.2.220 LDRB (immediate), unsigned offset +7100c085 # [141] subs w5, w4, #48 C6.2.464 SUBS (immediate) 32-bit +710028bf # [142] subs wzr, w5, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000003@u # [143] b.lo @u C6.2.34 B.cond (cond 3, Table C1-1) -> NH1 +71018485 # [144] subs w5, w4, #97 C6.2.464 SUBS (immediate) 32-bit +710018bf # [145] subs wzr, w5, #6 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000002@J # [146] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +910028a5 # [147] add x5, x5, #10 C6.2.5 ADD (immediate) +:u # NH1 +d2800786 # [148] movz x6, #60 C6.2.285 MOVZ +9ac62406 # [149] lsrv x6, x0, x6 C6.2.274 LSRV +b5000006@J # [150] cbnz x6, @J C6.2.77 CBNZ -> ERR +8b000000 # [151] add x0, x0, x0 C6.2.6 ADD (shifted register) +8b000000 # [152] add x0, x0, x0 C6.2.6 ADD (shifted register) +8b000000 # [153] add x0, x0, x0 C6.2.6 ADD (shifted register) +8b000000 # [154] add x0, x0, x0 C6.2.6 ADD (shifted register) +aa050000 # [155] orr x0, x0, x5 C6.2.302 ORR (shifted register) +91000421 # [156] add x1, x1, #1 C6.2.5 ADD (immediate) +5400000e@t # [157] b.al @t C6.2.34 B.cond (cond 14, Table C1-1) -> NHEX +:s # NDEC +eb02003f # [158] subs xzr, x1, x2 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@v # [159] b.eq @v C6.2.34 B.cond (cond 0, Table C1-1) -> NEND +39400024 # [160] ldrb w4, [x1] C6.2.220 LDRB (immediate), unsigned offset +7100c085 # [161] subs w5, w4, #48 C6.2.464 SUBS (immediate) 32-bit +710028bf # [162] subs wzr, w5, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000002@J # [163] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d2800146 # [164] movz x6, #10 C6.2.285 MOVZ +9b067c00 # [165] madd x0, x0, x6, xzr C6.2.275 MADD, alias MUL C6.2.293 +8b050000 # [166] add x0, x0, x5 C6.2.6 ADD (shifted register) +91000421 # [167] add x1, x1, #1 C6.2.5 ADD (immediate) +5400000e@s # [168] b.al @s C6.2.34 B.cond (cond 14, Table C1-1) -> NDEC +:v # NEND +b4000003@w # [169] cbz x3, @w C6.2.78 CBZ -> NRET +cb0003e0 # [170] sub x0, xzr, x0 C6.2.458 SUB (shifted register) +:w # NRET +d65f03c0 # [171] ret C6.2.338 RET (x30) +:x # REG +d28000f1 # [172] movz x17, #7 C6.2.285 MOVZ +d28f4f01 # [173] movz x1, #0x7a78 C6.2.285 MOVZ +f2a00e41 # [174] movk x1, #0x72, lsl #16 C6.2.283 MOVK +eb01013f # [175] subs xzr, x9, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@A # [176] b.eq @A C6.2.34 B.cond (cond 0, Table C1-1) -> R31 +d28f4ee1 # [177] movz x1, #0x7a77 C6.2.285 MOVZ +f2a00e41 # [178] movk x1, #0x72, lsl #16 C6.2.283 MOVK +eb01013f # [179] subs xzr, x9, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@A # [180] b.eq @A C6.2.34 B.cond (cond 0, Table C1-1) -> R31 +d28e0e61 # [181] movz x1, #0x7073 C6.2.285 MOVZ +eb01013f # [182] subs xzr, x9, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@A # [183] b.eq @A C6.2.34 B.cond (cond 0, Table C1-1) -> R31 +d28e6ee1 # [184] movz x1, #0x7377 C6.2.285 MOVZ +f2a00e01 # [185] movk x1, #0x70, lsl #16 C6.2.283 MOVK +eb01013f # [186] subs xzr, x9, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@A # [187] b.eq @A C6.2.34 B.cond (cond 0, Table C1-1) -> R31 +f100097f # [188] subs xzr, x11, #2 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000003@J # [189] b.lo @J C6.2.34 B.cond (cond 3, Table C1-1) -> ERR +f1000d7f # [190] subs xzr, x11, #3 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000008@J # [191] b.hi @J C6.2.34 B.cond (cond 8, Table C1-1) -> ERR +39400181 # [192] ldrb w1, [x12] C6.2.220 LDRB (immediate), unsigned offset +7101e03f # [193] subs wzr, w1, #120 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@y # [194] b.eq @y C6.2.34 B.cond (cond 0, Table C1-1) -> R1 +7101dc3f # [195] subs wzr, w1, #119 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000001@J # [196] b.ne @J C6.2.34 B.cond (cond 1, Table C1-1) -> ERR +:y # R1 +39400581 # [197] ldrb w1, [x12, #1] C6.2.220 LDRB (immediate), unsigned offset +7100c021 # [198] subs w1, w1, #48 C6.2.464 SUBS (immediate) 32-bit +7100283f # [199] subs wzr, w1, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000002@J # [200] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +f100097f # [201] subs xzr, x11, #2 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000000@z # [202] b.eq @z C6.2.34 B.cond (cond 0, Table C1-1) -> R2 +39400982 # [203] ldrb w2, [x12, #2] C6.2.220 LDRB (immediate), unsigned offset +7100c042 # [204] subs w2, w2, #48 C6.2.464 SUBS (immediate) 32-bit +7100285f # [205] subs wzr, w2, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000002@J # [206] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +b4000001@J # [207] cbz x1, @J C6.2.78 CBZ -> ERR +d2800143 # [208] movz x3, #10 C6.2.285 MOVZ +9b037c21 # [209] madd x1, x1, x3, xzr C6.2.275 MADD, alias MUL C6.2.293 +8b020021 # [210] add x1, x1, x2 C6.2.6 ADD (shifted register) +:z # R2 +f1007c3f # [211] subs xzr, x1, #31 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000002@J # [212] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +aa0103e0 # [213] orr x0, xzr, x1 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d65f03c0 # [214] ret C6.2.338 RET (x30) +:A # R31 +d28003e0 # [215] movz x0, #31 C6.2.285 MOVZ +d65f03c0 # [216] ret C6.2.338 RET (x30) +:B # FINDTAB +aa1a03ed # [217] orr x13, xzr, x26 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d280000f # [218] movz x15, #0 C6.2.285 MOVZ +:C # FT1 +eb1701ff # [219] subs xzr, x15, x23 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@E # [220] b.eq @E C6.2.34 B.cond (cond 0, Table C1-1) -> FT0 +f94001a1 # [221] ldr x1, [x13] C6.2.216 LDR (immediate) 64-bit, unsigned offset +f94005a2 # [222] ldr x2, [x13, #8] C6.2.216 LDR (immediate) 64-bit, unsigned offset +eb09003f # [223] subs xzr, x1, x9 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000001@D # [224] b.ne @D C6.2.34 B.cond (cond 1, Table C1-1) -> FT2 +eb0a005f # [225] subs xzr, x2, x10 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000001@D # [226] b.ne @D C6.2.34 B.cond (cond 1, Table C1-1) -> FT2 +d65f03c0 # [227] ret C6.2.338 RET (x30) +:D # FT2 +910101ad # [228] add x13, x13, #64 C6.2.5 ADD (immediate) +910005ef # [229] add x15, x15, #1 C6.2.5 ADD (immediate) +5400000e@C # [230] b.al @C C6.2.34 B.cond (cond 14, Table C1-1) -> FT1 +:E # FT0 +d280000d # [231] movz x13, #0 C6.2.285 MOVZ +d65f03c0 # [232] ret C6.2.338 RET (x30) +:F # FINDSYM +aa1b03ed # [233] orr x13, xzr, x27 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d280000f # [234] movz x15, #0 C6.2.285 MOVZ +:G # FS1 +eb1801ff # [235] subs xzr, x15, x24 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@I # [236] b.eq @I C6.2.34 B.cond (cond 0, Table C1-1) -> FS0 +f94001a1 # [237] ldr x1, [x13] C6.2.216 LDR (immediate) 64-bit, unsigned offset +f94005a2 # [238] ldr x2, [x13, #8] C6.2.216 LDR (immediate) 64-bit, unsigned offset +eb09003f # [239] subs xzr, x1, x9 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000001@H # [240] b.ne @H C6.2.34 B.cond (cond 1, Table C1-1) -> FS2 +eb0a005f # [241] subs xzr, x2, x10 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000001@H # [242] b.ne @H C6.2.34 B.cond (cond 1, Table C1-1) -> FS2 +d65f03c0 # [243] ret C6.2.338 RET (x30) +:H # FS2 +910081ad # [244] add x13, x13, #32 C6.2.5 ADD (immediate) +910005ef # [245] add x15, x15, #1 C6.2.5 ADD (immediate) +5400000e@G # [246] b.al @G C6.2.34 B.cond (cond 14, Table C1-1) -> FS1 +:I # FS0 +d280000d # [247] movz x13, #0 C6.2.285 MOVZ +d65f03c0 # [248] ret C6.2.338 RET (x30) +:J # ERR +d2a00bef # [249] movz x15, #0x5f, lsl #16 C6.2.285 MOVZ +10000001@Q # [250] adr x1, @Q C6.2.12 ADR (word-aligned target, immlo 0) -> MSG1 +1000005e # [251] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@K # [252] b.al @K C6.2.34 B.cond (cond 14, Table C1-1) -> COPYZ +aa1903e0 # [253] orr x0, xzr, x25 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +1000005e # [254] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@M # [255] b.al @M C6.2.34 B.cond (cond 14, Table C1-1) -> PUTDEC +10000001@R # [256] adr x1, @R C6.2.12 ADR (word-aligned target, immlo 0) -> MSG2 +1000005e # [257] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@K # [258] b.al @K C6.2.34 B.cond (cond 14, Table C1-1) -> COPYZ +aa1103e0 # [259] orr x0, xzr, x17 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +1000005e # [260] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@M # [261] b.al @M C6.2.34 B.cond (cond 14, Table C1-1) -> PUTDEC +d2800140 # [262] movz x0, #10 C6.2.285 MOVZ +390001e0 # [263] strb w0, [x15] C6.2.417 STRB (immediate), unsigned offset +910005ef # [264] add x15, x15, #1 C6.2.5 ADD (immediate) +d2800040 # [265] movz x0, #2 C6.2.285 MOVZ +d2a00be1 # [266] movz x1, #0x5f, lsl #16 C6.2.285 MOVZ +cb0101e2 # [267] sub x2, x15, x1 C6.2.458 SUB (shifted register) +d2800808 # [268] movz x8, #64 C6.2.285 MOVZ +d4000001 # [269] svc #0 C6.2.466 SVC +aa1103e0 # [270] orr x0, xzr, x17 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d2800ba8 # [271] movz x8, #93 C6.2.285 MOVZ +d4000001 # [272] svc #0 C6.2.466 SVC +:K # COPYZ +39400022 # [273] ldrb w2, [x1] C6.2.220 LDRB (immediate), unsigned offset +b4000002@L # [274] cbz x2, @L C6.2.78 CBZ -> CZR +390001e2 # [275] strb w2, [x15] C6.2.417 STRB (immediate), unsigned offset +910005ef # [276] add x15, x15, #1 C6.2.5 ADD (immediate) +91000421 # [277] add x1, x1, #1 C6.2.5 ADD (immediate) +5400000e@K # [278] b.al @K C6.2.34 B.cond (cond 14, Table C1-1) -> COPYZ +:L # CZR +d65f03c0 # [279] ret C6.2.338 RET (x30) +:M # PUTDEC +d2802803 # [280] movz x3, #0x140 C6.2.285 MOVZ +f2a00be3 # [281] movk x3, #0x5f, lsl #16 C6.2.283 MOVK +d2800144 # [282] movz x4, #10 C6.2.285 MOVZ +aa0303e5 # [283] orr x5, xzr, x3 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +:N # PD1 +9ac40806 # [284] udiv x6, x0, x4 C6.2.490 UDIV +9b0480c7 # [285] msub x7, x6, x4, x0 C6.2.291 MSUB +9100c0e7 # [286] add x7, x7, #48 C6.2.5 ADD (immediate) +d10004a5 # [287] sub x5, x5, #1 C6.2.457 SUB (immediate) +390000a7 # [288] strb w7, [x5] C6.2.417 STRB (immediate), unsigned offset +aa0603e0 # [289] orr x0, xzr, x6 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +b5000000@N # [290] cbnz x0, @N C6.2.77 CBNZ -> PD1 +:O # PD2 +eb0300bf # [291] subs xzr, x5, x3 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@P # [292] b.eq @P C6.2.34 B.cond (cond 0, Table C1-1) -> PDR +394000a7 # [293] ldrb w7, [x5] C6.2.220 LDRB (immediate), unsigned offset +390001e7 # [294] strb w7, [x15] C6.2.417 STRB (immediate), unsigned offset +910005ef # [295] add x15, x15, #1 C6.2.5 ADD (immediate) +910004a5 # [296] add x5, x5, #1 C6.2.5 ADD (immediate) +5400000e@O # [297] b.al @O C6.2.34 B.cond (cond 14, Table C1-1) -> PD2 +:P # PDR +d65f03c0 # [298] ret C6.2.338 RET (x30) +:S # TABDEF +91000673 # [299] add x19, x19, #1 C6.2.5 ADD (immediate) +b5000015@f # [300] cbnz x21, @f C6.2.77 CBNZ -> SKIPL +1000005e # [301] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [302] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +d2800191 # [303] movz x17, #12 C6.2.285 MOVZ +b400000b@J # [304] cbz x11, @J C6.2.78 CBZ -> ERR +1000005e # [305] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@B # [306] b.al @B C6.2.34 B.cond (cond 14, Table C1-1) -> FINDTAB +d2800171 # [307] movz x17, #11 C6.2.285 MOVZ +b500000d@J # [308] cbnz x13, @J C6.2.77 CBNZ -> ERR +d2800211 # [309] movz x17, #16 C6.2.285 MOVZ +d2808001 # [310] movz x1, #1024 C6.2.285 MOVZ +eb0102ff # [311] subs xzr, x23, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [312] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d2800801 # [313] movz x1, #64 C6.2.285 MOVZ +9b017eed # [314] madd x13, x23, x1, xzr C6.2.275 MADD, alias MUL C6.2.293 +8b1a01ad # [315] add x13, x13, x26 C6.2.6 ADD (shifted register) +f90001a9 # [316] str x9, [x13] C6.2.415 STR (immediate) 64-bit, unsigned offset +f90005aa # [317] str x10, [x13, #8] C6.2.415 STR (immediate) 64-bit, unsigned offset +1000005e # [318] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [319] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +1000005e # [320] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@q # [321] b.al @q C6.2.34 B.cond (cond 14, Table C1-1) -> NUM +f90009a0 # [322] str x0, [x13, #16] C6.2.415 STR (immediate) 64-bit, unsigned offset +d280000e # [323] movz x14, #0 C6.2.285 MOVZ +:T # TD1 +1000005e # [324] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [325] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +b400000b@0 # [326] cbz x11, @0 C6.2.78 CBZ -> TD9 +d2800211 # [327] movz x17, #16 C6.2.285 MOVZ +f10021df # [328] subs xzr, x14, #8 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000002@J # [329] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d2800191 # [330] movz x17, #12 C6.2.285 MOVZ +39400181 # [331] ldrb w1, [x12] C6.2.220 LDRB (immediate), unsigned offset +7101c83f # [332] subs wzr, w1, #114 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@U # [333] b.eq @U C6.2.34 B.cond (cond 0, Table C1-1) -> TD2 +7101a43f # [334] subs wzr, w1, #105 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@U # [335] b.eq @U C6.2.34 B.cond (cond 0, Table C1-1) -> TD2 +7101cc3f # [336] subs wzr, w1, #115 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@U # [337] b.eq @U C6.2.34 B.cond (cond 0, Table C1-1) -> TD2 +7101b03f # [338] subs wzr, w1, #108 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@U # [339] b.eq @U C6.2.34 B.cond (cond 0, Table C1-1) -> TD2 +7101843f # [340] subs wzr, w1, #97 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000001@J # [341] b.ne @J C6.2.34 B.cond (cond 1, Table C1-1) -> ERR +:U # TD2 +91000582 # [342] add x2, x12, #1 C6.2.5 ADD (immediate) +8b0b0183 # [343] add x3, x12, x11 C6.2.6 ADD (shifted register) +d2800004 # [344] movz x4, #0 C6.2.285 MOVZ +d2800146 # [345] movz x6, #10 C6.2.285 MOVZ +eb03005f # [346] subs xzr, x2, x3 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@Y # [347] b.eq @Y C6.2.34 B.cond (cond 0, Table C1-1) -> TD5 +:V # TD3 +eb03005f # [348] subs xzr, x2, x3 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@Y # [349] b.eq @Y C6.2.34 B.cond (cond 0, Table C1-1) -> TD5 +39400045 # [350] ldrb w5, [x2] C6.2.220 LDRB (immediate), unsigned offset +7100b8bf # [351] subs wzr, w5, #46 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@W # [352] b.eq @W C6.2.34 B.cond (cond 0, Table C1-1) -> TD4 +7100c0a5 # [353] subs w5, w5, #48 C6.2.464 SUBS (immediate) 32-bit +710028bf # [354] subs wzr, w5, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000002@J # [355] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +9b067c84 # [356] madd x4, x4, x6, xzr C6.2.275 MADD, alias MUL C6.2.293 +8b050084 # [357] add x4, x4, x5 C6.2.6 ADD (shifted register) +91000442 # [358] add x2, x2, #1 C6.2.5 ADD (immediate) +5400000e@V # [359] b.al @V C6.2.34 B.cond (cond 14, Table C1-1) -> TD3 +:W # TD4 +91000442 # [360] add x2, x2, #1 C6.2.5 ADD (immediate) +d2800007 # [361] movz x7, #0 C6.2.285 MOVZ +:X # TD4A +eb03005f # [362] subs xzr, x2, x3 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@Z # [363] b.eq @Z C6.2.34 B.cond (cond 0, Table C1-1) -> TD6 +39400045 # [364] ldrb w5, [x2] C6.2.220 LDRB (immediate), unsigned offset +7100c0a5 # [365] subs w5, w5, #48 C6.2.464 SUBS (immediate) 32-bit +710028bf # [366] subs wzr, w5, #10 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000002@J # [367] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +9b067ce7 # [368] madd x7, x7, x6, xzr C6.2.275 MADD, alias MUL C6.2.293 +8b0500e7 # [369] add x7, x7, x5 C6.2.6 ADD (shifted register) +91000442 # [370] add x2, x2, #1 C6.2.5 ADD (immediate) +5400000e@X # [371] b.al @X C6.2.34 B.cond (cond 14, Table C1-1) -> TD4A +:Y # TD5 +d28000a7 # [372] movz x7, #5 C6.2.285 MOVZ +:Z # TD6 +8b070085 # [373] add x5, x4, x7 C6.2.6 ADD (shifted register) +f10084bf # [374] subs xzr, x5, #33 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000002@J # [375] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +8b0e01c8 # [376] add x8, x14, x14 C6.2.6 ADD (shifted register) +8b080108 # [377] add x8, x8, x8 C6.2.6 ADD (shifted register) +8b0d0108 # [378] add x8, x8, x13 C6.2.6 ADD (shifted register) +39008101 # [379] strb w1, [x8, #32] C6.2.417 STRB (immediate), unsigned offset +39008504 # [380] strb w4, [x8, #33] C6.2.417 STRB (immediate), unsigned offset +39008907 # [381] strb w7, [x8, #34] C6.2.417 STRB (immediate), unsigned offset +910005ce # [382] add x14, x14, #1 C6.2.5 ADD (immediate) +5400000e@T # [383] b.al @T C6.2.34 B.cond (cond 14, Table C1-1) -> TD1 +:0 # TD9 +f9000dae # [384] str x14, [x13, #24] C6.2.415 STR (immediate) 64-bit, unsigned offset +910006f7 # [385] add x23, x23, #1 C6.2.5 ADD (immediate) +5400000e@g # [386] b.al @g C6.2.34 B.cond (cond 14, Table C1-1) -> ENDL +:1 # LABDEF +91000673 # [387] add x19, x19, #1 C6.2.5 ADD (immediate) +1000005e # [388] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [389] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +d2800191 # [390] movz x17, #12 C6.2.285 MOVZ +b400000b@J # [391] cbz x11, @J C6.2.78 CBZ -> ERR +b5000015@g # [392] cbnz x21, @g C6.2.77 CBNZ -> ENDL +1000005e # [393] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@F # [394] b.al @F C6.2.34 B.cond (cond 14, Table C1-1) -> FINDSYM +d2800151 # [395] movz x17, #10 C6.2.285 MOVZ +b500000d@J # [396] cbnz x13, @J C6.2.77 CBNZ -> ERR +d2800211 # [397] movz x17, #16 C6.2.285 MOVZ +d2840001 # [398] movz x1, #8192 C6.2.285 MOVZ +eb01031f # [399] subs xzr, x24, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [400] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d2800401 # [401] movz x1, #32 C6.2.285 MOVZ +9b017f0d # [402] madd x13, x24, x1, xzr C6.2.275 MADD, alias MUL C6.2.293 +8b1b01ad # [403] add x13, x13, x27 C6.2.6 ADD (shifted register) +f90001a9 # [404] str x9, [x13] C6.2.415 STR (immediate) 64-bit, unsigned offset +f90005aa # [405] str x10, [x13, #8] C6.2.415 STR (immediate) 64-bit, unsigned offset +f90009b6 # [406] str x22, [x13, #16] C6.2.415 STR (immediate) 64-bit, unsigned offset +91000718 # [407] add x24, x24, #1 C6.2.5 ADD (immediate) +5400000e@g # [408] b.al @g C6.2.34 B.cond (cond 14, Table C1-1) -> ENDL +:2 # DIR +1000005e # [409] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [410] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +d28001f1 # [411] movz x17, #15 C6.2.285 MOVZ +f100097f # [412] subs xzr, x11, #2 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +54000001@J # [413] b.ne @J C6.2.34 B.cond (cond 1, Table C1-1) -> ERR +d28ee5c1 # [414] movz x1, #0x772e C6.2.285 MOVZ +eb01013f # [415] subs xzr, x9, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000000@3 # [416] b.eq @3 C6.2.34 B.cond (cond 0, Table C1-1) -> DW +d28c45c1 # [417] movz x1, #0x622e C6.2.285 MOVZ +eb01013f # [418] subs xzr, x9, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000001@J # [419] b.ne @J C6.2.34 B.cond (cond 1, Table C1-1) -> ERR +1000005e # [420] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [421] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +1000005e # [422] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@q # [423] b.al @q C6.2.34 B.cond (cond 14, Table C1-1) -> NUM +d2800111 # [424] movz x17, #8 C6.2.285 MOVZ +d2802001 # [425] movz x1, #256 C6.2.285 MOVZ +eb01001f # [426] subs xzr, x0, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [427] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d2800211 # [428] movz x17, #16 C6.2.285 MOVZ +d2a01001 # [429] movz x1, #0x80, lsl #16 C6.2.285 MOVZ +eb0102df # [430] subs xzr, x22, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [431] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +8b160381 # [432] add x1, x28, x22 C6.2.6 ADD (shifted register) +39000020 # [433] strb w0, [x1] C6.2.417 STRB (immediate), unsigned offset +910006d6 # [434] add x22, x22, #1 C6.2.5 ADD (immediate) +5400000e@g # [435] b.al @g C6.2.34 B.cond (cond 14, Table C1-1) -> ENDL +:3 # DW +1000005e # [436] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [437] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +1000005e # [438] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@q # [439] b.al @q C6.2.34 B.cond (cond 14, Table C1-1) -> NUM +d2800111 # [440] movz x17, #8 C6.2.285 MOVZ +d2800401 # [441] movz x1, #32 C6.2.285 MOVZ +9ac12402 # [442] lsrv x2, x0, x1 C6.2.274 LSRV +b4000002@4 # [443] cbz x2, @4 C6.2.78 CBZ -> DW1 +d28003e1 # [444] movz x1, #31 C6.2.285 MOVZ +9ac12802 # [445] asrv x2, x0, x1 C6.2.21 ASRV +91000442 # [446] add x2, x2, #1 C6.2.5 ADD (immediate) +b5000002@J # [447] cbnz x2, @J C6.2.77 CBNZ -> ERR +:4 # DW1 +aa0003f0 # [448] orr x16, xzr, x0 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +:5 # STORE +d28001d1 # [449] movz x17, #14 C6.2.285 MOVZ +d28007c1 # [450] movz x1, #62 C6.2.285 MOVZ +9ac122c2 # [451] lslv x2, x22, x1 C6.2.271 LSLV +b5000002@J # [452] cbnz x2, @J C6.2.77 CBNZ -> ERR +d2800211 # [453] movz x17, #16 C6.2.285 MOVZ +d2a01001 # [454] movz x1, #0x80, lsl #16 C6.2.285 MOVZ +eb0102df # [455] subs xzr, x22, x1 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [456] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +8b160381 # [457] add x1, x28, x22 C6.2.6 ADD (shifted register) +b9000030 # [458] str w16, [x1] C6.2.415 STR (immediate) 32-bit, unsigned offset +910012d6 # [459] add x22, x22, #4 C6.2.5 ADD (immediate) +5400000e@g # [460] b.al @g C6.2.34 B.cond (cond 14, Table C1-1) -> ENDL +:6 # INSTR +1000005e # [461] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [462] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +1000005e # [463] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@B # [464] b.al @B C6.2.34 B.cond (cond 14, Table C1-1) -> FINDTAB +d2800071 # [465] movz x17, #3 C6.2.285 MOVZ +b400000d@J # [466] cbz x13, @J C6.2.78 CBZ -> ERR +f94009b0 # [467] ldr x16, [x13, #16] C6.2.216 LDR (immediate) 64-bit, unsigned offset +f9400dae # [468] ldr x14, [x13, #24] C6.2.216 LDR (immediate) 64-bit, unsigned offset +910081b2 # [469] add x18, x13, #32 C6.2.5 ADD (immediate) +:7 # IF1 +b400000e@< # [470] cbz x14, @< C6.2.78 CBZ -> IDONE +1000005e # [471] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@j # [472] b.al @j C6.2.34 B.cond (cond 14, Table C1-1) -> TOKEN +d2800091 # [473] movz x17, #4 C6.2.285 MOVZ +b400000b@J # [474] cbz x11, @J C6.2.78 CBZ -> ERR +39400241 # [475] ldrb w1, [x18] C6.2.220 LDRB (immediate), unsigned offset +7101c83f # [476] subs wzr, w1, #114 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@8 # [477] b.eq @8 C6.2.34 B.cond (cond 0, Table C1-1) -> FR +7101a43f # [478] subs wzr, w1, #105 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@9 # [479] b.eq @9 C6.2.34 B.cond (cond 0, Table C1-1) -> FI +7101cc3f # [480] subs wzr, w1, #115 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@$ # [481] b.eq @$ C6.2.34 B.cond (cond 0, Table C1-1) -> FS +7101b03f # [482] subs wzr, w1, #108 C6.2.464 SUBS (immediate) 32-bit, alias CMP C6.2.96 +54000000@& # [483] b.eq @& C6.2.34 B.cond (cond 0, Table C1-1) -> FL +5400000e@+ # [484] b.al @+ C6.2.34 B.cond (cond 14, Table C1-1) -> FA +:8 # FR +1000005e # [485] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@x # [486] b.al @x C6.2.34 B.cond (cond 14, Table C1-1) -> REG +5400000e@! # [487] b.al @! C6.2.34 B.cond (cond 14, Table C1-1) -> FU +:9 # FI +1000005e # [488] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@q # [489] b.al @q C6.2.34 B.cond (cond 14, Table C1-1) -> NUM +:! # FU +39400a43 # [490] ldrb w3, [x18, #2] C6.2.220 LDRB (immediate), unsigned offset +d2800024 # [491] movz x4, #1 C6.2.285 MOVZ +9ac32084 # [492] lslv x4, x4, x3 C6.2.271 LSLV +d2800111 # [493] movz x17, #8 C6.2.285 MOVZ +eb04001f # [494] subs xzr, x0, x4 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [495] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +5400000e@- # [496] b.al @- C6.2.34 B.cond (cond 14, Table C1-1) -> FINS +:$ # FS +1000005e # [497] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@q # [498] b.al @q C6.2.34 B.cond (cond 14, Table C1-1) -> NUM +:% # FSC +39400a43 # [499] ldrb w3, [x18, #2] C6.2.220 LDRB (immediate), unsigned offset +d2800024 # [500] movz x4, #1 C6.2.285 MOVZ +9ac32084 # [501] lslv x4, x4, x3 C6.2.271 LSLV +d2800025 # [502] movz x5, #1 C6.2.285 MOVZ +9ac52485 # [503] lsrv x5, x4, x5 C6.2.274 LSRV +8b050006 # [504] add x6, x0, x5 C6.2.6 ADD (shifted register) +d2800111 # [505] movz x17, #8 C6.2.285 MOVZ +eb0400df # [506] subs xzr, x6, x4 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [507] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d1000484 # [508] sub x4, x4, #1 C6.2.457 SUB (immediate) +8a040000 # [509] and x0, x0, x4 C6.2.15 AND (shifted register) +5400000e@- # [510] b.al @- C6.2.34 B.cond (cond 14, Table C1-1) -> FINS +:& # FL +b4000015@. # [511] cbz x21, @. C6.2.78 CBZ -> FL0 +1000005e # [512] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@F # [513] b.al @F C6.2.34 B.cond (cond 14, Table C1-1) -> FINDSYM +d2800131 # [514] movz x17, #9 C6.2.285 MOVZ +b400000d@J # [515] cbz x13, @J C6.2.78 CBZ -> ERR +f94009a0 # [516] ldr x0, [x13, #16] C6.2.216 LDR (immediate) 64-bit, unsigned offset +cb160000 # [517] sub x0, x0, x22 C6.2.458 SUB (shifted register) +d28001d1 # [518] movz x17, #14 C6.2.285 MOVZ +d28007c1 # [519] movz x1, #62 C6.2.285 MOVZ +9ac12002 # [520] lslv x2, x0, x1 C6.2.271 LSLV +b5000002@J # [521] cbnz x2, @J C6.2.77 CBNZ -> ERR +d2800041 # [522] movz x1, #2 C6.2.285 MOVZ +9ac12800 # [523] asrv x0, x0, x1 C6.2.21 ASRV +5400000e@% # [524] b.al @% C6.2.34 B.cond (cond 14, Table C1-1) -> FSC +:. # FL0 +d2800000 # [525] movz x0, #0 C6.2.285 MOVZ +5400000e@- # [526] b.al @- C6.2.34 B.cond (cond 14, Table C1-1) -> FINS +:+ # FA +b4000015@/ # [527] cbz x21, @/ C6.2.78 CBZ -> FNEXT +1000005e # [528] adr x30, +2 C6.2.12 ADR: return point = after the next word +5400000e@F # [529] b.al @F C6.2.34 B.cond (cond 14, Table C1-1) -> FINDSYM +d2800131 # [530] movz x17, #9 C6.2.285 MOVZ +b400000d@J # [531] cbz x13, @J C6.2.78 CBZ -> ERR +f94009a0 # [532] ldr x0, [x13, #16] C6.2.216 LDR (immediate) 64-bit, unsigned offset +cb160000 # [533] sub x0, x0, x22 C6.2.458 SUB (shifted register) +d2a00404 # [534] movz x4, #0x20, lsl #16 C6.2.285 MOVZ +d2a00205 # [535] movz x5, #0x10, lsl #16 C6.2.285 MOVZ +8b050006 # [536] add x6, x0, x5 C6.2.6 ADD (shifted register) +d2800111 # [537] movz x17, #8 C6.2.285 MOVZ +eb0400df # [538] subs xzr, x6, x4 C6.2.465 SUBS (shifted register), alias CMP C6.2.97 +54000002@J # [539] b.hs @J C6.2.34 B.cond (cond 2, Table C1-1) -> ERR +d28007c1 # [540] movz x1, #62 C6.2.285 MOVZ +9ac12002 # [541] lslv x2, x0, x1 C6.2.271 LSLV +d2800421 # [542] movz x1, #33 C6.2.285 MOVZ +9ac12442 # [543] lsrv x2, x2, x1 C6.2.274 LSRV +aa020210 # [544] orr x16, x16, x2 C6.2.302 ORR (shifted register) +d2800041 # [545] movz x1, #2 C6.2.285 MOVZ +9ac12803 # [546] asrv x3, x0, x1 C6.2.21 ASRV +d28005a1 # [547] movz x1, #45 C6.2.285 MOVZ +9ac12063 # [548] lslv x3, x3, x1 C6.2.271 LSLV +d2800501 # [549] movz x1, #40 C6.2.285 MOVZ +9ac12463 # [550] lsrv x3, x3, x1 C6.2.274 LSRV +aa030210 # [551] orr x16, x16, x3 C6.2.302 ORR (shifted register) +5400000e@/ # [552] b.al @/ C6.2.34 B.cond (cond 14, Table C1-1) -> FNEXT +:- # FINS +39400642 # [553] ldrb w2, [x18, #1] C6.2.220 LDRB (immediate), unsigned offset +9ac22000 # [554] lslv x0, x0, x2 C6.2.271 LSLV +aa000210 # [555] orr x16, x16, x0 C6.2.302 ORR (shifted register) +:/ # FNEXT +91001252 # [556] add x18, x18, #4 C6.2.5 ADD (immediate) +d10005ce # [557] sub x14, x14, #1 C6.2.457 SUB (immediate) +5400000e@7 # [558] b.al @7 C6.2.34 B.cond (cond 14, Table C1-1) -> IF1 +:< # IDONE +5400000e@5 # [559] b.al @5 C6.2.34 B.cond (cond 14, Table C1-1) -> STORE +:= # PASSEND +b5000015@> # [560] cbnz x21, @> C6.2.77 CBNZ -> OUTP +d2800035 # [561] movz x21, #1 C6.2.285 MOVZ +5400000e@c # [562] b.al @c C6.2.34 B.cond (cond 14, Table C1-1) -> PASS +:> # OUTP +aa1c03f4 # [563] orr x20, xzr, x28 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +aa1603ee # [564] orr x14, xzr, x22 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +:_ # WL +b400000e@^ # [565] cbz x14, @^ C6.2.78 CBZ -> EXIT0 +d2800020 # [566] movz x0, #1 C6.2.285 MOVZ +aa1403e1 # [567] orr x1, xzr, x20 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +aa0e03e2 # [568] orr x2, xzr, x14 C6.2.302 ORR (shifted register), alias MOV C6.2.282 +d2800808 # [569] movz x8, #64 C6.2.285 MOVZ +d4000001 # [570] svc #0 C6.2.466 SVC +d2800051 # [571] movz x17, #2 C6.2.285 MOVZ +f100001f # [572] subs xzr, x0, #0 C6.2.464 SUBS (immediate), alias CMP C6.2.96 +5400000d@J # [573] b.le @J C6.2.34 B.cond (cond 13, Table C1-1) -> ERR +8b000294 # [574] add x20, x20, x0 C6.2.6 ADD (shifted register) +cb0001ce # [575] sub x14, x14, x0 C6.2.458 SUB (shifted register) +5400000e@_ # [576] b.al @_ C6.2.34 B.cond (cond 14, Table C1-1) -> WL +:^ # EXIT0 +d2800000 # [577] movz x0, #0 C6.2.285 MOVZ +d2800ba8 # [578] movz x8, #93 C6.2.285 MOVZ +d4000001 # [579] svc #0 C6.2.466 SVC +:Q # MSG1 +326d7361 # data: "asm2" +696c203a # data: ": li" +0020656e # data: "ne " 0 +:R # MSG2 +7265203a # data: ": er" +20726f72 # data: "ror " +00000000 # data: 0 diff --git a/native/toolchain/seed/rung2/table.s2 b/native/toolchain/seed/rung2/table.s2 new file mode 100644 index 0000000..3b274e0 --- /dev/null +++ b/native/toolchain/seed/rung2/table.s2 @@ -0,0 +1,92 @@ +; table.s2 -- the instruction table of asm2 (rung 2), readable text. Every line: +; = name 0xBASE field... +; BASE is the word with every operand field zero, read from the encoding diagram of the Arm ARM +; DDI 0487 M.d section named in the comment. Fields, in operand order: rP register at bit P (5 bits), +; iP.W unsigned, sP.W signed, lP.W label distance in words, a ADR label distance in bytes. +; Units: load/store offsets are in units of the access size (the manual's imm12), as the bits hold them. +; Suffix .x = 64-bit (sf=1), .w = 32-bit (sf=0). +; +; ---- arithmetic and logic, shifted register with shift 0 (operands: Rd, Rn, Rm) ---- += add.x 0x8b000000 r0 r5 r16 ; C6.2.6 ADD (shifted register) += add.w 0x0b000000 r0 r5 r16 ; C6.2.6 += sub.x 0xcb000000 r0 r5 r16 ; C6.2.458 SUB (shifted register) += sub.w 0x4b000000 r0 r5 r16 ; C6.2.458 += subs.x 0xeb000000 r0 r5 r16 ; C6.2.465 SUBS (shifted register) += subs.w 0x6b000000 r0 r5 r16 ; C6.2.465 += cmp.x 0xeb00001f r5 r16 ; C6.2.97 CMP (shifted register) = SUBS with Rd 31 += cmp.w 0x6b00001f r5 r16 ; C6.2.97 += and.x 0x8a000000 r0 r5 r16 ; C6.2.15 AND (shifted register) += and.w 0x0a000000 r0 r5 r16 ; C6.2.15 += orr.x 0xaa000000 r0 r5 r16 ; C6.2.302 ORR (shifted register) += orr.w 0x2a000000 r0 r5 r16 ; C6.2.302 += eor.x 0xca000000 r0 r5 r16 ; C6.2.156 EOR (shifted register) += eor.w 0x4a000000 r0 r5 r16 ; C6.2.156 += mov.x 0xaa0003e0 r0 r16 ; C6.2.282 MOV (register) = ORR Rd, ZR, Rm += mov.w 0x2a0003e0 r0 r16 ; C6.2.282 +; ---- multiply, divide, variable shifts ---- += mul.x 0x9b007c00 r0 r5 r16 ; C6.2.293 MUL = MADD with Ra 31 (C6.2.275) += mul.w 0x1b007c00 r0 r5 r16 ; C6.2.293 += madd.x 0x9b000000 r0 r5 r16 r10 ; C6.2.275 MADD (Rd, Rn, Rm, Ra) += msub.x 0x9b008000 r0 r5 r16 r10 ; C6.2.291 MSUB (Rd, Rn, Rm, Ra) += udiv.x 0x9ac00800 r0 r5 r16 ; C6.2.490 UDIV += lslv.x 0x9ac02000 r0 r5 r16 ; C6.2.271 LSLV += lsrv.x 0x9ac02400 r0 r5 r16 ; C6.2.274 LSRV += asrv.x 0x9ac02800 r0 r5 r16 ; C6.2.21 ASRV +; ---- immediates ---- += add.x.i 0x91000000 r0 r5 i10.12 ; C6.2.5 ADD (immediate), sh 0 += sub.x.i 0xd1000000 r0 r5 i10.12 ; C6.2.457 SUB (immediate), sh 0 += subs.x.i 0xf1000000 r0 r5 i10.12 ; C6.2.464 SUBS (immediate), sh 0 += subs.w.i 0x71000000 r0 r5 i10.12 ; C6.2.464 += cmp.x.i 0xf100001f r5 i10.12 ; C6.2.96 CMP (immediate) = SUBS with Rd 31 += cmp.w.i 0x7100001f r5 i10.12 ; C6.2.96 += movz.x 0xd2800000 r0 i5.16 i21.2 ; C6.2.285 MOVZ (Rd, imm16, hw = shift/16) += movz.w 0x52800000 r0 i5.16 i21.1 ; C6.2.285 (32-bit: hw 0 or 1) += movk.x 0xf2800000 r0 i5.16 i21.2 ; C6.2.283 MOVK += movk.w 0x72800000 r0 i5.16 i21.1 ; C6.2.283 +; ---- loads and stores (Rt, Rn, offset in access-size units / signed bytes for post-index) ---- += ldr.x 0xf9400000 r0 r5 i10.12 ; C6.2.216 LDR (immediate), unsigned offset, size 11 += ldr.w 0xb9400000 r0 r5 i10.12 ; C6.2.216 size 10 += str.x 0xf9000000 r0 r5 i10.12 ; C6.2.415 STR (immediate), unsigned offset += str.w 0xb9000000 r0 r5 i10.12 ; C6.2.415 += ldrb 0x39400000 r0 r5 i10.12 ; C6.2.220 LDRB (immediate), unsigned offset += strb 0x39000000 r0 r5 i10.12 ; C6.2.417 STRB (immediate), unsigned offset += ldr.w.post 0xb8400400 r0 r5 s12.9 ; C6.2.216 LDR (immediate), post-index, 32-bit += ldr.x.post 0xf8400400 r0 r5 s12.9 ; C6.2.216 post-index, 64-bit += str.w.post 0xb8000400 r0 r5 s12.9 ; C6.2.415 STR (immediate), post-index, 32-bit += str.x.post 0xf8000400 r0 r5 s12.9 ; C6.2.415 post-index, 64-bit +; ---- branches (label operands) ---- += b 0x14000000 l0.26 ; C6.2.35 B += bl 0x94000000 l0.26 ; C6.2.43 BL += b.eq 0x54000000 l5.19 ; C6.2.34 B.cond, cond from Table C1-1 += b.ne 0x54000001 l5.19 += b.hs 0x54000002 l5.19 += b.lo 0x54000003 l5.19 += b.mi 0x54000004 l5.19 += b.pl 0x54000005 l5.19 += b.vs 0x54000006 l5.19 += b.vc 0x54000007 l5.19 += b.hi 0x54000008 l5.19 += b.ls 0x54000009 l5.19 += b.ge 0x5400000a l5.19 += b.lt 0x5400000b l5.19 += b.gt 0x5400000c l5.19 += b.le 0x5400000d l5.19 += b.al 0x5400000e l5.19 += b.nv 0x5400000f l5.19 += cbz.x 0xb4000000 r0 l5.19 ; C6.2.78 CBZ += cbz.w 0x34000000 r0 l5.19 += cbnz.x 0xb5000000 r0 l5.19 ; C6.2.77 CBNZ += cbnz.w 0x35000000 r0 l5.19 += adr 0x10000000 r0 a ; C6.2.12 ADR (byte distance, immlo at 29, immhi at 5) += ret 0xd65f03c0 ; C6.2.338 RET (x30) += ret.r 0xd65f0000 r5 ; C6.2.338 RET Rn += br 0xd61f0000 r5 ; C6.2.46 BR += blr 0xd63f0000 r5 ; C6.2.44 BLR += svc 0xd4000001 i5.16 ; C6.2.466 SVC +; ---- the same branches with the distance written as a number (words), for checks at the edges ---- += b.raw 0x14000000 s0.26 ; C6.2.35 += b.c.raw 0x54000000 i0.4 s5.19 ; C6.2.34 (cond, distance) += cbz.x.raw 0xb4000000 r0 s5.19 ; C6.2.78 += cbz.w.raw 0x34000000 r0 s5.19 += cbnz.x.raw 0xb5000000 r0 s5.19 ; C6.2.77 += cbnz.w.raw 0x35000000 r0 s5.19 diff --git a/native/toolchain/seed/rung3/table3.s2 b/native/toolchain/seed/rung3/table3.s2 new file mode 100644 index 0000000..91b141f --- /dev/null +++ b/native/toolchain/seed/rung3/table3.s2 @@ -0,0 +1,6 @@ +; table3.s2 -- extra table lines for rung 3 (read after rung2/table.s2). Same format; Arm DDI 0487 M.d. += str.x.pre 0xf8000c00 r0 r5 s12.9 ; C6.2.415 STR (immediate), pre-index, 64-bit += ldr.w.r 0xb8607800 r0 r5 r16 ; C6.2.218 LDR (register), 32-bit, LSL #2 (index scaled by 4) += ldrb.r 0x38606800 r0 r5 r16 ; C6.2.221 LDRB (register), no shift += ubfm.x 0xd3400000 r0 r5 i16.6 i10.6 ; C6.2.487 UBFM 64-bit (Rd, Rn, immr, imms) += sbfm.x 0x93400000 r0 r5 i16.6 i10.6 ; C6.2.355 SBFM 64-bit diff --git a/native/toolchain/seed/rung4/mk4.sh b/native/toolchain/seed/rung4/mk4.sh new file mode 100644 index 0000000..e0717af --- /dev/null +++ b/native/toolchain/seed/rung4/mk4.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# mk4.sh -- build om4.bin with asm2 (seed/rung2) and write its size into the p_filesz word of om4.s. +# asm2 has no size arithmetic, so the size is measured and written into the text; the build is then +# repeated so the image carries its own size (gate4.sh checks p_filesz = file size). +set -eu +T="seed/rung2/table.s2 seed/rung3/table3.s2 seed/rung4/table4.s2" +cat $T seed/rung4/om4.s | seed/rung2/asm2.bin > seed/rung4/om4.bin +n=$(stat -c %s seed/rung4/om4.bin) +sed -i "s/^ \.w 0x[0-9a-f]* ; p_filesz = the size of om4.bin.*/ .w $(printf 0x%08x $n) ; p_filesz = the size of om4.bin, $n bytes (asm2 has no size arithmetic; gate4.sh checks it)/" seed/rung4/om4.s +cat $T seed/rung4/om4.s | seed/rung2/asm2.bin > seed/rung4/om4.bin +chmod +x seed/rung4/om4.bin +echo "om4.bin $(stat -c %s seed/rung4/om4.bin) bytes" diff --git a/native/toolchain/seed/rung4/om4.s b/native/toolchain/seed/rung4/om4.s new file mode 100644 index 0000000..deec39a --- /dev/null +++ b/native/toolchain/seed/rung4/om4.s @@ -0,0 +1,4215 @@ +; om4.s -- rung 4 of the Omega seed chain: om3 (seed/rung3/om3.s) grown into the systems subset a compiler +; needs, written in asm2's language and built by asm2: +; cat seed/rung2/table.s2 seed/rung3/table3.s2 seed/rung4/om4.s | seed/rung2/asm2.bin > om4.bin +; Use: om4.bin < program.omegese > out. Two kinds of output (docs/one_layer/OMEGESE.md section 9 has the words): +; - function mode (no `fn main`): the functions' words only, entry = word 0, to be called under the OSC-1 +; native rules (docs/osc/OSC-1-DESIGN.md section 7): parameters in x0..x5, result in x0 in canonical +; form, OscRt * in x7, a trap calls OscRt.trap (offset 16) with x0 = rt, x1 = code. With more than one +; function, word 0 is a B to the last one (the entry is still written last). A call may name any +; function in the unit, earlier or later. +; - program mode (a line `fn main`): a whole AArch64 Linux program (ELF file header laid out by hand, no +; linker). Its start code sets the stack to a fixed 8 MiB pool, calls main, and exits with main's value; +; a trap exits with status 100 + code. +; +; What om4 adds to om3: many functions, calls to any function in the unit (a names pass collects every +; signature first; a later function is a call, never a new scalar), mutual recursion in program mode, +; a call cycle in function mode refused as error 9 (the same refusal a function calling itself already +; had), assigning to a function name refused as error 10; void functions and ret without a value; +; signed div, rem and shl; for with a value as count; +; true and false; local arrays (new, on the stack, only in a function's outermost block), array parameters +; (view / edit), global arrays (global, fixed pools in the program's memory image, no heap), text literals +; (text, read-only bytes with their length), get, put, len; read and write (Linux system calls on a +; checked part of an array) and exit; note lines. Every array carries its length; every index is checked +; (trap 3) unless it is a number, which is checked when om4 reads it. +; Semantics follow the C path's interpreter (src/compiler/osc_interp.c): unsigned ops wrap to the width, +; signed add/sub/mul/neg/div/shl trap 1 out of range, div/rem trap 2 on zero, a loop bound trap 4, a +; conversion out of range trap 5, a shift amount outside 0..width-1 trap 7; om4 adds trap 3 (index or +; system call range outside the array) and trap 6 (the stack pool is used up, program mode). +; +; Code generation (as om3): every name lives in its own register for its whole scope; temporaries are +; registers freed at the end of each statement. Registers handed out: x0..x6 not taken by parameters, +; x8..x15, x17 (never x7 = rt, x16 = scratch, x18, x19..x30; x28 = stack pool floor in program mode). +; A call saves every register in use and x30 on the stack, loads the arguments into x0..x5 from that save +; area, branches with BL, and loads the registers back; so a function needs no entry or exit code beyond +; giving back the stack of its local arrays. +; +; Every machine word om4 writes is built from a fixed part read from the encoding diagram of the Arm ARM +; DDI 0487 M.d section named beside it, ORed with register and number fields. +; +; om4's own registers: x18 input end, x19 input cursor, x20 output cursor, x21 output buffer start, x22 line +; number, x23 names in scope, x24 next free pool slot, x25 block stack top, x26 trap list end, x27 return +; type (0 outside a function, 10 void), x28 pool slots held by names, x29 pool start. +; Memory: input 0x800000 (under 8 MiB), output 0x1000000 (8 MiB: 176-byte file header, 1 entry word, then +; text bytes and functions), names 0x1800000 (32 bytes: packed name 8, register 4, type 4, length 4, kind +; 4, address 8), blocks 0x1810000 (128 bytes), trap list 0x1820000 (8 bytes: site, code), message +; 0x1830000, functions 0x1840000 (128 bytes: name 8, address 8, return type 4, parameter count 4, then per +; parameter 16 bytes: type 4, length 4, kind 4), state 0x1850000 (8-byte slots: 1 globals and texts in the +; name table, 2 functions, 4 stack bytes of local arrays, 5 the path has ended, 6 program mode, 7 global +; pool bytes, 9 last function, 10 value nesting depth, 11 a number written as 2^63 or more, 12 recorded +; calls, 13 namescan phase: 0 not started, 1 collecting signatures, 2 emitting). Call records, 24 bytes +; each (site, callee entry, caller entry), sit at 0x1860000, 65536 of them. Function-mode cycle marks, +; one byte per function, sit at 0x19e0000. Both are past the file and zeroed with the rest of the mapping. +; Name kinds: 0 scalar, 1 local array, 2 view parameter, 3 edit parameter, 4 global array, 5 text. +; Errors: "om4: line N: error E" on stderr, exit E: 1 read, 2 write, 3 unknown name, 4 line ends too +; early, 5 extra words, 6 bad number, 7 type mismatch, 8 number out of range for its type, 9 not in the +; subset, 10 name defined twice, 11 number with no type, 12 out of registers, 13 word over 8 characters, +; 14 table or buffer full, 15 block structure, 16 syntax, 17 a line after ret or exit in the same block, +; 18 a function that needs a value can reach its end, 19 one array passed twice in a call (aliasing), +; 20 writing through a read-only array, 21 a number index outside the array, 22 bad text literal, +; 23 array or pool too large. +; +; ---- ELF-64 file header (words as in seed/rung0/seed0.hex) ---- + .w 0x464c457f + .w 0x00010102 + .w 0x00000000 + .w 0x00000000 + .w 0x00b70002 + .w 0x00000001 + .w 0x00400078 + .w 0x00000000 + .w 0x00000040 + .w 0x00000000 + .w 0x00000000 + .w 0x00000000 + .w 0x00000000 + .w 0x00380040 + .w 0x00000001 + .w 0x00000000 +; ---- program header: one PT_LOAD, read/write/execute, file at 0x400000 ---- + .w 0x00000001 + .w 0x00000007 + .w 0x00000000 + .w 0x00000000 + .w 0x00400000 + .w 0x00000000 + .w 0x00400000 + .w 0x00000000 + .w 0x00003790 ; p_filesz = the size of om4.bin, 14224 bytes (asm2 has no size arithmetic; gate4.sh checks it) + .w 0x00000000 + .w 0x015f0000 ; p_memsz: through call fixups and graph marks at 0x19e0000 + .w 0x00000000 + .w 0x00001000 + .w 0x00000000 +; ---- 0x400078: entry ---- + b START + .w 0 +; ---- keyword table, 16 bytes per entry: packed word (8), code (4), 0 (4); made with +; evidence/SEED-0/rung4-worksheet.sh. Codes: 1..9 types, 33..58 values, 64.. statements, 77 not in subset. +:KWTAB + .w 0x6c6f6f62 + .w 0x00000000 + .w 1 + .w 0 + .w 0x61686375 + .w 0x00000072 + .w 2 + .w 0 + .w 0x00003875 + .w 0x00000000 + .w 2 + .w 0 + .w 0x6f687375 + .w 0x00007472 + .w 3 + .w 0 + .w 0x00363175 + .w 0x00000000 + .w 3 + .w 0 + .w 0x746e6975 + .w 0x00000000 + .w 4 + .w 0 + .w 0x00323375 + .w 0x00000000 + .w 4 + .w 0 + .w 0x6e6f6c75 + .w 0x00000067 + .w 5 + .w 0 + .w 0x00343675 + .w 0x00000000 + .w 5 + .w 0 + .w 0x65747962 + .w 0x00000000 + .w 6 + .w 0 + .w 0x00003869 + .w 0x00000000 + .w 6 + .w 0 + .w 0x726f6873 + .w 0x00000074 + .w 7 + .w 0 + .w 0x00363169 + .w 0x00000000 + .w 7 + .w 0 + .w 0x00746e69 + .w 0x00000000 + .w 8 + .w 0 + .w 0x00323369 + .w 0x00000000 + .w 8 + .w 0 + .w 0x676e6f6c + .w 0x00000000 + .w 9 + .w 0 + .w 0x00343669 + .w 0x00000000 + .w 9 + .w 0 + .w 0x00646461 + .w 0x00000000 + .w 33 + .w 0 + .w 0x00627573 + .w 0x00000000 + .w 34 + .w 0 + .w 0x006c756d + .w 0x00000000 + .w 35 + .w 0 + .w 0x00766964 + .w 0x00000000 + .w 36 + .w 0 + .w 0x006d6572 + .w 0x00000000 + .w 37 + .w 0 + .w 0x00646e61 + .w 0x00000000 + .w 38 + .w 0 + .w 0x0000726f + .w 0x00000000 + .w 39 + .w 0 + .w 0x00726f78 + .w 0x00000000 + .w 40 + .w 0 + .w 0x006c6873 + .w 0x00000000 + .w 41 + .w 0 + .w 0x00726873 + .w 0x00000000 + .w 42 + .w 0 + .w 0x00007165 + .w 0x00000000 + .w 43 + .w 0 + .w 0x0000656e + .w 0x00000000 + .w 44 + .w 0 + .w 0x0000746c + .w 0x00000000 + .w 45 + .w 0 + .w 0x0000656c + .w 0x00000000 + .w 46 + .w 0 + .w 0x00007467 + .w 0x00000000 + .w 47 + .w 0 + .w 0x00006567 + .w 0x00000000 + .w 48 + .w 0 + .w 0x0067656e + .w 0x00000000 + .w 49 + .w 0 + .w 0x00746f6e + .w 0x00000000 + .w 50 + .w 0 + .w 0x00746567 + .w 0x00000000 + .w 51 + .w 0 + .w 0x006e656c + .w 0x00000000 + .w 52 + .w 0 + .w 0x64616572 + .w 0x00000000 + .w 53 + .w 0 + .w 0x74697277 + .w 0x00000065 + .w 54 + .w 0 + .w 0x65757274 + .w 0x00000000 + .w 55 + .w 0 + .w 0x736c6166 + .w 0x00000065 + .w 56 + .w 0 + .w 0x77656976 + .w 0x00000000 + .w 57 + .w 0 + .w 0x74696465 + .w 0x00000000 + .w 58 + .w 0 + .w 0x00006e66 + .w 0x00000000 + .w 64 + .w 0 + .w 0x00006f74 + .w 0x00000000 + .w 65 + .w 0 + .w 0x00646e65 + .w 0x00000000 + .w 66 + .w 0 + .w 0x00006669 + .w 0x00000000 + .w 67 + .w 0 + .w 0x65736c65 + .w 0x00000000 + .w 68 + .w 0 + .w 0x6c696877 + .w 0x00000065 + .w 69 + .w 0 + .w 0x6e756f62 + .w 0x00000064 + .w 70 + .w 0 + .w 0x00726f66 + .w 0x00000000 + .w 71 + .w 0 + .w 0x00746572 + .w 0x00000000 + .w 72 + .w 0 + .w 0x0000003d + .w 0x00000000 + .w 73 + .w 0 + .w 0x00000028 + .w 0x00000000 + .w 74 + .w 0 + .w 0x00000029 + .w 0x00000000 + .w 75 + .w 0 + .w 0x64696f76 + .w 0x00000000 + .w 76 + .w 0 + .w 0x626f6c67 + .w 0x00006c61 + .w 78 + .w 0 + .w 0x74786574 + .w 0x00000000 + .w 79 + .w 0 + .w 0x00747570 + .w 0x00000000 + .w 80 + .w 0 + .w 0x65657266 + .w 0x00000000 + .w 81 + .w 0 + .w 0x74697865 + .w 0x00000000 + .w 82 + .w 0 + .w 0x65746f6e + .w 0x00000000 + .w 83 + .w 0 + .w 0x0077656e + .w 0x00000000 + .w 84 + .w 0 + .w 0x61657262 + .w 0x0000006b + .w 77 + .w 0 + .w 0x70617274 + .w 0x00000000 + .w 77 + .w 0 + .w 0x006e776f + .w 0x00000000 + .w 77 + .w 0 + .w 0 + .w 0 + .w 0 + .w 0 +; ---- messages ("om4: line ", ": error "), each with its length ---- +:MSG1 + .w 0x3a346d6f + .w 0x6e696c20 + .w 0x00002065 +:MSG2 + .w 0x7265203a + .w 0x20726f72 + .w 0x00000000 +; ---- register pool: x0..x6, x8..x15, x17; the pool starts after the parameter registers ---- +:POOLC + .b 0 + .b 1 + .b 2 + .b 3 + .b 4 + .b 5 + .b 6 + .b 8 + .b 9 + .b 10 + .b 11 + .b 12 + .b 13 + .b 14 + .b 15 + .b 17 +:POOLEND +; ---- the pool index of each register x0..x17 (255: not in the pool) ---- +:REGIDX + .b 0 + .b 1 + .b 2 + .b 3 + .b 4 + .b 5 + .b 6 + .b 255 + .b 7 + .b 8 + .b 9 + .b 10 + .b 11 + .b 12 + .b 13 + .b 14 + .b 255 + .b 15 +; ---- width in bits by type code 0..9 (bool 1) ---- +:TWID + .b 0 + .b 1 + .b 8 + .b 16 + .b 32 + .b 64 + .b 8 + .b 16 + .b 32 + .b 64 +; ---- log2 of the element size by type code 0..9 ---- +:TLOG + .b 0 + .b 0 + .b 0 + .b 1 + .b 2 + .b 3 + .b 0 + .b 1 + .b 2 + .b 3 +; ---- condition for eq ne lt le gt ge, unsigned then signed (Arm ARM Table C1-1, C1.2.4): +; EQ 0, NE 1, LO 3 / LT 11, LS 9 / LE 13, HI 8 / GT 12, HS 2 / GE 10. The opposite condition is cond ^ 1. +:CONDS + .b 0 + .b 0 + .b 1 + .b 1 + .b 3 + .b 11 + .b 9 + .b 13 + .b 8 + .b 12 + .b 2 + .b 10 + .b 0 ; pad to a word boundary (16 + 18 + 10 + 10 + 12 bytes of tables above) + .b 0 +; ---- load by element type 0..9, register offset scaled by the element size (LSL #log2 size; S = 1 +; except for bytes): uchar LDRB C6.2.221, ushort LDRH C6.2.223, uint LDR (32-bit) C6.2.218, ulong and +; long LDR (64-bit) C6.2.218, byte LDRSB (64-bit) C6.2.225, short LDRSH (64-bit) C6.2.227, int LDRSW +; C6.2.230. Fixed part: option 011 (LSL), Rm Rn Rt zero. +:LDOP + .w 0 + .w 0 + .w 0x38606800 + .w 0x78607800 + .w 0xb8607800 + .w 0xf8607800 + .w 0x38a06800 + .w 0x78a07800 + .w 0xb8a07800 + .w 0xf8607800 +; ---- store by element type: STRB C6.2.418, STRH C6.2.420, STR (32-bit, 64-bit) C6.2.416 ---- +:STOP + .w 0 + .w 0 + .w 0x38206800 + .w 0x78207800 + .w 0xb8207800 + .w 0xf8207800 + .w 0x38206800 + .w 0x78207800 + .w 0xb8207800 + .w 0xf8207800 +; ---- the file header om4 writes in program mode: ELF-64 header and two PT_LOAD program headers +; (the file at 0x400000 read/execute; the stack and global pools at 0x10000000 read/write, no file +; bytes). Words 24, 26 (file size) and 40 (pool size) are filled in at the end. ---- +:ELFHDR + .w 0x464c457f + .w 0x00010102 + .w 0x00000000 + .w 0x00000000 + .w 0x00b70002 + .w 0x00000001 + .w 0x004000b0 ; e_entry: the word after the header + .w 0x00000000 + .w 0x00000040 + .w 0x00000000 + .w 0x00000000 + .w 0x00000000 + .w 0x00000000 + .w 0x00380040 + .w 0x00000002 ; e_phnum 2 + .w 0x00000000 + .w 0x00000001 ; PT_LOAD + .w 0x00000005 ; PF_R | PF_X + .w 0x00000000 + .w 0x00000000 + .w 0x00400000 + .w 0x00000000 + .w 0x00400000 + .w 0x00000000 + .w 0x00000000 ; p_filesz (filled in) + .w 0x00000000 + .w 0x00000000 ; p_memsz (filled in) + .w 0x00000000 + .w 0x00001000 + .w 0x00000000 + .w 0x00000001 ; PT_LOAD + .w 0x00000006 ; PF_R | PF_W + .w 0x00000000 + .w 0x00000000 + .w 0x10000000 ; the stack pool from 0x10000000, the global pools from 0x10800000 + .w 0x00000000 + .w 0x10000000 + .w 0x00000000 + .w 0x00000000 ; p_filesz 0 + .w 0x00000000 + .w 0x00000000 ; p_memsz (filled in: 8 MiB stack + global pools) + .w 0x00000000 + .w 0x00001000 + .w 0x00000000 +; ====================================================================================================== +; start: read all of stdin to 0x800000 (at most 8 MiB - 1 bytes); x18 = its end (no end byte is written) +:START + movz.x x19 0x80 1 + movz.x x12 0 0 +:RD + movz.x x0 0 0 + add.x x1 x19 x12 + movz.x x2 0x80 1 + sub.x x2 x2 x12 + cbz.x x2 E_FULL + movz.x x8 63 0 + svc 0 + cmp.x.i x0 0 + b.eq RDDONE + b.lt E_READ + add.x x12 x12 x0 + b RD +:RDDONE + add.x x18 x19 x12 + movz.x x9 0x185 1 + movz.x x10 0 0 +:ST0 + str.x xzr x9 0 + add.x.i x9 x9 8 + add.x.i x10 x10 1 + cmp.x.i x10 16 + b.lo ST0 +; ---- program mode when some line is `fn main` (blanks, fn, blanks, main, then a blank or the end) ---- + mov.x x10 x19 +:PS_LINE + cmp.x x10 x18 + b.hs PS_DONE + ldrb w0 x10 0 + cmp.w.i w0 32 + b.eq PS_ADV + cmp.w.i w0 9 + b.eq PS_ADV + cmp.w.i w0 102 + b.ne PS_SKIP + add.x.i x12 x10 1 + cmp.x x12 x18 + b.hs PS_DONE + ldrb w0 x12 0 + cmp.w.i w0 110 + b.ne PS_SKIP + add.x.i x12 x12 1 + mov.x x13 x12 +:PS_B + cmp.x x12 x18 + b.hs PS_DONE + ldrb w0 x12 0 + cmp.w.i w0 32 + b.eq PS_B1 + cmp.w.i w0 9 + b.ne PS_M +:PS_B1 + add.x.i x12 x12 1 + b PS_B +:PS_M + cmp.x x12 x13 + b.eq PS_SKIP + add.x.i x13 x12 4 + cmp.x x13 x18 + b.hi PS_SKIP + ldrb w0 x12 0 + cmp.w.i w0 109 + b.ne PS_SKIP + ldrb w0 x12 1 + cmp.w.i w0 97 + b.ne PS_SKIP + ldrb w0 x12 2 + cmp.w.i w0 105 + b.ne PS_SKIP + ldrb w0 x12 3 + cmp.w.i w0 110 + b.ne PS_SKIP + cmp.x x13 x18 + b.hs PS_YES + ldrb w0 x13 0 + cmp.w.i w0 32 + b.hi PS_SKIP +:PS_YES + movz.x x9 0x185 1 + movz.x x0 1 0 + str.x x0 x9 6 + b PS_DONE +:PS_ADV + add.x.i x10 x10 1 + b PS_LINE +:PS_SKIP + cmp.x x10 x18 + b.hs PS_DONE + ldrb w0 x10 0 + add.x.i x10 x10 1 + cmp.w.i w0 10 + b.ne PS_SKIP + b PS_LINE +:PS_DONE + movz.x x21 0x100 1 + add.x.i x20 x21 180 + movz.x x22 1 0 + movz.x x23 0 0 + movz.x x24 0 0 + movz.x x25 0x181 1 + movz.x x26 0x182 1 + movz.x x27 0 0 + movz.x x28 0 0 + adr x29 POOLC +; ---- one statement per line ---- +:STMT + movz.x x9 0x185 1 + ldr.x x10 x9 13 + cbz.x x10 NS_INIT + cmp.x.i x10 1 + b.eq NS_LINE + b BODY_LINE +:NS_INIT + movz.x x10 1 0 + str.x x10 x9 13 +:NS_LINE + bl TOK + cbz.x x0 NS_LINE + cmp.x.i x0 3 + b.eq NS_DONE + cmp.x.i x0 1 + b.ne S_NOTE + cmp.x.i x2 2 + b.ne S_NOTE + movz.x x9 0x6e66 0 + cmp.x x1 x9 + b.eq S_FN + b S_NOTE +:NS_DONE + movz.x x9 0x185 1 + movz.x x10 2 0 + str.x x10 x9 13 + str.x xzr x9 3 + movz.x x19 0x80 1 + b PS_DONE +:BODY_LINE + mov.x x24 x28 + bl TOK + cbz.x x0 STMT + cmp.x.i x0 3 + b.eq S_EOF + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi S_LONG + mov.x x12 x1 + bl KW + cmp.x.i x0 83 + b.eq S_NOTE + cmp.x.i x0 64 + b.eq S_FN + cbz.x x27 S_TOP + cmp.x.i x0 66 + b.eq S_END + cmp.x.i x0 68 + b.eq S_ELSE + movz.x x9 0x185 1 + ldr.x x10 x9 5 + cbnz.x x10 E_DEAD + cbz.x x0 S_NAME + cmp.x.i x0 67 + b.eq S_IF + cmp.x.i x0 69 + b.eq S_WHILE + cmp.x.i x0 71 + b.eq S_FOR + cmp.x.i x0 72 + b.eq S_RET + cmp.x.i x0 80 + b.eq S_PUT + cmp.x.i x0 81 + b.eq E_SUBSET ; free: no heap and nothing to give back (decision 24), so not a word + cmp.x.i x0 82 + b.eq S_EXIT + cmp.x.i x0 77 + b.eq E_SUBSET + cmp.x.i x0 78 + b.eq E_SUBSET + cmp.x.i x0 79 + b.eq E_SUBSET + b E_SYNTAX +:S_TOP + cmp.x.i x0 78 + b.eq S_GLOBAL + cmp.x.i x0 79 + b.eq S_TEXT + b E_SYNTAX +; ---- note ...: the rest of the line is not read ---- +:S_NOTE + cmp.x x19 x18 + b.hs STMT + ldrb w0 x19 0 + cmp.w.i w0 10 + b.eq STMT + add.x.i x19 x19 1 + b S_NOTE +; ---- a name at the start of a line: a call of a void function, or name [=] value ---- +:S_NAME + mov.x x1 x12 + bl FINDNAME + cbnz.x x0 S_ASSIGN + mov.x x1 x12 + bl FINDFN + cbz.x x0 S_ASSIGN + ldr.w w9 x0 4 + cmp.x.i x9 10 + b.ne E_TYPE + movz.x x1 255 0 + bl CALL + bl EOL + b STMT +; ---- fn name (param type | param view T N | param edit T N)* to type | void ---- +:S_FN + cbnz.x x27 E_BLOCK + bl TOK + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 63 + b.hi E_LONG + mov.x x12 x1 + bl KW + cbnz.x x0 E_SYNTAX + mov.x x1 x12 + sub.x x3 x19 x2 + movz.x x9 0x185 1 + ldr.x x10 x9 13 + cmp.x.i x10 2 + b.eq FN_KNOWN + bl NEWNAME + movz.x x9 0x185 1 + ldr.x x10 x9 2 + + cmp.x.i x10 512 + b.hs E_FULL + add.x.i x11 x10 1 + str.x x11 x9 2 + movz.x x11 0x184 1 + ubfm.x x10 x10 57 56 + add.x x11 x11 x10 + str.x x11 x9 3 + str.x x11 x9 9 + str.x x12 x11 0 + str.x x20 x11 1 + str.x xzr x11 2 + str.w w2 x11 30 + movz.x x16 0x80 1 + sub.x x16 x3 x16 + str.w w16 x11 31 + b FN_SCOPE +:FN_KNOWN + bl FINDFN + cbz.x x0 E_SYNTAX + movz.x x9 0x185 1 + str.x x0 x9 3 + str.x x0 x9 9 + str.x x20 x0 1 +:FN_SCOPE + ldr.x x23 x9 1 + + movz.x x13 0 0 +:FN_P + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_LONG + mov.x x12 x1 + bl KW + cmp.x.i x0 65 + b.eq FN_TO + cbnz.x x0 E_SYNTAX + mov.x x1 x12 + bl NEWNAME + cmp.x.i x13 6 + b.hs E_SUBSET + sub.x.i sp sp 48 + str.x x12 sp 0 + bl TOK + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_SYNTAX + bl KW + cmp.x.i x0 57 + b.eq FN_ARR + cmp.x.i x0 58 + b.eq FN_ARR + sub.x.i x9 x0 1 + cmp.x.i x9 8 + b.hi E_SYNTAX + str.x x0 sp 1 + str.x xzr sp 2 + str.x xzr sp 3 + b FN_ADD +; an array parameter: view (kind 2) or edit (kind 3), element type, length (a number 1..2^24) +:FN_ARR + sub.x.i x0 x0 55 + str.x x0 sp 3 + bl TYPEWORD + bl ELEMTYPE + str.x x0 sp 1 + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 2 + b.ne E_SYNTAX + bl ARRLEN + str.x x1 sp 2 +:FN_ADD + adr x9 POOLC + ldrb.r w2 x9 x13 + ldr.x x1 sp 0 + ldr.x x3 sp 1 + ldr.x x4 sp 2 + ldr.x x5 sp 3 + movz.x x6 0 0 + bl ADDNAME + movz.x x9 0x185 1 + ldr.x x11 x9 3 + ubfm.x x10 x13 60 59 + add.x x11 x11 x10 + ldr.x x0 sp 1 + str.w w0 x11 6 + ldr.x x0 sp 2 + str.w w0 x11 7 + ldr.x x0 sp 3 + str.w w0 x11 8 + add.x.i sp sp 48 + add.x.i x13 x13 1 + b FN_P +:FN_TO + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_SYNTAX + bl KW + cmp.x.i x0 76 + b.eq FN_VOID + sub.x.i x9 x0 1 + cmp.x.i x9 8 + b.hi E_SYNTAX + mov.x x27 x0 + b FN_T2 +:FN_VOID + movz.x x27 10 0 +:FN_T2 + movz.x x9 0x185 1 + ldr.x x11 x9 3 + str.w w27 x11 4 + str.w w13 x11 5 + str.x xzr x9 4 + str.x xzr x9 5 + adr x29 POOLC + add.x x29 x29 x13 + movz.x x24 0 0 + movz.x x28 0 0 + movz.x x25 0x181 1 + movz.x x26 0x182 1 + bl EOL + movz.x x9 0x185 1 + ldr.x x10 x9 13 + cmp.x.i x10 1 + b.ne STMT + movz.x x27 0 0 + movz.x x23 0 0 + b STMT +; ---- name [=] value, or name = new T N v (a local array) ---- +:S_ASSIGN + sub.x.i sp sp 64 + str.x x12 sp 0 + bl TOK + mov.x x3 x0 + mov.x x4 x1 + mov.x x5 x2 + cmp.x.i x3 1 + b.ne SA1 + cmp.x.i x5 8 + b.hi SA1 + mov.x x1 x4 + bl KW + cmp.x.i x0 73 + b.ne SA1 + bl TOK + mov.x x3 x0 + mov.x x4 x1 + mov.x x5 x2 +:SA1 + ldr.x x1 sp 0 + bl FINDNAME + cbz.x x0 SA_NEW + ldr.w w9 x0 5 + cbnz.x x9 E_TYPE + ldr.w w1 x0 2 + str.x x1 sp 1 + ldr.w w0 x0 3 + str.x x0 sp 2 + bl VALTOK + ldr.x x9 sp 2 + cmp.x x2 x9 + b.ne E_TYPE + ldr.x x3 sp 1 + bl FORCE + b SA_END +:SA_NEW + ldr.x x1 sp 0 + movz.x x2 0 0 + bl FINDFN + cbnz.x x0 E_TWICE + cmp.x.i x3 1 + b.ne SA2 + cmp.x.i x5 8 + b.hi SA2 + mov.x x1 x4 + bl KW + cmp.x.i x0 84 + b.eq SA_ARR +:SA2 + bl ALLOC + mov.x x28 x24 + str.x x0 sp 1 + mov.x x1 x0 + movz.x x0 0 0 + bl VALTOK + cmp.x.i x0 2 + b.eq E_BARE + str.x x2 sp 2 + ldr.x x3 sp 1 + bl FORCE + ldr.x x1 sp 0 + ldr.x x2 sp 1 + ldr.x x3 sp 2 + movz.x x4 0 0 + movz.x x5 0 0 + movz.x x6 0 0 + bl ADDNAME +:SA_END + add.x.i sp sp 64 + bl EOL + b STMT +; x = new T N v: N elements of type T on the stack, each set to v; only in the function's outermost block, +; so the stack held by local arrays is known at every ret. SUB SP (C6.2.457); program mode: CMP SP, X28 +; (SUBS extended, C6.2.463), B.LO trap 6; MOV Xb, SP (ADD immediate, C6.2.5); then the fill loop. +:SA_ARR + movz.x x9 0x181 1 + cmp.x x25 x9 + b.ne E_SUBSET + bl TYPEWORD + bl ELEMTYPE + str.x x0 sp 2 + bl TOK + cmp.x.i x0 2 + b.ne E_SYNTAX + bl ARRLEN + str.x x1 sp 3 + ldr.x x2 sp 2 + adr x9 TLOG + ldrb.r w9 x9 x2 + lslv.x x1 x1 x9 + add.x.i x1 x1 15 + ubfm.x x1 x1 4 63 + ubfm.x x1 x1 60 59 + str.x x1 sp 4 + movz.x x9 0x185 1 + ldr.x x10 x9 4 + add.x x10 x10 x1 + movz.x x11 0x40 1 + cmp.x x10 x11 + b.hi E_TOOBIG + str.x x10 x9 4 + bl ALLOC + mov.x x28 x24 + str.x x0 sp 1 + ldr.x x0 sp 2 + movz.x x1 255 0 + bl VAL + ldr.x x9 sp 2 + cmp.x x2 x9 + b.ne E_TYPE + bl MATREG + str.x x0 sp 5 + ldr.x x1 sp 4 + bl SPSUB + bl STKCHK + movz.x x0 0x03e0 0 + movk.x x0 0x9100 1 ; MOV Xb, SP = ADD Xb, SP, #0, C6.2.5 / C6.2.278 + ldr.x x1 sp 1 + orr.x x0 x0 x1 + bl EMIT + bl ALLOC + str.x x0 sp 6 + movz.x x9 0xd280 1 ; MOVZ Xi, #0, C6.2.285 + orr.x x0 x0 x9 + bl EMIT + ldr.x x1 sp 3 + movz.x x9 4095 0 + cmp.x x1 x9 + b.ls SAA1 + bl ALLOC + str.x x0 sp 7 + ldr.x x1 sp 3 + bl MATCONST +:SAA1 + str.x x20 sp 4 + ldr.x x9 sp 2 + adr x10 STOP + ldr.w.r w0 x10 x9 + ldr.x x1 sp 5 + orr.x x0 x0 x1 + ldr.x x1 sp 1 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 6 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 0x0400 0 + movk.x x0 0x9100 1 ; ADD Xi, Xi, #1, C6.2.5 + ldr.x x1 sp 6 + orr.x x0 x0 x1 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + ldr.x x1 sp 3 + movz.x x9 4095 0 + cmp.x x1 x9 + b.hi SAA2 + movz.x x0 0x001f 0 + movk.x x0 0xf100 1 ; CMP Xi, #N, C6.2.96 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + b SAA3 +:SAA2 + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xi, Xn, C6.2.97 + ldr.x x1 sp 7 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 +:SAA3 + ldr.x x1 sp 6 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + ldr.x x0 sp 4 + sub.x x2 x0 x20 + ubfm.x x2 x2 2 20 + ubfm.x x2 x2 59 58 + movz.x x0 0x0003 0 + movk.x x0 0x5400 1 ; B.LO back to the store, C6.2.34 + orr.x x0 x0 x2 + bl EMIT + ldr.x x1 sp 0 + ldr.x x2 sp 1 + ldr.x x3 sp 2 + ldr.x x4 sp 3 + movz.x x5 1 0 + movz.x x6 0 0 + bl ADDNAME + b SA_END +; ---- ret [value]: the value into x0, give back the local arrays' stack, RET ---- +:S_RET + cmp.x.i x27 10 + b.eq SR_V + mov.x x0 x27 + movz.x x1 0 0 + bl VAL + cmp.x x2 x27 + b.ne E_TYPE + movz.x x3 0 0 + bl FORCE + bl EPI + bl DEAD1 + bl EOL + b STMT +:SR_V + bl EOL + bl EPI + bl DEAD1 + b STMT +; ---- exit value (int): Linux exit (system call 93, C6.2.466 SVC); the path ends ---- +:S_EXIT + movz.x x0 8 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x2 8 + b.ne E_TYPE + movz.x x3 0 0 + bl FORCE + movz.x x0 0x0ba8 0 + movk.x x0 0xd280 1 ; MOVZ X8, #93, C6.2.285 + bl EMIT + movz.x x0 0x0001 0 + movk.x x0 0xd400 1 ; SVC #0, C6.2.466 + bl EMIT + bl DEAD1 + bl EOL + b STMT +; ---- put A i v: index, then value, then the checked store ---- +:S_PUT + sub.x.i sp sp 64 + bl ARRNAME + str.x x0 sp 0 + ldr.w w9 x0 5 + cmp.x.i x9 2 + b.eq E_RDONLY + cmp.x.i x9 5 + b.eq E_RDONLY + movz.x x0 5 0 + movz.x x1 255 0 + bl VAL + str.x x0 sp 1 + str.x x1 sp 2 + str.x x2 sp 3 + ldr.x x9 sp 0 + ldr.w w0 x9 3 + movz.x x1 255 0 + bl VAL + ldr.x x9 sp 0 + ldr.w w9 x9 3 + cmp.x x2 x9 + b.ne E_TYPE + bl MATREG + str.x x0 sp 4 + ldr.x x0 sp 0 + ldr.x x1 sp 1 + ldr.x x2 sp 2 + ldr.x x3 sp 3 + bl ELEMADDR + ldr.x x9 sp 0 + ldr.w w9 x9 3 + adr x10 STOP + ldr.w.r w2 x10 x9 + ldr.x x3 sp 4 + orr.x x2 x2 x3 + ubfm.x x0 x0 59 58 + orr.x x2 x2 x0 + ubfm.x x1 x1 48 47 + orr.x x0 x2 x1 + bl EMIT + add.x.i sp sp 64 + bl EOL + b STMT +; ---- global NAME T N: a fixed pool of N elements, zero at start, in the read/write part of the program +; image after the 8 MiB stack pool (address 0x10800000 + pool bytes so far); at most 1 GiB of pools ---- +:S_GLOBAL + bl TOPNAME + bl TYPEWORD + bl ELEMTYPE + mov.x x13 x0 + bl TOK + cmp.x.i x0 2 + b.ne E_SYNTAX + bl ARRLEN + mov.x x14 x1 + adr x9 TLOG + ldrb.r w9 x9 x13 + lslv.x x1 x1 x9 + add.x.i x1 x1 15 + ubfm.x x1 x1 4 63 + ubfm.x x1 x1 60 59 + movz.x x9 0x185 1 + ldr.x x10 x9 7 + movz.x x6 0x1080 1 + add.x x6 x6 x10 + add.x x10 x10 x1 + movz.x x11 0x4000 1 + cmp.x x10 x11 + b.hi E_TOOBIG + str.x x10 x9 7 + mov.x x1 x12 + movz.x x2 0 0 + mov.x x3 x13 + mov.x x4 x14 + movz.x x5 4 0 + bl ADDNAME + movz.x x9 0x185 1 + str.x x23 x9 1 + bl EOL + b STMT +; ---- text NAME "...": read-only bytes in the program image (escapes \n \t \\ \"), with their length ---- +:S_TEXT + bl TOPNAME + bl TOK + cmp.x.i x0 4 + b.ne E_SYNTAX + sub.x x6 x20 x21 + movz.x x9 0x40 1 + add.x x6 x6 x9 + add.x x2 x1 x2 + movz.x x14 0 0 +:TX1 + cmp.x x1 x2 + b.hs TX4 + ldrb w0 x1 0 + add.x.i x1 x1 1 + cmp.w.i w0 92 + b.ne TX3 + ldrb w0 x1 0 + add.x.i x1 x1 1 + cmp.w.i w0 110 + b.ne TXa + movz.x x0 10 0 + b TX3 +:TXa + cmp.w.i w0 116 + b.ne TXb + movz.x x0 9 0 + b TX3 +:TXb + cmp.w.i w0 92 + b.eq TX3 + cmp.w.i w0 34 + b.ne E_TEXT +:TX3 + bl EMITB + add.x.i x14 x14 1 + b TX1 +:TX4 + ubfm.x x9 x20 0 1 + cbz.x x9 TX5 + movz.x x0 0 0 + bl EMITB + b TX4 +:TX5 + mov.x x1 x12 + movz.x x2 0 0 + movz.x x3 2 0 + mov.x x4 x14 + movz.x x5 5 0 + bl ADDNAME + movz.x x9 0x185 1 + str.x x23 x9 1 + bl EOL + b STMT +:S_IF + bl COND + movz.x x1 1 0 + movz.x x2 0 0 + movz.x x3 0 0 + movz.x x4 0 0 + mov.x x5 x23 + mov.x x6 x28 + bl PUSHB + bl EOL + b STMT +; ---- else: jump over the else part; the if's false branch lands after that jump ---- +:S_ELSE + movz.x x9 0x181 1 + cmp.x x25 x9 + b.eq E_BLOCK + sub.x.i x10 x25 128 + ldr.x x0 x10 0 + cmp.x.i x0 1 + b.ne E_BLOCK + mov.x x11 x20 + movz.x x0 0x1400 1 ; B (distance filled at end), C6.2.35 + bl EMIT + ldr.x x0 x10 1 + mov.x x1 x20 + bl PATCH19 + movz.x x0 2 0 + str.x x0 x10 0 + str.x x11 x10 1 + ldr.x x23 x10 5 + ldr.x x28 x10 6 + movz.x x9 0x185 1 + ldr.x x11 x9 5 + str.x x11 x10 7 + str.x xzr x9 5 + bl EOL + b STMT +; ---- while cond [bound N]: hidden counter = 0; head: cond false -> exit; counter >= N -> trap 4; +; counter = counter + 1; body; B head ---- +:S_WHILE + sub.x.i sp sp 64 + str.x x23 sp 0 + str.x x28 sp 1 + bl ALLOC + mov.x x28 x24 + str.x x0 sp 2 + movz.x x9 0xd280 1 ; MOVZ Xc, #0, C6.2.285 + orr.x x0 x0 x9 + bl EMIT + str.x x20 sp 3 + bl COND + str.x x0 sp 4 + movz.x x9 0x4240 0 + movk.x x9 0x000f 1 + str.x x9 sp 5 + bl TOK + cbz.x x0 SW_NOB + cmp.x.i x0 3 + b.eq SW_NOB + cmp.x.i x0 1 + b.ne E_EXTRA + cmp.x.i x2 8 + b.hi E_EXTRA + bl KW + cmp.x.i x0 70 + b.ne E_EXTRA + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 2 + b.ne E_SYNTAX + sub.x.i x9 x1 1 + movz.x x10 0x423f 0 + movk.x x10 0x000f 1 + cmp.x x9 x10 + b.hs E_RANGE + str.x x1 sp 5 + bl EOL +:SW_NOB + ldr.x x1 sp 5 + movz.x x9 4095 0 + cmp.x x1 x9 + b.hi SW_BIG + movz.x x0 0x001f 0 + movk.x x0 0xf100 1 ; CMP Xc, #N = SUBS XZR, Xc, #N, C6.2.96 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + ldr.x x1 sp 2 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + b SW_G +:SW_BIG + bl ALLOC + mov.x x13 x0 + ldr.x x1 sp 5 + bl MATCONST + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xc, Xn = SUBS XZR, Xc, Xn, C6.2.97 + ldr.x x1 sp 2 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ubfm.x x1 x13 48 47 + orr.x x0 x0 x1 + bl EMIT +:SW_G + movz.x x0 2 0 + movz.x x1 4 0 + bl TRAPC + movz.x x0 0x0400 0 + movk.x x0 0x9100 1 ; ADD Xc, Xc, #1, C6.2.5 + ldr.x x1 sp 2 + orr.x x0 x0 x1 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + ldr.x x0 sp 4 + movz.x x1 3 0 + ldr.x x2 sp 3 + ldr.x x3 sp 2 + movz.x x4 0 0 + ldr.x x5 sp 0 + ldr.x x6 sp 1 + bl PUSHB + add.x.i sp sp 64 + b STMT +; ---- for i T K (K a number): i = 0; head: not i < K -> exit; body; latch i = add i 1; B head ---- +; ---- for i T K: i = 0; head: not i < K -> exit; body; latch i = add i 1; B head. K a number, or a value +; of type T: a name is read at every pass, another value once before the loop; then the hidden counter +; guard of a while with no bound (trap 4 after 1000000 passes) ---- +:S_FOR + sub.x.i sp sp 80 + str.x x23 sp 0 + str.x x28 sp 1 + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_LONG + str.x x1 sp 2 + bl KW + cbnz.x x0 E_SYNTAX + ldr.x x1 sp 2 + bl NEWNAME + bl TYPEWORD + str.x x0 sp 3 + cmp.x.i x0 1 + b.eq E_TYPE + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 2 + b.ne SF_VAL + ldr.x x2 sp 3 + movz.x x9 0x185 1 + ldr.x x3 x9 11 + bl RANGE + str.x x1 sp 4 +:SF_NUM + bl EOL + bl ALLOC + mov.x x28 x24 + str.x x0 sp 5 + mov.x x2 x0 + ldr.x x1 sp 2 + ldr.x x3 sp 3 + movz.x x4 0 0 + movz.x x5 0 0 + movz.x x6 0 0 + bl ADDNAME + ldr.x x0 sp 5 + movz.x x9 0xd280 1 ; MOVZ Xi, #0, C6.2.285 + orr.x x0 x0 x9 + bl EMIT + str.x x20 sp 6 + ldr.x x1 sp 4 + movz.x x9 4095 0 + cmp.x x1 x9 + b.hi SF_BIG + movz.x x0 0x001f 0 + movk.x x0 0xf100 1 ; CMP Xi, #K, C6.2.96 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + ldr.x x1 sp 5 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + b SF_B +:SF_BIG + bl ALLOC + mov.x x13 x0 + ldr.x x1 sp 4 + bl MATCONST + mov.x x1 x13 + b SF_CMPR +; a value count +:SF_VAL + mov.x x3 x0 + mov.x x4 x1 + mov.x x5 x2 + ldr.x x0 sp 3 + movz.x x1 255 0 + bl VALTOK + cmp.x.i x0 3 + b.eq SF_TYPED + ldr.x x9 sp 3 + cmp.x x2 x9 + b.ne E_TYPE + bl MATREG + str.x x0 sp 7 + bl EOL + bl ALLOC + mov.x x28 x24 + str.x x0 sp 5 + mov.x x2 x0 + ldr.x x1 sp 2 + ldr.x x3 sp 3 + movz.x x4 0 0 + movz.x x5 0 0 + movz.x x6 0 0 + bl ADDNAME + ldr.x x0 sp 5 + movz.x x9 0xd280 1 ; MOVZ Xi, #0, C6.2.285 + orr.x x0 x0 x9 + bl EMIT + bl ALLOC + mov.x x28 x24 + str.x x0 sp 8 + movz.x x9 0xd280 1 ; MOVZ Xc, #0 (the hidden counter), C6.2.285 + orr.x x0 x0 x9 + bl EMIT + str.x x20 sp 6 + ldr.x x1 sp 7 + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xi, Xn, C6.2.97 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + ldr.x x1 sp 5 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + bl SF_BR + str.x x0 sp 9 + bl ALLOC + mov.x x13 x0 + movz.x x1 0x4240 0 + movk.x x1 0x000f 1 + bl MATCONST + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xc, Xm (the counter against 1000000), C6.2.97 + ldr.x x1 sp 8 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ubfm.x x1 x13 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 2 0 + movz.x x1 4 0 + bl TRAPC + movz.x x0 0x0400 0 + movk.x x0 0x9100 1 ; ADD Xc, Xc, #1, C6.2.5 + ldr.x x1 sp 8 + orr.x x0 x0 x1 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + ldr.x x0 sp 9 + b SF_PUSH +:SF_TYPED + ldr.x x9 sp 3 + cmp.x x2 x9 + b.ne E_TYPE + str.x x1 sp 4 + b SF_NUM +:SF_CMPR + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xi, Xk, C6.2.97 + ldr.x x9 sp 5 + ubfm.x x9 x9 59 58 + orr.x x0 x0 x9 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT +:SF_B + bl SF_BR +:SF_PUSH + movz.x x1 4 0 + ldr.x x2 sp 6 + ldr.x x3 sp 5 + ldr.x x4 sp 3 + ldr.x x5 sp 0 + ldr.x x6 sp 1 + bl PUSHB + add.x.i sp sp 80 + b STMT +; SF_BR: B.HS (unsigned) or B.GE (signed) to the loop exit, C6.2.34 (distance filled at end); x0 = its place +; (the loop type is the caller frame slot 3, at sp + 40 once this routine has pushed 16 bytes) +:SF_BR + str.x.pre x30 sp -16 + mov.x x13 x20 + movz.x x0 0x5400 1 ; B.cond, C6.2.34 + ldr.x x9 sp 5 + movz.x x1 2 0 + cmp.x.i x9 6 + b.lo SFB1 + movz.x x1 10 0 +:SFB1 + orr.x x0 x0 x1 + bl EMIT + mov.x x0 x13 + ldr.x.post x30 sp 16 + ret +; ---- end: close the innermost block, or the function ---- +:S_END + movz.x x9 0x181 1 + cmp.x x25 x9 + b.eq FINISH + sub.x.i x25 x25 128 + movz.x x9 0x185 1 + ldr.x x0 x25 0 + cmp.x.i x0 2 + b.eq SE_D + str.x xzr x9 5 + b SE_D2 +:SE_D + ldr.x x10 x9 5 + ldr.x x11 x25 7 + and.x x10 x10 x11 + str.x x10 x9 5 +:SE_D2 + cmp.x.i x0 1 + b.eq SE_IF + cmp.x.i x0 2 + b.eq SE_ELSE + cmp.x.i x0 3 + b.eq SE_WHILE + sub.x.i sp sp 48 + movz.x x0 1 0 + str.x x0 sp 0 + ldr.x x0 x25 3 + str.x x0 sp 1 + ldr.x x0 x25 4 + str.x x0 sp 2 + movz.x x0 3 0 + str.x x0 sp 3 + movz.x x0 1 0 + str.x x0 sp 4 + ldr.x x0 x25 4 + str.x x0 sp 5 + movz.x x0 33 0 + ldr.x x1 x25 3 + add.x.i x2 sp 0 + bl BINOP + add.x.i sp sp 48 +:SE_WHILE + ldr.x x0 x25 2 + bl BACK +:SE_IF + ldr.x x0 x25 1 + mov.x x1 x20 + bl PATCH19 + b SE_X +:SE_ELSE + ldr.x x0 x25 1 + mov.x x1 x20 + bl PATCH26 +:SE_X + ldr.x x23 x25 5 + ldr.x x28 x25 6 + bl EOL + b STMT +; ---- end of a function: a void function that can reach its end returns; trap stubs ---- +; shared tail, function mode: MOV X0, X7; LDR X16, [X7, #16]; BR X16 (OscRt.trap); program mode: +; ADD X0, X1, #100; MOVZ X8, #93; SVC #0 (exit 100 + code). Per trap code used: MOVZ X1, #code; B tail. +:FINISH + bl EOL + movz.x x9 0x185 1 + ldr.x x10 x9 5 + cbnz.x x10 FI_0 + cmp.x.i x27 10 + b.ne E_NORET + bl EPI +:FI_0 + movz.x x9 0x182 1 + cmp.x x26 x9 + b.eq FI_T + mov.x x13 x20 + movz.x x9 0x185 1 + ldr.x x10 x9 6 + cbnz.x x10 FI_PT + movz.x x0 0x03e0 0 + movk.x x0 0xaa07 1 ; MOV X0, X7 = ORR X0, XZR, X7, C6.2.282 + bl EMIT + movz.x x0 0x08f0 0 + movk.x x0 0xf940 1 ; LDR X16, [X7, #16], unsigned offset imm12 = 2, C6.2.216 + bl EMIT + movz.x x0 0x0200 0 + movk.x x0 0xd61f 1 ; BR X16, C6.2.46 + bl EMIT + b FI_C0 +:FI_PT + movz.x x0 0x9020 0 + movk.x x0 0x9101 1 ; ADD X0, X1, #100, C6.2.5 + bl EMIT + movz.x x0 0x0ba8 0 + movk.x x0 0xd280 1 ; MOVZ X8, #93, C6.2.285 + bl EMIT + movz.x x0 0x0001 0 + movk.x x0 0xd400 1 ; SVC #0, C6.2.466 + bl EMIT +:FI_C0 + movz.x x14 1 0 +:FI_C + movz.x x15 0 0 + movz.x x12 0x182 1 +:FI_S + cmp.x x12 x26 + b.hs FI_N + ldr.w w0 x12 1 + cmp.x x0 x14 + b.ne FI_NX + cbnz.x x15 FI_P + mov.x x15 x20 + movz.x x0 0x0001 0 + movk.x x0 0xd280 1 ; MOVZ X1, #code, C6.2.285 + ubfm.x x1 x14 59 58 + orr.x x0 x0 x1 + bl EMIT + mov.x x0 x13 + bl BACK +:FI_P + ldr.w w0 x12 0 + mov.x x1 x15 + bl PATCH19 +:FI_NX + add.x.i x12 x12 8 + b FI_S +:FI_N + add.x.i x14 x14 1 + cmp.x.i x14 14 + b.ls FI_C +:FI_T + movz.x x27 0 0 + movz.x x9 0x185 1 + ldr.x x23 x9 1 + str.x xzr x9 3 + b STMT +; ---- end of input: write the output ---- +:S_EOF + cbnz.x x27 E_BLOCK + bl RESOLVE + movz.x x9 0x185 1 + ldr.x x10 x9 2 + cbz.x x10 E_SYNTAX + ldr.x x11 x9 6 + cbnz.x x11 EOF_PROG + ldr.x x11 x9 1 + cbnz.x x11 E_SUBSET + add.x.i x12 x21 180 + cmp.x.i x10 1 + b.eq WRITEOUT + ldr.x x0 x9 9 + ldr.x x0 x0 1 + add.x.i x12 x21 176 + sub.x x2 x0 x12 + ubfm.x x2 x2 2 27 + movz.x x3 0x1400 1 ; B to the last function, C6.2.35 + orr.x x3 x3 x2 + str.w w3 x12 0 + b WRITEOUT +; program mode: start code = MOVZ X28, #0x1000, LSL 16 (stack pool floor); MOVZ X16, #0x1080, LSL 16; +; MOV SP, X16 (ADD immediate, C6.2.5); BL main (C6.2.43); [MOVZ X0, #0 for a void main]; MOVZ X8, #93; +; SVC #0. The entry word after the header is a B to it. +:EOF_PROG + movz.x x2 4 0 + movz.x x1 0x616d 0 + movk.x x1 0x6e69 1 + bl FINDFN + cbz.x x0 E_SYNTAX + ldr.w w9 x0 5 + cbnz.x x9 E_SUBSET + mov.x x14 x0 + add.x.i x12 x21 176 + sub.x x2 x20 x12 + ubfm.x x2 x2 2 27 + movz.x x3 0x1400 1 ; B, C6.2.35 + orr.x x3 x3 x2 + str.w w3 x12 0 + movz.x x0 0x001c 0 + movk.x x0 0xd2a2 1 ; MOVZ X28, #0x1000, LSL #16, C6.2.285 + bl EMIT + movz.x x0 0x1010 0 + movk.x x0 0xd2a2 1 ; MOVZ X16, #0x1080, LSL #16, C6.2.285 + bl EMIT + movz.x x0 0x021f 0 + movk.x x0 0x9100 1 ; MOV SP, X16 = ADD SP, X16, #0, C6.2.5 + bl EMIT + ldr.x x0 x14 1 + sub.x x2 x0 x20 + ubfm.x x2 x2 2 27 + movz.x x0 0x9400 1 ; BL main, C6.2.43 + orr.x x0 x0 x2 + bl EMIT + ldr.w w9 x14 4 + cmp.x.i x9 10 + b.ne EP1 + movz.x x0 0xd280 1 ; MOVZ X0, #0, C6.2.285 + bl EMIT +:EP1 + movz.x x0 0x0ba8 0 + movk.x x0 0xd280 1 ; MOVZ X8, #93, C6.2.285 + bl EMIT + movz.x x0 0x0001 0 + movk.x x0 0xd400 1 ; SVC #0, C6.2.466 + bl EMIT + adr x10 ELFHDR + mov.x x11 x21 + movz.x x12 0 0 +:EP2 + ldr.w.post w0 x10 4 + str.w.post w0 x11 4 + add.x.i x12 x12 1 + cmp.x.i x12 44 + b.lo EP2 + sub.x x0 x20 x21 + str.w w0 x21 24 + str.w w0 x21 26 + movz.x x9 0x185 1 + ldr.x x0 x9 7 + movz.x x1 0x80 1 + add.x x0 x0 x1 + str.w w0 x21 40 + mov.x x12 x21 +:WRITEOUT + sub.x x2 x20 x12 + cbz.x x2 EXIT0 + movz.x x0 1 0 + mov.x x1 x12 + movz.x x8 64 0 + svc 0 + cmp.x.i x0 0 + b.le E_WRITE + add.x x12 x12 x0 + b WRITEOUT +:EXIT0 + movz.x x0 0 0 + movz.x x8 93 0 + svc 0 +; VAL: read one value. x0 expected type (0 none), x1 destination register (255 none). +; Out: x0 kind (1 register, 2 bare number, 3 typed number, 4 flags), x1 register / number / condition, +; x2 type. Only the outermost op writes the destination. Clobbers x0..x17. +:VAL + str.x.pre x30 sp -32 + str.x x0 sp 1 + str.x x1 sp 2 + bl TOK + mov.x x3 x0 + mov.x x4 x1 + mov.x x5 x2 + ldr.x x0 sp 1 + ldr.x x1 sp 2 + ldr.x.post x30 sp 32 +; VALTOK: the same with the first word already read (x3 kind, x4 word or number, x5 length). +; Frame (8-byte slots): 0 x30, 1 expected, 2 dest, 3 op, 4..6 a, 7..9 b, 10 type of a conversion. +:VALTOK + str.x.pre x30 sp -128 + str.x x0 sp 1 + str.x x1 sp 2 + movz.x x9 0x185 1 ; nesting depth (state slot 10): at most 1024 values inside one another, else error 14 + ldr.x x10 x9 10 + add.x.i x10 x10 1 + str.x x10 x9 10 + cmp.x.i x10 1024 + b.hi E_FULL + cbz.x x3 E_FEW + cmp.x.i x3 3 + b.eq E_FEW + cmp.x.i x3 4 + b.eq E_SYNTAX + cmp.x.i x3 2 + b.ne VT_W + mov.x x1 x4 + movz.x x9 0x185 1 ; a bare number: x2 = 1 when written as 2^63 or more (RANGE needs it later) + ldr.x x2 x9 11 + movz.x x0 2 0 + ldr.x x9 sp 1 + cbz.x x9 VT_RET + mov.x x3 x2 + mov.x x2 x9 + bl RANGE + movz.x x0 3 0 + b VT_RET +:VT_W + cmp.x.i x5 8 + b.hi VT_LONG + mov.x x1 x4 + bl KW + cbnz.x x0 VT_K + str.x x1 sp 4 + bl FINDNAME + cbz.x x0 VT_FN + ldr.w w9 x0 5 + cbnz.x x9 E_TYPE + ldr.w w1 x0 2 + ldr.w w2 x0 3 + movz.x x0 1 0 + b VT_RET +; a call of a function that gives a value +:VT_FN + ldr.x x1 sp 4 + movz.x x2 0 0 + bl FINDFN + cbz.x x0 E_UNDEF +:VT_FN2 + ldr.w w9 x0 4 + cmp.x.i x9 10 + b.eq E_TYPE + ldr.x x1 sp 2 + bl CALL + b VT_RET +:VT_K + sub.x.i x9 x0 1 + cmp.x.i x9 8 + b.ls VT_TYPE + cmp.x.i x0 74 + b.eq VT_PAREN + cmp.x.i x0 77 + b.eq E_SUBSET + str.x x0 sp 3 + cmp.x.i x0 51 + b.eq VT_GET + cmp.x.i x0 52 + b.eq VT_LEN + cmp.x.i x0 53 + b.eq VT_SYS + cmp.x.i x0 54 + b.eq VT_SYS + cmp.x.i x0 55 + b.eq VT_TRUE + cmp.x.i x0 56 + b.eq VT_FALSE + sub.x.i x9 x0 33 + cmp.x.i x9 17 + b.hi E_SYNTAX + str.x x0 sp 3 + cmp.x.i x0 49 + b.hs VT_UN +; binary op: a, then b; a comparison used as a value is turned into a register at once (flags would not +; survive the next value) + movz.x x0 0 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x0 4 + b.ne VB1 + bl MATREG + mov.x x1 x0 + movz.x x0 1 0 + movz.x x2 1 0 +:VB1 + str.x x0 sp 4 + str.x x1 sp 5 + str.x x2 sp 6 + movz.x x0 0 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x0 4 + b.ne VB2 + bl MATREG + mov.x x1 x0 + movz.x x0 1 0 + movz.x x2 1 0 +:VB2 + str.x x0 sp 7 + str.x x1 sp 8 + str.x x2 sp 9 +; a bare number takes the type of the other value (in a shift too: shl 1 sh) + ldr.x x10 sp 4 + ldr.x x11 sp 7 + cmp.x.i x10 2 + b.ne VB3 + cmp.x.i x11 2 + b.eq E_BARE + ldr.x x1 sp 5 + ldr.x x2 sp 9 + ldr.x x3 sp 6 + bl RANGE + str.x x2 sp 6 + movz.x x0 3 0 + str.x x0 sp 4 +:VB3 + cmp.x.i x11 2 + b.ne VB4 + ldr.x x1 sp 8 + ldr.x x2 sp 6 + ldr.x x3 sp 9 + bl RANGE + str.x x2 sp 9 + movz.x x0 3 0 + str.x x0 sp 7 +:VB4 + ldr.x x0 sp 3 + cmp.x.i x0 41 + b.eq VB5 + cmp.x.i x0 42 + b.eq VB5 + ldr.x x1 sp 6 + ldr.x x2 sp 9 + cmp.x x1 x2 + b.ne E_TYPE +:VB5 + ldr.x x0 sp 3 + ldr.x x1 sp 2 + add.x.i x2 sp 32 + bl BINOP +:VT_RET + movz.x x9 0x185 1 + ldr.x x10 x9 10 + sub.x.i x10 x10 1 + str.x x10 x9 10 + ldr.x.post x30 sp 128 + ret +; ( value ) +:VT_PAREN + ldr.x x0 sp 1 + ldr.x x1 sp 2 + bl VAL + str.x x0 sp 4 + str.x x1 sp 5 + str.x x2 sp 6 + bl TOK + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_SYNTAX + bl KW + cmp.x.i x0 75 + b.ne E_SYNTAX + ldr.x x0 sp 4 + ldr.x x1 sp 5 + ldr.x x2 sp 6 + b VT_RET +; neg a, not a (a bare number takes the expected type) +:VT_UN + ldr.x x0 sp 1 + movz.x x1 255 0 + bl VAL + ldr.x x9 sp 3 + cmp.x.i x9 50 + b.ne VU1 + cmp.x.i x0 4 + b.ne VU1 + movz.x x9 1 0 + eor.x x1 x1 x9 + b VT_RET +:VU1 + cmp.x.i x0 2 + b.eq E_BARE + str.x x2 sp 6 + bl MATREG + str.x x0 sp 5 + ldr.x x0 sp 2 + bl DESTREG + str.x x0 sp 7 + ldr.x x9 sp 3 + cmp.x.i x9 50 + b.eq VU_NOT + ldr.x x9 sp 6 + cmp.x.i x9 1 + b.eq E_TYPE + cmp.x.i x9 9 + b.eq VN64 + movz.x x0 0x03e0 0 + movk.x x0 0xcb00 1 ; NEG Xd, Xm = SUB Xd, XZR, Xm, C6.2.458 + cmp.x.i x9 4 + b.ne VN1 + movz.x x0 0x03e0 0 + movk.x x0 0x4b00 1 ; NEG Wd, Wm (32-bit SUB, C6.2.458): the u32 result comes zero-extended + bl VU_E + b VU_R +:VN1 + bl VU_E + ldr.x x0 sp 7 + ldr.x x1 sp 6 + cmp.x.i x1 6 + b.hs VN2 + bl CANON + b VU_R +:VN2 + movz.x x2 1 0 + bl CHKEXT + b VU_R +:VN64 + movz.x x0 0x03e0 0 + movk.x x0 0xeb00 1 ; NEGS Xd, Xm = SUBS Xd, XZR, Xm, C6.2.465 + bl VU_E + movz.x x0 6 0 + movz.x x1 1 0 + bl TRAPC + b VU_R +:VU_NOT + ldr.x x9 sp 6 + cmp.x.i x9 1 + b.ne VNT1 + movz.x x0 0 0 + movk.x x0 0xd240 1 ; EOR Xd, Xn, #1 (immediate, N=1 immr=0 imms=0), C6.2.155 + ldr.x x1 sp 7 + ldr.x x2 sp 5 + movz.x x3 0 0 + bl E3 + b VU_R +:VNT1 + movz.x x0 0x03e0 0 + movk.x x0 0xaa20 1 ; MVN Xd, Xm = ORN Xd, XZR, Xm, C6.2.300 + cmp.x.i x9 4 + b.ne VNT2 + movz.x x0 0x03e0 0 + movk.x x0 0x2a20 1 ; MVN Wd, Wm (32-bit ORN, C6.2.300) + bl VU_E + b VU_R +:VNT2 + bl VU_E + ldr.x x0 sp 7 + ldr.x x1 sp 6 + cmp.x.i x1 6 + b.hs VU_R + bl CANON +:VU_R + movz.x x0 1 0 + ldr.x x1 sp 7 + ldr.x x2 sp 6 + b VT_RET +:VU_E + ldr.x x1 sp 7 + movz.x x2 0 0 + ldr.x x3 sp 5 + b E3 +; a type word: a typed number (uint 5) or a conversion of the next value +:VT_TYPE + str.x x0 sp 10 + bl TOK + cmp.x.i x0 2 + b.ne VTT1 + ldr.x x2 sp 10 + movz.x x9 0x185 1 ; x3 = the number was written as 2^63 or more + ldr.x x3 x9 11 + bl RANGE + movz.x x0 3 0 + b VT_RET +:VTT1 + mov.x x3 x0 + mov.x x4 x1 + mov.x x5 x2 + movz.x x0 0 0 + movz.x x1 255 0 + bl VALTOK + cmp.x.i x0 2 + b.eq E_BARE + str.x x2 sp 6 + bl MATREG + str.x x0 sp 5 + ldr.x x1 sp 6 + ldr.x x2 sp 10 + cmp.x.i x1 1 + b.eq E_SUBSET + cmp.x.i x2 1 + b.eq E_SUBSET + adr x9 TWID + ldrb.r w3 x9 x1 + ldrb.r w4 x9 x2 + cmp.x.i x1 6 + b.hs VC_SS + cmp.x.i x2 6 + b.hs VC_US + cmp.x x3 x4 + b.ls VC_OK + mov.x x5 x4 + b VC_LSR +:VC_US + cmp.x x3 x4 + b.lo VC_OK + sub.x.i x5 x4 1 + b VC_LSR +:VC_SS + cmp.x.i x2 6 + b.hs VC_S2 + mov.x x5 x4 + cmp.x.i x5 63 + b.ls VC_LSR + movz.x x5 63 0 + b VC_LSR +:VC_S2 + cmp.x x3 x4 + b.ls VC_OK + ldr.x x0 sp 5 + ldr.x x1 sp 10 + movz.x x2 5 0 + bl CHKEXT + b VC_OK +; out of range when any bit at or above x5 is set: LSR Xt, Xa, #x5 = UBFM Xt, Xa, #x5, #63 (C6.2.487); +; CBNZ Xt -> trap 5 (C6.2.77) +:VC_LSR + bl ALLOC + str.x x0 sp 7 + movz.x x1 0xfc00 0 + movk.x x1 0xd340 1 + orr.x x1 x1 x0 + ubfm.x x5 x5 48 47 + orr.x x1 x1 x5 + ldr.x x2 sp 5 + ubfm.x x2 x2 59 58 + orr.x x0 x1 x2 + bl EMIT + ldr.x x0 sp 7 + movz.x x9 0xb500 1 ; CBNZ Xt, C6.2.77 + orr.x x0 x0 x9 + movz.x x1 5 0 + bl TRAPSITE +:VC_OK + movz.x x0 1 0 + ldr.x x1 sp 5 + ldr.x x2 sp 10 + b VT_RET +; ====================================================================================================== +; BINOP: x0 op (33..48), x1 destination (255 none), x2 address of two values (kind, number/register, +; type) a then b, types already settled. Out: as VAL. Frame: 0 x30, 1 op, 2 rd, 3 values, 4 ra, +; 5 rb or immediate, 6 type, 7 1 if b is an immediate, 8 temporary. +:BINOP + str.x.pre x30 sp -80 + str.x x0 sp 1 + str.x x1 sp 2 + str.x x2 sp 3 + ldr.x x9 x2 2 + str.x x9 sp 6 + ldr.x x0 x2 0 + ldr.x x1 x2 1 + ldr.x x2 x2 2 + bl MATREG + str.x x0 sp 4 + movz.x x9 0 0 + str.x x9 sp 7 + ldr.x x10 sp 3 + ldr.x x0 x10 3 + cmp.x.i x0 3 + b.ne BO_BREG + ldr.x x1 x10 4 + ldr.x x11 sp 1 + cmp.x.i x11 41 + b.eq BO_IS + cmp.x.i x11 42 + b.eq BO_IS + cmp.x.i x11 35 + b.lo BO_II + cmp.x.i x11 43 + b.lo BO_BREG +:BO_II + movz.x x9 4095 0 + cmp.x x1 x9 + b.hi BO_BREG + b BO_IMM +:BO_IS + ldr.x x9 sp 6 + adr x12 TWID + ldrb.r w9 x12 x9 + cmp.x x1 x9 + b.hs BO_BREG +:BO_IMM + str.x x1 sp 5 + movz.x x9 1 0 + str.x x9 sp 7 + b BO_OPS +:BO_BREG + ldr.x x10 sp 3 + ldr.x x0 x10 3 + ldr.x x1 x10 4 + ldr.x x2 x10 5 + bl MATREG + str.x x0 sp 5 +:BO_OPS + ldr.x x0 sp 1 + cmp.x.i x0 43 + b.hs BO_CMP + ldr.x x9 sp 6 + cmp.x.i x9 1 + b.ne BO_NB + sub.x.i x10 x0 38 + cmp.x.i x10 2 + b.hi E_TYPE +:BO_NB + ldr.x x0 sp 2 + bl DESTREG + str.x x0 sp 2 + ldr.x x0 sp 1 + cmp.x.i x0 35 + b.lo BO_ADD + b.eq BO_MUL + cmp.x.i x0 38 + b.lo BO_DIV + cmp.x.i x0 41 + b.lo BO_LOG + b.eq BO_SHL + b BO_SHR +; add, sub. u32: 32-bit form (zero-extends); i64: flag-setting form + B.VS trap 1; u8/u16: wrap with +; UBFM; i8/i16/i32: exact in 64 bits, then the sign-extension check (trap 1) +:BO_ADD + ldr.x x9 sp 1 + ldr.x x10 sp 7 + cbnz.x x10 BA_I + movz.x x0 0x8b00 1 ; ADD (shifted register) 64-bit, C6.2.6 + cmp.x.i x9 33 + b.eq BA_S + movz.x x0 0xcb00 1 ; SUB (shifted register) 64-bit, C6.2.458 + b BA_S +:BA_I + movz.x x0 0x9100 1 ; ADD (immediate) 64-bit, C6.2.5 + cmp.x.i x9 33 + b.eq BA_S + movz.x x0 0xd100 1 ; SUB (immediate) 64-bit, C6.2.457 +:BA_S + ldr.x x9 sp 6 + cmp.x.i x9 4 + b.ne BA2 + movz.x x10 0x8000 1 ; sf (bit 31) = 0: the 32-bit form + eor.x x0 x0 x10 + bl BO_W3 + b BO_RET +:BA2 + cmp.x.i x9 9 + b.ne BA3 + movz.x x10 0x2000 1 ; S (bit 29) = 1: ADDS/SUBS, C6.2.10, C6.2.11, C6.2.464, C6.2.465 + orr.x x0 x0 x10 + bl BO_W3 + movz.x x0 6 0 + movz.x x1 1 0 + bl TRAPC + b BO_RET +:BA3 + bl BO_W3 + bl BO_FIX + b BO_RET +; mul. i64: SMULH t (C6.2.379), MUL, CMP t, rd, ASR #63 (C6.2.97), B.NE trap 1 +:BO_MUL + ldr.x x9 sp 6 + cmp.x.i x9 9 + b.eq BM64 + movz.x x0 0x7c00 0 + movk.x x0 0x9b00 1 ; MUL 64-bit = MADD Xd, Xn, Xm, XZR, C6.2.293 / C6.2.275 + cmp.x.i x9 4 + b.ne BM1 + movz.x x10 0x8000 1 + eor.x x0 x0 x10 + bl BO_W3 + b BO_RET +:BM1 + bl BO_W3 + bl BO_FIX + b BO_RET +:BM64 + bl ALLOC + str.x x0 sp 8 + movz.x x0 0x7c00 0 + movk.x x0 0x9b40 1 ; SMULH, C6.2.379 + ldr.x x1 sp 8 + ldr.x x2 sp 4 + ldr.x x3 sp 5 + bl E3 + movz.x x0 0x7c00 0 + movk.x x0 0x9b00 1 ; MUL, C6.2.293 + bl BO_W3 + movz.x x0 0xfc1f 0 + movk.x x0 0xeb80 1 ; CMP Xt, Xd, ASR #63 = SUBS XZR, Xt, Xd, ASR #63, C6.2.465 + movz.x x1 0 0 + ldr.x x2 sp 8 + ldr.x x3 sp 2 + bl E3 + movz.x x0 1 0 + movz.x x1 1 0 + bl TRAPC + b BO_RET +; div, rem (unsigned): CBZ Xb -> trap 2 (C6.2.78), unless b is a number other than 0; UDIV (C6.2.490); +; rem: t = a / b; rd = a - t * b (MSUB Xd, Xt, Xb, Xa, C6.2.291) +:BO_DIV + ldr.x x9 sp 6 + cmp.x.i x9 6 + b.hs BO_SDIV + ldr.x x10 sp 3 + ldr.x x0 x10 3 + cmp.x.i x0 3 + b.ne BD1 + ldr.x x0 x10 4 + cbnz.x x0 BD2 +:BD1 + ldr.x x0 sp 5 + movz.x x9 0xb400 1 ; CBZ Xb, C6.2.78 + orr.x x0 x0 x9 + movz.x x1 2 0 + bl TRAPSITE +:BD2 + ldr.x x9 sp 1 + cmp.x.i x9 37 + b.eq BD_REM + movz.x x0 0x0800 0 + movk.x x0 0x9ac0 1 ; UDIV 64-bit, C6.2.490 + bl BO_W3 + b BO_RET +:BD_REM + bl ALLOC + str.x x0 sp 8 + movz.x x0 0x0800 0 + movk.x x0 0x9ac0 1 ; UDIV, C6.2.490 + ldr.x x1 sp 8 + ldr.x x2 sp 4 + ldr.x x3 sp 5 + bl E3 + movz.x x0 0x8000 0 + movk.x x0 0x9b00 1 ; MSUB 64-bit, C6.2.291 (Ra at bit 10) + ldr.x x1 sp 4 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + ldr.x x1 sp 2 + ldr.x x2 sp 8 + ldr.x x3 sp 5 + bl E3 + b BO_RET +; and, or, xor: canonical in, canonical out +:BO_LOG + movz.x x0 0x8a00 1 ; AND (shifted register) 64-bit, C6.2.15 + ldr.x x9 sp 1 + cmp.x.i x9 39 + b.lo BL1 + movz.x x0 0xaa00 1 ; ORR (shifted register) 64-bit, C6.2.302 + b.eq BL1 + movz.x x0 0xca00 1 ; EOR (shifted register) 64-bit, C6.2.156 +:BL1 + bl BO_W3 + b BO_RET +; shl (unsigned): by a number s: LSL #s = UBFM Xd, Xn, #(64-s) mod 64, #(63-s) (C6.2.487), then wrap; +; by a register: CMP Xb, #w; B.HS trap 7; LSLV (C6.2.271; 32-bit for u32) +:BO_SHL + ldr.x x9 sp 6 + cmp.x.i x9 9 + b.eq BS_64 + ldr.x x10 sp 7 + cbnz.x x10 BS_IL + bl BO_SCHK + movz.x x0 0x2000 0 + movk.x x0 0x9ac0 1 ; LSLV 64-bit, C6.2.271 + ldr.x x9 sp 6 + cmp.x.i x9 4 + b.ne BS1 + movz.x x10 0x8000 1 + eor.x x0 x0 x10 + bl BO_W3 + b BO_RET +:BS1 + bl BO_W3 + bl BO_FIX + b BO_RET +:BS_IL + ldr.x x1 sp 5 + movz.x x2 64 0 + sub.x x2 x2 x1 + ubfm.x x2 x2 0 5 + movz.x x3 63 0 + sub.x x3 x3 x1 + movz.x x0 0xd340 1 ; UBFM 64-bit, C6.2.487 + ubfm.x x2 x2 48 47 + orr.x x0 x0 x2 + ubfm.x x3 x3 54 53 + orr.x x0 x0 x3 + ldr.x x1 sp 4 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 2 + orr.x x0 x0 x1 + bl EMIT + bl BO_FIX + b BO_RET +; shr: unsigned LSR, signed ASR. By a number s: UBFM/SBFM Xd, Xn, #s, #63 (C6.2.487, C6.2.355); +; by a register: the amount check, then LSRV (C6.2.274) / ASRV (C6.2.21) +:BO_SHR + ldr.x x10 sp 7 + cbnz.x x10 BR_I + bl BO_SCHK + movz.x x0 0x2400 0 + movk.x x0 0x9ac0 1 ; LSRV 64-bit, C6.2.274 + ldr.x x9 sp 6 + cmp.x.i x9 6 + b.lo BR1 + movz.x x0 0x2800 0 + movk.x x0 0x9ac0 1 ; ASRV 64-bit, C6.2.21 +:BR1 + bl BO_W3 + b BO_RET +:BR_I + movz.x x0 0xfc00 0 + movk.x x0 0xd340 1 ; UBFM Xd, Xn, #s, #63 = LSR, C6.2.487 + ldr.x x9 sp 6 + cmp.x.i x9 6 + b.lo BR2 + movz.x x0 0xfc00 0 + movk.x x0 0x9340 1 ; SBFM Xd, Xn, #s, #63 = ASR, C6.2.355 +:BR2 + ldr.x x1 sp 5 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + ldr.x x1 sp 4 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 2 + orr.x x0 x0 x1 + bl EMIT + b BO_RET +; comparisons: CMP Xa, #imm (C6.2.96) or CMP Xa, Xb (C6.2.97); the result is the flags and a condition +:BO_CMP + ldr.x x10 sp 7 + cbnz.x x10 BC_I + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP (shifted register) = SUBS XZR, Xa, Xb, C6.2.97 + ldr.x x1 sp 5 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + b BC_E +:BC_I + movz.x x0 0x001f 0 + movk.x x0 0xf100 1 ; CMP (immediate) = SUBS XZR, Xa, #imm, C6.2.96 + ldr.x x1 sp 5 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 +:BC_E + ldr.x x1 sp 4 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + ldr.x x9 sp 1 + sub.x.i x9 x9 43 + add.x x9 x9 x9 + ldr.x x10 sp 6 + cmp.x.i x10 6 + b.lo BC1 + add.x.i x9 x9 1 +:BC1 + adr x10 CONDS + ldrb.r w1 x10 x9 + movz.x x0 4 0 + movz.x x2 1 0 + b BO_RET2 +:BO_RET + movz.x x0 1 0 + ldr.x x1 sp 2 + ldr.x x2 sp 6 +:BO_RET2 + ldr.x.post x30 sp 80 + ret +; BO_W3: x0 fixed part; emit it | rd | ra << 5 | (imm12 << 10, or rb << 16), fields from the BINOP frame +:BO_W3 + ldr.x x1 sp 2 + orr.x x0 x0 x1 + ldr.x x1 sp 4 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 5 + ldr.x x2 sp 7 + cbnz.x x2 BW_I + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + b EMIT +:BW_I + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + b EMIT +; BO_FIX: after a 64-bit op on rd: u8/u16/u32 wrap (CANON), i8/i16/i32 overflow check (trap 1) +:BO_FIX + ldr.x x1 sp 6 + ldr.x x0 sp 2 + cmp.x.i x1 6 + b.lo CANON + cmp.x.i x1 9 + b.eq BF_X + movz.x x2 1 0 + b CHKEXT +:BF_X + ret +; BO_SCHK: shift amount in a register must be below the width: CMP Xb, #w (C6.2.96); B.HS trap 7 +:BO_SCHK + ldr.x x1 sp 6 + adr x9 TWID + ldrb.r w1 x9 x1 + ldr.x x2 sp 5 + movz.x x0 0x001f 0 + movk.x x0 0xf100 1 ; CMP Xb, #w, C6.2.96 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + ubfm.x x2 x2 59 58 + orr.x x0 x0 x2 + str.x.pre x30 sp -16 + bl EMIT + movz.x x0 2 0 + movz.x x1 7 0 + bl TRAPC + ldr.x.post x30 sp 16 + ret +; ====================================================================================================== +; COND: read a condition (a bool value); emit a branch taken when it is false; x0 = that branch's address +:COND + str.x.pre x30 sp -16 + movz.x x0 1 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x2 1 + b.ne E_TYPE + cmp.x.i x0 4 + b.ne CO1 + movz.x x9 1 0 + eor.x x1 x1 x9 + movz.x x0 0x5400 1 ; B.cond with the opposite condition, C6.2.34 + orr.x x0 x0 x1 + b CO2 +:CO1 + bl MATREG + movz.x x9 0xb400 1 ; CBZ Xr, C6.2.78 + orr.x x0 x0 x9 +:CO2 + mov.x x10 x20 + bl EMIT + mov.x x0 x10 + ldr.x.post x30 sp 16 + ret +; MATREG: x0 kind, x1 number/register/condition, x2 type -> x0 a register holding the value +:MATREG + cmp.x.i x0 1 + b.ne MR1 + mov.x x0 x1 + ret +:MR1 + str.x.pre x30 sp -32 + str.x x0 sp 1 + str.x x1 sp 2 + str.x x2 sp 3 + bl ALLOC + mov.x x3 x0 + ldr.x x0 sp 1 + ldr.x x1 sp 2 + ldr.x x2 sp 3 + str.x x3 sp 1 + bl FORCE + ldr.x x0 sp 1 + ldr.x.post x30 sp 32 + ret +; FORCE: x0 kind, x1 number/register/condition, x2 type, x3 register: put the value in that register +:FORCE + str.x.pre x30 sp -16 + cmp.x.i x0 1 + b.eq FO_R + cmp.x.i x0 3 + b.eq FO_C + cmp.x.i x0 4 + b.ne E_BARE + mov.x x0 x3 + bl CSET + b FO_X +:FO_R + cmp.x x1 x3 + b.eq FO_X + movz.x x0 0x03e0 0 + movk.x x0 0xaa00 1 ; MOV Xd, Xm = ORR Xd, XZR, Xm, C6.2.282 + orr.x x0 x0 x3 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + b FO_X +:FO_C + mov.x x0 x3 + bl MATCONST +:FO_X + ldr.x.post x30 sp 16 + ret +; CSET Xd, cond = CSINC Xd, XZR, XZR, opposite cond (C6.2.141). x0 register, x1 condition +:CSET + movz.x x9 0x07e0 0 + movk.x x9 0x9a9f 1 ; CSINC 64-bit, Rm = Rn = 31, C6.2.141 + orr.x x9 x9 x0 + movz.x x0 1 0 + eor.x x1 x1 x0 + ubfm.x x1 x1 52 51 + orr.x x0 x9 x1 + b EMIT +; MATCONST: x0 register, x1 64-bit value: MOVZ (C6.2.285) or, for a negative value, MOVN (C6.2.284) with +; the first halfword that differs from the fill, then MOVK (C6.2.283) for each other such halfword +:MATCONST + str.x.pre x30 sp -16 + mov.x x3 x0 + mov.x x4 x1 + movz.x x5 0 0 + movz.x x6 0 0 + movz.x x7 0xd280 1 ; MOVZ 64-bit, C6.2.285 + movz.x x8 0 0 + cmp.x.i x4 0 + b.ge MC2 + movz.x x6 0xffff 0 + movz.x x7 0x9280 1 ; MOVN 64-bit, C6.2.284 +:MC2 + ubfm.x x2 x5 60 59 + lsrv.x x1 x4 x2 + ubfm.x x1 x1 0 15 + cmp.x x1 x6 + b.eq MC4 + movz.x x0 0xf280 1 ; MOVK 64-bit, C6.2.283 + cbnz.x x8 MC3 + eor.x x1 x1 x6 + mov.x x0 x7 + movz.x x8 1 0 +:MC3 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ubfm.x x2 x5 43 42 + orr.x x0 x0 x2 + orr.x x0 x0 x3 + bl EMIT +:MC4 + add.x.i x5 x5 1 + cmp.x.i x5 4 + b.lo MC2 + cbnz.x x8 MC5 + orr.x x0 x7 x3 + bl EMIT +:MC5 + ldr.x.post x30 sp 16 + ret +; CANON: x0 register, x1 type: u8/u16/u32 UBFM Xr, Xr, #0, #w-1 (C6.2.487); i8/i16/i32 SBFM (C6.2.355) +:CANON + cmp.x.i x1 2 + b.lo CN_X + cmp.x.i x1 5 + b.lo CN_U + cmp.x.i x1 6 + b.lo CN_X + cmp.x.i x1 9 + b.lo CN_S +:CN_X + ret +:CN_U + movz.x x9 0xd340 1 ; UBFM 64-bit, C6.2.487 + b CN_GO +:CN_S + movz.x x9 0x9340 1 ; SBFM 64-bit, C6.2.355 +:CN_GO + adr x10 TWID + ldrb.r w10 x10 x1 + sub.x.i x10 x10 1 + ubfm.x x10 x10 54 53 + orr.x x9 x9 x10 + orr.x x9 x9 x0 + ubfm.x x0 x0 59 58 + orr.x x0 x9 x0 + b EMIT +; CHKEXT: x0 register, x1 type (i8 i16 i32), x2 trap code: CMP Xr, Wr, SXTB/SXTH/SXTW (SUBS extended, +; option 100/101/110, C6.2.463), then B.NE trap +:CHKEXT + sub.x.i x3 x1 2 + ubfm.x x3 x3 51 50 + movz.x x9 0x001f 0 + movk.x x9 0xeb20 1 ; SUBS (extended register) 64-bit, Rd 31 = CMP, C6.2.463 + orr.x x3 x3 x9 + ubfm.x x9 x0 48 47 + orr.x x3 x3 x9 + ubfm.x x9 x0 59 58 + orr.x x0 x3 x9 + str.x.pre x30 sp -16 + bl EMIT + movz.x x0 1 0 + mov.x x1 x2 + bl TRAPC + ldr.x.post x30 sp 16 + ret +; RANGE: x1 number, x2 type, x3 1 when the number was written as 2^63 or more (TK_NUM, state slot 11): +; error 8 unless the number is a value of that type +:RANGE + adr x9 TWID + ldrb.r w9 x9 x2 + cmp.x.i x9 64 + b.eq RG_64 + cbnz.x x3 E_RANGE + movz.x x10 1 0 + lslv.x x10 x10 x9 + cmp.x.i x2 6 + b.hs RG_S + cmp.x x1 x10 + b.hs E_RANGE + ret +:RG_S + ubfm.x x10 x10 1 63 + add.x x11 x1 x10 + add.x x10 x10 x10 + cmp.x x11 x10 + b.hs E_RANGE + ret +:RG_64 + cmp.x.i x2 9 + b.eq RG_L + cbnz.x x3 RG_OK + cmp.x.i x1 0 + b.lt E_RANGE +:RG_OK + ret +:RG_L + cbnz.x x3 E_RANGE + ret +; ====================================================================================================== +; TOK: next word. x0 kind (0 end of line, 1 word, 2 number, 3 end of input), x1 packed word (first 8 +; characters, first in the low byte) or number, x2 length. Clobbers x0..x7. +:TOK + cmp.x x19 x18 + b.hs TK_EOF + ldrb w0 x19 0 + cmp.w.i w0 32 + b.eq TK_SKIP + cmp.w.i w0 9 + b.eq TK_SKIP + cmp.w.i w0 13 + b.eq TK_SKIP + cmp.w.i w0 10 + b.eq TK_NL + cmp.w.i w0 34 + b.eq TK_TEXT + cmp.w.i w0 32 + b.lo E_SYNTAX + b TK_WORD +; a text literal: kind 4, x1 its first byte, x2 its length in the source (escapes not yet read); it ends +; at the next " that is not after a \, on the same line, and is followed by a blank, a line end or the end +:TK_TEXT + add.x.i x19 x19 1 + mov.x x1 x19 +:TT1 + cmp.x x19 x18 + b.hs E_TEXT + ldrb w0 x19 0 + cmp.w.i w0 10 + b.eq E_TEXT + cmp.w.i w0 34 + b.eq TT_END + add.x.i x19 x19 1 + cmp.w.i w0 92 + b.ne TT1 + cmp.x x19 x18 + b.hs E_TEXT + ldrb w0 x19 0 + cmp.w.i w0 10 + b.eq E_TEXT + add.x.i x19 x19 1 + b TT1 +:TT_END + sub.x x2 x19 x1 + add.x.i x19 x19 1 + movz.x x0 4 0 + cmp.x x19 x18 + b.hs TT_OK + ldrb w3 x19 0 + cmp.w.i w3 32 + b.hi E_TEXT +:TT_OK + ret +:TK_NL + add.x.i x19 x19 1 + add.x.i x22 x22 1 + movz.x x0 0 0 + ret +:TK_SKIP + add.x.i x19 x19 1 + b TOK +:TK_EOF + movz.x x0 3 0 + ret +:TK_WORD + movz.x x1 0 0 + movz.x x2 0 0 + movz.x x3 0 0 +:TK_CH + cmp.x x19 x18 + b.hs TK_END + ldrb w0 x19 0 + cmp.w.i w0 32 + b.ls TK_END + cmp.x.i x2 8 + b.hs TK_LONG + lslv.x x4 x0 x3 + orr.x x1 x1 x4 + add.x.i x3 x3 8 +:TK_LONG + add.x.i x2 x2 1 + add.x.i x19 x19 1 + b TK_CH +:TK_END + ubfm.x x4 x1 0 7 + cmp.x.i x4 45 + b.eq TK_NUM + sub.x.i x4 x4 48 + cmp.x.i x4 9 + b.ls TK_NUM + movz.x x0 1 0 + ret +; a number: [-]decimal, at most 20 digits, a value of some whole-number type: -2^63 .. 2^64 - 1, error 8 +; outside. State slot 11 = 1 when it is 2^63 or more (only ulong holds such a number), else 0. +:TK_NUM + sub.x x5 x19 x2 + movz.x x6 0 0 + ldrb w0 x5 0 + cmp.w.i w0 45 + b.ne TK_N1 + movz.x x6 1 0 + add.x.i x5 x5 1 +:TK_N1 + sub.x x0 x19 x5 + cbz.x x0 E_NUM + cmp.x.i x0 20 + b.hi E_NUM + movz.x x1 0 0 + movz.x x7 10 0 + movz.x x3 0x9999 0 ; x3 = 0x1999999999999999 = (2^64 - 1) / 10 rounded down: x1 * 10 + digit fits + movk.x x3 0x9999 1 ; unless x1 > x3, or x1 = x3 and digit > 5 + movk.x x3 0x9999 2 + movk.x x3 0x1999 3 +:TK_N2 + cmp.x x5 x19 + b.hs TK_N3 + ldrb w0 x5 0 + sub.x.i x0 x0 48 + cmp.x.i x0 9 + b.hi E_NUM + cmp.x x1 x3 + b.hi E_RANGE + b.lo TK_N2A + cmp.x.i x0 5 + b.hi E_RANGE +:TK_N2A + mul.x x1 x1 x7 + add.x x1 x1 x0 + add.x.i x5 x5 1 + b TK_N2 +:TK_N3 + movz.x x7 0x8000 3 + movz.x x4 0x185 1 + str.x xzr x4 11 + cbnz.x x6 TK_NEG + cmp.x x1 x7 + b.lo TK_N4 + movz.x x3 1 0 + str.x x3 x4 11 +:TK_N4 + movz.x x0 2 0 + ret +:TK_NEG + cmp.x x1 x7 + b.hi E_RANGE + sub.x x1 xzr x1 + movz.x x0 2 0 + ret +; KW: x1 packed word -> x0 keyword code (0 none). Clobbers x9..x11. +:KW + adr x9 KWTAB +:KW1 + ldr.w w0 x9 2 + cbz.w w0 KW2 + ldr.x x10 x9 0 + cmp.x x10 x1 + b.eq KW2 + add.x.i x9 x9 16 + b KW1 +:KW2 + ret +; TYPEWORD: read a type name -> x0 type 1..9 +:TYPEWORD + str.x.pre x30 sp -16 + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_SYNTAX + bl KW + cmp.x.i x0 76 + b.eq E_SUBSET + sub.x.i x9 x0 1 + cmp.x.i x9 8 + b.hi E_SYNTAX + ldr.x.post x30 sp 16 + ret +; EOL: the line must end here +:EOL + str.x.pre x30 sp -16 + bl TOK + cbz.x x0 EOL1 + cmp.x.i x0 3 + b.ne E_EXTRA +:EOL1 + ldr.x.post x30 sp 16 + ret +; ALLOC: -> x0 the next free register of the pool. Clobbers x9. +:ALLOC + add.x x0 x29 x24 + adr x9 POOLEND + cmp.x x0 x9 + b.hs E_REGS + ldrb w0 x0 0 + add.x.i x24 x24 1 + ret +; DESTREG: x0 destination register, or 255 for a new temporary +:DESTREG + cmp.x.i x0 255 + b.eq ALLOC + ret +; EMIT: x0 word -> output. Clobbers x9. +:EMIT + movz.x x9 0x180 1 + cmp.x x20 x9 + b.hs E_FULL + str.w.post w0 x20 4 + ret +; E3: emit x0 | x1 | x2 << 5 | x3 << 16. Clobbers x0..x3, x9. +:E3 + orr.x x0 x0 x1 + ubfm.x x2 x2 59 58 + orr.x x0 x0 x2 + ubfm.x x3 x3 48 47 + orr.x x0 x0 x3 + b EMIT +; TRAPC: x0 condition, x1 trap code: B.cond (C6.2.34) to the trap stub, distance filled at the end +:TRAPC + movz.x x9 0x5400 1 + orr.x x0 x0 x9 +; TRAPSITE: x0 branch word, x1 trap code: note the place, emit the word +:TRAPSITE + movz.x x9 0x183 1 + cmp.x x26 x9 + b.hs E_FULL + str.w w20 x26 0 + str.w w1 x26 1 + add.x.i x26 x26 8 + b EMIT +; PATCH19: x0 address of a B.cond/CBZ/CBNZ, x1 target: the word distance into bits 5..23 +:PATCH19 + sub.x x2 x1 x0 + ubfm.x x2 x2 2 20 + ubfm.x x2 x2 59 58 + ldr.w w1 x0 0 + orr.x x1 x1 x2 + str.w w1 x0 0 + ret +; PATCH26: x0 address of a B, x1 target: the word distance into bits 0..25 +:PATCH26 + sub.x x2 x1 x0 + ubfm.x x2 x2 2 27 + ldr.w w1 x0 0 + orr.x x1 x1 x2 + str.w w1 x0 0 + ret +; BACK: x0 earlier address: emit B to it (C6.2.35) +:BACK + sub.x x2 x0 x20 + ubfm.x x2 x2 2 27 + movz.x x0 0x1400 1 ; B, C6.2.35 + orr.x x0 x0 x2 + b EMIT +; ====================================================================================================== +; errors +:E_READ + movz.x x0 1 0 + b FAIL +:E_WRITE + movz.x x0 2 0 + b FAIL +:E_UNDEF + movz.x x0 3 0 + b FAIL +:E_FEW + movz.x x0 4 0 + b FAIL +:E_EXTRA + movz.x x0 5 0 + b FAIL +:E_NUM + movz.x x0 6 0 + b FAIL +:E_TYPE + movz.x x0 7 0 + b FAIL +:E_RANGE + movz.x x0 8 0 + b FAIL +:E_SUBSET + movz.x x0 9 0 + b FAIL +:E_TWICE + movz.x x0 10 0 + b FAIL +:E_BARE + movz.x x0 11 0 + b FAIL +:E_REGS + movz.x x0 12 0 + b FAIL +:E_LONG + movz.x x0 13 0 + b FAIL +:E_FULL + movz.x x0 14 0 + b FAIL +:E_BLOCK + movz.x x0 15 0 + b FAIL +:E_SYNTAX + movz.x x0 16 0 + b FAIL +; PUTDEC: x0 number: its decimal digits at x9 (x9 moves on) +:PUTDEC + movz.x x1 10 0 + add.x.i x2 x9 40 + mov.x x3 x2 +:PD1 + udiv.x x4 x0 x1 + msub.x x5 x4 x1 x0 + add.x.i x5 x5 48 + sub.x.i x3 x3 1 + strb w5 x3 0 + mov.x x0 x4 + cbnz.x x0 PD1 +:PD2 + ldrb w5 x3 0 + strb w5 x9 0 + add.x.i x9 x9 1 + add.x.i x3 x3 1 + cmp.x x3 x2 + b.lo PD2 + ret +; div, rem (signed): CBZ Xb -> trap 2 unless b is a number other than 0; SDIV (C6.2.357); i64 div also +; traps 1 for MIN / -1: CMN Xb, #1 (ADDS immediate, C6.2.10); B.NE over the next two (C6.2.34); +; NEGS XZR, Xa (SUBS shifted register, C6.2.465) sets V only for MIN; B.VS trap 1. i8/i16/i32: the +; quotient is exact in 64 bits, then the sign-extension check (trap 1). rem: t = a / b; rd = a - t * b +; (MSUB, C6.2.291), always in range (MIN rem -1 = 0). +:BO_SDIV + ldr.x x10 sp 3 + ldr.x x0 x10 3 + cmp.x.i x0 3 + b.ne SD1 + ldr.x x0 x10 4 + cbnz.x x0 SD2 +:SD1 + ldr.x x0 sp 5 + movz.x x9 0xb400 1 ; CBZ Xb, C6.2.78 + orr.x x0 x0 x9 + movz.x x1 2 0 + bl TRAPSITE +:SD2 + ldr.x x9 sp 1 + cmp.x.i x9 37 + b.eq SD_REM + ldr.x x9 sp 6 + cmp.x.i x9 9 + b.ne SD4 + ldr.x x10 sp 3 + ldr.x x0 x10 3 + cmp.x.i x0 3 + b.ne SD3 + ldr.x x0 x10 4 + cmn.x.i x0 1 + b.ne SD4 +:SD3 + movz.x x0 0x041f 0 + movk.x x0 0xb100 1 ; CMN Xb, #1 = ADDS XZR, Xb, #1, C6.2.10 + ldr.x x1 sp 5 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 0x0061 0 + movk.x x0 0x5400 1 ; B.NE +3 words, C6.2.34 + bl EMIT + movz.x x0 0x03ff 0 + movk.x x0 0xeb00 1 ; NEGS XZR, Xa = SUBS XZR, XZR, Xa, C6.2.465 + ldr.x x1 sp 4 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 6 0 + movz.x x1 1 0 + bl TRAPC +:SD4 + movz.x x0 0x0c00 0 + movk.x x0 0x9ac0 1 ; SDIV 64-bit, C6.2.357 + bl BO_W3 + ldr.x x9 sp 6 + cmp.x.i x9 9 + b.eq BO_RET + bl BO_FIX + b BO_RET +:SD_REM + bl ALLOC + str.x x0 sp 8 + movz.x x0 0x0c00 0 + movk.x x0 0x9ac0 1 ; SDIV, C6.2.357 + ldr.x x1 sp 8 + ldr.x x2 sp 4 + ldr.x x3 sp 5 + bl E3 + movz.x x0 0x8000 0 + movk.x x0 0x9b00 1 ; MSUB 64-bit, C6.2.291 (Ra at bit 10) + ldr.x x1 sp 4 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + ldr.x x1 sp 2 + ldr.x x2 sp 8 + ldr.x x3 sp 5 + bl E3 + b BO_RET +; shl (i64): t = a << s (LSLV C6.2.271, or UBFM C6.2.487 for a number); X16 = t >> s arithmetic (ASRV +; C6.2.21, or SBFM C6.2.355); CMP X16, Xa (C6.2.97); B.NE trap 1 (a bit left the value); MOV Xd, Xt. +; (i8/i16/i32 shift in 64 bits exactly and take the sign-extension check of BO_FIX, as unsigned types +; take their wrap.) +:BS_64 + bl ALLOC + str.x x0 sp 8 + ldr.x x10 sp 7 + cbnz.x x10 BS64_I + bl BO_SCHK + movz.x x0 0x2000 0 + movk.x x0 0x9ac0 1 ; LSLV Xt, Xa, Xb, C6.2.271 + ldr.x x1 sp 8 + ldr.x x2 sp 4 + ldr.x x3 sp 5 + bl E3 + movz.x x0 0x2810 0 + movk.x x0 0x9ac0 1 ; ASRV X16, Xt, Xb, C6.2.21 + movz.x x1 0 0 + ldr.x x2 sp 8 + ldr.x x3 sp 5 + bl E3 + b BS64_C +:BS64_I + ldr.x x1 sp 5 + movz.x x2 64 0 + sub.x x2 x2 x1 + ubfm.x x2 x2 0 5 + movz.x x3 63 0 + sub.x x3 x3 x1 + movz.x x0 0xd340 1 ; UBFM Xt, Xa, #(64-s) mod 64, #63-s = LSL, C6.2.487 + ubfm.x x2 x2 48 47 + orr.x x0 x0 x2 + ubfm.x x3 x3 54 53 + orr.x x0 x0 x3 + ldr.x x1 sp 4 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 8 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 0xfc10 0 + movk.x x0 0x9340 1 ; SBFM X16, Xt, #s, #63 = ASR, C6.2.355 + ldr.x x1 sp 5 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + ldr.x x1 sp 8 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT +:BS64_C + movz.x x0 0x021f 0 + movk.x x0 0xeb00 1 ; CMP X16, Xa = SUBS XZR, X16, Xa, C6.2.97 + ldr.x x1 sp 4 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 1 0 + movz.x x1 1 0 + bl TRAPC + movz.x x0 0x03e0 0 + movk.x x0 0xaa00 1 ; MOV Xd, Xt = ORR Xd, XZR, Xt, C6.2.282 + ldr.x x1 sp 2 + orr.x x0 x0 x1 + ldr.x x1 sp 8 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + b BO_RET +; ====================================================================================================== +; values new in om4 (inside VALTOK's frame: 0 x30, 1 expected, 2 dest, 3 op, 4.. free) +; true, false: bool numbers +:VT_TRUE + movz.x x0 3 0 + movz.x x1 1 0 + movz.x x2 1 0 + b VT_RET +:VT_FALSE + movz.x x0 3 0 + movz.x x1 0 0 + movz.x x2 1 0 + b VT_RET +; len A: the length of A, a ulong number +:VT_LEN + bl ARRNAME + ldr.w w1 x0 4 + movz.x x0 3 0 + movz.x x2 5 0 + b VT_RET +; get A i: the checked load (the load of the element type, register offset, LDOP table) +:VT_GET + bl ARRNAME + str.x x0 sp 4 + movz.x x0 5 0 + movz.x x1 255 0 + bl VAL + mov.x x3 x2 + mov.x x2 x1 + mov.x x1 x0 + ldr.x x0 sp 4 + bl ELEMADDR + str.x x0 sp 5 + str.x x1 sp 6 + ldr.x x0 sp 2 + bl DESTREG + str.x x0 sp 7 + ldr.x x9 sp 4 + ldr.w w9 x9 3 + adr x10 LDOP + ldr.w.r w0 x10 x9 + ldr.x x1 sp 7 + orr.x x0 x0 x1 + ldr.x x1 sp 5 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 6 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 1 0 + ldr.x x1 sp 7 + ldr.x x9 sp 4 + ldr.w w2 x9 3 + b VT_RET +; read fd A off n / write fd A off n: a long (bytes moved, or minus the Linux error number). fd int, off +; and n ulong; n <= len A and off <= len A - n, else trap 3 (CMP C6.2.97, B.HI C6.2.34, SUB C6.2.458). +; Then as a call: save the registers in use, X0 = fd, X1 = A + off (ADD through X16, C6.2.6), X2 = n, +; X8 = 63 (read) or 64 (write), SVC #0 (C6.2.466), the result from X0, the registers back. +; Frame: 4/5 fd, 6 A, 7/8 off, 9/10 n, 11 t, 12 saved count, 13 save bytes, 14 pool slot before. +:VT_SYS + str.x x24 sp 14 + movz.x x0 8 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x2 8 + b.ne E_TYPE + str.x x0 sp 4 + str.x x1 sp 5 + bl ARRNAME + str.x x0 sp 6 + ldr.x x9 sp 3 + cmp.x.i x9 53 + b.ne VS1 + ldr.w w9 x0 5 + cmp.x.i x9 2 + b.eq E_RDONLY + cmp.x.i x9 5 + b.eq E_RDONLY +:VS1 + movz.x x0 5 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x2 5 + b.ne E_TYPE + bl MATREG + str.x x0 sp 8 + movz.x x0 5 0 + movz.x x1 255 0 + bl VAL + cmp.x.i x2 5 + b.ne E_TYPE + bl MATREG + str.x x0 sp 10 + bl ALLOC + str.x x0 sp 11 + ldr.x x9 sp 6 + ldr.w w1 x9 4 + bl MATCONST + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xn, Xt, C6.2.97 + ldr.x x1 sp 10 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 11 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 8 0 + movz.x x1 3 0 + bl TRAPC + movz.x x0 0 0 + movk.x x0 0xcb00 1 ; SUB Xt, Xt, Xn, C6.2.458 + ldr.x x1 sp 11 + ldr.x x2 sp 11 + ldr.x x3 sp 10 + bl E3 + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xoff, Xt, C6.2.97 + ldr.x x1 sp 8 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + ldr.x x1 sp 11 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 8 0 + movz.x x1 3 0 + bl TRAPC + bl SAVE + str.x x0 sp 12 + str.x x1 sp 13 + movz.x x0 0 0 + ldr.x x1 sp 4 + ldr.x x2 sp 5 + bl LOADARG + movz.x x0 1 0 + ldr.x x9 sp 6 + bl BASEARG + movz.x x0 16 0 + movz.x x1 1 0 + ldr.x x2 sp 8 + bl LOADARG + movz.x x0 0x0021 0 + movk.x x0 0x8b10 1 ; ADD X1, X1, X16, C6.2.6 + bl EMIT + movz.x x0 2 0 + movz.x x1 1 0 + ldr.x x2 sp 10 + bl LOADARG + ldr.x x9 sp 3 + add.x.i x9 x9 10 + ubfm.x x9 x9 59 58 + movz.x x0 0x0008 0 + movk.x x0 0xd280 1 ; MOVZ X8, #63 or #64, C6.2.285 + orr.x x0 x0 x9 + bl EMIT + movz.x x0 0x0001 0 + movk.x x0 0xd400 1 ; SVC #0, C6.2.466 + bl EMIT + ldr.x x0 sp 2 + ldr.x x1 sp 14 + ldr.x x2 sp 12 + ldr.x x3 sp 13 + movz.x x4 1 0 + bl RESTORE + mov.x x1 x0 + movz.x x0 1 0 + movz.x x2 9 0 + b VT_RET +; ====================================================================================================== +; CALL: x0 function entry, x1 destination (255 none). Reads the arguments, then: SAVE; each argument into +; X0..X5 from the save area (LOADARG); BL (C6.2.43); RESTORE. Out: x0 1, x1 result register, x2 type. +; Frame: 0 x30, 1 entry, 2 dest, 3 pool slot before, 4 i, 5 parameter count, 6.. 3 per argument (kind, +; register/number, name entry of an array), 24 saved count, 25 save bytes. +:CALL + sub.x.i sp sp 224 + str.x x30 sp 0 + str.x x0 sp 1 + str.x x1 sp 2 + str.x x24 sp 3 + str.x xzr sp 4 + ldr.w w9 x0 5 + str.x x9 sp 5 + movz.x x9 0x185 1 + ldr.x x10 x9 6 + cbnz.x x10 CA_ARG + ldr.x x10 x9 3 + cmp.x x10 x0 + b.eq E_SUBSET +:CA_ARG + ldr.x x9 sp 4 + ldr.x x10 sp 5 + cmp.x x9 x10 + b.hs CA_DONE + ldr.x x11 sp 1 + ubfm.x x12 x9 60 59 + add.x x11 x11 x12 + ldr.w w12 x11 8 + cbnz.x x12 CA_ARR + ldr.w w0 x11 6 + movz.x x1 255 0 + bl VAL + cmp.x.i x0 4 + b.ne CA1 + bl MATREG + mov.x x1 x0 + movz.x x0 1 0 + movz.x x2 1 0 +:CA1 + ldr.x x9 sp 4 + ldr.x x11 sp 1 + ubfm.x x12 x9 60 59 + add.x x11 x11 x12 + ldr.w w12 x11 6 + cmp.x x2 x12 + b.ne E_TYPE + movz.x x3 0 0 + b CA_PUT +:CA_ARR + bl ARRARG + mov.x x3 x2 + ldr.x x9 sp 4 + movz.x x10 0 0 +:CA2 + cmp.x x10 x9 + b.hs CA_PUT + movz.x x11 3 0 + mul.x x11 x11 x10 + add.x.i x11 x11 8 + ldr.x.r x12 sp x11 + cmp.x x12 x3 + b.eq E_ALIAS + add.x.i x10 x10 1 + b CA2 +:CA_PUT + ldr.x x9 sp 4 + movz.x x11 3 0 + mul.x x11 x11 x9 + add.x.i x11 x11 6 + str.x.r x0 sp x11 + add.x.i x11 x11 1 + str.x.r x1 sp x11 + add.x.i x11 x11 1 + str.x.r x3 sp x11 + add.x.i x9 x9 1 + str.x x9 sp 4 + b CA_ARG +:CA_DONE + bl SAVE + str.x x0 sp 24 + str.x x1 sp 25 + movz.x x13 0 0 +:CA3 + ldr.x x10 sp 5 + cmp.x x13 x10 + b.hs CA4 + movz.x x11 3 0 + mul.x x11 x11 x13 + add.x.i x11 x11 6 + ldr.x.r x1 sp x11 + add.x.i x11 x11 1 + ldr.x.r x2 sp x11 + mov.x x0 x13 + bl LOADARG + add.x.i x13 x13 1 + b CA3 +:CA4 + movz.x x9 0x185 1 + ldr.x x10 x9 12 + movz.x x11 1 1 + cmp.x x10 x11 + b.hs E_FULL + movz.x x11 24 0 + mul.x x11 x11 x10 + movz.x x12 0x186 1 + add.x x11 x11 x12 + str.x x20 x11 0 + ldr.x x12 sp 1 + str.x x12 x11 1 + ldr.x x12 x9 3 + str.x x12 x11 2 + add.x.i x10 x10 1 + str.x x10 x9 12 + ldr.x x9 sp 1 + + ldr.x x0 x9 1 + sub.x x2 x0 x20 + ubfm.x x2 x2 2 27 + movz.x x0 0x9400 1 ; BL, C6.2.43 + orr.x x0 x0 x2 + bl EMIT + ldr.x x9 sp 1 + ldr.w w9 x9 4 + movz.x x4 1 0 + cmp.x.i x9 10 + b.ne CA5 + movz.x x4 0 0 +:CA5 + ldr.x x0 sp 2 + ldr.x x1 sp 3 + ldr.x x2 sp 24 + ldr.x x3 sp 25 + bl RESTORE + mov.x x1 x0 + movz.x x0 1 0 + ldr.x x9 sp 1 + ldr.w w2 x9 4 + ldr.x x30 sp 0 + add.x.i sp sp 224 + ret +; ARRARG: an array argument for the parameter at x11 (type +24, length +28, kind +32): [view | edit] NAME. +; Its type and length must equal the parameter's; an edit parameter needs a writable array (local or edit, +; error 20); a global is never passed (error 19: only so is every pair of live references disjoint). +; Out: x0 5 (register x1) or 6 (address x1, a text), x2 the name entry. +:ARRARG + str.x.pre x30 sp -32 + str.x x11 sp 1 + str.x xzr sp 2 + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_LONG + str.x x1 sp 3 + bl KW + cbz.x x0 AA1 + cmp.x.i x0 57 + b.lo E_SYNTAX + cmp.x.i x0 58 + b.hi E_SYNTAX + str.x x0 sp 2 + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_LONG + str.x x1 sp 3 +:AA1 + ldr.x x1 sp 3 + bl FINDNAME + cbz.x x0 E_UNDEF + ldr.w w9 x0 5 + cbz.x x9 E_TYPE + cmp.x.i x9 4 + b.eq E_ALIAS + ldr.x x11 sp 1 + ldr.w w10 x11 8 + cmp.x.i x10 3 + b.ne AA2 + ldr.x x12 sp 2 + cmp.x.i x12 57 + b.eq E_RDONLY ; view A to an edit parameter: passing a view as edit is error 20 (OMEGESE.md 9.4) + cmp.x.i x9 1 + b.eq AA3 + cmp.x.i x9 3 + b.ne E_RDONLY + b AA3 +:AA2 + ldr.x x12 sp 2 + cmp.x.i x12 58 + b.eq E_TYPE +:AA3 + ldr.w w12 x0 3 + ldr.w w13 x11 6 + cmp.x x12 x13 + b.ne E_TYPE + ldr.w w12 x0 4 + ldr.w w13 x11 7 + cmp.x x12 x13 + b.ne E_TYPE + mov.x x2 x0 + cmp.x.i x9 5 + b.eq AA4 + ldr.w w1 x0 2 + movz.x x0 5 0 + b AA5 +:AA4 + ldr.x x1 x0 3 + movz.x x0 6 0 +:AA5 + ldr.x.post x30 sp 32 + ret +; SAVE: n = registers in use (parameters + pool slots), A = 8 (n + 1) rounded up to 16: SUB SP, SP, #A +; (C6.2.457); program mode: CMP SP, X28 (C6.2.463), B.LO trap 6; STR Xr, [SP, #8j] for each (C6.2.415, +; unsigned offset); STR X30, [SP, #8n]. Out: x0 n, x1 A. +:SAVE + str.x.pre x30 sp -32 + adr x9 POOLC + sub.x x10 x29 x9 + add.x x10 x10 x24 + str.x x10 sp 1 + add.x.i x11 x10 2 + ubfm.x x11 x11 1 63 + ubfm.x x11 x11 60 59 + str.x x11 sp 2 + mov.x x1 x11 + bl SPSUB + bl STKCHK + movz.x x13 0 0 +:SV1 + ldr.x x10 sp 1 + cmp.x x13 x10 + b.hs SV2 + adr x9 POOLC + ldrb.r w0 x9 x13 + movz.x x9 0x03e0 0 + movk.x x9 0xf900 1 ; STR Xr, [SP, #8j], C6.2.415 + orr.x x0 x0 x9 + ubfm.x x1 x13 54 53 + orr.x x0 x0 x1 + bl EMIT + add.x.i x13 x13 1 + b SV1 +:SV2 + movz.x x0 0x03fe 0 + movk.x x0 0xf900 1 ; STR X30, [SP, #8n], C6.2.415 + ubfm.x x1 x13 54 53 + orr.x x0 x0 x1 + bl EMIT + ldr.x x0 sp 1 + ldr.x x1 sp 2 + ldr.x.post x30 sp 32 + ret +; LOADARG: x0 target register, x1 kind (1 or 5: register x2, read back from its save slot: LDR Xt, [SP, +; #8 slot], C6.2.216; 3 or 6: the number or address x2, MATCONST) +:LOADARG + cmp.x.i x1 3 + b.eq MATCONST_X + cmp.x.i x1 6 + b.eq MATCONST_X + adr x9 REGIDX + ldrb.r w9 x9 x2 + movz.x x10 0x03e0 0 + movk.x x10 0xf940 1 ; LDR Xt, [SP, #8j], C6.2.216 + orr.x x0 x0 x10 + ubfm.x x9 x9 54 53 + orr.x x0 x0 x9 + b EMIT +:MATCONST_X + mov.x x1 x2 + b MATCONST +; BASEARG: x0 target register, x9 an array's name entry: its register from the save area, or its address +:BASEARG + ldr.w w10 x9 5 + cmp.x.i x10 4 + b.hs BA_ADDR + movz.x x1 1 0 + ldr.w w2 x9 2 + b LOADARG +:BA_ADDR + ldr.x x1 x9 3 + b MATCONST +; RESTORE: x0 destination (255: a new temporary at pool slot x1), x1 pool slot before the arguments, x2 +; saved count, x3 save bytes, x4 1 if there is a result in X0. MOV Xd, X0 (C6.2.282); LDR each register +; in use before the arguments except Xd (C6.2.216); LDR X30; ADD SP, SP, #A (C6.2.5). Out: x0 Xd. +:RESTORE + str.x.pre x30 sp -64 + str.x x2 sp 2 + str.x x3 sp 3 + mov.x x24 x1 + str.x x1 sp 4 + movz.x x9 255 0 + str.x x9 sp 1 + cbz.x x4 RS2 + cmp.x.i x0 255 + b.ne RS1 + bl ALLOC +:RS1 + str.x x0 sp 1 + cbz.x x0 RS2 + movz.x x9 0x03e0 0 + movk.x x9 0xaa00 1 ; MOV Xd, X0 = ORR Xd, XZR, X0, C6.2.282 + orr.x x0 x0 x9 + bl EMIT +:RS2 + movz.x x13 0 0 + adr x9 POOLC + sub.x x14 x29 x9 + ldr.x x9 sp 4 + add.x x14 x14 x9 +:RS3 + cmp.x x13 x14 + b.hs RS4 + adr x9 POOLC + ldrb.r w0 x9 x13 + ldr.x x9 sp 1 + cmp.x x0 x9 + b.eq RS5 + movz.x x9 0x03e0 0 + movk.x x9 0xf940 1 ; LDR Xr, [SP, #8j], C6.2.216 + orr.x x0 x0 x9 + ubfm.x x1 x13 54 53 + orr.x x0 x0 x1 + bl EMIT +:RS5 + add.x.i x13 x13 1 + b RS3 +:RS4 + movz.x x0 0x03fe 0 + movk.x x0 0xf940 1 ; LDR X30, [SP, #8n], C6.2.216 + ldr.x x1 sp 2 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + bl EMIT + ldr.x x1 sp 3 + bl SPADD + ldr.x x0 sp 1 + ldr.x.post x30 sp 64 + ret +; ====================================================================================================== +; ELEMADDR: x0 array name entry, index x1 kind, x2 number or register, x3 type. A number index must be +; inside the array (error 21) and needs no check; a register index: CMP Xi, #len (C6.2.96) or CMP Xi, Xt +; (C6.2.97), B.HS trap 3 (unsigned, so a negative signed index traps too). Out: x0 base register (the +; array's register, or a new one holding its address), x1 index register. +:ELEMADDR + str.x.pre x30 sp -48 + str.x x0 sp 1 + cmp.x.i x3 1 + b.eq E_TYPE + cmp.x.i x1 3 + b.ne EA_R + ldr.w w9 x0 4 + cmp.x x2 x9 + b.hs E_BOUNDS + str.x x2 sp 2 + bl ALLOC + str.x x0 sp 3 + ldr.x x1 sp 2 + bl MATCONST + b EA_B +:EA_R + str.x x2 sp 3 + ldr.w w1 x0 4 + movz.x x9 4095 0 + cmp.x x1 x9 + b.hi EA_BIG + movz.x x0 0x001f 0 + movk.x x0 0xf100 1 ; CMP Xi, #len, C6.2.96 + ubfm.x x1 x1 54 53 + orr.x x0 x0 x1 + b EA_C +:EA_BIG + bl ALLOC + str.x x0 sp 4 + bl MATCONST + movz.x x0 0x001f 0 + movk.x x0 0xeb00 1 ; CMP Xi, Xt, C6.2.97 + ldr.x x1 sp 4 + ubfm.x x1 x1 48 47 + orr.x x0 x0 x1 +:EA_C + ldr.x x1 sp 3 + ubfm.x x1 x1 59 58 + orr.x x0 x0 x1 + bl EMIT + movz.x x0 2 0 + movz.x x1 3 0 + bl TRAPC +:EA_B + ldr.x x9 sp 1 + ldr.w w10 x9 5 + cmp.x.i x10 4 + b.hs EA_A + ldr.w w0 x9 2 + b EA_X +:EA_A + bl ALLOC + str.x x0 sp 4 + ldr.x x9 sp 1 + ldr.x x1 x9 3 + bl MATCONST + ldr.x x0 sp 4 +:EA_X + ldr.x x1 sp 3 + ldr.x.post x30 sp 48 + ret +; ARRNAME: read an array name -> x0 its entry +:ARRNAME + str.x.pre x30 sp -16 + bl TOK + cbz.x x0 E_FEW + cmp.x.i x0 3 + b.eq E_FEW + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_LONG + bl FINDNAME + cbz.x x0 E_UNDEF + ldr.w w9 x0 5 + cbz.x x9 E_TYPE + ldr.x.post x30 sp 16 + ret +; TOPNAME: read a new name for a global or a text -> x12 +:TOPNAME + str.x.pre x30 sp -16 + bl TOK + cmp.x.i x0 1 + b.ne E_SYNTAX + cmp.x.i x2 8 + b.hi E_LONG + mov.x x12 x1 + bl KW + cbnz.x x0 E_SYNTAX + mov.x x1 x12 + bl NEWNAME + ldr.x.post x30 sp 16 + ret +; FINDNAME: x1 packed name -> x0 its entry (0 none). Clobbers x9..x11. +:FINDNAME + movz.x x9 0x180 1 + movz.x x10 0 0 +:FD1 + cmp.x x10 x23 + b.hs FD0 + ldr.x x11 x9 0 + cmp.x x11 x1 + b.eq FDF + add.x.i x9 x9 32 + add.x.i x10 x10 1 + b FD1 +:FD0 + movz.x x0 0 0 + ret +:FDF + mov.x x0 x9 + ret +; ADDNAME: x1 packed name, x2 register, x3 type, x4 length, x5 kind, x6 address. Clobbers x9, x10. +:ADDNAME + cmp.x.i x23 1024 + b.hs E_FULL + movz.x x9 0x180 1 + ubfm.x x10 x23 59 58 + add.x x9 x9 x10 + str.x x1 x9 0 + str.w w2 x9 2 + str.w w3 x9 3 + str.w w4 x9 4 + str.w w5 x9 5 + str.x x6 x9 3 + add.x.i x23 x23 1 + ret +; PUSHB: x0 branch to patch, x1 kind (1 if, 2 else, 3 while, 4 for), x2 head, x3 loop register, +; x4 its type, x5 names and x6 pool slots to restore at end; slot 7 = the then-part ended (for else) +:PUSHB + movz.x x9 0x182 1 + cmp.x x25 x9 + b.hs E_FULL + str.x x1 x25 0 + str.x x0 x25 1 + str.x x2 x25 2 + str.x x3 x25 3 + str.x x4 x25 4 + str.x x5 x25 5 + str.x x6 x25 6 + str.x xzr x25 7 + add.x.i x25 x25 128 + ret +; ELEMTYPE: x0 a type that an array may hold (uchar .. long, not bool) +:ELEMTYPE + cmp.x.i x0 2 + b.lo E_SUBSET + ret +; ARRLEN: x1 an array length: 1 .. 16777216 (error 8 below, 23 above; a number written as 2^63 or more, +; state slot 11, is above) +:ARRLEN + movz.x x9 0x185 1 + ldr.x x9 x9 11 + cbnz.x x9 E_TOOBIG + cmp.x.i x1 1 + b.lt E_RANGE + movz.x x9 0x100 1 + cmp.x x1 x9 + b.hi E_TOOBIG + ret +; EPI: ADD SP, SP, #stack of the local arrays (if any), then RET (C6.2.338) +:EPI + str.x.pre x30 sp -16 + movz.x x9 0x185 1 + ldr.x x1 x9 4 + bl SPADD + movz.x x0 0x03c0 0 + movk.x x0 0xd65f 1 ; RET (X30), C6.2.338 + bl EMIT + ldr.x.post x30 sp 16 + ret +; SPADD / SPSUB: x1 bytes (a multiple of 16, below 2^24): ADD (C6.2.5) / SUB (C6.2.457) SP, SP, #low 12 +; bits, then #high 12 bits LSL 12 (sh = 1, bit 22); nothing for a zero part +:SPADD + movz.x x2 0x9100 1 + b SPOP +:SPSUB + movz.x x2 0xd100 1 +:SPOP + str.x.pre x30 sp -32 + str.x x1 sp 1 + str.x x2 sp 2 + ubfm.x x3 x1 0 11 + cbz.x x3 SPO1 + movz.x x9 0x03ff 0 + orr.x x0 x2 x9 + ubfm.x x3 x3 54 53 + orr.x x0 x0 x3 + bl EMIT +:SPO1 + ldr.x x1 sp 1 + ubfm.x x3 x1 12 23 + cbz.x x3 SPO2 + ldr.x x2 sp 2 + movz.x x9 0x03ff 0 + movk.x x9 0x0040 1 + orr.x x0 x2 x9 + ubfm.x x3 x3 54 53 + orr.x x0 x0 x3 + bl EMIT +:SPO2 + ldr.x.post x30 sp 32 + ret +; STKCHK: program mode only: CMP SP, X28 (SUBS extended register, UXTX, Rn = SP, C6.2.463); B.LO trap 6 +:STKCHK + movz.x x9 0x185 1 + ldr.x x10 x9 6 + cbz.x x10 SK1 + str.x.pre x30 sp -16 + movz.x x0 0x63ff 0 + movk.x x0 0xeb3c 1 ; CMP SP, X28, C6.2.463 + bl EMIT + movz.x x0 3 0 + movz.x x1 6 0 + bl TRAPC + ldr.x.post x30 sp 16 +:SK1 + ret +; DEAD1: the path has ended (ret, exit) +:DEAD1 + movz.x x9 0x185 1 + movz.x x10 1 0 + str.x x10 x9 5 + ret +; EMITB: x0 one byte -> output. Clobbers x9. +:EMITB + movz.x x9 0x180 1 + cmp.x x20 x9 + b.hs E_FULL + strb w0 x20 0 + add.x.i x20 x20 1 + ret +; ====================================================================================================== +; errors new in om4, and FAIL +:E_DEAD + movz.x x0 17 0 + b FAIL +:E_NORET + movz.x x0 18 0 + b FAIL +:E_ALIAS + movz.x x0 19 0 + b FAIL +:E_RDONLY + movz.x x0 20 0 + b FAIL +:E_BOUNDS + movz.x x0 21 0 + b FAIL +:E_TEXT + movz.x x0 22 0 + b FAIL +:E_TOOBIG + movz.x x0 23 0 + b FAIL +; FAIL: x0 code: "om4: line N: error E" and a newline on stderr (fd 2), exit E +:FAIL + mov.x x12 x0 + movz.x x9 0x183 1 + adr x10 MSG1 + movz.x x11 10 0 + bl COPYN + mov.x x0 x22 + bl PUTDEC + adr x10 MSG2 + movz.x x11 8 0 + bl COPYN + mov.x x0 x12 + bl PUTDEC + movz.x x0 10 0 + strb w0 x9 0 + add.x.i x9 x9 1 + movz.x x0 2 0 + movz.x x1 0x183 1 + sub.x x2 x9 x1 + movz.x x8 64 0 + svc 0 + mov.x x0 x12 + movz.x x8 93 0 + svc 0 +; COPYN: copy x11 bytes at x10 to x9 (x9 moves on) +:COPYN + cbz.x x11 CN1 + ldrb w13 x10 0 + strb w13 x9 0 + add.x.i x9 x9 1 + add.x.i x10 x10 1 + sub.x.i x11 x11 1 + b COPYN +:CN1 + ret +; ====================================================================================================== +; NEWNAME: x1 packed name, x2 its length, x3 its first byte: the name must not be in use (a name in scope, +; when 8 characters or fewer, or a function: error 10). Keeps x1..x8, x12..x14. Clobbers x0, x9..x11, x15..x17. +:NEWNAME + str.x.pre x30 sp -16 + str.x x1 sp 1 + cmp.x.i x2 8 + b.hi NN1 + bl FINDNAME + cbnz.x x0 E_TWICE +:NN1 + ldr.x x1 sp 1 + bl FINDFN + cbnz.x x0 E_TWICE + ldr.x x1 sp 1 + ldr.x.post x30 sp 16 + ret +; FINDFN: x1 packed name (first 8 characters), x2 length (any value up to 8 for a short name), x3 first +; byte (read only for a name over 8 characters) -> x0 its function entry (0 none). A function entry keeps +; its name's length at +120 and the name's place in the input at +124. Clobbers x9..x11, x15..x17. +:FINDFN + movz.x x9 0x185 1 + ldr.x x10 x9 2 + movz.x x9 0x184 1 +:FF1 + cbz.x x10 FD0 + ldr.x x11 x9 0 + cmp.x x11 x1 + b.ne FF2 + ldr.w w11 x9 30 + cmp.x.i x2 8 + b.hi FF_LONG + cmp.x.i x11 8 + b.ls FDF + b FF2 +:FF_LONG + cmp.x x11 x2 + b.ne FF2 + ldr.w w15 x9 31 + movz.x x16 0x80 1 + add.x x15 x15 x16 + movz.x x16 8 0 +:FF3 + cmp.x x16 x2 + b.hs FDF + ldrb.r w17 x15 x16 + ldrb.r w11 x3 x16 + cmp.x x17 x11 + b.ne FF2 + add.x.i x16 x16 1 + b FF3 +:FF2 + add.x.i x9 x9 128 + sub.x.i x10 x10 1 + b FF1 +; S_LONG: a word over 8 characters at the start of a line: only a call of a void function +:S_LONG + cbz.x x27 E_LONG + movz.x x9 0x185 1 + ldr.x x10 x9 5 + cbnz.x x10 E_DEAD + sub.x x3 x19 x2 + bl FINDFN + cbz.x x0 E_LONG + ldr.w w9 x0 4 + cmp.x.i x9 10 + b.ne E_TYPE + movz.x x1 255 0 + bl CALL + bl EOL + b STMT +; VT_LONG: a word over 8 characters as a value: only a call of a function that gives a value +:VT_LONG + mov.x x1 x4 + mov.x x2 x5 + sub.x x3 x19 x5 + bl FINDFN + cbz.x x0 E_LONG + b VT_FN2 +; Resolve recorded BL sites; function mode must have an acyclic call graph. +; 65536 fixed records at 0x1860000: site, callee entry, caller entry. State slot 12 is count. +:RESOLVE + movz.x x9 0x185 1 + ldr.x x10 x9 12 + movz.x x11 0x186 1 + movz.x x12 0 0 +:RS_PATCH + cmp.x x12 x10 + b.hs RS_GRAPH + ldr.x x0 x11 0 + ldr.x x1 x11 1 + ldr.x x1 x1 1 + sub.x x1 x1 x0 + ubfm.x x1 x1 2 27 + movz.x x2 0x9400 1 + orr.x x1 x1 x2 + str.w w1 x0 0 + add.x.i x11 x11 24 + add.x.i x12 x12 1 + b RS_PATCH +:RS_GRAPH + ldr.x x0 x9 6 + cbnz.x x0 RS_DONE + ldr.x x1 x9 2 + movz.x x2 0 0 + movz.x x3 0x19e 1 + movz.x x4 0x184 1 +:RS_PASS + cmp.x x2 x1 + b.hs RS_CHECK + movz.x x5 0 0 +:RS_FN + cmp.x x5 x1 + b.hs RS_NEXT + ldrb.r w0 x3 x5 + cbnz.x x0 RS_FNEXT + ubfm.x x6 x5 57 56 + add.x x6 x6 x4 + movz.x x7 0 0 + movz.x x11 0x186 1 +:RS_EDGE + cmp.x x7 x10 + b.hs RS_MARK + ldr.x x0 x11 2 + cmp.x x0 x6 + b.ne RS_ENEXT + ldr.x x0 x11 1 + sub.x x0 x0 x4 + ubfm.x x0 x0 7 63 + ldrb.r w0 x3 x0 + cbz.x x0 RS_FNEXT +:RS_ENEXT + add.x.i x7 x7 1 + add.x.i x11 x11 24 + b RS_EDGE +:RS_MARK + movz.x x0 1 0 + add.x x6 x3 x5 + strb w0 x6 0 +:RS_FNEXT + add.x.i x5 x5 1 + b RS_FN +:RS_NEXT + add.x.i x2 x2 1 + b RS_PASS +:RS_CHECK + movz.x x5 0 0 +:RS_CHECK1 + cmp.x x5 x1 + b.hs RS_DONE + ldrb.r w0 x3 x5 + cbz.x x0 E_SUBSET + add.x.i x5 x5 1 + b RS_CHECK1 +:RS_DONE + ret diff --git a/native/toolchain/seed/rung4/table4.s2 b/native/toolchain/seed/rung4/table4.s2 new file mode 100644 index 0000000..f2bf0f7 --- /dev/null +++ b/native/toolchain/seed/rung4/table4.s2 @@ -0,0 +1,5 @@ +; table4.s2 -- extra table lines for om4's own code (read after rung2/table.s2 and rung3/table3.s2). +; Same format; Arm DDI 0487 M.d. += cmn.x.i 0xb100001f r5 i10.12 ; C6.2.93 CMN (immediate) = ADDS XZR, Xn, #imm (C6.2.10) += ldr.x.r 0xf8607800 r0 r5 r16 ; C6.2.218 LDR (register), 64-bit, LSL #3 (index scaled by 8) += str.x.r 0xf8207800 r0 r5 r16 ; C6.2.416 STR (register), 64-bit, LSL #3 diff --git a/proofs/BuildConstants.wl b/proofs/BuildConstants.wl new file mode 100644 index 0000000..56c0278 --- /dev/null +++ b/proofs/BuildConstants.wl @@ -0,0 +1 @@ +<|"Kind" -> "MODELED ABI/config arithmetic; not hardware measurements", "WolframVersion" -> $Version, "OpenFlags" -> BitOr[1, 64, 128], "DirectoryFlags" -> BitOr[131072, 2048], "Mode644" -> FromDigits["644", 8], "Mode755" -> FromDigits["755", 8], "SourceFileLimitBytes" -> 1048576, "ExtraProbeBytes" -> 1048576 + 1|> diff --git a/proofs/EvidenceLabels.lean b/proofs/EvidenceLabels.lean new file mode 100644 index 0000000..d75d429 --- /dev/null +++ b/proofs/EvidenceLabels.lean @@ -0,0 +1,74 @@ +/- +Bounded model of an evidence-labeling rule. +This does not prove submitted code correct, authenticate the evidence fields, +or establish equivalence between this model and the website implementation. +-/ + +namespace Interplane + +structure Evidence where + pinnedSource : Bool + environmentRecorded : Bool + recipeRecorded : Bool + executionRecorded : Bool + checksPassed : Bool + deriving DecidableEq, Repr + +def eligibleForChecksPassed (e : Evidence) : Bool := + e.pinnedSource && e.environmentRecorded && e.recipeRecorded && + e.executionRecorded && e.checksPassed + +def allTrue : Evidence := ⟨true, true, true, true, true⟩ + +theorem eligible_iff_all_true (e : Evidence) : + eligibleForChecksPassed e = true ↔ e = allTrue := by + cases e with + | mk p env recipe execution checks => + cases p <;> cases env <;> cases recipe <;> cases execution <;> + cases checks <;> decide + +theorem eligible_implies_every_field (e : Evidence) + (h : eligibleForChecksPassed e = true) : + e.pinnedSource = true ∧ e.environmentRecorded = true ∧ + e.recipeRecorded = true ∧ e.executionRecorded = true ∧ + e.checksPassed = true := by + have hAll := (eligible_iff_all_true e).mp h + cases hAll + exact ⟨rfl, rfl, rfl, rfl, rfl⟩ + +theorem missing_any_field_prevents_acceptance (e : Evidence) : + (e.pinnedSource = false ∨ e.environmentRecorded = false ∨ + e.recipeRecorded = false ∨ e.executionRecorded = false ∨ + e.checksPassed = false) → eligibleForChecksPassed e = false := by + cases e with + | mk p env recipe execution checks => + cases p <;> cases env <;> cases recipe <;> cases execution <;> + cases checks <;> decide + +def allEvidence : List Evidence := + [true, false].bind fun p => + [true, false].bind fun env => + [true, false].bind fun recipe => + [true, false].bind fun execution => + [true, false].map fun checks => + ⟨p, env, recipe, execution, checks⟩ + +theorem all_evidence_enumerated (e : Evidence) : + List.elem e allEvidence = true := by + cases e with + | mk p env recipe execution checks => + cases p <;> cases env <;> cases recipe <;> cases execution <;> + cases checks <;> decide + +theorem sole_accepting_assignment : + allEvidence.filter eligibleForChecksPassed = [allTrue] := by + decide + +#print axioms eligible_iff_all_true +#print axioms eligible_implies_every_field +#print axioms missing_any_field_prevents_acceptance +#print axioms all_evidence_enumerated +#print axioms sole_accepting_assignment +#eval allEvidence.filter eligibleForChecksPassed + +end Interplane diff --git a/proofs/EvidenceLabels.wl b/proofs/EvidenceLabels.wl new file mode 100644 index 0000000..2e8065c --- /dev/null +++ b/proofs/EvidenceLabels.wl @@ -0,0 +1 @@ +With[{vars = {pinnedSource, environmentRecorded, recipeRecorded, executionRecorded, checksPassed}}, With[{eligible = And @@ vars}, <|"WolframVersion" -> $Version, "FieldOrder" -> (ToString /@ vars), "ImplicationToEachField" -> (TautologyQ[Implies[eligible, #], vars] & /@ vars), "MissingEachFieldPreventsAcceptance" -> (TautologyQ[Implies[Not[#], Not[eligible]], vars] & /@ vars), "MissingAnyFieldPreventsAcceptance" -> TautologyQ[Implies[Or @@ (Not /@ vars), Not[eligible]], vars], "TruthTable" -> BooleanTable[Join[vars, {eligible}], vars], "AcceptingAssignments" -> Select[BooleanTable[Join[vars, {eligible}], vars], Last[#] &]|>]] diff --git a/proofs/check.sh b/proofs/check.sh new file mode 100755 index 0000000..7ec27ec --- /dev/null +++ b/proofs/check.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$0")/.." + +lean_bin="$(command -v "${LEAN_BIN:-lean}")" +checker_root="$(cd "$(dirname "$lean_bin")/.." && pwd)" +temporary_dir="$(mktemp -d)" +trap 'rm -rf "$temporary_dir"' EXIT + +run_lean() { + if [[ "${LEAN_PROC_SELF_COMPAT:-0}" == 1 ]]; then + env LD_PRELOAD="$temporary_dir/proc-self-compat.so" "$lean_bin" "$@" + else + "$lean_bin" "$@" + fi +} + +printf 'Scope: bounded evidence-label model only\n' +printf 'UTC: ' +date -u '+%Y-%m-%dT%H:%M:%SZ' +printf 'Base commit: ' +git rev-parse HEAD +printf 'Platform: ' +uname -sm +printf 'LEAN_BIN=%s\nLEAN_PROC_SELF_COMPAT=%s\n' "$lean_bin" "${LEAN_PROC_SELF_COMPAT:-0}" + +if [[ "${LEAN_PROC_SELF_COMPAT:-0}" == 1 ]]; then + printf 'Command: cc -Wall -Wextra -Werror -shared -fPIC proofs/proc-self-compat.c -ldl -o TEMP/proc-self-compat.so\n' + cc -Wall -Wextra -Werror -shared -fPIC proofs/proc-self-compat.c -ldl -o "$temporary_dir/proc-self-compat.so" +fi + +printf 'Command: lean --version\n' +run_lean --version +printf 'Source and checker SHA-256:\n' +sha256sum proofs/EvidenceLabels.lean proofs/lean-toolchain proofs/proc-self-compat.c proofs/check.sh "$lean_bin" "$checker_root/lib/lean/libleanshared.so" "$checker_root/lib/lean/libInit_shared.so" + +printf 'Command: lean proofs/EvidenceLabels.lean\n' +run_lean proofs/EvidenceLabels.lean +printf 'Positive check exit status: 0\n' + +cat proofs/EvidenceLabels.lean > "$temporary_dir/FalseEvidenceLabel.lean" +cat >> "$temporary_dir/FalseEvidenceLabel.lean" <<'LEAN' + +-- This intentionally false theorem must be rejected by the checker. +example : Interplane.eligibleForChecksPassed + ⟨true, true, true, true, false⟩ = true := by + decide +LEAN +printf 'Negative control: same source plus a false theorem asserting eligibility when checksPassed=false\n' +printf 'Command: lean TEMP/FalseEvidenceLabel.lean\n' +set +e +run_lean "$temporary_dir/FalseEvidenceLabel.lean" > "$temporary_dir/negative-control.txt" 2>&1 +negative_status=$? +set -e +sed "s|$temporary_dir/|TEMP/|g" "$temporary_dir/negative-control.txt" +printf 'Negative check exit status: %s\n' "$negative_status" +if [[ "$negative_status" == 0 ]] || ! grep -q "tactic 'decide' proved that the proposition" "$temporary_dir/negative-control.txt"; then + printf 'ERROR: negative control did not fail in the expected way\n' >&2 + exit 1 +fi +printf 'Negative control rejected as expected\n' diff --git a/proofs/lean-toolchain b/proofs/lean-toolchain new file mode 100644 index 0000000..ef1f67e --- /dev/null +++ b/proofs/lean-toolchain @@ -0,0 +1 @@ +leanprover/lean4:v4.8.0 diff --git a/proofs/proc-self-compat.c b/proofs/proc-self-compat.c new file mode 100644 index 0000000..a8ab046 --- /dev/null +++ b/proofs/proc-self-compat.c @@ -0,0 +1,21 @@ +/* + * Compatibility for containers exposing /proc/self/exe but not /proc/PID/exe. + * Redirect only this process's executable-path query. All other readlink calls + * pass through unchanged. This does not modify Lean or its proof checker. + */ +#define _GNU_SOURCE +#include +#include +#include +#include + +ssize_t readlink(const char *path, char *buffer, size_t size) { + ssize_t (*next_readlink)(const char *, char *, size_t) = + dlsym(RTLD_NEXT, "readlink"); + char own_executable[64]; + snprintf(own_executable, sizeof own_executable, "/proc/%d/exe", getpid()); + if (strcmp(path, own_executable) == 0) { + path = "/proc/self/exe"; + } + return next_readlink(path, buffer, size); +} diff --git a/public/favicon.svg b/public/favicon.svg new file mode 100644 index 0000000..4378b33 --- /dev/null +++ b/public/favicon.svg @@ -0,0 +1 @@ + diff --git a/public/orbit.svg b/public/orbit.svg new file mode 100644 index 0000000..955aea5 --- /dev/null +++ b/public/orbit.svg @@ -0,0 +1 @@ +A second orbitAn unfinished code window, a salvaged satellite, and a useful component drift around a warm orange planet.almost.om01020304there's a useful bit in here.RECOVERED POSSIBILITYstill has potential.KEEP EXPLORING{ }idea-v7.finalROOM FOR ANOTHER ORBIT diff --git a/public/style.css b/public/style.css index f96a265..e8fcb3d 100644 --- a/public/style.css +++ b/public/style.css @@ -1,144 +1,4 @@ -/* interplane.io: one stylesheet, system fonts only, light and dark from the reader's setting. */ -:root { - --bg: #fbfaf7; - --bg-raised: #ffffff; - --fg: #1a1c20; - --muted: #5b6270; - --line: #e2ded6; - --accent: #b86e0a; - --accent-ink: #7a4705; - --plane: #f2a93b; - --ok: #1e6f3d; - --bad: #a32b22; - --wait: #7a5a00; - --code-bg: #f1eee8; - --shadow: 0 1px 2px rgba(20, 20, 30, 0.06), 0 12px 32px rgba(20, 20, 30, 0.06); - color-scheme: light dark; -} -@media (prefers-color-scheme: dark) { - :root { - --bg: #101317; - --bg-raised: #171b21; - --fg: #e8e9ec; - --muted: #9ba3b0; - --line: #2a313b; - --accent: #f2a93b; - --accent-ink: #ffd089; - --plane: #f2a93b; - --ok: #7bd89a; - --bad: #ff8a80; - --wait: #f0c674; - --code-bg: #1d222a; - --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35); - } -} -* { box-sizing: border-box; } -html { scroll-behavior: smooth; } -body { - margin: 0; - background: var(--bg); - color: var(--fg); - font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; - -webkit-font-smoothing: antialiased; -} -a { color: var(--accent-ink); text-decoration-color: var(--line); text-underline-offset: 3px; } -a:hover { text-decoration-color: currentColor; } -code, pre { font: 0.92em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; } -pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; } -h1, h2, h3 { line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.5em; } -h2 { font-size: 1.75rem; margin-top: 0; } -h3 { font-size: 1.15rem; } -p { margin: 0 0 1em; } -strong.ok { color: var(--ok); } -strong.bad { color: var(--bad); } -.skip { position: absolute; left: -999px; top: 8px; background: var(--bg-raised); padding: 8px 12px; border-radius: 8px; } -.skip:focus { left: 16px; z-index: 10; } -.dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); vertical-align: middle; } - -/* Width and rhythm */ -main, footer, .hero { max-width: 68rem; margin: 0 auto; padding: 0 16px; } -main > section { padding: 56px 0; border-top: 1px solid var(--line); } -main > section:first-child { border-top: 0; } -.prose { max-width: 44rem; } -.section-lede { color: var(--muted); max-width: 44rem; margin-bottom: 2em; } -.fine { color: var(--muted); font-size: 0.92rem; } - -/* Hero */ -.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; padding-top: 56px; padding-bottom: 56px; } -.kicker { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; margin-bottom: 1.2em; } -.hero h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); letter-spacing: 0.06em; margin-bottom: 0.3em; } -.hero h1::after { content: ""; display: block; width: 4.5rem; height: 4px; background: var(--plane); margin-top: 0.4em; border-radius: 2px; } -.tagline { font-size: 1.35rem; line-height: 1.35; font-weight: 600; max-width: 30ch; } -.lede { color: var(--muted); max-width: 52ch; } -.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1.6em; } -.button { display: inline-block; padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-raised); color: var(--fg); text-decoration: none; font-weight: 600; font-size: 0.95rem; } -.button:hover { border-color: var(--accent); } -.button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); } -.hero-art { margin: 0; } -.hero-art img { display: block; width: 100%; height: auto; border-radius: 14px; box-shadow: var(--shadow); } - -/* Problem */ -blockquote { margin: 1.6em 0 0; padding: 0 0 0 18px; border-left: 4px solid var(--plane); font-size: 1.15rem; font-weight: 600; line-height: 1.4; } - -/* Modules */ -.modules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; counter-reset: module; } -.modules li { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px; padding: 20px 20px 16px; position: relative; counter-increment: module; } -.modules li::before { content: counter(module, decimal-leading-zero); position: absolute; top: 18px; right: 20px; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.08em; } -.modules h3 { margin-bottom: 0.2em; } -.modules .question { color: var(--accent-ink); font-weight: 600; margin-bottom: 0.6em; } -.modules p { font-size: 0.97rem; } -.modules .spec { font-size: 0.9rem; } - -/* Receipt */ -.receipt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 1.4em; } -.cell { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 14px; padding: 20px; } -.big { display: block; font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; } -.label { display: block; color: var(--muted); font-size: 0.92rem; margin-top: 6px; } - -/* Status */ -.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-raised); margin-bottom: 28px; } -.pill { font-weight: 800; font-size: 0.85rem; letter-spacing: 0.08em; padding: 4px 10px; border-radius: 999px; color: #fff; } -.pill.ok { background: var(--ok); } -.pill.bad { background: var(--bad); } -.pill.wait { background: var(--wait); } -.pill.none { background: var(--muted); } -.verdict-text { flex: 1 1 20rem; } -.stages { margin-bottom: 28px; } -.stage-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--bg-raised); } -.stage { display: grid; grid-template-columns: 4rem 9rem 1fr 15rem; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); align-items: baseline; } -.stage:first-child { border-top: 0; } -.stage .version { font-weight: 700; } -.stage .layer { font-weight: 600; } -.stage .goal { color: var(--muted); font-size: 0.95rem; } -.stage .state { font-size: 0.92rem; text-align: right; } -.stage.next .state { color: var(--accent-ink); font-weight: 600; } -.stage.planned { color: var(--muted); } -.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-bottom: 28px; } -.counts { margin: 0 0 1em; padding-left: 1.1em; } -.counts li { margin-bottom: 4px; } -.report-list { margin: 0; padding-left: 1.1em; } -.report-list li { margin-bottom: 10px; } -.report-list .headline { color: var(--muted); } - -/* Shared documentation routes: the existing system-font palette and width. */ -.docs-nav { max-width: 68rem; margin: 0 auto; padding: 18px 16px; display: flex; flex-wrap: wrap; gap: 10px 24px; border-bottom: 1px solid var(--line); font-size: .92rem; } -.docs-nav a { padding: 4px 0; } -.docs-nav a[aria-current="page"] { font-weight: 700; text-decoration-color: var(--accent); } -.docs-main h1 { font-size: clamp(2rem, 5vw, 3rem); } -.source-record code, .prose p code { overflow-wrap: anywhere; } -.docs-main ol { padding-left: 1.3em; } -.docs-main li { margin-bottom: .7em; } - -/* Footer */ -footer { padding: 32px 16px 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.92rem; } - -@media (max-width: 820px) { - body { font-size: 16px; } - .hero { grid-template-columns: 1fr; padding-top: 32px; gap: 24px; } - .hero-art { order: -1; } - main > section { padding: 40px 0; } - .stage { grid-template-columns: 3.5rem 1fr; } - .stage .goal { grid-column: 1 / -1; } - .stage .state { grid-column: 1 / -1; text-align: left; } - .big { font-size: 1.6rem; } -} +:root{--paper:#f5f3eb;--ink:#242923;--muted:#62665c;--orange:#da4828;--lime:#e2e89b;--line:#d6d8cc;--white:#fdfcf7;--green:#416556}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--paper);color:var(--ink);font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:1.6;-webkit-font-smoothing:antialiased}a{color:inherit;text-underline-offset:5px}a:hover{color:var(--orange)}a:focus-visible,summary:focus-visible,input:focus-visible+label{outline:3px solid var(--orange);outline-offset:5px}h1,h2,h3,p,figure{margin:0}h1,h2,h3{line-height:1.05;letter-spacing:-.055em;font-weight:600}h1{font-size:clamp(46px,6.3vw,88px)}h1 em{font-style:normal;color:var(--orange)}h2{font-size:clamp(32px,3.5vw,49px)}h3{font-size:24px;letter-spacing:-.035em}p{color:var(--muted)}header,main,footer{max-width:1360px;margin:auto}header{min-height:108px;display:flex;align-items:center;gap:36px;padding:0 64px;border-bottom:1px solid var(--line)}.brand{display:flex;align-items:center;gap:10px;font-size:29px;font-weight:700;text-decoration:none;letter-spacing:-1.5px;white-space:nowrap}.brandmark{font-size:39px;font-weight:400;line-height:1}.branddot{color:var(--orange);margin-left:-10px}nav{display:flex;gap:30px;margin-left:auto}nav a{font-size:13px;text-decoration:none;font-weight:600}.button{display:inline-flex;gap:34px;align-items:center;justify-content:space-between;min-height:52px;padding:14px 24px;border:1px solid transparent;border-radius:5px;font-weight:600;font-size:14px;text-decoration:none;transition:transform .2s,background .2s}.button:hover{transform:translateY(-2px)}.button.dark{background:var(--ink);color:var(--white)}.button.dark:hover{background:#3e473b}.button.orange{background:var(--orange);color:#fff}.button.orange:hover{background:#b6371b}.button.small{min-height:43px;padding:10px 16px;gap:24px;font-size:12px}.text-link{display:inline-flex;gap:17px;align-items:center;font-size:14px;font-weight:600;text-decoration:none;border-bottom:1px solid currentColor;padding-bottom:3px}.eyebrow{font-family:ui-monospace,monospace;font-size:10px;font-weight:500;letter-spacing:1.9px;line-height:1.6}.signal{display:inline-block;width:6px;height:6px;background:var(--green);border-radius:50%;margin-right:9px}.hero{display:grid;grid-template-columns:1fr 1.02fr;gap:20px;padding:70px 64px 46px;align-items:center;min-height:670px}.hero h1{margin:25px 0 26px}.hero-copy>p{max-width:430px;font-size:16px;line-height:1.8}.actions{display:flex;gap:30px;align-items:center;margin:30px 0 28px;flex-wrap:wrap}.hero-note{font-size:11px;color:var(--muted);display:flex;gap:10px;align-items:center}.small-star{color:var(--orange);font-size:20px}.hero-art img{display:block;width:100%;height:auto}.hero-art figcaption{display:flex;justify-content:space-between;padding:0 20px 0 12px;align-items:center}.coordinate{font-family:ui-monospace,monospace;font-size:9px;letter-spacing:1.7px}.stamp{font-family:ui-monospace,monospace;font-size:9px;border:1px solid var(--ink);border-radius:3px;padding:5px 9px;transform:rotate(-5deg)}.ticker{display:flex;justify-content:space-between;gap:17px;align-items:center;flex-wrap:wrap;padding:21px 64px;background:var(--lime);font-family:ui-monospace,monospace;font-size:12px;letter-spacing:.1px;border-top:1px solid #ccd37f;border-bottom:1px solid #ccd37f}.ticker span:nth-child(even){font-size:20px}.split{display:grid;grid-template-columns:1fr 1.5fr;gap:60px}.intro{padding:95px 64px;border-bottom:1px solid var(--line)}.intro>.eyebrow{padding-top:7px}.intro p{margin:26px 0 23px;max-width:650px;font-size:16px;line-height:1.85}.collection{padding:84px 64px}.section-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:25px;margin-bottom:24px}.section-heading .eyebrow{margin-bottom:15px}.section-note{max-width:780px;font-size:13px;line-height:1.8;margin-bottom:28px}.card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:24px}.piece{min-width:0}.piece-visual{position:relative;min-height:220px;border:1px solid var(--line);border-radius:7px;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;text-decoration:none;isolation:isolate;transition:transform .2s}.piece-visual:hover{transform:translateY(-4px);color:var(--ink)}.piece-visual:before,.piece-visual:after{content:"";position:absolute;z-index:-1}.piece-visual.code{background:#e6e4da}.piece-visual.code:before{width:180px;height:108px;border:1px solid #6a7065;transform:rotate(-8deg);background:#f8f7f1;box-shadow:8px 9px 0 #c3c5b9}.piece-visual.code:after{width:160px;top:63px;border-top:1px solid #9a9e90;transform:rotate(-8deg)}.artifact-symbol{font-family:ui-monospace,monospace;font-size:48px;line-height:1;font-weight:400}.visual-label{position:absolute;left:18px;bottom:16px;font-family:ui-monospace,monospace;font-size:10px}.round-arrow{position:absolute;right:15px;bottom:14px;border:1px solid #969d89;border-radius:100%;width:28px;height:28px;text-align:center;line-height:25px}.piece-visual.mesh{background:#dfe8d9}.piece-visual.mesh:before{width:125px;height:125px;background:repeating-linear-gradient(35deg,transparent 0 9px,#7a9775 10px 11px,transparent 12px 18px);border:1px solid #658361;border-radius:50%;transform:rotate(-25deg)}.piece-visual.mesh .artifact-symbol{font-size:82px;color:#3f6b45}.piece-visual.orbit{background:#f1dcd0}.piece-visual.orbit:before{width:180px;height:80px;border:1px solid #ae7057;border-radius:50%;transform:rotate(-30deg)}.piece-visual.orbit:after{width:85px;height:130px;border:1px solid #ae7057;border-radius:50%;transform:rotate(-30deg)}.piece-visual.orbit .artifact-symbol{font-size:90px;color:#b94726}.piece-body{padding:23px 0 12px}.piece-body .eyebrow{color:var(--muted);font-size:9px;letter-spacing:1.7px}.piece-body h3{font-size:24px;line-height:1.2;margin:12px 0 14px;max-width:280px}.piece-body h3 a{text-decoration:none}.piece-body p{font-size:13px;line-height:1.75;min-height:70px}.piece-meta{display:flex;align-items:center;gap:5px;flex-wrap:wrap;font-size:10px;color:var(--muted);margin-top:20px}.status-dot{width:5px;height:5px;background:var(--green);border-radius:50%}.piece-meta .mono{margin-left:auto}.mono{font-family:ui-monospace,monospace}.process{padding:75px 64px 90px;border-top:1px solid var(--line)}.steps{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:40px;margin-top:55px}.step-number{font-family:ui-monospace,monospace;font-size:12px;color:var(--orange);display:block;padding-bottom:15px;border-bottom:1px solid var(--line);margin-bottom:23px}.steps h3{font-size:23px;line-height:1.2;margin-bottom:12px}.steps p{font-size:13px;line-height:1.8}.invitation{background:var(--lime);margin:0 64px 82px;border-radius:8px;padding:50px 55px;display:flex;gap:28px;position:relative;overflow:hidden}.invite-star{font-size:58px;line-height:1}.invitation .eyebrow{font-size:9px}.invitation h2{font-size:clamp(38px,4.7vw,64px);margin:20px 0}.invitation p{color:#515841;font-size:14px;margin-bottom:24px}.invite-orbit{font-size:300px;line-height:1;position:absolute;right:-15px;top:30px;opacity:.12;transform:rotate(-30deg);pointer-events:none}.invitation .button{position:relative;z-index:1}.invitation.compact h2{font-size:42px}footer{padding:0 64px 30px}.footer-top{display:flex;align-items:center;justify-content:space-between;gap:25px;padding:30px 0}.footer-top .brand{font-size:26px}.footer-top p,.footer-top>a:last-child{font-size:12px}.footer-bottom{border-top:1px solid var(--line);padding-top:24px;display:flex;justify-content:space-between;gap:18px;font-size:10px;color:var(--muted)}.footer-bottom>div{display:flex;gap:24px}.footer-bottom a{text-decoration:none}.skip{position:absolute;left:20px;top:-80px;z-index:20;background:var(--ink);color:white;padding:10px 20px}.skip:focus{top:10px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.page-lead{padding:80px 64px 55px;max-width:1160px}.page-lead h1{font-size:clamp(43px,5.4vw,70px);margin:25px 0 26px}.page-lead p{max-width:760px;font-size:18px;line-height:1.8}.explorer{padding:0 64px 85px}.filters{display:flex;flex-wrap:wrap;gap:10px;border:0;padding:0 0 28px;margin:0}.filters input{position:absolute;opacity:0;width:1px;height:1px}.filters label{border:1px solid var(--line);border-radius:30px;padding:9px 20px;font-size:13px;cursor:pointer}.filters input:checked+label{background:var(--ink);color:var(--white);border-color:var(--ink)}.filters:has(#cat-tools:checked)~.catalog .piece:not([data-type="tools"]),.filters:has(#cat-models:checked)~.catalog .piece:not([data-type="models"]),.filters:has(#cat-protocols:checked)~.catalog .piece:not([data-type="protocols"]){display:none}.inline-cta{padding:50px 64px;background:#e7e9db;display:flex;align-items:center;justify-content:space-between;gap:24px;margin-bottom:70px}.inline-cta h2{font-size:32px}.inline-cta p{max-width:650px;margin-top:15px;font-size:14px}.contribute-layout,.detail-layout{display:grid;grid-template-columns:1.5fr 1fr;gap:50px;padding:0 64px 70px}.formlike{border:1px solid var(--line);border-radius:8px;padding:35px;background:var(--white)}.formlike h2{font-size:33px;margin:20px 0}.intake-list{list-style:none;padding:0;margin:30px 0}.intake-list li{display:flex;gap:22px;margin:25px 0;padding-bottom:25px;border-bottom:1px solid var(--line)}.intake-list li>span{font-family:ui-monospace,monospace;color:var(--orange);font-size:12px}.intake-list h3{font-size:19px;line-height:1.3;margin-bottom:8px}.intake-list p{font-size:13px;line-height:1.8}.wide{width:100%;gap:10px}.fine{font-size:11px;line-height:1.7;margin-top:15px}.note-panel{background:#e8eadf;border-radius:6px;padding:35px;align-self:start}.note-icon{font-size:45px;line-height:1}.note-panel h3{font-size:23px;line-height:1.2;margin:14px 0}.note-panel p{font-size:13px;line-height:1.9;margin-bottom:20px}.note-panel hr{border:0;border-top:1px solid #c7cbba;margin:30px 0}.download{display:flex;justify-content:space-between;align-items:center;font-size:13px;border-bottom:1px solid #a7ad98;padding:13px 0;text-decoration:none}.prose-section{max-width:920px;padding:25px 64px 90px}.prose-section h2{font-size:32px;margin:35px 0 20px}.prose-section p{line-height:1.85;margin:15px 0 22px}.prose-section .text-link{margin-top:20px}details{border-top:1px solid var(--line);border-bottom:1px solid var(--line);margin:30px 0;padding:20px 0}summary{cursor:pointer;font-weight:600;line-height:1.5}details p{margin-top:18px}details ul{padding-left:20px;font-size:14px}details li{margin:14px 0}.journey{padding:0 64px 70px}.journey article{display:grid;grid-template-columns:1fr 2fr;gap:60px;border-top:1px solid var(--line);padding:42px 0}.journey article>span{font-size:11px;font-family:ui-monospace,monospace;color:var(--orange);padding-top:8px}.journey h2{font-size:37px;margin-bottom:20px}.journey p{line-height:1.8;max-width:650px}.mission-copy{display:grid;grid-template-columns:1fr 1.6fr;gap:90px;padding:15px 64px 90px}.big-quote{font-size:30px;line-height:1.3;letter-spacing:-1px;padding-top:20px;color:var(--orange)}.mission-copy h2{font-size:36px;margin:20px 0}.mission-copy p{line-height:1.9;margin-bottom:27px}.signature{margin-top:40px;color:var(--ink);font-weight:600}.signature span{font-size:12px;font-weight:400;color:var(--muted)}.evidence-table{border-top:1px solid var(--line);margin:30px 0 45px}.evidence-table>div{display:grid;grid-template-columns:150px 1fr;gap:30px;border-bottom:1px solid var(--line);padding:20px 0}.evidence-table strong{font-size:14px}.evidence-table p{margin:0;font-size:14px}.piece-lead{padding:55px 64px 50px}.backlink{display:block;font-size:12px;margin-bottom:36px;text-decoration:none}.piece-lead h1{margin:24px 0;font-size:clamp(43px,5vw,70px)}.piece-lead>p{max-width:740px;font-size:18px;line-height:1.8}.badge{display:inline-block;font-size:11px;padding:6px 14px;background:#e4eadb;border:1px solid #bac9ae;border-radius:20px;margin-top:23px}.detail-layout h2{font-size:32px;margin:22px 0 16px}.detail-layout p{line-height:1.85;margin-bottom:28px}.detail-layout .button{margin:12px 0 30px}.hash{overflow-wrap:anywhere;font-size:12px!important;color:var(--ink)}dl{font-size:12px}dt{font-weight:600;margin-top:18px}dd{margin:3px 0 0;color:var(--muted)}.note-panel .text-link{font-size:12px;margin-top:20px}.doc-nav{display:flex;gap:16px;flex-wrap:wrap;font-size:13px;border-top:1px solid var(--line);padding-top:24px;margin-top:35px} +@media(min-width:1440px){header,main,footer{border-left:1px solid #e9e8df;border-right:1px solid #e9e8df}}@media(max-width:1050px){header{padding:0 32px;gap:25px}nav{gap:20px}header .brand{font-size:26px}.hero{padding:55px 32px 40px;min-height:auto;gap:10px}.hero h1{font-size:66px}.hero-copy>p{font-size:14px}.hero .actions{gap:20px}.hero-art figcaption{gap:12px}.stamp{font-size:8px}.intro,.collection,.process,.explorer,.journey,.page-lead,.piece-lead{padding-left:32px;padding-right:32px}.ticker{padding-left:32px;padding-right:32px;font-size:10px;gap:12px}.invitation{margin-left:32px;margin-right:32px}footer{padding-left:32px;padding-right:32px}.contribute-layout,.detail-layout,.mission-copy{padding-left:32px;padding-right:32px;gap:30px}.card-grid{gap:18px}.piece-visual{min-height:195px}.section-heading h2{font-size:38px}.piece-body h3{font-size:21px}.piece-meta .mono{margin-left:0;width:100%}.footer-top p{display:none}.inline-cta{padding-left:32px;padding-right:32px}} +@media(max-width:760px){header{min-height:82px;padding:18px 22px;flex-wrap:wrap;gap:16px}header .brand{font-size:25px;margin-right:auto}.brandmark{font-size:30px}header>.button{font-size:11px;padding:8px 11px;min-height:36px;gap:14px}nav{order:3;width:100%;justify-content:space-between;margin:0;padding-top:3px;gap:12px}nav a{font-size:11px}.hero{grid-template-columns:1fr;padding:42px 22px 30px;gap:25px}.hero h1{font-size:clamp(56px,12vw,80px);margin:22px 0}.hero-copy>p{font-size:15px;max-width:470px}.hero .eyebrow{font-size:9px;letter-spacing:1.4px}.hero .actions{gap:22px;margin:26px 0 22px}.hero-art{max-width:480px;width:100%;margin:auto}.hero-art figcaption{padding:0 8px}.hero-art img{margin-top:-12px}.ticker{padding:17px 22px;justify-content:center;gap:12px;font-size:10px}.ticker span:nth-child(even){font-size:14px}.ticker span:nth-child(n+8){display:none}.split{grid-template-columns:1fr;gap:22px}.intro{padding:55px 22px}.intro h2{font-size:36px}.intro p{font-size:15px}.collection,.process{padding:55px 22px}.section-heading{align-items:flex-start;flex-direction:column;gap:20px}.section-heading h2{font-size:35px}.section-heading .eyebrow{font-size:9px}.card-grid{grid-template-columns:1fr;gap:30px}.piece-visual{min-height:245px}.piece-visual.code:before{top:60px}.piece-visual.code:after{top:83px}.piece-body{padding:19px 0 10px}.piece-body h3{font-size:26px;max-width:none}.piece-body p{min-height:0;font-size:14px}.piece-meta{margin-top:18px;font-size:11px}.piece-meta .mono{margin-left:auto;width:auto}.steps{grid-template-columns:1fr;gap:32px;margin-top:33px}.steps h3{font-size:25px}.steps p{font-size:14px}.step-number{margin-bottom:20px}.invitation{margin:0 22px 45px;padding:32px 25px;gap:15px}.invite-star{display:none}.invitation h2{font-size:48px}.invitation .eyebrow{max-width:220px}.invite-orbit{right:-90px;top:60px}.invitation p{max-width:220px}.invitation.compact h2{font-size:33px}footer{padding:0 22px 30px}.footer-top{align-items:flex-start;gap:20px;flex-direction:column}.footer-top>a:last-child{font-size:13px}.footer-bottom{flex-direction:column;gap:20px;line-height:1.7}.footer-bottom>div{gap:20px;flex-wrap:wrap}.page-lead{padding:45px 22px 35px}.page-lead h1{font-size:43px;margin:22px 0}.page-lead p{font-size:16px}.explorer{padding:0 22px 45px}.filters{gap:8px}.filters label{font-size:12px;padding:7px 13px}.inline-cta{padding:35px 22px;flex-direction:column;align-items:flex-start;margin-bottom:40px}.inline-cta h2{font-size:30px}.contribute-layout,.detail-layout{grid-template-columns:1fr;padding:0 22px 35px;gap:30px}.formlike{padding:25px 20px}.formlike h2{font-size:30px}.intake-list li{gap:15px}.wide{font-size:12px;padding:14px 15px}.note-panel{padding:26px}.prose-section{padding:10px 22px 50px}.prose-section h2{font-size:29px}.journey{padding:0 22px 40px}.journey article{grid-template-columns:1fr;gap:20px;padding:30px 0}.journey h2{font-size:31px}.journey p{font-size:15px}.mission-copy{grid-template-columns:1fr;gap:30px;padding:0 22px 40px}.big-quote{font-size:29px;border-bottom:1px solid var(--line);padding-bottom:30px}.mission-copy h2{font-size:31px}.mission-copy p{font-size:15px}.evidence-table>div{grid-template-columns:1fr;gap:8px}.piece-lead{padding:35px 22px}.piece-lead h1{font-size:43px}.piece-lead>p{font-size:16px}.detail-layout h2{font-size:30px}.backlink{margin-bottom:28px}} +@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}*{transition:none!important}}@media print{header,footer,.actions,.button{display:none}.hero{display:block}.hero-art{max-width:400px}.card-grid{grid-template-columns:1fr}.piece{break-inside:avoid}body{background:white;color:black}} diff --git a/scripts/build-native.sh b/scripts/build-native.sh new file mode 100755 index 0000000..bbd3df2 --- /dev/null +++ b/scripts/build-native.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# Host orchestration only. Product assembly and verification live in native/site.om. +# OMC: pinned executable compiler; required on x86 Linux. +# OMEGA_SRC: local Omega checkout (default ~/workspace/omega-mv), used on AArch64 +# only when OMC is unset. Its seed/out/omc must match the pinned digest. +# OMC_RUNNER: optional single executable, for example qemu-aarch64-static. +# Usage: sh scripts/build-native.sh OUTPUT [x86_64|aarch64] +set -eu + +if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then + echo 'usage: build-native.sh OUTPUT [x86_64|aarch64]' >&2 + exit 2 +fi +OUTPUT=$1 +ARCH=${2:-$(uname -m)} +case "$ARCH" in + x86_64|aarch64) ;; + *) echo "unsupported native target: $ARCH" >&2; exit 2 ;; +esac + +if [ -z "${OMC:-}" ]; then + if [ "$(uname -m)" != aarch64 ]; then + echo 'set OMC to the pinned native compiler; see docs/RELEASE.md' >&2 + exit 2 + fi + OMC="${OMEGA_SRC:-$HOME/workspace/omega-mv}/seed/out/omc" +fi +if [ ! -x "$OMC" ]; then + echo "pinned compiler missing or not executable: $OMC; set OMC explicitly" >&2 + exit 2 +fi +COMPILER_HASH=$(sha256sum "$OMC") +COMPILER_HASH=${COMPILER_HASH%% *} +case "$COMPILER_HASH" in + 3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194|\ + 79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd) ;; + *) echo "refuse: compiler SHA-256 is not the pinned Omega compiler: $COMPILER_HASH" >&2; exit 3 ;; +esac + +ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +test "$(head -n 1 "$ROOT/native/site.om")" = 'target x86linux' || { + echo 'refuse: unexpected native/site.om target header' >&2 + exit 3 +} +mkdir -p "$(dirname -- "$OUTPUT")" +WORK=$(mktemp -d "$(dirname -- "$OUTPUT")/.native-build.XXXXXXXX") +trap 'rm -rf "$WORK"' 0 +trap 'exit 1' 1 2 15 +if [ "$ARCH" = aarch64 ]; then + # Remove only the target-selection line. Omega defaults to AArch64 Linux. + sed '1d' "$ROOT/native/site.om" > "$WORK/site.om" +else + cp "$ROOT/native/site.om" "$WORK/site.om" +fi +if [ -n "${OMC_RUNNER:-}" ]; then + "$OMC_RUNNER" "$OMC" < "$WORK/site.om" > "$WORK/site-omega" +else + "$OMC" < "$WORK/site.om" > "$WORK/site-omega" +fi +test -s "$WORK/site-omega" +chmod +x "$WORK/site-omega" +mv "$WORK/site-omega" "$OUTPUT" diff --git a/scripts/build-seed.sh b/scripts/build-seed.sh new file mode 100755 index 0000000..f72e416 --- /dev/null +++ b/scripts/build-seed.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# Reproduce the pinned compiler from the vendored upstream seed text. +# Host orchestration only. The assembler/compiler programs are upstream sources. +# Usage: QEMU=/path/to/qemu-aarch64-static sh scripts/build-seed.sh NEW_OUTPUT_DIR +set -eu +test "$#" -eq 1 || { echo 'usage: build-seed.sh NEW_OUTPUT_DIR' >&2; exit 2; } +test ! -e "$1" || { echo 'refuse: seed output directory already exists' >&2; exit 2; } +ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) +SOURCE="$ROOT/native/toolchain" +printf '%s %s\n' af381c8f7bd701674eb9a281dc43bba30e278c37369ab3a990ee697ce861fd75 "$SOURCE/SHA256SUMS" | sha256sum --check +(cd "$SOURCE" && sha256sum --check SHA256SUMS) +case "$(uname -m)" in + aarch64) RUNNER=${QEMU:-} ;; + x86_64) RUNNER=${QEMU:-qemu-aarch64-static} ;; + *) echo 'unsupported seed host architecture' >&2; exit 2 ;; +esac +if [ -n "$RUNNER" ]; then command -v "$RUNNER" >/dev/null; fi +mkdir -p "$1" +cd "$1" +run_arm() { + if [ -n "$RUNNER" ]; then "$RUNNER" "$@"; else "$@"; fi +} +check_hash() { printf '%s %s\n' "$2" "$1" | sha256sum --check; } + +sh "$SOURCE/seed/rung0/load0.sh" "$SOURCE/seed/rung0/seed0.hex" seed0.bin +check_hash seed0.bin aca00cf3677236809f0f223437398c6bb429e4c65f13d58762bcf96d13799474 +chmod +x seed0.bin +run_arm ./seed0.bin < "$SOURCE/seed/rung0/seed0.hex" > seed0.self +cmp seed0.bin seed0.self +run_arm ./seed0.bin < "$SOURCE/seed/rung1/hex1.hex" > hex1.bin +check_hash hex1.bin 920e1756aec399c7c74f5cedd1676abb91b844ea75448e14aa50dcb0bbc7ba5d +chmod +x hex1.bin +run_arm ./hex1.bin < "$SOURCE/seed/rung1/hex1.hex" > hex1.self +cmp hex1.bin hex1.self +run_arm ./hex1.bin < "$SOURCE/seed/rung2/asm2.hex1" > asm2.bin +check_hash asm2.bin 6988abe072fac3cdef2240d5ad13a3ecd8fb576fa09112d344b9e7c2315969c4 +chmod +x asm2.bin +cat "$SOURCE/seed/rung2/table.s2" "$SOURCE/seed/rung3/table3.s2" \ + "$SOURCE/seed/rung4/table4.s2" "$SOURCE/seed/rung4/om4.s" > om4.input +run_arm ./asm2.bin < om4.input > om4.bin +check_hash om4.bin d0da40e45f1fcc45d9a39c9c52c9d745b545e076970729e51c12d76ef519efab +chmod +x om4.bin +run_arm ./om4.bin < "$SOURCE/seed/omc/omc.om" > omc-stage1 +check_hash omc-stage1 3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194 +chmod +x omc-stage1 +run_arm ./omc-stage1 < "$SOURCE/seed/omc/omc.om" > omc-stage2 +cmp omc-stage1 omc-stage2 +chmod +x omc-stage2 +run_arm ./omc-stage2 < "$SOURCE/seed/omc/omc.om" > omc-stage3 +cmp omc-stage2 omc-stage3 +check_hash omc-stage3 3ad9f10f64309e7acf8a725082b28e23a2a4aeb07e98322fb4dc0fcd8fc93194 +cp omc-stage3 omc-aarch64 +chmod +x omc-aarch64 +{ printf 'target x86linux\n'; cat "$SOURCE/seed/omc/omc.om"; } > omc-x86-source.om +run_arm ./omc-aarch64 < omc-x86-source.om > omc-x86 +check_hash omc-x86 79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd +chmod +x omc-x86 +if [ "$(uname -m)" = x86_64 ]; then + ./omc-x86 < omc-x86-source.om > omc-x86-stage2 + cmp omc-x86 omc-x86-stage2 + echo 'PASS native x86 compiler fixed point' +fi +echo 'PASS pinned seed replay and AArch64 compiler fixed point' diff --git a/scripts/sync-to-hub.sh b/scripts/sync-to-hub.sh index 9b6eb54..f3a66ef 100644 --- a/scripts/sync-to-hub.sh +++ b/scripts/sync-to-hub.sh @@ -1,15 +1,18 @@ #!/bin/sh -# scripts/sync-to-hub.sh: rebuild interplane.io from the protocol repository's public record and +# scripts/sync-to-hub.sh: rebuild interplane.io from reviewed, committed static sources and # copy the result to the web server on the hub Pi. Runs from cron on the Spark once an hour. # -# REPO clean clone of aien-dev/interplane.io on branch main (default ~/workspace/web/interplane.io-live) +# REPO clean clone of canonical interplane.io on branch main (default ~/workspace/web/interplane.io-live) # HUB ssh host that serves the site (default hub) # WEBDIR document root on HUB (default /var/www/interplane.io) -# LOGDIR where this script keeps its log and the last facts file (default ~/.local/share/interplane-site) +# LOGDIR log and published release digest (default ~/.local/share/interplane-site) +# OMC pinned Omega executable (AArch64 default: $OMEGA_SRC/seed/out/omc) +# OMEGA_SRC local Omega checkout (default ~/workspace/omega-mv; see docs/RELEASE.md) +# OMC_RUNNER optional emulator executable (normally unset on Spark) # # Rules: never run while the Spark quiet flag is held (chip runs own the machine then); never build -# a dirty checkout; if the facts step fails, rebuild from the last good facts so the site still -# follows a source change; refuse to publish a page that fails `site-builder verify`. +# a dirty checkout; require the pinned compiler; refuse a failed native build or verify. +# No facts refresh or last-good fallback: the reviewed content/facts.json is part of each build. set -eu REPO=${REPO:-"$HOME/workspace/web/interplane.io-live"} @@ -28,7 +31,7 @@ fi if [ ! -d "$REPO/.git" ]; then say "clone into $REPO" - git clone -q https://github.com/aien-dev/interplane.io.git "$REPO" + git clone -q https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git "$REPO" fi cd "$REPO" if [ -n "$(git status --porcelain)" ]; then @@ -40,32 +43,35 @@ git checkout -q main git merge -q --ff-only origin/main HEAD=$(git rev-parse --short=12 HEAD) -export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$REPO/target}" -cargo build -q --locked --release -p site-builder -BIN="$CARGO_TARGET_DIR/release/site-builder" - -if "$BIN" facts "$LOGDIR/facts.json" >>"$LOG" 2>&1; then - say "facts refreshed" -else - if [ -s "$LOGDIR/facts.json" ]; then - say "facts step failed; building with the last good facts" - else - say "facts step failed and no earlier facts exist; nothing published" - exit 3 - fi +WORK=$(mktemp -d "$LOGDIR/build.XXXXXXXX") +trap 'rm -rf "$WORK"' 0 +trap 'exit 1' 1 2 15 +BIN="$WORK/site-omega" +if ! sh scripts/build-native.sh "$BIN" >>"$LOG" 2>&1; then + say "refuse: pinned native compilation failed for $HEAD; see $LOG" + exit 3 fi +"$BIN" build "$WORK/dist" >>"$LOG" 2>&1 || { say "refuse: native build failed for $HEAD"; exit 4; } +"$BIN" verify "$WORK/dist" >>"$LOG" 2>&1 || { say "refuse: verify failed for $HEAD"; exit 4; } -rm -rf "$LOGDIR/dist" -"$BIN" build "$LOGDIR/dist" "$LOGDIR/facts.json" >>"$LOG" 2>&1 -"$BIN" verify "$LOGDIR/dist" >>"$LOG" 2>&1 || { say "refuse: verify failed for $HEAD"; exit 4; } - -NEW=$(cat "$LOGDIR/dist/index.html" "$LOGDIR/dist/facts.json" | cksum | cut -d' ' -f1) -OLD=$(cat "$LOGDIR/published.cksum" 2>/dev/null || echo none) -if [ "$NEW" = "$OLD" ]; then +# Include every emitted file and path, so CSS, SVG and download changes publish too. +# Keep each pipeline stage separate: a failed hash command must never become a receipt. +(cd "$WORK/dist" && find . -type f -print0) > "$WORK/files" +LC_ALL=C sort -z "$WORK/files" > "$WORK/files.sorted" +(cd "$WORK/dist" && xargs -0 sha256sum < "$WORK/files.sorted") > "$WORK/manifest.sha256" +NEW=$(sha256sum "$WORK/manifest.sha256") +NEW=${NEW%% *} +OLD=$(cat "$LOGDIR/published.sha256" 2>/dev/null || echo none) +if [ "$NEW" = "$OLD" ] && [ ! -e "$LOGDIR/publish.pending" ]; then say "unchanged ($HEAD); nothing to publish" exit 0 fi -rsync -a --delete --exclude '.well-known' "$LOGDIR/dist/" "$HUB:$WEBDIR/" >>"$LOG" 2>&1 -echo "$NEW" >"$LOGDIR/published.cksum" +# Keep this marker across failure or interruption. A partial transfer may have +# changed the server even when the next source reverts to the previous digest. +printf '%s\n' "$NEW" > "$LOGDIR/publish.pending" +rsync -a --delete --exclude '.well-known' "$WORK/dist/" "$HUB:$WEBDIR/" >>"$LOG" 2>&1 +printf '%s\n' "$NEW" > "$WORK/published.sha256" +mv "$WORK/published.sha256" "$LOGDIR/published.sha256" +rm "$LOGDIR/publish.pending" say "published site $HEAD to $HUB:$WEBDIR" diff --git a/scripts/tests/check-sync.sh b/scripts/tests/check-sync.sh new file mode 100755 index 0000000..684c27a --- /dev/null +++ b/scripts/tests/check-sync.sh @@ -0,0 +1,229 @@ +#!/bin/sh +# Independent shell oracle: git, quietlock, compiler, digest and rsync are local +# stubs. It never contacts GitHub or a server or makes external writes. +set -eu +ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) +TEST_ROOT=$(mktemp -d) +trap 'rm -rf "$TEST_ROOT"' 0 +trap 'exit 1' 1 2 15 +export TEST_ROOT +REAL_SHA256=$(command -v sha256sum) +export REAL_SHA256 +mkdir -p "$TEST_ROOT/bin" "$TEST_ROOT/repo/.git" "$TEST_ROOT/repo/scripts" "$TEST_ROOT/repo/native" +cp "$ROOT/scripts/build-native.sh" "$TEST_ROOT/repo/scripts/build-native.sh" +cp "$ROOT/native/site.om" "$TEST_ROOT/repo/native/site.om" +cat > "$TEST_ROOT/bin/git" <<'STUB' +#!/bin/sh +set -eu +printf 'git %s\n' "$*" >> "$TEST_ROOT/trace" +case "$1" in + clone) + test "$2" = -q + test "$3" = https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git + mkdir -p "$4/.git" + cp -R "$TEST_ROOT/repo/scripts" "$TEST_ROOT/repo/native" "$4/" + ;; + status) [ "${STUB_DIRTY:-0}" = 0 ] || echo ' M content/index.html' ;; + rev-parse) echo 0123456789ab ;; + fetch|checkout|merge) ;; + *) echo 'unexpected git command in deployment test' >&2; exit 90 ;; +esac +STUB +cat > "$TEST_ROOT/bin/quietlock" <<'STUB' +#!/bin/sh +exit "${STUB_QUIET:-0}" +STUB +cat > "$TEST_ROOT/bin/uname" <<'STUB' +#!/bin/sh +printf '%s\n' "${STUB_MACHINE:-x86_64}" +STUB +cat > "$TEST_ROOT/bin/sha256sum" <<'STUB' +#!/bin/sh +set -eu +case "$1" in + "$TEST_ROOT/compiler"|"$TEST_ROOT/omega/seed/out/omc") + if [ "${STUB_BAD_COMPILER:-0}" = 1 ]; then + printf '%s %s\n' invalid "$1" + else + printf '%s %s\n' 79b557687528bbeb68dc94ba2badb031206c3dcc575fc024efd728e6638821bd "$1" + fi ;; + *) [ "${STUB_HASH_FAIL:-0}" = 0 ] || exit 91 + exec "$REAL_SHA256" "$@" ;; +esac +STUB +cat > "$TEST_ROOT/compiler" <<'STUB' +#!/bin/sh +set -eu +echo compile >> "$TEST_ROOT/trace" +cat > "$TEST_ROOT/compiled-input" +[ "${STUB_COMPILE_FAIL:-0}" = 0 ] || exit 92 +cat "$TEST_ROOT/builder-template" +STUB +cat > "$TEST_ROOT/builder-template" <<'STUB' +#!/bin/sh +set -eu +printf 'builder %s\n' "$1" >> "$TEST_ROOT/trace" +case "$1" in + build) + [ "${STUB_BUILD_FAIL:-0}" = 0 ] || exit 93 + test ! -e "$2" + mkdir -p "$2/public" + printf '%s\n' 'Fixture' > "$2/index.html" + printf '%s\n' '{"source":"committed"}' > "$2/facts.json" + printf '%s\n' "${STUB_ASSET:-base}" > "$2/public/style.css" + ;; + verify) [ "${STUB_VERIFY_FAIL:-0}" = 0 ] || exit 94 ;; + *) exit 95 ;; +esac +STUB +cat > "$TEST_ROOT/bin/rsync" <<'STUB' +#!/bin/sh +set -eu +printf 'rsync %s\n' "$*" >> "$TEST_ROOT/trace" +[ "${STUB_RSYNC_FAIL:-0}" = 0 ] || exit 96 +STUB +chmod +x "$TEST_ROOT/bin/"* "$TEST_ROOT/compiler" +PATH="$TEST_ROOT/bin:$PATH" +OMC="$TEST_ROOT/compiler" +REPO="$TEST_ROOT/repo" +HUB=fixture-hub +WEBDIR=/fixture-web +export PATH OMC REPO HUB WEBDIR +unset OMC_RUNNER + +prepare() { + LOGDIR="$TEST_ROOT/log-$1" + export LOGDIR + STUB_DIRTY=0 STUB_QUIET=0 STUB_BAD_COMPILER=0 STUB_HASH_FAIL=0 + STUB_COMPILE_FAIL=0 STUB_BUILD_FAIL=0 STUB_VERIFY_FAIL=0 STUB_RSYNC_FAIL=0 + STUB_MACHINE=x86_64 STUB_ASSET=base + export STUB_DIRTY STUB_QUIET STUB_BAD_COMPILER STUB_HASH_FAIL STUB_COMPILE_FAIL + export STUB_BUILD_FAIL STUB_VERIFY_FAIL STUB_RSYNC_FAIL STUB_MACHINE STUB_ASSET + : > "$TEST_ROOT/trace" +} +run_ok() { sh "$ROOT/scripts/sync-to-hub.sh" > "$TEST_ROOT/stdout" 2> "$TEST_ROOT/stderr"; } +run_refused() { + if run_ok; then echo 'FAIL: expected deployment refusal' >&2; exit 1; fi + if grep -q '^rsync ' "$TEST_ROOT/trace"; then echo 'FAIL: refusal reached rsync' >&2; exit 1; fi + test ! -e "$LOGDIR/published.sha256" +} +no_publish() { if grep -q '^rsync ' "$TEST_ROOT/trace"; then exit 1; fi; } +passed() { printf 'PASS control: %s\n' "$1"; } + +prepare quiet +STUB_QUIET=1 +run_ok +test ! -s "$TEST_ROOT/trace" +passed quietlock-skip +prepare canonical-clone +REPO="$TEST_ROOT/new-clone" +run_ok +grep -Fq 'git clone -q https://www.aienos.com/rad/z399yKvnXcBQNkKoq86iBDgTvQ5QV.git ' "$TEST_ROOT/trace" +REPO="$TEST_ROOT/repo" +passed canonical-radicle-fallback-clone +prepare dirty +STUB_DIRTY=1 +run_refused +if grep -q '^git fetch' "$TEST_ROOT/trace"; then exit 1; fi +passed dirty-checkout-refused +prepare bad-compiler +STUB_BAD_COMPILER=1 +run_refused +if grep -q '^compile$' "$TEST_ROOT/trace"; then exit 1; fi +passed incorrect-compiler-hash-refused +prepare missing-compiler +OMC="$TEST_ROOT/absent" +run_refused +OMC="$TEST_ROOT/compiler" +passed missing-compiler-refused +prepare compile-failed +STUB_COMPILE_FAIL=1 +run_refused +passed compilation-failure-refused +prepare build-failed +STUB_BUILD_FAIL=1 +run_refused +passed build-failure-refused +prepare verify-failed +STUB_VERIFY_FAIL=1 +run_refused +passed verify-failure-refused +prepare hash-failed +STUB_HASH_FAIL=1 +run_refused +passed digest-failure-refused + +prepare publish +run_ok +grep -q '^git fetch -q origin main$' "$TEST_ROOT/trace" +grep -q '^git checkout -q main$' "$TEST_ROOT/trace" +grep -q '^git merge -q --ff-only origin/main$' "$TEST_ROOT/trace" +grep -q '^rsync -a --delete --exclude .well-known .* fixture-hub:/fixture-web/$' "$TEST_ROOT/trace" +passed clean-main-and-transfer-options +cp "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest" +: > "$TEST_ROOT/trace" +run_ok +no_publish +cmp "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest" +grep -q unchanged "$TEST_ROOT/stdout" +passed unchanged-release-skipped + +# A stylesheet-only change must publish, even if HTML and facts are unchanged. +STUB_ASSET=changed +: > "$TEST_ROOT/trace" +run_ok +grep -q '^rsync ' "$TEST_ROOT/trace" +if cmp -s "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest"; then exit 1; fi +passed stylesheet-only-change-published +cp "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest" +STUB_ASSET=changed-again STUB_RSYNC_FAIL=1 +: > "$TEST_ROOT/trace" +if run_ok; then echo 'FAIL: failed transfer was accepted' >&2; exit 1; fi +cmp "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest" +test -f "$LOGDIR/publish.pending" +passed failed-transfer-keeps-receipt-and-pending-marker +# Reverting to the last successfully published source must still repair a +# possibly partial remote transfer; matching the old digest alone is unsafe. +STUB_ASSET=changed STUB_RSYNC_FAIL=0 +: > "$TEST_ROOT/trace" +run_ok +grep -q '^rsync ' "$TEST_ROOT/trace" +test ! -e "$LOGDIR/publish.pending" +cmp "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest" +passed reverted-source-repairs-pending-transfer +STUB_ASSET=changed-again +STUB_RSYNC_FAIL=0 +run_ok +if cmp -s "$LOGDIR/published.sha256" "$TEST_ROOT/old-digest"; then exit 1; fi +passed later-release-retried + +prepare target-selection +sh "$REPO/scripts/build-native.sh" "$TEST_ROOT/site-x86" x86_64 +cmp "$TEST_ROOT/compiled-input" "$REPO/native/site.om" +passed x86-target-retained +sh "$REPO/scripts/build-native.sh" "$TEST_ROOT/site-arm" aarch64 +sed '1d' "$REPO/native/site.om" > "$TEST_ROOT/expected-arm.om" +cmp "$TEST_ROOT/compiled-input" "$TEST_ROOT/expected-arm.om" +passed aarch64-first-line-only-removed +printf 'unexpected target\n' > "$REPO/native/site.om" +run_refused +cp "$ROOT/native/site.om" "$REPO/native/site.om" +passed unexpected-target-header-refused + +# Default Spark lookup is local and still uses the checksum gate. +prepare spark-default +STUB_MACHINE=aarch64 +OMEGA_SRC="$TEST_ROOT/omega" +export OMEGA_SRC +mkdir -p "$OMEGA_SRC/seed/out" +cp "$TEST_ROOT/compiler" "$OMEGA_SRC/seed/out/omc" +unset OMC +run_ok +grep -q '^rsync ' "$TEST_ROOT/trace" +cmp "$TEST_ROOT/compiled-input" "$TEST_ROOT/expected-arm.om" +passed spark-default-compiler-lookup +prepare explicit-x86-required +run_refused +passed x86-explicit-compiler-required + +printf '%s\n' 'PASS deployment orchestration: quietlock, clean main, compiler pin, build/verify refusals, whole-tree digest, transfer receipt, target selection and default compiler lookup; all external operations stubbed'