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.
63 lines
1.6 KiB
NASM
63 lines
1.6 KiB
NASM
; A program for CosmOS to load and run.
|
|
;
|
|
; It carries no library of its own and no vector table. Everything it can do it asks the
|
|
; system for, by name, through services.asm, which the system includes too. The order of
|
|
; the names in that one file is what gives them their numbers, so neither side has a
|
|
; number written down anywhere and the two cannot disagree about them.
|
|
;
|
|
; Compare it with Programs/loadable/hello.asm, which is the same idea one step earlier:
|
|
; that one talks to the console port itself and stops with HALT, because when it was
|
|
; written there was no system to ask and nowhere to give the machine back to.
|
|
;
|
|
; It is assembled for where it will live. #Base says so, and that makes the assembler
|
|
; write it out as a loadable program rather than as a boot image. Nothing relocates
|
|
; anything, so those addresses have to be the ones CosmOS puts it at.
|
|
|
|
#Include services.asm
|
|
|
|
#Program
|
|
|
|
#Base 0x4000 ; Above the system, which keeps below here.
|
|
|
|
greet:
|
|
SETD.0 Opening
|
|
SWI osPrintString
|
|
|
|
SETD.0 Question
|
|
SWI osPrintString
|
|
|
|
SETD.0 Answer
|
|
INIB 0d31
|
|
SWI osReadLine
|
|
|
|
SETD.0 Hello
|
|
SWI osPrintString
|
|
SETD.0 Answer
|
|
SWI osPrintString
|
|
SETD.0 Ending
|
|
SWI osPrintString
|
|
|
|
; 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
|
|
|
|
#Base 0x2000 ; And its data above the system's.
|
|
|
|
Opening:
|
|
"a program, loaded off a disk, running on the system that loaded it
|
|
"
|
|
Question:
|
|
"what should I call you? "
|
|
Hello:
|
|
"hello, "
|
|
Ending:
|
|
". that is all I do.
|
|
"
|
|
|
|
; Thirty one characters and the zero byte that ends them.
|
|
Answer:
|
|
#Reserve 0d32
|