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 -1
View File
@@ -5,7 +5,7 @@ break at 4016
A 11 B 22 Q 00 status 00
DP0 2030 DP1 2000 DP2 2037 DP3 4000 SP FFFF
press a key
break at 4033
break at 4034
A 44 B 55 Q 00 status 00
DP0 2000 DP1 2037 DP2 2030 DP3 4000 SP FFF5
press a key
+1 -1
View File
@@ -2,7 +2,7 @@ CosmOS
> claiming more than was reserved was refused
and the size it really came to was taken
finished
> Claim.sbx 572
> Claim.sbx 580
claim.dat 266
2 files
> halted
+1 -1
View File
@@ -3,7 +3,7 @@ CosmOS
A <dir>
B <dir>
0 files, 3 directories
> /A> Say.sbx 52
> /A> Say.sbx 53
notes.txt 25
2 files
/A> these are the notes in A
+2 -2
View File
@@ -5,8 +5,8 @@ finished
finished
> it says: once more
finished
> Say.sbx 155
dir.sbx 155
> Say.sbx 156
dir.sbx 156
notes.txt 21
notes.sbx 21
4 files
+1 -1
View File
@@ -14,7 +14,7 @@ CosmOS
4014 47 00 20 5D SETD.0 205D
* 4000 47 00 20 00 72 10 47 00 20 44 72 10 47 00 20 7A G. .r.G. Dr.G. z
4010 27 1F 72 11 47 00 20 5D 72 10 47 00 20 7A 72 10 '.r.G. ]r.G. zr.
4020 47 00 20 65 72 10 72 12 00 00 00 00 00 00 00 00 G. er.r.........
4020 47 00 20 65 72 10 20 72 12 00 00 00 00 00 00 00 G. er. r........
4030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* bank 01
* 2000 61 20 70 72 6F 67 72 61 6D 2C 20 6C 6F 61 64 65 a program, loade
+7 -7
View File
@@ -1,12 +1,12 @@
CosmOS
> nothing is loaded
> greet.sbx 210
hello.sbx 52
Life.sbx 1409
Snake.sbx 2167
Keys.sbx 663
Say.sbx 155
Break.sbx 148
> greet.sbx 211
hello.sbx 53
Life.sbx 1410
Snake.sbx 2168
Keys.sbx 664
Say.sbx 156
Break.sbx 149
notes.txt 21
8 files
> load what?
+7 -7
View File
@@ -1,11 +1,11 @@
CosmOS
> greet.sbx 210
hello.sbx 52
Life.sbx 1409
Snake.sbx 2167
Keys.sbx 663
Say.sbx 155
Break.sbx 148
> greet.sbx 211
hello.sbx 53
Life.sbx 1410
Snake.sbx 2168
Keys.sbx 664
Say.sbx 156
Break.sbx 149
notes.txt 21
8 files
> loaded, starting at 4000
+16
View File
@@ -0,0 +1,16 @@
CosmOS
> it says: it worked
finished
> the last program left 0, which is: it did what it was asked
finished
> type: give me a file name
finished
> the last program left 2, which is: it was asked wrongly
finished
> type: cannot find the file, error 2
finished
> the last program left 1, which is: it did not
finished
> halted
Execution halted.
[exit 0]
+2 -2
View File
@@ -1,13 +1,13 @@
CosmOS
> Folder <dir>
Edit.sbx 1983
Edit.sbx 1986
1 file, 1 directory
> loaded, starting at 4000
> note.txt, 0 lines
> : : : > written, 67 bytes
> finished
> Folder <dir>
Edit.sbx 1983
Edit.sbx 1986
note.txt 67
2 files, 1 directory
> halted
+7
View File
@@ -0,0 +1,7 @@
Say it worked
Status
Type
Status
Type /nothing/here.txt
Status
exit
+1
View File
@@ -3,6 +3,7 @@ Programs/Boot/stage1.asm redundant-setd 2
Programs/Boot/stage2.asm redundant-setd 1
Programs/CosmOS/Apps/Copy.asm redundant-setd 2
Programs/CosmOS/Apps/Edit.asm redundant-setd 3
Programs/CosmOS/Apps/Status.asm redundant-setd 1
Programs/CosmOS/Apps/Wander.asm redundant-setd 1
Programs/CosmOS/Assembler/Asm.asm redundant-assignment 2
Programs/CosmOS/Assembler/Asm.asm redundant-setd 8
+14
View File
@@ -491,3 +491,17 @@ cp "$DISKS/selfboot.img" "$DISKS/nofallback.img"
printf 'system /System/Boot/cosmos.bin\n' > "$WORK/lonely.cfg"
"$TOOL" put "$DISKS/nofallback.img" "$WORK/lonely.cfg" /System/Boot/boot.cfg >/dev/null
"$TOOL" bootstate "$DISKS/nofallback.img" 1 >/dev/null
# ---- What a program made of it ----
#
# A status is only worth having if it survives the program that set it, so this runs three
# in a row and asks after each: one that works, one that is asked wrongly, and one that
# fails outright. Status is a PROGRAM and reaches the number through a service, which is
# what will let something other than a person read it.
"$TOOL" format "$DISKS/status.img" 512 4 >/dev/null
"$TOOL" mkdir "$DISKS/status.img" /Apps >/dev/null
for app in Status Say Type Settle; do
"$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/$app.asm" -o "$WORK/$app.sbx" >/dev/null
"$TOOL" put "$DISKS/status.img" "$WORK/$app.sbx" /Apps/$app.sbx >/dev/null
done
+10
View File
@@ -445,6 +445,16 @@ cosmosSettle | CosmOS/Source/cosmos.asm | run | settle.in
cosmosSettled | CosmOS/Source/cosmos.asm | run | settle.in | 90000000 | disks/settled.img
settleApp | CosmOS/Apps/Settle.asm | assemble | - | -
# ---- What a program made of it ----
#
# Three programs in a row, each asked after. A status that did not survive the program that
# set it would be no use to the thing this exists for - whatever comes to run programs in
# sequence and has to decide whether to run the next one.
#
# 0 it did what it was asked, 1 it did not, 2 it was asked wrongly.
cosmosStatus | CosmOS/Source/cosmos.asm | run | status.in | 90000000 | disks/status.img
statusApp | CosmOS/Apps/Status.asm | assemble | - | -
# A failed start with NOTHING to fall back to. The mark must not become a reason to refuse
# to start at all - a failure that was passing recovers here, and one that is not leaves
# the machine exactly where it would have been without any of this.