#pragma once #include #include // Machine geometry the tools use unless something says otherwise: how wide a // cell is in bits, and how many cells the tape holds. The instruction set does // not fix either (ROR just rotates inside a cell and the tape is a ring), so // these are the only places the old 8 bit / 256 cell assumptions live. inline constexpr size_t kDefaultCellSize = R8FORGE_CELL_SIZE; // build option: -DR8FORGE_CELL_SIZE=<1..32> inline constexpr size_t kDefaultMemoryCells = R8FORGE_MEMORY_CELLS; // build option: -DR8FORGE_MEMORY_CELLS=<1..65536> // The ring size is a *hardware* decision as much as a software one: the physical // machine only has to hold the highest cell a program ever touches. Measured on // every program we ship (a script walks the tape's > and < and records the peak): // calc 51, hello 49, signed_demo 34, term 27 -- so a 64 cell ring runs all of // them, and 259 was only ever the historical default. The one exception is // asm/test.r8asm, the "every macro once" self test, which lays every macro's // cell block out side by side and peaks at 155; it needs the default. // The VMs store a cell in uint32_t, so 32 bits is the ceiling -- and `1u << 32` // would be undefined, hence the special case instead of a plain shift. CMake // refuses anything outside 1..32 at configure time, and the exhaustive byte // level test prints "skipped" instead of running above 16 bits (its sweeps are // 2^W rows). Going past 32 would mean widening the cell in all five VMs *and* // in ROT-8-viz's rot8_data -- SPEC ยง13 has the checklist. inline constexpr uint32_t kDefaultCellMask = kDefaultCellSize >= 32 ? 0xFFFFFFFFu : (1u << kDefaultCellSize) - 1u;