# Original experimental x86-64 engines

`createOriginalX64Backends()` returns two optional backends written in this
repository: an instruction-to-WebAssembly translator and a JavaScript instruction
interpreter. Neither embeds a third-party compiler or CPU emulator. Register the
returned backends with `box.kernel.binaries.register(backend)`.

The translator emits real Wasm integer operations, using mutable register globals
and an instruction cache. It translates lazily during execution, rather than
producing a distributable standalone Wasm file. The interpreter executes the same
decoded instructions directly. They currently support the same instruction subset;
register only the `emulation` backend to exercise the interpreter directly.

Supported inputs are freestanding, static, little-endian x86-64 ET_EXEC ELF files.
Loadable segments must fit a 16 MiB memory window and use addresses below 4 GiB.
Dynamic linking is rejected. Supported instructions: 32/64-bit immediate and
register MOV, register ADD/SUB/XOR/CMP, selected immediate ADD/SUB/CMP, RIP-relative
LEA, NOP, short JMP/JZ/JNZ, relative JMP, and SYSCALL. Only the zero flag is modeled.
There is no stack/argv ABI, arbitrary memory operand, SSE, libc, file-open syscall,
networking, threads, or Docker support. Unsupported instructions fail explicitly.

Linux calls: read stdin, write stdout/stderr, exit/exit_group, getpid. Unsupported
calls return ENOSYS. Segment read/write permissions are checked for I/O buffers;
self-modifying code is rejected. Each run owns its registers and memory. The
one-million-instruction default budget and periodic event-loop yields bound loops
and permit cancellation between batches. This is not a hardened security boundary
or a claim of native performance. Translation currently has substantial per-
instruction overhead; performance optimization is future work.

Tests use `test/fixtures/native/hello.s`, assembled by Clang for Linux. The checked
in ELF is built with the adjacent `package-elf.py` script. Both engines run the
same binary, including a conditional loop and Linux console output; an infinite
loop fixture verifies the instruction limit. Clang is only used to produce test
inputs; it is not part of either engine at runtime.

The local browser project registers both backends and exposes `native-hello`.
Opening `/?native=emulation` selects the interpreter. Node and Python commands
continue through their existing runtimes. This is an initial working CPU subset,
not arbitrary Linux package compatibility.
