Double CosmOS's half of the machine, and check that it fits

The memory map gave CosmOS 0x0000 through 0x1FFF of Program Memory and
applications 0x2000 and above. CosmOS is 8141 bytes at the previous commit,
which is fifty one bytes short of the line, and the next thing added to it
went over.

GOING OVER DOES NOT FAIL WHERE IT HAPPENS. Nothing enforces the division: an
application says where it goes with #Base and the loader puts it there, so a
CosmOS that has grown past 0x1FFF simply has the next program loaded written
over the end of it. What breaks is whichever part of the shell that program
happened to cover, at whatever later moment somebody uses it. It turned up here
as the monitor's assemble command answering "I do not know" to valid
instructions, several commands into a session, on a machine that had booted
perfectly well.

Both halves are doubled: applications now start at 0x4000 in Program Memory and
0x2000 in Data Memory. That is 16K of code and 8K of data for the system,
against the 8775 and 2948 it uses today. Both were on the same trajectory, and
moving them together means the twenty files that say #Base are edited once
rather than twice.

The standalone loader's loadable.asm keeps its old base: it belongs to the
loader CosmOS grew out of, not to CosmOS, and its addresses answer to a
different program. The unbased-segment diagnostic keeps its old base too - it
exists to produce an error message that names the address, and the message is
what is recorded.

Tests/docs.sh now reads the two limits out of the table in the README and
measures both segments against them. It reads them rather than being told them
because the table is the specification, and this is the second time in this
project that the thing nobody checked is the thing that rotted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-24 22:21:02 -04:00
co-authored by Claude Opus 5
parent 36a1b07b5b
commit 588e02aff5
41 changed files with 126 additions and 86 deletions
+32
View File
@@ -430,6 +430,38 @@ for heading in ["## An Example SplitBit Assembly Program:",
problems.append("the example under \"%s\" no longer assembles"
% heading.strip("# :"))
# ---- CosmOS fits in the half of the machine it says it does ----
#
# The memory map in the CosmOS README is a CONVENTION. Nothing in the assembler, the
# loader or the machine enforces it: an application says where it goes with #Base, and
# CosmOS puts it there. So when CosmOS grew past the address applications are based at,
# nothing said so - the next program loaded simply landed on top of the shell's own code,
# and what broke was whichever part of the shell that program happened to cover, at
# whatever later moment somebody used it.
#
# That is why this reads the numbers out of the table rather than being told them: the
# table is the specification, and a table nothing checks is the thing that goes stale.
readme = open("Programs/CosmOS/README.md").read()
row = re.compile(r"\|\s*(Program|Data) Memory\s*\|\s*`0x0000` through `0x([0-9A-Fa-f]{4})`")
limits = {kind: int(top, 16) + 1 for kind, top in row.findall(readme)}
if len(limits) != 2:
problems.append("the CosmOS README no longer states a memory map this can check")
else:
built = subprocess.run(["./Assembler", "-I", "Programs/CosmOS/Source",
"Programs/CosmOS/Source/cosmos.asm", "-o", os.devnull],
capture_output=True, text=True)
sizes = dict(re.findall(r"(Program|Data) Segment size: (\d+)", built.stdout))
if len(sizes) != 2:
problems.append("could not measure the CosmOS segments")
else:
for kind in ("Program", "Data"):
used, room = int(sizes[kind]), limits[kind]
if used > room:
problems.append(
"CosmOS's %s Segment is %d bytes and the map gives it %d - it now"
" reaches into the %d bytes an application is loaded at, and loading"
" one will overwrite it" % (kind, used, room, used - room))
if problems:
print("The manuals and the code disagree:")
for p in problems:
+5 -5
View File
@@ -1,13 +1,13 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> two stops, and what the registers were at each
break at 200E
break at 400E
A 11 B 22 Q 00 status 00
DP0 1030 DP1 0730 DP2 0000 DP3 2000 SP FFFF
DP0 2030 DP1 0730 DP2 0000 DP3 4000 SP FFFF
press a key
break at 2023
break at 4023
A 44 B 55 Q 00 status 00
DP0 1000 DP1 0730 DP2 0000 DP3 2000 SP FFF5
DP0 2000 DP1 0730 DP2 0000 DP3 4000 SP FFF5
press a key
carried on to the end
finished
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> poem.txt, 0 lines
> : : : : > : : > 1: alpha
2: INSERTED
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> Hello, World!
finished
> Hello, World!
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> keys, by interrupt. q stops.
ab
the console has been handed back
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
>  #
#
###
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
>  #
#
###
+17 -17
View File
@@ -2,25 +2,25 @@ CosmOS
> x examine, d disassemble, a assemble, s set, b bank, g go, exit leaves
* b <program|data|number>
* there is no such bank
* loaded, starting at 2000
* loaded, starting at 4000
* bank 00
* 2000 47 00 10 00 SETD.0 1000
2004 18 10 SWI 10
2006 47 00 10 44 SETD.0 1044
200A 18 10 SWI 10
200C 47 00 10 7A SETD.0 107A
2010 27 1F INIB 1F
2012 18 11 SWI 11
2014 47 00 10 5D SETD.0 105D
* 2000 47 00 10 00 18 10 47 00 10 44 18 10 47 00 10 7A G.....G..D..G..z
2010 27 1F 18 11 47 00 10 5D 18 10 47 00 10 7A 18 10 '...G..]..G..z..
2020 47 00 10 65 18 10 18 12 00 00 00 00 00 00 00 00 G..e............
2030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* 4000 47 00 20 00 SETD.0 2000
4004 18 10 SWI 10
4006 47 00 20 44 SETD.0 2044
400A 18 10 SWI 10
400C 47 00 20 7A SETD.0 207A
4010 27 1F INIB 1F
4012 18 11 SWI 11
4014 47 00 20 5D SETD.0 205D
* 4000 47 00 20 00 18 10 47 00 20 44 18 10 47 00 20 7A G. ...G. D..G. z
4010 27 1F 18 11 47 00 20 5D 18 10 47 00 20 7A 18 10 '...G. ]..G. z..
4020 47 00 20 65 18 10 18 12 00 00 00 00 00 00 00 00 G. e............
4030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
* bank 01
* 1000 61 20 70 72 6F 67 72 61 6D 2C 20 6C 6F 61 64 65 a program, loade
1010 64 20 6F 66 66 20 61 20 64 69 73 6B 2C 20 72 75 d off a disk, ru
1020 6E 6E 69 6E 67 20 6F 6E 20 74 68 65 20 73 79 73 nning on the sys
1030 74 65 6D 20 74 68 61 74 20 6C 6F 61 64 65 64 20 tem that loaded
* 2000 61 20 70 72 6F 67 72 61 6D 2C 20 6C 6F 61 64 65 a program, loade
2010 64 20 6F 66 66 20 61 20 64 69 73 6B 2C 20 72 75 d off a disk, ru
2020 6E 6E 69 6E 67 20 6F 6E 20 74 68 65 20 73 79 73 nning on the sys
2030 74 65 6D 20 74 68 61 74 20 6C 6F 61 64 65 64 20 tem that loaded
* bank 02
* 0000 01 FF 00 00 00 00 00 00 01 FF 00 00 00 00 00 00 ................
0010 03 FF 08 00 00 00 00 00 01 20 01 00 00 00 00 00 ......... ......
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> first line
second line
line 00: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+1 -1
View File
@@ -12,7 +12,7 @@ notes.txt 21
> load what?
> no such file
> not a program
> loaded, starting at 2000
> loaded, starting at 4000
> a program, loaded off a disk, running on the system that loaded it
what should I call you? hello, Anachronaut. that is all I do.
finished
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> nothing was said
finished
> it says: notes.txt
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> saved it
read it back, 22 bytes:
a file kept by asking
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> +----------------+
| |
| |
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> ; This is a basic hello world program for the SplitBit CPU.
; We'll create a loop that outputs each byte of our string to Output 0, the text console.
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> big.txt is 329 blocks
read 329 blocks, checksum 57368, stopped with 3
small.txt streamed is 15216, read whole is 15216
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> 4 keyword 0 [#Program]
6 label: 0 [Start:]
7 instr 2 [LDA]
+4 -4
View File
@@ -5,16 +5,16 @@ Say.sbx 155
Say.sbx 52
rooted.txt 21
3 files, 2 directories
> loaded, starting at 2000
> loaded, starting at 4000
> it says: the shallow one
finished
> loaded, starting at 2000
> loaded, starting at 4000
> Hello, World!
finished
> loaded, starting at 2000
> loaded, starting at 4000
> it says: the shallow one again
finished
> loaded, starting at 2000
> loaded, starting at 4000
> Hello, World!
finished
> no such file
+1 -1
View File
@@ -3,7 +3,7 @@ CosmOS
Inner <dir>
Edit.sbx 1996
1 file, 2 directories
> loaded, starting at 2000
> loaded, starting at 4000
> note.txt, 0 lines
> : : : > written, 67 bytes
> finished
+1 -1
View File
@@ -1,5 +1,5 @@
CosmOS
> loaded, starting at 2000
> loaded, starting at 4000
> first line
second line
line 00: ABCDEFGHIJKLMNOPQRSTUVWXYZ
+3 -3
View File
@@ -3,10 +3,10 @@ b nonsense
b 9
load greet.sbx
b program
d 2000
x 2000
d 4000
x 4000
b data
x 1000
x 2000
b 2
x 0
s 0 FF