diff options
| author | hachem <im@hachem.wtf> | 2026-09-09 05:14:44 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-09 05:14:44 +0200 |
| commit | 8b76d35b0a045e0a3277be422513b938ef33dcce (patch) | |
| tree | b876d92ba3afb810e38f3f83792fc3fb849dd457 /scripts/test_examples.sh | |
| parent | b9eff51ee157b22d8fa46aeecac7b95d5ed345d9 (diff) | |
feat: fasm backend
Diffstat (limited to 'scripts/test_examples.sh')
| -rwxr-xr-x | scripts/test_examples.sh | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scripts/test_examples.sh b/scripts/test_examples.sh index f8d1462..ab4f184 100755 --- a/scripts/test_examples.sh +++ b/scripts/test_examples.sh @@ -17,13 +17,24 @@ if [ ! -x "$hdass" ]; then exit 1 fi -for tool in nasm ld; do +assembler="${ASSEMBLER:-nasm}" + +for tool in "$assembler" ld; do if ! command -v "$tool" >/dev/null 2>&1; then echo "${red}error:${reset} '$tool' not found; run this inside the Docker environment" >&2 exit 1 fi done +assemble() +{ + if [ "$assembler" = "fasm" ]; then + fasm "$1" "$2" >/dev/null + else + nasm -f elf64 "$1" -o "$2" + fi +} + work="$(mktemp -d)" trap 'rm -rf "$work"' EXIT @@ -35,9 +46,9 @@ check() local name="$1" desc="$2" source="$3" expected_exit="$4" expected_stdout="$5" local asm="$work/$name.asm" obj="$work/$name.o" bin="$work/$name" stage="" - if ! "$hdass" "$source" -o "$asm" 2>"$work/err"; then + if ! "$hdass" -t "$assembler" "$source" -o "$asm" 2>"$work/err"; then stage="transpile" - elif ! nasm -f elf64 "$asm" -o "$obj" 2>"$work/err"; then + elif ! assemble "$asm" "$obj" 2>"$work/err"; then stage="assemble" elif ! ld -e main "$obj" -o "$bin" 2>"$work/err"; then stage="link" @@ -71,7 +82,7 @@ check() pass=$((pass + 1)) } -printf '%s━━ example programs ━━%s\n' "$bold" "$reset" +printf '%s━━ example programs (%s) ━━%s\n' "$bold" "$assembler" "$reset" check hello_world "writes a greeting to stdout" examples/hello_world.hdass 0 "Hello, World!" check greet "writes a fixed string" examples/greet.hdass 0 "hdass works!" |
