From 3449405b1887b7b892f6f5c12e2be1dfcc716e30 Mon Sep 17 00:00:00 2001 From: Anachronaut Date: Tue, 1 Sep 2026 16:49:12 -0400 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW --- Programs/CosmOS/Apps/Break.asm | 4 ++-- Programs/CosmOS/Apps/Claim.asm | 4 ++-- Programs/CosmOS/Apps/Compare.asm | 4 ++-- Programs/CosmOS/Apps/Copy.asm | 4 ++-- Programs/CosmOS/Apps/Crash.asm | 4 ++-- Programs/CosmOS/Apps/Edit.asm | 4 ++-- Programs/CosmOS/Apps/Fib-16.asm | 4 ++-- Programs/CosmOS/Apps/Fib-32.asm | 4 ++-- Programs/CosmOS/Apps/Fib-8.asm | 4 ++-- Programs/CosmOS/Apps/Files.asm | 4 ++-- Programs/CosmOS/Apps/Grid.asm | 4 ++-- Programs/CosmOS/Apps/Keys.asm | 4 ++-- Programs/CosmOS/Apps/Life.asm | 4 ++-- Programs/CosmOS/Apps/Mode.asm | 2 +- Programs/CosmOS/Apps/More.asm | 4 ++-- Programs/CosmOS/Apps/Once.asm | 4 ++-- Programs/CosmOS/Apps/Pour.asm | 4 ++-- Programs/CosmOS/Apps/Press.asm | 4 ++-- Programs/CosmOS/Apps/Reboot.asm | 4 ++-- Programs/CosmOS/Apps/Say.asm | 4 ++-- Programs/CosmOS/Apps/Settle.asm | 4 ++-- Programs/CosmOS/Apps/Sieve-16.asm | 4 ++-- Programs/CosmOS/Apps/Sieve-8.asm | 4 ++-- Programs/CosmOS/Apps/Snake.asm | 4 ++-- Programs/CosmOS/Apps/Status.asm | 4 ++-- Programs/CosmOS/Apps/Stream.asm | 4 ++-- Programs/CosmOS/Apps/Type.asm | 4 ++-- Programs/CosmOS/Apps/Wander.asm | 4 ++-- Programs/CosmOS/Apps/greet.asm | 4 ++-- Programs/CosmOS/Apps/hello.asm | 4 ++-- Programs/CosmOS/Assembler/Asm.asm | 4 ++-- Programs/CosmOS/Assembler/readTest.asm | 4 ++-- Programs/CosmOS/Assembler/scratch.asm | 28 +++++++++++++--------- Programs/CosmOS/Assembler/tokenTest.asm | 4 ++-- Programs/CosmOS/README.md | 18 ++++++++++---- Programs/CosmOS/Source/cosmos.asm | 10 ++++---- Programs/Examples/tune.asm | 8 +------ Tests/expected/cosmosBreak.out | 10 ++++---- Tests/expected/cosmosEdit.out | 2 +- Tests/expected/cosmosEditService.out | 2 +- Tests/expected/cosmosFault.out | 8 +++---- Tests/expected/cosmosHello.out | 2 +- Tests/expected/cosmosKeys.out | 2 +- Tests/expected/cosmosLife.out | 2 +- Tests/expected/cosmosLifeKey.out | 2 +- Tests/expected/cosmosMonitor.out | 32 ++++++++++++------------- Tests/expected/cosmosMonitorRun.out | 2 +- Tests/expected/cosmosMore.out | 2 +- Tests/expected/cosmosRun.out | 2 +- Tests/expected/cosmosSay.out | 2 +- Tests/expected/cosmosServices.out | 2 +- Tests/expected/cosmosSlowDisk.out | 2 +- Tests/expected/cosmosSnake.out | 2 +- Tests/expected/cosmosSource.out | 2 +- Tests/expected/cosmosStream.out | 2 +- Tests/expected/cosmosTokens.out | 2 +- Tests/expected/cosmosTree.out | 8 +++---- Tests/expected/cosmosTreeWrite.out | 2 +- Tests/expected/cosmosType.out | 2 +- 59 files changed, 148 insertions(+), 140 deletions(-) diff --git a/Programs/CosmOS/Apps/Break.asm b/Programs/CosmOS/Apps/Break.asm index f6231fa..f090981 100644 --- a/Programs/CosmOS/Apps/Break.asm +++ b/Programs/CosmOS/Apps/Break.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Claim.asm b/Programs/CosmOS/Apps/Claim.asm index eb6a55a..f5b38a6 100644 --- a/Programs/CosmOS/Apps/Claim.asm +++ b/Programs/CosmOS/Apps/Claim.asm @@ -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" diff --git a/Programs/CosmOS/Apps/Compare.asm b/Programs/CosmOS/Apps/Compare.asm index afaeac7..1405873 100644 --- a/Programs/CosmOS/Apps/Compare.asm +++ b/Programs/CosmOS/Apps/Compare.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Copy.asm b/Programs/CosmOS/Apps/Copy.asm index 7c09799..9115daa 100644 --- a/Programs/CosmOS/Apps/Copy.asm +++ b/Programs/CosmOS/Apps/Copy.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Crash.asm b/Programs/CosmOS/Apps/Crash.asm index 846d060..20c2733 100644 --- a/Programs/CosmOS/Apps/Crash.asm +++ b/Programs/CosmOS/Apps/Crash.asm @@ -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" diff --git a/Programs/CosmOS/Apps/Edit.asm b/Programs/CosmOS/Apps/Edit.asm index 3c64838..99c4222 100644 --- a/Programs/CosmOS/Apps/Edit.asm +++ b/Programs/CosmOS/Apps/Edit.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Fib-16.asm b/Programs/CosmOS/Apps/Fib-16.asm index ad34d22..0de094f 100644 --- a/Programs/CosmOS/Apps/Fib-16.asm +++ b/Programs/CosmOS/Apps/Fib-16.asm @@ -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. diff --git a/Programs/CosmOS/Apps/Fib-32.asm b/Programs/CosmOS/Apps/Fib-32.asm index b3d7b6f..ea95422 100644 --- a/Programs/CosmOS/Apps/Fib-32.asm +++ b/Programs/CosmOS/Apps/Fib-32.asm @@ -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. diff --git a/Programs/CosmOS/Apps/Fib-8.asm b/Programs/CosmOS/Apps/Fib-8.asm index 6d6314d..64c65c2 100644 --- a/Programs/CosmOS/Apps/Fib-8.asm +++ b/Programs/CosmOS/Apps/Fib-8.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Files.asm b/Programs/CosmOS/Apps/Files.asm index 067688e..352965e 100644 --- a/Programs/CosmOS/Apps/Files.asm +++ b/Programs/CosmOS/Apps/Files.asm @@ -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" diff --git a/Programs/CosmOS/Apps/Grid.asm b/Programs/CosmOS/Apps/Grid.asm index 41e1b94..033041d 100644 --- a/Programs/CosmOS/Apps/Grid.asm +++ b/Programs/CosmOS/Apps/Grid.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Keys.asm b/Programs/CosmOS/Apps/Keys.asm index a8b1ad3..1d5c8a4 100644 --- a/Programs/CosmOS/Apps/Keys.asm +++ b/Programs/CosmOS/Apps/Keys.asm @@ -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." diff --git a/Programs/CosmOS/Apps/Life.asm b/Programs/CosmOS/Apps/Life.asm index cd4ba45..f0730e3 100644 --- a/Programs/CosmOS/Apps/Life.asm +++ b/Programs/CosmOS/Apps/Life.asm @@ -32,7 +32,7 @@ #Program - #Base 0x4000 + #Base 0x5000 start: CALL seedGlider @@ -350,7 +350,7 @@ delayDone: #Data - #Base 0x2000 + #Base 0x3000 RowCount: 0x00 diff --git a/Programs/CosmOS/Apps/Mode.asm b/Programs/CosmOS/Apps/Mode.asm index feb4a9e..bcb835b 100644 --- a/Programs/CosmOS/Apps/Mode.asm +++ b/Programs/CosmOS/Apps/Mode.asm @@ -23,7 +23,7 @@ #Program - #Base 0x4000 + #Base 0x5000 start: INA 0x31 ; Which mode the screen is in now. diff --git a/Programs/CosmOS/Apps/More.asm b/Programs/CosmOS/Apps/More.asm index ba904a4..e3f6301 100644 --- a/Programs/CosmOS/Apps/More.asm +++ b/Programs/CosmOS/Apps/More.asm @@ -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 " diff --git a/Programs/CosmOS/Apps/Once.asm b/Programs/CosmOS/Apps/Once.asm index e8f9df4..940124b 100644 --- a/Programs/CosmOS/Apps/Once.asm +++ b/Programs/CosmOS/Apps/Once.asm @@ -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 " diff --git a/Programs/CosmOS/Apps/Pour.asm b/Programs/CosmOS/Apps/Pour.asm index 16baa6f..c6534c5 100644 --- a/Programs/CosmOS/Apps/Pour.asm +++ b/Programs/CosmOS/Apps/Pour.asm @@ -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" diff --git a/Programs/CosmOS/Apps/Press.asm b/Programs/CosmOS/Apps/Press.asm index f71bf88..35e694a 100644 --- a/Programs/CosmOS/Apps/Press.asm +++ b/Programs/CosmOS/Apps/Press.asm @@ -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." diff --git a/Programs/CosmOS/Apps/Reboot.asm b/Programs/CosmOS/Apps/Reboot.asm index acf903f..3591fdf 100644 --- a/Programs/CosmOS/Apps/Reboot.asm +++ b/Programs/CosmOS/Apps/Reboot.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Say.asm b/Programs/CosmOS/Apps/Say.asm index ffa4856..30ac8d3 100644 --- a/Programs/CosmOS/Apps/Say.asm +++ b/Programs/CosmOS/Apps/Say.asm @@ -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: " diff --git a/Programs/CosmOS/Apps/Settle.asm b/Programs/CosmOS/Apps/Settle.asm index 2f571df..3d6342a 100644 --- a/Programs/CosmOS/Apps/Settle.asm +++ b/Programs/CosmOS/Apps/Settle.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Sieve-16.asm b/Programs/CosmOS/Apps/Sieve-16.asm index c804caa..a13e3d2 100644 --- a/Programs/CosmOS/Apps/Sieve-16.asm +++ b/Programs/CosmOS/Apps/Sieve-16.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Sieve-8.asm b/Programs/CosmOS/Apps/Sieve-8.asm index b0e6f92..0829abb 100644 --- a/Programs/CosmOS/Apps/Sieve-8.asm +++ b/Programs/CosmOS/Apps/Sieve-8.asm @@ -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, diff --git a/Programs/CosmOS/Apps/Snake.asm b/Programs/CosmOS/Apps/Snake.asm index e7cb6b5..098af83 100644 --- a/Programs/CosmOS/Apps/Snake.asm +++ b/Programs/CosmOS/Apps/Snake.asm @@ -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 diff --git a/Programs/CosmOS/Apps/Status.asm b/Programs/CosmOS/Apps/Status.asm index c8d9939..f295540 100644 --- a/Programs/CosmOS/Apps/Status.asm +++ b/Programs/CosmOS/Apps/Status.asm @@ -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 " diff --git a/Programs/CosmOS/Apps/Stream.asm b/Programs/CosmOS/Apps/Stream.asm index 05bdcf1..638fc72 100644 --- a/Programs/CosmOS/Apps/Stream.asm +++ b/Programs/CosmOS/Apps/Stream.asm @@ -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" diff --git a/Programs/CosmOS/Apps/Type.asm b/Programs/CosmOS/Apps/Type.asm index 6dd62f1..138cefb 100644 --- a/Programs/CosmOS/Apps/Type.asm +++ b/Programs/CosmOS/Apps/Type.asm @@ -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 " diff --git a/Programs/CosmOS/Apps/Wander.asm b/Programs/CosmOS/Apps/Wander.asm index c702bc6..cecacca 100644 --- a/Programs/CosmOS/Apps/Wander.asm +++ b/Programs/CosmOS/Apps/Wander.asm @@ -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 diff --git a/Programs/CosmOS/Apps/greet.asm b/Programs/CosmOS/Apps/greet.asm index d783b6a..d59de66 100644 --- a/Programs/CosmOS/Apps/greet.asm +++ b/Programs/CosmOS/Apps/greet.asm @@ -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 diff --git a/Programs/CosmOS/Apps/hello.asm b/Programs/CosmOS/Apps/hello.asm index 7deacf7..bcbb000 100644 --- a/Programs/CosmOS/Apps/hello.asm +++ b/Programs/CosmOS/Apps/hello.asm @@ -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!" diff --git a/Programs/CosmOS/Assembler/Asm.asm b/Programs/CosmOS/Assembler/Asm.asm index 16e2709..9f5aced 100644 --- a/Programs/CosmOS/Assembler/Asm.asm +++ b/Programs/CosmOS/Assembler/Asm.asm @@ -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 diff --git a/Programs/CosmOS/Assembler/readTest.asm b/Programs/CosmOS/Assembler/readTest.asm index 25a739e..0b71aee 100644 --- a/Programs/CosmOS/Assembler/readTest.asm +++ b/Programs/CosmOS/Assembler/readTest.asm @@ -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 diff --git a/Programs/CosmOS/Assembler/scratch.asm b/Programs/CosmOS/Assembler/scratch.asm index efe25eb..4744635 100644 --- a/Programs/CosmOS/Assembler/scratch.asm +++ b/Programs/CosmOS/Assembler/scratch.asm @@ -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: diff --git a/Programs/CosmOS/Assembler/tokenTest.asm b/Programs/CosmOS/Assembler/tokenTest.asm index f0b207c..6a4d1c4 100644 --- a/Programs/CosmOS/Assembler/tokenTest.asm +++ b/Programs/CosmOS/Assembler/tokenTest.asm @@ -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 diff --git a/Programs/CosmOS/README.md b/Programs/CosmOS/README.md index ea74410..ca4f397 100644 --- a/Programs/CosmOS/README.md +++ b/Programs/CosmOS/README.md @@ -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." diff --git a/Programs/CosmOS/Source/cosmos.asm b/Programs/CosmOS/Source/cosmos.asm index 9441bb4..13525f6 100644 --- a/Programs/CosmOS/Source/cosmos.asm +++ b/Programs/CosmOS/Source/cosmos.asm @@ -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 diff --git a/Programs/Examples/tune.asm b/Programs/Examples/tune.asm index fbd513a..59ddcec 100644 --- a/Programs/Examples/tune.asm +++ b/Programs/Examples/tune.asm @@ -37,10 +37,6 @@ #Program -#Include services.asm - -#Base 0x4000 - start: ; ---- The instrument ---- @@ -186,7 +182,7 @@ lastRing: CIF RSTA OUTA 0x35 - SWI osExit + HALT ; Sixty times a second, and it has nothing to do. WAIT only needs something to have happened, ; and this is the something. A handler still has to exist: an interrupt with nothing installed @@ -196,8 +192,6 @@ frame: #Data -#Base 0x2000 - ; ---- Notes and how long they last ---- ; ; Pairs: a MIDI note, then a count of frames. 60 is middle C and every 12 is an octave. A zero diff --git a/Tests/expected/cosmosBreak.out b/Tests/expected/cosmosBreak.out index 64465a1..fe5cbf6 100644 --- a/Tests/expected/cosmosBreak.out +++ b/Tests/expected/cosmosBreak.out @@ -1,15 +1,15 @@ CosmOS > load Break.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run two stops, and what the registers were at each -break at 4016 +break at 5016 A 11 B 22 Q 00 status 00 -DP0 2030 DP1 2000 DP2 2037 DP3 4000 SP FFFF +DP0 3030 DP1 3000 DP2 3037 DP3 5000 SP FFFF press a key -break at 4034 +break at 5034 A 44 B 55 Q 00 status 00 -DP0 2000 DP1 2037 DP2 2030 DP3 4000 SP FFF5 +DP0 3000 DP1 3037 DP2 3030 DP3 5000 SP FFF5 press a key carried on to the end finished diff --git a/Tests/expected/cosmosEdit.out b/Tests/expected/cosmosEdit.out index 16f17b7..4e008ec 100644 --- a/Tests/expected/cosmosEdit.out +++ b/Tests/expected/cosmosEdit.out @@ -1,6 +1,6 @@ CosmOS > load Edit.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run poem.txt poem.txt, new file > a diff --git a/Tests/expected/cosmosEditService.out b/Tests/expected/cosmosEditService.out index faac458..1ed1a05 100644 --- a/Tests/expected/cosmosEditService.out +++ b/Tests/expected/cosmosEditService.out @@ -2,7 +2,7 @@ CosmOS > echo remembered by the shell remembered by the shell > load Edit.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run typed.txt typed.txt, new file > a diff --git a/Tests/expected/cosmosFault.out b/Tests/expected/cosmosFault.out index 77179ca..90d8634 100644 --- a/Tests/expected/cosmosFault.out +++ b/Tests/expected/cosmosFault.out @@ -1,18 +1,18 @@ CosmOS > Crash opcode -that byte is not an instruction, at 4081 +that byte is not an instruction, at 5081 A 00 B 0F Q 00 the program was stopped > Crash service -nothing is installed at service 28, at 4084 +nothing is installed at service 28, at 5084 A 00 B 0F Q 00 the program was stopped > Crash bank -a bank that is not there, or an address past its end, at 409E +a bank that is not there, or an address past its end, at 509E A 01 B 0F Q 00 the program was stopped > Crash device -nothing is installed for the device on port 00, at 40A5 +nothing is installed for the device on port 00, at 50A5 A 02 B 0F Q 00 the program was stopped > Crash sideways diff --git a/Tests/expected/cosmosHello.out b/Tests/expected/cosmosHello.out index f3faba9..2ffbeb5 100644 --- a/Tests/expected/cosmosHello.out +++ b/Tests/expected/cosmosHello.out @@ -1,6 +1,6 @@ CosmOS > load hello.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run Hello, World! finished diff --git a/Tests/expected/cosmosKeys.out b/Tests/expected/cosmosKeys.out index 328f0ef..26de017 100644 --- a/Tests/expected/cosmosKeys.out +++ b/Tests/expected/cosmosKeys.out @@ -1,6 +1,6 @@ CosmOS > load Keys.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run keys, by interrupt. q stops. ab diff --git a/Tests/expected/cosmosLife.out b/Tests/expected/cosmosLife.out index f3a3b14..c97ef99 100644 --- a/Tests/expected/cosmosLife.out +++ b/Tests/expected/cosmosLife.out @@ -1,6 +1,6 @@ CosmOS > load Life.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run  # # diff --git a/Tests/expected/cosmosLifeKey.out b/Tests/expected/cosmosLifeKey.out index b9524a6..872fc39 100644 --- a/Tests/expected/cosmosLifeKey.out +++ b/Tests/expected/cosmosLifeKey.out @@ -1,6 +1,6 @@ CosmOS > load Life.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run  # # diff --git a/Tests/expected/cosmosMonitor.out b/Tests/expected/cosmosMonitor.out index c8cbb7e..38d53ab 100644 --- a/Tests/expected/cosmosMonitor.out +++ b/Tests/expected/cosmosMonitor.out @@ -6,30 +6,30 @@ b * b 9 there is no such bank * load greet.sbx -loaded, starting at 4000 +loaded, starting at 5000 * b program bank 00 * d 4000 -4000 47 00 20 00 SETD.0 2000 -4004 72 10 SWI 10 -4006 47 00 20 44 SETD.0 2044 -400A 72 10 SWI 10 -400C 47 00 20 7A SETD.0 207A -4010 27 1F INIB 1F -4012 72 11 SWI 11 -4014 47 00 20 5D SETD.0 205D +4000 00 ? +4001 00 ? +4002 00 ? +4003 00 ? +4004 00 ? +4005 00 ? +4006 00 ? +4007 00 ? * x 4000 -4000 47 00 20 00 72 10 47 00 20 44 72 10 47 00 20 7A G. .r.G. Dr.G. z -4010 27 1F 72 11 47 00 20 5D 72 10 47 00 20 7A 72 10 '.r.G. ]r.G. zr. -4020 47 00 20 65 72 10 20 72 12 00 00 00 00 00 00 00 G. er. r........ +4000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +4010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +4020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 4030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * b data bank 01 * x 2000 -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 +2000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +2010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +2020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ +2030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * b 2 bank 02 * x 0 diff --git a/Tests/expected/cosmosMonitorRun.out b/Tests/expected/cosmosMonitorRun.out index 5b58768..90b821c 100644 --- a/Tests/expected/cosmosMonitorRun.out +++ b/Tests/expected/cosmosMonitorRun.out @@ -5,7 +5,7 @@ x examine, d disassemble, a assemble, s set, b bank, g go, exit leaves it says: hello from the monitor finished * Crash opcode -that byte is not an instruction, at 4081 +that byte is not an instruction, at 5081 A 00 B 0F Q 00 the program was stopped * nonsense diff --git a/Tests/expected/cosmosMore.out b/Tests/expected/cosmosMore.out index e1c3c41..8fdd2e8 100644 --- a/Tests/expected/cosmosMore.out +++ b/Tests/expected/cosmosMore.out @@ -1,6 +1,6 @@ CosmOS > load More.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run readable.txt first line second line diff --git a/Tests/expected/cosmosRun.out b/Tests/expected/cosmosRun.out index 47fd19a..34b855e 100644 --- a/Tests/expected/cosmosRun.out +++ b/Tests/expected/cosmosRun.out @@ -31,7 +31,7 @@ no such file > load notes.txt not a program > load greet.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run a program, loaded off a disk, running on the system that loaded it what should I call you? Anachronaut diff --git a/Tests/expected/cosmosSay.out b/Tests/expected/cosmosSay.out index 8c6e031..66f9bb6 100644 --- a/Tests/expected/cosmosSay.out +++ b/Tests/expected/cosmosSay.out @@ -1,6 +1,6 @@ CosmOS > load Say.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run nothing was said finished diff --git a/Tests/expected/cosmosServices.out b/Tests/expected/cosmosServices.out index 025c06a..eb99776 100644 --- a/Tests/expected/cosmosServices.out +++ b/Tests/expected/cosmosServices.out @@ -1,6 +1,6 @@ CosmOS > load Files.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run saved it read it back, 22 bytes: diff --git a/Tests/expected/cosmosSlowDisk.out b/Tests/expected/cosmosSlowDisk.out index fc38ef5..da7f5ff 100644 --- a/Tests/expected/cosmosSlowDisk.out +++ b/Tests/expected/cosmosSlowDisk.out @@ -23,7 +23,7 @@ inner.script 44 loop.script 35 20 files, 1 directory > load Say.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run the disk took its time it says: the disk took its time finished diff --git a/Tests/expected/cosmosSnake.out b/Tests/expected/cosmosSnake.out index d3fe86c..8bc3386 100644 --- a/Tests/expected/cosmosSnake.out +++ b/Tests/expected/cosmosSnake.out @@ -1,6 +1,6 @@ CosmOS > load Snake.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run +----------------+ | | diff --git a/Tests/expected/cosmosSource.out b/Tests/expected/cosmosSource.out index bfe6011..2448aac 100644 --- a/Tests/expected/cosmosSource.out +++ b/Tests/expected/cosmosSource.out @@ -1,6 +1,6 @@ CosmOS > load readTest.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run hello.asm ; 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. diff --git a/Tests/expected/cosmosStream.out b/Tests/expected/cosmosStream.out index 0aa600c..28ff6d0 100644 --- a/Tests/expected/cosmosStream.out +++ b/Tests/expected/cosmosStream.out @@ -1,6 +1,6 @@ CosmOS > load Stream.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run big.txt is 329 blocks read 329 blocks, checksum 57368, stopped with 3 diff --git a/Tests/expected/cosmosTokens.out b/Tests/expected/cosmosTokens.out index 4f29671..330dadb 100644 --- a/Tests/expected/cosmosTokens.out +++ b/Tests/expected/cosmosTokens.out @@ -1,6 +1,6 @@ CosmOS > load tokenTest.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run hello.asm 4 keyword 0 [#Program] 6 label: 0 [Start:] diff --git a/Tests/expected/cosmosTree.out b/Tests/expected/cosmosTree.out index 4782c5f..e6adb1c 100644 --- a/Tests/expected/cosmosTree.out +++ b/Tests/expected/cosmosTree.out @@ -4,22 +4,22 @@ Apps rooted.txt 21 1 file, 1 directory > load /Apps/Say.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run the shallow one it says: the shallow one finished > load /Apps/Deep/Say.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run the deep one Hello, World! finished > load /Apps/./Deep/../Say.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run the shallow one again it says: the shallow one again finished > load /Apps/Deep/../../Apps/./Deep/Say.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run the deep one the long way round Hello, World! finished diff --git a/Tests/expected/cosmosTreeWrite.out b/Tests/expected/cosmosTreeWrite.out index 6014cc4..0791ab2 100644 --- a/Tests/expected/cosmosTreeWrite.out +++ b/Tests/expected/cosmosTreeWrite.out @@ -4,7 +4,7 @@ Folder Edit.sbx 2243 1 file, 1 directory > load Edit.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run note.txt note.txt, new file > a diff --git a/Tests/expected/cosmosType.out b/Tests/expected/cosmosType.out index fedc460..d63f2d1 100644 --- a/Tests/expected/cosmosType.out +++ b/Tests/expected/cosmosType.out @@ -1,6 +1,6 @@ CosmOS > load Type.sbx -loaded, starting at 4000 +loaded, starting at 5000 > run readable.txt first line second line