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.
110 lines
1.8 KiB
NASM
110 lines
1.8 KiB
NASM
; Goes somewhere else and reads a file by a bare name once it is there.
|
|
;
|
|
; This exists to prove two things the shell promises and nothing else could test. First
|
|
; that osChangeDir works: the file it prints is named with no path at all, so the only way
|
|
; to reach it is to be standing in the right place. Second that the shell puts the working
|
|
; directory back afterwards: the prompt after this returns says where the shell was, not
|
|
; where this went.
|
|
;
|
|
; Written by Anachronaut
|
|
|
|
#Include services.asm
|
|
#Program
|
|
#Base 0x4000
|
|
|
|
start:
|
|
; Where to go is the argument. Nothing else about this program says a directory name, so
|
|
; running it anywhere else moves it anywhere else.
|
|
SETD.0 Where
|
|
INIB 0d40
|
|
SWI osArgument
|
|
SETD.0 Where
|
|
LDA.0
|
|
BRA noWhere
|
|
|
|
SETD.0 Where
|
|
SWI osChangeDir
|
|
BNQ noSuchPlace
|
|
|
|
SETD.0 Went
|
|
SWI osPrintString
|
|
|
|
; And now a bare name, which means nothing until you are somewhere.
|
|
SETD.0 Bare
|
|
CALL fileStreamOpen
|
|
BNQ noFile
|
|
|
|
wanderBlock:
|
|
CALL fileStreamNext
|
|
BNQ noFile
|
|
PSHD.3
|
|
POPB
|
|
POPA
|
|
SETD.2 Left
|
|
STA.2
|
|
INCD.2
|
|
STB.2
|
|
|
|
SETD.2 Left
|
|
LDA.2
|
|
INCD.2
|
|
LDB.2
|
|
OR
|
|
BRQ wanderDone
|
|
|
|
SETD.0 FileStreamBlock
|
|
SETD.2 Left
|
|
INCD.2
|
|
LDB.2
|
|
wanderByte:
|
|
LDA.0
|
|
OUTA 0x00
|
|
INCD.0
|
|
DECB
|
|
BNB 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
|
|
#Base 0x2000
|
|
|
|
Where:
|
|
#Reserve 0d40
|
|
Left:
|
|
0x00 0x00
|
|
Went:
|
|
"moved, and reading a bare name from there:
|
|
"
|
|
NoWhereText:
|
|
"wander where?
|
|
"
|
|
NoPlaceText:
|
|
"cannot go there
|
|
"
|
|
NoFileText:
|
|
"nothing of that name here
|
|
"
|
|
Bare:
|
|
"notes.txt"
|
|
|
|
#Include fileStream.asm
|