The sixteen kilobytes taken back a moment ago all went to the output image, because that was the wall: 13,245 bytes of cosmos.bin against 13,312. Lifting it moved the machine straight into the next one, a hundred and eleven bytes away - the label names, at 8,081 of 8,192 - and the index was a hundred and eighteen entries from the same place. So the room is shared out rather than given to the obvious one. Names and index both double, and the output takes what is left, which is still four and a half thousand bytes more than CosmOS needs. LabLimit and LabRoom in labels.asm have to agree with the map in scratch.asm and are now said to. Worth recording how this was found, because it is the good case. The assembler STOPPED and said "no room left for label names: Mode, at line 3598" - a limit it checks, names, and points at. Every other ceiling this project has hit went unnoticed until something downstream broke: a program loaded over the shell, a path silently cut short, a file reported as itself less 65,536. A limit that announces itself is worth the handful of instructions it costs. The output's eighteen kilobytes are temporary. They exist because the assembler holds a whole finished file in memory before writing it, and the file is produced in order, so it could be written as it is made. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
76 lines
3.9 KiB
NASM
76 lines
3.9 KiB
NASM
; Where the assembler's big buffers live.
|
|
;
|
|
; A map rather than a set of declarations, and it has a file of its own because the reader
|
|
; and the label table both need addresses out of it while neither includes the other.
|
|
;
|
|
#Data
|
|
|
|
; NOT #Reserve, AND THAT IS THE WHOLE POINT. Reserved space in a segment is written into
|
|
; the file as zeroes and copied at load, so 22K of scratch made a 34K file - and a loaded
|
|
; program is staged at 0x8000 before being put in place, which leaves exactly 32,768 bytes
|
|
; for the whole of it. The assembler could not load itself.
|
|
;
|
|
; 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 0x1000, 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.
|
|
;
|
|
; 0x4000 6144 the label index, 1536 entries of four
|
|
; 0x5800 16384 the label names, packed end to end
|
|
; 0x9800 18432 the output file being built
|
|
; 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
|
|
;
|
|
; IT USED TO START AT 0x8000, and the reason given was that everything above the
|
|
; assembler's own data is free. That was true when it was written and stopped being true
|
|
; without anything noticing: the system kept below 0x1000 then, and its data now reaches
|
|
; 0x1FFF, and the assembler's own moved from 0x1000 to 0x2000 with it. The floor came up
|
|
; 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 4,114 bytes 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.
|
|
;
|
|
; THE ROOM WENT TO ALL THREE OF THE BUFFERS THAT WERE FULL, and there turned out to be
|
|
; three rather than one. The output was the obvious wall - cosmos.bin was 13,245 bytes
|
|
; against 13,312, which is sixty seven - so it was given the lot, and the very next thing
|
|
; added to the system ran out of LABEL NAMES instead, at 8,081 of 8,192. Two ceilings a
|
|
; hundred bytes apart look like one ceiling until the first is lifted.
|
|
;
|
|
; The index was a hundred and eighteen entries from the same place. So: names doubled,
|
|
; index doubled, and the output given what is left, which is still four and a half thousand
|
|
; bytes more than CosmOS needs today.
|
|
;
|
|
; The output's share is temporary. It exists only because the assembler holds a whole
|
|
; finished file in memory before writing it, and that is the next thing to go - the file is
|
|
; produced in order and could be written as it is made, which would leave this needing three
|
|
; blocks rather than eighteen kilobytes.
|
|
;
|
|
; That ends at 0xF070, with the Stack coming down from 0xFFFF above it - nearly four
|
|
; kilobytes, against the tens of bytes of CALL frames this ever nests.
|
|
;
|
|
; The reader's levels went from 293 to 301 when an include gained somewhere to be looked
|
|
; for: the name in each level is a PATH now, and "/Lib/" is five characters of it. Six
|
|
; levels of 301 is 1806, so the room here has to stay above that - which is why the include
|
|
; list moved up rather than the stack simply being asked to fit.
|
|
;
|
|
; THE TWO THINGS THAT DECIDE THESE SIZES are the largest program it will be asked to build
|
|
; and the largest one it will be asked to read. CosmOS is 475 labels and 9,564 bytes of
|
|
; output; the assembler itself is 555 labels, about 6,800 bytes of name and 11,648 of output. The
|
|
; 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
|
|
ScratchLabArena:
|
|
0x58 0x00
|
|
ScratchImage:
|
|
0x98 0x00
|
|
ScratchVecNames:
|
|
0xE0 0x00
|
|
ScratchSrcStack:
|
|
0xE7 0x00
|
|
ScratchIncNames:
|
|
0xEF 0x00
|