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:
@@ -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
|
||||
Reference in New Issue
Block a user