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:
co-authored by
Claude Opus 5
parent
a8707f29f0
commit
4b109f704c
@@ -414,6 +414,17 @@ cosmosTabPath | CosmOS/Source/cosmos.asm | run | cosmosTab
|
||||
# refusing. Somebody who wants an empty value writes "set name" and gets one - the escape
|
||||
# hatch exists and has to be asked for.
|
||||
cosmosVars | CosmOS/Source/cosmos.asm | run | cosmosVars.in | - | disks/cosmos.img
|
||||
# The Stack is where it was, after eight lines that failed.
|
||||
#
|
||||
# EVERY FAILURE IN THIS SHELL ABANDONS A FRAME: commandFailed is reached with CALL and never
|
||||
# returns, which is the idiom every command uses and is why a failure needs no unwinding.
|
||||
# Nothing gave those frames back, so the Stack Pointer only ever moved one way - FFFD to FE6D
|
||||
# over twenty failures. It took thousands to reach anything, which is why nobody had noticed;
|
||||
# a loop in a script would have got there.
|
||||
#
|
||||
# Break is what makes it visible, because it prints the registers. The two dumps have to
|
||||
# agree, and the failures between them are what would move it.
|
||||
cosmosStack | CosmOS/Source/cosmos.asm | run | cosmosStack.in | - | disks/cosmos.img
|
||||
# The same editing offered to a PROGRAM, through osReadLine. Edit reads its lines that way,
|
||||
# so a word typed with two letters the wrong way round is put right without starting the line
|
||||
# again - which is the whole of what A4 buys.
|
||||
|
||||
Reference in New Issue
Block a user