Load a program that has no data

A five instruction program that writes one port and exits has no Data Segment at
all, and the loader stopped the machine dead on it. It asked the memory
controller to move a segment of no bytes, and a length of zero asks for the
whole 64K - which is the machine's rule, and a reasonable one, since two bytes
cannot say 65536 and a transfer of nothing is not usually what anybody meant. It
is exactly what was meant here. 64K did not fit, the controller refused, and the
load stopped half done.

ON A TERMINAL THAT PRINTS A FAULT WITH AN ADDRESS. Behind a window it is a
frozen picture and no reason at all, which is how it was found and is a separate
problem from this one.

The header says how long each segment is, so the loader knows before it asks.
Both bytes are already in hand, so the test costs one OR. Nothing is lost by
skipping the transfer: a blit leaves the controller's addresses past whatever it
touched, and a blit of nothing would have left them where they already are,
which is where the vectors are read from next.

Guarded for the code segment too. A program with no code is equally assemblable
and would have stopped in exactly the same place.

Mode.sbx is the fix's test and a program worth having on its own: forty columns
or eighty, whichever the screen is not in, which is what a person wanting Snake
drawn twice the size actually needs. Ten instructions and no data, deliberately
- it prints its two digits a register at a time rather than from a string, so it
stays the smallest shape a loadable program can take. Nothing else on that disk
had ever been that shape, which is why nothing had ever tried it.

Reported by the user, who wrote the program.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-09-01 11:47:20 -04:00
co-authored by Claude Opus 5
parent 373454ec00
commit 81e544eb3d
14 changed files with 128 additions and 12 deletions
+2 -1
View File
@@ -21,6 +21,7 @@ Say.sbx 156
Break.sbx 149
Grid.sbx 559
Press.sbx 872
Mode.sbx 48
notes.txt 21
Apps <dir>
hi.script 121
@@ -32,7 +33,7 @@ outer.script 376
inner.script 44
loop.script 35
crossed.txt 560
19 files, 1 directory
20 files, 1 directory
> exit
halted
Execution halted.
+2 -1
View File
@@ -11,6 +11,7 @@ Say.sbx 156
Break.sbx 149
Grid.sbx 559
Press.sbx 872
Mode.sbx 48
notes.txt 21
Apps <dir>
hi.script 121
@@ -21,7 +22,7 @@ nonl.script 38
outer.script 376
inner.script 44
loop.script 35
18 files, 1 directory
19 files, 1 directory
> drive 1
> dir
other.txt 28
+2 -1
View File
@@ -18,6 +18,7 @@ Say.sbx 156
Break.sbx 149
Grid.sbx 559
Press.sbx 872
Mode.sbx 48
notes.txt 21
Apps <dir>
hi.script 121
@@ -28,7 +29,7 @@ nonl.script 38
outer.script 376
inner.script 44
loop.script 35
18 files, 1 directory
19 files, 1 directory
> exit
halted
Execution halted.
+15
View File
@@ -0,0 +1,15 @@
CosmOS
> Mode
40
finished
> echo a narrow screen
a narrow screen
> Mode
80
finished
> echo and a wide one again
and a wide one again
> exit
halted
Execution halted.
[exit 0]
+2 -1
View File
@@ -11,6 +11,7 @@ Say.sbx 156
Break.sbx 149
Grid.sbx 559
Press.sbx 872
Mode.sbx 48
notes.txt 21
Apps <dir>
hi.script 121
@@ -21,7 +22,7 @@ nonl.script 38
outer.script 376
inner.script 44
loop.script 35
18 files, 1 directory
19 files, 1 directory
> load
load what?
> load nosuch.sbx
+2 -1
View File
@@ -9,6 +9,7 @@ Say.sbx 156
Break.sbx 149
Grid.sbx 559
Press.sbx 872
Mode.sbx 48
notes.txt 21
Apps <dir>
hi.script 121
@@ -19,7 +20,7 @@ nonl.script 38
outer.script 376
inner.script 44
loop.script 35
18 files, 1 directory
19 files, 1 directory
> load Say.sbx
loaded, starting at 4000
> run the disk took its time
+5
View File
@@ -0,0 +1,5 @@
Mode
echo a narrow screen
Mode
echo and a wide one again
exit
-1
View File
@@ -15,7 +15,6 @@ Programs/CosmOS/Assembler/token.asm redundant-assignment 4
Programs/CosmOS/Assembler/token.asm redundant-setd 2
Programs/CosmOS/Assembler/tokenTest.asm redundant-setd 1
Programs/CosmOS/Source/config.asm redundant-assignment 1
Programs/CosmOS/Source/cosmos.asm redundant-assignment 1
Programs/CosmOS/Source/cosmos.asm redundant-setd 10
Programs/CosmOS/Source/sbfs.asm branch-to-next 1
Programs/CosmOS/Source/sbfs.asm redundant-assignment 4
+6
View File
@@ -118,6 +118,12 @@ for i in 1 2 3 4 5 6 7 8; do "$TOOL" put "$DISKS/sbfs.img" "filler$i.txt" >/dev/
"$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/Press.asm" -o "$WORK/Press.sbx" >/dev/null
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Press.sbx" >/dev/null
# Mode.sbx has NO DATA SEGMENT, which is the whole reason it is here. Nothing else on this
# disk is that shape, and the loader used to stop the machine dead on it: a segment of no
# bytes asks the memory controller for the whole 64K, which does not fit, which it refuses.
"$ROOT/Assembler" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/Mode.asm" -o "$WORK/Mode.sbx" >/dev/null
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Mode.sbx" >/dev/null
printf 'this is not a program' > notes.txt
"$TOOL" put "$DISKS/cosmos.img" notes.txt >/dev/null
+11
View File
@@ -305,6 +305,17 @@ cosmosPress | CosmOS/Source/cosmos.asm | run | cosmosPre
# end - the window's path through the gatherer - and it has its own copy of the line mode
# rule, so it needs its own test. The two recordings should agree, which is the point.
cosmosPressKeys | CosmOS/Source/cosmos.asm | run | - | - | disks/cosmos.img | cosmosPress.in
# A program with NO DATA SEGMENT, loaded and run. Every program written for this system had
# something in its data until somebody wrote one that did not, and the loader stopped the
# machine dead: a segment of no bytes asks the controller for the whole 64K, which does not
# fit, so it refused in the middle of loading. The most basic form a program can take, and
# nothing had ever tried it.
#
# It is run twice, because it is a toggle and the second run has to find the mode the first
# one left. The line between them is there so the recording shows the shell still working on
# a forty column screen, which is a width nothing else here ever runs at - and the shell
# reads that width for itself now, every line it edits.
cosmosNoData | CosmOS/Source/cosmos.asm | run | cosmosNoData.in | - | disks/cosmos.img
# The shell editing the line it is being given, which is the whole reason the keys were
# made to arrive. Every line here is typed wrong and then corrected with a different key, and
# every one of them comes out as the same command - so the recording says both what the