Programs can now list and share vectors.

This commit is contained in:
Anachronaut
2026-08-17 21:39:27 -04:00
parent a842c884e8
commit 1d1a14318c
18 changed files with 537 additions and 27 deletions
+29
View File
@@ -131,6 +131,35 @@ else:
problems.append("the Assembler Manual does not say the automatic vectors start"
" at %d" % autoFrom)
# ---- The loadable header table matches the offsets the assembler writes ----
#
# The Programming Manual prints the header field by field, which is the description two
# implementations work from. sbex.h is where the offsets actually are, so a field moved
# there and not here would leave the manual describing a format nobody writes.
sbex = read("Source/Assembler/sbex.h")
offsets = {name: int(value)
for name, value in re.findall(r'^#define (SBEX_[A-Z_]+_AT)\s+(\d+)$', sbex, re.M)}
if "## Loading A Program From A Disk:" not in pm:
problems.append("the Programming Manual has lost its loadable program section")
else:
loading = pm.split("## Loading A Program From A Disk:")[1].split("\n## ")[0]
listed = [int(m) for m in re.findall(r'^\| (\d+) \| \d* \|', loading, re.M)]
for name, offset in sorted(offsets.items(), key=lambda pair: pair[1]):
if offset not in listed:
problems.append("%s is at offset %d and the header table has no row for it"
% (name, offset))
# Spelled as a word, the way these manuals write small numbers in prose.
asWord = {1: "one", 2: "two", 3: "three", 4: "four", 5: "five"}
for version in ("SBEX_VERSION", "SBEX_VERSION_VECTORS"):
number = re.search(r'^#define %s\s+(\d+)$' % version, sbex, re.M)
if not number:
problems.append("%s is gone from sbex.h" % version)
continue
said = asWord.get(int(number.group(1)))
if said is None or said not in loading.lower():
problems.append("the loadable program section does not mention version %s (%s)"
% (number.group(1), said))
# ---- Every console status bit is described ----
#
# The status port is read by writing a mask and testing it, so a program can only use a bit
+1 -1
View File
@@ -19,5 +19,5 @@ CosmOS
0020 00 FF 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 ................
0030 00 FF 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 ................
> halted
Execution halted after 23498 cycles.
Execution halted after 23512 cycles.
[exit 0]
+1 -1
View File
@@ -5,5 +5,5 @@ finished
> Hello, World!
finished
> halted
Execution halted after 2668 cycles.
Execution halted after 2702 cycles.
[exit 0]
+17
View File
@@ -0,0 +1,17 @@
CosmOS
> loaded, starting at 2000
> keys, by interrupt. q stops.
ab
the console has been handed back
finished
> > keys, by interrupt. q stops.
cd
the console has been handed back
finished
> > FE00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
FE10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
FE20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
FE30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> halted
Execution halted after 10055 cycles.
[exit 0]
+1 -1
View File
@@ -869,5 +869,5 @@ the board has settled
finished
>
halted
Execution halted after 11671206 cycles.
Execution halted after 11671230 cycles.
[exit 0]
+1 -1
View File
@@ -21,5 +21,5 @@ stopped
finished
> >
halted
Execution halted after 26219 cycles.
Execution halted after 26243 cycles.
[exit 0]
+3 -2
View File
@@ -4,8 +4,9 @@ CosmOS
hello.sbx 52
Life.sbx 1411
Snake.sbx 2175
Keys.sbx 663
notes.txt 21
5 files
6 files
> load what?
> no such file
> not a program
@@ -17,5 +18,5 @@ finished
what should I call you? hello, Claude. that is all I do.
finished
> halted
Execution halted after 12778 cycles.
Execution halted after 14083 cycles.
[exit 0]
+1 -1
View File
@@ -289,5 +289,5 @@ you ran into something
finished
>
halted
Execution halted after 1910669 cycles.
Execution halted after 1910693 cycles.
[exit 0]
+7
View File
@@ -0,0 +1,7 @@
load Keys.sbx
run
abq
run
cdq
dump program fe00
exit
+6
View File
@@ -80,6 +80,12 @@ for i in 1 2 3 4 5 6 7 8; do "$TOOL" put "$DISKS/sbfs.img" "filler$i.txt" >/dev/
"$ROOT/Assembler" -I "$ROOT/Programs/Libraries" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/Snake.asm" -o "$WORK/Snake.sbx" >/dev/null
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Snake.sbx" >/dev/null
# Keys.sbx brings a vector of its own, which is what the version two format exists for. It
# is the only program here the system has to install anything for, so it is what says the
# whole path works: written into the file, installed at run, taken back out at exit.
"$ROOT/Assembler" -I "$ROOT/Programs/Libraries" -I "$ROOT/Programs/CosmOS/Source" \
"$ROOT/Programs/CosmOS/Apps/Keys.asm" -o "$WORK/Keys.sbx" >/dev/null
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Keys.sbx" >/dev/null
printf 'this is not a program' > notes.txt
"$TOOL" put "$DISKS/cosmos.img" notes.txt >/dev/null
+8
View File
@@ -231,12 +231,20 @@ cosmosLifeKey | CosmOS/Source/cosmos.asm | run | cosmosLif
# twelve moves at once: six turn it down the board and six take it left onto the food. So
# what is recorded is a turn, a meal, a longer snake, and then a wall.
cosmosSnake | CosmOS/Source/cosmos.asm | run | cosmosSnake.in | - | disks/cosmos.img
# A loaded program that brings a vector of its own, which nothing could do until the
# loadable format could carry one. It is run TWICE on purpose: installing has to be exactly
# undone by removing, and the way that fails is asymmetrically, so the second run is the one
# that catches it. The dump afterwards is the proof that the table was put back - the
# console's slot at FE00 is zero again, and CosmOS's own disk handler further along is
# untouched by a program having installed over the top of it.
cosmosKeys | CosmOS/Source/cosmos.asm | run | cosmosKeys.in | - | disks/cosmos.img
# The programs CosmOS loads, checked on their own so that a failure here reads as "the app
# does not assemble" rather than as a broken disk image.
app-greet | CosmOS/Apps/greet.asm | assemble | - | -
app-hello | CosmOS/Apps/hello.asm | assemble | - | -
app-Life | CosmOS/Apps/Life.asm | assemble | - | -
app-Snake | CosmOS/Apps/Snake.asm | assemble | - | -
app-Keys | CosmOS/Apps/Keys.asm | assemble | - | -
# ---- Programs driven by console input ----
inputTest | inputTest.asm | run | inputTest.in | -