# 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 10) { $failures += ("a = {0}, expected 10" -f $mb[10]) } if ($mb[11] -ne 7) { $failures += ("b = {0}, expected 7" -f $mb[11]) } if ($mb[12] -lt 60) { $failures += "emitted only $($mb[12]) bytes" } if ($mb[13] -ne 0) { $failures += "codegen error $($mb[13])" } # print "sum" records SUM + CR; print a records $FF, $0A, CR. $expect = @(0x53, 0x55, 0x4D, 0x0D, 0xFF, 0x0A, 0x0D) if ($mb[14] -ne $expect.Count) { $failures += ("recorded {0} bytes, expected {1}" -f $mb[14], $expect.Count) } else { for ($i = 0; $i -lt $expect.Count; $i++) { if ($log[$i] -ne $expect[$i]) { $failures += ("recorded byte {0} is {1:X2}, expected {2:X2}" -f $i, $log[$i], $expect[$i]) } } } if ($failures) { throw ("statements verification failed:`n " + ($failures -join "`n ")) } Write-Host ("emitted {0} bytes; a=10, b=7; print recorded SUM, 10" -f $mb[12]) Write-Host "verified parser pass-2 statement emission executes in x128"