Long standing assembler bugs fixed, new path system. Make compatibility update.

This commit is contained in:
Anachronaut
2026-08-14 16:53:28 -04:00
parent 94b3a7af28
commit 638b68b25c
32 changed files with 1002 additions and 273 deletions
+4
View File
@@ -0,0 +1,4 @@
Hello
World
H
Execution halted after 79 cycles.
+5
View File
@@ -0,0 +1,5 @@
one
two
three
AFTER
Execution halted after 122 cycles.
+34 -31
View File
@@ -4,11 +4,10 @@
# One test per line, fields separated by '|'. Blank lines and lines starting
# with '#' are ignored.
#
# name | source | assemble-from | mode | stdin | limit
# name | source | mode | stdin | limit
#
# source and assemble-from are both relative to Programs/. assemble-from exists
# because #Include paths resolve against the current directory rather than
# against the including file, so each program has one directory it builds in.
# source is relative to Programs/. Everything assembles from there with
# Libraries/ on the include path, and the binary is written into Tests/build.
#
# Modes:
# run Assemble, execute, compare all output against Tests/expected/<name>.out
@@ -23,43 +22,47 @@
# on what a program prints.
# ---- Programs that halt on their own ----
hello | hello.asm | . | run | - | -
printHello | printHello.asm | . | run | - | -
8bitFibonacci | Fibonacci/8bitFibonacci.asm | . | run | - | -
16bitFibonacci | Fibonacci/16bitFibonacci.asm | . | run | - | -
32bitFibonacci | Fibonacci/32bitFibonacci.asm | . | run | - | -
8bitSieve | primeSieve/8bitSieve.asm | primeSieve | run | - | -
16bitSegmentedSieve | primeSieve/16bitSegmentedSieve.asm | . | run | - | -
mathTest | testPrograms/mathTest.asm | testPrograms | run | - | -
printTest | testPrograms/printTest.asm | testPrograms | run | - | -
int16print | Libraries/int16print.asm | Libraries | run | - | -
hello | hello.asm | run | - | -
printHello | printHello.asm | run | - | -
8bitFibonacci | Fibonacci/8bitFibonacci.asm | run | - | -
16bitFibonacci | Fibonacci/16bitFibonacci.asm | run | - | -
32bitFibonacci | Fibonacci/32bitFibonacci.asm | run | - | -
8bitSieve | primeSieve/8bitSieve.asm | run | - | -
16bitSegmentedSieve | primeSieve/16bitSegmentedSieve.asm | run | - | -
mathTest | testPrograms/mathTest.asm | run | - | -
printTest | testPrograms/printTest.asm | run | - | -
int16print | Libraries/int16print.asm | run | - | -
# ---- The multiple Data Pointer behaviour, which nothing else exercises ----
dataPointerTest | testPrograms/dataPointerTest.asm | testPrograms | run | - | -
twoPointerCopy | testPrograms/twoPointerCopy.asm | testPrograms | run | - | -
dataPointerTest | testPrograms/dataPointerTest.asm | run | - | -
twoPointerCopy | testPrograms/twoPointerCopy.asm | run | - | -
pointerTableTest | testPrograms/pointerTableTest.asm | run | - | -
staticTableTest | testPrograms/staticTableTest.asm | run | - | -
# ---- Programs driven by console input ----
inputTest | inputTest.asm | . | run | inputTest.in | -
inputTestOld | testPrograms/inputTest.asm | testPrograms | run | inputTest.in | -
replCalculator | replCalculator.asm | . | run | replCalculator.in | -
inputTest | inputTest.asm | run | inputTest.in | -
inputTestOld | testPrograms/inputTest.asm | run | inputTest.in | -
replCalculator | replCalculator.asm | run | replCalculator.in | -
# ---- Programs that run forever by design, bounded by a cycle count ----
# 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
16x16Life | gameOfLife/16x16Life.asm | run | - | 3000000
# ---- Libraries: no entry point, so only check that they assemble ----
lib-int8 | Libraries/int8.asm | . | assemble | - | -
lib-int16 | Libraries/int16.asm | . | assemble | - | -
lib-int32 | Libraries/int32.asm | . | assemble | - | -
lib-math | Libraries/math.asm | . | assemble | - | -
lib-int8 | Libraries/int8.asm | assemble | - | -
lib-int16 | Libraries/int16.asm | assemble | - | -
lib-int32 | Libraries/int32.asm | assemble | - | -
lib-math | Libraries/math.asm | assemble | - | -
# ---- Known breakages, recorded rather than ignored ----
# print.asm branches to 'start', which only the including program defines.
lib-print | Libraries/print.asm | . | xfail | - | -
# These three call print.asm routines but have no #Include line at all.
printDecimalTest | testPrograms/printDecimalTest.asm | testPrograms | xfail | - | -
printDigitTest | testPrograms/printDigitTest.asm | testPrograms | xfail | - | -
printHexTest | testPrograms/printHexTest.asm | testPrograms | xfail | - | -
# shiftTest includes "print.asm", which is not beside it.
shiftTest | testPrograms/shiftTest.asm | testPrograms | xfail | - | -
lib-print | Libraries/print.asm | xfail | - | -
# These three call print.asm routines but have no #Include line at all. They are
# only ever pulled in by printTest.asm, so they are not standalone programs.
printDecimalTest | testPrograms/printDecimalTest.asm | xfail | - | -
printDigitTest | testPrograms/printDigitTest.asm | xfail | - | -
printHexTest | testPrograms/printHexTest.asm | xfail | - | -
# shiftTest calls printDecimal, which print.asm does not have. It looks like the
# routine was renamed and this caller was never updated.
shiftTest | testPrograms/shiftTest.asm | xfail | - | -
+12 -12
View File
@@ -49,10 +49,10 @@ for tool in "$ASSEMBLER" "$EMULATOR"; do
fi
done
PROGRAMS="$ROOT/Programs"
rm -rf "$BUILD"
mkdir -p "$BUILD" "$EXPECTED"
cp -r "$ROOT/Programs/." "$BUILD/"
find "$BUILD" -name '*.bin' -delete
PASS=0
FAIL=0
@@ -104,30 +104,30 @@ check() {
}
assemble() {
# assemble <source> <assemble-from>; echoes the built binary path on success
local src="$1" dir="$2"
local wd="$BUILD/$dir" rel bin
rel="$(realpath --relative-to="$wd" "$BUILD/$src")"
bin="$wd/$(basename "${src%.asm}").bin"
if ( cd "$wd" && "$ASSEMBLER" "$rel" ) >"$BUILD/.assemble.log" 2>&1; then
# assemble <name> <source>; echoes the built binary path on success.
# Everything builds from Programs/ with Libraries/ on the include path, and the
# binary goes to Tests/build, so the source tree is never written to.
local name="$1" src="$2"
local bin="$BUILD/$name.bin"
if ( cd "$PROGRAMS" && "$ASSEMBLER" -I Libraries -o "$bin" "$src" ) >"$BUILD/.assemble.log" 2>&1; then
echo "$bin"
return 0
fi
return 1
}
while IFS='|' read -r name src dir mode stdin limit; do
while IFS='|' read -r name src mode stdin limit; do
name="$(trim "$name")"
[ -z "$name" ] && continue
case "$name" in \#*) continue ;; esac
src="$(trim "$src")"; dir="$(trim "$dir")"
src="$(trim "$src")"
mode="$(trim "$mode")"; stdin="$(trim "$stdin")"
limit="$(trim "$limit")"
wanted "$name" || continue
if [ "$mode" = "xfail" ]; then
if assemble "$src" "$dir" >/dev/null; then
if assemble "$name" "$src" >/dev/null; then
FAIL=$((FAIL + 1)); FAILED_NAMES+=("$name")
report "FAIL" "$name" "expected assembly to fail, but it succeeded"
else
@@ -137,7 +137,7 @@ while IFS='|' read -r name src dir mode stdin limit; do
continue
fi
if ! BIN="$(assemble "$src" "$dir")"; then
if ! BIN="$(assemble "$name" "$src")"; then
FAIL=$((FAIL + 1)); FAILED_NAMES+=("$name")
report "FAIL" "$name" "assembly failed"
head -3 "$BUILD/.assemble.log" | tr -d '\033' | sed 's/\[[0-9;]*m//g' | sed 's/^/ /'