From a69260522bd2d4374a683fa6047fdcc02f93282b Mon Sep 17 00:00:00 2001 From: dsh Date: Sun, 15 Nov 2026 17:32:55 +0800 Subject: [PATCH] geometry: kDefaultCellSize now really reads R8FORGE_CELL_SIZE The build option was plumbed all the way to the compiler (the generated vcxproj carries R8FORGE_CELL_SIZE=17) but geometry.hh still said = 11, so every width built an 11 bit toolchain -- which is why the first matrix run printed identical tapes for all nine widths. My earlier '16 and 32 verified' claims were therefore measurements of 11 bit binaries: synth_test and full_add are bit level blocks whose tape does not depend on the width, so they never noticed. Now at -DR8FORGE_CELL_SIZE=17: asm/test.r8asm 108789 characters (64513 at 11), examples/calc.r8asm 112795 (62585), and one session prints '> 000046' -- D is 6 at 17 bits, which is exactly floor(17*log10 2)+1. tests/widths.ps1 now prints the flagship and calculator tape lengths, because that is the evidence that a width took effect; an unchanged 64513 means it did not. --- include/r8forge/geometry.hh | 2 +- tests/widths.ps1 | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/r8forge/geometry.hh b/include/r8forge/geometry.hh index dd0f609..944cc50 100644 --- a/include/r8forge/geometry.hh +++ b/include/r8forge/geometry.hh @@ -7,7 +7,7 @@ // 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 = 11; +inline constexpr size_t kDefaultCellSize = R8FORGE_CELL_SIZE; // build option: -DR8FORGE_CELL_SIZE=<1..32> inline constexpr size_t kDefaultMemoryCells = 259; // 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. diff --git a/tests/widths.ps1 b/tests/widths.ps1 index cce7519..4dd68ae 100644 --- a/tests/widths.ps1 +++ b/tests/widths.ps1 @@ -1,4 +1,4 @@ -# Build the toolchain at a set of cell widths and run what is meaningful there. +# Build the toolchain at a set of cell widths and run what is meaningful there. # # powershell -File tests\widths.ps1 # 1,2,7,8,11,16,17,31,32 # powershell -File tests\widths.ps1 -Widths 8,11,32 # just these @@ -30,10 +30,19 @@ foreach ($w in $Widths) { if ($LASTEXITCODE -ne 0) { Write-Host " widthfree tests FAILED"; $failed += $w } else { Write-Host " widthfree tests ok" } + # Tape lengths are the honest evidence that the width took effect: the + # flagship is full of %rep _CELL_SIZE, so it must grow with the width. + $r8 = Join-Path $dir "Release\r8forge.exe" + $flagship = (& $r8 "asm/test.r8asm" --quiet 2>$null | Out-String).Length + Write-Host (" flagship tape: $flagship chars (11 bit: 64513)") + $derive = Join-Path $dir "Release\r8forge_derive.exe" + $calc = (& $r8 "examples/calc.r8asm" --quiet 2>$null | Out-String).Length $out = & $derive "examples/calc.r8asm" 0 -i "12 34 + ." 2>$null | Out-String - if ($LASTEXITCODE -eq 0) { Write-Host (" calc: " + ($out.Trim() -replace '\s+', ' ')) } - else { Write-Host " calc: does not run at this width" } + if ($LASTEXITCODE -eq 0) { + Write-Host (" calc: $calc chars" + $(if ($calc -gt 65536) { " (over the viz limit)" } else { "" })) + Write-Host (" calc run: " + ($out.Trim() -replace '\s+', ' ')) + } else { Write-Host " calc: does not run at this width" } Remove-Item -Recurse -Force $dir }