A program can say how it went

SWI osExit takes a status in A, and the shell keeps it. Fifty eight exits
across twenty three programs now say deliberately whether they worked: 25
did what they were asked, 24 did not, 9 were asked wrongly. Compare is the
exception and says so - one there means the files differ, which is a result
rather than a failure, the way diff has always had it.

IN A RATHER THAN Q, which is not a departure from the rule that a service
answers in Q. This one takes an ARGUMENT, the way osPrintNumber takes A and
B, and it never returns to answer anything. A is free precisely because a
return would have put it back - and Q is the ALU's output, so a small
number costs four instructions there against one in A.

The shell does not print it. A program that failed has already said so in
words and a number beside that is noise, so osLastStatus hands it back and
Status is the program that shows it. That indirection is the point: the
number exists for the thing that cannot read words.

MARKING THE EXITS FOUND A DEFECT ON THE FIRST RUN. Type and More printed
why they had failed and then fell through into the success exit, reporting
that all was well. Nobody had noticed, because while the only reader was a
person, the person could see both the complaint and the claim.

Two smaller things. Snake sets the console to line mode and then exits with
zero, and the linter flagged the second RSTA as redundant - an exit status
and a console mode, equal by accident, which is the class that must never
be collapsed. And the README still taught answering by writing into the
frame, three months of habit that SRET replaced yesterday; that section is
gone and the one describing SRET stands in its place.
This commit is contained in:
Anachronaut
2026-08-27 19:16:21 -04:00
parent b4206673a6
commit 87d819847e
40 changed files with 297 additions and 47 deletions
+1
View File
@@ -58,6 +58,7 @@ start:
SETD.0 DoneText
SWI osPrintString
RSTA
SWI osExit
deeper:
+5
View File
@@ -47,6 +47,7 @@ start:
BNQ refused
SETD.0 Allowed
SWI osPrintString
RSTA
SWI osExit
refused:
@@ -60,19 +61,23 @@ refused:
BNQ noHonest
SETD.0 Honest
SWI osPrintString
RSTA
SWI osExit
noHonest:
SETD.0 NoHonest
SWI osPrintString
INIA 0d1
SWI osExit
noStart:
SETD.0 NoStart
SWI osPrintString
INIA 0d1
SWI osExit
noWrite:
SETD.0 NoWrite
SWI osPrintString
INIA 0d1
SWI osExit
#Data
+7
View File
@@ -202,30 +202,37 @@ byteBorrow:
alike:
SETD.0 SameText
SWI osPrintString
RSTA
SWI osExit
different:
SETD.0 DifferentText
SWI osPrintString
INIA 0d1
SWI osExit
usage:
SETD.0 Usage
SWI osPrintString
INIA 0d2
SWI osExit
firstFailed:
SETD.0 FirstError
SWI osPrintString
INIA 0d2
SWI osExit
secondFailed:
SETD.0 SecondError
SWI osPrintString
INIA 0d2
SWI osExit
firstReadFailed:
SETD.0 FirstReadError
SWI osPrintString
INIA 0d2
SWI osExit
secondReadFailed:
SETD.0 SecondReadError
SWI osPrintString
INIA 0d2
SWI osExit
#Data
+7
View File
@@ -154,6 +154,7 @@ copyDone:
BNQ doneFailed
SETD.0 Copied
SWI osPrintString
RSTA
SWI osExit
; DP0 names the source word and DP1 the destination word.
@@ -202,26 +203,32 @@ takeBorrow:
usage:
SETD.0 Usage
SWI osPrintString
INIA 0d2
SWI osExit
sourceFailed:
SETD.0 SourceError
SWI osPrintString
INIA 0d1
SWI osExit
readFailed:
SETD.0 ReadError
SWI osPrintString
INIA 0d1
SWI osExit
startFailed:
SETD.0 StartError
SWI osPrintString
INIA 0d1
SWI osExit
writeFailed:
SETD.0 WriteError
SWI osPrintString
INIA 0d1
SWI osExit
doneFailed:
SETD.0 DoneError
SWI osPrintString
INIA 0d1
SWI osExit
#Data
+2
View File
@@ -161,12 +161,14 @@ commandArgument:
BRI commandLoop
quit:
RSTA
SWI osExit
noName:
SETD.0 NoNameText
SWI osPrintString
CALL newLine
INIA 0d2
SWI osExit
+1
View File
@@ -67,6 +67,7 @@ start:
BRI start
end:
CALL lineFeed
RSTA
SWI osExit
#Data
+1
View File
@@ -123,6 +123,7 @@ start:
end:
CALL lineFeed
;HALT
RSTA
SWI osExit
#Data
+1
View File
@@ -33,6 +33,7 @@ start:
end:
CALL lineFeed
;HALT
RSTA
SWI osExit ; Return to CosmOS.
#Data
+6
View File
@@ -101,28 +101,34 @@ atEnd:
BRQ stillThere
SETD.0 GoneText
SWI osPrintString
RSTA
SWI osExit
stillThere:
SETD.0 StillText
SWI osPrintString
RSTA
SWI osExit
noSave:
SETD.0 NoSaveText
SWI osPrintString
INIA 0d1
SWI osExit
noRead:
SETD.0 NoReadText
SWI osPrintString
INIA 0d1
SWI osExit
noRename:
SETD.0 NoRenameText
SWI osPrintString
INIA 0d1
SWI osExit
noDelete:
SETD.0 NoDeleteText
SWI osPrintString
INIA 0d1
SWI osExit
#Data
+1
View File
@@ -56,6 +56,7 @@ spin:
SETD.0 DoneText
CALL printString
CALL newLine
RSTA
SWI osExit
; Entered because the console had something to say. Never called.
+1
View File
@@ -105,6 +105,7 @@ lifeEnd:
CALL lineFeed
CALL printString ; DP0 still holds the words: CALL puts DP0 back.
CALL lineFeed
RSTA
SWI osExit
seedGlider:
+8
View File
@@ -109,6 +109,7 @@ fullPage:
noName:
SETD.0 Usage
SWI osPrintString
INIA 0d2
SWI osExit
openFailed:
SETD.0 OpenError
@@ -123,7 +124,14 @@ printError:
SWI osPrintNumber
SETD.0 NewLine
SWI osPrintString
; ITS OWN EXIT, and it did not have one. This fell through into finished and reported
; that everything was fine, having just printed the reason it was not - which nobody
; noticed while the only reader was a person, who could see both.
INIA 0d1
SWI osExit
finished:
RSTA
SWI osExit
#Data
+4
View File
@@ -118,6 +118,7 @@ theTail:
SWI osPrintNumber
SETD.0 AndTail
SWI osPrintString
RSTA
SWI osExit
; The block becomes 256 copies of the block number plus a fixed byte, so that a block
@@ -198,14 +199,17 @@ tenLoop:
startFailed:
SETD.0 NoStart
SWI osPrintString
INIA 0d1
SWI osExit
writeFailed:
SETD.0 NoWrite
SWI osPrintString
INIA 0d1
SWI osExit
doneFailed:
SETD.0 NoDone
SWI osPrintString
INIA 0d1
SWI osExit
#Data
+1
View File
@@ -40,6 +40,7 @@ sayNothing:
sayEnd:
SETD.0 NewLine
SWI osPrintString
RSTA
SWI osExit
#Data
+3
View File
@@ -54,16 +54,19 @@ doSettle:
BNA settleFailed
SETD.0 Settled
SWI osPrintString
RSTA
SWI osExit
settleFailed:
SETD.0 NoDisk
SWI osPrintString
INIA 0d1
SWI osExit
alreadySettled:
SETD.0 Already
SWI osPrintString
RSTA
SWI osExit
#Data
+1
View File
@@ -74,6 +74,7 @@ advancePage:
finished:
CALL lineFeed
RSTA
SWI osExit ; Return to CosmOS.
; DP0 points at a PrimeStates entry. CALL restores it on return.
+1
View File
@@ -38,6 +38,7 @@ start:
BRI markMultiples ; Otherwise, loop again to mark the next multiple as nonprime.
end:
CALL lineFeed ; Print a linefeed to make it look nice.
RSTA
SWI osExit ; The program is done, we found all the primes!
+1
View File
@@ -105,6 +105,7 @@ gameOverSay:
CALL newLine
RSTA
OUTA 0x02 ; Line mode, the way it was found.
RSTA ; splitlint[redundant-assignment]: an exit status, not a console mode
SWI osExit
; ---- Reaching a square ----
+87
View File
@@ -0,0 +1,87 @@
; Status.asm
; Says what the last program made of what it was asked to do.
;
; The shell keeps the number and does not print it, because a program that failed has
; already said so in words and a number beside that would be noise. But a number nobody can
; see is a number nobody can trust, so this is how a person looks.
;
; 0 it did what it was asked
; 1 it did not
; 2 it was asked wrongly
;
; A program may give its own meanings if it says so, and Compare does: one there means the
; files differ, which is a result rather than a failure.
;
; Written by Anachronaut
#Include services.asm
#Program
#Base 0x4000
start:
SWI osLastStatus
MVQA
SETD.0 Was
STA.0
SETD.0 Prefix
SWI osPrintString
; A and B together, most significant first - so the status is the LOW half. Put in A the
; first time this was written, which printed a status of two as five hundred and twelve.
RSTA
SETD.0 Was
LDB.0
SWI osPrintNumber
; And in words, for the three the system itself uses.
SETD.0 Was
LDA.0
BRA sayWorked
INIB 0d1
XOR
BRQ sayFailed
SETD.0 Was
LDA.0
INIB 0d2
XOR
BRQ sayAsked
BRI done
sayWorked:
SETD.0 WorkedText
SWI osPrintString
BRI done
sayFailed:
SETD.0 FailedText
SWI osPrintString
BRI done
sayAsked:
SETD.0 AskedText
SWI osPrintString
done:
SETD.0 NewLine
SWI osPrintString
RSTA
SWI osExit
#Data
#Base 0x2000
Prefix:
"the last program left "
WorkedText:
", which is: it did what it was asked"
FailedText:
", which is: it did not"
AskedText:
", which is: it was asked wrongly"
NewLine:
"
"
Was:
0x00
+4
View File
@@ -216,6 +216,7 @@ missing:
SWI osPrintString
CALL printWhy
INIA 0d1
SWI osExit
noBig:
@@ -223,14 +224,17 @@ noBig:
SETD.0 NoBigText
SWI osPrintString
CALL printWhy
INIA 0d1
SWI osExit
noSmall:
SETD.0 NoSmallText
SWI osPrintString
INIA 0d1
SWI osExit
noRename:
SETD.0 NoRenameText
SWI osPrintString
INIA 0d1
SWI osExit
; ---- Routines ----
+8
View File
@@ -44,6 +44,7 @@ printLoop:
noName:
SETD.0 Usage
SWI osPrintString
INIA 0d2
SWI osExit
openFailed:
SETD.0 OpenError
@@ -58,7 +59,14 @@ printError:
SWI osPrintNumber
SETD.0 NewLine
SWI osPrintString
; ITS OWN EXIT, and it did not have one. This fell through into finished and reported
; that everything was fine, having just printed the reason it was not - which nobody
; noticed while the only reader was a person, who could see both.
INIA 0d1
SWI osExit
finished:
RSTA
SWI osExit
#Data
+4
View File
@@ -65,19 +65,23 @@ wanderByte:
BRI wanderBlock
wanderDone:
RSTA
SWI osExit
noWhere:
SETD.0 NoWhereText
SWI osPrintString
INIA 0d1
SWI osExit
noSuchPlace:
SETD.0 NoPlaceText
SWI osPrintString
INIA 0d1
SWI osExit
noFile:
SETD.0 NoFileText
SWI osPrintString
INIA 0d1
SWI osExit
#Data
+1
View File
@@ -39,6 +39,7 @@ greet:
; Give the machine back. The system takes its Stack back at this point, so everything
; this program pushed goes with it.
RSTA
SWI osExit
#Data
+1
View File
@@ -21,6 +21,7 @@ End:
OUTA 0x00 ; Output it to the text console.
;HALT ; Terminate the program.
; Instead, let's call osExit to return the system nicely. Fourth change.
RSTA
SWI osExit
#Data