Give the system another page of each memory

CosmOS had 1,161 bytes of Program Memory left before the address applications
load at, and Tab completion is not going to fit in that with anything to spare.
So the wall moves up one page: the system keeps below 0x4FFF and 0x2FFF, and an
application is based at 0x5000 and 0x3000.

A PAGE IS A CHEAP THING TO GIVE IT AND AN EXPENSIVE THING TO RUN OUT OF. An
application still has 44K of Program Memory before the vector table and the
largest one here uses 7.5K, so what was taken from applications is space nothing
has ever asked for - while what the system gained is the difference between
building the next thing and counting bytes while building it.

Not doubling, which was the version that would have cost application space worth
minding. One page, and the same again when it is needed.

Nothing in the machine knows where the wall is, so this is 34 #Base lines, one
threshold in the fault handler, and the table in the CosmOS README that
Tests/docs.sh reads its limits out of.

The native assembler's scratch map had to move with it, and docs.sh said so
before anything ran: its data reached 0x40D6 and its buffers began at 0x4000, so
they were sitting on its variables. That file already carries a paragraph about
the floor coming up and the map staying where it was. It has happened twice now,
and been caught by a check the first time wrote.

Twenty three recordings are the same runs a page higher.

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 16:49:12 -04:00
co-authored by Claude Opus 5
parent f97d15de08
commit 3449405b18
59 changed files with 148 additions and 140 deletions
+2 -2
View File
@@ -39,7 +39,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Banner
@@ -72,7 +72,7 @@ deeper:
#Data
#Base 0x2000
#Base 0x3000
Banner:
"two stops, and what the registers were at each
+2 -2
View File
@@ -19,7 +19,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
; One block, and ten bytes after it.
@@ -81,7 +81,7 @@ noWrite:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Name:
"claim.dat"
+2 -2
View File
@@ -9,7 +9,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Arguments
@@ -236,7 +236,7 @@ secondReadFailed:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Arguments:
#Reserve 0d256
+2 -2
View File
@@ -14,7 +14,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Arguments
@@ -232,7 +232,7 @@ doneFailed:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Arguments:
#Reserve 0d256
+2 -2
View File
@@ -21,7 +21,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Argument
@@ -124,7 +124,7 @@ crashWait:
#Data
#Base 0x2000
#Base 0x3000
WordOpcode:
"opcode"
+2 -2
View File
@@ -51,7 +51,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; ---- Room for a PATH, not a name ----
@@ -869,7 +869,7 @@ addByteToWord:
#Data
#Base 0x2000
#Base 0x3000
Break:
0x0A 0x00
+2 -2
View File
@@ -4,7 +4,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; Swap ValueB and ValueA.
@@ -72,7 +72,7 @@ start:
#Data
#Base 0x2000
#Base 0x3000
ValueA:
; Low byte, high byte.
+2 -2
View File
@@ -4,7 +4,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; Swap ValueB and ValueA.
@@ -128,7 +128,7 @@ start:
#Data
#Base 0x2000
#Base 0x3000
ValueA:
; Lowest byte ... Highest byte.
+2 -2
View File
@@ -4,7 +4,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; Load our initial values into A and B.
@@ -38,6 +38,6 @@ start:
#Data
#Base 0x2000
#Base 0x3000
#Include print.asm
+2 -2
View File
@@ -24,7 +24,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; ---- Write it ----
@@ -133,7 +133,7 @@ noDelete:
#Data
#Base 0x2000
#Base 0x3000
Name:
"kept.txt"
+2 -2
View File
@@ -23,7 +23,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; ---- Reaching video memory ----
@@ -411,7 +411,7 @@ everyCell:
#Data
#Base 0x2000
#Base 0x3000
ScreenKept:
0x00
+2 -2
View File
@@ -17,7 +17,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
CIF ; Nothing arrives until there is something to catch it.
@@ -85,7 +85,7 @@ keyStop:
#Data
#Base 0x2000
#Base 0x3000
Banner:
"keys, by interrupt. q stops."
+2 -2
View File
@@ -32,7 +32,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
CALL seedGlider
@@ -350,7 +350,7 @@ delayDone:
#Data
#Base 0x2000
#Base 0x3000
RowCount:
0x00
+1 -1
View File
@@ -23,7 +23,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
INA 0x31 ; Which mode the screen is in now.
+2 -2
View File
@@ -8,7 +8,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Name
@@ -139,7 +139,7 @@ finished:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Usage:
"more: give me a file name
"
+2 -2
View File
@@ -25,7 +25,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Wanted
@@ -114,7 +114,7 @@ measureDone:
#Data
#Base 0x2000
#Base 0x3000
Prefix:
"system "
+2 -2
View File
@@ -12,7 +12,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Argument
@@ -213,7 +213,7 @@ doneFailed:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Name:
"poured.dat"
+2 -2
View File
@@ -19,7 +19,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 LineText
@@ -141,7 +141,7 @@ keySay:
#Data
#Base 0x2000
#Base 0x3000
LineText:
"a line, then keys. q stops."
+2 -2
View File
@@ -27,7 +27,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Saying
@@ -45,7 +45,7 @@ start:
#Data
#Base 0x2000
#Base 0x3000
Saying:
"starting again
+2 -2
View File
@@ -16,7 +16,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Given
@@ -45,7 +45,7 @@ sayEnd:
#Data
#Base 0x2000
#Base 0x3000
SaidText:
"it says: "
+2 -2
View File
@@ -23,7 +23,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SWI osBootState
@@ -71,7 +71,7 @@ alreadySettled:
#Data
#Base 0x2000
#Base 0x3000
WasTrying:
"the disk says a start is still in progress
+2 -2
View File
@@ -9,7 +9,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
RSTA
@@ -140,7 +140,7 @@ printCandidateHex:
#Data
#Base 0x2000
#Base 0x3000
; Segment has to begin on a page boundary, and now says so itself rather than relying on
; whatever happens to have been assembled before it. The marking loop adds the prime to
+2 -2
View File
@@ -4,7 +4,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; Search the list until we find a prime.
@@ -46,7 +46,7 @@ start:
#Data
#Base 0x2000
#Base 0x3000
; The table of our prime candidates. It has to begin on a page boundary: marking walks
; the pointer's low byte and treats the carry out as running off the end of the table,
+2 -2
View File
@@ -38,7 +38,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; The two pointers whose low byte is a square number. Both regions are page aligned, so
@@ -615,7 +615,7 @@ pauseInner:
#Data
#Base 0x2000
#Base 0x3000
HeadCell:
0x00
+2 -2
View File
@@ -18,7 +18,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SWI osLastStatus
@@ -70,7 +70,7 @@ done:
#Data
#Base 0x2000
#Base 0x3000
Prefix:
"the last program left "
+2 -2
View File
@@ -36,7 +36,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
; ---- 1. How big is something that will not fit ----
@@ -408,7 +408,7 @@ printWhy:
#Data
#Base 0x2000
#Base 0x3000
BigName:
"big.txt"
+2 -2
View File
@@ -6,7 +6,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Name
@@ -70,7 +70,7 @@ finished:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Usage:
"type: give me a file name
"
+2 -2
View File
@@ -10,7 +10,7 @@
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
; Where to go is the argument. Nothing else about this program says a directory name, so
@@ -85,7 +85,7 @@ noFile:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Where:
#Reserve 0d64
+2 -2
View File
@@ -17,7 +17,7 @@
#Program
#Base 0x4000 ; Above the system, which keeps below here.
#Base 0x5000 ; Above the system, which keeps below here.
greet:
SETD.0 Opening
@@ -44,7 +44,7 @@ greet:
#Data
#Base 0x2000 ; And its data above the system's.
#Base 0x3000 ; And its data above the system's.
Opening:
"a program, loaded off a disk, running on the system that loaded it
+2 -2
View File
@@ -6,7 +6,7 @@
#Program
#Base 0x4000 ; Change two:
#Base 0x5000 ; Change two:
SETD hello ; Change three
Start:
@@ -26,6 +26,6 @@ End:
#Data
#Base 0x2000 ; Five, adjust the base of the data segment.
#Base 0x3000 ; Five, adjust the base of the data segment.
hello: ; Throw a label here so we can explicitly point at this data. Six, actually.
"Hello, World!"
+2 -2
View File
@@ -38,7 +38,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Argument
@@ -2180,7 +2180,7 @@ report:
#Data
#Base 0x2000
#Base 0x3000
Argument:
#Reserve 0d23
+2 -2
View File
@@ -14,7 +14,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Wanted
@@ -60,7 +60,7 @@ noFile:
#Data
#Base 0x2000
#Base 0x3000
Wanted:
#Reserve 0d23
+17 -11
View File
@@ -12,7 +12,7 @@
;
; None of this is initialised data. It is scratch, wanted only while the assembler is
; running, and while it is running everything above its own data is free: the system keeps
; below 0x1FFF, the staging area is only in use during a load, and the Stack comes down
; below 0x2FFF, the staging area is only in use during a load, and the Stack comes down
; from the top. So the addresses are written down here and the file carries none of it.
;
; That sentence said 0x1000 for a while after the system's half of Data Memory was
@@ -20,10 +20,10 @@
; bad enough; a stale number sitting next to the correction is worse, because whichever
; one a reader takes is a coin toss.
;
; 0x4000 6144 the label index, 1536 entries of four
; 0x5800 16384 the label names, packed end to end
; 0x9800 256 one block of the output file, on its way to the disk
; 0x9900 18176 free
; 0x5000 6144 the label index, 1536 entries of four
; 0x6800 16384 the label names, packed end to end
; 0xA800 256 one block of the output file, on its way to the disk
; 0xA900 17152 free
; 0xE000 1792 the vector names, 64 entries of twenty eight
; 0xE700 2048 the reader's stack, six levels of 301
; 0xEF00 368 which files have been included, sixteen names of 23
@@ -35,9 +35,15 @@
; and the map stayed where it was, leaving sixteen kilobytes between the two that nothing
; touched.
;
; Starting at 0x4000 takes that back. The assembler's data is a little over four kilobytes
; from 0x2000, so there is still nearly four kilobytes of slack in front of this - and room
; for its data to double before the two would meet. `make test` measures that gap now
; Starting above the assembler's own data takes that back. It began at 0x4000 with the data
; from 0x2000, and moved to 0x5000 when the system was given another page and every
; application's data moved to 0x3000 with it - THE FLOOR CAME UP A SECOND TIME, exactly as
; the paragraph above says it did the first, and this time the check below said so before
; anything ran: the assembler's data reached 0x40D6 and the index began at 0x4000, so the
; buffers were sitting on the variables.
;
; There is still nearly four kilobytes of slack in front of this, and room for the data to
; double before the two would meet. `make test` measures that gap now
; rather than trusting this paragraph, and measures the floor above as well, because both
; of those numbers describe the machine AROUND this file and neither is enforced by a line
; of code anywhere.
@@ -77,11 +83,11 @@
; second is bigger than the first, which is worth knowing: the hardest thing this assembles
; is not the operating system, it is itself.
ScratchLabIndex:
0x40 0x00
0x50 0x00
ScratchLabArena:
0x58 0x00
0x68 0x00
ScratchWindow:
0x98 0x00
0xA8 0x00
ScratchVecNames:
0xE0 0x00
ScratchSrcStack:
+2 -2
View File
@@ -15,7 +15,7 @@
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Wanted
@@ -128,7 +128,7 @@ noFile:
#Data
#Base 0x2000
#Base 0x3000
Wanted:
#Reserve 0d23
+13 -5
View File
@@ -847,16 +847,24 @@ CosmOS divides the two SplitBit address spaces by convention:
| Memory | CosmOS | Loaded application |
| -- | -- | -- |
| Program Memory | `0x0000` through `0x3FFF` | `0x4000` and above |
| Data Memory | `0x0000` through `0x1FFF` | `0x2000` and above |
| Program Memory | `0x0000` through `0x4FFF` | `0x5000` and above |
| Data Memory | `0x0000` through `0x2FFF` | `0x3000` and above |
Both of CosmOS's halves were doubled once it outgrew the first ones. **The division is a
CosmOS's halves have been enlarged twice: doubled once when it outgrew the first ones, and
given a page each when the shell learned to edit and remember a line. **The division is a
convention and nothing enforced it**, so CosmOS quietly grew past `0x1FFF` and the next
program loaded landed on top of its own code - which does not fail where it happens, it
fails later, in whatever part of the shell the program happened to cover. `make test` now
measures both segments against the numbers in this table, so the table is checked rather
than merely written down.
**A page is a cheap thing to give it and an expensive thing to run out of.** An application
still has 44K of Program Memory before the vector table, and the largest one here uses 7.5K,
so the space taken from applications is space nothing has ever asked for - while the space
given to the system is the difference between building the next thing and counting bytes
while building it. Moving the wall costs a `#Base` line in each application and a rebuild;
that is the whole of it, because nothing in the machine knows where the wall is.
**The table is checked against itself as well.** The first version of that check read only
the CosmOS column, and so it passed a table whose Data row gave the system `0x3FFF` and an
application `0x2000` - two columns that cannot both be true, sitting next to each other.
@@ -890,7 +898,7 @@ A minimal CosmOS application therefore looks like this:
#Include services.asm
#Program
#Base 0x4000
#Base 0x5000
start:
SETD.0 Message
@@ -898,7 +906,7 @@ start:
SWI osExit
#Data
#Base 0x2000
#Base 0x3000
Message:
"Hello from CosmOS."
+5 -5
View File
@@ -10,10 +10,10 @@
; The system keeps to the bottom of both memories, and everything above is for whatever
; it is running:
;
; Program Memory 0x0000 - 0x3FFF the system
; 0x4000 - a loaded program's code
; Data Memory 0x0000 - 0x1FFF the system
; 0x2000 - a loaded program's data
; Program Memory 0x0000 - 0x4FFF the system
; 0x5000 - a loaded program's code
; Data Memory 0x0000 - 0x2FFF the system
; 0x3000 - a loaded program's data
;
; Nothing enforces that. Nothing can: the fence guards a range, and this is a convention
; about which range belongs to whom rather than a rule about what may be touched. The
@@ -1384,7 +1384,7 @@ faultWhere:
POPD.0
DPUP.0 0d13
LDA.0
INIB 0x40
INIB 0x50
CCF
SUB
BRC faultInSystem