Delete a comment describing a design that was removed, and check the rest

Two comments in the native assembler survived the changes that made them
false, and both are the kind that misleads rather than merely ages.

Asm.asm still explained an eighteen kilobyte buffer that the whole output
had to fit in "because a file is written in one call and there is nowhere
to put half of one" - which stopped being true when the assembler learned
to stream, and the variable it described, ImgRoom, does not exist any more.
It was sitting in front of the comment that replaced it, so the paragraph a
reader met first described the design that had been taken out. Replaced by
what is actually there: no limit but the disk, one block at a time through
a window in scratch.

scratch.asm said the system keeps below 0x1000 twelve lines above the
paragraph explaining that the system's half of Data Memory was doubled to
0x1FFF. A stale number next to its own correction is worse than a stale
number alone, because which one a reader believes is a coin toss.

docs.sh now checks both of the facts scratch.asm asserts about the machine
around it: the floor it claims the system keeps below, against the CosmOS
README, and the address its buffers start at, against where the assembler's
own data actually ends. Neither is enforced by a line of code anywhere -
the map is a comment, deliberately, because reserving the buffers would put
22K of zeroes in the file and the assembler could not load itself - so a
check is the only thing that can hold them. Both fail when broken; the
second reports the exact overlap.
This commit is contained in:
Anachronaut
2026-08-26 10:28:14 -04:00
parent c74075dc51
commit 6b41354f8f
3 changed files with 68 additions and 15 deletions
+41
View File
@@ -539,6 +539,47 @@ else:
"cosmos.asm says the system keeps below 0x%s in %s Memory and the CosmOS"
" README says 0x%04X" % (stated[kind].upper(), kind, limits[kind] - 1))
# ---- The assembler's scratch map sits above what it says it sits above ----
#
# scratch.asm is a MAP rather than a set of declarations: the buffers are not reserved,
# they are addresses written in a comment, because reserving them would put 22K of zeroes
# in the file and the assembler could not load itself. Nothing enforces a word of it.
#
# So it carries two claims about the machine around it, and both have gone stale once. It
# said the system keeps below 0x1000 for a while after the system's half of Data Memory
# was doubled - twelve lines above the paragraph explaining the doubling. And the map
# starts at 0x4000 on the grounds that the assembler's own data ends well before there,
# which was measured on the day and is not measured again by anything.
scratch = open("Programs/CosmOS/Assembler/scratch.asm").read()
floor = re.search(r"the system keeps\s*;?\s*below 0x([0-9A-Fa-f]{4})", scratch)
if not floor:
problems.append("scratch.asm no longer says what the system keeps below")
elif "Data" in limits and int(floor.group(1), 16) + 1 != limits["Data"]:
problems.append(
"the assembler's scratch map says the system keeps below 0x%s and the CosmOS"
" README says 0x%04X" % (floor.group(1).upper(), limits["Data"] - 1))
first = re.search(r"^;\s+0x([0-9A-Fa-f]{4})\s+\d+\s+the label index", scratch, re.M)
if not first:
problems.append("scratch.asm no longer states where its buffers begin")
else:
built = subprocess.run(["./Assembler", "-I", "Programs/CosmOS/Source",
"-I", "Programs/CosmOS/Assembler",
"Programs/CosmOS/Assembler/Asm.asm", "-o", os.devnull],
capture_output=True, text=True)
# A loadable program reports "Data: N bytes at 0xAAAA"; a boot image says it another
# way. The assembler is the former, and the address matters as much as the size.
said = re.search(r"Data:\s*(\d+) bytes at 0x([0-9A-Fa-f]{4})", built.stdout)
if not said:
problems.append("could not measure the native assembler's data")
else:
ends = int(said.group(2), 16) + int(said.group(1))
if ends > int(first.group(1), 16):
problems.append(
"the native assembler's data reaches 0x%04X and its scratch map begins at"
" 0x%s - the buffers are on top of the variables"
% (ends - 1, first.group(1).upper()))
if problems:
print("The manuals and the code disagree:")
for p in problems: