Files
SplitBit-Emulator/Programs/CosmOS/Apps/Wander.asm
T
AnachronautandClaude Opus 5 7073b972e6 Say what went wrong, and give the file tools room for a path
The makefile on the disk was fine. "Makefile" is not "makefile", and SBFS names are case
sensitive - but neither tool said so, and both failed in ways that pointed somewhere else.

MORE PRINTED A NUMBER THAT MEANT NOTHING. "cannot find the file, error 2" invents a
vocabulary the system does not have: the filesystem library documents its answer as zero or
not zero, never as a code, so 2 could not be looked up anywhere. It says "there is no file by
that name" now, which is the only way opening fails that a person can do anything about, and
is nearly always a name typed slightly wrong.

EDIT SAID "0 LINES", which is also what an empty file that IS on the disk says. A name typed
slightly wrong therefore looked exactly like the document you meant to open, right up until
you saved it somewhere new. It says "new file" instead.

Two bugs came out of writing that, and both are worth more than the feature.

The first is mine and the label lied to me: loadNothing is not where a load FAILS, it is
where every load FINISHES, reached at the end of splitLast on files that opened perfectly
well. A flag set there on the strength of the name was set on everything. It is called
loadDone now, and the failure has its own name.

The second is older and general: a program is loaded once and may be run many times, so
"load Edit.sbx" then "run" twice is two sessions over one copy of the Data Segment. Anything
a session changes has to be put back by the session. A zero written in the Data Segment is
the state a program starts in the first time and never again - and cosmosEdit runs Edit twice
from one load, which is why it caught it immediately.

AND THE FILE TOOLS COULD NOT ADDRESS THE TREE THEY NOW HAVE. Edit took 23 characters of name
and More and Type took 29, which were right when everything lived in the root. With the
sources mirrored onto the disk, "/Source/CosmOS/Assembler/classify.asm" is an ordinary thing
to type - thirty-seven characters, cut down to a name meaning something else, or nothing. All
of them take sixty-three now, which is what the shell reads of a command line, so nothing
longer can arrive. Wander with it, since a directory is a path too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
2026-08-29 09:24:10 -04:00

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 0d63
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 0d64
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