The desk calculator hardcoded a four cell window, which is only right at 11 bits: clb_digits and clb_undigits use D = _CELL_SIZE * 30103 / 100000 + 1 digits (3 at 8 bits, 5 at 16, 10 at 32). D is now a .var, the window is REG..REG+D-1, every cell after it moves by D-4 (zero at 11 bits, so the numeric map is unchanged), and the startup fill, the shift chain, the flush reset and the D outputs are all %for generated. Two more width hardcodes turned up outside the window and are fixed: the C restore after the four-ror bit 4 test was `%rep 7` (only 4+7=11 at the default), it is `%rep _CELL_SIZE - 4` now -- which emits the same seven rors at 11 bits, so the tape is byte for byte identical (62585 characters, every step count unchanged). The literal descending shift was tried first and assembles fine but is wrong: writing REG+D-2 before reading it clobbers the digit that is about to move, giving "> 0350" for 12 34 + . instead of "> 0046". The chain goes ascending, which is the exact generalisation of the old four copy chain. tests/widths.ps1 builds the toolchain at 1 2 7 8 11 16 17 31 32 bits, runs the widthfree label at each and, where the ASCII constants fit (>= 6), runs one calculator session. 1 and 2 cannot: '0' is 48 and a two bit cell holds 3. Verified at 11 bits: tape unchanged, all five sessions identical, derive agrees, r8forge_examples_test 16/16.
42 lines
1.9 KiB
PowerShell
42 lines
1.9 KiB
PowerShell
# Build the toolchain at a set of cell widths and run what is meaningful there.
|
|
#
|
|
# powershell -File tests\widths.ps1 # the full list below
|
|
# powershell -File tests\widths.ps1 -Widths 8,11,32 # just these
|
|
#
|
|
# What is checked per width:
|
|
# * the `widthfree` ctest label: bit level slices, the synthesizer, the looping
|
|
# demo and the macro comment format (all true at any width);
|
|
# * examples/calc.r8asm assembles, and at widths where the ASCII constants fit
|
|
# (>= 6) it also runs one session through r8forge_derive.
|
|
# The 11 bit baseline (byte_ops, examples, the flagship tape) only means anything
|
|
# at the default geometry, so it is not part of this script.
|
|
param(
|
|
[int[]]$Widths = @(1, 2, 7, 8, 11, 16, 17, 31, 32),
|
|
[string]$CMake = "C:/Program Files/Microsoft Visual Studio/18/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe"
|
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
$ctest = Join-Path (Split-Path $CMake) "ctest.exe"
|
|
$failed = @()
|
|
|
|
foreach ($w in $Widths) {
|
|
$dir = Join-Path $root "build$w"
|
|
Write-Host "=== cell $w"
|
|
& $CMake -S $root -B $dir -DCMAKE_BUILD_TYPE=Release -DR8FORGE_CELL_SIZE=$w | Out-Null
|
|
& $CMake --build $dir --config Release | Out-Null
|
|
|
|
& $ctest --test-dir $dir -C Release -L widthfree --output-on-failure | Out-Null
|
|
if ($LASTEXITCODE -ne 0) { Write-Host " widthfree tests FAILED"; $failed += $w }
|
|
else { Write-Host " widthfree tests ok" }
|
|
|
|
$derive = Join-Path $dir "Release\r8forge_derive.exe"
|
|
$out = & $derive "examples/calc.r8asm" 0 -i "12 34 + ." 2>&1 | Out-String
|
|
if ($LASTEXITCODE -eq 0) { Write-Host (" calc: " + ($out.Trim() -replace '\s+', ' ')) }
|
|
else { Write-Host " calc: does not run at this width (constant or digit does not fit)" }
|
|
|
|
Remove-Item -Recurse -Force $dir
|
|
}
|
|
|
|
if ($failed.Count -gt 0) { Write-Host ("FAILED at widths: " + ($failed -join ", ")); exit 1 }
|
|
Write-Host "all requested widths ok"
|