Interrupt system implemented, some new programs.

This commit is contained in:
Anachronaut
2026-08-15 00:44:13 -04:00
parent 638b68b25c
commit 6d1966d500
79 changed files with 2778 additions and 88 deletions
+1
View File
@@ -1,2 +1,3 @@
0000 0001 0001 0002 0003 0005 0008 000D 0015 0022 0037 0059 0090 00E9 0179 0262 03DB 063D 0A18 1055 1A6D 2AC2 452F 6FF1
Execution halted after 2534 cycles.
[exit 0]
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -223,3 +223,4 @@
Execution stopped after 3000000 cycles. (cycle limit reached)
[exit 0]
+226
View File
@@ -0,0 +1,226 @@
 #
#
###

# #
##
#

#
# #
##

#
##
##

#
#
###

# #
##
#

#
# #
##

#
##
##

#
#
###

# #
##
#

#
# #
##

#
##
##

#
#
###

# #
##
#
Execution stopped after 3000000 cycles. (cycle limit reached)
[exit 0]
+1
View File
@@ -1,2 +1,3 @@
00000000 00000001 00000001 00000002 00000003 00000005 00000008 0000000D 00000015 00000022 00000037 00000059 00000090 000000E9 00000179 00000262 000003DB 0000063D 00000A18 00001055 00001A6D 00002AC2 0000452F 00006FF1 0000B520 00012511 0001DA31 0002FF42 0004D973 0007D8B5 000CB228 00148ADD 00213D05 0035C7E2 005704E7 008CCCC9 00E3D1B0 01709E79 02547029 03C50EA2 06197ECB 09DE8D6D 0FF80C38 19D699A5 29CEA5DD 43A53F82 6D73E55F
Execution halted after 10610 cycles.
[exit 0]
+1
View File
@@ -1,2 +1,3 @@
0 1 1 2 3 5 8 13 21 34 55 89 144 233
Execution halted after 1506 cycles.
[exit 0]
+1
View File
@@ -1,2 +1,3 @@
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251
Execution halted after 54061 cycles.
[exit 0]
+1
View File
@@ -1,2 +1,3 @@
ABCZ
Execution halted after 21 cycles.
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
O
K
!
Execution halted after 19 cycles.
[exit 0]
+6
View File
@@ -0,0 +1,6 @@
one
two
three
done
Execution halted after 126 cycles.
[exit 0]
+4
View File
@@ -0,0 +1,4 @@
O
K
Execution halted after 17 cycles.
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
Fault: 0xFE at Program Address 0x0002 is not an instruction.
Execution halted after 2 cycles.
[exit 1]
+1
View File
@@ -1,2 +1,3 @@
Hello, World!
Execution halted after 70 cycles.
[exit 0]
+1
View File
@@ -1,3 +1,4 @@
Input Test: Will echo anything you put in.
Hello SplitBit
Execution halted after 406 cycles.
[exit 0]
+1
View File
@@ -1,3 +1,4 @@
Input Test: Will echo anything you put in.
Hello SplitBit
Execution halted after 406 cycles.
[exit 0]
+1
View File
@@ -1,3 +1,4 @@
00 00 00 00 01
1
Execution halted after 4707 cycles.
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
ready
trap
device
Execution halted after 105 cycles.
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
OKC
Execution halted after 19 cycles.
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
Fault: The device on port 16 interrupted at Program Address 0x0019, and hardware vector 16 has no handler installed.
M
S
Execution halted after 16 cycles.
[exit 1]
+1
View File
@@ -1,2 +1,3 @@
0000 0032
Execution halted after 1134 cycles.
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
AAA
Execution halted after 24 cycles.
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
00 31
Execution halted after 78 cycles.
[exit 0]
+1
View File
@@ -2,3 +2,4 @@ Hello
World
H
Execution halted after 79 cycles.
[exit 0]
+1
View File
@@ -1,3 +1,4 @@
Hello, World!
42 is the great answer.
Execution halted after 295 cycles.
[exit 0]
+1
View File
@@ -10,3 +10,4 @@ Testing printByteHex...
Testing complete!
Execution halted after 71185 cycles.
[exit 0]
+1
View File
@@ -14,3 +14,4 @@ SplitBit calculator (+ - * & | ^), Q quits.
> 18
> Goodbye!Execution halted after 2960 cycles.
[exit 0]
+3
View File
@@ -0,0 +1,3 @@
OK
Execution halted after 14 cycles.
[exit 0]
+1
View File
@@ -3,3 +3,4 @@ two
three
AFTER
Execution halted after 122 cycles.
[exit 0]
+4
View File
@@ -0,0 +1,4 @@
Fault: Software vector 20, dispatched from Program Address 0x0008, has no handler installed.
O
Execution halted after 5 cycles.
[exit 1]
+1
View File
@@ -1,2 +1,3 @@
Two pointers, no stack shenanigans.
Execution halted after 395 cycles.
[exit 0]
+5
View File
@@ -0,0 +1,5 @@
OK!
good
AFTER
Execution halted after 77 cycles.
[exit 0]
+62
View File
@@ -29,6 +29,9 @@ printHello | printHello.asm | run | -
32bitFibonacci | Fibonacci/32bitFibonacci.asm | run | - | -
8bitSieve | primeSieve/8bitSieve.asm | run | - | -
16bitSegmentedSieve | primeSieve/16bitSegmentedSieve.asm | run | - | -
# The four pointer rewrite. It emits exactly the same primes as the line above, which
# is the whole point of keeping both: the pair is a direct before and after.
16bitSegmentedSieveModern | primeSieve/16bitSegmentedSieveModern.asm | run | - | -
mathTest | testPrograms/mathTest.asm | run | - | -
printTest | testPrograms/printTest.asm | run | - | -
int16print | Libraries/int16print.asm | run | - | -
@@ -38,6 +41,47 @@ dataPointerTest | testPrograms/dataPointerTest.asm | run | -
twoPointerCopy | testPrograms/twoPointerCopy.asm | run | - | -
pointerTableTest | testPrograms/pointerTableTest.asm | run | - | -
staticTableTest | testPrograms/staticTableTest.asm | run | - | -
dispatchTest | testPrograms/dispatchTest.asm | run | - | -
# ---- Moving an ALU result back into an operand register ----
moveQTest | testPrograms/moveQTest.asm | run | - | -
# ---- Moving the cursor along ----
paddingTest | testPrograms/paddingTest.asm | run | - | -
# ---- Finding the Stack ----
stackPointerTest | testPrograms/stackPointerTest.asm | run | - | -
# ---- The Interrupt Flag ----
# Nothing reads the flag yet. This checks that setting and clearing it leaves
# the registers and the Carry Flag it shares a byte with untouched.
interruptFlagTest | testPrograms/interruptFlagTest.asm | run | - | -
# ---- Vectors laid down by the assembler ----
# 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 | - | -
deviceTest | testPrograms/deviceTest.asm | run | - | -
faultResumeTest | testPrograms/faultResumeTest.asm | run | - | -
# The worked example out of the Assembler Manual, so the manual cannot go stale.
interruptExample | testPrograms/interruptExample.asm | run | - | -
# ---- Holding a device off, and then letting it through ----
# Faults on purpose. The fault is the proof that the line was answered, and where it
# lands in the output is the proof of when.
maskTest | testPrograms/maskTest.asm | run | - | -
# ---- Dispatching through a vector with nothing in it ----
# Also meant to fault. Until the assembler can lay a vector table down, every entry
# reads as zero, so this is the only half of the interrupt path a source file can
# reach on its own. The round trip through a handler is covered by hand built
# binaries until #Vectors arrives.
swiFaultTest | testPrograms/swiFaultTest.asm | run | - | -
# ---- Meeting a byte that is not an instruction ----
# This one is meant to fault. It checks the CPU stops, says what it found and
# where, and exits non zero, rather than stepping over it and carrying on.
faultTest | testPrograms/faultTest.asm | run | - | -
# ---- Programs driven by console input ----
inputTest | inputTest.asm | run | inputTest.in | -
@@ -48,6 +92,12 @@ replCalculator | replCalculator.asm | run | replCalcu
# 3,000,000 cycles is about fourteen generations of the glider, which puts
# evolveBoard and its pointer juggling through its paces many times over.
16x16Life | gameOfLife/16x16Life.asm | run | - | 3000000
# The four pointer rewrite, on the same budget so the two can be compared directly.
# Note that this cannot show a speed difference: frameDelay is 255 by 255 and swamps
# the simulation, so both versions render the same fourteen generations and produce
# identical bytes. What it checks is that the rewrite still evolves the board the same
# way, which is what a regression test is for.
16x16LifeModern | gameOfLife/16x16LifeModern.asm | run | - | 3000000
# ---- Libraries: no entry point, so only check that they assemble ----
lib-int8 | Libraries/int8.asm | assemble | - | -
@@ -55,6 +105,18 @@ lib-int16 | Libraries/int16.asm | assemble | -
lib-int32 | Libraries/int32.asm | assemble | - | -
lib-math | Libraries/math.asm | assemble | - | -
# ---- Deliberately broken, to check the assembler still diagnoses them ----
# These are not programs anyone meant to run. Each one contains a single mistake
# that the assembler used to accept quietly, and is here so that it cannot start
# being accepted quietly again.
diagDuplicateLabel | testPrograms/diagnostics/duplicateLabel.asm | xfail | - | -
diagBareInclude | testPrograms/diagnostics/bareInclude.asm | xfail | - | -
diagUnknownVector | testPrograms/diagnostics/unknownVector.asm | xfail | - | -
diagDuplicateVector | testPrograms/diagnostics/duplicateVector.asm | xfail | - | -
diagBareSWI | testPrograms/diagnostics/bareSWI.asm | xfail | - | -
diagAlignOutside | testPrograms/diagnostics/alignOutside.asm | xfail | - | -
diagBareAlign | testPrograms/diagnostics/bareAlign.asm | xfail | - | -
# ---- Known breakages, recorded rather than ignored ----
# print.asm branches to 'start', which only the including program defines.
lib-print | Libraries/print.asm | xfail | - | -
+8 -1
View File
@@ -166,11 +166,18 @@ while IFS='|' read -r name src mode stdin limit; do
# bounds them by cycle count rather than by wall clock.
EMUARGS=(--fast)
[ "$limit" != "-" ] && EMUARGS+=(--cycles "$limit")
if ! timeout "$RUN_TIMEOUT" "$EMULATOR" "${EMUARGS[@]}" "$BIN" <"$IN" >"$OUT" 2>&1; then
timeout "$RUN_TIMEOUT" "$EMULATOR" "${EMUARGS[@]}" "$BIN" <"$IN" >"$OUT" 2>&1
STATUS=$?
if [ "$STATUS" -eq 124 ]; then
FAIL=$((FAIL + 1)); FAILED_NAMES+=("$name")
report "FAIL" "$name" "did not finish within ${RUN_TIMEOUT}s"
continue
fi
# What a program exits with is part of what it does, so it is recorded
# with the output rather than thrown away. A program that faults is
# supposed to exit non zero, and that should be just as pinned down as
# what it printed.
printf '[exit %d]\n' "$STATUS" >> "$OUT"
check "$name" "$OUT"
;;
*)