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:
co-authored by
Claude Opus 5
parent
36a1b07b5b
commit
588e02aff5
@@ -22,7 +22,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Banner
|
||||
@@ -50,7 +50,7 @@ deeper:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Banner:
|
||||
"two stops, and what the registers were at each
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 FileName
|
||||
@@ -780,7 +780,7 @@ addByteToWord:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Break:
|
||||
0x0A 0x00
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; Swap ValueB and ValueA.
|
||||
@@ -71,7 +71,7 @@ start:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
ValueA:
|
||||
; Low byte, high byte.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; Swap ValueB and ValueA.
|
||||
@@ -127,7 +127,7 @@ start:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
ValueA:
|
||||
; Lowest byte ... Highest byte.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; Load our initial values into A and B.
|
||||
@@ -38,6 +38,6 @@ start:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
#Include print.asm
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; ---- Write it ----
|
||||
@@ -127,7 +127,7 @@ noDelete:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Name:
|
||||
"kept.txt"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
CIF ; Nothing arrives until there is something to catch it.
|
||||
@@ -82,7 +82,7 @@ keyStop:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Banner:
|
||||
"keys, by interrupt. q stops."
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
CALL seedGlider
|
||||
@@ -348,7 +348,7 @@ delayDone:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
RowCount:
|
||||
0x00
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#Include services.asm
|
||||
#Program
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Name
|
||||
@@ -127,7 +127,7 @@ finished:
|
||||
SWI osExit
|
||||
|
||||
#Data
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
Usage:
|
||||
"more: give me a file name
|
||||
"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Given
|
||||
@@ -44,7 +44,7 @@ sayEnd:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
SaidText:
|
||||
"it says: "
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
RSTA
|
||||
@@ -139,7 +139,7 @@ printCandidateHex:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
; 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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; Search the list until we find a prime.
|
||||
@@ -45,7 +45,7 @@ start:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
; 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,
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; The two pointers whose low byte is a square number. Both regions are page aligned, so
|
||||
@@ -605,7 +605,7 @@ pauseInner:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
HeadCell:
|
||||
0x00
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
; ---- 1. How big is something that will not fit ----
|
||||
@@ -404,7 +404,7 @@ printWhy:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
BigName:
|
||||
"big.txt"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#Include services.asm
|
||||
#Program
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Name
|
||||
@@ -62,7 +62,7 @@ finished:
|
||||
SWI osExit
|
||||
|
||||
#Data
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
Usage:
|
||||
"type: give me a file name
|
||||
"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000 ; Above the system, which keeps below here.
|
||||
#Base 0x4000 ; Above the system, which keeps below here.
|
||||
|
||||
greet:
|
||||
SETD.0 Opening
|
||||
@@ -43,7 +43,7 @@ greet:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000 ; And its data above the system's.
|
||||
#Base 0x2000 ; And its data above the system's.
|
||||
|
||||
Opening:
|
||||
"a program, loaded off a disk, running on the system that loaded it
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000 ; Change two:
|
||||
#Base 0x4000 ; Change two:
|
||||
|
||||
SETD hello ; Change three
|
||||
Start:
|
||||
@@ -25,6 +25,6 @@ End:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000 ; Five, adjust the base of the data segment.
|
||||
#Base 0x2000 ; 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!"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Argument
|
||||
@@ -1915,7 +1915,7 @@ report:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Argument:
|
||||
#Reserve 0d23
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Wanted
|
||||
@@ -60,7 +60,7 @@ noFile:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Wanted:
|
||||
#Reserve 0d23
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#Program
|
||||
|
||||
#Base 0x2000
|
||||
#Base 0x4000
|
||||
|
||||
start:
|
||||
SETD.0 Wanted
|
||||
@@ -128,7 +128,7 @@ noFile:
|
||||
|
||||
#Data
|
||||
|
||||
#Base 0x1000
|
||||
#Base 0x2000
|
||||
|
||||
Wanted:
|
||||
#Reserve 0d23
|
||||
|
||||
@@ -322,8 +322,16 @@ CosmOS divides the two SplitBit address spaces by convention:
|
||||
|
||||
| Memory | CosmOS | Loaded application |
|
||||
| -- | -- | -- |
|
||||
| Program Memory | `0x0000` through `0x1FFF` | `0x2000` and above |
|
||||
| Data Memory | `0x0000` through `0x0FFF` | `0x1000` and above |
|
||||
| Program Memory | `0x0000` through `0x3FFF` | `0x4000` and above |
|
||||
| Data Memory | `0x0000` through `0x3FFF` | `0x2000` and above |
|
||||
|
||||
Both of CosmOS's halves were doubled once it outgrew the first ones. **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.
|
||||
|
||||
|
||||
Applications state their actual Program and Data addresses with `#Base`. The SplitBit
|
||||
assembler then writes an SBEX loadable image containing those addresses, the entry point,
|
||||
|
||||
Reference in New Issue
Block a user