The shell starts each line with the Stack where it left it

Every failure in this shell abandons a frame. commandFailed is reached with CALL
and never returns: it marks the line and branches to the prompt, which is the
idiom every command uses and is why a failure needs no unwinding anywhere. What
it costs is the frame of that call and of everything between the prompt and it -
twenty bytes for a name that was never set, more from somewhere deeper - and
nothing ever gave them back.

MEASURED BEFORE IT WAS FIXED. Twenty failed lines moved the Stack Pointer from
FFFD to FE6D, and it only ever went one way.

Nothing had noticed because it takes thousands of failures to reach anything and
nobody types thousands of anything. A loop in a script would, which is why this
is worth doing before there are loops rather than after.

So the loop starts each turn from a known place. SystemStack is NOT that place:
it is taken when a program starts, so that the shell's Stack can be given back
when the program stops - which means it holds wherever the shell had got to at
that moment, the value that needs correcting rather than the one to correct
from. ShellStack is taken once, at boot, when nothing is happening.

Second use of MVDS in the system, and it earns it for the same reason as the
first: a Stack that is right by construction beats one that is right because
everybody remembered.

Break prints the registers, so the test is two dumps with eight failures between
them and a requirement that they agree.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-01 19:29:20 -04:00
co-authored by Claude Opus 5
parent a8707f29f0
commit 4b109f704c
5 changed files with 102 additions and 1 deletions
+32
View File
@@ -146,6 +146,16 @@ bootStartup:
CALL newLine
bootReady:
; ---- Where the Stack is when nothing is happening ----
;
; Taken once, here, and put back at the top of every turn of the loop below. SystemStack is
; not this: that is taken when a PROGRAM starts, to be given back when it stops, so it
; holds wherever the shell had got to at that moment - which is the value that needs
; correcting rather than the one to correct from.
MVSD.0
SETD.1 ShellStack
STD.0.1
; ---- The loop ----
;
; The shell has two modes and one prompt that says which. Ordinary mode runs programs;
@@ -158,6 +168,25 @@ bootReady:
; shell. Only saying so leaves the monitor, or a program breaking the machine badly enough
; to need starting again.
prompt:
; ---- The Stack, back where it was when nothing was happening ----
;
; EVERY FAILURE IN THIS SHELL ABANDONS A FRAME. commandFailed is reached with CALL and
; never returns: it marks the line and branches here, which is the idiom every command
; uses and is why a failure needs no unwinding. What it costs is the frame of that call and
; of everything between here and it - twenty bytes for a name that was never set, more from
; somewhere deeper - and nothing ever gave them back. Twenty failed lines moved the Stack
; Pointer from FFFD to FE6D, and it only ever went one way.
;
; Nothing had noticed because it takes thousands of failures to reach anything, and nobody
; types thousands of anything. A loop in a script would.
;
; So the loop starts each turn from a known place. This is the second use of MVDS in the
; system and it earns it for the same reason as the first: a Stack that is right by
; construction beats one that is right by everybody remembering.
SETD.1 ShellStack
LDD.0.1
MVDS.0
; ---- A script stops at the first line that did not work ----
;
; Checked here, before the next line is read, because this is the one place every command
@@ -7226,6 +7255,9 @@ DumpBytes:
; region a program owns, so that a program has to go looking to break it.
SystemStack:
0x00 0x00
; And where it is when the shell is between lines, which is not the same thing. See prompt.
ShellStack:
0x00 0x00
DirSeen:
0x00
DirSize: