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:
@@ -2242,6 +2242,18 @@ handlePrintNumber:
|
||||
;
|
||||
; Which is exactly why this cannot RETI. Its return address is on the Stack it just walked
|
||||
; away from, so it branches to the prompt instead.
|
||||
; What the last program made of what it was asked to do. Kept rather than shown: a program
|
||||
; that failed has already said so in words, and a number beside that would be noise. It is
|
||||
; here for the thing that cannot read words - whatever comes to run programs in sequence and
|
||||
; has to decide whether to run the next one.
|
||||
handleLastStatus:
|
||||
SETD.2 LastStatus
|
||||
LDA.2
|
||||
RSTB
|
||||
CCF
|
||||
ADD ; A is the answer, so Q becomes it.
|
||||
SRET
|
||||
|
||||
; ---- How the last start went, and settling it ----
|
||||
;
|
||||
; The answer goes in Q by writing into this handler's own frame, which is how every service
|
||||
@@ -2292,6 +2304,17 @@ bootSettleNo:
|
||||
SRET
|
||||
|
||||
handleExit:
|
||||
; ---- What the program made of it ----
|
||||
;
|
||||
; A, before anything below disturbs it. IN A RATHER THAN Q, and that 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. The register a
|
||||
; subroutine cannot hand anything back in is exactly the one that is free here - and Q is
|
||||
; the ALU's output, so setting it to a small number costs four instructions where A costs
|
||||
; one.
|
||||
SETD.1 LastStatus
|
||||
STA.1
|
||||
|
||||
SETD.1 SystemStack
|
||||
LDD.0.1
|
||||
MVDS.0
|
||||
@@ -3417,6 +3440,10 @@ Banner:
|
||||
"CosmOS"
|
||||
PromptText:
|
||||
"> "
|
||||
; Nothing has run yet, so nothing has failed yet.
|
||||
LastStatus:
|
||||
0x00
|
||||
|
||||
OnFallback:
|
||||
"this is the fallback: what boot.cfg asks for did not start
|
||||
"
|
||||
@@ -3913,6 +3940,7 @@ CommandLine:
|
||||
osFileFetch handleFileFetch
|
||||
osPrintNumber handlePrintNumber
|
||||
osBreak handleBreak
|
||||
osLastStatus handleLastStatus
|
||||
osBootState handleBootState
|
||||
osBootSettle handleBootSettle
|
||||
Device 0x20 diskDone
|
||||
|
||||
@@ -153,3 +153,17 @@
|
||||
; about something the loader has no way to check.
|
||||
osBootState 0d33
|
||||
osBootSettle 0d34
|
||||
|
||||
; ---- What a program made of it ----
|
||||
;
|
||||
; osExit takes a status in A: zero if the program did what it was asked, and a number of
|
||||
; its own choosing if it did not. 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
|
||||
; does, and 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 and one in A.
|
||||
;
|
||||
; osLastStatus answers in Q with what the last program exited with. The shell does not
|
||||
; print it: a program that failed has already said so in words, and a number beside that
|
||||
; would be noise. This is for the thing that cannot read words.
|
||||
osLastStatus 0d35
|
||||
|
||||
Reference in New Issue
Block a user