Programs can now pin specific routines to specific vectors in SplitBit assembly. Added snake game.
This commit is contained in:
@@ -103,6 +103,34 @@ else:
|
||||
problems.append("%s (0x%02X) is a device class and has no row in the Devices"
|
||||
" table" % (name, value))
|
||||
|
||||
# ---- The vector ranges the manuals quote are the ones the assembler uses ----
|
||||
#
|
||||
# Both manuals print the boundary between numbers a program may pin and numbers the
|
||||
# assembler hands out. Those are two constants in one header, and moving them without
|
||||
# touching the manuals would leave every programmer reading a range that no longer exists
|
||||
# and being refused a number the manual said was theirs.
|
||||
header = read("Source/Assembler/assembly.h")
|
||||
ranges = {name: int(value)
|
||||
for name, value in re.findall(r'^#define (VECTOR_FIRST_[A-Z]+)\s+(\d+)$',
|
||||
header, re.M)}
|
||||
if set(ranges) != {"VECTOR_FIRST_PINNED", "VECTOR_FIRST_AUTO"}:
|
||||
problems.append("the vector range constants are not the two this check knows about: %s"
|
||||
% ", ".join(sorted(ranges)) if ranges else "none found")
|
||||
else:
|
||||
pinnedFrom = ranges["VECTOR_FIRST_PINNED"]
|
||||
autoFrom = ranges["VECTOR_FIRST_AUTO"]
|
||||
said = "%d to %d" % (pinnedFrom, autoFrom - 1)
|
||||
for manual, text in [("Programming Manual", pm), ("Assembler Manual", am)]:
|
||||
if said not in text:
|
||||
problems.append("the %s does not say the pinned vectors are %s"
|
||||
% (manual, said))
|
||||
if "%d and up" % autoFrom not in pm:
|
||||
problems.append("the Programming Manual does not say the automatic vectors start"
|
||||
" at %d" % autoFrom)
|
||||
if "from vector %d upwards" % autoFrom not in am:
|
||||
problems.append("the Assembler Manual does not say the automatic vectors start"
|
||||
" at %d" % autoFrom)
|
||||
|
||||
# ---- 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
|
||||
|
||||
@@ -3,8 +3,9 @@ CosmOS
|
||||
> greet.sbx 210
|
||||
hello.sbx 52
|
||||
Life.sbx 1411
|
||||
Snake.sbx 2175
|
||||
notes.txt 21
|
||||
4 files
|
||||
5 files
|
||||
> load what?
|
||||
> no such file
|
||||
> not a program
|
||||
@@ -16,5 +17,5 @@ finished
|
||||
what should I call you? hello, Claude. that is all I do.
|
||||
finished
|
||||
> halted
|
||||
Execution halted after 11647 cycles.
|
||||
Execution halted after 12778 cycles.
|
||||
[exit 0]
|
||||
|
||||
@@ -0,0 +1,293 @@
|
||||
CosmOS
|
||||
> loaded, starting at 2000
|
||||
> [2J[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| ## |
|
||||
| @ |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| # |
|
||||
| # |
|
||||
| @ |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| # |
|
||||
| # |
|
||||
| @ |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| # |
|
||||
| # |
|
||||
| @ |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| # |
|
||||
| # |
|
||||
| @ |
|
||||
| * |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| # |
|
||||
| # |
|
||||
| * @ |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| # |
|
||||
| * @# |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * @## |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * @## |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * @## |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| *@## |
|
||||
| |
|
||||
+----------------+
|
||||
score 0 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| @### |
|
||||
| |
|
||||
+----------------+
|
||||
score 1 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| @### |
|
||||
| |
|
||||
+----------------+
|
||||
score 1 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
|@### |
|
||||
| |
|
||||
+----------------+
|
||||
score 1 wasd steers, q stops
|
||||
[H+----------------+
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| * |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
| |
|
||||
|@### |
|
||||
| |
|
||||
+----------------+
|
||||
score 1 wasd steers, q stops
|
||||
you ran into something
|
||||
finished
|
||||
>
|
||||
halted
|
||||
Execution halted after 1910669 cycles.
|
||||
[exit 0]
|
||||
@@ -0,0 +1,7 @@
|
||||
pinned vectors
|
||||
twenty
|
||||
sixty three
|
||||
automatic
|
||||
done
|
||||
Execution halted after 272 cycles.
|
||||
[exit 0]
|
||||
@@ -0,0 +1,3 @@
|
||||
load Snake.sbx
|
||||
run
|
||||
ssssssaaaaaa
|
||||
@@ -74,6 +74,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/Life.asm" -o "$WORK/Life.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Life.sbx" >/dev/null
|
||||
# Snake.sbx is the one that is played rather than watched. It reads the console a key at a
|
||||
# time without ever waiting for one, so a script of moves drives it a move to a frame, and
|
||||
# what is recorded is a whole game: turning, eating, growing, and running into a wall.
|
||||
"$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
|
||||
printf 'this is not a program' > notes.txt
|
||||
"$TOOL" put "$DISKS/cosmos.img" notes.txt >/dev/null
|
||||
|
||||
|
||||
@@ -130,6 +130,12 @@ interruptFlagTest | testPrograms/interruptFlagTest.asm | run | -
|
||||
# These are the interrupt path end to end. Until #Vectors existed, none of them could
|
||||
# be written as a source file at all, because nothing could install a handler.
|
||||
vectorTest | testPrograms/vectorTest.asm | run | - | -
|
||||
# Numbers written down and numbers handed out, in one program. A vector number only matters
|
||||
# where two separately assembled programs have to agree about it, so those are pinned by
|
||||
# hand from a range the assembler never allocates, and everything else is drawn from above
|
||||
# it. This pins both ends of that range and leaves a third to the assembler, then calls all
|
||||
# three by name: a number going astray shows up as the wrong word rather than as silence.
|
||||
pinnedVectorTest | testPrograms/pinnedVectorTest.asm | run | - | -
|
||||
deviceTest | testPrograms/deviceTest.asm | run | - | -
|
||||
faultResumeTest | testPrograms/faultResumeTest.asm | run | - | -
|
||||
# The worked example out of the Assembler Manual, so the manual cannot go stale.
|
||||
@@ -219,11 +225,18 @@ cosmosLife | CosmOS/Source/cosmos.asm | run | cosmosLif
|
||||
# 54. The two together are what say the poll is reading the console rather than always
|
||||
# answering the same way.
|
||||
cosmosLifeKey | CosmOS/Source/cosmos.asm | run | cosmosLifeKey.in | - | disks/cosmos.img
|
||||
# A whole game of Snake, played by a script. Life is watched; this is steered, and it is
|
||||
# the first program on this machine that reads the console without ever waiting for it.
|
||||
# One key is taken per frame, so twelve bytes in the pipe are twelve moves rather than
|
||||
# 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
|
||||
# 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 | - | -
|
||||
|
||||
# ---- Programs driven by console input ----
|
||||
inputTest | inputTest.asm | run | inputTest.in | -
|
||||
@@ -261,6 +274,11 @@ diagDuplicateLabel | testPrograms/diagnostics/duplicateLabel.asm | xfail | -
|
||||
diagBareInclude | testPrograms/diagnostics/bareInclude.asm | xfail | - | -
|
||||
diagUnknownVector | testPrograms/diagnostics/unknownVector.asm | xfail | - | -
|
||||
diagDuplicateVector | testPrograms/diagnostics/duplicateVector.asm | xfail | - | -
|
||||
# The two mistakes that pinning a number makes possible. Numbers the assembler hands out
|
||||
# cannot collide; numbers a person writes down can, and can also be written outside the
|
||||
# range set aside for them.
|
||||
diagPinnedRange | testPrograms/diagnostics/pinnedVectorRange.asm | xfail | - | -
|
||||
diagPinnedTaken | testPrograms/diagnostics/pinnedVectorTaken.asm | xfail | - | -
|
||||
diagBareSWI | testPrograms/diagnostics/bareSWI.asm | xfail | - | -
|
||||
diagAlignOutside | testPrograms/diagnostics/alignOutside.asm | xfail | - | -
|
||||
diagBareAlign | testPrograms/diagnostics/bareAlign.asm | xfail | - | -
|
||||
|
||||
Reference in New Issue
Block a user