# E04-S06: parse STMTS.N8 in x128, run the emitted body, and check the locals # and the bytes the generated print calls asked for. [CmdletBinding()] param([int]$Port = 6560, [int]$TimeoutSeconds = 180) $ErrorActionPreference = "Stop" $project = Split-Path $PSScriptRoot -Parent Import-Module (Join-Path $PSScriptRoot "lib\Nova128Test.psm1") -Force & (Join-Path $PSScriptRoot "build-statements-test.ps1") $out = Join-Path $project "build\statements-test" $disk = Join-Path $out "statements-test.d81" $failures = @() $lbl = Get-Content -Raw -LiteralPath (Join-Path $out "statements-test.lbl") if ($lbl -notmatch "([0-9A-Fa-f]{6})\s+\.rec_buf\b") { throw "rec_buf not in the label file" } $recBuf = [Convert]::ToInt32($matches[1], 16) $session = Start-Nova128X128 -Autostart $disk -Drive8Image $disk -Port $Port ` -Screenshot (Join-Path $out "statements-vicii.png") try { $mb = Wait-Nova128Mailbox $session -TimeoutSeconds $TimeoutSeconds $log = Read-Nova128Memory $session $recBuf 16 } finally { Stop-Nova128X128 $session } Write-Host ("mailbox: " + (($mb | ForEach-Object { $_.ToString('X2') }) -join ' ')) Write-Host ("recorded: " + (($log | ForEach-Object { $_.ToString('X2') }) -join ' ')) if ($mb[2] -ne 0x02) { $failures += ("producer $($mb[2]) expected 2 (compiler)") } if ($mb[3] -ne 0xA5) { $failures += ("fixture status {0:X2} failed at stage {1}" -f $mb[3], $mb[4]) } if ($mb[8] -ne 0) { $failures += "diagnostics present: $($mb[8])" } if ($mb[9] -ne 0) { $failures += "emitter error $($mb[9])" } if ($mb[10] -ne 2) { $failures += ("a = {0}, expected 2 (loop variable past end)" -f $mb[10]) } if ($mb[11] -ne 3) { $failures += ("b = {0}, expected 3" -f $mb[11]) } if ($mb[12] -lt 60) { $failures += "emitted only $($mb[12]) bytes" } if ($mb[13] -ne 0) { $failures += "codegen error $($mb[13])" } if ($mb[14] -ne 0) { $failures += ("recorded {0} bytes, expected none" -f $mb[14]) } if ($failures) { throw ("statements verification failed:`n " + ($failures -join "`n ")) } Write-Host ("emitted {0} bytes; a=2, b=3" -f $mb[12]) Write-Host "verified parser pass-2 statement emission executes in x128"