Files
vt1200/tools/as34/test.sh
T
arti 6338095683 tools: add as34/ld34 TMS34010 binutils, ported to 64-bit Linux
Andrew Morton's Unix-hosted assembler/linker for the TMS34010, fetched from the gsptools archive and patched to build on x86-64. The K&R sources silently truncate pointers there: implicit int parameter declarations and fixed-argument printf wrappers. The patch fixes those and the flex 2.6 yy_init mismatch.

hello.as34.g is harness/hello-world/hello.asm in as34 syntax. as34/ld34 reproduce the GSPA-built payload byte-for-byte (82 bytes, md5 db91788991ebba476b55a11127a36475), and the MAME hello.lua run reports the same markers, the same 1024-word VRAM block and a byte-identical frame.

build.sh downloads the upstream tarball at build time (sha256 pinned); the tree is not vendored.
2026-10-22 14:19:14 +03:00

66 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# Assemble hello.as34.g with as34, link it with ld34, extract .text, then
# compare against the TI-GSPA-built payload and (optionally) run MAME.
#
# tools/as34/test.sh
# REPO=$PWD MAME=/path/to/vt1200 tools/as34/test.sh
#
# Without REPO/MAME only the byte comparison runs.
set -eu
here=$(cd "$(dirname "$0")" && pwd)
builddir=${AS34_BUILD_DIR:-"$here/build"}
as34="$builddir/src/gsp/binutils/as34/as34"
ld34="$builddir/src/gsp/binutils/ld34/ld34"
if [ ! -x "$as34" ] || [ ! -x "$ld34" ]; then
echo "tools not built; run tools/as34/build.sh first" >&2
exit 1
fi
work="$builddir/work"
mkdir -p "$work" "$work/evidence"
cp "$here/hello.as34.g" "$work/hello.as34.g"
cd "$work"
"$as34" hello.as34.g
"$ld34" -c -T 1800000 -e_start hello.as34.go -o hello.out -m hello.map
python3 "$here/extract.py" hello.out hello.bin
echo
if [ -n "${REPO:-}" ] && [ -f "$REPO/harness/hello-world/payload.bin" ]; then
expected="$REPO/harness/hello-world/payload.bin"
else
expected="$here/expected-payload.bin"
fi
if cmp hello.bin "$expected"; then
echo "PASS: hello.bin is byte-identical to $expected"
else
echo "FAIL: hello.bin differs from $expected" >&2
exit 1
fi
if [ -n "${MAME:-}" ] && [ -n "${REPO:-}" ]; then
echo
echo "running MAME acceptance test"
out=$(cd "$REPO" && HELLO_END=150 HELLO_PAYLOAD="$work/hello.bin" \
VT1200_DUMP_FRAME=145 VT1200_DUMP_RAM=145 \
VT1200_DUMP_DIR="$work/evidence" \
"$MAME" vt1200 -rompath harness/mame/roms -video none -sound none \
-nothrottle -debug -debugger none \
-autoboot_script harness/mame/hello.lua -autoboot_delay 0 2>&1)
echo "$out" | grep -E "MAGIC|COUNT|VRAM block|PC at|lit ="
if echo "$out" | grep -q "WRONG"; then
echo "FAIL: MAME reported WRONG" >&2
exit 1
fi
if ! echo "$out" | grep -q "1024 stores ok"; then
echo "FAIL: counter did not reach 0x400" >&2
exit 1
fi
if ! echo "$out" | grep -q "VRAM block 1024/1024 words are FFFF, 0 holes"; then
echo "FAIL: VRAM block not complete" >&2
exit 1
fi
echo "PASS: MAME markers and VRAM block"
fi